1 \input texinfo @c -*-texinfo-*-
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
7 @c GNAT DOCUMENTATION o
11 @c Copyright (C) 1995-2008, Free Software Foundation o
14 @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o
16 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
18 @setfilename gnat_rm.info
21 @set DEFAULTLANGUAGEVERSION Ada 2005
22 @set NONDEFAULTLANGUAGEVERSION Ada 95
24 @settitle GNAT Reference Manual
26 @setchapternewpage odd
29 @include gcc-common.texi
31 @dircategory GNU Ada tools
33 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
37 Copyright @copyright{} 1995-2008, Free Software Foundation, Inc.
39 Permission is granted to copy, distribute and/or modify this document
40 under the terms of the GNU Free Documentation License, Version 1.2
41 or any later version published by the Free Software Foundation;
42 with the Invariant Sections being ``GNU Free Documentation License'',
43 with the Front-Cover Texts being ``GNAT Reference Manual'', and with
44 no Back-Cover Texts. A copy of the license is included in the section
45 entitled ``GNU Free Documentation License''.
49 @title GNAT Reference Manual
50 @subtitle GNAT, The GNU Ada Compiler
54 @vskip 0pt plus 1filll
61 @node Top, About This Guide, (dir), (dir)
62 @top GNAT Reference Manual
68 GNAT, The GNU Ada Compiler@*
69 GCC version @value{version-GCC}@*
76 * Implementation Defined Pragmas::
77 * Implementation Defined Attributes::
78 * Implementation Advice::
79 * Implementation Defined Characteristics::
80 * Intrinsic Subprograms::
81 * Representation Clauses and Pragmas::
82 * Standard Library Routines::
83 * The Implementation of Standard I/O::
85 * Interfacing to Other Languages::
86 * Specialized Needs Annexes::
87 * Implementation of Specific Ada Features::
88 * Project File Reference::
89 * Obsolescent Features::
90 * GNU Free Documentation License::
93 --- The Detailed Node Listing ---
97 * What This Reference Manual Contains::
98 * Related Information::
100 Implementation Defined Pragmas
102 * Pragma Abort_Defer::
110 * Pragma C_Pass_By_Copy::
112 * Pragma Check_Name::
113 * Pragma Check_Policy::
115 * Pragma Common_Object::
116 * Pragma Compile_Time_Error::
117 * Pragma Compile_Time_Warning::
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::
139 * Pragma External_Name_Casing::
141 * Pragma Favor_Top_Level::
142 * Pragma Finalize_Storage_Only::
143 * Pragma Float_Representation::
145 * Pragma Implemented_By_Entry::
146 * Pragma Implicit_Packing::
147 * Pragma Import_Exception::
148 * Pragma Import_Function::
149 * Pragma Import_Object::
150 * Pragma Import_Procedure::
151 * Pragma Import_Valued_Procedure::
152 * Pragma Initialize_Scalars::
153 * Pragma Inline_Always::
154 * Pragma Inline_Generic::
156 * Pragma Interface_Name::
157 * Pragma Interrupt_Handler::
158 * Pragma Interrupt_State::
159 * Pragma Keep_Names::
162 * Pragma Linker_Alias::
163 * Pragma Linker_Constructor::
164 * Pragma Linker_Destructor::
165 * Pragma Linker_Section::
166 * Pragma Long_Float::
167 * Pragma Machine_Attribute::
169 * Pragma Main_Storage::
172 * Pragma No_Strict_Aliasing ::
173 * Pragma Normalize_Scalars::
174 * Pragma Obsolescent::
175 * Pragma Optimize_Alignment::
177 * Pragma Persistent_BSS::
179 * Pragma Postcondition::
180 * Pragma Precondition::
181 * Pragma Profile (Ravenscar)::
182 * Pragma Profile (Restricted)::
183 * Pragma Psect_Object::
184 * Pragma Pure_Function::
185 * Pragma Restriction_Warnings::
187 * Pragma Source_File_Name::
188 * Pragma Source_File_Name_Project::
189 * Pragma Source_Reference::
190 * Pragma Stream_Convert::
191 * Pragma Style_Checks::
194 * Pragma Suppress_All::
195 * Pragma Suppress_Exception_Locations::
196 * Pragma Suppress_Initialization::
199 * Pragma Task_Storage::
200 * Pragma Time_Slice::
202 * Pragma Unchecked_Union::
203 * Pragma Unimplemented_Unit::
204 * Pragma Universal_Aliasing ::
205 * Pragma Universal_Data::
206 * Pragma Unmodified::
207 * Pragma Unreferenced::
208 * Pragma Unreferenced_Objects::
209 * Pragma Unreserve_All_Interrupts::
210 * Pragma Unsuppress::
211 * Pragma Use_VADS_Size::
212 * Pragma Validity_Checks::
215 * Pragma Weak_External::
216 * Pragma Wide_Character_Encoding::
218 Implementation Defined Attributes
228 * Default_Bit_Order::
238 * Has_Access_Values::
239 * Has_Discriminants::
246 * Max_Interrupt_Priority::
248 * Maximum_Alignment::
253 * Passed_By_Reference::
266 * Unconstrained_Array::
267 * Universal_Literal_String::
268 * Unrestricted_Access::
274 The Implementation of Standard I/O
276 * Standard I/O Packages::
282 * Wide_Wide_Text_IO::
285 * Filenames encoding::
287 * Operations on C Streams::
288 * Interfacing to C Streams::
292 * Ada.Characters.Latin_9 (a-chlat9.ads)::
293 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
294 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
295 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
296 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
297 * Ada.Command_Line.Environment (a-colien.ads)::
298 * Ada.Command_Line.Remove (a-colire.ads)::
299 * Ada.Command_Line.Response_File (a-clrefi.ads)::
300 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
301 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
302 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
303 * Ada.Exceptions.Traceback (a-exctra.ads)::
304 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
305 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
306 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
307 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
308 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
309 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
310 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
311 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
312 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
313 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
314 * GNAT.Altivec (g-altive.ads)::
315 * GNAT.Altivec.Conversions (g-altcon.ads)::
316 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
317 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
318 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
319 * GNAT.Array_Split (g-arrspl.ads)::
320 * GNAT.AWK (g-awk.ads)::
321 * GNAT.Bounded_Buffers (g-boubuf.ads)::
322 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
323 * GNAT.Bubble_Sort (g-bubsor.ads)::
324 * GNAT.Bubble_Sort_A (g-busora.ads)::
325 * GNAT.Bubble_Sort_G (g-busorg.ads)::
326 * GNAT.Byte_Order_Mark (g-byorma.ads)::
327 * GNAT.Byte_Swapping (g-bytswa.ads)::
328 * GNAT.Calendar (g-calend.ads)::
329 * GNAT.Calendar.Time_IO (g-catiio.ads)::
330 * GNAT.Case_Util (g-casuti.ads)::
331 * GNAT.CGI (g-cgi.ads)::
332 * GNAT.CGI.Cookie (g-cgicoo.ads)::
333 * GNAT.CGI.Debug (g-cgideb.ads)::
334 * GNAT.Command_Line (g-comlin.ads)::
335 * GNAT.Compiler_Version (g-comver.ads)::
336 * GNAT.Ctrl_C (g-ctrl_c.ads)::
337 * GNAT.CRC32 (g-crc32.ads)::
338 * GNAT.Current_Exception (g-curexc.ads)::
339 * GNAT.Debug_Pools (g-debpoo.ads)::
340 * GNAT.Debug_Utilities (g-debuti.ads)::
341 * GNAT.Decode_String (g-decstr.ads)::
342 * GNAT.Decode_UTF8_String (g-deutst.ads)::
343 * GNAT.Directory_Operations (g-dirope.ads)::
344 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
345 * GNAT.Dynamic_HTables (g-dynhta.ads)::
346 * GNAT.Dynamic_Tables (g-dyntab.ads)::
347 * GNAT.Encode_String (g-encstr.ads)::
348 * GNAT.Encode_UTF8_String (g-enutst.ads)::
349 * GNAT.Exception_Actions (g-excact.ads)::
350 * GNAT.Exception_Traces (g-exctra.ads)::
351 * GNAT.Exceptions (g-except.ads)::
352 * GNAT.Expect (g-expect.ads)::
353 * GNAT.Float_Control (g-flocon.ads)::
354 * GNAT.Heap_Sort (g-heasor.ads)::
355 * GNAT.Heap_Sort_A (g-hesora.ads)::
356 * GNAT.Heap_Sort_G (g-hesorg.ads)::
357 * GNAT.HTable (g-htable.ads)::
358 * GNAT.IO (g-io.ads)::
359 * GNAT.IO_Aux (g-io_aux.ads)::
360 * GNAT.Lock_Files (g-locfil.ads)::
361 * GNAT.MD5 (g-md5.ads)::
362 * GNAT.Memory_Dump (g-memdum.ads)::
363 * GNAT.Most_Recent_Exception (g-moreex.ads)::
364 * GNAT.OS_Lib (g-os_lib.ads)::
365 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
366 * GNAT.Random_Numbers (g-rannum.ads)::
367 * GNAT.Regexp (g-regexp.ads)::
368 * GNAT.Registry (g-regist.ads)::
369 * GNAT.Regpat (g-regpat.ads)::
370 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
371 * GNAT.Semaphores (g-semaph.ads)::
372 * GNAT.Serial_Communications (g-sercom.ads)::
373 * GNAT.SHA1 (g-sha1.ads)::
374 * GNAT.Signals (g-signal.ads)::
375 * GNAT.Sockets (g-socket.ads)::
376 * GNAT.Source_Info (g-souinf.ads)::
377 * GNAT.Spelling_Checker (g-speche.ads)::
378 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
379 * GNAT.Spitbol.Patterns (g-spipat.ads)::
380 * GNAT.Spitbol (g-spitbo.ads)::
381 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
382 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
383 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
384 * GNAT.Strings (g-string.ads)::
385 * GNAT.String_Split (g-strspl.ads)::
386 * GNAT.Table (g-table.ads)::
387 * GNAT.Task_Lock (g-tasloc.ads)::
388 * GNAT.Threads (g-thread.ads)::
389 * GNAT.Time_Stamp (g-timsta.ads)::
390 * GNAT.Traceback (g-traceb.ads)::
391 * GNAT.Traceback.Symbolic (g-trasym.ads)::
392 * GNAT.UTF_32 (g-utf_32.ads)::
393 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
394 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
395 * GNAT.Wide_String_Split (g-wistsp.ads)::
396 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
397 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
398 * Interfaces.C.Extensions (i-cexten.ads)::
399 * Interfaces.C.Streams (i-cstrea.ads)::
400 * Interfaces.CPP (i-cpp.ads)::
401 * Interfaces.Packed_Decimal (i-pacdec.ads)::
402 * Interfaces.VxWorks (i-vxwork.ads)::
403 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
404 * System.Address_Image (s-addima.ads)::
405 * System.Assertions (s-assert.ads)::
406 * System.Memory (s-memory.ads)::
407 * System.Partition_Interface (s-parint.ads)::
408 * System.Pool_Global (s-pooglo.ads)::
409 * System.Pool_Local (s-pooloc.ads)::
410 * System.Restrictions (s-restri.ads)::
411 * System.Rident (s-rident.ads)::
412 * System.Task_Info (s-tasinf.ads)::
413 * System.Wch_Cnv (s-wchcnv.ads)::
414 * System.Wch_Con (s-wchcon.ads)::
418 * Text_IO Stream Pointer Positioning::
419 * Text_IO Reading and Writing Non-Regular Files::
421 * Treating Text_IO Files as Streams::
422 * Text_IO Extensions::
423 * Text_IO Facilities for Unbounded Strings::
427 * Wide_Text_IO Stream Pointer Positioning::
428 * Wide_Text_IO Reading and Writing Non-Regular Files::
432 * Wide_Wide_Text_IO Stream Pointer Positioning::
433 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
435 Interfacing to Other Languages
438 * Interfacing to C++::
439 * Interfacing to COBOL::
440 * Interfacing to Fortran::
441 * Interfacing to non-GNAT Ada code::
443 Specialized Needs Annexes
445 Implementation of Specific Ada Features
446 * Machine Code Insertions::
447 * GNAT Implementation of Tasking::
448 * GNAT Implementation of Shared Passive Packages::
449 * Code Generation for Array Aggregates::
450 * The Size of Discriminated Records with Default Discriminants::
451 * Strict Conformance to the Ada Reference Manual::
453 Project File Reference
457 GNU Free Documentation License
464 @node About This Guide
465 @unnumbered About This Guide
468 This manual contains useful information in writing programs using the
469 @value{EDITION} compiler. It includes information on implementation dependent
470 characteristics of @value{EDITION}, including all the information required by
471 Annex M of the Ada language standard.
473 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
474 Ada 83 compatibility mode.
475 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
476 but you can override with a compiler switch
477 to explicitly specify the language version.
478 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
479 @value{EDITION} User's Guide}, for details on these switches.)
480 Throughout this manual, references to ``Ada'' without a year suffix
481 apply to both the Ada 95 and Ada 2005 versions of the language.
483 Ada is designed to be highly portable.
484 In general, a program will have the same effect even when compiled by
485 different compilers on different platforms.
486 However, since Ada is designed to be used in a
487 wide variety of applications, it also contains a number of system
488 dependent features to be used in interfacing to the external world.
489 @cindex Implementation-dependent features
492 Note: Any program that makes use of implementation-dependent features
493 may be non-portable. You should follow good programming practice and
494 isolate and clearly document any sections of your program that make use
495 of these features in a non-portable manner.
498 For ease of exposition, ``GNAT Pro'' will be referred to simply as
499 ``GNAT'' in the remainder of this document.
503 * What This Reference Manual Contains::
505 * Related Information::
508 @node What This Reference Manual Contains
509 @unnumberedsec What This Reference Manual Contains
512 This reference manual contains the following chapters:
516 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
517 pragmas, which can be used to extend and enhance the functionality of the
521 @ref{Implementation Defined Attributes}, lists GNAT
522 implementation-dependent attributes which can be used to extend and
523 enhance the functionality of the compiler.
526 @ref{Implementation Advice}, provides information on generally
527 desirable behavior which are not requirements that all compilers must
528 follow since it cannot be provided on all systems, or which may be
529 undesirable on some systems.
532 @ref{Implementation Defined Characteristics}, provides a guide to
533 minimizing implementation dependent features.
536 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
537 implemented by GNAT, and how they can be imported into user
538 application programs.
541 @ref{Representation Clauses and Pragmas}, describes in detail the
542 way that GNAT represents data, and in particular the exact set
543 of representation clauses and pragmas that is accepted.
546 @ref{Standard Library Routines}, provides a listing of packages and a
547 brief description of the functionality that is provided by Ada's
548 extensive set of standard library routines as implemented by GNAT@.
551 @ref{The Implementation of Standard I/O}, details how the GNAT
552 implementation of the input-output facilities.
555 @ref{The GNAT Library}, is a catalog of packages that complement
556 the Ada predefined library.
559 @ref{Interfacing to Other Languages}, describes how programs
560 written in Ada using GNAT can be interfaced to other programming
563 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
564 of the specialized needs annexes.
567 @ref{Implementation of Specific Ada Features}, discusses issues related
568 to GNAT's implementation of machine code insertions, tasking, and several
572 @ref{Project File Reference}, presents the syntax and semantics
576 @ref{Obsolescent Features} documents implementation dependent features,
577 including pragmas and attributes, which are considered obsolescent, since
578 there are other preferred ways of achieving the same results. These
579 obsolescent forms are retained for backwards compatibility.
583 @cindex Ada 95 Language Reference Manual
584 @cindex Ada 2005 Language Reference Manual
586 This reference manual assumes a basic familiarity with the Ada 95 language, as
587 described in the International Standard ANSI/ISO/IEC-8652:1995,
589 It does not require knowledge of the new features introduced by Ada 2005,
590 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
592 Both reference manuals are included in the GNAT documentation
596 @unnumberedsec Conventions
597 @cindex Conventions, typographical
598 @cindex Typographical conventions
601 Following are examples of the typographical and graphic conventions used
606 @code{Functions}, @code{utility program names}, @code{standard names},
613 @file{File names}, @samp{button names}, and @samp{field names}.
616 @code{Variables}, @env{environment variables}, and @var{metasyntactic
623 [optional information or parameters]
626 Examples are described by text
628 and then shown this way.
633 Commands that are entered by the user are preceded in this manual by the
634 characters @samp{$ } (dollar sign followed by space). If your system uses this
635 sequence as a prompt, then the commands will appear exactly as you see them
636 in the manual. If your system uses some other prompt, then the command will
637 appear with the @samp{$} replaced by whatever prompt character you are using.
639 @node Related Information
640 @unnumberedsec Related Information
642 See the following documents for further information on GNAT:
646 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
647 @value{EDITION} User's Guide}, which provides information on how to use the
648 GNAT compiler system.
651 @cite{Ada 95 Reference Manual}, which contains all reference
652 material for the Ada 95 programming language.
655 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
656 of the Ada 95 standard. The annotations describe
657 detailed aspects of the design decision, and in particular contain useful
658 sections on Ada 83 compatibility.
661 @cite{Ada 2005 Reference Manual}, which contains all reference
662 material for the Ada 2005 programming language.
665 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
666 of the Ada 2005 standard. The annotations describe
667 detailed aspects of the design decision, and in particular contain useful
668 sections on Ada 83 and Ada 95 compatibility.
671 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
672 which contains specific information on compatibility between GNAT and
676 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
677 describes in detail the pragmas and attributes provided by the DEC Ada 83
682 @node Implementation Defined Pragmas
683 @chapter Implementation Defined Pragmas
686 Ada defines a set of pragmas that can be used to supply additional
687 information to the compiler. These language defined pragmas are
688 implemented in GNAT and work as described in the Ada Reference
691 In addition, Ada allows implementations to define additional pragmas
692 whose meaning is defined by the implementation. GNAT provides a number
693 of these implementation-defined pragmas, which can be used to extend
694 and enhance the functionality of the compiler. This section of the GNAT
695 Reference Manual describes these additional pragmas.
697 Note that any program using these pragmas might not be portable to other
698 compilers (although GNAT implements this set of pragmas on all
699 platforms). Therefore if portability to other compilers is an important
700 consideration, the use of these pragmas should be minimized.
703 * Pragma Abort_Defer::
711 * Pragma C_Pass_By_Copy::
713 * Pragma Check_Name::
714 * Pragma Check_Policy::
716 * Pragma Common_Object::
717 * Pragma Compile_Time_Error::
718 * Pragma Compile_Time_Warning::
719 * Pragma Complete_Representation::
720 * Pragma Complex_Representation::
721 * Pragma Component_Alignment::
722 * Pragma Convention_Identifier::
724 * Pragma CPP_Constructor::
725 * Pragma CPP_Virtual::
726 * Pragma CPP_Vtable::
728 * Pragma Debug_Policy::
729 * Pragma Detect_Blocking::
730 * Pragma Elaboration_Checks::
732 * Pragma Export_Exception::
733 * Pragma Export_Function::
734 * Pragma Export_Object::
735 * Pragma Export_Procedure::
736 * Pragma Export_Value::
737 * Pragma Export_Valued_Procedure::
738 * Pragma Extend_System::
740 * Pragma External_Name_Casing::
742 * Pragma Favor_Top_Level::
743 * Pragma Finalize_Storage_Only::
744 * Pragma Float_Representation::
746 * Pragma Implemented_By_Entry::
747 * Pragma Implicit_Packing::
748 * Pragma Import_Exception::
749 * Pragma Import_Function::
750 * Pragma Import_Object::
751 * Pragma Import_Procedure::
752 * Pragma Import_Valued_Procedure::
753 * Pragma Initialize_Scalars::
754 * Pragma Inline_Always::
755 * Pragma Inline_Generic::
757 * Pragma Interface_Name::
758 * Pragma Interrupt_Handler::
759 * Pragma Interrupt_State::
760 * Pragma Keep_Names::
763 * Pragma Linker_Alias::
764 * Pragma Linker_Constructor::
765 * Pragma Linker_Destructor::
766 * Pragma Linker_Section::
767 * Pragma Long_Float::
768 * Pragma Machine_Attribute::
770 * Pragma Main_Storage::
773 * Pragma No_Strict_Aliasing::
774 * Pragma Normalize_Scalars::
775 * Pragma Obsolescent::
776 * Pragma Optimize_Alignment::
778 * Pragma Persistent_BSS::
780 * Pragma Postcondition::
781 * Pragma Precondition::
782 * Pragma Profile (Ravenscar)::
783 * Pragma Profile (Restricted)::
784 * Pragma Psect_Object::
785 * Pragma Pure_Function::
786 * Pragma Restriction_Warnings::
788 * Pragma Source_File_Name::
789 * Pragma Source_File_Name_Project::
790 * Pragma Source_Reference::
791 * Pragma Stream_Convert::
792 * Pragma Style_Checks::
795 * Pragma Suppress_All::
796 * Pragma Suppress_Exception_Locations::
797 * Pragma Suppress_Initialization::
800 * Pragma Task_Storage::
801 * Pragma Time_Slice::
803 * Pragma Unchecked_Union::
804 * Pragma Unimplemented_Unit::
805 * Pragma Universal_Aliasing ::
806 * Pragma Universal_Data::
807 * Pragma Unmodified::
808 * Pragma Unreferenced::
809 * Pragma Unreferenced_Objects::
810 * Pragma Unreserve_All_Interrupts::
811 * Pragma Unsuppress::
812 * Pragma Use_VADS_Size::
813 * Pragma Validity_Checks::
816 * Pragma Weak_External::
817 * Pragma Wide_Character_Encoding::
820 @node Pragma Abort_Defer
821 @unnumberedsec Pragma Abort_Defer
823 @cindex Deferring aborts
831 This pragma must appear at the start of the statement sequence of a
832 handled sequence of statements (right after the @code{begin}). It has
833 the effect of deferring aborts for the sequence of statements (but not
834 for the declarations or handlers, if any, associated with this statement
838 @unnumberedsec Pragma Ada_83
847 A configuration pragma that establishes Ada 83 mode for the unit to
848 which it applies, regardless of the mode set by the command line
849 switches. In Ada 83 mode, GNAT attempts to be as compatible with
850 the syntax and semantics of Ada 83, as defined in the original Ada
851 83 Reference Manual as possible. In particular, the keywords added by Ada 95
852 and Ada 2005 are not recognized, optional package bodies are allowed,
853 and generics may name types with unknown discriminants without using
854 the @code{(<>)} notation. In addition, some but not all of the additional
855 restrictions of Ada 83 are enforced.
857 Ada 83 mode is intended for two purposes. Firstly, it allows existing
858 Ada 83 code to be compiled and adapted to GNAT with less effort.
859 Secondly, it aids in keeping code backwards compatible with Ada 83.
860 However, there is no guarantee that code that is processed correctly
861 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
862 83 compiler, since GNAT does not enforce all the additional checks
866 @unnumberedsec Pragma Ada_95
875 A configuration pragma that establishes Ada 95 mode for the unit to which
876 it applies, regardless of the mode set by the command line switches.
877 This mode is set automatically for the @code{Ada} and @code{System}
878 packages and their children, so you need not specify it in these
879 contexts. This pragma is useful when writing a reusable component that
880 itself uses Ada 95 features, but which is intended to be usable from
881 either Ada 83 or Ada 95 programs.
884 @unnumberedsec Pragma Ada_05
893 A configuration pragma that establishes Ada 2005 mode for the unit to which
894 it applies, regardless of the mode set by the command line switches.
895 This mode is set automatically for the @code{Ada} and @code{System}
896 packages and their children, so you need not specify it in these
897 contexts. This pragma is useful when writing a reusable component that
898 itself uses Ada 2005 features, but which is intended to be usable from
899 either Ada 83 or Ada 95 programs.
901 @node Pragma Ada_2005
902 @unnumberedsec Pragma Ada_2005
911 This configuration pragma is a synonym for pragma Ada_05 and has the
912 same syntax and effect.
914 @node Pragma Annotate
915 @unnumberedsec Pragma Annotate
920 pragma Annotate (IDENTIFIER @{, ARG@});
922 ARG ::= NAME | EXPRESSION
926 This pragma is used to annotate programs. @var{identifier} identifies
927 the type of annotation. GNAT verifies that it is an identifier, but does
928 not otherwise analyze it. The @var{arg} argument
929 can be either a string literal or an
930 expression. String literals are assumed to be of type
931 @code{Standard.String}. Names of entities are simply analyzed as entity
932 names. All other expressions are analyzed as expressions, and must be
935 The analyzed pragma is retained in the tree, but not otherwise processed
936 by any part of the GNAT compiler. This pragma is intended for use by
937 external tools, including ASIS@.
940 @unnumberedsec Pragma Assert
947 [, string_EXPRESSION]);
951 The effect of this pragma depends on whether the corresponding command
952 line switch is set to activate assertions. The pragma expands into code
953 equivalent to the following:
956 if assertions-enabled then
957 if not boolean_EXPRESSION then
958 System.Assertions.Raise_Assert_Failure
965 The string argument, if given, is the message that will be associated
966 with the exception occurrence if the exception is raised. If no second
967 argument is given, the default message is @samp{@var{file}:@var{nnn}},
968 where @var{file} is the name of the source file containing the assert,
969 and @var{nnn} is the line number of the assert. A pragma is not a
970 statement, so if a statement sequence contains nothing but a pragma
971 assert, then a null statement is required in addition, as in:
976 pragma Assert (K > 3, "Bad value for K");
982 Note that, as with the @code{if} statement to which it is equivalent, the
983 type of the expression is either @code{Standard.Boolean}, or any type derived
984 from this standard type.
986 If assertions are disabled (switch @option{-gnata} not used), then there
987 is no run-time effect (and in particular, any side effects from the
988 expression will not occur at run time). (The expression is still
989 analyzed at compile time, and may cause types to be frozen if they are
990 mentioned here for the first time).
992 If assertions are enabled, then the given expression is tested, and if
993 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
994 which results in the raising of @code{Assert_Failure} with the given message.
996 You should generally avoid side effects in the expression arguments of
997 this pragma, because these side effects will turn on and off with the
998 setting of the assertions mode, resulting in assertions that have an
999 effect on the program. However, the expressions are analyzed for
1000 semantic correctness whether or not assertions are enabled, so turning
1001 assertions on and off cannot affect the legality of a program.
1003 @node Pragma Ast_Entry
1004 @unnumberedsec Pragma Ast_Entry
1009 @smallexample @c ada
1010 pragma AST_Entry (entry_IDENTIFIER);
1014 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1015 argument is the simple name of a single entry; at most one @code{AST_Entry}
1016 pragma is allowed for any given entry. This pragma must be used in
1017 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1018 the entry declaration and in the same task type specification or single task
1019 as the entry to which it applies. This pragma specifies that the given entry
1020 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1021 resulting from an OpenVMS system service call. The pragma does not affect
1022 normal use of the entry. For further details on this pragma, see the
1023 DEC Ada Language Reference Manual, section 9.12a.
1025 @node Pragma C_Pass_By_Copy
1026 @unnumberedsec Pragma C_Pass_By_Copy
1027 @cindex Passing by copy
1028 @findex C_Pass_By_Copy
1031 @smallexample @c ada
1032 pragma C_Pass_By_Copy
1033 ([Max_Size =>] static_integer_EXPRESSION);
1037 Normally the default mechanism for passing C convention records to C
1038 convention subprograms is to pass them by reference, as suggested by RM
1039 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1040 this default, by requiring that record formal parameters be passed by
1041 copy if all of the following conditions are met:
1045 The size of the record type does not exceed the value specified for
1048 The record type has @code{Convention C}.
1050 The formal parameter has this record type, and the subprogram has a
1051 foreign (non-Ada) convention.
1055 If these conditions are met the argument is passed by copy, i.e.@: in a
1056 manner consistent with what C expects if the corresponding formal in the
1057 C prototype is a struct (rather than a pointer to a struct).
1059 You can also pass records by copy by specifying the convention
1060 @code{C_Pass_By_Copy} for the record type, or by using the extended
1061 @code{Import} and @code{Export} pragmas, which allow specification of
1062 passing mechanisms on a parameter by parameter basis.
1065 @unnumberedsec Pragma Check
1067 @cindex Named assertions
1071 @smallexample @c ada
1073 [Name =>] Identifier,
1074 [Check =>] Boolean_EXPRESSION
1075 [, [Message =>] string_EXPRESSION] );
1079 This pragma is similar to the predefined pragma @code{Assert} except that an
1080 extra identifier argument is present. In conjunction with pragma
1081 @code{Check_Policy}, this can be used to define groups of assertions that can
1082 be independently controlled. The identifier @code{Assertion} is special, it
1083 refers to the normal set of pragma @code{Assert} statements. The identifiers
1084 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1085 names, so these three names would normally not be used directly in a pragma
1088 Checks introduced by this pragma are normally deactivated by default. They can
1089 be activated either by the command line option @option{-gnata}, which turns on
1090 all checks, or individually controlled using pragma @code{Check_Policy}.
1092 @node Pragma Check_Name
1093 @unnumberedsec Pragma Check_Name
1094 @cindex Defining check names
1095 @cindex Check names, defining
1099 @smallexample @c ada
1100 pragma Check_Name (check_name_IDENTIFIER);
1104 This is a configuration pragma that defines a new implementation
1105 defined check name (unless IDENTIFIER matches one of the predefined
1106 check names, in which case the pragma has no effect). Check names
1107 are global to a partition, so if two or more configuration pragmas
1108 are present in a partition mentioning the same name, only one new
1109 check name is introduced.
1111 An implementation defined check name introduced with this pragma may
1112 be used in only three contexts: @code{pragma Suppress},
1113 @code{pragma Unsuppress},
1114 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1115 any of these three cases, the check name must be visible. A check
1116 name is visible if it is in the configuration pragmas applying to
1117 the current unit, or if it appears at the start of any unit that
1118 is part of the dependency set of the current unit (e.g., units that
1119 are mentioned in @code{with} clauses).
1121 @node Pragma Check_Policy
1122 @unnumberedsec Pragma Check_Policy
1123 @cindex Controlling assertions
1124 @cindex Assertions, control
1125 @cindex Check pragma control
1126 @cindex Named assertions
1130 @smallexample @c ada
1131 pragma Check_Policy ([Name =>] Identifier, POLICY_IDENTIFIER);
1133 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1137 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1138 except that it controls sets of named assertions introduced using the
1139 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1140 @code{Assertion_Policy}) can be used within a declarative part, in which case
1141 it controls the status to the end of the corresponding construct (in a manner
1142 identical to pragma @code{Suppress)}.
1144 The identifier given as the first argument corresponds to a name used in
1145 associated @code{Check} pragmas. For example, if the pragma:
1147 @smallexample @c ada
1148 pragma Check_Policy (Critical_Error, Off);
1152 is given, then subsequent @code{Check} pragmas whose first argument is also
1153 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1154 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1155 @code{Check_Policy} with this identifier is similar to the normal
1156 @code{Assertion_Policy} pragma except that it can appear within a
1159 The special identifiers @code{Precondition} and @code{Postcondition} control
1160 the status of preconditions and postconditions. If a @code{Precondition} pragma
1161 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1162 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1163 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1166 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1167 to turn on corresponding checks. The default for a set of checks for which no
1168 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1169 @option{-gnata} is given, which turns on all checks by default.
1171 The check policy settings @code{Check} and @code{Ignore} are also recognized
1172 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1173 compatibility with the standard @code{Assertion_Policy} pragma.
1175 @node Pragma Comment
1176 @unnumberedsec Pragma Comment
1181 @smallexample @c ada
1182 pragma Comment (static_string_EXPRESSION);
1186 This is almost identical in effect to pragma @code{Ident}. It allows the
1187 placement of a comment into the object file and hence into the
1188 executable file if the operating system permits such usage. The
1189 difference is that @code{Comment}, unlike @code{Ident}, has
1190 no limitations on placement of the pragma (it can be placed
1191 anywhere in the main source unit), and if more than one pragma
1192 is used, all comments are retained.
1194 @node Pragma Common_Object
1195 @unnumberedsec Pragma Common_Object
1196 @findex Common_Object
1200 @smallexample @c ada
1201 pragma Common_Object (
1202 [Internal =>] LOCAL_NAME
1203 [, [External =>] EXTERNAL_SYMBOL]
1204 [, [Size =>] EXTERNAL_SYMBOL] );
1208 | static_string_EXPRESSION
1212 This pragma enables the shared use of variables stored in overlaid
1213 linker areas corresponding to the use of @code{COMMON}
1214 in Fortran. The single
1215 object @var{LOCAL_NAME} is assigned to the area designated by
1216 the @var{External} argument.
1217 You may define a record to correspond to a series
1218 of fields. The @var{Size} argument
1219 is syntax checked in GNAT, but otherwise ignored.
1221 @code{Common_Object} is not supported on all platforms. If no
1222 support is available, then the code generator will issue a message
1223 indicating that the necessary attribute for implementation of this
1224 pragma is not available.
1226 @node Pragma Compile_Time_Error
1227 @unnumberedsec Pragma Compile_Time_Error
1228 @findex Compile_Time_Error
1232 @smallexample @c ada
1233 pragma Compile_Time_Error
1234 (boolean_EXPRESSION, static_string_EXPRESSION);
1238 This pragma can be used to generate additional compile time
1240 is particularly useful in generics, where errors can be issued for
1241 specific problematic instantiations. The first parameter is a boolean
1242 expression. The pragma is effective only if the value of this expression
1243 is known at compile time, and has the value True. The set of expressions
1244 whose values are known at compile time includes all static boolean
1245 expressions, and also other values which the compiler can determine
1246 at compile time (e.g., the size of a record type set by an explicit
1247 size representation clause, or the value of a variable which was
1248 initialized to a constant and is known not to have been modified).
1249 If these conditions are met, an error message is generated using
1250 the value given as the second argument. This string value may contain
1251 embedded ASCII.LF characters to break the message into multiple lines.
1253 @node Pragma Compile_Time_Warning
1254 @unnumberedsec Pragma Compile_Time_Warning
1255 @findex Compile_Time_Warning
1259 @smallexample @c ada
1260 pragma Compile_Time_Warning
1261 (boolean_EXPRESSION, static_string_EXPRESSION);
1265 Same as pragma Compile_Time_Error, except a warning is issued instead
1266 of an error message. Note that if this pragma is used in a package that
1267 is with'ed by a client, the client will get the warning even though it
1268 is issued by a with'ed package (normally warnings in with'ed units are
1269 suppressed, but this is a special exception to that rule).
1271 One typical use is within a generic where compile time known characteristics
1272 of formal parameters are tested, and warnings given appropriately. Another use
1273 with a first parameter of True is to warn a client about use of a package,
1274 for example that it is not fully implemented.
1276 @node Pragma Complete_Representation
1277 @unnumberedsec Pragma Complete_Representation
1278 @findex Complete_Representation
1282 @smallexample @c ada
1283 pragma Complete_Representation;
1287 This pragma must appear immediately within a record representation
1288 clause. Typical placements are before the first component clause
1289 or after the last component clause. The effect is to give an error
1290 message if any component is missing a component clause. This pragma
1291 may be used to ensure that a record representation clause is
1292 complete, and that this invariant is maintained if fields are
1293 added to the record in the future.
1295 @node Pragma Complex_Representation
1296 @unnumberedsec Pragma Complex_Representation
1297 @findex Complex_Representation
1301 @smallexample @c ada
1302 pragma Complex_Representation
1303 ([Entity =>] LOCAL_NAME);
1307 The @var{Entity} argument must be the name of a record type which has
1308 two fields of the same floating-point type. The effect of this pragma is
1309 to force gcc to use the special internal complex representation form for
1310 this record, which may be more efficient. Note that this may result in
1311 the code for this type not conforming to standard ABI (application
1312 binary interface) requirements for the handling of record types. For
1313 example, in some environments, there is a requirement for passing
1314 records by pointer, and the use of this pragma may result in passing
1315 this type in floating-point registers.
1317 @node Pragma Component_Alignment
1318 @unnumberedsec Pragma Component_Alignment
1319 @cindex Alignments of components
1320 @findex Component_Alignment
1324 @smallexample @c ada
1325 pragma Component_Alignment (
1326 [Form =>] ALIGNMENT_CHOICE
1327 [, [Name =>] type_LOCAL_NAME]);
1329 ALIGNMENT_CHOICE ::=
1337 Specifies the alignment of components in array or record types.
1338 The meaning of the @var{Form} argument is as follows:
1341 @findex Component_Size
1342 @item Component_Size
1343 Aligns scalar components and subcomponents of the array or record type
1344 on boundaries appropriate to their inherent size (naturally
1345 aligned). For example, 1-byte components are aligned on byte boundaries,
1346 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1347 integer components are aligned on 4-byte boundaries and so on. These
1348 alignment rules correspond to the normal rules for C compilers on all
1349 machines except the VAX@.
1351 @findex Component_Size_4
1352 @item Component_Size_4
1353 Naturally aligns components with a size of four or fewer
1354 bytes. Components that are larger than 4 bytes are placed on the next
1357 @findex Storage_Unit
1359 Specifies that array or record components are byte aligned, i.e.@:
1360 aligned on boundaries determined by the value of the constant
1361 @code{System.Storage_Unit}.
1365 Specifies that array or record components are aligned on default
1366 boundaries, appropriate to the underlying hardware or operating system or
1367 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1368 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1369 the @code{Default} choice is the same as @code{Component_Size} (natural
1374 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1375 refer to a local record or array type, and the specified alignment
1376 choice applies to the specified type. The use of
1377 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1378 @code{Component_Alignment} pragma to be ignored. The use of
1379 @code{Component_Alignment} together with a record representation clause
1380 is only effective for fields not specified by the representation clause.
1382 If the @code{Name} parameter is absent, the pragma can be used as either
1383 a configuration pragma, in which case it applies to one or more units in
1384 accordance with the normal rules for configuration pragmas, or it can be
1385 used within a declarative part, in which case it applies to types that
1386 are declared within this declarative part, or within any nested scope
1387 within this declarative part. In either case it specifies the alignment
1388 to be applied to any record or array type which has otherwise standard
1391 If the alignment for a record or array type is not specified (using
1392 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1393 clause), the GNAT uses the default alignment as described previously.
1395 @node Pragma Convention_Identifier
1396 @unnumberedsec Pragma Convention_Identifier
1397 @findex Convention_Identifier
1398 @cindex Conventions, synonyms
1402 @smallexample @c ada
1403 pragma Convention_Identifier (
1404 [Name =>] IDENTIFIER,
1405 [Convention =>] convention_IDENTIFIER);
1409 This pragma provides a mechanism for supplying synonyms for existing
1410 convention identifiers. The @code{Name} identifier can subsequently
1411 be used as a synonym for the given convention in other pragmas (including
1412 for example pragma @code{Import} or another @code{Convention_Identifier}
1413 pragma). As an example of the use of this, suppose you had legacy code
1414 which used Fortran77 as the identifier for Fortran. Then the pragma:
1416 @smallexample @c ada
1417 pragma Convention_Identifier (Fortran77, Fortran);
1421 would allow the use of the convention identifier @code{Fortran77} in
1422 subsequent code, avoiding the need to modify the sources. As another
1423 example, you could use this to parametrize convention requirements
1424 according to systems. Suppose you needed to use @code{Stdcall} on
1425 windows systems, and @code{C} on some other system, then you could
1426 define a convention identifier @code{Library} and use a single
1427 @code{Convention_Identifier} pragma to specify which convention
1428 would be used system-wide.
1430 @node Pragma CPP_Class
1431 @unnumberedsec Pragma CPP_Class
1433 @cindex Interfacing with C++
1437 @smallexample @c ada
1438 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1442 The argument denotes an entity in the current declarative region that is
1443 declared as a tagged record type. It indicates that the type corresponds
1444 to an externally declared C++ class type, and is to be laid out the same
1445 way that C++ would lay out the type.
1447 Types for which @code{CPP_Class} is specified do not have assignment or
1448 equality operators defined (such operations can be imported or declared
1449 as subprograms as required). Initialization is allowed only by constructor
1450 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1451 limited if not explicitly declared as limited or derived from a limited
1452 type, and a warning is issued in that case.
1454 Pragma @code{CPP_Class} is intended primarily for automatic generation
1455 using an automatic binding generator tool.
1456 See @ref{Interfacing to C++} for related information.
1458 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1459 for backward compatibility but its functionality is available
1460 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1462 @node Pragma CPP_Constructor
1463 @unnumberedsec Pragma CPP_Constructor
1464 @cindex Interfacing with C++
1465 @findex CPP_Constructor
1469 @smallexample @c ada
1470 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1471 [, [External_Name =>] static_string_EXPRESSION ]
1472 [, [Link_Name =>] static_string_EXPRESSION ]);
1476 This pragma identifies an imported function (imported in the usual way
1477 with pragma @code{Import}) as corresponding to a C++ constructor. If
1478 @code{External_Name} and @code{Link_Name} are not specified then the
1479 @code{Entity} argument is a name that must have been previously mentioned
1480 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1481 must be of one of the following forms:
1485 @code{function @var{Fname} return @var{T}'Class}
1488 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1492 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1494 The first form is the default constructor, used when an object of type
1495 @var{T} is created on the Ada side with no explicit constructor. Other
1496 constructors (including the copy constructor, which is simply a special
1497 case of the second form in which the one and only argument is of type
1498 @var{T}), can only appear in two contexts:
1502 On the right side of an initialization of an object of type @var{T}.
1504 In an extension aggregate for an object of a type derived from @var{T}.
1508 Although the constructor is described as a function that returns a value
1509 on the Ada side, it is typically a procedure with an extra implicit
1510 argument (the object being initialized) at the implementation
1511 level. GNAT issues the appropriate call, whatever it is, to get the
1512 object properly initialized.
1514 In the case of derived objects, you may use one of two possible forms
1515 for declaring and creating an object:
1518 @item @code{New_Object : Derived_T}
1519 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1523 In the first case the default constructor is called and extension fields
1524 if any are initialized according to the default initialization
1525 expressions in the Ada declaration. In the second case, the given
1526 constructor is called and the extension aggregate indicates the explicit
1527 values of the extension fields.
1529 If no constructors are imported, it is impossible to create any objects
1530 on the Ada side. If no default constructor is imported, only the
1531 initialization forms using an explicit call to a constructor are
1534 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1535 using an automatic binding generator tool.
1536 See @ref{Interfacing to C++} for more related information.
1538 @node Pragma CPP_Virtual
1539 @unnumberedsec Pragma CPP_Virtual
1540 @cindex Interfacing to C++
1543 This pragma is now obsolete has has no effect because GNAT generates
1544 the same object layout than the G++ compiler.
1546 See @ref{Interfacing to C++} for related information.
1548 @node Pragma CPP_Vtable
1549 @unnumberedsec Pragma CPP_Vtable
1550 @cindex Interfacing with C++
1553 This pragma is now obsolete has has no effect because GNAT generates
1554 the same object layout than the G++ compiler.
1556 See @ref{Interfacing to C++} for related information.
1559 @unnumberedsec Pragma Debug
1564 @smallexample @c ada
1565 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1567 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1569 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1573 The procedure call argument has the syntactic form of an expression, meeting
1574 the syntactic requirements for pragmas.
1576 If debug pragmas are not enabled or if the condition is present and evaluates
1577 to False, this pragma has no effect. If debug pragmas are enabled, the
1578 semantics of the pragma is exactly equivalent to the procedure call statement
1579 corresponding to the argument with a terminating semicolon. Pragmas are
1580 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1581 intersperse calls to debug procedures in the middle of declarations. Debug
1582 pragmas can be enabled either by use of the command line switch @option{-gnata}
1583 or by use of the configuration pragma @code{Debug_Policy}.
1585 @node Pragma Debug_Policy
1586 @unnumberedsec Pragma Debug_Policy
1587 @findex Debug_Policy
1591 @smallexample @c ada
1592 pragma Debug_Policy (CHECK | IGNORE);
1596 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1597 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1598 This pragma overrides the effect of the @option{-gnata} switch on the
1601 @node Pragma Detect_Blocking
1602 @unnumberedsec Pragma Detect_Blocking
1603 @findex Detect_Blocking
1607 @smallexample @c ada
1608 pragma Detect_Blocking;
1612 This is a configuration pragma that forces the detection of potentially
1613 blocking operations within a protected operation, and to raise Program_Error
1616 @node Pragma Elaboration_Checks
1617 @unnumberedsec Pragma Elaboration_Checks
1618 @cindex Elaboration control
1619 @findex Elaboration_Checks
1623 @smallexample @c ada
1624 pragma Elaboration_Checks (Dynamic | Static);
1628 This is a configuration pragma that provides control over the
1629 elaboration model used by the compilation affected by the
1630 pragma. If the parameter is @code{Dynamic},
1631 then the dynamic elaboration
1632 model described in the Ada Reference Manual is used, as though
1633 the @option{-gnatE} switch had been specified on the command
1634 line. If the parameter is @code{Static}, then the default GNAT static
1635 model is used. This configuration pragma overrides the setting
1636 of the command line. For full details on the elaboration models
1637 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1638 gnat_ugn, @value{EDITION} User's Guide}.
1640 @node Pragma Eliminate
1641 @unnumberedsec Pragma Eliminate
1642 @cindex Elimination of unused subprograms
1647 @smallexample @c ada
1649 [Unit_Name =>] IDENTIFIER |
1650 SELECTED_COMPONENT);
1653 [Unit_Name =>] IDENTIFIER |
1655 [Entity =>] IDENTIFIER |
1656 SELECTED_COMPONENT |
1658 [,OVERLOADING_RESOLUTION]);
1660 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1663 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1666 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1668 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1669 Result_Type => result_SUBTYPE_NAME]
1671 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1672 SUBTYPE_NAME ::= STRING_VALUE
1674 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1675 SOURCE_TRACE ::= STRING_VALUE
1677 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1681 This pragma indicates that the given entity is not used outside the
1682 compilation unit it is defined in. The entity must be an explicitly declared
1683 subprogram; this includes generic subprogram instances and
1684 subprograms declared in generic package instances.
1686 If the entity to be eliminated is a library level subprogram, then
1687 the first form of pragma @code{Eliminate} is used with only a single argument.
1688 In this form, the @code{Unit_Name} argument specifies the name of the
1689 library level unit to be eliminated.
1691 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1692 are required. If item is an entity of a library package, then the first
1693 argument specifies the unit name, and the second argument specifies
1694 the particular entity. If the second argument is in string form, it must
1695 correspond to the internal manner in which GNAT stores entity names (see
1696 compilation unit Namet in the compiler sources for details).
1698 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1699 to distinguish between overloaded subprograms. If a pragma does not contain
1700 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1701 subprograms denoted by the first two parameters.
1703 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1704 to be eliminated in a manner similar to that used for the extended
1705 @code{Import} and @code{Export} pragmas, except that the subtype names are
1706 always given as strings. At the moment, this form of distinguishing
1707 overloaded subprograms is implemented only partially, so we do not recommend
1708 using it for practical subprogram elimination.
1710 Note that in case of a parameterless procedure its profile is represented
1711 as @code{Parameter_Types => ("")}
1713 Alternatively, the @code{Source_Location} parameter is used to specify
1714 which overloaded alternative is to be eliminated by pointing to the
1715 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1716 source text. The string literal (or concatenation of string literals)
1717 given as SOURCE_TRACE must have the following format:
1719 @smallexample @c ada
1720 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1725 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1726 FILE_NAME ::= STRING_LITERAL
1727 LINE_NUMBER ::= DIGIT @{DIGIT@}
1730 SOURCE_TRACE should be the short name of the source file (with no directory
1731 information), and LINE_NUMBER is supposed to point to the line where the
1732 defining name of the subprogram is located.
1734 For the subprograms that are not a part of generic instantiations, only one
1735 SOURCE_LOCATION is used. If a subprogram is declared in a package
1736 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1737 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1738 second one denotes the declaration of the corresponding subprogram in the
1739 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1740 in case of nested instantiations.
1742 The effect of the pragma is to allow the compiler to eliminate
1743 the code or data associated with the named entity. Any reference to
1744 an eliminated entity outside the compilation unit it is defined in,
1745 causes a compile time or link time error.
1747 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1748 in a system independent manner, with unused entities eliminated, without
1749 the requirement of modifying the source text. Normally the required set
1750 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1751 tool. Elimination of unused entities local to a compilation unit is
1752 automatic, without requiring the use of pragma @code{Eliminate}.
1754 Note that the reason this pragma takes string literals where names might
1755 be expected is that a pragma @code{Eliminate} can appear in a context where the
1756 relevant names are not visible.
1758 Note that any change in the source files that includes removing, splitting of
1759 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1762 It is legal to use pragma Eliminate where the referenced entity is a
1763 dispatching operation, but it is not clear what this would mean, since
1764 in general the call does not know which entity is actually being called.
1765 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1767 @node Pragma Export_Exception
1768 @unnumberedsec Pragma Export_Exception
1770 @findex Export_Exception
1774 @smallexample @c ada
1775 pragma Export_Exception (
1776 [Internal =>] LOCAL_NAME
1777 [, [External =>] EXTERNAL_SYMBOL]
1778 [, [Form =>] Ada | VMS]
1779 [, [Code =>] static_integer_EXPRESSION]);
1783 | static_string_EXPRESSION
1787 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1788 causes the specified exception to be propagated outside of the Ada program,
1789 so that it can be handled by programs written in other OpenVMS languages.
1790 This pragma establishes an external name for an Ada exception and makes the
1791 name available to the OpenVMS Linker as a global symbol. For further details
1792 on this pragma, see the
1793 DEC Ada Language Reference Manual, section 13.9a3.2.
1795 @node Pragma Export_Function
1796 @unnumberedsec Pragma Export_Function
1797 @cindex Argument passing mechanisms
1798 @findex Export_Function
1803 @smallexample @c ada
1804 pragma Export_Function (
1805 [Internal =>] LOCAL_NAME
1806 [, [External =>] EXTERNAL_SYMBOL]
1807 [, [Parameter_Types =>] PARAMETER_TYPES]
1808 [, [Result_Type =>] result_SUBTYPE_MARK]
1809 [, [Mechanism =>] MECHANISM]
1810 [, [Result_Mechanism =>] MECHANISM_NAME]);
1814 | static_string_EXPRESSION
1819 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1823 | subtype_Name ' Access
1827 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1829 MECHANISM_ASSOCIATION ::=
1830 [formal_parameter_NAME =>] MECHANISM_NAME
1835 | Descriptor [([Class =>] CLASS_NAME)]
1837 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1841 Use this pragma to make a function externally callable and optionally
1842 provide information on mechanisms to be used for passing parameter and
1843 result values. We recommend, for the purposes of improving portability,
1844 this pragma always be used in conjunction with a separate pragma
1845 @code{Export}, which must precede the pragma @code{Export_Function}.
1846 GNAT does not require a separate pragma @code{Export}, but if none is
1847 present, @code{Convention Ada} is assumed, which is usually
1848 not what is wanted, so it is usually appropriate to use this
1849 pragma in conjunction with a @code{Export} or @code{Convention}
1850 pragma that specifies the desired foreign convention.
1851 Pragma @code{Export_Function}
1852 (and @code{Export}, if present) must appear in the same declarative
1853 region as the function to which they apply.
1855 @var{internal_name} must uniquely designate the function to which the
1856 pragma applies. If more than one function name exists of this name in
1857 the declarative part you must use the @code{Parameter_Types} and
1858 @code{Result_Type} parameters is mandatory to achieve the required
1859 unique designation. @var{subtype_mark}s in these parameters must
1860 exactly match the subtypes in the corresponding function specification,
1861 using positional notation to match parameters with subtype marks.
1862 The form with an @code{'Access} attribute can be used to match an
1863 anonymous access parameter.
1866 @cindex Passing by descriptor
1867 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1869 @cindex Suppressing external name
1870 Special treatment is given if the EXTERNAL is an explicit null
1871 string or a static string expressions that evaluates to the null
1872 string. In this case, no external name is generated. This form
1873 still allows the specification of parameter mechanisms.
1875 @node Pragma Export_Object
1876 @unnumberedsec Pragma Export_Object
1877 @findex Export_Object
1881 @smallexample @c ada
1882 pragma Export_Object
1883 [Internal =>] LOCAL_NAME
1884 [, [External =>] EXTERNAL_SYMBOL]
1885 [, [Size =>] EXTERNAL_SYMBOL]
1889 | static_string_EXPRESSION
1893 This pragma designates an object as exported, and apart from the
1894 extended rules for external symbols, is identical in effect to the use of
1895 the normal @code{Export} pragma applied to an object. You may use a
1896 separate Export pragma (and you probably should from the point of view
1897 of portability), but it is not required. @var{Size} is syntax checked,
1898 but otherwise ignored by GNAT@.
1900 @node Pragma Export_Procedure
1901 @unnumberedsec Pragma Export_Procedure
1902 @findex Export_Procedure
1906 @smallexample @c ada
1907 pragma Export_Procedure (
1908 [Internal =>] LOCAL_NAME
1909 [, [External =>] EXTERNAL_SYMBOL]
1910 [, [Parameter_Types =>] PARAMETER_TYPES]
1911 [, [Mechanism =>] MECHANISM]);
1915 | static_string_EXPRESSION
1920 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1924 | subtype_Name ' Access
1928 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1930 MECHANISM_ASSOCIATION ::=
1931 [formal_parameter_NAME =>] MECHANISM_NAME
1936 | Descriptor [([Class =>] CLASS_NAME)]
1938 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1942 This pragma is identical to @code{Export_Function} except that it
1943 applies to a procedure rather than a function and the parameters
1944 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1945 GNAT does not require a separate pragma @code{Export}, but if none is
1946 present, @code{Convention Ada} is assumed, which is usually
1947 not what is wanted, so it is usually appropriate to use this
1948 pragma in conjunction with a @code{Export} or @code{Convention}
1949 pragma that specifies the desired foreign convention.
1952 @cindex Passing by descriptor
1953 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1955 @cindex Suppressing external name
1956 Special treatment is given if the EXTERNAL is an explicit null
1957 string or a static string expressions that evaluates to the null
1958 string. In this case, no external name is generated. This form
1959 still allows the specification of parameter mechanisms.
1961 @node Pragma Export_Value
1962 @unnumberedsec Pragma Export_Value
1963 @findex Export_Value
1967 @smallexample @c ada
1968 pragma Export_Value (
1969 [Value =>] static_integer_EXPRESSION,
1970 [Link_Name =>] static_string_EXPRESSION);
1974 This pragma serves to export a static integer value for external use.
1975 The first argument specifies the value to be exported. The Link_Name
1976 argument specifies the symbolic name to be associated with the integer
1977 value. This pragma is useful for defining a named static value in Ada
1978 that can be referenced in assembly language units to be linked with
1979 the application. This pragma is currently supported only for the
1980 AAMP target and is ignored for other targets.
1982 @node Pragma Export_Valued_Procedure
1983 @unnumberedsec Pragma Export_Valued_Procedure
1984 @findex Export_Valued_Procedure
1988 @smallexample @c ada
1989 pragma Export_Valued_Procedure (
1990 [Internal =>] LOCAL_NAME
1991 [, [External =>] EXTERNAL_SYMBOL]
1992 [, [Parameter_Types =>] PARAMETER_TYPES]
1993 [, [Mechanism =>] MECHANISM]);
1997 | static_string_EXPRESSION
2002 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2006 | subtype_Name ' Access
2010 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2012 MECHANISM_ASSOCIATION ::=
2013 [formal_parameter_NAME =>] MECHANISM_NAME
2018 | Descriptor [([Class =>] CLASS_NAME)]
2020 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2024 This pragma is identical to @code{Export_Procedure} except that the
2025 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2026 mode @code{OUT}, and externally the subprogram is treated as a function
2027 with this parameter as the result of the function. GNAT provides for
2028 this capability to allow the use of @code{OUT} and @code{IN OUT}
2029 parameters in interfacing to external functions (which are not permitted
2031 GNAT does not require a separate pragma @code{Export}, but if none is
2032 present, @code{Convention Ada} is assumed, which is almost certainly
2033 not what is wanted since the whole point of this pragma is to interface
2034 with foreign language functions, so it is usually appropriate to use this
2035 pragma in conjunction with a @code{Export} or @code{Convention}
2036 pragma that specifies the desired foreign convention.
2039 @cindex Passing by descriptor
2040 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2042 @cindex Suppressing external name
2043 Special treatment is given if the EXTERNAL is an explicit null
2044 string or a static string expressions that evaluates to the null
2045 string. In this case, no external name is generated. This form
2046 still allows the specification of parameter mechanisms.
2048 @node Pragma Extend_System
2049 @unnumberedsec Pragma Extend_System
2050 @cindex @code{system}, extending
2052 @findex Extend_System
2056 @smallexample @c ada
2057 pragma Extend_System ([Name =>] IDENTIFIER);
2061 This pragma is used to provide backwards compatibility with other
2062 implementations that extend the facilities of package @code{System}. In
2063 GNAT, @code{System} contains only the definitions that are present in
2064 the Ada RM@. However, other implementations, notably the DEC Ada 83
2065 implementation, provide many extensions to package @code{System}.
2067 For each such implementation accommodated by this pragma, GNAT provides a
2068 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2069 implementation, which provides the required additional definitions. You
2070 can use this package in two ways. You can @code{with} it in the normal
2071 way and access entities either by selection or using a @code{use}
2072 clause. In this case no special processing is required.
2074 However, if existing code contains references such as
2075 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2076 definitions provided in package @code{System}, you may use this pragma
2077 to extend visibility in @code{System} in a non-standard way that
2078 provides greater compatibility with the existing code. Pragma
2079 @code{Extend_System} is a configuration pragma whose single argument is
2080 the name of the package containing the extended definition
2081 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2082 control of this pragma will be processed using special visibility
2083 processing that looks in package @code{System.Aux_@var{xxx}} where
2084 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2085 package @code{System}, but not found in package @code{System}.
2087 You can use this pragma either to access a predefined @code{System}
2088 extension supplied with the compiler, for example @code{Aux_DEC} or
2089 you can construct your own extension unit following the above
2090 definition. Note that such a package is a child of @code{System}
2091 and thus is considered part of the implementation. To compile
2092 it you will have to use the appropriate switch for compiling
2093 system units. @xref{Top, @value{EDITION} User's Guide, About This
2094 Guide,, gnat_ugn, @value{EDITION} User's Guide}, for details.
2096 @node Pragma External
2097 @unnumberedsec Pragma External
2102 @smallexample @c ada
2104 [ Convention =>] convention_IDENTIFIER,
2105 [ Entity =>] LOCAL_NAME
2106 [, [External_Name =>] static_string_EXPRESSION ]
2107 [, [Link_Name =>] static_string_EXPRESSION ]);
2111 This pragma is identical in syntax and semantics to pragma
2112 @code{Export} as defined in the Ada Reference Manual. It is
2113 provided for compatibility with some Ada 83 compilers that
2114 used this pragma for exactly the same purposes as pragma
2115 @code{Export} before the latter was standardized.
2117 @node Pragma External_Name_Casing
2118 @unnumberedsec Pragma External_Name_Casing
2119 @cindex Dec Ada 83 casing compatibility
2120 @cindex External Names, casing
2121 @cindex Casing of External names
2122 @findex External_Name_Casing
2126 @smallexample @c ada
2127 pragma External_Name_Casing (
2128 Uppercase | Lowercase
2129 [, Uppercase | Lowercase | As_Is]);
2133 This pragma provides control over the casing of external names associated
2134 with Import and Export pragmas. There are two cases to consider:
2137 @item Implicit external names
2138 Implicit external names are derived from identifiers. The most common case
2139 arises when a standard Ada Import or Export pragma is used with only two
2142 @smallexample @c ada
2143 pragma Import (C, C_Routine);
2147 Since Ada is a case-insensitive language, the spelling of the identifier in
2148 the Ada source program does not provide any information on the desired
2149 casing of the external name, and so a convention is needed. In GNAT the
2150 default treatment is that such names are converted to all lower case
2151 letters. This corresponds to the normal C style in many environments.
2152 The first argument of pragma @code{External_Name_Casing} can be used to
2153 control this treatment. If @code{Uppercase} is specified, then the name
2154 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2155 then the normal default of all lower case letters will be used.
2157 This same implicit treatment is also used in the case of extended DEC Ada 83
2158 compatible Import and Export pragmas where an external name is explicitly
2159 specified using an identifier rather than a string.
2161 @item Explicit external names
2162 Explicit external names are given as string literals. The most common case
2163 arises when a standard Ada Import or Export pragma is used with three
2166 @smallexample @c ada
2167 pragma Import (C, C_Routine, "C_routine");
2171 In this case, the string literal normally provides the exact casing required
2172 for the external name. The second argument of pragma
2173 @code{External_Name_Casing} may be used to modify this behavior.
2174 If @code{Uppercase} is specified, then the name
2175 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2176 then the name will be forced to all lowercase letters. A specification of
2177 @code{As_Is} provides the normal default behavior in which the casing is
2178 taken from the string provided.
2182 This pragma may appear anywhere that a pragma is valid. In particular, it
2183 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2184 case it applies to all subsequent compilations, or it can be used as a program
2185 unit pragma, in which case it only applies to the current unit, or it can
2186 be used more locally to control individual Import/Export pragmas.
2188 It is primarily intended for use with OpenVMS systems, where many
2189 compilers convert all symbols to upper case by default. For interfacing to
2190 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2193 @smallexample @c ada
2194 pragma External_Name_Casing (Uppercase, Uppercase);
2198 to enforce the upper casing of all external symbols.
2200 @node Pragma Fast_Math
2201 @unnumberedsec Pragma Fast_Math
2206 @smallexample @c ada
2211 This is a configuration pragma which activates a mode in which speed is
2212 considered more important for floating-point operations than absolutely
2213 accurate adherence to the requirements of the standard. Currently the
2214 following operations are affected:
2217 @item Complex Multiplication
2218 The normal simple formula for complex multiplication can result in intermediate
2219 overflows for numbers near the end of the range. The Ada standard requires that
2220 this situation be detected and corrected by scaling, but in Fast_Math mode such
2221 cases will simply result in overflow. Note that to take advantage of this you
2222 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2223 under control of the pragma, rather than use the preinstantiated versions.
2226 @node Pragma Favor_Top_Level
2227 @unnumberedsec Pragma Favor_Top_Level
2228 @findex Favor_Top_Level
2232 @smallexample @c ada
2233 pragma Favor_Top_Level (type_NAME);
2237 The named type must be an access-to-subprogram type. This pragma is an
2238 efficiency hint to the compiler, regarding the use of 'Access or
2239 'Unrestricted_Access on nested (non-library-level) subprograms. The
2240 pragma means that nested subprograms are not used with this type, or
2241 are rare, so that the generated code should be efficient in the
2242 top-level case. When this pragma is used, dynamically generated
2243 trampolines may be used on some targets for nested subprograms.
2244 See also the No_Implicit_Dynamic_Code restriction.
2246 @node Pragma Finalize_Storage_Only
2247 @unnumberedsec Pragma Finalize_Storage_Only
2248 @findex Finalize_Storage_Only
2252 @smallexample @c ada
2253 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2257 This pragma allows the compiler not to emit a Finalize call for objects
2258 defined at the library level. This is mostly useful for types where
2259 finalization is only used to deal with storage reclamation since in most
2260 environments it is not necessary to reclaim memory just before terminating
2261 execution, hence the name.
2263 @node Pragma Float_Representation
2264 @unnumberedsec Pragma Float_Representation
2266 @findex Float_Representation
2270 @smallexample @c ada
2271 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2273 FLOAT_REP ::= VAX_Float | IEEE_Float
2277 In the one argument form, this pragma is a configuration pragma which
2278 allows control over the internal representation chosen for the predefined
2279 floating point types declared in the packages @code{Standard} and
2280 @code{System}. On all systems other than OpenVMS, the argument must
2281 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2282 argument may be @code{VAX_Float} to specify the use of the VAX float
2283 format for the floating-point types in Standard. This requires that
2284 the standard runtime libraries be recompiled. @xref{The GNAT Run-Time
2285 Library Builder gnatlbr,,, gnat_ugn, @value{EDITION} User's Guide
2286 OpenVMS}, for a description of the @code{GNAT LIBRARY} command.
2288 The two argument form specifies the representation to be used for
2289 the specified floating-point type. On all systems other than OpenVMS,
2291 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2292 argument may be @code{VAX_Float} to specify the use of the VAX float
2297 For digits values up to 6, F float format will be used.
2299 For digits values from 7 to 9, G float format will be used.
2301 For digits values from 10 to 15, F float format will be used.
2303 Digits values above 15 are not allowed.
2307 @unnumberedsec Pragma Ident
2312 @smallexample @c ada
2313 pragma Ident (static_string_EXPRESSION);
2317 This pragma provides a string identification in the generated object file,
2318 if the system supports the concept of this kind of identification string.
2319 This pragma is allowed only in the outermost declarative part or
2320 declarative items of a compilation unit. If more than one @code{Ident}
2321 pragma is given, only the last one processed is effective.
2323 On OpenVMS systems, the effect of the pragma is identical to the effect of
2324 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2325 maximum allowed length is 31 characters, so if it is important to
2326 maintain compatibility with this compiler, you should obey this length
2329 @node Pragma Implemented_By_Entry
2330 @unnumberedsec Pragma Implemented_By_Entry
2331 @findex Implemented_By_Entry
2335 @smallexample @c ada
2336 pragma Implemented_By_Entry (LOCAL_NAME);
2340 This is a representation pragma which applies to protected, synchronized and
2341 task interface primitives. If the pragma is applied to primitive operation Op
2342 of interface Iface, it is illegal to override Op in a type that implements
2343 Iface, with anything other than an entry.
2345 @smallexample @c ada
2346 type Iface is protected interface;
2347 procedure Do_Something (Object : in out Iface) is abstract;
2348 pragma Implemented_By_Entry (Do_Something);
2350 protected type P is new Iface with
2351 procedure Do_Something; -- Illegal
2354 task type T is new Iface with
2355 entry Do_Something; -- Legal
2360 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2361 is intended to be used in conjunction with dispatching requeue statements as
2362 described in AI05-0030. Should the ARG decide on an official name and syntax,
2363 this pragma will become language-defined rather than GNAT-specific.
2365 @node Pragma Implicit_Packing
2366 @unnumberedsec Pragma Implicit_Packing
2367 @findex Implicit_Packing
2371 @smallexample @c ada
2372 pragma Implicit_Packing;
2376 This is a configuration pragma that requests implicit packing for packed
2377 arrays for which a size clause is given but no explicit pragma Pack or
2378 specification of Component_Size is present. Consider this example:
2380 @smallexample @c ada
2381 type R is array (0 .. 7) of Boolean;
2386 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2387 does not change the layout of a composite object. So the Size clause in the
2388 above example is normally rejected, since the default layout of the array uses
2389 8-bit components, and thus the array requires a minimum of 64 bits.
2391 If this declaration is compiled in a region of code covered by an occurrence
2392 of the configuration pragma Implicit_Packing, then the Size clause in this
2393 and similar examples will cause implicit packing and thus be accepted. For
2394 this implicit packing to occur, the type in question must be an array of small
2395 components whose size is known at compile time, and the Size clause must
2396 specify the exact size that corresponds to the length of the array multiplied
2397 by the size in bits of the component type.
2398 @cindex Array packing
2400 @node Pragma Import_Exception
2401 @unnumberedsec Pragma Import_Exception
2403 @findex Import_Exception
2407 @smallexample @c ada
2408 pragma Import_Exception (
2409 [Internal =>] LOCAL_NAME
2410 [, [External =>] EXTERNAL_SYMBOL]
2411 [, [Form =>] Ada | VMS]
2412 [, [Code =>] static_integer_EXPRESSION]);
2416 | static_string_EXPRESSION
2420 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2421 It allows OpenVMS conditions (for example, from OpenVMS system services or
2422 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2423 The pragma specifies that the exception associated with an exception
2424 declaration in an Ada program be defined externally (in non-Ada code).
2425 For further details on this pragma, see the
2426 DEC Ada Language Reference Manual, section 13.9a.3.1.
2428 @node Pragma Import_Function
2429 @unnumberedsec Pragma Import_Function
2430 @findex Import_Function
2434 @smallexample @c ada
2435 pragma Import_Function (
2436 [Internal =>] LOCAL_NAME,
2437 [, [External =>] EXTERNAL_SYMBOL]
2438 [, [Parameter_Types =>] PARAMETER_TYPES]
2439 [, [Result_Type =>] SUBTYPE_MARK]
2440 [, [Mechanism =>] MECHANISM]
2441 [, [Result_Mechanism =>] MECHANISM_NAME]
2442 [, [First_Optional_Parameter =>] IDENTIFIER]);
2446 | static_string_EXPRESSION
2450 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2454 | subtype_Name ' Access
2458 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2460 MECHANISM_ASSOCIATION ::=
2461 [formal_parameter_NAME =>] MECHANISM_NAME
2466 | Descriptor [([Class =>] CLASS_NAME)]
2468 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2472 This pragma is used in conjunction with a pragma @code{Import} to
2473 specify additional information for an imported function. The pragma
2474 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2475 @code{Import_Function} pragma and both must appear in the same
2476 declarative part as the function specification.
2478 The @var{Internal} argument must uniquely designate
2479 the function to which the
2480 pragma applies. If more than one function name exists of this name in
2481 the declarative part you must use the @code{Parameter_Types} and
2482 @var{Result_Type} parameters to achieve the required unique
2483 designation. Subtype marks in these parameters must exactly match the
2484 subtypes in the corresponding function specification, using positional
2485 notation to match parameters with subtype marks.
2486 The form with an @code{'Access} attribute can be used to match an
2487 anonymous access parameter.
2489 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2490 parameters to specify passing mechanisms for the
2491 parameters and result. If you specify a single mechanism name, it
2492 applies to all parameters. Otherwise you may specify a mechanism on a
2493 parameter by parameter basis using either positional or named
2494 notation. If the mechanism is not specified, the default mechanism
2498 @cindex Passing by descriptor
2499 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2501 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2502 It specifies that the designated parameter and all following parameters
2503 are optional, meaning that they are not passed at the generated code
2504 level (this is distinct from the notion of optional parameters in Ada
2505 where the parameters are passed anyway with the designated optional
2506 parameters). All optional parameters must be of mode @code{IN} and have
2507 default parameter values that are either known at compile time
2508 expressions, or uses of the @code{'Null_Parameter} attribute.
2510 @node Pragma Import_Object
2511 @unnumberedsec Pragma Import_Object
2512 @findex Import_Object
2516 @smallexample @c ada
2517 pragma Import_Object
2518 [Internal =>] LOCAL_NAME
2519 [, [External =>] EXTERNAL_SYMBOL]
2520 [, [Size =>] EXTERNAL_SYMBOL]);
2524 | static_string_EXPRESSION
2528 This pragma designates an object as imported, and apart from the
2529 extended rules for external symbols, is identical in effect to the use of
2530 the normal @code{Import} pragma applied to an object. Unlike the
2531 subprogram case, you need not use a separate @code{Import} pragma,
2532 although you may do so (and probably should do so from a portability
2533 point of view). @var{size} is syntax checked, but otherwise ignored by
2536 @node Pragma Import_Procedure
2537 @unnumberedsec Pragma Import_Procedure
2538 @findex Import_Procedure
2542 @smallexample @c ada
2543 pragma Import_Procedure (
2544 [Internal =>] LOCAL_NAME
2545 [, [External =>] EXTERNAL_SYMBOL]
2546 [, [Parameter_Types =>] PARAMETER_TYPES]
2547 [, [Mechanism =>] MECHANISM]
2548 [, [First_Optional_Parameter =>] IDENTIFIER]);
2552 | static_string_EXPRESSION
2556 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2560 | subtype_Name ' Access
2564 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2566 MECHANISM_ASSOCIATION ::=
2567 [formal_parameter_NAME =>] MECHANISM_NAME
2572 | Descriptor [([Class =>] CLASS_NAME)]
2574 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2578 This pragma is identical to @code{Import_Function} except that it
2579 applies to a procedure rather than a function and the parameters
2580 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2582 @node Pragma Import_Valued_Procedure
2583 @unnumberedsec Pragma Import_Valued_Procedure
2584 @findex Import_Valued_Procedure
2588 @smallexample @c ada
2589 pragma Import_Valued_Procedure (
2590 [Internal =>] LOCAL_NAME
2591 [, [External =>] EXTERNAL_SYMBOL]
2592 [, [Parameter_Types =>] PARAMETER_TYPES]
2593 [, [Mechanism =>] MECHANISM]
2594 [, [First_Optional_Parameter =>] IDENTIFIER]);
2598 | static_string_EXPRESSION
2602 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2606 | subtype_Name ' Access
2610 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2612 MECHANISM_ASSOCIATION ::=
2613 [formal_parameter_NAME =>] MECHANISM_NAME
2618 | Descriptor [([Class =>] CLASS_NAME)]
2620 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2624 This pragma is identical to @code{Import_Procedure} except that the
2625 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2626 mode @code{OUT}, and externally the subprogram is treated as a function
2627 with this parameter as the result of the function. The purpose of this
2628 capability is to allow the use of @code{OUT} and @code{IN OUT}
2629 parameters in interfacing to external functions (which are not permitted
2630 in Ada functions). You may optionally use the @code{Mechanism}
2631 parameters to specify passing mechanisms for the parameters.
2632 If you specify a single mechanism name, it applies to all parameters.
2633 Otherwise you may specify a mechanism on a parameter by parameter
2634 basis using either positional or named notation. If the mechanism is not
2635 specified, the default mechanism is used.
2637 Note that it is important to use this pragma in conjunction with a separate
2638 pragma Import that specifies the desired convention, since otherwise the
2639 default convention is Ada, which is almost certainly not what is required.
2641 @node Pragma Initialize_Scalars
2642 @unnumberedsec Pragma Initialize_Scalars
2643 @findex Initialize_Scalars
2644 @cindex debugging with Initialize_Scalars
2648 @smallexample @c ada
2649 pragma Initialize_Scalars;
2653 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2654 two important differences. First, there is no requirement for the pragma
2655 to be used uniformly in all units of a partition, in particular, it is fine
2656 to use this just for some or all of the application units of a partition,
2657 without needing to recompile the run-time library.
2659 In the case where some units are compiled with the pragma, and some without,
2660 then a declaration of a variable where the type is defined in package
2661 Standard or is locally declared will always be subject to initialization,
2662 as will any declaration of a scalar variable. For composite variables,
2663 whether the variable is initialized may also depend on whether the package
2664 in which the type of the variable is declared is compiled with the pragma.
2666 The other important difference is that you can control the value used
2667 for initializing scalar objects. At bind time, you can select several
2668 options for initialization. You can
2669 initialize with invalid values (similar to Normalize_Scalars, though for
2670 Initialize_Scalars it is not always possible to determine the invalid
2671 values in complex cases like signed component fields with non-standard
2672 sizes). You can also initialize with high or
2673 low values, or with a specified bit pattern. See the users guide for binder
2674 options for specifying these cases.
2676 This means that you can compile a program, and then without having to
2677 recompile the program, you can run it with different values being used
2678 for initializing otherwise uninitialized values, to test if your program
2679 behavior depends on the choice. Of course the behavior should not change,
2680 and if it does, then most likely you have an erroneous reference to an
2681 uninitialized value.
2683 It is even possible to change the value at execution time eliminating even
2684 the need to rebind with a different switch using an environment variable.
2685 See the GNAT users guide for details.
2687 Note that pragma @code{Initialize_Scalars} is particularly useful in
2688 conjunction with the enhanced validity checking that is now provided
2689 in GNAT, which checks for invalid values under more conditions.
2690 Using this feature (see description of the @option{-gnatV} flag in the
2691 users guide) in conjunction with pragma @code{Initialize_Scalars}
2692 provides a powerful new tool to assist in the detection of problems
2693 caused by uninitialized variables.
2695 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2696 effect on the generated code. This may cause your code to be
2697 substantially larger. It may also cause an increase in the amount
2698 of stack required, so it is probably a good idea to turn on stack
2699 checking (see description of stack checking in the GNAT users guide)
2700 when using this pragma.
2702 @node Pragma Inline_Always
2703 @unnumberedsec Pragma Inline_Always
2704 @findex Inline_Always
2708 @smallexample @c ada
2709 pragma Inline_Always (NAME [, NAME]);
2713 Similar to pragma @code{Inline} except that inlining is not subject to
2714 the use of option @option{-gnatn} and the inlining happens regardless of
2715 whether this option is used.
2717 @node Pragma Inline_Generic
2718 @unnumberedsec Pragma Inline_Generic
2719 @findex Inline_Generic
2723 @smallexample @c ada
2724 pragma Inline_Generic (generic_package_NAME);
2728 This is implemented for compatibility with DEC Ada 83 and is recognized,
2729 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2730 by default when using GNAT@.
2732 @node Pragma Interface
2733 @unnumberedsec Pragma Interface
2738 @smallexample @c ada
2740 [Convention =>] convention_identifier,
2741 [Entity =>] local_NAME
2742 [, [External_Name =>] static_string_expression]
2743 [, [Link_Name =>] static_string_expression]);
2747 This pragma is identical in syntax and semantics to
2748 the standard Ada pragma @code{Import}. It is provided for compatibility
2749 with Ada 83. The definition is upwards compatible both with pragma
2750 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2751 with some extended implementations of this pragma in certain Ada 83
2754 @node Pragma Interface_Name
2755 @unnumberedsec Pragma Interface_Name
2756 @findex Interface_Name
2760 @smallexample @c ada
2761 pragma Interface_Name (
2762 [Entity =>] LOCAL_NAME
2763 [, [External_Name =>] static_string_EXPRESSION]
2764 [, [Link_Name =>] static_string_EXPRESSION]);
2768 This pragma provides an alternative way of specifying the interface name
2769 for an interfaced subprogram, and is provided for compatibility with Ada
2770 83 compilers that use the pragma for this purpose. You must provide at
2771 least one of @var{External_Name} or @var{Link_Name}.
2773 @node Pragma Interrupt_Handler
2774 @unnumberedsec Pragma Interrupt_Handler
2775 @findex Interrupt_Handler
2779 @smallexample @c ada
2780 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2784 This program unit pragma is supported for parameterless protected procedures
2785 as described in Annex C of the Ada Reference Manual. On the AAMP target
2786 the pragma can also be specified for nonprotected parameterless procedures
2787 that are declared at the library level (which includes procedures
2788 declared at the top level of a library package). In the case of AAMP,
2789 when this pragma is applied to a nonprotected procedure, the instruction
2790 @code{IERET} is generated for returns from the procedure, enabling
2791 maskable interrupts, in place of the normal return instruction.
2793 @node Pragma Interrupt_State
2794 @unnumberedsec Pragma Interrupt_State
2795 @findex Interrupt_State
2799 @smallexample @c ada
2800 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2804 Normally certain interrupts are reserved to the implementation. Any attempt
2805 to attach an interrupt causes Program_Error to be raised, as described in
2806 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
2807 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
2808 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2809 interrupt execution. Additionally, signals such as @code{SIGSEGV},
2810 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2811 Ada exceptions, or used to implement run-time functions such as the
2812 @code{abort} statement and stack overflow checking.
2814 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2815 such uses of interrupts. It subsumes the functionality of pragma
2816 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
2817 available on OS/2, Windows or VMS. On all other platforms than VxWorks,
2818 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2819 and may be used to mark interrupts required by the board support package
2822 Interrupts can be in one of three states:
2826 The interrupt is reserved (no Ada handler can be installed), and the
2827 Ada run-time may not install a handler. As a result you are guaranteed
2828 standard system default action if this interrupt is raised.
2832 The interrupt is reserved (no Ada handler can be installed). The run time
2833 is allowed to install a handler for internal control purposes, but is
2834 not required to do so.
2838 The interrupt is unreserved. The user may install a handler to provide
2843 These states are the allowed values of the @code{State} parameter of the
2844 pragma. The @code{Name} parameter is a value of the type
2845 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
2846 @code{Ada.Interrupts.Names}.
2848 This is a configuration pragma, and the binder will check that there
2849 are no inconsistencies between different units in a partition in how a
2850 given interrupt is specified. It may appear anywhere a pragma is legal.
2852 The effect is to move the interrupt to the specified state.
2854 By declaring interrupts to be SYSTEM, you guarantee the standard system
2855 action, such as a core dump.
2857 By declaring interrupts to be USER, you guarantee that you can install
2860 Note that certain signals on many operating systems cannot be caught and
2861 handled by applications. In such cases, the pragma is ignored. See the
2862 operating system documentation, or the value of the array @code{Reserved}
2863 declared in the spec of package @code{System.OS_Interface}.
2865 Overriding the default state of signals used by the Ada runtime may interfere
2866 with an application's runtime behavior in the cases of the synchronous signals,
2867 and in the case of the signal used to implement the @code{abort} statement.
2869 @node Pragma Keep_Names
2870 @unnumberedsec Pragma Keep_Names
2875 @smallexample @c ada
2876 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2880 The @var{LOCAL_NAME} argument
2881 must refer to an enumeration first subtype
2882 in the current declarative part. The effect is to retain the enumeration
2883 literal names for use by @code{Image} and @code{Value} even if a global
2884 @code{Discard_Names} pragma applies. This is useful when you want to
2885 generally suppress enumeration literal names and for example you therefore
2886 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2887 want to retain the names for specific enumeration types.
2889 @node Pragma License
2890 @unnumberedsec Pragma License
2892 @cindex License checking
2896 @smallexample @c ada
2897 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2901 This pragma is provided to allow automated checking for appropriate license
2902 conditions with respect to the standard and modified GPL@. A pragma
2903 @code{License}, which is a configuration pragma that typically appears at
2904 the start of a source file or in a separate @file{gnat.adc} file, specifies
2905 the licensing conditions of a unit as follows:
2909 This is used for a unit that can be freely used with no license restrictions.
2910 Examples of such units are public domain units, and units from the Ada
2914 This is used for a unit that is licensed under the unmodified GPL, and which
2915 therefore cannot be @code{with}'ed by a restricted unit.
2918 This is used for a unit licensed under the GNAT modified GPL that includes
2919 a special exception paragraph that specifically permits the inclusion of
2920 the unit in programs without requiring the entire program to be released
2924 This is used for a unit that is restricted in that it is not permitted to
2925 depend on units that are licensed under the GPL@. Typical examples are
2926 proprietary code that is to be released under more restrictive license
2927 conditions. Note that restricted units are permitted to @code{with} units
2928 which are licensed under the modified GPL (this is the whole point of the
2934 Normally a unit with no @code{License} pragma is considered to have an
2935 unknown license, and no checking is done. However, standard GNAT headers
2936 are recognized, and license information is derived from them as follows.
2940 A GNAT license header starts with a line containing 78 hyphens. The following
2941 comment text is searched for the appearance of any of the following strings.
2943 If the string ``GNU General Public License'' is found, then the unit is assumed
2944 to have GPL license, unless the string ``As a special exception'' follows, in
2945 which case the license is assumed to be modified GPL@.
2947 If one of the strings
2948 ``This specification is adapted from the Ada Semantic Interface'' or
2949 ``This specification is derived from the Ada Reference Manual'' is found
2950 then the unit is assumed to be unrestricted.
2954 These default actions means that a program with a restricted license pragma
2955 will automatically get warnings if a GPL unit is inappropriately
2956 @code{with}'ed. For example, the program:
2958 @smallexample @c ada
2961 procedure Secret_Stuff is
2967 if compiled with pragma @code{License} (@code{Restricted}) in a
2968 @file{gnat.adc} file will generate the warning:
2973 >>> license of withed unit "Sem_Ch3" is incompatible
2975 2. with GNAT.Sockets;
2976 3. procedure Secret_Stuff is
2980 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2981 compiler and is licensed under the
2982 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2983 run time, and is therefore licensed under the modified GPL@.
2985 @node Pragma Link_With
2986 @unnumberedsec Pragma Link_With
2991 @smallexample @c ada
2992 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2996 This pragma is provided for compatibility with certain Ada 83 compilers.
2997 It has exactly the same effect as pragma @code{Linker_Options} except
2998 that spaces occurring within one of the string expressions are treated
2999 as separators. For example, in the following case:
3001 @smallexample @c ada
3002 pragma Link_With ("-labc -ldef");
3006 results in passing the strings @code{-labc} and @code{-ldef} as two
3007 separate arguments to the linker. In addition pragma Link_With allows
3008 multiple arguments, with the same effect as successive pragmas.
3010 @node Pragma Linker_Alias
3011 @unnumberedsec Pragma Linker_Alias
3012 @findex Linker_Alias
3016 @smallexample @c ada
3017 pragma Linker_Alias (
3018 [Entity =>] LOCAL_NAME,
3019 [Target =>] static_string_EXPRESSION);
3023 @var{LOCAL_NAME} must refer to an object that is declared at the library
3024 level. This pragma establishes the given entity as a linker alias for the
3025 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3026 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3027 @var{static_string_EXPRESSION} in the object file, that is to say no space
3028 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3029 to the same address as @var{static_string_EXPRESSION} by the linker.
3031 The actual linker name for the target must be used (e.g.@: the fully
3032 encoded name with qualification in Ada, or the mangled name in C++),
3033 or it must be declared using the C convention with @code{pragma Import}
3034 or @code{pragma Export}.
3036 Not all target machines support this pragma. On some of them it is accepted
3037 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3039 @smallexample @c ada
3040 -- Example of the use of pragma Linker_Alias
3044 pragma Export (C, i);
3046 new_name_for_i : Integer;
3047 pragma Linker_Alias (new_name_for_i, "i");
3051 @node Pragma Linker_Constructor
3052 @unnumberedsec Pragma Linker_Constructor
3053 @findex Linker_Constructor
3057 @smallexample @c ada
3058 pragma Linker_Constructor (procedure_LOCAL_NAME);
3062 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3063 is declared at the library level. A procedure to which this pragma is
3064 applied will be treated as an initialization routine by the linker.
3065 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3066 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3067 of the executable is called (or immediately after the shared library is
3068 loaded if the procedure is linked in a shared library), in particular
3069 before the Ada run-time environment is set up.
3071 Because of these specific contexts, the set of operations such a procedure
3072 can perform is very limited and the type of objects it can manipulate is
3073 essentially restricted to the elementary types. In particular, it must only
3074 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3076 This pragma is used by GNAT to implement auto-initialization of shared Stand
3077 Alone Libraries, which provides a related capability without the restrictions
3078 listed above. Where possible, the use of Stand Alone Libraries is preferable
3079 to the use of this pragma.
3081 @node Pragma Linker_Destructor
3082 @unnumberedsec Pragma Linker_Destructor
3083 @findex Linker_Destructor
3087 @smallexample @c ada
3088 pragma Linker_Destructor (procedure_LOCAL_NAME);
3092 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3093 is declared at the library level. A procedure to which this pragma is
3094 applied will be treated as a finalization routine by the linker.
3095 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3096 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3097 of the executable has exited (or immediately before the shared library
3098 is unloaded if the procedure is linked in a shared library), in particular
3099 after the Ada run-time environment is shut down.
3101 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3102 because of these specific contexts.
3104 @node Pragma Linker_Section
3105 @unnumberedsec Pragma Linker_Section
3106 @findex Linker_Section
3110 @smallexample @c ada
3111 pragma Linker_Section (
3112 [Entity =>] LOCAL_NAME,
3113 [Section =>] static_string_EXPRESSION);
3117 @var{LOCAL_NAME} must refer to an object that is declared at the library
3118 level. This pragma specifies the name of the linker section for the given
3119 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3120 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3121 section of the executable (assuming the linker doesn't rename the section).
3123 The compiler normally places library-level objects in standard sections
3124 depending on their type: procedures and functions generally go in the
3125 @code{.text} section, initialized variables in the @code{.data} section
3126 and uninitialized variables in the @code{.bss} section.
3128 Other, special sections may exist on given target machines to map special
3129 hardware, for example I/O ports or flash memory. This pragma is a means to
3130 defer the final layout of the executable to the linker, thus fully working
3131 at the symbolic level with the compiler.
3133 Some file formats do not support arbitrary sections so not all target
3134 machines support this pragma. The use of this pragma may cause a program
3135 execution to be erroneous if it is used to place an entity into an
3136 inappropriate section (e.g.@: a modified variable into the @code{.text}
3137 section). See also @code{pragma Persistent_BSS}.
3139 @smallexample @c ada
3140 -- Example of the use of pragma Linker_Section
3144 pragma Volatile (Port_A);
3145 pragma Linker_Section (Port_A, ".bss.port_a");
3148 pragma Volatile (Port_B);
3149 pragma Linker_Section (Port_B, ".bss.port_b");
3153 @node Pragma Long_Float
3154 @unnumberedsec Pragma Long_Float
3160 @smallexample @c ada
3161 pragma Long_Float (FLOAT_FORMAT);
3163 FLOAT_FORMAT ::= D_Float | G_Float
3167 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3168 It allows control over the internal representation chosen for the predefined
3169 type @code{Long_Float} and for floating point type representations with
3170 @code{digits} specified in the range 7 through 15.
3171 For further details on this pragma, see the
3172 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3173 this pragma, the standard runtime libraries must be recompiled.
3174 @xref{The GNAT Run-Time Library Builder gnatlbr,,, gnat_ugn,
3175 @value{EDITION} User's Guide OpenVMS}, for a description of the
3176 @code{GNAT LIBRARY} command.
3178 @node Pragma Machine_Attribute
3179 @unnumberedsec Pragma Machine_Attribute
3180 @findex Machine_Attribute
3184 @smallexample @c ada
3185 pragma Machine_Attribute (
3186 [Entity =>] LOCAL_NAME,
3187 [Attribute_Name =>] static_string_EXPRESSION
3188 [, [Info =>] static_string_EXPRESSION] );
3192 Machine-dependent attributes can be specified for types and/or
3193 declarations. This pragma is semantically equivalent to
3194 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3195 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3196 in GNU C, where @code{@var{attribute_name}} is recognized by the
3197 target macro @code{TARGET_ATTRIBUTE_TABLE} which is defined for each
3198 machine. The optional parameter @var{info} is transformed into an
3199 identifier, which may make this pragma unusable for some attributes
3200 (parameter of some attributes must be a number or a string).
3201 @xref{Target Attributes,, Defining target-specific uses of
3202 @code{__attribute__}, gccint, GNU Compiler Colletion (GCC) Internals},
3203 further information. It is not possible to specify
3204 attributes defined by other languages, only attributes defined by the
3205 machine the code is intended to run on.
3208 @unnumberedsec Pragma Main
3214 @smallexample @c ada
3216 (MAIN_OPTION [, MAIN_OPTION]);
3219 [STACK_SIZE =>] static_integer_EXPRESSION
3220 | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
3221 | [TIME_SLICING_ENABLED =>] static_boolean_EXPRESSION
3225 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3226 no effect in GNAT, other than being syntax checked.
3228 @node Pragma Main_Storage
3229 @unnumberedsec Pragma Main_Storage
3231 @findex Main_Storage
3235 @smallexample @c ada
3237 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3239 MAIN_STORAGE_OPTION ::=
3240 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3241 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3245 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3246 no effect in GNAT, other than being syntax checked. Note that the pragma
3247 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3249 @node Pragma No_Body
3250 @unnumberedsec Pragma No_Body
3255 @smallexample @c ada
3260 There are a number of cases in which a package spec does not require a body,
3261 and in fact a body is not permitted. GNAT will not permit the spec to be
3262 compiled if there is a body around. The pragma No_Body allows you to provide
3263 a body file, even in a case where no body is allowed. The body file must
3264 contain only comments and a single No_Body pragma. This is recognized by
3265 the compiler as indicating that no body is logically present.
3267 This is particularly useful during maintenance when a package is modified in
3268 such a way that a body needed before is no longer needed. The provision of a
3269 dummy body with a No_Body pragma ensures that there is no interference from
3270 earlier versions of the package body.
3272 @node Pragma No_Return
3273 @unnumberedsec Pragma No_Return
3278 @smallexample @c ada
3279 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3283 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3284 declarations in the current declarative part. A procedure to which this
3285 pragma is applied may not contain any explicit @code{return} statements.
3286 In addition, if the procedure contains any implicit returns from falling
3287 off the end of a statement sequence, then execution of that implicit
3288 return will cause Program_Error to be raised.
3290 One use of this pragma is to identify procedures whose only purpose is to raise
3291 an exception. Another use of this pragma is to suppress incorrect warnings
3292 about missing returns in functions, where the last statement of a function
3293 statement sequence is a call to such a procedure.
3295 Note that in Ada 2005 mode, this pragma is part of the language, and is
3296 identical in effect to the pragma as implemented in Ada 95 mode.
3298 @node Pragma No_Strict_Aliasing
3299 @unnumberedsec Pragma No_Strict_Aliasing
3300 @findex No_Strict_Aliasing
3304 @smallexample @c ada
3305 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3309 @var{type_LOCAL_NAME} must refer to an access type
3310 declaration in the current declarative part. The effect is to inhibit
3311 strict aliasing optimization for the given type. The form with no
3312 arguments is a configuration pragma which applies to all access types
3313 declared in units to which the pragma applies. For a detailed
3314 description of the strict aliasing optimization, and the situations
3315 in which it must be suppressed, see @ref{Optimization and Strict
3316 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3318 @node Pragma Normalize_Scalars
3319 @unnumberedsec Pragma Normalize_Scalars
3320 @findex Normalize_Scalars
3324 @smallexample @c ada
3325 pragma Normalize_Scalars;
3329 This is a language defined pragma which is fully implemented in GNAT@. The
3330 effect is to cause all scalar objects that are not otherwise initialized
3331 to be initialized. The initial values are implementation dependent and
3335 @item Standard.Character
3337 Objects whose root type is Standard.Character are initialized to
3338 Character'Last unless the subtype range excludes NUL (in which case
3339 NUL is used). This choice will always generate an invalid value if
3342 @item Standard.Wide_Character
3344 Objects whose root type is Standard.Wide_Character are initialized to
3345 Wide_Character'Last unless the subtype range excludes NUL (in which case
3346 NUL is used). This choice will always generate an invalid value if
3349 @item Standard.Wide_Wide_Character
3351 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3352 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3353 which case NUL is used). This choice will always generate an invalid value if
3358 Objects of an integer type are treated differently depending on whether
3359 negative values are present in the subtype. If no negative values are
3360 present, then all one bits is used as the initial value except in the
3361 special case where zero is excluded from the subtype, in which case
3362 all zero bits are used. This choice will always generate an invalid
3363 value if one exists.
3365 For subtypes with negative values present, the largest negative number
3366 is used, except in the unusual case where this largest negative number
3367 is in the subtype, and the largest positive number is not, in which case
3368 the largest positive value is used. This choice will always generate
3369 an invalid value if one exists.
3371 @item Floating-Point Types
3372 Objects of all floating-point types are initialized to all 1-bits. For
3373 standard IEEE format, this corresponds to a NaN (not a number) which is
3374 indeed an invalid value.
3376 @item Fixed-Point Types
3377 Objects of all fixed-point types are treated as described above for integers,
3378 with the rules applying to the underlying integer value used to represent
3379 the fixed-point value.
3382 Objects of a modular type are initialized to all one bits, except in
3383 the special case where zero is excluded from the subtype, in which
3384 case all zero bits are used. This choice will always generate an
3385 invalid value if one exists.
3387 @item Enumeration types
3388 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3389 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3390 whose Pos value is zero, in which case a code of zero is used. This choice
3391 will always generate an invalid value if one exists.
3395 @node Pragma Obsolescent
3396 @unnumberedsec Pragma Obsolescent
3401 @smallexample @c ada
3403 (Entity => NAME [, static_string_EXPRESSION [,Ada_05]]);
3407 This pragma can occur immediately following a declaration of an entity,
3408 including the case of a record component, and usually the Entity name
3409 must match the name of the entity declared by this declaration.
3410 Alternatively, the pragma can immediately follow an
3411 enumeration type declaration, where the entity argument names one of the
3412 enumeration literals.
3414 This pragma is used to indicate that the named entity
3415 is considered obsolescent and should not be used. Typically this is
3416 used when an API must be modified by eventually removing or modifying
3417 existing subprograms or other entities. The pragma can be used at an
3418 intermediate stage when the entity is still present, but will be
3421 The effect of this pragma is to output a warning message on
3422 a call to a program thus marked that the
3423 subprogram is obsolescent if the appropriate warning option in the
3424 compiler is activated. If the string parameter is present, then a second
3425 warning message is given containing this text.
3426 In addition, a call to such a program is considered a violation of
3427 pragma Restrictions (No_Obsolescent_Features).
3429 This pragma can also be used as a program unit pragma for a package,
3430 in which case the entity name is the name of the package, and the
3431 pragma indicates that the entire package is considered
3432 obsolescent. In this case a client @code{with}'ing such a package
3433 violates the restriction, and the @code{with} statement is
3434 flagged with warnings if the warning option is set.
3436 If the optional third parameter is present (which must be exactly
3437 the identifier Ada_05, no other argument is allowed), then the
3438 indication of obsolescence applies only when compiling in Ada 2005
3439 mode. This is primarily intended for dealing with the situations
3440 in the predefined library where subprograms or packages
3441 have become defined as obsolescent in Ada 2005
3442 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3444 The following examples show typical uses of this pragma:
3446 @smallexample @c ada
3449 (Entity => p, "use pp instead of p");
3455 (Entity => q2, "use q2new instead");
3457 type R is new integer;
3459 (Entity => R, "use RR in Ada 2005", Ada_05);
3464 pragma Obsolescent (Entity => F2);
3468 type E is (a, bc, 'd', quack);
3469 pragma Obsolescent (Entity => bc)
3470 pragma Obsolescent (Entity => 'd')
3473 (a, b : character) return character;
3474 pragma Obsolescent (Entity => "+");
3479 In an earlier version of GNAT, the Entity parameter was not required,
3480 and this form is still accepted for compatibility purposes. If the
3481 Entity parameter is omitted, then the pragma applies to the declaration
3482 immediately preceding the pragma (this form cannot be used for the
3483 enumeration literal case).
3485 @node Pragma Optimize_Alignment
3486 @unnumberedsec Pragma Optimize_Alignment
3487 @findex Optimize_Alignment
3488 @cindex Alignment, default settings
3492 @smallexample @c ada
3493 pragma Optimize_Alignment (TIME | SPACE | OFF);
3497 This is a configuration pragma which affects the choice of default alignments
3498 for types where no alignment is explicitly specified. There is a time/space
3499 trade-off in the selection of these values. Large alignments result in more
3500 efficient code, at the expense of larger data space, since sizes have to be
3501 increased to match these alignments. Smaller alignments save space, but the
3502 access code is slower. The normal choice of default alignments (which is what
3503 you get if you do not use this pragma, or if you use an argument of OFF),
3504 tries to balance these two requirements.
3506 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3507 First any packed record is given an alignment of 1. Second, if a size is given
3508 for the type, then the alignment is chosen to avoid increasing this size. For
3511 @smallexample @c ada
3521 In the default mode, this type gets an alignment of 4, so that access to the
3522 Integer field X are efficient. But this means that objects of the type end up
3523 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3524 allowed to be bigger than the size of the type, but it can waste space if for
3525 example fields of type R appear in an enclosing record. If the above type is
3526 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3528 Specifying TIME causes larger default alignments to be chosen in the case of
3529 small types with sizes that are not a power of 2. For example, consider:
3531 @smallexample @c ada
3543 The default alignment for this record is normally 1, but if this type is
3544 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3545 to 4, which wastes space for objects of the type, since they are now 4 bytes
3546 long, but results in more efficient access when the whole record is referenced.
3548 As noted above, this is a configuration pragma, and there is a requirement
3549 that all units in a partition be compiled with a consistent setting of the
3550 optimization setting. This would normally be achieved by use of a configuration
3551 pragma file containing the appropriate setting. The exception to this rule is
3552 that units with an explicit configuration pragma in the same file as the source
3553 unit are excluded from the consistency check, as are all predefined units. The
3554 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3555 pragma appears at the start of the file.
3557 @node Pragma Passive
3558 @unnumberedsec Pragma Passive
3563 @smallexample @c ada
3564 pragma Passive [(Semaphore | No)];
3568 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3569 compatibility with DEC Ada 83 implementations, where it is used within a
3570 task definition to request that a task be made passive. If the argument
3571 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3572 treats the pragma as an assertion that the containing task is passive
3573 and that optimization of context switch with this task is permitted and
3574 desired. If the argument @code{No} is present, the task must not be
3575 optimized. GNAT does not attempt to optimize any tasks in this manner
3576 (since protected objects are available in place of passive tasks).
3578 @node Pragma Persistent_BSS
3579 @unnumberedsec Pragma Persistent_BSS
3580 @findex Persistent_BSS
3584 @smallexample @c ada
3585 pragma Persistent_BSS [(LOCAL_NAME)]
3589 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3590 section. On some targets the linker and loader provide for special
3591 treatment of this section, allowing a program to be reloaded without
3592 affecting the contents of this data (hence the name persistent).
3594 There are two forms of usage. If an argument is given, it must be the
3595 local name of a library level object, with no explicit initialization
3596 and whose type is potentially persistent. If no argument is given, then
3597 the pragma is a configuration pragma, and applies to all library level
3598 objects with no explicit initialization of potentially persistent types.
3600 A potentially persistent type is a scalar type, or a non-tagged,
3601 non-discriminated record, all of whose components have no explicit
3602 initialization and are themselves of a potentially persistent type,
3603 or an array, all of whose constraints are static, and whose component
3604 type is potentially persistent.
3606 If this pragma is used on a target where this feature is not supported,
3607 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3609 @node Pragma Polling
3610 @unnumberedsec Pragma Polling
3615 @smallexample @c ada
3616 pragma Polling (ON | OFF);
3620 This pragma controls the generation of polling code. This is normally off.
3621 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3622 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3623 runtime library, and can be found in file @file{a-excpol.adb}.
3625 Pragma @code{Polling} can appear as a configuration pragma (for example it
3626 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3627 can be used in the statement or declaration sequence to control polling
3630 A call to the polling routine is generated at the start of every loop and
3631 at the start of every subprogram call. This guarantees that the @code{Poll}
3632 routine is called frequently, and places an upper bound (determined by
3633 the complexity of the code) on the period between two @code{Poll} calls.
3635 The primary purpose of the polling interface is to enable asynchronous
3636 aborts on targets that cannot otherwise support it (for example Windows
3637 NT), but it may be used for any other purpose requiring periodic polling.
3638 The standard version is null, and can be replaced by a user program. This
3639 will require re-compilation of the @code{Ada.Exceptions} package that can
3640 be found in files @file{a-except.ads} and @file{a-except.adb}.
3642 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3643 distribution) is used to enable the asynchronous abort capability on
3644 targets that do not normally support the capability. The version of
3645 @code{Poll} in this file makes a call to the appropriate runtime routine
3646 to test for an abort condition.
3648 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3649 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3652 @node Pragma Postcondition
3653 @unnumberedsec Pragma Postcondition
3654 @cindex Postconditions
3655 @cindex Checks, postconditions
3656 @findex Postconditions
3660 @smallexample @c ada
3661 pragma Postcondition (
3662 [Check =>] Boolean_Expression
3663 [,[Message =>] String_Expression]);
3667 The @code{Postcondition} pragma allows specification of automatic
3668 postcondition checks for subprograms. These checks are similar to
3669 assertions, but are automatically inserted just prior to the return
3670 statements of the subprogram with which they are associated.
3671 Furthermore, the boolean expression which is the condition which
3672 must be true may contain references to function'Result in the case
3673 of a function to refer to the returned value.
3675 @code{Postcondition} pragmas may appear either immediate following the
3676 (separate) declaration of a subprogram, or at the start of the
3677 declarations of a subprogram body. Only other pragmas may intervene
3678 (that is appear between the subprogram declaration and its
3679 postconditions, or appear before the postcondition in the
3680 declaration sequence in a subprogram body). In the case of a
3681 postcondition appearing after a subprogram declaration, the
3682 formal arguments of the subprogram are visible, and can be
3683 referenced in the postcondition expressions.
3685 The postconditions are collected and automatically tested just
3686 before any return (implicit or explicit) in the subprogram body.
3687 A postcondition is only recognized if postconditions are active
3688 at the time the pragma is encountered. The compiler switch @option{gnata}
3689 turns on all postconditions by default, and pragma @code{Check_Policy}
3690 with an identifier of @code{Postcondition} can also be used to
3691 control whether postconditions are active.
3693 The general approach is that postconditions are placed in the spec
3694 if they represent functional aspects which make sense to the client.
3695 For example we might have:
3697 @smallexample @c ada
3698 function Direction return Integer;
3699 pragma Postcondition
3700 (Direction'Result = +1
3702 Direction'Result = -1);
3706 which serves to document that the result must be +1 or -1, and
3707 will test that this is the case at run time if postcondition
3710 Postconditions within the subprogram body can be used to
3711 check that some internal aspect of the implementation,
3712 not visible to the client, is operating as expected.
3713 For instance if a square root routine keeps an internal
3714 counter of the number of times it is called, then we
3715 might have the following postcondition:
3717 @smallexample @c ada
3718 Sqrt_Calls : Natural := 0;
3720 function Sqrt (Arg : Float) return Float is
3721 pragma Postcondition
3722 (Sqrt_Calls = Sqrt_Calls'Old + 1);
3728 As this example, shows, the use of the @code{Old} attribute
3729 is often useful in postconditions to refer to the state on
3730 entry to the subprogram.
3732 Note that postconditions are only checked on normal returns
3733 from the subprogram. If an abnormal return results from
3734 raising an exception, then the postconditions are not checked.
3736 If a postcondition fails, then the exception
3737 @code{System.Assertions.Assert_Failure} is raised. If
3738 a message argument was supplied, then the given string
3739 will be used as the exception message. If no message
3740 argument was supplied, then the default message has
3741 the form "Postcondition failed at file:line". The
3742 exception is raised in the context of the subprogram
3743 body, so it is possible to catch postcondition failures
3744 within the subprogram body itself.
3746 Within a package spec, normal visibility rules
3747 in Ada would prevent forward references within a
3748 postcondition pragma to functions defined later in
3749 the same package. This would introduce undesirable
3750 ordering constraints. To avoid this problem, all
3751 postcondition pragmas are analyzed at the end of
3752 the package spec, allowing forward references.
3754 The following example shows that this even allows
3755 mutually recursive postconditions as in:
3757 @smallexample @c ada
3758 package Parity_Functions is
3759 function Odd (X : Natural) return Boolean;
3760 pragma Postcondition
3764 (x /= 0 and then Even (X - 1))));
3766 function Even (X : Natural) return Boolean;
3767 pragma Postcondition
3771 (x /= 1 and then Odd (X - 1))));
3773 end Parity_Functions;
3777 There are no restrictions on the complexity or form of
3778 conditions used within @code{Postcondition} pragmas.
3779 The following example shows that it is even possible
3780 to verify performance behavior.
3782 @smallexample @c ada
3785 Performance : constant Float;
3786 -- Performance constant set by implementation
3787 -- to match target architecture behavior.
3789 procedure Treesort (Arg : String);
3790 -- Sorts characters of argument using N*logN sort
3791 pragma Postcondition
3792 (Float (Clock - Clock'Old) <=
3793 Float (Arg'Length) *
3794 log (Float (Arg'Length)) *
3799 @node Pragma Precondition
3800 @unnumberedsec Pragma Precondition
3801 @cindex Preconditions
3802 @cindex Checks, preconditions
3803 @findex Preconditions
3807 @smallexample @c ada
3808 pragma Precondition (
3809 [Check =>] Boolean_Expression
3810 [,[Message =>] String_Expression]);
3814 The @code{Precondition} pragma is similar to @code{Postcondition}
3815 except that the corresponding checks take place immediately upon
3816 entry to the subprogram, and if a precondition fails, the exception
3817 is raised in the context of the caller, and the attribute 'Result
3818 cannot be used within the precondition expression.
3820 Otherwise, the placement and visibility rules are identical to those
3821 described for postconditions. The following is an example of use
3822 within a package spec:
3824 @smallexample @c ada
3825 package Math_Functions is
3827 function Sqrt (Arg : Float) return Float;
3828 pragma Precondition (Arg >= 0.0)
3833 @code{Postcondition} pragmas may appear either immediate following the
3834 (separate) declaration of a subprogram, or at the start of the
3835 declarations of a subprogram body. Only other pragmas may intervene
3836 (that is appear between the subprogram declaration and its
3837 postconditions, or appear before the postcondition in the
3838 declaration sequence in a subprogram body).
3840 @node Pragma Profile (Ravenscar)
3841 @unnumberedsec Pragma Profile (Ravenscar)
3846 @smallexample @c ada
3847 pragma Profile (Ravenscar);
3851 A configuration pragma that establishes the following set of configuration
3855 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3856 [RM D.2.2] Tasks are dispatched following a preemptive
3857 priority-ordered scheduling policy.
3859 @item Locking_Policy (Ceiling_Locking)
3860 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3861 the ceiling priority of the corresponding protected object.
3863 @c @item Detect_Blocking
3864 @c This pragma forces the detection of potentially blocking operations within a
3865 @c protected operation, and to raise Program_Error if that happens.
3869 plus the following set of restrictions:
3872 @item Max_Entry_Queue_Length = 1
3873 Defines the maximum number of calls that are queued on a (protected) entry.
3874 Note that this restrictions is checked at run time. Violation of this
3875 restriction results in the raising of Program_Error exception at the point of
3876 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3877 always 1 and hence no task can be queued on a protected entry.
3879 @item Max_Protected_Entries = 1
3880 [RM D.7] Specifies the maximum number of entries per protected type. The
3881 bounds of every entry family of a protected unit shall be static, or shall be
3882 defined by a discriminant of a subtype whose corresponding bound is static.
3883 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3885 @item Max_Task_Entries = 0
3886 [RM D.7] Specifies the maximum number of entries
3887 per task. The bounds of every entry family
3888 of a task unit shall be static, or shall be
3889 defined by a discriminant of a subtype whose
3890 corresponding bound is static. A value of zero
3891 indicates that no rendezvous are possible. For
3892 the Profile (Ravenscar), the value of Max_Task_Entries is always
3895 @item No_Abort_Statements
3896 [RM D.7] There are no abort_statements, and there are
3897 no calls to Task_Identification.Abort_Task.
3899 @item No_Asynchronous_Control
3900 There are no semantic dependences on the package
3901 Asynchronous_Task_Control.
3904 There are no semantic dependencies on the package Ada.Calendar.
3906 @item No_Dynamic_Attachment
3907 There is no call to any of the operations defined in package Ada.Interrupts
3908 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3909 Detach_Handler, and Reference).
3911 @item No_Dynamic_Priorities
3912 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3914 @item No_Implicit_Heap_Allocations
3915 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3917 @item No_Local_Protected_Objects
3918 Protected objects and access types that designate
3919 such objects shall be declared only at library level.
3921 @item No_Local_Timing_Events
3922 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
3923 declared at the library level.
3925 @item No_Protected_Type_Allocators
3926 There are no allocators for protected types or
3927 types containing protected subcomponents.
3929 @item No_Relative_Delay
3930 There are no delay_relative statements.
3932 @item No_Requeue_Statements
3933 Requeue statements are not allowed.
3935 @item No_Select_Statements
3936 There are no select_statements.
3938 @item No_Specific_Termination_Handlers
3939 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
3940 or to Ada.Task_Termination.Specific_Handler.
3942 @item No_Task_Allocators
3943 [RM D.7] There are no allocators for task types
3944 or types containing task subcomponents.
3946 @item No_Task_Attributes_Package
3947 There are no semantic dependencies on the Ada.Task_Attributes package.
3949 @item No_Task_Hierarchy
3950 [RM D.7] All (non-environment) tasks depend
3951 directly on the environment task of the partition.
3953 @item No_Task_Termination
3954 Tasks which terminate are erroneous.
3956 @item No_Unchecked_Conversion
3957 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
3959 @item No_Unchecked_Deallocation
3960 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
3962 @item Simple_Barriers
3963 Entry barrier condition expressions shall be either static
3964 boolean expressions or boolean objects which are declared in
3965 the protected type which contains the entry.
3969 This set of configuration pragmas and restrictions correspond to the
3970 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3971 published by the @cite{International Real-Time Ada Workshop}, 1997,
3972 and whose most recent description is available at
3973 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
3975 The original definition of the profile was revised at subsequent IRTAW
3976 meetings. It has been included in the ISO
3977 @cite{Guide for the Use of the Ada Programming Language in High
3978 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3979 the next revision of the standard. The formal definition given by
3980 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3981 AI-305) available at
3982 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3983 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3986 The above set is a superset of the restrictions provided by pragma
3987 @code{Profile (Restricted)}, it includes six additional restrictions
3988 (@code{Simple_Barriers}, @code{No_Select_Statements},
3989 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3990 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
3991 that pragma @code{Profile (Ravenscar)}, like the pragma
3992 @code{Profile (Restricted)},
3993 automatically causes the use of a simplified,
3994 more efficient version of the tasking run-time system.
3996 @node Pragma Profile (Restricted)
3997 @unnumberedsec Pragma Profile (Restricted)
3998 @findex Restricted Run Time
4002 @smallexample @c ada
4003 pragma Profile (Restricted);
4007 A configuration pragma that establishes the following set of restrictions:
4010 @item No_Abort_Statements
4011 @item No_Entry_Queue
4012 @item No_Task_Hierarchy
4013 @item No_Task_Allocators
4014 @item No_Dynamic_Priorities
4015 @item No_Terminate_Alternatives
4016 @item No_Dynamic_Attachment
4017 @item No_Protected_Type_Allocators
4018 @item No_Local_Protected_Objects
4019 @item No_Requeue_Statements
4020 @item No_Task_Attributes_Package
4021 @item Max_Asynchronous_Select_Nesting = 0
4022 @item Max_Task_Entries = 0
4023 @item Max_Protected_Entries = 1
4024 @item Max_Select_Alternatives = 0
4028 This set of restrictions causes the automatic selection of a simplified
4029 version of the run time that provides improved performance for the
4030 limited set of tasking functionality permitted by this set of restrictions.
4032 @node Pragma Psect_Object
4033 @unnumberedsec Pragma Psect_Object
4034 @findex Psect_Object
4038 @smallexample @c ada
4039 pragma Psect_Object (
4040 [Internal =>] LOCAL_NAME,
4041 [, [External =>] EXTERNAL_SYMBOL]
4042 [, [Size =>] EXTERNAL_SYMBOL]);
4046 | static_string_EXPRESSION
4050 This pragma is identical in effect to pragma @code{Common_Object}.
4052 @node Pragma Pure_Function
4053 @unnumberedsec Pragma Pure_Function
4054 @findex Pure_Function
4058 @smallexample @c ada
4059 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4063 This pragma appears in the same declarative part as a function
4064 declaration (or a set of function declarations if more than one
4065 overloaded declaration exists, in which case the pragma applies
4066 to all entities). It specifies that the function @code{Entity} is
4067 to be considered pure for the purposes of code generation. This means
4068 that the compiler can assume that there are no side effects, and
4069 in particular that two calls with identical arguments produce the
4070 same result. It also means that the function can be used in an
4073 Note that, quite deliberately, there are no static checks to try
4074 to ensure that this promise is met, so @code{Pure_Function} can be used
4075 with functions that are conceptually pure, even if they do modify
4076 global variables. For example, a square root function that is
4077 instrumented to count the number of times it is called is still
4078 conceptually pure, and can still be optimized, even though it
4079 modifies a global variable (the count). Memo functions are another
4080 example (where a table of previous calls is kept and consulted to
4081 avoid re-computation).
4084 Note: Most functions in a @code{Pure} package are automatically pure, and
4085 there is no need to use pragma @code{Pure_Function} for such functions. One
4086 exception is any function that has at least one formal of type
4087 @code{System.Address} or a type derived from it. Such functions are not
4088 considered pure by default, since the compiler assumes that the
4089 @code{Address} parameter may be functioning as a pointer and that the
4090 referenced data may change even if the address value does not.
4091 Similarly, imported functions are not considered to be pure by default,
4092 since there is no way of checking that they are in fact pure. The use
4093 of pragma @code{Pure_Function} for such a function will override these default
4094 assumption, and cause the compiler to treat a designated subprogram as pure
4097 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4098 applies to the underlying renamed function. This can be used to
4099 disambiguate cases of overloading where some but not all functions
4100 in a set of overloaded functions are to be designated as pure.
4102 If pragma @code{Pure_Function} is applied to a library level function, the
4103 function is also considered pure from an optimization point of view, but the
4104 unit is not a Pure unit in the categorization sense. So for example, a function
4105 thus marked is free to @code{with} non-pure units.
4107 @node Pragma Restriction_Warnings
4108 @unnumberedsec Pragma Restriction_Warnings
4109 @findex Restriction_Warnings
4113 @smallexample @c ada
4114 pragma Restriction_Warnings
4115 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4119 This pragma allows a series of restriction identifiers to be
4120 specified (the list of allowed identifiers is the same as for
4121 pragma @code{Restrictions}). For each of these identifiers
4122 the compiler checks for violations of the restriction, but
4123 generates a warning message rather than an error message
4124 if the restriction is violated.
4127 @unnumberedsec Pragma Shared
4131 This pragma is provided for compatibility with Ada 83. The syntax and
4132 semantics are identical to pragma Atomic.
4134 @node Pragma Source_File_Name
4135 @unnumberedsec Pragma Source_File_Name
4136 @findex Source_File_Name
4140 @smallexample @c ada
4141 pragma Source_File_Name (
4142 [Unit_Name =>] unit_NAME,
4143 Spec_File_Name => STRING_LITERAL);
4145 pragma Source_File_Name (
4146 [Unit_Name =>] unit_NAME,
4147 Body_File_Name => STRING_LITERAL);
4151 Use this to override the normal naming convention. It is a configuration
4152 pragma, and so has the usual applicability of configuration pragmas
4153 (i.e.@: it applies to either an entire partition, or to all units in a
4154 compilation, or to a single unit, depending on how it is used.
4155 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4156 the second argument is required, and indicates whether this is the file
4157 name for the spec or for the body.
4159 Another form of the @code{Source_File_Name} pragma allows
4160 the specification of patterns defining alternative file naming schemes
4161 to apply to all files.
4163 @smallexample @c ada
4164 pragma Source_File_Name
4165 (Spec_File_Name => STRING_LITERAL
4166 [,Casing => CASING_SPEC]
4167 [,Dot_Replacement => STRING_LITERAL]);
4169 pragma Source_File_Name
4170 (Body_File_Name => STRING_LITERAL
4171 [,Casing => CASING_SPEC]
4172 [,Dot_Replacement => STRING_LITERAL]);
4174 pragma Source_File_Name
4175 (Subunit_File_Name => STRING_LITERAL
4176 [,Casing => CASING_SPEC]
4177 [,Dot_Replacement => STRING_LITERAL]);
4179 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4183 The first argument is a pattern that contains a single asterisk indicating
4184 the point at which the unit name is to be inserted in the pattern string
4185 to form the file name. The second argument is optional. If present it
4186 specifies the casing of the unit name in the resulting file name string.
4187 The default is lower case. Finally the third argument allows for systematic
4188 replacement of any dots in the unit name by the specified string literal.
4190 A pragma Source_File_Name cannot appear after a
4191 @ref{Pragma Source_File_Name_Project}.
4193 For more details on the use of the @code{Source_File_Name} pragma,
4194 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4195 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4198 @node Pragma Source_File_Name_Project
4199 @unnumberedsec Pragma Source_File_Name_Project
4200 @findex Source_File_Name_Project
4203 This pragma has the same syntax and semantics as pragma Source_File_Name.
4204 It is only allowed as a stand alone configuration pragma.
4205 It cannot appear after a @ref{Pragma Source_File_Name}, and
4206 most importantly, once pragma Source_File_Name_Project appears,
4207 no further Source_File_Name pragmas are allowed.
4209 The intention is that Source_File_Name_Project pragmas are always
4210 generated by the Project Manager in a manner consistent with the naming
4211 specified in a project file, and when naming is controlled in this manner,
4212 it is not permissible to attempt to modify this naming scheme using
4213 Source_File_Name pragmas (which would not be known to the project manager).
4215 @node Pragma Source_Reference
4216 @unnumberedsec Pragma Source_Reference
4217 @findex Source_Reference
4221 @smallexample @c ada
4222 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4226 This pragma must appear as the first line of a source file.
4227 @var{integer_literal} is the logical line number of the line following
4228 the pragma line (for use in error messages and debugging
4229 information). @var{string_literal} is a static string constant that
4230 specifies the file name to be used in error messages and debugging
4231 information. This is most notably used for the output of @code{gnatchop}
4232 with the @option{-r} switch, to make sure that the original unchopped
4233 source file is the one referred to.
4235 The second argument must be a string literal, it cannot be a static
4236 string expression other than a string literal. This is because its value
4237 is needed for error messages issued by all phases of the compiler.
4239 @node Pragma Stream_Convert
4240 @unnumberedsec Pragma Stream_Convert
4241 @findex Stream_Convert
4245 @smallexample @c ada
4246 pragma Stream_Convert (
4247 [Entity =>] type_LOCAL_NAME,
4248 [Read =>] function_NAME,
4249 [Write =>] function_NAME);
4253 This pragma provides an efficient way of providing stream functions for
4254 types defined in packages. Not only is it simpler to use than declaring
4255 the necessary functions with attribute representation clauses, but more
4256 significantly, it allows the declaration to made in such a way that the
4257 stream packages are not loaded unless they are needed. The use of
4258 the Stream_Convert pragma adds no overhead at all, unless the stream
4259 attributes are actually used on the designated type.
4261 The first argument specifies the type for which stream functions are
4262 provided. The second parameter provides a function used to read values
4263 of this type. It must name a function whose argument type may be any
4264 subtype, and whose returned type must be the type given as the first
4265 argument to the pragma.
4267 The meaning of the @var{Read}
4268 parameter is that if a stream attribute directly
4269 or indirectly specifies reading of the type given as the first parameter,
4270 then a value of the type given as the argument to the Read function is
4271 read from the stream, and then the Read function is used to convert this
4272 to the required target type.
4274 Similarly the @var{Write} parameter specifies how to treat write attributes
4275 that directly or indirectly apply to the type given as the first parameter.
4276 It must have an input parameter of the type specified by the first parameter,
4277 and the return type must be the same as the input type of the Read function.
4278 The effect is to first call the Write function to convert to the given stream
4279 type, and then write the result type to the stream.
4281 The Read and Write functions must not be overloaded subprograms. If necessary
4282 renamings can be supplied to meet this requirement.
4283 The usage of this attribute is best illustrated by a simple example, taken
4284 from the GNAT implementation of package Ada.Strings.Unbounded:
4286 @smallexample @c ada
4287 function To_Unbounded (S : String)
4288 return Unbounded_String
4289 renames To_Unbounded_String;
4291 pragma Stream_Convert
4292 (Unbounded_String, To_Unbounded, To_String);
4296 The specifications of the referenced functions, as given in the Ada
4297 Reference Manual are:
4299 @smallexample @c ada
4300 function To_Unbounded_String (Source : String)
4301 return Unbounded_String;
4303 function To_String (Source : Unbounded_String)
4308 The effect is that if the value of an unbounded string is written to a
4309 stream, then the representation of the item in the stream is in the same
4310 format used for @code{Standard.String}, and this same representation is
4311 expected when a value of this type is read from the stream.
4313 @node Pragma Style_Checks
4314 @unnumberedsec Pragma Style_Checks
4315 @findex Style_Checks
4319 @smallexample @c ada
4320 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4321 On | Off [, LOCAL_NAME]);
4325 This pragma is used in conjunction with compiler switches to control the
4326 built in style checking provided by GNAT@. The compiler switches, if set,
4327 provide an initial setting for the switches, and this pragma may be used
4328 to modify these settings, or the settings may be provided entirely by
4329 the use of the pragma. This pragma can be used anywhere that a pragma
4330 is legal, including use as a configuration pragma (including use in
4331 the @file{gnat.adc} file).
4333 The form with a string literal specifies which style options are to be
4334 activated. These are additive, so they apply in addition to any previously
4335 set style check options. The codes for the options are the same as those
4336 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4337 For example the following two methods can be used to enable
4342 @smallexample @c ada
4343 pragma Style_Checks ("l");
4348 gcc -c -gnatyl @dots{}
4353 The form ALL_CHECKS activates all standard checks (its use is equivalent
4354 to the use of the @code{gnaty} switch with no options. @xref{Top,
4355 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4356 @value{EDITION} User's Guide}, for details.
4358 The forms with @code{Off} and @code{On}
4359 can be used to temporarily disable style checks
4360 as shown in the following example:
4362 @smallexample @c ada
4366 pragma Style_Checks ("k"); -- requires keywords in lower case
4367 pragma Style_Checks (Off); -- turn off style checks
4368 NULL; -- this will not generate an error message
4369 pragma Style_Checks (On); -- turn style checks back on
4370 NULL; -- this will generate an error message
4374 Finally the two argument form is allowed only if the first argument is
4375 @code{On} or @code{Off}. The effect is to turn of semantic style checks
4376 for the specified entity, as shown in the following example:
4378 @smallexample @c ada
4382 pragma Style_Checks ("r"); -- require consistency of identifier casing
4384 Rf1 : Integer := ARG; -- incorrect, wrong case
4385 pragma Style_Checks (Off, Arg);
4386 Rf2 : Integer := ARG; -- OK, no error
4389 @node Pragma Subtitle
4390 @unnumberedsec Pragma Subtitle
4395 @smallexample @c ada
4396 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4400 This pragma is recognized for compatibility with other Ada compilers
4401 but is ignored by GNAT@.
4403 @node Pragma Suppress
4404 @unnumberedsec Pragma Suppress
4409 @smallexample @c ada
4410 pragma Suppress (Identifier [, [On =>] Name]);
4414 This is a standard pragma, and supports all the check names required in
4415 the RM. It is included here because GNAT recognizes one additional check
4416 name: @code{Alignment_Check} which can be used to suppress alignment checks
4417 on addresses used in address clauses. Such checks can also be suppressed
4418 by suppressing range checks, but the specific use of @code{Alignment_Check}
4419 allows suppression of alignment checks without suppressing other range checks.
4421 @node Pragma Suppress_All
4422 @unnumberedsec Pragma Suppress_All
4423 @findex Suppress_All
4427 @smallexample @c ada
4428 pragma Suppress_All;
4432 This pragma can only appear immediately following a compilation
4433 unit. The effect is to apply @code{Suppress (All_Checks)} to the unit
4434 which it follows. This pragma is implemented for compatibility with DEC
4435 Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal
4436 configuration pragma is the preferred usage in GNAT@.
4438 @node Pragma Suppress_Exception_Locations
4439 @unnumberedsec Pragma Suppress_Exception_Locations
4440 @findex Suppress_Exception_Locations
4444 @smallexample @c ada
4445 pragma Suppress_Exception_Locations;
4449 In normal mode, a raise statement for an exception by default generates
4450 an exception message giving the file name and line number for the location
4451 of the raise. This is useful for debugging and logging purposes, but this
4452 entails extra space for the strings for the messages. The configuration
4453 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4454 generation of these strings, with the result that space is saved, but the
4455 exception message for such raises is null. This configuration pragma may
4456 appear in a global configuration pragma file, or in a specific unit as
4457 usual. It is not required that this pragma be used consistently within
4458 a partition, so it is fine to have some units within a partition compiled
4459 with this pragma and others compiled in normal mode without it.
4461 @node Pragma Suppress_Initialization
4462 @unnumberedsec Pragma Suppress_Initialization
4463 @findex Suppress_Initialization
4464 @cindex Suppressing initialization
4465 @cindex Initialization, suppression of
4469 @smallexample @c ada
4470 pragma Suppress_Initialization ([Entity =>] type_Name);
4474 This pragma suppresses any implicit or explicit initialization
4475 associated with the given type name for all variables of this type.
4477 @node Pragma Task_Info
4478 @unnumberedsec Pragma Task_Info
4483 @smallexample @c ada
4484 pragma Task_Info (EXPRESSION);
4488 This pragma appears within a task definition (like pragma
4489 @code{Priority}) and applies to the task in which it appears. The
4490 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4491 The @code{Task_Info} pragma provides system dependent control over
4492 aspects of tasking implementation, for example, the ability to map
4493 tasks to specific processors. For details on the facilities available
4494 for the version of GNAT that you are using, see the documentation
4495 in the spec of package System.Task_Info in the runtime
4498 @node Pragma Task_Name
4499 @unnumberedsec Pragma Task_Name
4504 @smallexample @c ada
4505 pragma Task_Name (string_EXPRESSION);
4509 This pragma appears within a task definition (like pragma
4510 @code{Priority}) and applies to the task in which it appears. The
4511 argument must be of type String, and provides a name to be used for
4512 the task instance when the task is created. Note that this expression
4513 is not required to be static, and in particular, it can contain
4514 references to task discriminants. This facility can be used to
4515 provide different names for different tasks as they are created,
4516 as illustrated in the example below.
4518 The task name is recorded internally in the run-time structures
4519 and is accessible to tools like the debugger. In addition the
4520 routine @code{Ada.Task_Identification.Image} will return this
4521 string, with a unique task address appended.
4523 @smallexample @c ada
4524 -- Example of the use of pragma Task_Name
4526 with Ada.Task_Identification;
4527 use Ada.Task_Identification;
4528 with Text_IO; use Text_IO;
4531 type Astring is access String;
4533 task type Task_Typ (Name : access String) is
4534 pragma Task_Name (Name.all);
4537 task body Task_Typ is
4538 Nam : constant String := Image (Current_Task);
4540 Put_Line ("-->" & Nam (1 .. 14) & "<--");
4543 type Ptr_Task is access Task_Typ;
4544 Task_Var : Ptr_Task;
4548 new Task_Typ (new String'("This is task 1"));
4550 new Task_Typ (new String'("This is task 2"));
4554 @node Pragma Task_Storage
4555 @unnumberedsec Pragma Task_Storage
4556 @findex Task_Storage
4559 @smallexample @c ada
4560 pragma Task_Storage (
4561 [Task_Type =>] LOCAL_NAME,
4562 [Top_Guard =>] static_integer_EXPRESSION);
4566 This pragma specifies the length of the guard area for tasks. The guard
4567 area is an additional storage area allocated to a task. A value of zero
4568 means that either no guard area is created or a minimal guard area is
4569 created, depending on the target. This pragma can appear anywhere a
4570 @code{Storage_Size} attribute definition clause is allowed for a task
4573 @node Pragma Time_Slice
4574 @unnumberedsec Pragma Time_Slice
4579 @smallexample @c ada
4580 pragma Time_Slice (static_duration_EXPRESSION);
4584 For implementations of GNAT on operating systems where it is possible
4585 to supply a time slice value, this pragma may be used for this purpose.
4586 It is ignored if it is used in a system that does not allow this control,
4587 or if it appears in other than the main program unit.
4589 Note that the effect of this pragma is identical to the effect of the
4590 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4593 @unnumberedsec Pragma Title
4598 @smallexample @c ada
4599 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4602 [Title =>] STRING_LITERAL,
4603 | [Subtitle =>] STRING_LITERAL
4607 Syntax checked but otherwise ignored by GNAT@. This is a listing control
4608 pragma used in DEC Ada 83 implementations to provide a title and/or
4609 subtitle for the program listing. The program listing generated by GNAT
4610 does not have titles or subtitles.
4612 Unlike other pragmas, the full flexibility of named notation is allowed
4613 for this pragma, i.e.@: the parameters may be given in any order if named
4614 notation is used, and named and positional notation can be mixed
4615 following the normal rules for procedure calls in Ada.
4617 @node Pragma Unchecked_Union
4618 @unnumberedsec Pragma Unchecked_Union
4620 @findex Unchecked_Union
4624 @smallexample @c ada
4625 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4629 This pragma is used to specify a representation of a record type that is
4630 equivalent to a C union. It was introduced as a GNAT implementation defined
4631 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4632 pragma, making it language defined, and GNAT fully implements this extended
4633 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4634 details, consult the Ada 2005 Reference Manual, section B.3.3.
4636 @node Pragma Unimplemented_Unit
4637 @unnumberedsec Pragma Unimplemented_Unit
4638 @findex Unimplemented_Unit
4642 @smallexample @c ada
4643 pragma Unimplemented_Unit;
4647 If this pragma occurs in a unit that is processed by the compiler, GNAT
4648 aborts with the message @samp{@var{xxx} not implemented}, where
4649 @var{xxx} is the name of the current compilation unit. This pragma is
4650 intended to allow the compiler to handle unimplemented library units in
4653 The abort only happens if code is being generated. Thus you can use
4654 specs of unimplemented packages in syntax or semantic checking mode.
4656 @node Pragma Universal_Aliasing
4657 @unnumberedsec Pragma Universal_Aliasing
4658 @findex Universal_Aliasing
4662 @smallexample @c ada
4663 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4667 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4668 declarative part. The effect is to inhibit strict type-based aliasing
4669 optimization for the given type. In other words, the effect is as though
4670 access types designating this type were subject to pragma No_Strict_Aliasing.
4671 For a detailed description of the strict aliasing optimization, and the
4672 situations in which it must be suppressed, @xref{Optimization and Strict
4673 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4675 @node Pragma Universal_Data
4676 @unnumberedsec Pragma Universal_Data
4677 @findex Universal_Data
4681 @smallexample @c ada
4682 pragma Universal_Data [(library_unit_Name)];
4686 This pragma is supported only for the AAMP target and is ignored for
4687 other targets. The pragma specifies that all library-level objects
4688 (Counter 0 data) associated with the library unit are to be accessed
4689 and updated using universal addressing (24-bit addresses for AAMP5)
4690 rather than the default of 16-bit Data Environment (DENV) addressing.
4691 Use of this pragma will generally result in less efficient code for
4692 references to global data associated with the library unit, but
4693 allows such data to be located anywhere in memory. This pragma is
4694 a library unit pragma, but can also be used as a configuration pragma
4695 (including use in the @file{gnat.adc} file). The functionality
4696 of this pragma is also available by applying the -univ switch on the
4697 compilations of units where universal addressing of the data is desired.
4699 @node Pragma Unmodified
4700 @unnumberedsec Pragma Unmodified
4702 @cindex Warnings, unmodified
4706 @smallexample @c ada
4707 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4711 This pragma signals that the assignable entities (variables,
4712 @code{out} parameters, @code{in out} parameters) whose names are listed are
4713 deliberately not assigned in the current source unit. This
4714 suppresses warnings about the
4715 entities being referenced but not assigned, and in addition a warning will be
4716 generated if one of these entities is in fact assigned in the
4717 same unit as the pragma (or in the corresponding body, or one
4720 This is particularly useful for clearly signaling that a particular
4721 parameter is not modified, even though the spec suggests that it might
4724 @node Pragma Unreferenced
4725 @unnumberedsec Pragma Unreferenced
4726 @findex Unreferenced
4727 @cindex Warnings, unreferenced
4731 @smallexample @c ada
4732 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4733 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4737 This pragma signals that the entities whose names are listed are
4738 deliberately not referenced in the current source unit. This
4739 suppresses warnings about the
4740 entities being unreferenced, and in addition a warning will be
4741 generated if one of these entities is in fact referenced in the
4742 same unit as the pragma (or in the corresponding body, or one
4745 This is particularly useful for clearly signaling that a particular
4746 parameter is not referenced in some particular subprogram implementation
4747 and that this is deliberate. It can also be useful in the case of
4748 objects declared only for their initialization or finalization side
4751 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4752 current scope, then the entity most recently declared is the one to which
4753 the pragma applies. Note that in the case of accept formals, the pragma
4754 Unreferenced may appear immediately after the keyword @code{do} which
4755 allows the indication of whether or not accept formals are referenced
4756 or not to be given individually for each accept statement.
4758 The left hand side of an assignment does not count as a reference for the
4759 purpose of this pragma. Thus it is fine to assign to an entity for which
4760 pragma Unreferenced is given.
4762 Note that if a warning is desired for all calls to a given subprogram,
4763 regardless of whether they occur in the same unit as the subprogram
4764 declaration, then this pragma should not be used (calls from another
4765 unit would not be flagged); pragma Obsolescent can be used instead
4766 for this purpose, see @xref{Pragma Obsolescent}.
4768 The second form of pragma @code{Unreferenced} is used within a context
4769 clause. In this case the arguments must be unit names of units previously
4770 mentioned in @code{with} clauses (similar to the usage of pragma
4771 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4772 units and unreferenced entities within these units.
4774 @node Pragma Unreferenced_Objects
4775 @unnumberedsec Pragma Unreferenced_Objects
4776 @findex Unreferenced_Objects
4777 @cindex Warnings, unreferenced
4781 @smallexample @c ada
4782 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4786 This pragma signals that for the types or subtypes whose names are
4787 listed, objects which are declared with one of these types or subtypes may
4788 not be referenced, and if no references appear, no warnings are given.
4790 This is particularly useful for objects which are declared solely for their
4791 initialization and finalization effect. Such variables are sometimes referred
4792 to as RAII variables (Resource Acquisition Is Initialization). Using this
4793 pragma on the relevant type (most typically a limited controlled type), the
4794 compiler will automatically suppress unwanted warnings about these variables
4795 not being referenced.
4797 @node Pragma Unreserve_All_Interrupts
4798 @unnumberedsec Pragma Unreserve_All_Interrupts
4799 @findex Unreserve_All_Interrupts
4803 @smallexample @c ada
4804 pragma Unreserve_All_Interrupts;
4808 Normally certain interrupts are reserved to the implementation. Any attempt
4809 to attach an interrupt causes Program_Error to be raised, as described in
4810 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
4811 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
4812 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4813 interrupt execution.
4815 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4816 a program, then all such interrupts are unreserved. This allows the
4817 program to handle these interrupts, but disables their standard
4818 functions. For example, if this pragma is used, then pressing
4819 @kbd{Ctrl-C} will not automatically interrupt execution. However,
4820 a program can then handle the @code{SIGINT} interrupt as it chooses.
4822 For a full list of the interrupts handled in a specific implementation,
4823 see the source code for the spec of @code{Ada.Interrupts.Names} in
4824 file @file{a-intnam.ads}. This is a target dependent file that contains the
4825 list of interrupts recognized for a given target. The documentation in
4826 this file also specifies what interrupts are affected by the use of
4827 the @code{Unreserve_All_Interrupts} pragma.
4829 For a more general facility for controlling what interrupts can be
4830 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4831 of the @code{Unreserve_All_Interrupts} pragma.
4833 @node Pragma Unsuppress
4834 @unnumberedsec Pragma Unsuppress
4839 @smallexample @c ada
4840 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4844 This pragma undoes the effect of a previous pragma @code{Suppress}. If
4845 there is no corresponding pragma @code{Suppress} in effect, it has no
4846 effect. The range of the effect is the same as for pragma
4847 @code{Suppress}. The meaning of the arguments is identical to that used
4848 in pragma @code{Suppress}.
4850 One important application is to ensure that checks are on in cases where
4851 code depends on the checks for its correct functioning, so that the code
4852 will compile correctly even if the compiler switches are set to suppress
4855 @node Pragma Use_VADS_Size
4856 @unnumberedsec Pragma Use_VADS_Size
4857 @cindex @code{Size}, VADS compatibility
4858 @findex Use_VADS_Size
4862 @smallexample @c ada
4863 pragma Use_VADS_Size;
4867 This is a configuration pragma. In a unit to which it applies, any use
4868 of the 'Size attribute is automatically interpreted as a use of the
4869 'VADS_Size attribute. Note that this may result in incorrect semantic
4870 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
4871 the handling of existing code which depends on the interpretation of Size
4872 as implemented in the VADS compiler. See description of the VADS_Size
4873 attribute for further details.
4875 @node Pragma Validity_Checks
4876 @unnumberedsec Pragma Validity_Checks
4877 @findex Validity_Checks
4881 @smallexample @c ada
4882 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4886 This pragma is used in conjunction with compiler switches to control the
4887 built-in validity checking provided by GNAT@. The compiler switches, if set
4888 provide an initial setting for the switches, and this pragma may be used
4889 to modify these settings, or the settings may be provided entirely by
4890 the use of the pragma. This pragma can be used anywhere that a pragma
4891 is legal, including use as a configuration pragma (including use in
4892 the @file{gnat.adc} file).
4894 The form with a string literal specifies which validity options are to be
4895 activated. The validity checks are first set to include only the default
4896 reference manual settings, and then a string of letters in the string
4897 specifies the exact set of options required. The form of this string
4898 is exactly as described for the @option{-gnatVx} compiler switch (see the
4899 GNAT users guide for details). For example the following two methods
4900 can be used to enable validity checking for mode @code{in} and
4901 @code{in out} subprogram parameters:
4905 @smallexample @c ada
4906 pragma Validity_Checks ("im");
4911 gcc -c -gnatVim @dots{}
4916 The form ALL_CHECKS activates all standard checks (its use is equivalent
4917 to the use of the @code{gnatva} switch.
4919 The forms with @code{Off} and @code{On}
4920 can be used to temporarily disable validity checks
4921 as shown in the following example:
4923 @smallexample @c ada
4927 pragma Validity_Checks ("c"); -- validity checks for copies
4928 pragma Validity_Checks (Off); -- turn off validity checks
4929 A := B; -- B will not be validity checked
4930 pragma Validity_Checks (On); -- turn validity checks back on
4931 A := C; -- C will be validity checked
4934 @node Pragma Volatile
4935 @unnumberedsec Pragma Volatile
4940 @smallexample @c ada
4941 pragma Volatile (LOCAL_NAME);
4945 This pragma is defined by the Ada Reference Manual, and the GNAT
4946 implementation is fully conformant with this definition. The reason it
4947 is mentioned in this section is that a pragma of the same name was supplied
4948 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
4949 implementation of pragma Volatile is upwards compatible with the
4950 implementation in DEC Ada 83.
4952 @node Pragma Warnings
4953 @unnumberedsec Pragma Warnings
4958 @smallexample @c ada
4959 pragma Warnings (On | Off);
4960 pragma Warnings (On | Off, LOCAL_NAME);
4961 pragma Warnings (static_string_EXPRESSION);
4962 pragma Warnings (On | Off, static_string_EXPRESSION);
4966 Normally warnings are enabled, with the output being controlled by
4967 the command line switch. Warnings (@code{Off}) turns off generation of
4968 warnings until a Warnings (@code{On}) is encountered or the end of the
4969 current unit. If generation of warnings is turned off using this
4970 pragma, then no warning messages are output, regardless of the
4971 setting of the command line switches.
4973 The form with a single argument may be used as a configuration pragma.
4975 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
4976 the specified entity. This suppression is effective from the point where
4977 it occurs till the end of the extended scope of the variable (similar to
4978 the scope of @code{Suppress}).
4980 The form with a single static_string_EXPRESSION argument provides more precise
4981 control over which warnings are active. The string is a list of letters
4982 specifying which warnings are to be activated and which deactivated. The
4983 code for these letters is the same as the string used in the command
4984 line switch controlling warnings. The following is a brief summary. For
4985 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
4989 a turn on all optional warnings (except d h l .o)
4990 A turn off all optional warnings
4991 .a* turn on warnings for failing assertions
4992 .A turn off warnings for failing assertions
4993 b turn on warnings for bad fixed value (not multiple of small)
4994 B* turn off warnings for bad fixed value (not multiple of small)
4995 c turn on warnings for constant conditional
4996 C* turn off warnings for constant conditional
4997 .c turn on warnings for unrepped components
4998 .C* turn off warnings for unrepped components
4999 d turn on warnings for implicit dereference
5000 D* turn off warnings for implicit dereference
5001 e treat all warnings as errors
5002 f turn on warnings for unreferenced formal
5003 F* turn off warnings for unreferenced formal
5004 g* turn on warnings for unrecognized pragma
5005 G turn off warnings for unrecognized pragma
5006 h turn on warnings for hiding variable
5007 H* turn off warnings for hiding variable
5008 i* turn on warnings for implementation unit
5009 I turn off warnings for implementation unit
5010 j turn on warnings for obsolescent (annex J) feature
5011 J* turn off warnings for obsolescent (annex J) feature
5012 k turn on warnings on constant variable
5013 K* turn off warnings on constant variable
5014 l turn on warnings for missing elaboration pragma
5015 L* turn off warnings for missing elaboration pragma
5016 m turn on warnings for variable assigned but not read
5017 M* turn off warnings for variable assigned but not read
5018 n* normal warning mode (cancels -gnatws/-gnatwe)
5019 o* turn on warnings for address clause overlay
5020 O turn off warnings for address clause overlay
5021 .o turn on warnings for out parameters assigned but not read
5022 .O* turn off warnings for out parameters assigned but not read
5023 p turn on warnings for ineffective pragma Inline in frontend
5024 P* turn off warnings for ineffective pragma Inline in frontend
5025 q* turn on warnings for questionable missing parentheses
5026 Q turn off warnings for questionable missing parentheses
5027 r turn on warnings for redundant construct
5028 R* turn off warnings for redundant construct
5029 .r turn on warnings for object renaming function
5030 .R* turn off warnings for object renaming function
5031 s suppress all warnings
5032 t turn on warnings for tracking deleted code
5033 T* turn off warnings for tracking deleted code
5034 u turn on warnings for unused entity
5035 U* turn off warnings for unused entity
5036 v* turn on warnings for unassigned variable
5037 V turn off warnings for unassigned variable
5038 w* turn on warnings for wrong low bound assumption
5039 W turn off warnings for wrong low bound assumption
5040 x* turn on warnings for export/import
5041 X turn off warnings for export/import
5042 .x turn on warnings for non-local exceptions
5043 .X* turn off warnings for non-local exceptions
5044 y* turn on warnings for Ada 2005 incompatibility
5045 Y turn off warnings for Ada 2005 incompatibility
5046 z* turn on convention/size/align warnings for unchecked conversion
5047 Z turn off convention/size/align warnings for unchecked conversion
5048 * indicates default in above list
5052 The specified warnings will be in effect until the end of the program
5053 or another pragma Warnings is encountered. The effect of the pragma is
5054 cumulative. Initially the set of warnings is the standard default set
5055 as possibly modified by compiler switches. Then each pragma Warning
5056 modifies this set of warnings as specified. This form of the pragma may
5057 also be used as a configuration pragma.
5059 The fourth form, with an On|Off parameter and a string, is used to
5060 control individual messages, based on their text. The string argument
5061 is a pattern that is used to match against the text of individual
5062 warning messages (not including the initial "warnings: " tag).
5064 The pattern may contain asterisks which match zero or more characters in
5065 the message. For example, you can use
5066 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5067 message @code{warning: 960 bits of "a" unused}. No other regular
5068 expression notations are permitted. All characters other than asterisk in
5069 these three specific cases are treated as literal characters in the match.
5071 There are two ways to use this pragma. The OFF form can be used as a
5072 configuration pragma. The effect is to suppress all warnings (if any)
5073 that match the pattern string throughout the compilation.
5075 The second usage is to suppress a warning locally, and in this case, two
5076 pragmas must appear in sequence:
5078 @smallexample @c ada
5079 pragma Warnings (Off, Pattern);
5080 @dots{} code where given warning is to be suppressed
5081 pragma Warnings (On, Pattern);
5085 In this usage, the pattern string must match in the Off and On pragmas,
5086 and at least one matching warning must be suppressed.
5088 @node Pragma Weak_External
5089 @unnumberedsec Pragma Weak_External
5090 @findex Weak_External
5094 @smallexample @c ada
5095 pragma Weak_External ([Entity =>] LOCAL_NAME);
5099 @var{LOCAL_NAME} must refer to an object that is declared at the library
5100 level. This pragma specifies that the given entity should be marked as a
5101 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5102 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5103 of a regular symbol, that is to say a symbol that does not have to be
5104 resolved by the linker if used in conjunction with a pragma Import.
5106 When a weak symbol is not resolved by the linker, its address is set to
5107 zero. This is useful in writing interfaces to external modules that may
5108 or may not be linked in the final executable, for example depending on
5109 configuration settings.
5111 If a program references at run time an entity to which this pragma has been
5112 applied, and the corresponding symbol was not resolved at link time, then
5113 the execution of the program is erroneous. It is not erroneous to take the
5114 Address of such an entity, for example to guard potential references,
5115 as shown in the example below.
5117 Some file formats do not support weak symbols so not all target machines
5118 support this pragma.
5120 @smallexample @c ada
5121 -- Example of the use of pragma Weak_External
5123 package External_Module is
5125 pragma Import (C, key);
5126 pragma Weak_External (key);
5127 function Present return boolean;
5128 end External_Module;
5130 with System; use System;
5131 package body External_Module is
5132 function Present return boolean is
5134 return key'Address /= System.Null_Address;
5136 end External_Module;
5139 @node Pragma Wide_Character_Encoding
5140 @unnumberedsec Pragma Wide_Character_Encoding
5141 @findex Wide_Character_Encoding
5145 @smallexample @c ada
5146 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5150 This pragma specifies the wide character encoding to be used in program
5151 source text appearing subsequently. It is a configuration pragma, but may
5152 also be used at any point that a pragma is allowed, and it is permissible
5153 to have more than one such pragma in a file, allowing multiple encodings
5154 to appear within the same file.
5156 The argument can be an identifier or a character literal. In the identifier
5157 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5158 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5159 case it is correspondingly one of the characters @samp{h}, @samp{u},
5160 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5162 Note that when the pragma is used within a file, it affects only the
5163 encoding within that file, and does not affect withed units, specs,
5166 @node Implementation Defined Attributes
5167 @chapter Implementation Defined Attributes
5168 Ada defines (throughout the Ada reference manual,
5169 summarized in Annex K),
5170 a set of attributes that provide useful additional functionality in all
5171 areas of the language. These language defined attributes are implemented
5172 in GNAT and work as described in the Ada Reference Manual.
5174 In addition, Ada allows implementations to define additional
5175 attributes whose meaning is defined by the implementation. GNAT provides
5176 a number of these implementation-dependent attributes which can be used
5177 to extend and enhance the functionality of the compiler. This section of
5178 the GNAT reference manual describes these additional attributes.
5180 Note that any program using these attributes may not be portable to
5181 other compilers (although GNAT implements this set of attributes on all
5182 platforms). Therefore if portability to other compilers is an important
5183 consideration, you should minimize the use of these attributes.
5194 * Default_Bit_Order::
5204 * Has_Access_Values::
5205 * Has_Discriminants::
5212 * Max_Interrupt_Priority::
5214 * Maximum_Alignment::
5219 * Passed_By_Reference::
5232 * Unconstrained_Array::
5233 * Universal_Literal_String::
5234 * Unrestricted_Access::
5242 @unnumberedsec Abort_Signal
5243 @findex Abort_Signal
5245 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5246 prefix) provides the entity for the special exception used to signal
5247 task abort or asynchronous transfer of control. Normally this attribute
5248 should only be used in the tasking runtime (it is highly peculiar, and
5249 completely outside the normal semantics of Ada, for a user program to
5250 intercept the abort exception).
5253 @unnumberedsec Address_Size
5254 @cindex Size of @code{Address}
5255 @findex Address_Size
5257 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5258 prefix) is a static constant giving the number of bits in an
5259 @code{Address}. It is the same value as System.Address'Size,
5260 but has the advantage of being static, while a direct
5261 reference to System.Address'Size is non-static because Address
5265 @unnumberedsec Asm_Input
5268 The @code{Asm_Input} attribute denotes a function that takes two
5269 parameters. The first is a string, the second is an expression of the
5270 type designated by the prefix. The first (string) argument is required
5271 to be a static expression, and is the constraint for the parameter,
5272 (e.g.@: what kind of register is required). The second argument is the
5273 value to be used as the input argument. The possible values for the
5274 constant are the same as those used in the RTL, and are dependent on
5275 the configuration file used to built the GCC back end.
5276 @ref{Machine Code Insertions}
5279 @unnumberedsec Asm_Output
5282 The @code{Asm_Output} attribute denotes a function that takes two
5283 parameters. The first is a string, the second is the name of a variable
5284 of the type designated by the attribute prefix. The first (string)
5285 argument is required to be a static expression and designates the
5286 constraint for the parameter (e.g.@: what kind of register is
5287 required). The second argument is the variable to be updated with the
5288 result. The possible values for constraint are the same as those used in
5289 the RTL, and are dependent on the configuration file used to build the
5290 GCC back end. If there are no output operands, then this argument may
5291 either be omitted, or explicitly given as @code{No_Output_Operands}.
5292 @ref{Machine Code Insertions}
5295 @unnumberedsec AST_Entry
5299 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
5300 the name of an entry, it yields a value of the predefined type AST_Handler
5301 (declared in the predefined package System, as extended by the use of
5302 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
5303 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
5304 Language Reference Manual}, section 9.12a.
5309 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5310 offset within the storage unit (byte) that contains the first bit of
5311 storage allocated for the object. The value of this attribute is of the
5312 type @code{Universal_Integer}, and is always a non-negative number not
5313 exceeding the value of @code{System.Storage_Unit}.
5315 For an object that is a variable or a constant allocated in a register,
5316 the value is zero. (The use of this attribute does not force the
5317 allocation of a variable to memory).
5319 For an object that is a formal parameter, this attribute applies
5320 to either the matching actual parameter or to a copy of the
5321 matching actual parameter.
5323 For an access object the value is zero. Note that
5324 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5325 designated object. Similarly for a record component
5326 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5327 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5328 are subject to index checks.
5330 This attribute is designed to be compatible with the DEC Ada 83 definition
5331 and implementation of the @code{Bit} attribute.
5334 @unnumberedsec Bit_Position
5335 @findex Bit_Position
5337 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5338 of the fields of the record type, yields the bit
5339 offset within the record contains the first bit of
5340 storage allocated for the object. The value of this attribute is of the
5341 type @code{Universal_Integer}. The value depends only on the field
5342 @var{C} and is independent of the alignment of
5343 the containing record @var{R}.
5346 @unnumberedsec Code_Address
5347 @findex Code_Address
5348 @cindex Subprogram address
5349 @cindex Address of subprogram code
5352 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5353 intended effect seems to be to provide
5354 an address value which can be used to call the subprogram by means of
5355 an address clause as in the following example:
5357 @smallexample @c ada
5358 procedure K is @dots{}
5361 for L'Address use K'Address;
5362 pragma Import (Ada, L);
5366 A call to @code{L} is then expected to result in a call to @code{K}@.
5367 In Ada 83, where there were no access-to-subprogram values, this was
5368 a common work-around for getting the effect of an indirect call.
5369 GNAT implements the above use of @code{Address} and the technique
5370 illustrated by the example code works correctly.
5372 However, for some purposes, it is useful to have the address of the start
5373 of the generated code for the subprogram. On some architectures, this is
5374 not necessarily the same as the @code{Address} value described above.
5375 For example, the @code{Address} value may reference a subprogram
5376 descriptor rather than the subprogram itself.
5378 The @code{'Code_Address} attribute, which can only be applied to
5379 subprogram entities, always returns the address of the start of the
5380 generated code of the specified subprogram, which may or may not be
5381 the same value as is returned by the corresponding @code{'Address}
5384 @node Default_Bit_Order
5385 @unnumberedsec Default_Bit_Order
5387 @cindex Little endian
5388 @findex Default_Bit_Order
5390 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5391 permissible prefix), provides the value @code{System.Default_Bit_Order}
5392 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5393 @code{Low_Order_First}). This is used to construct the definition of
5394 @code{Default_Bit_Order} in package @code{System}.
5397 @unnumberedsec Elaborated
5400 The prefix of the @code{'Elaborated} attribute must be a unit name. The
5401 value is a Boolean which indicates whether or not the given unit has been
5402 elaborated. This attribute is primarily intended for internal use by the
5403 generated code for dynamic elaboration checking, but it can also be used
5404 in user programs. The value will always be True once elaboration of all
5405 units has been completed. An exception is for units which need no
5406 elaboration, the value is always False for such units.
5409 @unnumberedsec Elab_Body
5412 This attribute can only be applied to a program unit name. It returns
5413 the entity for the corresponding elaboration procedure for elaborating
5414 the body of the referenced unit. This is used in the main generated
5415 elaboration procedure by the binder and is not normally used in any
5416 other context. However, there may be specialized situations in which it
5417 is useful to be able to call this elaboration procedure from Ada code,
5418 e.g.@: if it is necessary to do selective re-elaboration to fix some
5422 @unnumberedsec Elab_Spec
5425 This attribute can only be applied to a program unit name. It returns
5426 the entity for the corresponding elaboration procedure for elaborating
5427 the spec of the referenced unit. This is used in the main
5428 generated elaboration procedure by the binder and is not normally used
5429 in any other context. However, there may be specialized situations in
5430 which it is useful to be able to call this elaboration procedure from
5431 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5436 @cindex Ada 83 attributes
5439 The @code{Emax} attribute is provided for compatibility with Ada 83. See
5440 the Ada 83 reference manual for an exact description of the semantics of
5444 @unnumberedsec Enabled
5447 The @code{Enabled} attribute allows an application program to check at compile
5448 time to see if the designated check is currently enabled. The prefix is a
5449 simple identifier, referencing any predefined check name (other than
5450 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5451 no argument is given for the attribute, the check is for the general state
5452 of the check, if an argument is given, then it is an entity name, and the
5453 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5454 given naming the entity (if not, then the argument is ignored).
5456 Note that instantiations inherit the check status at the point of the
5457 instantiation, so a useful idiom is to have a library package that
5458 introduces a check name with @code{pragma Check_Name}, and then contains
5459 generic packages or subprograms which use the @code{Enabled} attribute
5460 to see if the check is enabled. A user of this package can then issue
5461 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5462 the package or subprogram, controlling whether the check will be present.
5465 @unnumberedsec Enum_Rep
5466 @cindex Representation of enums
5469 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5470 function with the following spec:
5472 @smallexample @c ada
5473 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5474 return @i{Universal_Integer};
5478 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5479 enumeration type or to a non-overloaded enumeration
5480 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
5481 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5482 enumeration literal or object.
5484 The function returns the representation value for the given enumeration
5485 value. This will be equal to value of the @code{Pos} attribute in the
5486 absence of an enumeration representation clause. This is a static
5487 attribute (i.e.@: the result is static if the argument is static).
5489 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5490 in which case it simply returns the integer value. The reason for this
5491 is to allow it to be used for @code{(<>)} discrete formal arguments in
5492 a generic unit that can be instantiated with either enumeration types
5493 or integer types. Note that if @code{Enum_Rep} is used on a modular
5494 type whose upper bound exceeds the upper bound of the largest signed
5495 integer type, and the argument is a variable, so that the universal
5496 integer calculation is done at run time, then the call to @code{Enum_Rep}
5497 may raise @code{Constraint_Error}.
5500 @unnumberedsec Enum_Val
5501 @cindex Representation of enums
5504 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5505 function with the following spec:
5507 @smallexample @c ada
5508 function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5509 return @var{S}'Base};
5513 The function returns the enumeration value whose representation matches the
5514 argument, or raises Constraint_Error if no enumeration literal of the type
5515 has the matching value.
5516 This will be equal to value of the @code{Val} attribute in the
5517 absence of an enumeration representation clause. This is a static
5518 attribute (i.e.@: the result is static if the argument is static).
5521 @unnumberedsec Epsilon
5522 @cindex Ada 83 attributes
5525 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
5526 the Ada 83 reference manual for an exact description of the semantics of
5530 @unnumberedsec Fixed_Value
5533 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5534 function with the following specification:
5536 @smallexample @c ada
5537 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5542 The value returned is the fixed-point value @var{V} such that
5544 @smallexample @c ada
5545 @var{V} = Arg * @var{S}'Small
5549 The effect is thus similar to first converting the argument to the
5550 integer type used to represent @var{S}, and then doing an unchecked
5551 conversion to the fixed-point type. The difference is
5552 that there are full range checks, to ensure that the result is in range.
5553 This attribute is primarily intended for use in implementation of the
5554 input-output functions for fixed-point values.
5556 @node Has_Access_Values
5557 @unnumberedsec Has_Access_Values
5558 @cindex Access values, testing for
5559 @findex Has_Access_Values
5561 The prefix of the @code{Has_Access_Values} attribute is a type. The result
5562 is a Boolean value which is True if the is an access type, or is a composite
5563 type with a component (at any nesting depth) that is an access type, and is
5565 The intended use of this attribute is in conjunction with generic
5566 definitions. If the attribute is applied to a generic private type, it
5567 indicates whether or not the corresponding actual type has access values.
5569 @node Has_Discriminants
5570 @unnumberedsec Has_Discriminants
5571 @cindex Discriminants, testing for
5572 @findex Has_Discriminants
5574 The prefix of the @code{Has_Discriminants} attribute is a type. The result
5575 is a Boolean value which is True if the type has discriminants, and False
5576 otherwise. The intended use of this attribute is in conjunction with generic
5577 definitions. If the attribute is applied to a generic private type, it
5578 indicates whether or not the corresponding actual type has discriminants.
5584 The @code{Img} attribute differs from @code{Image} in that it may be
5585 applied to objects as well as types, in which case it gives the
5586 @code{Image} for the subtype of the object. This is convenient for
5589 @smallexample @c ada
5590 Put_Line ("X = " & X'Img);
5594 has the same meaning as the more verbose:
5596 @smallexample @c ada
5597 Put_Line ("X = " & @var{T}'Image (X));
5601 where @var{T} is the (sub)type of the object @code{X}.
5604 @unnumberedsec Integer_Value
5605 @findex Integer_Value
5607 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5608 function with the following spec:
5610 @smallexample @c ada
5611 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5616 The value returned is the integer value @var{V}, such that
5618 @smallexample @c ada
5619 Arg = @var{V} * @var{T}'Small
5623 where @var{T} is the type of @code{Arg}.
5624 The effect is thus similar to first doing an unchecked conversion from
5625 the fixed-point type to its corresponding implementation type, and then
5626 converting the result to the target integer type. The difference is
5627 that there are full range checks, to ensure that the result is in range.
5628 This attribute is primarily intended for use in implementation of the
5629 standard input-output functions for fixed-point values.
5632 @unnumberedsec Invalid_Value
5633 @findex Invalid_Value
5635 For every scalar type S, S'Invalid_Value returns an undefined value of the
5636 type. If possible this value is an invalid representation for the type. The
5637 value returned is identical to the value used to initialize an otherwise
5638 uninitialized value of the type if pragma Initialize_Scalars is used,
5639 including the ability to modify the value with the binder -Sxx flag and
5640 relevant environment variables at run time.
5643 @unnumberedsec Large
5644 @cindex Ada 83 attributes
5647 The @code{Large} attribute is provided for compatibility with Ada 83. See
5648 the Ada 83 reference manual for an exact description of the semantics of
5652 @unnumberedsec Machine_Size
5653 @findex Machine_Size
5655 This attribute is identical to the @code{Object_Size} attribute. It is
5656 provided for compatibility with the DEC Ada 83 attribute of this name.
5659 @unnumberedsec Mantissa
5660 @cindex Ada 83 attributes
5663 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
5664 the Ada 83 reference manual for an exact description of the semantics of
5667 @node Max_Interrupt_Priority
5668 @unnumberedsec Max_Interrupt_Priority
5669 @cindex Interrupt priority, maximum
5670 @findex Max_Interrupt_Priority
5672 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5673 permissible prefix), provides the same value as
5674 @code{System.Max_Interrupt_Priority}.
5677 @unnumberedsec Max_Priority
5678 @cindex Priority, maximum
5679 @findex Max_Priority
5681 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5682 prefix) provides the same value as @code{System.Max_Priority}.
5684 @node Maximum_Alignment
5685 @unnumberedsec Maximum_Alignment
5686 @cindex Alignment, maximum
5687 @findex Maximum_Alignment
5689 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5690 permissible prefix) provides the maximum useful alignment value for the
5691 target. This is a static value that can be used to specify the alignment
5692 for an object, guaranteeing that it is properly aligned in all
5695 @node Mechanism_Code
5696 @unnumberedsec Mechanism_Code
5697 @cindex Return values, passing mechanism
5698 @cindex Parameters, passing mechanism
5699 @findex Mechanism_Code
5701 @code{@var{function}'Mechanism_Code} yields an integer code for the
5702 mechanism used for the result of function, and
5703 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5704 used for formal parameter number @var{n} (a static integer value with 1
5705 meaning the first parameter) of @var{subprogram}. The code returned is:
5713 by descriptor (default descriptor class)
5715 by descriptor (UBS: unaligned bit string)
5717 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5719 by descriptor (UBA: unaligned bit array)
5721 by descriptor (S: string, also scalar access type parameter)
5723 by descriptor (SB: string with arbitrary bounds)
5725 by descriptor (A: contiguous array)
5727 by descriptor (NCA: non-contiguous array)
5731 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5734 @node Null_Parameter
5735 @unnumberedsec Null_Parameter
5736 @cindex Zero address, passing
5737 @findex Null_Parameter
5739 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5740 type or subtype @var{T} allocated at machine address zero. The attribute
5741 is allowed only as the default expression of a formal parameter, or as
5742 an actual expression of a subprogram call. In either case, the
5743 subprogram must be imported.
5745 The identity of the object is represented by the address zero in the
5746 argument list, independent of the passing mechanism (explicit or
5749 This capability is needed to specify that a zero address should be
5750 passed for a record or other composite object passed by reference.
5751 There is no way of indicating this without the @code{Null_Parameter}
5755 @unnumberedsec Object_Size
5756 @cindex Size, used for objects
5759 The size of an object is not necessarily the same as the size of the type
5760 of an object. This is because by default object sizes are increased to be
5761 a multiple of the alignment of the object. For example,
5762 @code{Natural'Size} is
5763 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5764 Similarly, a record containing an integer and a character:
5766 @smallexample @c ada
5774 will have a size of 40 (that is @code{Rec'Size} will be 40. The
5775 alignment will be 4, because of the
5776 integer field, and so the default size of record objects for this type
5777 will be 64 (8 bytes).
5781 @cindex Capturing Old values
5782 @cindex Postconditions
5784 The attribute Prefix'Old can be used within a
5785 subprogram to refer to the value of the prefix on entry. So for
5786 example if you have an argument of a record type X called Arg1,
5787 you can refer to Arg1.Field'Old which yields the value of
5788 Arg1.Field on entry. The implementation simply involves generating
5789 an object declaration which captures the value on entry. Any
5790 prefix is allowed except one of a limited type (since limited
5791 types cannot be copied to capture their values) or a local variable
5792 (since it does not exist at subprogram entry time).
5794 The following example shows the use of 'Old to implement
5795 a test of a postcondition:
5797 @smallexample @c ada
5808 package body Old_Pkg is
5809 Count : Natural := 0;
5813 ... code manipulating the value of Count
5815 pragma Assert (Count = Count'Old + 1);
5821 Note that it is allowed to apply 'Old to a constant entity, but this will
5822 result in a warning, since the old and new values will always be the same.
5824 @node Passed_By_Reference
5825 @unnumberedsec Passed_By_Reference
5826 @cindex Parameters, when passed by reference
5827 @findex Passed_By_Reference
5829 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5830 a value of type @code{Boolean} value that is @code{True} if the type is
5831 normally passed by reference and @code{False} if the type is normally
5832 passed by copy in calls. For scalar types, the result is always @code{False}
5833 and is static. For non-scalar types, the result is non-static.
5836 @unnumberedsec Pool_Address
5837 @cindex Parameters, when passed by reference
5838 @findex Pool_Address
5840 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
5841 of X within its storage pool. This is the same as
5842 @code{@var{X}'Address}, except that for an unconstrained array whose
5843 bounds are allocated just before the first component,
5844 @code{@var{X}'Pool_Address} returns the address of those bounds,
5845 whereas @code{@var{X}'Address} returns the address of the first
5848 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
5849 the object is allocated'', which could be a user-defined storage pool,
5850 the global heap, on the stack, or in a static memory area. For an
5851 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
5852 what is passed to @code{Allocate} and returned from @code{Deallocate}.
5855 @unnumberedsec Range_Length
5856 @findex Range_Length
5858 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5859 the number of values represented by the subtype (zero for a null
5860 range). The result is static for static subtypes. @code{Range_Length}
5861 applied to the index subtype of a one dimensional array always gives the
5862 same result as @code{Range} applied to the array itself.
5865 @unnumberedsec Safe_Emax
5866 @cindex Ada 83 attributes
5869 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
5870 the Ada 83 reference manual for an exact description of the semantics of
5874 @unnumberedsec Safe_Large
5875 @cindex Ada 83 attributes
5878 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
5879 the Ada 83 reference manual for an exact description of the semantics of
5883 @unnumberedsec Small
5884 @cindex Ada 83 attributes
5887 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
5889 GNAT also allows this attribute to be applied to floating-point types
5890 for compatibility with Ada 83. See
5891 the Ada 83 reference manual for an exact description of the semantics of
5892 this attribute when applied to floating-point types.
5895 @unnumberedsec Storage_Unit
5896 @findex Storage_Unit
5898 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
5899 prefix) provides the same value as @code{System.Storage_Unit}.
5902 @unnumberedsec Stub_Type
5905 The GNAT implementation of remote access-to-classwide types is
5906 organized as described in AARM section E.4 (20.t): a value of an RACW type
5907 (designating a remote object) is represented as a normal access
5908 value, pointing to a "stub" object which in turn contains the
5909 necessary information to contact the designated remote object. A
5910 call on any dispatching operation of such a stub object does the
5911 remote call, if necessary, using the information in the stub object
5912 to locate the target partition, etc.
5914 For a prefix @code{T} that denotes a remote access-to-classwide type,
5915 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
5917 By construction, the layout of @code{T'Stub_Type} is identical to that of
5918 type @code{RACW_Stub_Type} declared in the internal implementation-defined
5919 unit @code{System.Partition_Interface}. Use of this attribute will create
5920 an implicit dependency on this unit.
5923 @unnumberedsec Target_Name
5926 @code{Standard'Target_Name} (@code{Standard} is the only permissible
5927 prefix) provides a static string value that identifies the target
5928 for the current compilation. For GCC implementations, this is the
5929 standard gcc target name without the terminating slash (for
5930 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
5936 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
5937 provides the same value as @code{System.Tick},
5940 @unnumberedsec To_Address
5943 The @code{System'To_Address}
5944 (@code{System} is the only permissible prefix)
5945 denotes a function identical to
5946 @code{System.Storage_Elements.To_Address} except that
5947 it is a static attribute. This means that if its argument is
5948 a static expression, then the result of the attribute is a
5949 static expression. The result is that such an expression can be
5950 used in contexts (e.g.@: preelaborable packages) which require a
5951 static expression and where the function call could not be used
5952 (since the function call is always non-static, even if its
5953 argument is static).
5956 @unnumberedsec Type_Class
5959 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
5960 the value of the type class for the full type of @var{type}. If
5961 @var{type} is a generic formal type, the value is the value for the
5962 corresponding actual subtype. The value of this attribute is of type
5963 @code{System.Aux_DEC.Type_Class}, which has the following definition:
5965 @smallexample @c ada
5967 (Type_Class_Enumeration,
5969 Type_Class_Fixed_Point,
5970 Type_Class_Floating_Point,
5975 Type_Class_Address);
5979 Protected types yield the value @code{Type_Class_Task}, which thus
5980 applies to all concurrent types. This attribute is designed to
5981 be compatible with the DEC Ada 83 attribute of the same name.
5984 @unnumberedsec UET_Address
5987 The @code{UET_Address} attribute can only be used for a prefix which
5988 denotes a library package. It yields the address of the unit exception
5989 table when zero cost exception handling is used. This attribute is
5990 intended only for use within the GNAT implementation. See the unit
5991 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
5992 for details on how this attribute is used in the implementation.
5994 @node Unconstrained_Array
5995 @unnumberedsec Unconstrained_Array
5996 @findex Unconstrained_Array
5998 The @code{Unconstrained_Array} attribute can be used with a prefix that
5999 denotes any type or subtype. It is a static attribute that yields
6000 @code{True} if the prefix designates an unconstrained array,
6001 and @code{False} otherwise. In a generic instance, the result is
6002 still static, and yields the result of applying this test to the
6005 @node Universal_Literal_String
6006 @unnumberedsec Universal_Literal_String
6007 @cindex Named numbers, representation of
6008 @findex Universal_Literal_String
6010 The prefix of @code{Universal_Literal_String} must be a named
6011 number. The static result is the string consisting of the characters of
6012 the number as defined in the original source. This allows the user
6013 program to access the actual text of named numbers without intermediate
6014 conversions and without the need to enclose the strings in quotes (which
6015 would preclude their use as numbers). This is used internally for the
6016 construction of values of the floating-point attributes from the file
6017 @file{ttypef.ads}, but may also be used by user programs.
6019 For example, the following program prints the first 50 digits of pi:
6021 @smallexample @c ada
6022 with Text_IO; use Text_IO;
6026 Put (Ada.Numerics.Pi'Universal_Literal_String);
6030 @node Unrestricted_Access
6031 @unnumberedsec Unrestricted_Access
6032 @cindex @code{Access}, unrestricted
6033 @findex Unrestricted_Access
6035 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6036 except that all accessibility and aliased view checks are omitted. This
6037 is a user-beware attribute. It is similar to
6038 @code{Address}, for which it is a desirable replacement where the value
6039 desired is an access type. In other words, its effect is identical to
6040 first applying the @code{Address} attribute and then doing an unchecked
6041 conversion to a desired access type. In GNAT, but not necessarily in
6042 other implementations, the use of static chains for inner level
6043 subprograms means that @code{Unrestricted_Access} applied to a
6044 subprogram yields a value that can be called as long as the subprogram
6045 is in scope (normal Ada accessibility rules restrict this usage).
6047 It is possible to use @code{Unrestricted_Access} for any type, but care
6048 must be exercised if it is used to create pointers to unconstrained
6049 objects. In this case, the resulting pointer has the same scope as the
6050 context of the attribute, and may not be returned to some enclosing
6051 scope. For instance, a function cannot use @code{Unrestricted_Access}
6052 to create a unconstrained pointer and then return that value to the
6056 @unnumberedsec VADS_Size
6057 @cindex @code{Size}, VADS compatibility
6060 The @code{'VADS_Size} attribute is intended to make it easier to port
6061 legacy code which relies on the semantics of @code{'Size} as implemented
6062 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
6063 same semantic interpretation. In particular, @code{'VADS_Size} applied
6064 to a predefined or other primitive type with no Size clause yields the
6065 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6066 typical machines). In addition @code{'VADS_Size} applied to an object
6067 gives the result that would be obtained by applying the attribute to
6068 the corresponding type.
6071 @unnumberedsec Value_Size
6072 @cindex @code{Size}, setting for not-first subtype
6074 @code{@var{type}'Value_Size} is the number of bits required to represent
6075 a value of the given subtype. It is the same as @code{@var{type}'Size},
6076 but, unlike @code{Size}, may be set for non-first subtypes.
6079 @unnumberedsec Wchar_T_Size
6080 @findex Wchar_T_Size
6081 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6082 prefix) provides the size in bits of the C @code{wchar_t} type
6083 primarily for constructing the definition of this type in
6084 package @code{Interfaces.C}.
6087 @unnumberedsec Word_Size
6089 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6090 prefix) provides the value @code{System.Word_Size}.
6092 @c ------------------------
6093 @node Implementation Advice
6094 @chapter Implementation Advice
6096 The main text of the Ada Reference Manual describes the required
6097 behavior of all Ada compilers, and the GNAT compiler conforms to
6100 In addition, there are sections throughout the Ada Reference Manual headed
6101 by the phrase ``Implementation advice''. These sections are not normative,
6102 i.e., they do not specify requirements that all compilers must
6103 follow. Rather they provide advice on generally desirable behavior. You
6104 may wonder why they are not requirements. The most typical answer is
6105 that they describe behavior that seems generally desirable, but cannot
6106 be provided on all systems, or which may be undesirable on some systems.
6108 As far as practical, GNAT follows the implementation advice sections in
6109 the Ada Reference Manual. This chapter contains a table giving the
6110 reference manual section number, paragraph number and several keywords
6111 for each advice. Each entry consists of the text of the advice followed
6112 by the GNAT interpretation of this advice. Most often, this simply says
6113 ``followed'', which means that GNAT follows the advice. However, in a
6114 number of cases, GNAT deliberately deviates from this advice, in which
6115 case the text describes what GNAT does and why.
6117 @cindex Error detection
6118 @unnumberedsec 1.1.3(20): Error Detection
6121 If an implementation detects the use of an unsupported Specialized Needs
6122 Annex feature at run time, it should raise @code{Program_Error} if
6125 Not relevant. All specialized needs annex features are either supported,
6126 or diagnosed at compile time.
6129 @unnumberedsec 1.1.3(31): Child Units
6132 If an implementation wishes to provide implementation-defined
6133 extensions to the functionality of a language-defined library unit, it
6134 should normally do so by adding children to the library unit.
6138 @cindex Bounded errors
6139 @unnumberedsec 1.1.5(12): Bounded Errors
6142 If an implementation detects a bounded error or erroneous
6143 execution, it should raise @code{Program_Error}.
6145 Followed in all cases in which the implementation detects a bounded
6146 error or erroneous execution. Not all such situations are detected at
6150 @unnumberedsec 2.8(16): Pragmas
6153 Normally, implementation-defined pragmas should have no semantic effect
6154 for error-free programs; that is, if the implementation-defined pragmas
6155 are removed from a working program, the program should still be legal,
6156 and should still have the same semantics.
6158 The following implementation defined pragmas are exceptions to this
6170 @item CPP_Constructor
6174 @item Interface_Name
6176 @item Machine_Attribute
6178 @item Unimplemented_Unit
6180 @item Unchecked_Union
6185 In each of the above cases, it is essential to the purpose of the pragma
6186 that this advice not be followed. For details see the separate section
6187 on implementation defined pragmas.
6189 @unnumberedsec 2.8(17-19): Pragmas
6192 Normally, an implementation should not define pragmas that can
6193 make an illegal program legal, except as follows:
6197 A pragma used to complete a declaration, such as a pragma @code{Import};
6201 A pragma used to configure the environment by adding, removing, or
6202 replacing @code{library_items}.
6204 See response to paragraph 16 of this same section.
6206 @cindex Character Sets
6207 @cindex Alternative Character Sets
6208 @unnumberedsec 3.5.2(5): Alternative Character Sets
6211 If an implementation supports a mode with alternative interpretations
6212 for @code{Character} and @code{Wide_Character}, the set of graphic
6213 characters of @code{Character} should nevertheless remain a proper
6214 subset of the set of graphic characters of @code{Wide_Character}. Any
6215 character set ``localizations'' should be reflected in the results of
6216 the subprograms defined in the language-defined package
6217 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
6218 an alternative interpretation of @code{Character}, the implementation should
6219 also support a corresponding change in what is a legal
6220 @code{identifier_letter}.
6222 Not all wide character modes follow this advice, in particular the JIS
6223 and IEC modes reflect standard usage in Japan, and in these encoding,
6224 the upper half of the Latin-1 set is not part of the wide-character
6225 subset, since the most significant bit is used for wide character
6226 encoding. However, this only applies to the external forms. Internally
6227 there is no such restriction.
6229 @cindex Integer types
6230 @unnumberedsec 3.5.4(28): Integer Types
6234 An implementation should support @code{Long_Integer} in addition to
6235 @code{Integer} if the target machine supports 32-bit (or longer)
6236 arithmetic. No other named integer subtypes are recommended for package
6237 @code{Standard}. Instead, appropriate named integer subtypes should be
6238 provided in the library package @code{Interfaces} (see B.2).
6240 @code{Long_Integer} is supported. Other standard integer types are supported
6241 so this advice is not fully followed. These types
6242 are supported for convenient interface to C, and so that all hardware
6243 types of the machine are easily available.
6244 @unnumberedsec 3.5.4(29): Integer Types
6248 An implementation for a two's complement machine should support
6249 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
6250 implementation should support a non-binary modules up to @code{Integer'Last}.
6254 @cindex Enumeration values
6255 @unnumberedsec 3.5.5(8): Enumeration Values
6258 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6259 subtype, if the value of the operand does not correspond to the internal
6260 code for any enumeration literal of its type (perhaps due to an
6261 un-initialized variable), then the implementation should raise
6262 @code{Program_Error}. This is particularly important for enumeration
6263 types with noncontiguous internal codes specified by an
6264 enumeration_representation_clause.
6269 @unnumberedsec 3.5.7(17): Float Types
6272 An implementation should support @code{Long_Float} in addition to
6273 @code{Float} if the target machine supports 11 or more digits of
6274 precision. No other named floating point subtypes are recommended for
6275 package @code{Standard}. Instead, appropriate named floating point subtypes
6276 should be provided in the library package @code{Interfaces} (see B.2).
6278 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
6279 former provides improved compatibility with other implementations
6280 supporting this type. The latter corresponds to the highest precision
6281 floating-point type supported by the hardware. On most machines, this
6282 will be the same as @code{Long_Float}, but on some machines, it will
6283 correspond to the IEEE extended form. The notable case is all ia32
6284 (x86) implementations, where @code{Long_Long_Float} corresponds to
6285 the 80-bit extended precision format supported in hardware on this
6286 processor. Note that the 128-bit format on SPARC is not supported,
6287 since this is a software rather than a hardware format.
6289 @cindex Multidimensional arrays
6290 @cindex Arrays, multidimensional
6291 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6294 An implementation should normally represent multidimensional arrays in
6295 row-major order, consistent with the notation used for multidimensional
6296 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
6297 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6298 column-major order should be used instead (see B.5, ``Interfacing with
6303 @findex Duration'Small
6304 @unnumberedsec 9.6(30-31): Duration'Small
6307 Whenever possible in an implementation, the value of @code{Duration'Small}
6308 should be no greater than 100 microseconds.
6310 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
6314 The time base for @code{delay_relative_statements} should be monotonic;
6315 it need not be the same time base as used for @code{Calendar.Clock}.
6319 @unnumberedsec 10.2.1(12): Consistent Representation
6322 In an implementation, a type declared in a pre-elaborated package should
6323 have the same representation in every elaboration of a given version of
6324 the package, whether the elaborations occur in distinct executions of
6325 the same program, or in executions of distinct programs or partitions
6326 that include the given version.
6328 Followed, except in the case of tagged types. Tagged types involve
6329 implicit pointers to a local copy of a dispatch table, and these pointers
6330 have representations which thus depend on a particular elaboration of the
6331 package. It is not easy to see how it would be possible to follow this
6332 advice without severely impacting efficiency of execution.
6334 @cindex Exception information
6335 @unnumberedsec 11.4.1(19): Exception Information
6338 @code{Exception_Message} by default and @code{Exception_Information}
6339 should produce information useful for
6340 debugging. @code{Exception_Message} should be short, about one
6341 line. @code{Exception_Information} can be long. @code{Exception_Message}
6342 should not include the
6343 @code{Exception_Name}. @code{Exception_Information} should include both
6344 the @code{Exception_Name} and the @code{Exception_Message}.
6346 Followed. For each exception that doesn't have a specified
6347 @code{Exception_Message}, the compiler generates one containing the location
6348 of the raise statement. This location has the form ``file:line'', where
6349 file is the short file name (without path information) and line is the line
6350 number in the file. Note that in the case of the Zero Cost Exception
6351 mechanism, these messages become redundant with the Exception_Information that
6352 contains a full backtrace of the calling sequence, so they are disabled.
6353 To disable explicitly the generation of the source location message, use the
6354 Pragma @code{Discard_Names}.
6356 @cindex Suppression of checks
6357 @cindex Checks, suppression of
6358 @unnumberedsec 11.5(28): Suppression of Checks
6361 The implementation should minimize the code executed for checks that
6362 have been suppressed.
6366 @cindex Representation clauses
6367 @unnumberedsec 13.1 (21-24): Representation Clauses
6370 The recommended level of support for all representation items is
6371 qualified as follows:
6375 An implementation need not support representation items containing
6376 non-static expressions, except that an implementation should support a
6377 representation item for a given entity if each non-static expression in
6378 the representation item is a name that statically denotes a constant
6379 declared before the entity.
6381 Followed. In fact, GNAT goes beyond the recommended level of support
6382 by allowing nonstatic expressions in some representation clauses even
6383 without the need to declare constants initialized with the values of
6387 @smallexample @c ada
6390 for Y'Address use X'Address;>>
6396 An implementation need not support a specification for the @code{Size}
6397 for a given composite subtype, nor the size or storage place for an
6398 object (including a component) of a given composite subtype, unless the
6399 constraints on the subtype and its composite subcomponents (if any) are
6400 all static constraints.
6402 Followed. Size Clauses are not permitted on non-static components, as
6407 An aliased component, or a component whose type is by-reference, should
6408 always be allocated at an addressable location.
6412 @cindex Packed types
6413 @unnumberedsec 13.2(6-8): Packed Types
6416 If a type is packed, then the implementation should try to minimize
6417 storage allocated to objects of the type, possibly at the expense of
6418 speed of accessing components, subject to reasonable complexity in
6419 addressing calculations.
6423 The recommended level of support pragma @code{Pack} is:
6425 For a packed record type, the components should be packed as tightly as
6426 possible subject to the Sizes of the component subtypes, and subject to
6427 any @code{record_representation_clause} that applies to the type; the
6428 implementation may, but need not, reorder components or cross aligned
6429 word boundaries to improve the packing. A component whose @code{Size} is
6430 greater than the word size may be allocated an integral number of words.
6432 Followed. Tight packing of arrays is supported for all component sizes
6433 up to 64-bits. If the array component size is 1 (that is to say, if
6434 the component is a boolean type or an enumeration type with two values)
6435 then values of the type are implicitly initialized to zero. This
6436 happens both for objects of the packed type, and for objects that have a
6437 subcomponent of the packed type.
6441 An implementation should support Address clauses for imported
6445 @cindex @code{Address} clauses
6446 @unnumberedsec 13.3(14-19): Address Clauses
6450 For an array @var{X}, @code{@var{X}'Address} should point at the first
6451 component of the array, and not at the array bounds.
6457 The recommended level of support for the @code{Address} attribute is:
6459 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6460 object that is aliased or of a by-reference type, or is an entity whose
6461 @code{Address} has been specified.
6463 Followed. A valid address will be produced even if none of those
6464 conditions have been met. If necessary, the object is forced into
6465 memory to ensure the address is valid.
6469 An implementation should support @code{Address} clauses for imported
6476 Objects (including subcomponents) that are aliased or of a by-reference
6477 type should be allocated on storage element boundaries.
6483 If the @code{Address} of an object is specified, or it is imported or exported,
6484 then the implementation should not perform optimizations based on
6485 assumptions of no aliases.
6489 @cindex @code{Alignment} clauses
6490 @unnumberedsec 13.3(29-35): Alignment Clauses
6493 The recommended level of support for the @code{Alignment} attribute for
6496 An implementation should support specified Alignments that are factors
6497 and multiples of the number of storage elements per word, subject to the
6504 An implementation need not support specified @code{Alignment}s for
6505 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6506 loaded and stored by available machine instructions.
6512 An implementation need not support specified @code{Alignment}s that are
6513 greater than the maximum @code{Alignment} the implementation ever returns by
6520 The recommended level of support for the @code{Alignment} attribute for
6523 Same as above, for subtypes, but in addition:
6529 For stand-alone library-level objects of statically constrained
6530 subtypes, the implementation should support all @code{Alignment}s
6531 supported by the target linker. For example, page alignment is likely to
6532 be supported for such objects, but not for subtypes.
6536 @cindex @code{Size} clauses
6537 @unnumberedsec 13.3(42-43): Size Clauses
6540 The recommended level of support for the @code{Size} attribute of
6543 A @code{Size} clause should be supported for an object if the specified
6544 @code{Size} is at least as large as its subtype's @code{Size}, and
6545 corresponds to a size in storage elements that is a multiple of the
6546 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6550 @unnumberedsec 13.3(50-56): Size Clauses
6553 If the @code{Size} of a subtype is specified, and allows for efficient
6554 independent addressability (see 9.10) on the target architecture, then
6555 the @code{Size} of the following objects of the subtype should equal the
6556 @code{Size} of the subtype:
6558 Aliased objects (including components).
6564 @code{Size} clause on a composite subtype should not affect the
6565 internal layout of components.
6567 Followed. But note that this can be overridden by use of the implementation
6568 pragma Implicit_Packing in the case of packed arrays.
6572 The recommended level of support for the @code{Size} attribute of subtypes is:
6576 The @code{Size} (if not specified) of a static discrete or fixed point
6577 subtype should be the number of bits needed to represent each value
6578 belonging to the subtype using an unbiased representation, leaving space
6579 for a sign bit only if the subtype contains negative values. If such a
6580 subtype is a first subtype, then an implementation should support a
6581 specified @code{Size} for it that reflects this representation.
6587 For a subtype implemented with levels of indirection, the @code{Size}
6588 should include the size of the pointers, but not the size of what they
6593 @cindex @code{Component_Size} clauses
6594 @unnumberedsec 13.3(71-73): Component Size Clauses
6597 The recommended level of support for the @code{Component_Size}
6602 An implementation need not support specified @code{Component_Sizes} that are
6603 less than the @code{Size} of the component subtype.
6609 An implementation should support specified @code{Component_Size}s that
6610 are factors and multiples of the word size. For such
6611 @code{Component_Size}s, the array should contain no gaps between
6612 components. For other @code{Component_Size}s (if supported), the array
6613 should contain no gaps between components when packing is also
6614 specified; the implementation should forbid this combination in cases
6615 where it cannot support a no-gaps representation.
6619 @cindex Enumeration representation clauses
6620 @cindex Representation clauses, enumeration
6621 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6624 The recommended level of support for enumeration representation clauses
6627 An implementation need not support enumeration representation clauses
6628 for boolean types, but should at minimum support the internal codes in
6629 the range @code{System.Min_Int.System.Max_Int}.
6633 @cindex Record representation clauses
6634 @cindex Representation clauses, records
6635 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6638 The recommended level of support for
6639 @*@code{record_representation_clauses} is:
6641 An implementation should support storage places that can be extracted
6642 with a load, mask, shift sequence of machine code, and set with a load,
6643 shift, mask, store sequence, given the available machine instructions
6650 A storage place should be supported if its size is equal to the
6651 @code{Size} of the component subtype, and it starts and ends on a
6652 boundary that obeys the @code{Alignment} of the component subtype.
6658 If the default bit ordering applies to the declaration of a given type,
6659 then for a component whose subtype's @code{Size} is less than the word
6660 size, any storage place that does not cross an aligned word boundary
6661 should be supported.
6667 An implementation may reserve a storage place for the tag field of a
6668 tagged type, and disallow other components from overlapping that place.
6670 Followed. The storage place for the tag field is the beginning of the tagged
6671 record, and its size is Address'Size. GNAT will reject an explicit component
6672 clause for the tag field.
6676 An implementation need not support a @code{component_clause} for a
6677 component of an extension part if the storage place is not after the
6678 storage places of all components of the parent type, whether or not
6679 those storage places had been specified.
6681 Followed. The above advice on record representation clauses is followed,
6682 and all mentioned features are implemented.
6684 @cindex Storage place attributes
6685 @unnumberedsec 13.5.2(5): Storage Place Attributes
6688 If a component is represented using some form of pointer (such as an
6689 offset) to the actual data of the component, and this data is contiguous
6690 with the rest of the object, then the storage place attributes should
6691 reflect the place of the actual data, not the pointer. If a component is
6692 allocated discontinuously from the rest of the object, then a warning
6693 should be generated upon reference to one of its storage place
6696 Followed. There are no such components in GNAT@.
6698 @cindex Bit ordering
6699 @unnumberedsec 13.5.3(7-8): Bit Ordering
6702 The recommended level of support for the non-default bit ordering is:
6706 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6707 should support the non-default bit ordering in addition to the default
6710 Followed. Word size does not equal storage size in this implementation.
6711 Thus non-default bit ordering is not supported.
6713 @cindex @code{Address}, as private type
6714 @unnumberedsec 13.7(37): Address as Private
6717 @code{Address} should be of a private type.
6721 @cindex Operations, on @code{Address}
6722 @cindex @code{Address}, operations of
6723 @unnumberedsec 13.7.1(16): Address Operations
6726 Operations in @code{System} and its children should reflect the target
6727 environment semantics as closely as is reasonable. For example, on most
6728 machines, it makes sense for address arithmetic to ``wrap around''.
6729 Operations that do not make sense should raise @code{Program_Error}.
6731 Followed. Address arithmetic is modular arithmetic that wraps around. No
6732 operation raises @code{Program_Error}, since all operations make sense.
6734 @cindex Unchecked conversion
6735 @unnumberedsec 13.9(14-17): Unchecked Conversion
6738 The @code{Size} of an array object should not include its bounds; hence,
6739 the bounds should not be part of the converted data.
6745 The implementation should not generate unnecessary run-time checks to
6746 ensure that the representation of @var{S} is a representation of the
6747 target type. It should take advantage of the permission to return by
6748 reference when possible. Restrictions on unchecked conversions should be
6749 avoided unless required by the target environment.
6751 Followed. There are no restrictions on unchecked conversion. A warning is
6752 generated if the source and target types do not have the same size since
6753 the semantics in this case may be target dependent.
6757 The recommended level of support for unchecked conversions is:
6761 Unchecked conversions should be supported and should be reversible in
6762 the cases where this clause defines the result. To enable meaningful use
6763 of unchecked conversion, a contiguous representation should be used for
6764 elementary subtypes, for statically constrained array subtypes whose
6765 component subtype is one of the subtypes described in this paragraph,
6766 and for record subtypes without discriminants whose component subtypes
6767 are described in this paragraph.
6771 @cindex Heap usage, implicit
6772 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6775 An implementation should document any cases in which it dynamically
6776 allocates heap storage for a purpose other than the evaluation of an
6779 Followed, the only other points at which heap storage is dynamically
6780 allocated are as follows:
6784 At initial elaboration time, to allocate dynamically sized global
6788 To allocate space for a task when a task is created.
6791 To extend the secondary stack dynamically when needed. The secondary
6792 stack is used for returning variable length results.
6797 A default (implementation-provided) storage pool for an
6798 access-to-constant type should not have overhead to support deallocation of
6805 A storage pool for an anonymous access type should be created at the
6806 point of an allocator for the type, and be reclaimed when the designated
6807 object becomes inaccessible.
6811 @cindex Unchecked deallocation
6812 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6815 For a standard storage pool, @code{Free} should actually reclaim the
6820 @cindex Stream oriented attributes
6821 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6824 If a stream element is the same size as a storage element, then the
6825 normal in-memory representation should be used by @code{Read} and
6826 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
6827 should use the smallest number of stream elements needed to represent
6828 all values in the base range of the scalar type.
6831 Followed. By default, GNAT uses the interpretation suggested by AI-195,
6832 which specifies using the size of the first subtype.
6833 However, such an implementation is based on direct binary
6834 representations and is therefore target- and endianness-dependent.
6835 To address this issue, GNAT also supplies an alternate implementation
6836 of the stream attributes @code{Read} and @code{Write},
6837 which uses the target-independent XDR standard representation
6839 @cindex XDR representation
6840 @cindex @code{Read} attribute
6841 @cindex @code{Write} attribute
6842 @cindex Stream oriented attributes
6843 The XDR implementation is provided as an alternative body of the
6844 @code{System.Stream_Attributes} package, in the file
6845 @file{s-strxdr.adb} in the GNAT library.
6846 There is no @file{s-strxdr.ads} file.
6847 In order to install the XDR implementation, do the following:
6849 @item Replace the default implementation of the
6850 @code{System.Stream_Attributes} package with the XDR implementation.
6851 For example on a Unix platform issue the commands:
6853 $ mv s-stratt.adb s-strold.adb
6854 $ mv s-strxdr.adb s-stratt.adb
6858 Rebuild the GNAT run-time library as documented in
6859 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
6862 @unnumberedsec A.1(52): Names of Predefined Numeric Types
6865 If an implementation provides additional named predefined integer types,
6866 then the names should end with @samp{Integer} as in
6867 @samp{Long_Integer}. If an implementation provides additional named
6868 predefined floating point types, then the names should end with
6869 @samp{Float} as in @samp{Long_Float}.
6873 @findex Ada.Characters.Handling
6874 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
6877 If an implementation provides a localized definition of @code{Character}
6878 or @code{Wide_Character}, then the effects of the subprograms in
6879 @code{Characters.Handling} should reflect the localizations. See also
6882 Followed. GNAT provides no such localized definitions.
6884 @cindex Bounded-length strings
6885 @unnumberedsec A.4.4(106): Bounded-Length String Handling
6888 Bounded string objects should not be implemented by implicit pointers
6889 and dynamic allocation.
6891 Followed. No implicit pointers or dynamic allocation are used.
6893 @cindex Random number generation
6894 @unnumberedsec A.5.2(46-47): Random Number Generation
6897 Any storage associated with an object of type @code{Generator} should be
6898 reclaimed on exit from the scope of the object.
6904 If the generator period is sufficiently long in relation to the number
6905 of distinct initiator values, then each possible value of
6906 @code{Initiator} passed to @code{Reset} should initiate a sequence of
6907 random numbers that does not, in a practical sense, overlap the sequence
6908 initiated by any other value. If this is not possible, then the mapping
6909 between initiator values and generator states should be a rapidly
6910 varying function of the initiator value.
6912 Followed. The generator period is sufficiently long for the first
6913 condition here to hold true.
6915 @findex Get_Immediate
6916 @unnumberedsec A.10.7(23): @code{Get_Immediate}
6919 The @code{Get_Immediate} procedures should be implemented with
6920 unbuffered input. For a device such as a keyboard, input should be
6921 @dfn{available} if a key has already been typed, whereas for a disk
6922 file, input should always be available except at end of file. For a file
6923 associated with a keyboard-like device, any line-editing features of the
6924 underlying operating system should be disabled during the execution of
6925 @code{Get_Immediate}.
6927 Followed on all targets except VxWorks. For VxWorks, there is no way to
6928 provide this functionality that does not result in the input buffer being
6929 flushed before the @code{Get_Immediate} call. A special unit
6930 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
6934 @unnumberedsec B.1(39-41): Pragma @code{Export}
6937 If an implementation supports pragma @code{Export} to a given language,
6938 then it should also allow the main subprogram to be written in that
6939 language. It should support some mechanism for invoking the elaboration
6940 of the Ada library units included in the system, and for invoking the
6941 finalization of the environment task. On typical systems, the
6942 recommended mechanism is to provide two subprograms whose link names are
6943 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
6944 elaboration code for library units. @code{adafinal} should contain the
6945 finalization code. These subprograms should have no effect the second
6946 and subsequent time they are called.
6952 Automatic elaboration of pre-elaborated packages should be
6953 provided when pragma @code{Export} is supported.
6955 Followed when the main program is in Ada. If the main program is in a
6956 foreign language, then
6957 @code{adainit} must be called to elaborate pre-elaborated
6962 For each supported convention @var{L} other than @code{Intrinsic}, an
6963 implementation should support @code{Import} and @code{Export} pragmas
6964 for objects of @var{L}-compatible types and for subprograms, and pragma
6965 @code{Convention} for @var{L}-eligible types and for subprograms,
6966 presuming the other language has corresponding features. Pragma
6967 @code{Convention} need not be supported for scalar types.
6971 @cindex Package @code{Interfaces}
6973 @unnumberedsec B.2(12-13): Package @code{Interfaces}
6976 For each implementation-defined convention identifier, there should be a
6977 child package of package Interfaces with the corresponding name. This
6978 package should contain any declarations that would be useful for
6979 interfacing to the language (implementation) represented by the
6980 convention. Any declarations useful for interfacing to any language on
6981 the given hardware architecture should be provided directly in
6984 Followed. An additional package not defined
6985 in the Ada Reference Manual is @code{Interfaces.CPP}, used
6986 for interfacing to C++.
6990 An implementation supporting an interface to C, COBOL, or Fortran should
6991 provide the corresponding package or packages described in the following
6994 Followed. GNAT provides all the packages described in this section.
6996 @cindex C, interfacing with
6997 @unnumberedsec B.3(63-71): Interfacing with C
7000 An implementation should support the following interface correspondences
7007 An Ada procedure corresponds to a void-returning C function.
7013 An Ada function corresponds to a non-void C function.
7019 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7026 An Ada @code{in} parameter of an access-to-object type with designated
7027 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7028 where @var{t} is the C type corresponding to the Ada type @var{T}.
7034 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7035 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7036 argument to a C function, where @var{t} is the C type corresponding to
7037 the Ada type @var{T}. In the case of an elementary @code{out} or
7038 @code{in out} parameter, a pointer to a temporary copy is used to
7039 preserve by-copy semantics.
7045 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7046 @code{@var{t}*} argument to a C function, where @var{t} is the C
7047 structure corresponding to the Ada type @var{T}.
7049 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
7050 pragma, or Convention, or by explicitly specifying the mechanism for a given
7051 call using an extended import or export pragma.
7055 An Ada parameter of an array type with component type @var{T}, of any
7056 mode, is passed as a @code{@var{t}*} argument to a C function, where
7057 @var{t} is the C type corresponding to the Ada type @var{T}.
7063 An Ada parameter of an access-to-subprogram type is passed as a pointer
7064 to a C function whose prototype corresponds to the designated
7065 subprogram's specification.
7069 @cindex COBOL, interfacing with
7070 @unnumberedsec B.4(95-98): Interfacing with COBOL
7073 An Ada implementation should support the following interface
7074 correspondences between Ada and COBOL@.
7080 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7081 the COBOL type corresponding to @var{T}.
7087 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7088 the corresponding COBOL type.
7094 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7095 COBOL type corresponding to the Ada parameter type; for scalars, a local
7096 copy is used if necessary to ensure by-copy semantics.
7100 @cindex Fortran, interfacing with
7101 @unnumberedsec B.5(22-26): Interfacing with Fortran
7104 An Ada implementation should support the following interface
7105 correspondences between Ada and Fortran:
7111 An Ada procedure corresponds to a Fortran subroutine.
7117 An Ada function corresponds to a Fortran function.
7123 An Ada parameter of an elementary, array, or record type @var{T} is
7124 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7125 the Fortran type corresponding to the Ada type @var{T}, and where the
7126 INTENT attribute of the corresponding dummy argument matches the Ada
7127 formal parameter mode; the Fortran implementation's parameter passing
7128 conventions are used. For elementary types, a local copy is used if
7129 necessary to ensure by-copy semantics.
7135 An Ada parameter of an access-to-subprogram type is passed as a
7136 reference to a Fortran procedure whose interface corresponds to the
7137 designated subprogram's specification.
7141 @cindex Machine operations
7142 @unnumberedsec C.1(3-5): Access to Machine Operations
7145 The machine code or intrinsic support should allow access to all
7146 operations normally available to assembly language programmers for the
7147 target environment, including privileged instructions, if any.
7153 The interfacing pragmas (see Annex B) should support interface to
7154 assembler; the default assembler should be associated with the
7155 convention identifier @code{Assembler}.
7161 If an entity is exported to assembly language, then the implementation
7162 should allocate it at an addressable location, and should ensure that it
7163 is retained by the linking process, even if not otherwise referenced
7164 from the Ada code. The implementation should assume that any call to a
7165 machine code or assembler subprogram is allowed to read or update every
7166 object that is specified as exported.
7170 @unnumberedsec C.1(10-16): Access to Machine Operations
7173 The implementation should ensure that little or no overhead is
7174 associated with calling intrinsic and machine-code subprograms.
7176 Followed for both intrinsics and machine-code subprograms.
7180 It is recommended that intrinsic subprograms be provided for convenient
7181 access to any machine operations that provide special capabilities or
7182 efficiency and that are not otherwise available through the language
7185 Followed. A full set of machine operation intrinsic subprograms is provided.
7189 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7190 swap, decrement and test, enqueue/dequeue.
7192 Followed on any target supporting such operations.
7196 Standard numeric functions---e.g.@:, sin, log.
7198 Followed on any target supporting such operations.
7202 String manipulation operations---e.g.@:, translate and test.
7204 Followed on any target supporting such operations.
7208 Vector operations---e.g.@:, compare vector against thresholds.
7210 Followed on any target supporting such operations.
7214 Direct operations on I/O ports.
7216 Followed on any target supporting such operations.
7218 @cindex Interrupt support
7219 @unnumberedsec C.3(28): Interrupt Support
7222 If the @code{Ceiling_Locking} policy is not in effect, the
7223 implementation should provide means for the application to specify which
7224 interrupts are to be blocked during protected actions, if the underlying
7225 system allows for a finer-grain control of interrupt blocking.
7227 Followed. The underlying system does not allow for finer-grain control
7228 of interrupt blocking.
7230 @cindex Protected procedure handlers
7231 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7234 Whenever possible, the implementation should allow interrupt handlers to
7235 be called directly by the hardware.
7239 This is never possible under IRIX, so this is followed by default.
7241 Followed on any target where the underlying operating system permits
7246 Whenever practical, violations of any
7247 implementation-defined restrictions should be detected before run time.
7249 Followed. Compile time warnings are given when possible.
7251 @cindex Package @code{Interrupts}
7253 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7257 If implementation-defined forms of interrupt handler procedures are
7258 supported, such as protected procedures with parameters, then for each
7259 such form of a handler, a type analogous to @code{Parameterless_Handler}
7260 should be specified in a child package of @code{Interrupts}, with the
7261 same operations as in the predefined package Interrupts.
7265 @cindex Pre-elaboration requirements
7266 @unnumberedsec C.4(14): Pre-elaboration Requirements
7269 It is recommended that pre-elaborated packages be implemented in such a
7270 way that there should be little or no code executed at run time for the
7271 elaboration of entities not already covered by the Implementation
7274 Followed. Executable code is generated in some cases, e.g.@: loops
7275 to initialize large arrays.
7277 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7281 If the pragma applies to an entity, then the implementation should
7282 reduce the amount of storage used for storing names associated with that
7287 @cindex Package @code{Task_Attributes}
7288 @findex Task_Attributes
7289 @unnumberedsec C.7.2(30): The Package Task_Attributes
7292 Some implementations are targeted to domains in which memory use at run
7293 time must be completely deterministic. For such implementations, it is
7294 recommended that the storage for task attributes will be pre-allocated
7295 statically and not from the heap. This can be accomplished by either
7296 placing restrictions on the number and the size of the task's
7297 attributes, or by using the pre-allocated storage for the first @var{N}
7298 attribute objects, and the heap for the others. In the latter case,
7299 @var{N} should be documented.
7301 Not followed. This implementation is not targeted to such a domain.
7303 @cindex Locking Policies
7304 @unnumberedsec D.3(17): Locking Policies
7308 The implementation should use names that end with @samp{_Locking} for
7309 locking policies defined by the implementation.
7311 Followed. A single implementation-defined locking policy is defined,
7312 whose name (@code{Inheritance_Locking}) follows this suggestion.
7314 @cindex Entry queuing policies
7315 @unnumberedsec D.4(16): Entry Queuing Policies
7318 Names that end with @samp{_Queuing} should be used
7319 for all implementation-defined queuing policies.
7321 Followed. No such implementation-defined queuing policies exist.
7323 @cindex Preemptive abort
7324 @unnumberedsec D.6(9-10): Preemptive Abort
7327 Even though the @code{abort_statement} is included in the list of
7328 potentially blocking operations (see 9.5.1), it is recommended that this
7329 statement be implemented in a way that never requires the task executing
7330 the @code{abort_statement} to block.
7336 On a multi-processor, the delay associated with aborting a task on
7337 another processor should be bounded; the implementation should use
7338 periodic polling, if necessary, to achieve this.
7342 @cindex Tasking restrictions
7343 @unnumberedsec D.7(21): Tasking Restrictions
7346 When feasible, the implementation should take advantage of the specified
7347 restrictions to produce a more efficient implementation.
7349 GNAT currently takes advantage of these restrictions by providing an optimized
7350 run time when the Ravenscar profile and the GNAT restricted run time set
7351 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
7352 pragma @code{Profile (Restricted)} for more details.
7354 @cindex Time, monotonic
7355 @unnumberedsec D.8(47-49): Monotonic Time
7358 When appropriate, implementations should provide configuration
7359 mechanisms to change the value of @code{Tick}.
7361 Such configuration mechanisms are not appropriate to this implementation
7362 and are thus not supported.
7366 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7367 be implemented as transformations of the same time base.
7373 It is recommended that the @dfn{best} time base which exists in
7374 the underlying system be available to the application through
7375 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
7379 @cindex Partition communication subsystem
7381 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7384 Whenever possible, the PCS on the called partition should allow for
7385 multiple tasks to call the RPC-receiver with different messages and
7386 should allow them to block until the corresponding subprogram body
7389 Followed by GLADE, a separately supplied PCS that can be used with
7394 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7395 should raise @code{Storage_Error} if it runs out of space trying to
7396 write the @code{Item} into the stream.
7398 Followed by GLADE, a separately supplied PCS that can be used with
7401 @cindex COBOL support
7402 @unnumberedsec F(7): COBOL Support
7405 If COBOL (respectively, C) is widely supported in the target
7406 environment, implementations supporting the Information Systems Annex
7407 should provide the child package @code{Interfaces.COBOL} (respectively,
7408 @code{Interfaces.C}) specified in Annex B and should support a
7409 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7410 pragmas (see Annex B), thus allowing Ada programs to interface with
7411 programs written in that language.
7415 @cindex Decimal radix support
7416 @unnumberedsec F.1(2): Decimal Radix Support
7419 Packed decimal should be used as the internal representation for objects
7420 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7422 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
7426 @unnumberedsec G: Numerics
7429 If Fortran (respectively, C) is widely supported in the target
7430 environment, implementations supporting the Numerics Annex
7431 should provide the child package @code{Interfaces.Fortran} (respectively,
7432 @code{Interfaces.C}) specified in Annex B and should support a
7433 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7434 pragmas (see Annex B), thus allowing Ada programs to interface with
7435 programs written in that language.
7439 @cindex Complex types
7440 @unnumberedsec G.1.1(56-58): Complex Types
7443 Because the usual mathematical meaning of multiplication of a complex
7444 operand and a real operand is that of the scaling of both components of
7445 the former by the latter, an implementation should not perform this
7446 operation by first promoting the real operand to complex type and then
7447 performing a full complex multiplication. In systems that, in the
7448 future, support an Ada binding to IEC 559:1989, the latter technique
7449 will not generate the required result when one of the components of the
7450 complex operand is infinite. (Explicit multiplication of the infinite
7451 component by the zero component obtained during promotion yields a NaN
7452 that propagates into the final result.) Analogous advice applies in the
7453 case of multiplication of a complex operand and a pure-imaginary
7454 operand, and in the case of division of a complex operand by a real or
7455 pure-imaginary operand.
7461 Similarly, because the usual mathematical meaning of addition of a
7462 complex operand and a real operand is that the imaginary operand remains
7463 unchanged, an implementation should not perform this operation by first
7464 promoting the real operand to complex type and then performing a full
7465 complex addition. In implementations in which the @code{Signed_Zeros}
7466 attribute of the component type is @code{True} (and which therefore
7467 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7468 predefined arithmetic operations), the latter technique will not
7469 generate the required result when the imaginary component of the complex
7470 operand is a negatively signed zero. (Explicit addition of the negative
7471 zero to the zero obtained during promotion yields a positive zero.)
7472 Analogous advice applies in the case of addition of a complex operand
7473 and a pure-imaginary operand, and in the case of subtraction of a
7474 complex operand and a real or pure-imaginary operand.
7480 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7481 attempt to provide a rational treatment of the signs of zero results and
7482 result components. As one example, the result of the @code{Argument}
7483 function should have the sign of the imaginary component of the
7484 parameter @code{X} when the point represented by that parameter lies on
7485 the positive real axis; as another, the sign of the imaginary component
7486 of the @code{Compose_From_Polar} function should be the same as
7487 (respectively, the opposite of) that of the @code{Argument} parameter when that
7488 parameter has a value of zero and the @code{Modulus} parameter has a
7489 nonnegative (respectively, negative) value.
7493 @cindex Complex elementary functions
7494 @unnumberedsec G.1.2(49): Complex Elementary Functions
7497 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7498 @code{True} should attempt to provide a rational treatment of the signs
7499 of zero results and result components. For example, many of the complex
7500 elementary functions have components that are odd functions of one of
7501 the parameter components; in these cases, the result component should
7502 have the sign of the parameter component at the origin. Other complex
7503 elementary functions have zero components whose sign is opposite that of
7504 a parameter component at the origin, or is always positive or always
7509 @cindex Accuracy requirements
7510 @unnumberedsec G.2.4(19): Accuracy Requirements
7513 The versions of the forward trigonometric functions without a
7514 @code{Cycle} parameter should not be implemented by calling the
7515 corresponding version with a @code{Cycle} parameter of
7516 @code{2.0*Numerics.Pi}, since this will not provide the required
7517 accuracy in some portions of the domain. For the same reason, the
7518 version of @code{Log} without a @code{Base} parameter should not be
7519 implemented by calling the corresponding version with a @code{Base}
7520 parameter of @code{Numerics.e}.
7524 @cindex Complex arithmetic accuracy
7525 @cindex Accuracy, complex arithmetic
7526 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7530 The version of the @code{Compose_From_Polar} function without a
7531 @code{Cycle} parameter should not be implemented by calling the
7532 corresponding version with a @code{Cycle} parameter of
7533 @code{2.0*Numerics.Pi}, since this will not provide the required
7534 accuracy in some portions of the domain.
7538 @c -----------------------------------------
7539 @node Implementation Defined Characteristics
7540 @chapter Implementation Defined Characteristics
7543 In addition to the implementation dependent pragmas and attributes, and
7544 the implementation advice, there are a number of other Ada features
7545 that are potentially implementation dependent. These are mentioned
7546 throughout the Ada Reference Manual, and are summarized in annex M@.
7548 A requirement for conforming Ada compilers is that they provide
7549 documentation describing how the implementation deals with each of these
7550 issues. In this chapter, you will find each point in annex M listed
7551 followed by a description in italic font of how GNAT
7555 implementation on IRIX 5.3 operating system or greater
7557 handles the implementation dependence.
7559 You can use this chapter as a guide to minimizing implementation
7560 dependent features in your programs if portability to other compilers
7561 and other operating systems is an important consideration. The numbers
7562 in each section below correspond to the paragraph number in the Ada
7568 @strong{2}. Whether or not each recommendation given in Implementation
7569 Advice is followed. See 1.1.2(37).
7572 @xref{Implementation Advice}.
7577 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
7580 The complexity of programs that can be processed is limited only by the
7581 total amount of available virtual memory, and disk space for the
7582 generated object files.
7587 @strong{4}. Variations from the standard that are impractical to avoid
7588 given the implementation's execution environment. See 1.1.3(6).
7591 There are no variations from the standard.
7596 @strong{5}. Which @code{code_statement}s cause external
7597 interactions. See 1.1.3(10).
7600 Any @code{code_statement} can potentially cause external interactions.
7605 @strong{6}. The coded representation for the text of an Ada
7606 program. See 2.1(4).
7609 See separate section on source representation.
7614 @strong{7}. The control functions allowed in comments. See 2.1(14).
7617 See separate section on source representation.
7622 @strong{8}. The representation for an end of line. See 2.2(2).
7625 See separate section on source representation.
7630 @strong{9}. Maximum supported line length and lexical element
7631 length. See 2.2(15).
7634 The maximum line length is 255 characters and the maximum length of a
7635 lexical element is also 255 characters.
7640 @strong{10}. Implementation defined pragmas. See 2.8(14).
7644 @xref{Implementation Defined Pragmas}.
7649 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
7652 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7653 parameter, checks that the optimization flag is set, and aborts if it is
7659 @strong{12}. The sequence of characters of the value returned by
7660 @code{@var{S}'Image} when some of the graphic characters of
7661 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
7665 The sequence of characters is as defined by the wide character encoding
7666 method used for the source. See section on source representation for
7672 @strong{13}. The predefined integer types declared in
7673 @code{Standard}. See 3.5.4(25).
7677 @item Short_Short_Integer
7680 (Short) 16 bit signed
7684 64 bit signed (Alpha OpenVMS only)
7685 32 bit signed (all other targets)
7686 @item Long_Long_Integer
7693 @strong{14}. Any nonstandard integer types and the operators defined
7694 for them. See 3.5.4(26).
7697 There are no nonstandard integer types.
7702 @strong{15}. Any nonstandard real types and the operators defined for
7706 There are no nonstandard real types.
7711 @strong{16}. What combinations of requested decimal precision and range
7712 are supported for floating point types. See 3.5.7(7).
7715 The precision and range is as defined by the IEEE standard.
7720 @strong{17}. The predefined floating point types declared in
7721 @code{Standard}. See 3.5.7(16).
7728 (Short) 32 bit IEEE short
7731 @item Long_Long_Float
7732 64 bit IEEE long (80 bit IEEE long on x86 processors)
7738 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
7741 @code{Fine_Delta} is 2**(@minus{}63)
7746 @strong{19}. What combinations of small, range, and digits are
7747 supported for fixed point types. See 3.5.9(10).
7750 Any combinations are permitted that do not result in a small less than
7751 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7752 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7753 is 64 bits (true of all architectures except ia32), then the output from
7754 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
7755 is because floating-point conversions are used to convert fixed point.
7760 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
7761 within an unnamed @code{block_statement}. See 3.9(10).
7764 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7765 decimal integer are allocated.
7770 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
7773 @xref{Implementation Defined Attributes}.
7778 @strong{22}. Any implementation-defined time types. See 9.6(6).
7781 There are no implementation-defined time types.
7786 @strong{23}. The time base associated with relative delays.
7789 See 9.6(20). The time base used is that provided by the C library
7790 function @code{gettimeofday}.
7795 @strong{24}. The time base of the type @code{Calendar.Time}. See
7799 The time base used is that provided by the C library function
7800 @code{gettimeofday}.
7805 @strong{25}. The time zone used for package @code{Calendar}
7806 operations. See 9.6(24).
7809 The time zone used by package @code{Calendar} is the current system time zone
7810 setting for local time, as accessed by the C library function
7816 @strong{26}. Any limit on @code{delay_until_statements} of
7817 @code{select_statements}. See 9.6(29).
7820 There are no such limits.
7825 @strong{27}. Whether or not two non-overlapping parts of a composite
7826 object are independently addressable, in the case where packing, record
7827 layout, or @code{Component_Size} is specified for the object. See
7831 Separate components are independently addressable if they do not share
7832 overlapping storage units.
7837 @strong{28}. The representation for a compilation. See 10.1(2).
7840 A compilation is represented by a sequence of files presented to the
7841 compiler in a single invocation of the @command{gcc} command.
7846 @strong{29}. Any restrictions on compilations that contain multiple
7847 compilation_units. See 10.1(4).
7850 No single file can contain more than one compilation unit, but any
7851 sequence of files can be presented to the compiler as a single
7857 @strong{30}. The mechanisms for creating an environment and for adding
7858 and replacing compilation units. See 10.1.4(3).
7861 See separate section on compilation model.
7866 @strong{31}. The manner of explicitly assigning library units to a
7867 partition. See 10.2(2).
7870 If a unit contains an Ada main program, then the Ada units for the partition
7871 are determined by recursive application of the rules in the Ada Reference
7872 Manual section 10.2(2-6). In other words, the Ada units will be those that
7873 are needed by the main program, and then this definition of need is applied
7874 recursively to those units, and the partition contains the transitive
7875 closure determined by this relationship. In short, all the necessary units
7876 are included, with no need to explicitly specify the list. If additional
7877 units are required, e.g.@: by foreign language units, then all units must be
7878 mentioned in the context clause of one of the needed Ada units.
7880 If the partition contains no main program, or if the main program is in
7881 a language other than Ada, then GNAT
7882 provides the binder options @option{-z} and @option{-n} respectively, and in
7883 this case a list of units can be explicitly supplied to the binder for
7884 inclusion in the partition (all units needed by these units will also
7885 be included automatically). For full details on the use of these
7886 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
7887 @value{EDITION} User's Guide}.
7892 @strong{32}. The implementation-defined means, if any, of specifying
7893 which compilation units are needed by a given compilation unit. See
7897 The units needed by a given compilation unit are as defined in
7898 the Ada Reference Manual section 10.2(2-6). There are no
7899 implementation-defined pragmas or other implementation-defined
7900 means for specifying needed units.
7905 @strong{33}. The manner of designating the main subprogram of a
7906 partition. See 10.2(7).
7909 The main program is designated by providing the name of the
7910 corresponding @file{ALI} file as the input parameter to the binder.
7915 @strong{34}. The order of elaboration of @code{library_items}. See
7919 The first constraint on ordering is that it meets the requirements of
7920 Chapter 10 of the Ada Reference Manual. This still leaves some
7921 implementation dependent choices, which are resolved by first
7922 elaborating bodies as early as possible (i.e., in preference to specs
7923 where there is a choice), and second by evaluating the immediate with
7924 clauses of a unit to determine the probably best choice, and
7925 third by elaborating in alphabetical order of unit names
7926 where a choice still remains.
7931 @strong{35}. Parameter passing and function return for the main
7932 subprogram. See 10.2(21).
7935 The main program has no parameters. It may be a procedure, or a function
7936 returning an integer type. In the latter case, the returned integer
7937 value is the return code of the program (overriding any value that
7938 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
7943 @strong{36}. The mechanisms for building and running partitions. See
7947 GNAT itself supports programs with only a single partition. The GNATDIST
7948 tool provided with the GLADE package (which also includes an implementation
7949 of the PCS) provides a completely flexible method for building and running
7950 programs consisting of multiple partitions. See the separate GLADE manual
7956 @strong{37}. The details of program execution, including program
7957 termination. See 10.2(25).
7960 See separate section on compilation model.
7965 @strong{38}. The semantics of any non-active partitions supported by the
7966 implementation. See 10.2(28).
7969 Passive partitions are supported on targets where shared memory is
7970 provided by the operating system. See the GLADE reference manual for
7976 @strong{39}. The information returned by @code{Exception_Message}. See
7980 Exception message returns the null string unless a specific message has
7981 been passed by the program.
7986 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
7987 declared within an unnamed @code{block_statement}. See 11.4.1(12).
7990 Blocks have implementation defined names of the form @code{B@var{nnn}}
7991 where @var{nnn} is an integer.
7996 @strong{41}. The information returned by
7997 @code{Exception_Information}. See 11.4.1(13).
8000 @code{Exception_Information} returns a string in the following format:
8003 @emph{Exception_Name:} nnnnn
8004 @emph{Message:} mmmmm
8006 @emph{Call stack traceback locations:}
8007 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8015 @code{nnnn} is the fully qualified name of the exception in all upper
8016 case letters. This line is always present.
8019 @code{mmmm} is the message (this line present only if message is non-null)
8022 @code{ppp} is the Process Id value as a decimal integer (this line is
8023 present only if the Process Id is nonzero). Currently we are
8024 not making use of this field.
8027 The Call stack traceback locations line and the following values
8028 are present only if at least one traceback location was recorded.
8029 The values are given in C style format, with lower case letters
8030 for a-f, and only as many digits present as are necessary.
8034 The line terminator sequence at the end of each line, including
8035 the last line is a single @code{LF} character (@code{16#0A#}).
8040 @strong{42}. Implementation-defined check names. See 11.5(27).
8043 The implementation defined check name Alignment_Check controls checking of
8044 address clause values for proper alignment (that is, the address supplied
8045 must be consistent with the alignment of the type).
8047 In addition, a user program can add implementation-defined check names
8048 by means of the pragma Check_Name.
8053 @strong{43}. The interpretation of each aspect of representation. See
8057 See separate section on data representations.
8062 @strong{44}. Any restrictions placed upon representation items. See
8066 See separate section on data representations.
8071 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
8075 Size for an indefinite subtype is the maximum possible size, except that
8076 for the case of a subprogram parameter, the size of the parameter object
8082 @strong{46}. The default external representation for a type tag. See
8086 The default external representation for a type tag is the fully expanded
8087 name of the type in upper case letters.
8092 @strong{47}. What determines whether a compilation unit is the same in
8093 two different partitions. See 13.3(76).
8096 A compilation unit is the same in two different partitions if and only
8097 if it derives from the same source file.
8102 @strong{48}. Implementation-defined components. See 13.5.1(15).
8105 The only implementation defined component is the tag for a tagged type,
8106 which contains a pointer to the dispatching table.
8111 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
8112 ordering. See 13.5.3(5).
8115 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8116 implementation, so no non-default bit ordering is supported. The default
8117 bit ordering corresponds to the natural endianness of the target architecture.
8122 @strong{50}. The contents of the visible part of package @code{System}
8123 and its language-defined children. See 13.7(2).
8126 See the definition of these packages in files @file{system.ads} and
8127 @file{s-stoele.ads}.
8132 @strong{51}. The contents of the visible part of package
8133 @code{System.Machine_Code}, and the meaning of
8134 @code{code_statements}. See 13.8(7).
8137 See the definition and documentation in file @file{s-maccod.ads}.
8142 @strong{52}. The effect of unchecked conversion. See 13.9(11).
8145 Unchecked conversion between types of the same size
8146 results in an uninterpreted transmission of the bits from one type
8147 to the other. If the types are of unequal sizes, then in the case of
8148 discrete types, a shorter source is first zero or sign extended as
8149 necessary, and a shorter target is simply truncated on the left.
8150 For all non-discrete types, the source is first copied if necessary
8151 to ensure that the alignment requirements of the target are met, then
8152 a pointer is constructed to the source value, and the result is obtained
8153 by dereferencing this pointer after converting it to be a pointer to the
8154 target type. Unchecked conversions where the target subtype is an
8155 unconstrained array are not permitted. If the target alignment is
8156 greater than the source alignment, then a copy of the result is
8157 made with appropriate alignment
8162 @strong{53}. The manner of choosing a storage pool for an access type
8163 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
8166 There are 3 different standard pools used by the compiler when
8167 @code{Storage_Pool} is not specified depending whether the type is local
8168 to a subprogram or defined at the library level and whether
8169 @code{Storage_Size}is specified or not. See documentation in the runtime
8170 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8171 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8172 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8178 @strong{54}. Whether or not the implementation provides user-accessible
8179 names for the standard pool type(s). See 13.11(17).
8183 See documentation in the sources of the run time mentioned in paragraph
8184 @strong{53} . All these pools are accessible by means of @code{with}'ing
8190 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
8193 @code{Storage_Size} is measured in storage units, and refers to the
8194 total space available for an access type collection, or to the primary
8195 stack space for a task.
8200 @strong{56}. Implementation-defined aspects of storage pools. See
8204 See documentation in the sources of the run time mentioned in paragraph
8205 @strong{53} for details on GNAT-defined aspects of storage pools.
8210 @strong{57}. The set of restrictions allowed in a pragma
8211 @code{Restrictions}. See 13.12(7).
8214 All RM defined Restriction identifiers are implemented. The following
8215 additional restriction identifiers are provided. There are two separate
8216 lists of implementation dependent restriction identifiers. The first
8217 set requires consistency throughout a partition (in other words, if the
8218 restriction identifier is used for any compilation unit in the partition,
8219 then all compilation units in the partition must obey the restriction.
8223 @item Simple_Barriers
8224 @findex Simple_Barriers
8225 This restriction ensures at compile time that barriers in entry declarations
8226 for protected types are restricted to either static boolean expressions or
8227 references to simple boolean variables defined in the private part of the
8228 protected type. No other form of entry barriers is permitted. This is one
8229 of the restrictions of the Ravenscar profile for limited tasking (see also
8230 pragma @code{Profile (Ravenscar)}).
8232 @item Max_Entry_Queue_Length => Expr
8233 @findex Max_Entry_Queue_Length
8234 This restriction is a declaration that any protected entry compiled in
8235 the scope of the restriction has at most the specified number of
8236 tasks waiting on the entry
8237 at any one time, and so no queue is required. This restriction is not
8238 checked at compile time. A program execution is erroneous if an attempt
8239 is made to queue more than the specified number of tasks on such an entry.
8243 This restriction ensures at compile time that there is no implicit or
8244 explicit dependence on the package @code{Ada.Calendar}.
8246 @item No_Default_Initialization
8247 @findex No_Default_Initialization
8249 This restriction prohibits any instance of default initialization of variables.
8250 The binder implements a consistency rule which prevents any unit compiled
8251 without the restriction from with'ing a unit with the restriction (this allows
8252 the generation of initialization procedures to be skipped, since you can be
8253 sure that no call is ever generated to an initialization procedure in a unit
8254 with the restriction active). If used in conjunction with Initialize_Scalars or
8255 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8256 without a specific initializer (including the case of OUT scalar parameters).
8258 @item No_Direct_Boolean_Operators
8259 @findex No_Direct_Boolean_Operators
8260 This restriction ensures that no logical (and/or/xor) or comparison
8261 operators are used on operands of type Boolean (or any type derived
8262 from Boolean). This is intended for use in safety critical programs
8263 where the certification protocol requires the use of short-circuit
8264 (and then, or else) forms for all composite boolean operations.
8266 @item No_Dispatching_Calls
8267 @findex No_Dispatching_Calls
8268 This restriction ensures at compile time that the code generated by the
8269 compiler involves no dispatching calls. The use of this restriction allows the
8270 safe use of record extensions, classwide membership tests and other classwide
8271 features not involving implicit dispatching. This restriction ensures that
8272 the code contains no indirect calls through a dispatching mechanism. Note that
8273 this includes internally-generated calls created by the compiler, for example
8274 in the implementation of class-wide objects assignments. The
8275 membership test is allowed in the presence of this restriction, because its
8276 implementation requires no dispatching.
8277 This restriction is comparable to the official Ada restriction
8278 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8279 all classwide constructs that do not imply dispatching.
8280 The following example indicates constructs that violate this restriction.
8284 type T is tagged record
8287 procedure P (X : T);
8289 type DT is new T with record
8290 More_Data : Natural;
8292 procedure Q (X : DT);
8296 procedure Example is
8297 procedure Test (O : T'Class) is
8298 N : Natural := O'Size;-- Error: Dispatching call
8299 C : T'Class := O; -- Error: implicit Dispatching Call
8301 if O in DT'Class then -- OK : Membership test
8302 Q (DT (O)); -- OK : Type conversion plus direct call
8304 P (O); -- Error: Dispatching call
8310 P (Obj); -- OK : Direct call
8311 P (T (Obj)); -- OK : Type conversion plus direct call
8312 P (T'Class (Obj)); -- Error: Dispatching call
8314 Test (Obj); -- OK : Type conversion
8316 if Obj in T'Class then -- OK : Membership test
8322 @item No_Dynamic_Attachment
8323 @findex No_Dynamic_Attachment
8324 This restriction ensures that there is no call to any of the operations
8325 defined in package Ada.Interrupts.
8327 @item No_Enumeration_Maps
8328 @findex No_Enumeration_Maps
8329 This restriction ensures at compile time that no operations requiring
8330 enumeration maps are used (that is Image and Value attributes applied
8331 to enumeration types).
8333 @item No_Entry_Calls_In_Elaboration_Code
8334 @findex No_Entry_Calls_In_Elaboration_Code
8335 This restriction ensures at compile time that no task or protected entry
8336 calls are made during elaboration code. As a result of the use of this
8337 restriction, the compiler can assume that no code past an accept statement
8338 in a task can be executed at elaboration time.
8340 @item No_Exception_Handlers
8341 @findex No_Exception_Handlers
8342 This restriction ensures at compile time that there are no explicit
8343 exception handlers. It also indicates that no exception propagation will
8344 be provided. In this mode, exceptions may be raised but will result in
8345 an immediate call to the last chance handler, a routine that the user
8346 must define with the following profile:
8348 @smallexample @c ada
8349 procedure Last_Chance_Handler
8350 (Source_Location : System.Address; Line : Integer);
8351 pragma Export (C, Last_Chance_Handler,
8352 "__gnat_last_chance_handler");
8355 The parameter is a C null-terminated string representing a message to be
8356 associated with the exception (typically the source location of the raise
8357 statement generated by the compiler). The Line parameter when nonzero
8358 represents the line number in the source program where the raise occurs.
8360 @item No_Exception_Propagation
8361 @findex No_Exception_Propagation
8362 This restriction guarantees that exceptions are never propagated to an outer
8363 subprogram scope). The only case in which an exception may be raised is when
8364 the handler is statically in the same subprogram, so that the effect of a raise
8365 is essentially like a goto statement. Any other raise statement (implicit or
8366 explicit) will be considered unhandled. Exception handlers are allowed, but may
8367 not contain an exception occurrence identifier (exception choice). In addition
8368 use of the package GNAT.Current_Exception is not permitted, and reraise
8369 statements (raise with no operand) are not permitted.
8371 @item No_Exception_Registration
8372 @findex No_Exception_Registration
8373 This restriction ensures at compile time that no stream operations for
8374 types Exception_Id or Exception_Occurrence are used. This also makes it
8375 impossible to pass exceptions to or from a partition with this restriction
8376 in a distributed environment. If this exception is active, then the generated
8377 code is simplified by omitting the otherwise-required global registration
8378 of exceptions when they are declared.
8380 @item No_Implicit_Conditionals
8381 @findex No_Implicit_Conditionals
8382 This restriction ensures that the generated code does not contain any
8383 implicit conditionals, either by modifying the generated code where possible,
8384 or by rejecting any construct that would otherwise generate an implicit
8385 conditional. Note that this check does not include run time constraint
8386 checks, which on some targets may generate implicit conditionals as
8387 well. To control the latter, constraint checks can be suppressed in the
8388 normal manner. Constructs generating implicit conditionals include comparisons
8389 of composite objects and the Max/Min attributes.
8391 @item No_Implicit_Dynamic_Code
8392 @findex No_Implicit_Dynamic_Code
8394 This restriction prevents the compiler from building ``trampolines''.
8395 This is a structure that is built on the stack and contains dynamic
8396 code to be executed at run time. On some targets, a trampoline is
8397 built for the following features: @code{Access},
8398 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8399 nested task bodies; primitive operations of nested tagged types.
8400 Trampolines do not work on machines that prevent execution of stack
8401 data. For example, on windows systems, enabling DEP (data execution
8402 protection) will cause trampolines to raise an exception.
8403 Trampolines are also quite slow at run time.
8405 On many targets, trampolines have been largely eliminated. Look at the
8406 version of system.ads for your target --- if it has
8407 Always_Compatible_Rep equal to False, then trampolines are largely
8408 eliminated. In particular, a trampoline is built for the following
8409 features: @code{Address} of a nested subprogram;
8410 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8411 but only if pragma Favor_Top_Level applies, or the access type has a
8412 foreign-language convention; primitive operations of nested tagged
8415 @item No_Implicit_Loops
8416 @findex No_Implicit_Loops
8417 This restriction ensures that the generated code does not contain any
8418 implicit @code{for} loops, either by modifying
8419 the generated code where possible,
8420 or by rejecting any construct that would otherwise generate an implicit
8421 @code{for} loop. If this restriction is active, it is possible to build
8422 large array aggregates with all static components without generating an
8423 intermediate temporary, and without generating a loop to initialize individual
8424 components. Otherwise, a loop is created for arrays larger than about 5000
8427 @item No_Initialize_Scalars
8428 @findex No_Initialize_Scalars
8429 This restriction ensures that no unit in the partition is compiled with
8430 pragma Initialize_Scalars. This allows the generation of more efficient
8431 code, and in particular eliminates dummy null initialization routines that
8432 are otherwise generated for some record and array types.
8434 @item No_Local_Protected_Objects
8435 @findex No_Local_Protected_Objects
8436 This restriction ensures at compile time that protected objects are
8437 only declared at the library level.
8439 @item No_Protected_Type_Allocators
8440 @findex No_Protected_Type_Allocators
8441 This restriction ensures at compile time that there are no allocator
8442 expressions that attempt to allocate protected objects.
8444 @item No_Secondary_Stack
8445 @findex No_Secondary_Stack
8446 This restriction ensures at compile time that the generated code does not
8447 contain any reference to the secondary stack. The secondary stack is used
8448 to implement functions returning unconstrained objects (arrays or records)
8451 @item No_Select_Statements
8452 @findex No_Select_Statements
8453 This restriction ensures at compile time no select statements of any kind
8454 are permitted, that is the keyword @code{select} may not appear.
8455 This is one of the restrictions of the Ravenscar
8456 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8458 @item No_Standard_Storage_Pools
8459 @findex No_Standard_Storage_Pools
8460 This restriction ensures at compile time that no access types
8461 use the standard default storage pool. Any access type declared must
8462 have an explicit Storage_Pool attribute defined specifying a
8463 user-defined storage pool.
8467 This restriction ensures at compile/bind time that there are no
8468 stream objects created (and therefore no actual stream operations).
8469 This restriction does not forbid dependences on the package
8470 @code{Ada.Streams}. So it is permissible to with
8471 @code{Ada.Streams} (or another package that does so itself)
8472 as long as no actual stream objects are created.
8474 @item No_Task_Attributes_Package
8475 @findex No_Task_Attributes_Package
8476 This restriction ensures at compile time that there are no implicit or
8477 explicit dependencies on the package @code{Ada.Task_Attributes}.
8479 @item No_Task_Termination
8480 @findex No_Task_Termination
8481 This restriction ensures at compile time that no terminate alternatives
8482 appear in any task body.
8486 This restriction prevents the declaration of tasks or task types throughout
8487 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
8488 except that violations are caught at compile time and cause an error message
8489 to be output either by the compiler or binder.
8491 @item Static_Priorities
8492 @findex Static_Priorities
8493 This restriction ensures at compile time that all priority expressions
8494 are static, and that there are no dependencies on the package
8495 @code{Ada.Dynamic_Priorities}.
8497 @item Static_Storage_Size
8498 @findex Static_Storage_Size
8499 This restriction ensures at compile time that any expression appearing
8500 in a Storage_Size pragma or attribute definition clause is static.
8505 The second set of implementation dependent restriction identifiers
8506 does not require partition-wide consistency.
8507 The restriction may be enforced for a single
8508 compilation unit without any effect on any of the
8509 other compilation units in the partition.
8513 @item No_Elaboration_Code
8514 @findex No_Elaboration_Code
8515 This restriction ensures at compile time that no elaboration code is
8516 generated. Note that this is not the same condition as is enforced
8517 by pragma @code{Preelaborate}. There are cases in which pragma
8518 @code{Preelaborate} still permits code to be generated (e.g.@: code
8519 to initialize a large array to all zeroes), and there are cases of units
8520 which do not meet the requirements for pragma @code{Preelaborate},
8521 but for which no elaboration code is generated. Generally, it is
8522 the case that preelaborable units will meet the restrictions, with
8523 the exception of large aggregates initialized with an others_clause,
8524 and exception declarations (which generate calls to a run-time
8525 registry procedure). This restriction is enforced on
8526 a unit by unit basis, it need not be obeyed consistently
8527 throughout a partition.
8529 In the case of aggregates with others, if the aggregate has a dynamic
8530 size, there is no way to eliminate the elaboration code (such dynamic
8531 bounds would be incompatible with @code{Preelaborate} in any case). If
8532 the bounds are static, then use of this restriction actually modifies
8533 the code choice of the compiler to avoid generating a loop, and instead
8534 generate the aggregate statically if possible, no matter how many times
8535 the data for the others clause must be repeatedly generated.
8537 It is not possible to precisely document
8538 the constructs which are compatible with this restriction, since,
8539 unlike most other restrictions, this is not a restriction on the
8540 source code, but a restriction on the generated object code. For
8541 example, if the source contains a declaration:
8544 Val : constant Integer := X;
8548 where X is not a static constant, it may be possible, depending
8549 on complex optimization circuitry, for the compiler to figure
8550 out the value of X at compile time, in which case this initialization
8551 can be done by the loader, and requires no initialization code. It
8552 is not possible to document the precise conditions under which the
8553 optimizer can figure this out.
8555 Note that this the implementation of this restriction requires full
8556 code generation. If it is used in conjunction with "semantics only"
8557 checking, then some cases of violations may be missed.
8559 @item No_Entry_Queue
8560 @findex No_Entry_Queue
8561 This restriction is a declaration that any protected entry compiled in
8562 the scope of the restriction has at most one task waiting on the entry
8563 at any one time, and so no queue is required. This restriction is not
8564 checked at compile time. A program execution is erroneous if an attempt
8565 is made to queue a second task on such an entry.
8567 @item No_Implementation_Attributes
8568 @findex No_Implementation_Attributes
8569 This restriction checks at compile time that no GNAT-defined attributes
8570 are present. With this restriction, the only attributes that can be used
8571 are those defined in the Ada Reference Manual.
8573 @item No_Implementation_Pragmas
8574 @findex No_Implementation_Pragmas
8575 This restriction checks at compile time that no GNAT-defined pragmas
8576 are present. With this restriction, the only pragmas that can be used
8577 are those defined in the Ada Reference Manual.
8579 @item No_Implementation_Restrictions
8580 @findex No_Implementation_Restrictions
8581 This restriction checks at compile time that no GNAT-defined restriction
8582 identifiers (other than @code{No_Implementation_Restrictions} itself)
8583 are present. With this restriction, the only other restriction identifiers
8584 that can be used are those defined in the Ada Reference Manual.
8586 @item No_Wide_Characters
8587 @findex No_Wide_Characters
8588 This restriction ensures at compile time that no uses of the types
8589 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8591 appear, and that no wide or wide wide string or character literals
8592 appear in the program (that is literals representing characters not in
8593 type @code{Character}.
8600 @strong{58}. The consequences of violating limitations on
8601 @code{Restrictions} pragmas. See 13.12(9).
8604 Restrictions that can be checked at compile time result in illegalities
8605 if violated. Currently there are no other consequences of violating
8611 @strong{59}. The representation used by the @code{Read} and
8612 @code{Write} attributes of elementary types in terms of stream
8613 elements. See 13.13.2(9).
8616 The representation is the in-memory representation of the base type of
8617 the type, using the number of bits corresponding to the
8618 @code{@var{type}'Size} value, and the natural ordering of the machine.
8623 @strong{60}. The names and characteristics of the numeric subtypes
8624 declared in the visible part of package @code{Standard}. See A.1(3).
8627 See items describing the integer and floating-point types supported.
8632 @strong{61}. The accuracy actually achieved by the elementary
8633 functions. See A.5.1(1).
8636 The elementary functions correspond to the functions available in the C
8637 library. Only fast math mode is implemented.
8642 @strong{62}. The sign of a zero result from some of the operators or
8643 functions in @code{Numerics.Generic_Elementary_Functions}, when
8644 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
8647 The sign of zeroes follows the requirements of the IEEE 754 standard on
8653 @strong{63}. The value of
8654 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
8657 Maximum image width is 649, see library file @file{a-numran.ads}.
8662 @strong{64}. The value of
8663 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
8666 Maximum image width is 80, see library file @file{a-nudira.ads}.
8671 @strong{65}. The algorithms for random number generation. See
8675 The algorithm is documented in the source files @file{a-numran.ads} and
8676 @file{a-numran.adb}.
8681 @strong{66}. The string representation of a random number generator's
8682 state. See A.5.2(38).
8685 See the documentation contained in the file @file{a-numran.adb}.
8690 @strong{67}. The minimum time interval between calls to the
8691 time-dependent Reset procedure that are guaranteed to initiate different
8692 random number sequences. See A.5.2(45).
8695 The minimum period between reset calls to guarantee distinct series of
8696 random numbers is one microsecond.
8701 @strong{68}. The values of the @code{Model_Mantissa},
8702 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8703 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8704 Annex is not supported. See A.5.3(72).
8707 See the source file @file{ttypef.ads} for the values of all numeric
8713 @strong{69}. Any implementation-defined characteristics of the
8714 input-output packages. See A.7(14).
8717 There are no special implementation defined characteristics for these
8723 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
8727 All type representations are contiguous, and the @code{Buffer_Size} is
8728 the value of @code{@var{type}'Size} rounded up to the next storage unit
8734 @strong{71}. External files for standard input, standard output, and
8735 standard error See A.10(5).
8738 These files are mapped onto the files provided by the C streams
8739 libraries. See source file @file{i-cstrea.ads} for further details.
8744 @strong{72}. The accuracy of the value produced by @code{Put}. See
8748 If more digits are requested in the output than are represented by the
8749 precision of the value, zeroes are output in the corresponding least
8750 significant digit positions.
8755 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
8756 @code{Command_Name}. See A.15(1).
8759 These are mapped onto the @code{argv} and @code{argc} parameters of the
8760 main program in the natural manner.
8765 @strong{74}. Implementation-defined convention names. See B.1(11).
8768 The following convention names are supported
8776 Synonym for Assembler
8778 Synonym for Assembler
8781 @item C_Pass_By_Copy
8782 Allowed only for record types, like C, but also notes that record
8783 is to be passed by copy rather than reference.
8786 @item C_Plus_Plus (or CPP)
8789 Treated the same as C
8791 Treated the same as C
8795 For support of pragma @code{Import} with convention Intrinsic, see
8796 separate section on Intrinsic Subprograms.
8798 Stdcall (used for Windows implementations only). This convention correspond
8799 to the WINAPI (previously called Pascal convention) C/C++ convention under
8800 Windows. A function with this convention cleans the stack before exit.
8806 Stubbed is a special convention used to indicate that the body of the
8807 subprogram will be entirely ignored. Any call to the subprogram
8808 is converted into a raise of the @code{Program_Error} exception. If a
8809 pragma @code{Import} specifies convention @code{stubbed} then no body need
8810 be present at all. This convention is useful during development for the
8811 inclusion of subprograms whose body has not yet been written.
8815 In addition, all otherwise unrecognized convention names are also
8816 treated as being synonymous with convention C@. In all implementations
8817 except for VMS, use of such other names results in a warning. In VMS
8818 implementations, these names are accepted silently.
8823 @strong{75}. The meaning of link names. See B.1(36).
8826 Link names are the actual names used by the linker.
8831 @strong{76}. The manner of choosing link names when neither the link
8832 name nor the address of an imported or exported entity is specified. See
8836 The default linker name is that which would be assigned by the relevant
8837 external language, interpreting the Ada name as being in all lower case
8843 @strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37).
8846 The string passed to @code{Linker_Options} is presented uninterpreted as
8847 an argument to the link command, unless it contains ASCII.NUL characters.
8848 NUL characters if they appear act as argument separators, so for example
8850 @smallexample @c ada
8851 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
8855 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8856 linker. The order of linker options is preserved for a given unit. The final
8857 list of options passed to the linker is in reverse order of the elaboration
8858 order. For example, linker options for a body always appear before the options
8859 from the corresponding package spec.
8864 @strong{78}. The contents of the visible part of package
8865 @code{Interfaces} and its language-defined descendants. See B.2(1).
8868 See files with prefix @file{i-} in the distributed library.
8873 @strong{79}. Implementation-defined children of package
8874 @code{Interfaces}. The contents of the visible part of package
8875 @code{Interfaces}. See B.2(11).
8878 See files with prefix @file{i-} in the distributed library.
8883 @strong{80}. The types @code{Floating}, @code{Long_Floating},
8884 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
8885 @code{COBOL_Character}; and the initialization of the variables
8886 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
8887 @code{Interfaces.COBOL}. See B.4(50).
8894 (Floating) Long_Float
8899 @item Decimal_Element
8901 @item COBOL_Character
8906 For initialization, see the file @file{i-cobol.ads} in the distributed library.
8911 @strong{81}. Support for access to machine instructions. See C.1(1).
8914 See documentation in file @file{s-maccod.ads} in the distributed library.
8919 @strong{82}. Implementation-defined aspects of access to machine
8920 operations. See C.1(9).
8923 See documentation in file @file{s-maccod.ads} in the distributed library.
8928 @strong{83}. Implementation-defined aspects of interrupts. See C.3(2).
8931 Interrupts are mapped to signals or conditions as appropriate. See
8933 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
8934 on the interrupts supported on a particular target.
8939 @strong{84}. Implementation-defined aspects of pre-elaboration. See
8943 GNAT does not permit a partition to be restarted without reloading,
8944 except under control of the debugger.
8949 @strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7).
8952 Pragma @code{Discard_Names} causes names of enumeration literals to
8953 be suppressed. In the presence of this pragma, the Image attribute
8954 provides the image of the Pos of the literal, and Value accepts
8960 @strong{86}. The result of the @code{Task_Identification.Image}
8961 attribute. See C.7.1(7).
8964 The result of this attribute is a string that identifies
8965 the object or component that denotes a given task. If a variable @code{Var}
8966 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
8968 is the hexadecimal representation of the virtual address of the corresponding
8969 task control block. If the variable is an array of tasks, the image of each
8970 task will have the form of an indexed component indicating the position of a
8971 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
8972 component of a record, the image of the task will have the form of a selected
8973 component. These rules are fully recursive, so that the image of a task that
8974 is a subcomponent of a composite object corresponds to the expression that
8975 designates this task.
8977 If a task is created by an allocator, its image depends on the context. If the
8978 allocator is part of an object declaration, the rules described above are used
8979 to construct its image, and this image is not affected by subsequent
8980 assignments. If the allocator appears within an expression, the image
8981 includes only the name of the task type.
8983 If the configuration pragma Discard_Names is present, or if the restriction
8984 No_Implicit_Heap_Allocation is in effect, the image reduces to
8985 the numeric suffix, that is to say the hexadecimal representation of the
8986 virtual address of the control block of the task.
8990 @strong{87}. The value of @code{Current_Task} when in a protected entry
8991 or interrupt handler. See C.7.1(17).
8994 Protected entries or interrupt handlers can be executed by any
8995 convenient thread, so the value of @code{Current_Task} is undefined.
9000 @strong{88}. The effect of calling @code{Current_Task} from an entry
9001 body or interrupt handler. See C.7.1(19).
9004 The effect of calling @code{Current_Task} from an entry body or
9005 interrupt handler is to return the identification of the task currently
9011 @strong{89}. Implementation-defined aspects of
9012 @code{Task_Attributes}. See C.7.2(19).
9015 There are no implementation-defined aspects of @code{Task_Attributes}.
9020 @strong{90}. Values of all @code{Metrics}. See D(2).
9023 The metrics information for GNAT depends on the performance of the
9024 underlying operating system. The sources of the run-time for tasking
9025 implementation, together with the output from @option{-gnatG} can be
9026 used to determine the exact sequence of operating systems calls made
9027 to implement various tasking constructs. Together with appropriate
9028 information on the performance of the underlying operating system,
9029 on the exact target in use, this information can be used to determine
9030 the required metrics.
9035 @strong{91}. The declarations of @code{Any_Priority} and
9036 @code{Priority}. See D.1(11).
9039 See declarations in file @file{system.ads}.
9044 @strong{92}. Implementation-defined execution resources. See D.1(15).
9047 There are no implementation-defined execution resources.
9052 @strong{93}. Whether, on a multiprocessor, a task that is waiting for
9053 access to a protected object keeps its processor busy. See D.2.1(3).
9056 On a multi-processor, a task that is waiting for access to a protected
9057 object does not keep its processor busy.
9062 @strong{94}. The affect of implementation defined execution resources
9063 on task dispatching. See D.2.1(9).
9068 Tasks map to IRIX threads, and the dispatching policy is as defined by
9069 the IRIX implementation of threads.
9071 Tasks map to threads in the threads package used by GNAT@. Where possible
9072 and appropriate, these threads correspond to native threads of the
9073 underlying operating system.
9078 @strong{95}. Implementation-defined @code{policy_identifiers} allowed
9079 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
9082 There are no implementation-defined policy-identifiers allowed in this
9088 @strong{96}. Implementation-defined aspects of priority inversion. See
9092 Execution of a task cannot be preempted by the implementation processing
9093 of delay expirations for lower priority tasks.
9098 @strong{97}. Implementation defined task dispatching. See D.2.2(18).
9103 Tasks map to IRIX threads, and the dispatching policy is as defined by
9104 the IRIX implementation of threads.
9106 The policy is the same as that of the underlying threads implementation.
9111 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
9112 in a pragma @code{Locking_Policy}. See D.3(4).
9115 The only implementation defined policy permitted in GNAT is
9116 @code{Inheritance_Locking}. On targets that support this policy, locking
9117 is implemented by inheritance, i.e.@: the task owning the lock operates
9118 at a priority equal to the highest priority of any task currently
9119 requesting the lock.
9124 @strong{99}. Default ceiling priorities. See D.3(10).
9127 The ceiling priority of protected objects of the type
9128 @code{System.Interrupt_Priority'Last} as described in the Ada
9129 Reference Manual D.3(10),
9134 @strong{100}. The ceiling of any protected object used internally by
9135 the implementation. See D.3(16).
9138 The ceiling priority of internal protected objects is
9139 @code{System.Priority'Last}.
9144 @strong{101}. Implementation-defined queuing policies. See D.4(1).
9147 There are no implementation-defined queuing policies.
9152 @strong{102}. On a multiprocessor, any conditions that cause the
9153 completion of an aborted construct to be delayed later than what is
9154 specified for a single processor. See D.6(3).
9157 The semantics for abort on a multi-processor is the same as on a single
9158 processor, there are no further delays.
9163 @strong{103}. Any operations that implicitly require heap storage
9164 allocation. See D.7(8).
9167 The only operation that implicitly requires heap storage allocation is
9173 @strong{104}. Implementation-defined aspects of pragma
9174 @code{Restrictions}. See D.7(20).
9177 There are no such implementation-defined aspects.
9182 @strong{105}. Implementation-defined aspects of package
9183 @code{Real_Time}. See D.8(17).
9186 There are no implementation defined aspects of package @code{Real_Time}.
9191 @strong{106}. Implementation-defined aspects of
9192 @code{delay_statements}. See D.9(8).
9195 Any difference greater than one microsecond will cause the task to be
9196 delayed (see D.9(7)).
9201 @strong{107}. The upper bound on the duration of interrupt blocking
9202 caused by the implementation. See D.12(5).
9205 The upper bound is determined by the underlying operating system. In
9206 no cases is it more than 10 milliseconds.
9211 @strong{108}. The means for creating and executing distributed
9215 The GLADE package provides a utility GNATDIST for creating and executing
9216 distributed programs. See the GLADE reference manual for further details.
9221 @strong{109}. Any events that can result in a partition becoming
9222 inaccessible. See E.1(7).
9225 See the GLADE reference manual for full details on such events.
9230 @strong{110}. The scheduling policies, treatment of priorities, and
9231 management of shared resources between partitions in certain cases. See
9235 See the GLADE reference manual for full details on these aspects of
9236 multi-partition execution.
9241 @strong{111}. Events that cause the version of a compilation unit to
9245 Editing the source file of a compilation unit, or the source files of
9246 any units on which it is dependent in a significant way cause the version
9247 to change. No other actions cause the version number to change. All changes
9248 are significant except those which affect only layout, capitalization or
9254 @strong{112}. Whether the execution of the remote subprogram is
9255 immediately aborted as a result of cancellation. See E.4(13).
9258 See the GLADE reference manual for details on the effect of abort in
9259 a distributed application.
9264 @strong{113}. Implementation-defined aspects of the PCS@. See E.5(25).
9267 See the GLADE reference manual for a full description of all implementation
9268 defined aspects of the PCS@.
9273 @strong{114}. Implementation-defined interfaces in the PCS@. See
9277 See the GLADE reference manual for a full description of all
9278 implementation defined interfaces.
9283 @strong{115}. The values of named numbers in the package
9284 @code{Decimal}. See F.2(7).
9296 @item Max_Decimal_Digits
9303 @strong{116}. The value of @code{Max_Picture_Length} in the package
9304 @code{Text_IO.Editing}. See F.3.3(16).
9312 @strong{117}. The value of @code{Max_Picture_Length} in the package
9313 @code{Wide_Text_IO.Editing}. See F.3.4(5).
9321 @strong{118}. The accuracy actually achieved by the complex elementary
9322 functions and by other complex arithmetic operations. See G.1(1).
9325 Standard library functions are used for the complex arithmetic
9326 operations. Only fast math mode is currently supported.
9331 @strong{119}. The sign of a zero result (or a component thereof) from
9332 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9333 @code{Real'Signed_Zeros} is True. See G.1.1(53).
9336 The signs of zero values are as recommended by the relevant
9337 implementation advice.
9342 @strong{120}. The sign of a zero result (or a component thereof) from
9343 any operator or function in
9344 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9345 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
9348 The signs of zero values are as recommended by the relevant
9349 implementation advice.
9354 @strong{121}. Whether the strict mode or the relaxed mode is the
9355 default. See G.2(2).
9358 The strict mode is the default. There is no separate relaxed mode. GNAT
9359 provides a highly efficient implementation of strict mode.
9364 @strong{122}. The result interval in certain cases of fixed-to-float
9365 conversion. See G.2.1(10).
9368 For cases where the result interval is implementation dependent, the
9369 accuracy is that provided by performing all operations in 64-bit IEEE
9370 floating-point format.
9375 @strong{123}. The result of a floating point arithmetic operation in
9376 overflow situations, when the @code{Machine_Overflows} attribute of the
9377 result type is @code{False}. See G.2.1(13).
9380 Infinite and NaN values are produced as dictated by the IEEE
9381 floating-point standard.
9383 Note that on machines that are not fully compliant with the IEEE
9384 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9385 must be used for achieving IEEE confirming behavior (although at the cost
9386 of a significant performance penalty), so infinite and NaN values are
9392 @strong{124}. The result interval for division (or exponentiation by a
9393 negative exponent), when the floating point hardware implements division
9394 as multiplication by a reciprocal. See G.2.1(16).
9397 Not relevant, division is IEEE exact.
9402 @strong{125}. The definition of close result set, which determines the
9403 accuracy of certain fixed point multiplications and divisions. See
9407 Operations in the close result set are performed using IEEE long format
9408 floating-point arithmetic. The input operands are converted to
9409 floating-point, the operation is done in floating-point, and the result
9410 is converted to the target type.
9415 @strong{126}. Conditions on a @code{universal_real} operand of a fixed
9416 point multiplication or division for which the result shall be in the
9417 perfect result set. See G.2.3(22).
9420 The result is only defined to be in the perfect result set if the result
9421 can be computed by a single scaling operation involving a scale factor
9422 representable in 64-bits.
9427 @strong{127}. The result of a fixed point arithmetic operation in
9428 overflow situations, when the @code{Machine_Overflows} attribute of the
9429 result type is @code{False}. See G.2.3(27).
9432 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9438 @strong{128}. The result of an elementary function reference in
9439 overflow situations, when the @code{Machine_Overflows} attribute of the
9440 result type is @code{False}. See G.2.4(4).
9443 IEEE infinite and Nan values are produced as appropriate.
9448 @strong{129}. The value of the angle threshold, within which certain
9449 elementary functions, complex arithmetic operations, and complex
9450 elementary functions yield results conforming to a maximum relative
9451 error bound. See G.2.4(10).
9454 Information on this subject is not yet available.
9459 @strong{130}. The accuracy of certain elementary functions for
9460 parameters beyond the angle threshold. See G.2.4(10).
9463 Information on this subject is not yet available.
9468 @strong{131}. The result of a complex arithmetic operation or complex
9469 elementary function reference in overflow situations, when the
9470 @code{Machine_Overflows} attribute of the corresponding real type is
9471 @code{False}. See G.2.6(5).
9474 IEEE infinite and Nan values are produced as appropriate.
9479 @strong{132}. The accuracy of certain complex arithmetic operations and
9480 certain complex elementary functions for parameters (or components
9481 thereof) beyond the angle threshold. See G.2.6(8).
9484 Information on those subjects is not yet available.
9489 @strong{133}. Information regarding bounded errors and erroneous
9490 execution. See H.2(1).
9493 Information on this subject is not yet available.
9498 @strong{134}. Implementation-defined aspects of pragma
9499 @code{Inspection_Point}. See H.3.2(8).
9502 Pragma @code{Inspection_Point} ensures that the variable is live and can
9503 be examined by the debugger at the inspection point.
9508 @strong{135}. Implementation-defined aspects of pragma
9509 @code{Restrictions}. See H.4(25).
9512 There are no implementation-defined aspects of pragma @code{Restrictions}. The
9513 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9514 generated code. Checks must suppressed by use of pragma @code{Suppress}.
9519 @strong{136}. Any restrictions on pragma @code{Restrictions}. See
9523 There are no restrictions on pragma @code{Restrictions}.
9525 @node Intrinsic Subprograms
9526 @chapter Intrinsic Subprograms
9527 @cindex Intrinsic Subprograms
9530 * Intrinsic Operators::
9531 * Enclosing_Entity::
9532 * Exception_Information::
9533 * Exception_Message::
9541 * Shift_Right_Arithmetic::
9546 GNAT allows a user application program to write the declaration:
9548 @smallexample @c ada
9549 pragma Import (Intrinsic, name);
9553 providing that the name corresponds to one of the implemented intrinsic
9554 subprograms in GNAT, and that the parameter profile of the referenced
9555 subprogram meets the requirements. This chapter describes the set of
9556 implemented intrinsic subprograms, and the requirements on parameter profiles.
9557 Note that no body is supplied; as with other uses of pragma Import, the
9558 body is supplied elsewhere (in this case by the compiler itself). Note
9559 that any use of this feature is potentially non-portable, since the
9560 Ada standard does not require Ada compilers to implement this feature.
9562 @node Intrinsic Operators
9563 @section Intrinsic Operators
9564 @cindex Intrinsic operator
9567 All the predefined numeric operators in package Standard
9568 in @code{pragma Import (Intrinsic,..)}
9569 declarations. In the binary operator case, the operands must have the same
9570 size. The operand or operands must also be appropriate for
9571 the operator. For example, for addition, the operands must
9572 both be floating-point or both be fixed-point, and the
9573 right operand for @code{"**"} must have a root type of
9574 @code{Standard.Integer'Base}.
9575 You can use an intrinsic operator declaration as in the following example:
9577 @smallexample @c ada
9578 type Int1 is new Integer;
9579 type Int2 is new Integer;
9581 function "+" (X1 : Int1; X2 : Int2) return Int1;
9582 function "+" (X1 : Int1; X2 : Int2) return Int2;
9583 pragma Import (Intrinsic, "+");
9587 This declaration would permit ``mixed mode'' arithmetic on items
9588 of the differing types @code{Int1} and @code{Int2}.
9589 It is also possible to specify such operators for private types, if the
9590 full views are appropriate arithmetic types.
9592 @node Enclosing_Entity
9593 @section Enclosing_Entity
9594 @cindex Enclosing_Entity
9596 This intrinsic subprogram is used in the implementation of the
9597 library routine @code{GNAT.Source_Info}. The only useful use of the
9598 intrinsic import in this case is the one in this unit, so an
9599 application program should simply call the function
9600 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9601 the current subprogram, package, task, entry, or protected subprogram.
9603 @node Exception_Information
9604 @section Exception_Information
9605 @cindex Exception_Information'
9607 This intrinsic subprogram is used in the implementation of the
9608 library routine @code{GNAT.Current_Exception}. The only useful
9609 use of the intrinsic import in this case is the one in this unit,
9610 so an application program should simply call the function
9611 @code{GNAT.Current_Exception.Exception_Information} to obtain
9612 the exception information associated with the current exception.
9614 @node Exception_Message
9615 @section Exception_Message
9616 @cindex Exception_Message
9618 This intrinsic subprogram is used in the implementation of the
9619 library routine @code{GNAT.Current_Exception}. The only useful
9620 use of the intrinsic import in this case is the one in this unit,
9621 so an application program should simply call the function
9622 @code{GNAT.Current_Exception.Exception_Message} to obtain
9623 the message associated with the current exception.
9625 @node Exception_Name
9626 @section Exception_Name
9627 @cindex Exception_Name
9629 This intrinsic subprogram is used in the implementation of the
9630 library routine @code{GNAT.Current_Exception}. The only useful
9631 use of the intrinsic import in this case is the one in this unit,
9632 so an application program should simply call the function
9633 @code{GNAT.Current_Exception.Exception_Name} to obtain
9634 the name of the current exception.
9640 This intrinsic subprogram is used in the implementation of the
9641 library routine @code{GNAT.Source_Info}. The only useful use of the
9642 intrinsic import in this case is the one in this unit, so an
9643 application program should simply call the function
9644 @code{GNAT.Source_Info.File} to obtain the name of the current
9651 This intrinsic subprogram is used in the implementation of the
9652 library routine @code{GNAT.Source_Info}. The only useful use of the
9653 intrinsic import in this case is the one in this unit, so an
9654 application program should simply call the function
9655 @code{GNAT.Source_Info.Line} to obtain the number of the current
9659 @section Rotate_Left
9662 In standard Ada, the @code{Rotate_Left} function is available only
9663 for the predefined modular types in package @code{Interfaces}. However, in
9664 GNAT it is possible to define a Rotate_Left function for a user
9665 defined modular type or any signed integer type as in this example:
9667 @smallexample @c ada
9669 (Value : My_Modular_Type;
9671 return My_Modular_Type;
9675 The requirements are that the profile be exactly as in the example
9676 above. The only modifications allowed are in the formal parameter
9677 names, and in the type of @code{Value} and the return type, which
9678 must be the same, and must be either a signed integer type, or
9679 a modular integer type with a binary modulus, and the size must
9680 be 8. 16, 32 or 64 bits.
9683 @section Rotate_Right
9684 @cindex Rotate_Right
9686 A @code{Rotate_Right} function can be defined for any user defined
9687 binary modular integer type, or signed integer type, as described
9688 above for @code{Rotate_Left}.
9694 A @code{Shift_Left} function can be defined for any user defined
9695 binary modular integer type, or signed integer type, as described
9696 above for @code{Rotate_Left}.
9699 @section Shift_Right
9702 A @code{Shift_Right} function can be defined for any user defined
9703 binary modular integer type, or signed integer type, as described
9704 above for @code{Rotate_Left}.
9706 @node Shift_Right_Arithmetic
9707 @section Shift_Right_Arithmetic
9708 @cindex Shift_Right_Arithmetic
9710 A @code{Shift_Right_Arithmetic} function can be defined for any user
9711 defined binary modular integer type, or signed integer type, as described
9712 above for @code{Rotate_Left}.
9714 @node Source_Location
9715 @section Source_Location
9716 @cindex Source_Location
9718 This intrinsic subprogram is used in the implementation of the
9719 library routine @code{GNAT.Source_Info}. The only useful use of the
9720 intrinsic import in this case is the one in this unit, so an
9721 application program should simply call the function
9722 @code{GNAT.Source_Info.Source_Location} to obtain the current
9723 source file location.
9725 @node Representation Clauses and Pragmas
9726 @chapter Representation Clauses and Pragmas
9727 @cindex Representation Clauses
9730 * Alignment Clauses::
9732 * Storage_Size Clauses::
9733 * Size of Variant Record Objects::
9734 * Biased Representation ::
9735 * Value_Size and Object_Size Clauses::
9736 * Component_Size Clauses::
9737 * Bit_Order Clauses::
9738 * Effect of Bit_Order on Byte Ordering::
9739 * Pragma Pack for Arrays::
9740 * Pragma Pack for Records::
9741 * Record Representation Clauses::
9742 * Enumeration Clauses::
9744 * Effect of Convention on Representation::
9745 * Determining the Representations chosen by GNAT::
9749 @cindex Representation Clause
9750 @cindex Representation Pragma
9751 @cindex Pragma, representation
9752 This section describes the representation clauses accepted by GNAT, and
9753 their effect on the representation of corresponding data objects.
9755 GNAT fully implements Annex C (Systems Programming). This means that all
9756 the implementation advice sections in chapter 13 are fully implemented.
9757 However, these sections only require a minimal level of support for
9758 representation clauses. GNAT provides much more extensive capabilities,
9759 and this section describes the additional capabilities provided.
9761 @node Alignment Clauses
9762 @section Alignment Clauses
9763 @cindex Alignment Clause
9766 GNAT requires that all alignment clauses specify a power of 2, and all
9767 default alignments are always a power of 2. The default alignment
9768 values are as follows:
9771 @item @emph{Primitive Types}.
9772 For primitive types, the alignment is the minimum of the actual size of
9773 objects of the type divided by @code{Storage_Unit},
9774 and the maximum alignment supported by the target.
9775 (This maximum alignment is given by the GNAT-specific attribute
9776 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9777 @cindex @code{Maximum_Alignment} attribute
9778 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9779 default alignment will be 8 on any target that supports alignments
9780 this large, but on some targets, the maximum alignment may be smaller
9781 than 8, in which case objects of type @code{Long_Float} will be maximally
9784 @item @emph{Arrays}.
9785 For arrays, the alignment is equal to the alignment of the component type
9786 for the normal case where no packing or component size is given. If the
9787 array is packed, and the packing is effective (see separate section on
9788 packed arrays), then the alignment will be one for long packed arrays,
9789 or arrays whose length is not known at compile time. For short packed
9790 arrays, which are handled internally as modular types, the alignment
9791 will be as described for primitive types, e.g.@: a packed array of length
9792 31 bits will have an object size of four bytes, and an alignment of 4.
9794 @item @emph{Records}.
9795 For the normal non-packed case, the alignment of a record is equal to
9796 the maximum alignment of any of its components. For tagged records, this
9797 includes the implicit access type used for the tag. If a pragma @code{Pack}
9798 is used and all components are packable (see separate section on pragma
9799 @code{Pack}), then the resulting alignment is 1, unless the layout of the
9800 record makes it profitable to increase it.
9802 A special case is when:
9805 the size of the record is given explicitly, or a
9806 full record representation clause is given, and
9808 the size of the record is 2, 4, or 8 bytes.
9811 In this case, an alignment is chosen to match the
9812 size of the record. For example, if we have:
9814 @smallexample @c ada
9815 type Small is record
9818 for Small'Size use 16;
9822 then the default alignment of the record type @code{Small} is 2, not 1. This
9823 leads to more efficient code when the record is treated as a unit, and also
9824 allows the type to specified as @code{Atomic} on architectures requiring
9830 An alignment clause may specify a larger alignment than the default value
9831 up to some maximum value dependent on the target (obtainable by using the
9832 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
9833 a smaller alignment than the default value for enumeration, integer and
9834 fixed point types, as well as for record types, for example
9836 @smallexample @c ada
9841 for V'alignment use 1;
9845 @cindex Alignment, default
9846 The default alignment for the type @code{V} is 4, as a result of the
9847 Integer field in the record, but it is permissible, as shown, to
9848 override the default alignment of the record with a smaller value.
9851 @section Size Clauses
9855 The default size for a type @code{T} is obtainable through the
9856 language-defined attribute @code{T'Size} and also through the
9857 equivalent GNAT-defined attribute @code{T'Value_Size}.
9858 For objects of type @code{T}, GNAT will generally increase the type size
9859 so that the object size (obtainable through the GNAT-defined attribute
9860 @code{T'Object_Size})
9861 is a multiple of @code{T'Alignment * Storage_Unit}.
9864 @smallexample @c ada
9865 type Smallint is range 1 .. 6;
9874 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
9875 as specified by the RM rules,
9876 but objects of this type will have a size of 8
9877 (@code{Smallint'Object_Size} = 8),
9878 since objects by default occupy an integral number
9879 of storage units. On some targets, notably older
9880 versions of the Digital Alpha, the size of stand
9881 alone objects of this type may be 32, reflecting
9882 the inability of the hardware to do byte load/stores.
9884 Similarly, the size of type @code{Rec} is 40 bits
9885 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
9886 the alignment is 4, so objects of this type will have
9887 their size increased to 64 bits so that it is a multiple
9888 of the alignment (in bits). This decision is
9889 in accordance with the specific Implementation Advice in RM 13.3(43):
9892 A @code{Size} clause should be supported for an object if the specified
9893 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
9894 to a size in storage elements that is a multiple of the object's
9895 @code{Alignment} (if the @code{Alignment} is nonzero).
9899 An explicit size clause may be used to override the default size by
9900 increasing it. For example, if we have:
9902 @smallexample @c ada
9903 type My_Boolean is new Boolean;
9904 for My_Boolean'Size use 32;
9908 then values of this type will always be 32 bits long. In the case of
9909 discrete types, the size can be increased up to 64 bits, with the effect
9910 that the entire specified field is used to hold the value, sign- or
9911 zero-extended as appropriate. If more than 64 bits is specified, then
9912 padding space is allocated after the value, and a warning is issued that
9913 there are unused bits.
9915 Similarly the size of records and arrays may be increased, and the effect
9916 is to add padding bits after the value. This also causes a warning message
9919 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
9920 Size in bits, this corresponds to an object of size 256 megabytes (minus
9921 one). This limitation is true on all targets. The reason for this
9922 limitation is that it improves the quality of the code in many cases
9923 if it is known that a Size value can be accommodated in an object of
9926 @node Storage_Size Clauses
9927 @section Storage_Size Clauses
9928 @cindex Storage_Size Clause
9931 For tasks, the @code{Storage_Size} clause specifies the amount of space
9932 to be allocated for the task stack. This cannot be extended, and if the
9933 stack is exhausted, then @code{Storage_Error} will be raised (if stack
9934 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
9935 or a @code{Storage_Size} pragma in the task definition to set the
9936 appropriate required size. A useful technique is to include in every
9937 task definition a pragma of the form:
9939 @smallexample @c ada
9940 pragma Storage_Size (Default_Stack_Size);
9944 Then @code{Default_Stack_Size} can be defined in a global package, and
9945 modified as required. Any tasks requiring stack sizes different from the
9946 default can have an appropriate alternative reference in the pragma.
9948 You can also use the @option{-d} binder switch to modify the default stack
9951 For access types, the @code{Storage_Size} clause specifies the maximum
9952 space available for allocation of objects of the type. If this space is
9953 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9954 In the case where the access type is declared local to a subprogram, the
9955 use of a @code{Storage_Size} clause triggers automatic use of a special
9956 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9957 space for the pool is automatically reclaimed on exit from the scope in
9958 which the type is declared.
9960 A special case recognized by the compiler is the specification of a
9961 @code{Storage_Size} of zero for an access type. This means that no
9962 items can be allocated from the pool, and this is recognized at compile
9963 time, and all the overhead normally associated with maintaining a fixed
9964 size storage pool is eliminated. Consider the following example:
9966 @smallexample @c ada
9968 type R is array (Natural) of Character;
9969 type P is access all R;
9970 for P'Storage_Size use 0;
9971 -- Above access type intended only for interfacing purposes
9975 procedure g (m : P);
9976 pragma Import (C, g);
9987 As indicated in this example, these dummy storage pools are often useful in
9988 connection with interfacing where no object will ever be allocated. If you
9989 compile the above example, you get the warning:
9992 p.adb:16:09: warning: allocation from empty storage pool
9993 p.adb:16:09: warning: Storage_Error will be raised at run time
9997 Of course in practice, there will not be any explicit allocators in the
9998 case of such an access declaration.
10000 @node Size of Variant Record Objects
10001 @section Size of Variant Record Objects
10002 @cindex Size, variant record objects
10003 @cindex Variant record objects, size
10006 In the case of variant record objects, there is a question whether Size gives
10007 information about a particular variant, or the maximum size required
10008 for any variant. Consider the following program
10010 @smallexample @c ada
10011 with Text_IO; use Text_IO;
10013 type R1 (A : Boolean := False) is record
10015 when True => X : Character;
10016 when False => null;
10024 Put_Line (Integer'Image (V1'Size));
10025 Put_Line (Integer'Image (V2'Size));
10030 Here we are dealing with a variant record, where the True variant
10031 requires 16 bits, and the False variant requires 8 bits.
10032 In the above example, both V1 and V2 contain the False variant,
10033 which is only 8 bits long. However, the result of running the
10042 The reason for the difference here is that the discriminant value of
10043 V1 is fixed, and will always be False. It is not possible to assign
10044 a True variant value to V1, therefore 8 bits is sufficient. On the
10045 other hand, in the case of V2, the initial discriminant value is
10046 False (from the default), but it is possible to assign a True
10047 variant value to V2, therefore 16 bits must be allocated for V2
10048 in the general case, even fewer bits may be needed at any particular
10049 point during the program execution.
10051 As can be seen from the output of this program, the @code{'Size}
10052 attribute applied to such an object in GNAT gives the actual allocated
10053 size of the variable, which is the largest size of any of the variants.
10054 The Ada Reference Manual is not completely clear on what choice should
10055 be made here, but the GNAT behavior seems most consistent with the
10056 language in the RM@.
10058 In some cases, it may be desirable to obtain the size of the current
10059 variant, rather than the size of the largest variant. This can be
10060 achieved in GNAT by making use of the fact that in the case of a
10061 subprogram parameter, GNAT does indeed return the size of the current
10062 variant (because a subprogram has no way of knowing how much space
10063 is actually allocated for the actual).
10065 Consider the following modified version of the above program:
10067 @smallexample @c ada
10068 with Text_IO; use Text_IO;
10070 type R1 (A : Boolean := False) is record
10072 when True => X : Character;
10073 when False => null;
10079 function Size (V : R1) return Integer is
10085 Put_Line (Integer'Image (V2'Size));
10086 Put_Line (Integer'IMage (Size (V2)));
10088 Put_Line (Integer'Image (V2'Size));
10089 Put_Line (Integer'IMage (Size (V2)));
10094 The output from this program is
10104 Here we see that while the @code{'Size} attribute always returns
10105 the maximum size, regardless of the current variant value, the
10106 @code{Size} function does indeed return the size of the current
10109 @node Biased Representation
10110 @section Biased Representation
10111 @cindex Size for biased representation
10112 @cindex Biased representation
10115 In the case of scalars with a range starting at other than zero, it is
10116 possible in some cases to specify a size smaller than the default minimum
10117 value, and in such cases, GNAT uses an unsigned biased representation,
10118 in which zero is used to represent the lower bound, and successive values
10119 represent successive values of the type.
10121 For example, suppose we have the declaration:
10123 @smallexample @c ada
10124 type Small is range -7 .. -4;
10125 for Small'Size use 2;
10129 Although the default size of type @code{Small} is 4, the @code{Size}
10130 clause is accepted by GNAT and results in the following representation
10134 -7 is represented as 2#00#
10135 -6 is represented as 2#01#
10136 -5 is represented as 2#10#
10137 -4 is represented as 2#11#
10141 Biased representation is only used if the specified @code{Size} clause
10142 cannot be accepted in any other manner. These reduced sizes that force
10143 biased representation can be used for all discrete types except for
10144 enumeration types for which a representation clause is given.
10146 @node Value_Size and Object_Size Clauses
10147 @section Value_Size and Object_Size Clauses
10149 @findex Object_Size
10150 @cindex Size, of objects
10153 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10154 number of bits required to hold values of type @code{T}.
10155 Although this interpretation was allowed in Ada 83, it was not required,
10156 and this requirement in practice can cause some significant difficulties.
10157 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10158 However, in Ada 95 and Ada 2005,
10159 @code{Natural'Size} is
10160 typically 31. This means that code may change in behavior when moving
10161 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
10163 @smallexample @c ada
10164 type Rec is record;
10170 at 0 range 0 .. Natural'Size - 1;
10171 at 0 range Natural'Size .. 2 * Natural'Size - 1;
10176 In the above code, since the typical size of @code{Natural} objects
10177 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10178 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10179 there are cases where the fact that the object size can exceed the
10180 size of the type causes surprises.
10182 To help get around this problem GNAT provides two implementation
10183 defined attributes, @code{Value_Size} and @code{Object_Size}. When
10184 applied to a type, these attributes yield the size of the type
10185 (corresponding to the RM defined size attribute), and the size of
10186 objects of the type respectively.
10188 The @code{Object_Size} is used for determining the default size of
10189 objects and components. This size value can be referred to using the
10190 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
10191 the basis of the determination of the size. The backend is free to
10192 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10193 character might be stored in 32 bits on a machine with no efficient
10194 byte access instructions such as the Alpha.
10196 The default rules for the value of @code{Object_Size} for
10197 discrete types are as follows:
10201 The @code{Object_Size} for base subtypes reflect the natural hardware
10202 size in bits (run the compiler with @option{-gnatS} to find those values
10203 for numeric types). Enumeration types and fixed-point base subtypes have
10204 8, 16, 32 or 64 bits for this size, depending on the range of values
10208 The @code{Object_Size} of a subtype is the same as the
10209 @code{Object_Size} of
10210 the type from which it is obtained.
10213 The @code{Object_Size} of a derived base type is copied from the parent
10214 base type, and the @code{Object_Size} of a derived first subtype is copied
10215 from the parent first subtype.
10219 The @code{Value_Size} attribute
10220 is the (minimum) number of bits required to store a value
10222 This value is used to determine how tightly to pack
10223 records or arrays with components of this type, and also affects
10224 the semantics of unchecked conversion (unchecked conversions where
10225 the @code{Value_Size} values differ generate a warning, and are potentially
10228 The default rules for the value of @code{Value_Size} are as follows:
10232 The @code{Value_Size} for a base subtype is the minimum number of bits
10233 required to store all values of the type (including the sign bit
10234 only if negative values are possible).
10237 If a subtype statically matches the first subtype of a given type, then it has
10238 by default the same @code{Value_Size} as the first subtype. This is a
10239 consequence of RM 13.1(14) (``if two subtypes statically match,
10240 then their subtype-specific aspects are the same''.)
10243 All other subtypes have a @code{Value_Size} corresponding to the minimum
10244 number of bits required to store all values of the subtype. For
10245 dynamic bounds, it is assumed that the value can range down or up
10246 to the corresponding bound of the ancestor
10250 The RM defined attribute @code{Size} corresponds to the
10251 @code{Value_Size} attribute.
10253 The @code{Size} attribute may be defined for a first-named subtype. This sets
10254 the @code{Value_Size} of
10255 the first-named subtype to the given value, and the
10256 @code{Object_Size} of this first-named subtype to the given value padded up
10257 to an appropriate boundary. It is a consequence of the default rules
10258 above that this @code{Object_Size} will apply to all further subtypes. On the
10259 other hand, @code{Value_Size} is affected only for the first subtype, any
10260 dynamic subtypes obtained from it directly, and any statically matching
10261 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
10263 @code{Value_Size} and
10264 @code{Object_Size} may be explicitly set for any subtype using
10265 an attribute definition clause. Note that the use of these attributes
10266 can cause the RM 13.1(14) rule to be violated. If two access types
10267 reference aliased objects whose subtypes have differing @code{Object_Size}
10268 values as a result of explicit attribute definition clauses, then it
10269 is erroneous to convert from one access subtype to the other.
10271 At the implementation level, Esize stores the Object_Size and the
10272 RM_Size field stores the @code{Value_Size} (and hence the value of the
10273 @code{Size} attribute,
10274 which, as noted above, is equivalent to @code{Value_Size}).
10276 To get a feel for the difference, consider the following examples (note
10277 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10280 Object_Size Value_Size
10282 type x1 is range 0 .. 5; 8 3
10284 type x2 is range 0 .. 5;
10285 for x2'size use 12; 16 12
10287 subtype x3 is x2 range 0 .. 3; 16 2
10289 subtype x4 is x2'base range 0 .. 10; 8 4
10291 subtype x5 is x2 range 0 .. dynamic; 16 3*
10293 subtype x6 is x2'base range 0 .. dynamic; 8 3*
10298 Note: the entries marked ``3*'' are not actually specified by the Ada
10299 Reference Manual, but it seems in the spirit of the RM rules to allocate
10300 the minimum number of bits (here 3, given the range for @code{x2})
10301 known to be large enough to hold the given range of values.
10303 So far, so good, but GNAT has to obey the RM rules, so the question is
10304 under what conditions must the RM @code{Size} be used.
10305 The following is a list
10306 of the occasions on which the RM @code{Size} must be used:
10310 Component size for packed arrays or records
10313 Value of the attribute @code{Size} for a type
10316 Warning about sizes not matching for unchecked conversion
10320 For record types, the @code{Object_Size} is always a multiple of the
10321 alignment of the type (this is true for all types). In some cases the
10322 @code{Value_Size} can be smaller. Consider:
10332 On a typical 32-bit architecture, the X component will be four bytes, and
10333 require four-byte alignment, and the Y component will be one byte. In this
10334 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10335 required to store a value of this type, and for example, it is permissible
10336 to have a component of type R in an outer record whose component size is
10337 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10338 since it must be rounded up so that this value is a multiple of the
10339 alignment (4 bytes = 32 bits).
10342 For all other types, the @code{Object_Size}
10343 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10344 Only @code{Size} may be specified for such types.
10346 @node Component_Size Clauses
10347 @section Component_Size Clauses
10348 @cindex Component_Size Clause
10351 Normally, the value specified in a component size clause must be consistent
10352 with the subtype of the array component with regard to size and alignment.
10353 In other words, the value specified must be at least equal to the size
10354 of this subtype, and must be a multiple of the alignment value.
10356 In addition, component size clauses are allowed which cause the array
10357 to be packed, by specifying a smaller value. A first case is for
10358 component size values in the range 1 through 63. The value specified
10359 must not be smaller than the Size of the subtype. GNAT will accurately
10360 honor all packing requests in this range. For example, if we have:
10362 @smallexample @c ada
10363 type r is array (1 .. 8) of Natural;
10364 for r'Component_Size use 31;
10368 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10369 Of course access to the components of such an array is considerably
10370 less efficient than if the natural component size of 32 is used.
10371 A second case is when the subtype of the component is a record type
10372 padded because of its default alignment. For example, if we have:
10374 @smallexample @c ada
10381 type a is array (1 .. 8) of r;
10382 for a'Component_Size use 72;
10386 then the resulting array has a length of 72 bytes, instead of 96 bytes
10387 if the alignment of the record (4) was obeyed.
10389 Note that there is no point in giving both a component size clause
10390 and a pragma Pack for the same array type. if such duplicate
10391 clauses are given, the pragma Pack will be ignored.
10393 @node Bit_Order Clauses
10394 @section Bit_Order Clauses
10395 @cindex Bit_Order Clause
10396 @cindex bit ordering
10397 @cindex ordering, of bits
10400 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10401 attribute. The specification may either correspond to the default bit
10402 order for the target, in which case the specification has no effect and
10403 places no additional restrictions, or it may be for the non-standard
10404 setting (that is the opposite of the default).
10406 In the case where the non-standard value is specified, the effect is
10407 to renumber bits within each byte, but the ordering of bytes is not
10408 affected. There are certain
10409 restrictions placed on component clauses as follows:
10413 @item Components fitting within a single storage unit.
10415 These are unrestricted, and the effect is merely to renumber bits. For
10416 example if we are on a little-endian machine with @code{Low_Order_First}
10417 being the default, then the following two declarations have exactly
10420 @smallexample @c ada
10423 B : Integer range 1 .. 120;
10427 A at 0 range 0 .. 0;
10428 B at 0 range 1 .. 7;
10433 B : Integer range 1 .. 120;
10436 for R2'Bit_Order use High_Order_First;
10439 A at 0 range 7 .. 7;
10440 B at 0 range 0 .. 6;
10445 The useful application here is to write the second declaration with the
10446 @code{Bit_Order} attribute definition clause, and know that it will be treated
10447 the same, regardless of whether the target is little-endian or big-endian.
10449 @item Components occupying an integral number of bytes.
10451 These are components that exactly fit in two or more bytes. Such component
10452 declarations are allowed, but have no effect, since it is important to realize
10453 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10454 In particular, the following attempt at getting an endian-independent integer
10457 @smallexample @c ada
10462 for R2'Bit_Order use High_Order_First;
10465 A at 0 range 0 .. 31;
10470 This declaration will result in a little-endian integer on a
10471 little-endian machine, and a big-endian integer on a big-endian machine.
10472 If byte flipping is required for interoperability between big- and
10473 little-endian machines, this must be explicitly programmed. This capability
10474 is not provided by @code{Bit_Order}.
10476 @item Components that are positioned across byte boundaries
10478 but do not occupy an integral number of bytes. Given that bytes are not
10479 reordered, such fields would occupy a non-contiguous sequence of bits
10480 in memory, requiring non-trivial code to reassemble. They are for this
10481 reason not permitted, and any component clause specifying such a layout
10482 will be flagged as illegal by GNAT@.
10487 Since the misconception that Bit_Order automatically deals with all
10488 endian-related incompatibilities is a common one, the specification of
10489 a component field that is an integral number of bytes will always
10490 generate a warning. This warning may be suppressed using @code{pragma
10491 Warnings (Off)} if desired. The following section contains additional
10492 details regarding the issue of byte ordering.
10494 @node Effect of Bit_Order on Byte Ordering
10495 @section Effect of Bit_Order on Byte Ordering
10496 @cindex byte ordering
10497 @cindex ordering, of bytes
10500 In this section we will review the effect of the @code{Bit_Order} attribute
10501 definition clause on byte ordering. Briefly, it has no effect at all, but
10502 a detailed example will be helpful. Before giving this
10503 example, let us review the precise
10504 definition of the effect of defining @code{Bit_Order}. The effect of a
10505 non-standard bit order is described in section 15.5.3 of the Ada
10509 2 A bit ordering is a method of interpreting the meaning of
10510 the storage place attributes.
10514 To understand the precise definition of storage place attributes in
10515 this context, we visit section 13.5.1 of the manual:
10518 13 A record_representation_clause (without the mod_clause)
10519 specifies the layout. The storage place attributes (see 13.5.2)
10520 are taken from the values of the position, first_bit, and last_bit
10521 expressions after normalizing those values so that first_bit is
10522 less than Storage_Unit.
10526 The critical point here is that storage places are taken from
10527 the values after normalization, not before. So the @code{Bit_Order}
10528 interpretation applies to normalized values. The interpretation
10529 is described in the later part of the 15.5.3 paragraph:
10532 2 A bit ordering is a method of interpreting the meaning of
10533 the storage place attributes. High_Order_First (known in the
10534 vernacular as ``big endian'') means that the first bit of a
10535 storage element (bit 0) is the most significant bit (interpreting
10536 the sequence of bits that represent a component as an unsigned
10537 integer value). Low_Order_First (known in the vernacular as
10538 ``little endian'') means the opposite: the first bit is the
10543 Note that the numbering is with respect to the bits of a storage
10544 unit. In other words, the specification affects only the numbering
10545 of bits within a single storage unit.
10547 We can make the effect clearer by giving an example.
10549 Suppose that we have an external device which presents two bytes, the first
10550 byte presented, which is the first (low addressed byte) of the two byte
10551 record is called Master, and the second byte is called Slave.
10553 The left most (most significant bit is called Control for each byte, and
10554 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10555 (least significant) bit.
10557 On a big-endian machine, we can write the following representation clause
10559 @smallexample @c ada
10560 type Data is record
10561 Master_Control : Bit;
10569 Slave_Control : Bit;
10579 for Data use record
10580 Master_Control at 0 range 0 .. 0;
10581 Master_V1 at 0 range 1 .. 1;
10582 Master_V2 at 0 range 2 .. 2;
10583 Master_V3 at 0 range 3 .. 3;
10584 Master_V4 at 0 range 4 .. 4;
10585 Master_V5 at 0 range 5 .. 5;
10586 Master_V6 at 0 range 6 .. 6;
10587 Master_V7 at 0 range 7 .. 7;
10588 Slave_Control at 1 range 0 .. 0;
10589 Slave_V1 at 1 range 1 .. 1;
10590 Slave_V2 at 1 range 2 .. 2;
10591 Slave_V3 at 1 range 3 .. 3;
10592 Slave_V4 at 1 range 4 .. 4;
10593 Slave_V5 at 1 range 5 .. 5;
10594 Slave_V6 at 1 range 6 .. 6;
10595 Slave_V7 at 1 range 7 .. 7;
10600 Now if we move this to a little endian machine, then the bit ordering within
10601 the byte is backwards, so we have to rewrite the record rep clause as:
10603 @smallexample @c ada
10604 for Data use record
10605 Master_Control at 0 range 7 .. 7;
10606 Master_V1 at 0 range 6 .. 6;
10607 Master_V2 at 0 range 5 .. 5;
10608 Master_V3 at 0 range 4 .. 4;
10609 Master_V4 at 0 range 3 .. 3;
10610 Master_V5 at 0 range 2 .. 2;
10611 Master_V6 at 0 range 1 .. 1;
10612 Master_V7 at 0 range 0 .. 0;
10613 Slave_Control at 1 range 7 .. 7;
10614 Slave_V1 at 1 range 6 .. 6;
10615 Slave_V2 at 1 range 5 .. 5;
10616 Slave_V3 at 1 range 4 .. 4;
10617 Slave_V4 at 1 range 3 .. 3;
10618 Slave_V5 at 1 range 2 .. 2;
10619 Slave_V6 at 1 range 1 .. 1;
10620 Slave_V7 at 1 range 0 .. 0;
10625 It is a nuisance to have to rewrite the clause, especially if
10626 the code has to be maintained on both machines. However,
10627 this is a case that we can handle with the
10628 @code{Bit_Order} attribute if it is implemented.
10629 Note that the implementation is not required on byte addressed
10630 machines, but it is indeed implemented in GNAT.
10631 This means that we can simply use the
10632 first record clause, together with the declaration
10634 @smallexample @c ada
10635 for Data'Bit_Order use High_Order_First;
10639 and the effect is what is desired, namely the layout is exactly the same,
10640 independent of whether the code is compiled on a big-endian or little-endian
10643 The important point to understand is that byte ordering is not affected.
10644 A @code{Bit_Order} attribute definition never affects which byte a field
10645 ends up in, only where it ends up in that byte.
10646 To make this clear, let us rewrite the record rep clause of the previous
10649 @smallexample @c ada
10650 for Data'Bit_Order use High_Order_First;
10651 for Data use record
10652 Master_Control at 0 range 0 .. 0;
10653 Master_V1 at 0 range 1 .. 1;
10654 Master_V2 at 0 range 2 .. 2;
10655 Master_V3 at 0 range 3 .. 3;
10656 Master_V4 at 0 range 4 .. 4;
10657 Master_V5 at 0 range 5 .. 5;
10658 Master_V6 at 0 range 6 .. 6;
10659 Master_V7 at 0 range 7 .. 7;
10660 Slave_Control at 0 range 8 .. 8;
10661 Slave_V1 at 0 range 9 .. 9;
10662 Slave_V2 at 0 range 10 .. 10;
10663 Slave_V3 at 0 range 11 .. 11;
10664 Slave_V4 at 0 range 12 .. 12;
10665 Slave_V5 at 0 range 13 .. 13;
10666 Slave_V6 at 0 range 14 .. 14;
10667 Slave_V7 at 0 range 15 .. 15;
10672 This is exactly equivalent to saying (a repeat of the first example):
10674 @smallexample @c ada
10675 for Data'Bit_Order use High_Order_First;
10676 for Data use record
10677 Master_Control at 0 range 0 .. 0;
10678 Master_V1 at 0 range 1 .. 1;
10679 Master_V2 at 0 range 2 .. 2;
10680 Master_V3 at 0 range 3 .. 3;
10681 Master_V4 at 0 range 4 .. 4;
10682 Master_V5 at 0 range 5 .. 5;
10683 Master_V6 at 0 range 6 .. 6;
10684 Master_V7 at 0 range 7 .. 7;
10685 Slave_Control at 1 range 0 .. 0;
10686 Slave_V1 at 1 range 1 .. 1;
10687 Slave_V2 at 1 range 2 .. 2;
10688 Slave_V3 at 1 range 3 .. 3;
10689 Slave_V4 at 1 range 4 .. 4;
10690 Slave_V5 at 1 range 5 .. 5;
10691 Slave_V6 at 1 range 6 .. 6;
10692 Slave_V7 at 1 range 7 .. 7;
10697 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10698 field. The storage place attributes are obtained by normalizing the
10699 values given so that the @code{First_Bit} value is less than 8. After
10700 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10701 we specified in the other case.
10703 Now one might expect that the @code{Bit_Order} attribute might affect
10704 bit numbering within the entire record component (two bytes in this
10705 case, thus affecting which byte fields end up in), but that is not
10706 the way this feature is defined, it only affects numbering of bits,
10707 not which byte they end up in.
10709 Consequently it never makes sense to specify a starting bit number
10710 greater than 7 (for a byte addressable field) if an attribute
10711 definition for @code{Bit_Order} has been given, and indeed it
10712 may be actively confusing to specify such a value, so the compiler
10713 generates a warning for such usage.
10715 If you do need to control byte ordering then appropriate conditional
10716 values must be used. If in our example, the slave byte came first on
10717 some machines we might write:
10719 @smallexample @c ada
10720 Master_Byte_First constant Boolean := @dots{};
10722 Master_Byte : constant Natural :=
10723 1 - Boolean'Pos (Master_Byte_First);
10724 Slave_Byte : constant Natural :=
10725 Boolean'Pos (Master_Byte_First);
10727 for Data'Bit_Order use High_Order_First;
10728 for Data use record
10729 Master_Control at Master_Byte range 0 .. 0;
10730 Master_V1 at Master_Byte range 1 .. 1;
10731 Master_V2 at Master_Byte range 2 .. 2;
10732 Master_V3 at Master_Byte range 3 .. 3;
10733 Master_V4 at Master_Byte range 4 .. 4;
10734 Master_V5 at Master_Byte range 5 .. 5;
10735 Master_V6 at Master_Byte range 6 .. 6;
10736 Master_V7 at Master_Byte range 7 .. 7;
10737 Slave_Control at Slave_Byte range 0 .. 0;
10738 Slave_V1 at Slave_Byte range 1 .. 1;
10739 Slave_V2 at Slave_Byte range 2 .. 2;
10740 Slave_V3 at Slave_Byte range 3 .. 3;
10741 Slave_V4 at Slave_Byte range 4 .. 4;
10742 Slave_V5 at Slave_Byte range 5 .. 5;
10743 Slave_V6 at Slave_Byte range 6 .. 6;
10744 Slave_V7 at Slave_Byte range 7 .. 7;
10749 Now to switch between machines, all that is necessary is
10750 to set the boolean constant @code{Master_Byte_First} in
10751 an appropriate manner.
10753 @node Pragma Pack for Arrays
10754 @section Pragma Pack for Arrays
10755 @cindex Pragma Pack (for arrays)
10758 Pragma @code{Pack} applied to an array has no effect unless the component type
10759 is packable. For a component type to be packable, it must be one of the
10766 Any type whose size is specified with a size clause
10768 Any packed array type with a static size
10770 Any record type padded because of its default alignment
10774 For all these cases, if the component subtype size is in the range
10775 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10776 component size were specified giving the component subtype size.
10777 For example if we have:
10779 @smallexample @c ada
10780 type r is range 0 .. 17;
10782 type ar is array (1 .. 8) of r;
10787 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10788 and the size of the array @code{ar} will be exactly 40 bits.
10790 Note that in some cases this rather fierce approach to packing can produce
10791 unexpected effects. For example, in Ada 95 and Ada 2005,
10792 subtype @code{Natural} typically has a size of 31, meaning that if you
10793 pack an array of @code{Natural}, you get 31-bit
10794 close packing, which saves a few bits, but results in far less efficient
10795 access. Since many other Ada compilers will ignore such a packing request,
10796 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10797 might not be what is intended. You can easily remove this warning by
10798 using an explicit @code{Component_Size} setting instead, which never generates
10799 a warning, since the intention of the programmer is clear in this case.
10801 GNAT treats packed arrays in one of two ways. If the size of the array is
10802 known at compile time and is less than 64 bits, then internally the array
10803 is represented as a single modular type, of exactly the appropriate number
10804 of bits. If the length is greater than 63 bits, or is not known at compile
10805 time, then the packed array is represented as an array of bytes, and the
10806 length is always a multiple of 8 bits.
10808 Note that to represent a packed array as a modular type, the alignment must
10809 be suitable for the modular type involved. For example, on typical machines
10810 a 32-bit packed array will be represented by a 32-bit modular integer with
10811 an alignment of four bytes. If you explicitly override the default alignment
10812 with an alignment clause that is too small, the modular representation
10813 cannot be used. For example, consider the following set of declarations:
10815 @smallexample @c ada
10816 type R is range 1 .. 3;
10817 type S is array (1 .. 31) of R;
10818 for S'Component_Size use 2;
10820 for S'Alignment use 1;
10824 If the alignment clause were not present, then a 62-bit modular
10825 representation would be chosen (typically with an alignment of 4 or 8
10826 bytes depending on the target). But the default alignment is overridden
10827 with the explicit alignment clause. This means that the modular
10828 representation cannot be used, and instead the array of bytes
10829 representation must be used, meaning that the length must be a multiple
10830 of 8. Thus the above set of declarations will result in a diagnostic
10831 rejecting the size clause and noting that the minimum size allowed is 64.
10833 @cindex Pragma Pack (for type Natural)
10834 @cindex Pragma Pack warning
10836 One special case that is worth noting occurs when the base type of the
10837 component size is 8/16/32 and the subtype is one bit less. Notably this
10838 occurs with subtype @code{Natural}. Consider:
10840 @smallexample @c ada
10841 type Arr is array (1 .. 32) of Natural;
10846 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10847 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10848 Ada 83 compilers did not attempt 31 bit packing.
10850 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
10851 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
10852 substantial unintended performance penalty when porting legacy Ada 83 code.
10853 To help prevent this, GNAT generates a warning in such cases. If you really
10854 want 31 bit packing in a case like this, you can set the component size
10857 @smallexample @c ada
10858 type Arr is array (1 .. 32) of Natural;
10859 for Arr'Component_Size use 31;
10863 Here 31-bit packing is achieved as required, and no warning is generated,
10864 since in this case the programmer intention is clear.
10866 @node Pragma Pack for Records
10867 @section Pragma Pack for Records
10868 @cindex Pragma Pack (for records)
10871 Pragma @code{Pack} applied to a record will pack the components to reduce
10872 wasted space from alignment gaps and by reducing the amount of space
10873 taken by components. We distinguish between @emph{packable} components and
10874 @emph{non-packable} components.
10875 Components of the following types are considered packable:
10878 All primitive types are packable.
10881 Small packed arrays, whose size does not exceed 64 bits, and where the
10882 size is statically known at compile time, are represented internally
10883 as modular integers, and so they are also packable.
10888 All packable components occupy the exact number of bits corresponding to
10889 their @code{Size} value, and are packed with no padding bits, i.e.@: they
10890 can start on an arbitrary bit boundary.
10892 All other types are non-packable, they occupy an integral number of
10894 are placed at a boundary corresponding to their alignment requirements.
10896 For example, consider the record
10898 @smallexample @c ada
10899 type Rb1 is array (1 .. 13) of Boolean;
10902 type Rb2 is array (1 .. 65) of Boolean;
10917 The representation for the record x2 is as follows:
10919 @smallexample @c ada
10920 for x2'Size use 224;
10922 l1 at 0 range 0 .. 0;
10923 l2 at 0 range 1 .. 64;
10924 l3 at 12 range 0 .. 31;
10925 l4 at 16 range 0 .. 0;
10926 l5 at 16 range 1 .. 13;
10927 l6 at 18 range 0 .. 71;
10932 Studying this example, we see that the packable fields @code{l1}
10934 of length equal to their sizes, and placed at specific bit boundaries (and
10935 not byte boundaries) to
10936 eliminate padding. But @code{l3} is of a non-packable float type, so
10937 it is on the next appropriate alignment boundary.
10939 The next two fields are fully packable, so @code{l4} and @code{l5} are
10940 minimally packed with no gaps. However, type @code{Rb2} is a packed
10941 array that is longer than 64 bits, so it is itself non-packable. Thus
10942 the @code{l6} field is aligned to the next byte boundary, and takes an
10943 integral number of bytes, i.e.@: 72 bits.
10945 @node Record Representation Clauses
10946 @section Record Representation Clauses
10947 @cindex Record Representation Clause
10950 Record representation clauses may be given for all record types, including
10951 types obtained by record extension. Component clauses are allowed for any
10952 static component. The restrictions on component clauses depend on the type
10955 @cindex Component Clause
10956 For all components of an elementary type, the only restriction on component
10957 clauses is that the size must be at least the 'Size value of the type
10958 (actually the Value_Size). There are no restrictions due to alignment,
10959 and such components may freely cross storage boundaries.
10961 Packed arrays with a size up to and including 64 bits are represented
10962 internally using a modular type with the appropriate number of bits, and
10963 thus the same lack of restriction applies. For example, if you declare:
10965 @smallexample @c ada
10966 type R is array (1 .. 49) of Boolean;
10972 then a component clause for a component of type R may start on any
10973 specified bit boundary, and may specify a value of 49 bits or greater.
10975 For packed bit arrays that are longer than 64 bits, there are two
10976 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
10977 including the important case of single bits or boolean values, then
10978 there are no limitations on placement of such components, and they
10979 may start and end at arbitrary bit boundaries.
10981 If the component size is not a power of 2 (e.g.@: 3 or 5), then
10982 an array of this type longer than 64 bits must always be placed on
10983 on a storage unit (byte) boundary and occupy an integral number
10984 of storage units (bytes). Any component clause that does not
10985 meet this requirement will be rejected.
10987 Any aliased component, or component of an aliased type, must
10988 have its normal alignment and size. A component clause that
10989 does not meet this requirement will be rejected.
10991 The tag field of a tagged type always occupies an address sized field at
10992 the start of the record. No component clause may attempt to overlay this
10993 tag. When a tagged type appears as a component, the tag field must have
10996 In the case of a record extension T1, of a type T, no component clause applied
10997 to the type T1 can specify a storage location that would overlap the first
10998 T'Size bytes of the record.
11000 For all other component types, including non-bit-packed arrays,
11001 the component can be placed at an arbitrary bit boundary,
11002 so for example, the following is permitted:
11004 @smallexample @c ada
11005 type R is array (1 .. 10) of Boolean;
11014 G at 0 range 0 .. 0;
11015 H at 0 range 1 .. 1;
11016 L at 0 range 2 .. 81;
11017 R at 0 range 82 .. 161;
11022 Note: the above rules apply to recent releases of GNAT 5.
11023 In GNAT 3, there are more severe restrictions on larger components.
11024 For non-primitive types, including packed arrays with a size greater than
11025 64 bits, component clauses must respect the alignment requirement of the
11026 type, in particular, always starting on a byte boundary, and the length
11027 must be a multiple of the storage unit.
11029 @node Enumeration Clauses
11030 @section Enumeration Clauses
11032 The only restriction on enumeration clauses is that the range of values
11033 must be representable. For the signed case, if one or more of the
11034 representation values are negative, all values must be in the range:
11036 @smallexample @c ada
11037 System.Min_Int .. System.Max_Int
11041 For the unsigned case, where all values are nonnegative, the values must
11044 @smallexample @c ada
11045 0 .. System.Max_Binary_Modulus;
11049 A @emph{confirming} representation clause is one in which the values range
11050 from 0 in sequence, i.e.@: a clause that confirms the default representation
11051 for an enumeration type.
11052 Such a confirming representation
11053 is permitted by these rules, and is specially recognized by the compiler so
11054 that no extra overhead results from the use of such a clause.
11056 If an array has an index type which is an enumeration type to which an
11057 enumeration clause has been applied, then the array is stored in a compact
11058 manner. Consider the declarations:
11060 @smallexample @c ada
11061 type r is (A, B, C);
11062 for r use (A => 1, B => 5, C => 10);
11063 type t is array (r) of Character;
11067 The array type t corresponds to a vector with exactly three elements and
11068 has a default size equal to @code{3*Character'Size}. This ensures efficient
11069 use of space, but means that accesses to elements of the array will incur
11070 the overhead of converting representation values to the corresponding
11071 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11073 @node Address Clauses
11074 @section Address Clauses
11075 @cindex Address Clause
11077 The reference manual allows a general restriction on representation clauses,
11078 as found in RM 13.1(22):
11081 An implementation need not support representation
11082 items containing nonstatic expressions, except that
11083 an implementation should support a representation item
11084 for a given entity if each nonstatic expression in the
11085 representation item is a name that statically denotes
11086 a constant declared before the entity.
11090 In practice this is applicable only to address clauses, since this is the
11091 only case in which a non-static expression is permitted by the syntax. As
11092 the AARM notes in sections 13.1 (22.a-22.h):
11095 22.a Reason: This is to avoid the following sort of thing:
11097 22.b X : Integer := F(@dots{});
11098 Y : Address := G(@dots{});
11099 for X'Address use Y;
11101 22.c In the above, we have to evaluate the
11102 initialization expression for X before we
11103 know where to put the result. This seems
11104 like an unreasonable implementation burden.
11106 22.d The above code should instead be written
11109 22.e Y : constant Address := G(@dots{});
11110 X : Integer := F(@dots{});
11111 for X'Address use Y;
11113 22.f This allows the expression ``Y'' to be safely
11114 evaluated before X is created.
11116 22.g The constant could be a formal parameter of mode in.
11118 22.h An implementation can support other nonstatic
11119 expressions if it wants to. Expressions of type
11120 Address are hardly ever static, but their value
11121 might be known at compile time anyway in many
11126 GNAT does indeed permit many additional cases of non-static expressions. In
11127 particular, if the type involved is elementary there are no restrictions
11128 (since in this case, holding a temporary copy of the initialization value,
11129 if one is present, is inexpensive). In addition, if there is no implicit or
11130 explicit initialization, then there are no restrictions. GNAT will reject
11131 only the case where all three of these conditions hold:
11136 The type of the item is non-elementary (e.g.@: a record or array).
11139 There is explicit or implicit initialization required for the object.
11140 Note that access values are always implicitly initialized, and also
11141 in GNAT, certain bit-packed arrays (those having a dynamic length or
11142 a length greater than 64) will also be implicitly initialized to zero.
11145 The address value is non-static. Here GNAT is more permissive than the
11146 RM, and allows the address value to be the address of a previously declared
11147 stand-alone variable, as long as it does not itself have an address clause.
11149 @smallexample @c ada
11150 Anchor : Some_Initialized_Type;
11151 Overlay : Some_Initialized_Type;
11152 for Overlay'Address use Anchor'Address;
11156 However, the prefix of the address clause cannot be an array component, or
11157 a component of a discriminated record.
11162 As noted above in section 22.h, address values are typically non-static. In
11163 particular the To_Address function, even if applied to a literal value, is
11164 a non-static function call. To avoid this minor annoyance, GNAT provides
11165 the implementation defined attribute 'To_Address. The following two
11166 expressions have identical values:
11170 @smallexample @c ada
11171 To_Address (16#1234_0000#)
11172 System'To_Address (16#1234_0000#);
11176 except that the second form is considered to be a static expression, and
11177 thus when used as an address clause value is always permitted.
11180 Additionally, GNAT treats as static an address clause that is an
11181 unchecked_conversion of a static integer value. This simplifies the porting
11182 of legacy code, and provides a portable equivalent to the GNAT attribute
11185 Another issue with address clauses is the interaction with alignment
11186 requirements. When an address clause is given for an object, the address
11187 value must be consistent with the alignment of the object (which is usually
11188 the same as the alignment of the type of the object). If an address clause
11189 is given that specifies an inappropriately aligned address value, then the
11190 program execution is erroneous.
11192 Since this source of erroneous behavior can have unfortunate effects, GNAT
11193 checks (at compile time if possible, generating a warning, or at execution
11194 time with a run-time check) that the alignment is appropriate. If the
11195 run-time check fails, then @code{Program_Error} is raised. This run-time
11196 check is suppressed if range checks are suppressed, or if the special GNAT
11197 check Alignment_Check is suppressed, or if
11198 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11200 Finally, GNAT does not permit overlaying of objects of controlled types or
11201 composite types containing a controlled component. In most cases, the compiler
11202 can detect an attempt at such overlays and will generate a warning at compile
11203 time and a Program_Error exception at run time.
11206 An address clause cannot be given for an exported object. More
11207 understandably the real restriction is that objects with an address
11208 clause cannot be exported. This is because such variables are not
11209 defined by the Ada program, so there is no external object to export.
11212 It is permissible to give an address clause and a pragma Import for the
11213 same object. In this case, the variable is not really defined by the
11214 Ada program, so there is no external symbol to be linked. The link name
11215 and the external name are ignored in this case. The reason that we allow this
11216 combination is that it provides a useful idiom to avoid unwanted
11217 initializations on objects with address clauses.
11219 When an address clause is given for an object that has implicit or
11220 explicit initialization, then by default initialization takes place. This
11221 means that the effect of the object declaration is to overwrite the
11222 memory at the specified address. This is almost always not what the
11223 programmer wants, so GNAT will output a warning:
11233 for Ext'Address use System'To_Address (16#1234_1234#);
11235 >>> warning: implicit initialization of "Ext" may
11236 modify overlaid storage
11237 >>> warning: use pragma Import for "Ext" to suppress
11238 initialization (RM B(24))
11244 As indicated by the warning message, the solution is to use a (dummy) pragma
11245 Import to suppress this initialization. The pragma tell the compiler that the
11246 object is declared and initialized elsewhere. The following package compiles
11247 without warnings (and the initialization is suppressed):
11249 @smallexample @c ada
11257 for Ext'Address use System'To_Address (16#1234_1234#);
11258 pragma Import (Ada, Ext);
11263 A final issue with address clauses involves their use for overlaying
11264 variables, as in the following example:
11265 @cindex Overlaying of objects
11267 @smallexample @c ada
11270 for B'Address use A'Address;
11274 or alternatively, using the form recommended by the RM:
11276 @smallexample @c ada
11278 Addr : constant Address := A'Address;
11280 for B'Address use Addr;
11284 In both of these cases, @code{A}
11285 and @code{B} become aliased to one another via the
11286 address clause. This use of address clauses to overlay
11287 variables, achieving an effect similar to unchecked
11288 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11289 the effect is implementation defined. Furthermore, the
11290 Ada RM specifically recommends that in a situation
11291 like this, @code{B} should be subject to the following
11292 implementation advice (RM 13.3(19)):
11295 19 If the Address of an object is specified, or it is imported
11296 or exported, then the implementation should not perform
11297 optimizations based on assumptions of no aliases.
11301 GNAT follows this recommendation, and goes further by also applying
11302 this recommendation to the overlaid variable (@code{A}
11303 in the above example) in this case. This means that the overlay
11304 works "as expected", in that a modification to one of the variables
11305 will affect the value of the other.
11307 @node Effect of Convention on Representation
11308 @section Effect of Convention on Representation
11309 @cindex Convention, effect on representation
11312 Normally the specification of a foreign language convention for a type or
11313 an object has no effect on the chosen representation. In particular, the
11314 representation chosen for data in GNAT generally meets the standard system
11315 conventions, and for example records are laid out in a manner that is
11316 consistent with C@. This means that specifying convention C (for example)
11319 There are four exceptions to this general rule:
11323 @item Convention Fortran and array subtypes
11324 If pragma Convention Fortran is specified for an array subtype, then in
11325 accordance with the implementation advice in section 3.6.2(11) of the
11326 Ada Reference Manual, the array will be stored in a Fortran-compatible
11327 column-major manner, instead of the normal default row-major order.
11329 @item Convention C and enumeration types
11330 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11331 to accommodate all values of the type. For example, for the enumeration
11334 @smallexample @c ada
11335 type Color is (Red, Green, Blue);
11339 8 bits is sufficient to store all values of the type, so by default, objects
11340 of type @code{Color} will be represented using 8 bits. However, normal C
11341 convention is to use 32 bits for all enum values in C, since enum values
11342 are essentially of type int. If pragma @code{Convention C} is specified for an
11343 Ada enumeration type, then the size is modified as necessary (usually to
11344 32 bits) to be consistent with the C convention for enum values.
11346 Note that this treatment applies only to types. If Convention C is given for
11347 an enumeration object, where the enumeration type is not Convention C, then
11348 Object_Size bits are allocated. For example, for a normal enumeration type,
11349 with less than 256 elements, only 8 bits will be allocated for the object.
11350 Since this may be a surprise in terms of what C expects, GNAT will issue a
11351 warning in this situation. The warning can be suppressed by giving an explicit
11352 size clause specifying the desired size.
11354 @item Convention C/Fortran and Boolean types
11355 In C, the usual convention for boolean values, that is values used for
11356 conditions, is that zero represents false, and nonzero values represent
11357 true. In Ada, the normal convention is that two specific values, typically
11358 0/1, are used to represent false/true respectively.
11360 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11361 value represents true).
11363 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11364 C or Fortran convention for a derived Boolean, as in the following example:
11366 @smallexample @c ada
11367 type C_Switch is new Boolean;
11368 pragma Convention (C, C_Switch);
11372 then the GNAT generated code will treat any nonzero value as true. For truth
11373 values generated by GNAT, the conventional value 1 will be used for True, but
11374 when one of these values is read, any nonzero value is treated as True.
11376 @item Access types on OpenVMS
11377 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11378 arrays) are 64-bits long. An exception to this rule is for the case of
11379 C-convention access types where there is no explicit size clause present (or
11380 inherited for derived types). In this case, GNAT chooses to make these
11381 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11382 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11386 @node Determining the Representations chosen by GNAT
11387 @section Determining the Representations chosen by GNAT
11388 @cindex Representation, determination of
11389 @cindex @option{-gnatR} switch
11392 Although the descriptions in this section are intended to be complete, it is
11393 often easier to simply experiment to see what GNAT accepts and what the
11394 effect is on the layout of types and objects.
11396 As required by the Ada RM, if a representation clause is not accepted, then
11397 it must be rejected as illegal by the compiler. However, when a
11398 representation clause or pragma is accepted, there can still be questions
11399 of what the compiler actually does. For example, if a partial record
11400 representation clause specifies the location of some components and not
11401 others, then where are the non-specified components placed? Or if pragma
11402 @code{Pack} is used on a record, then exactly where are the resulting
11403 fields placed? The section on pragma @code{Pack} in this chapter can be
11404 used to answer the second question, but it is often easier to just see
11405 what the compiler does.
11407 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
11408 with this option, then the compiler will output information on the actual
11409 representations chosen, in a format similar to source representation
11410 clauses. For example, if we compile the package:
11412 @smallexample @c ada
11414 type r (x : boolean) is tagged record
11416 when True => S : String (1 .. 100);
11417 when False => null;
11421 type r2 is new r (false) with record
11426 y2 at 16 range 0 .. 31;
11433 type x1 is array (1 .. 10) of x;
11434 for x1'component_size use 11;
11436 type ia is access integer;
11438 type Rb1 is array (1 .. 13) of Boolean;
11441 type Rb2 is array (1 .. 65) of Boolean;
11457 using the switch @option{-gnatR} we obtain the following output:
11460 Representation information for unit q
11461 -------------------------------------
11464 for r'Alignment use 4;
11466 x at 4 range 0 .. 7;
11467 _tag at 0 range 0 .. 31;
11468 s at 5 range 0 .. 799;
11471 for r2'Size use 160;
11472 for r2'Alignment use 4;
11474 x at 4 range 0 .. 7;
11475 _tag at 0 range 0 .. 31;
11476 _parent at 0 range 0 .. 63;
11477 y2 at 16 range 0 .. 31;
11481 for x'Alignment use 1;
11483 y at 0 range 0 .. 7;
11486 for x1'Size use 112;
11487 for x1'Alignment use 1;
11488 for x1'Component_Size use 11;
11490 for rb1'Size use 13;
11491 for rb1'Alignment use 2;
11492 for rb1'Component_Size use 1;
11494 for rb2'Size use 72;
11495 for rb2'Alignment use 1;
11496 for rb2'Component_Size use 1;
11498 for x2'Size use 224;
11499 for x2'Alignment use 4;
11501 l1 at 0 range 0 .. 0;
11502 l2 at 0 range 1 .. 64;
11503 l3 at 12 range 0 .. 31;
11504 l4 at 16 range 0 .. 0;
11505 l5 at 16 range 1 .. 13;
11506 l6 at 18 range 0 .. 71;
11511 The Size values are actually the Object_Size, i.e.@: the default size that
11512 will be allocated for objects of the type.
11513 The ?? size for type r indicates that we have a variant record, and the
11514 actual size of objects will depend on the discriminant value.
11516 The Alignment values show the actual alignment chosen by the compiler
11517 for each record or array type.
11519 The record representation clause for type r shows where all fields
11520 are placed, including the compiler generated tag field (whose location
11521 cannot be controlled by the programmer).
11523 The record representation clause for the type extension r2 shows all the
11524 fields present, including the parent field, which is a copy of the fields
11525 of the parent type of r2, i.e.@: r1.
11527 The component size and size clauses for types rb1 and rb2 show
11528 the exact effect of pragma @code{Pack} on these arrays, and the record
11529 representation clause for type x2 shows how pragma @code{Pack} affects
11532 In some cases, it may be useful to cut and paste the representation clauses
11533 generated by the compiler into the original source to fix and guarantee
11534 the actual representation to be used.
11536 @node Standard Library Routines
11537 @chapter Standard Library Routines
11540 The Ada Reference Manual contains in Annex A a full description of an
11541 extensive set of standard library routines that can be used in any Ada
11542 program, and which must be provided by all Ada compilers. They are
11543 analogous to the standard C library used by C programs.
11545 GNAT implements all of the facilities described in annex A, and for most
11546 purposes the description in the Ada Reference Manual, or appropriate Ada
11547 text book, will be sufficient for making use of these facilities.
11549 In the case of the input-output facilities,
11550 @xref{The Implementation of Standard I/O},
11551 gives details on exactly how GNAT interfaces to the
11552 file system. For the remaining packages, the Ada Reference Manual
11553 should be sufficient. The following is a list of the packages included,
11554 together with a brief description of the functionality that is provided.
11556 For completeness, references are included to other predefined library
11557 routines defined in other sections of the Ada Reference Manual (these are
11558 cross-indexed from Annex A).
11562 This is a parent package for all the standard library packages. It is
11563 usually included implicitly in your program, and itself contains no
11564 useful data or routines.
11566 @item Ada.Calendar (9.6)
11567 @code{Calendar} provides time of day access, and routines for
11568 manipulating times and durations.
11570 @item Ada.Characters (A.3.1)
11571 This is a dummy parent package that contains no useful entities
11573 @item Ada.Characters.Handling (A.3.2)
11574 This package provides some basic character handling capabilities,
11575 including classification functions for classes of characters (e.g.@: test
11576 for letters, or digits).
11578 @item Ada.Characters.Latin_1 (A.3.3)
11579 This package includes a complete set of definitions of the characters
11580 that appear in type CHARACTER@. It is useful for writing programs that
11581 will run in international environments. For example, if you want an
11582 upper case E with an acute accent in a string, it is often better to use
11583 the definition of @code{UC_E_Acute} in this package. Then your program
11584 will print in an understandable manner even if your environment does not
11585 support these extended characters.
11587 @item Ada.Command_Line (A.15)
11588 This package provides access to the command line parameters and the name
11589 of the current program (analogous to the use of @code{argc} and @code{argv}
11590 in C), and also allows the exit status for the program to be set in a
11591 system-independent manner.
11593 @item Ada.Decimal (F.2)
11594 This package provides constants describing the range of decimal numbers
11595 implemented, and also a decimal divide routine (analogous to the COBOL
11596 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11598 @item Ada.Direct_IO (A.8.4)
11599 This package provides input-output using a model of a set of records of
11600 fixed-length, containing an arbitrary definite Ada type, indexed by an
11601 integer record number.
11603 @item Ada.Dynamic_Priorities (D.5)
11604 This package allows the priorities of a task to be adjusted dynamically
11605 as the task is running.
11607 @item Ada.Exceptions (11.4.1)
11608 This package provides additional information on exceptions, and also
11609 contains facilities for treating exceptions as data objects, and raising
11610 exceptions with associated messages.
11612 @item Ada.Finalization (7.6)
11613 This package contains the declarations and subprograms to support the
11614 use of controlled types, providing for automatic initialization and
11615 finalization (analogous to the constructors and destructors of C++)
11617 @item Ada.Interrupts (C.3.2)
11618 This package provides facilities for interfacing to interrupts, which
11619 includes the set of signals or conditions that can be raised and
11620 recognized as interrupts.
11622 @item Ada.Interrupts.Names (C.3.2)
11623 This package provides the set of interrupt names (actually signal
11624 or condition names) that can be handled by GNAT@.
11626 @item Ada.IO_Exceptions (A.13)
11627 This package defines the set of exceptions that can be raised by use of
11628 the standard IO packages.
11631 This package contains some standard constants and exceptions used
11632 throughout the numerics packages. Note that the constants pi and e are
11633 defined here, and it is better to use these definitions than rolling
11636 @item Ada.Numerics.Complex_Elementary_Functions
11637 Provides the implementation of standard elementary functions (such as
11638 log and trigonometric functions) operating on complex numbers using the
11639 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11640 created by the package @code{Numerics.Complex_Types}.
11642 @item Ada.Numerics.Complex_Types
11643 This is a predefined instantiation of
11644 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11645 build the type @code{Complex} and @code{Imaginary}.
11647 @item Ada.Numerics.Discrete_Random
11648 This package provides a random number generator suitable for generating
11649 random integer values from a specified range.
11651 @item Ada.Numerics.Float_Random
11652 This package provides a random number generator suitable for generating
11653 uniformly distributed floating point values.
11655 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11656 This is a generic version of the package that provides the
11657 implementation of standard elementary functions (such as log and
11658 trigonometric functions) for an arbitrary complex type.
11660 The following predefined instantiations of this package are provided:
11664 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11666 @code{Ada.Numerics.Complex_Elementary_Functions}
11668 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
11671 @item Ada.Numerics.Generic_Complex_Types
11672 This is a generic package that allows the creation of complex types,
11673 with associated complex arithmetic operations.
11675 The following predefined instantiations of this package exist
11678 @code{Ada.Numerics.Short_Complex_Complex_Types}
11680 @code{Ada.Numerics.Complex_Complex_Types}
11682 @code{Ada.Numerics.Long_Complex_Complex_Types}
11685 @item Ada.Numerics.Generic_Elementary_Functions
11686 This is a generic package that provides the implementation of standard
11687 elementary functions (such as log an trigonometric functions) for an
11688 arbitrary float type.
11690 The following predefined instantiations of this package exist
11694 @code{Ada.Numerics.Short_Elementary_Functions}
11696 @code{Ada.Numerics.Elementary_Functions}
11698 @code{Ada.Numerics.Long_Elementary_Functions}
11701 @item Ada.Real_Time (D.8)
11702 This package provides facilities similar to those of @code{Calendar}, but
11703 operating with a finer clock suitable for real time control. Note that
11704 annex D requires that there be no backward clock jumps, and GNAT generally
11705 guarantees this behavior, but of course if the external clock on which
11706 the GNAT runtime depends is deliberately reset by some external event,
11707 then such a backward jump may occur.
11709 @item Ada.Sequential_IO (A.8.1)
11710 This package provides input-output facilities for sequential files,
11711 which can contain a sequence of values of a single type, which can be
11712 any Ada type, including indefinite (unconstrained) types.
11714 @item Ada.Storage_IO (A.9)
11715 This package provides a facility for mapping arbitrary Ada types to and
11716 from a storage buffer. It is primarily intended for the creation of new
11719 @item Ada.Streams (13.13.1)
11720 This is a generic package that provides the basic support for the
11721 concept of streams as used by the stream attributes (@code{Input},
11722 @code{Output}, @code{Read} and @code{Write}).
11724 @item Ada.Streams.Stream_IO (A.12.1)
11725 This package is a specialization of the type @code{Streams} defined in
11726 package @code{Streams} together with a set of operations providing
11727 Stream_IO capability. The Stream_IO model permits both random and
11728 sequential access to a file which can contain an arbitrary set of values
11729 of one or more Ada types.
11731 @item Ada.Strings (A.4.1)
11732 This package provides some basic constants used by the string handling
11735 @item Ada.Strings.Bounded (A.4.4)
11736 This package provides facilities for handling variable length
11737 strings. The bounded model requires a maximum length. It is thus
11738 somewhat more limited than the unbounded model, but avoids the use of
11739 dynamic allocation or finalization.
11741 @item Ada.Strings.Fixed (A.4.3)
11742 This package provides facilities for handling fixed length strings.
11744 @item Ada.Strings.Maps (A.4.2)
11745 This package provides facilities for handling character mappings and
11746 arbitrarily defined subsets of characters. For instance it is useful in
11747 defining specialized translation tables.
11749 @item Ada.Strings.Maps.Constants (A.4.6)
11750 This package provides a standard set of predefined mappings and
11751 predefined character sets. For example, the standard upper to lower case
11752 conversion table is found in this package. Note that upper to lower case
11753 conversion is non-trivial if you want to take the entire set of
11754 characters, including extended characters like E with an acute accent,
11755 into account. You should use the mappings in this package (rather than
11756 adding 32 yourself) to do case mappings.
11758 @item Ada.Strings.Unbounded (A.4.5)
11759 This package provides facilities for handling variable length
11760 strings. The unbounded model allows arbitrary length strings, but
11761 requires the use of dynamic allocation and finalization.
11763 @item Ada.Strings.Wide_Bounded (A.4.7)
11764 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11765 @itemx Ada.Strings.Wide_Maps (A.4.7)
11766 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11767 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11768 These packages provide analogous capabilities to the corresponding
11769 packages without @samp{Wide_} in the name, but operate with the types
11770 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11771 and @code{Character}.
11773 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11774 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11775 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11776 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11777 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11778 These packages provide analogous capabilities to the corresponding
11779 packages without @samp{Wide_} in the name, but operate with the types
11780 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11781 of @code{String} and @code{Character}.
11783 @item Ada.Synchronous_Task_Control (D.10)
11784 This package provides some standard facilities for controlling task
11785 communication in a synchronous manner.
11788 This package contains definitions for manipulation of the tags of tagged
11791 @item Ada.Task_Attributes
11792 This package provides the capability of associating arbitrary
11793 task-specific data with separate tasks.
11796 This package provides basic text input-output capabilities for
11797 character, string and numeric data. The subpackages of this
11798 package are listed next.
11800 @item Ada.Text_IO.Decimal_IO
11801 Provides input-output facilities for decimal fixed-point types
11803 @item Ada.Text_IO.Enumeration_IO
11804 Provides input-output facilities for enumeration types.
11806 @item Ada.Text_IO.Fixed_IO
11807 Provides input-output facilities for ordinary fixed-point types.
11809 @item Ada.Text_IO.Float_IO
11810 Provides input-output facilities for float types. The following
11811 predefined instantiations of this generic package are available:
11815 @code{Short_Float_Text_IO}
11817 @code{Float_Text_IO}
11819 @code{Long_Float_Text_IO}
11822 @item Ada.Text_IO.Integer_IO
11823 Provides input-output facilities for integer types. The following
11824 predefined instantiations of this generic package are available:
11827 @item Short_Short_Integer
11828 @code{Ada.Short_Short_Integer_Text_IO}
11829 @item Short_Integer
11830 @code{Ada.Short_Integer_Text_IO}
11832 @code{Ada.Integer_Text_IO}
11834 @code{Ada.Long_Integer_Text_IO}
11835 @item Long_Long_Integer
11836 @code{Ada.Long_Long_Integer_Text_IO}
11839 @item Ada.Text_IO.Modular_IO
11840 Provides input-output facilities for modular (unsigned) types
11842 @item Ada.Text_IO.Complex_IO (G.1.3)
11843 This package provides basic text input-output capabilities for complex
11846 @item Ada.Text_IO.Editing (F.3.3)
11847 This package contains routines for edited output, analogous to the use
11848 of pictures in COBOL@. The picture formats used by this package are a
11849 close copy of the facility in COBOL@.
11851 @item Ada.Text_IO.Text_Streams (A.12.2)
11852 This package provides a facility that allows Text_IO files to be treated
11853 as streams, so that the stream attributes can be used for writing
11854 arbitrary data, including binary data, to Text_IO files.
11856 @item Ada.Unchecked_Conversion (13.9)
11857 This generic package allows arbitrary conversion from one type to
11858 another of the same size, providing for breaking the type safety in
11859 special circumstances.
11861 If the types have the same Size (more accurately the same Value_Size),
11862 then the effect is simply to transfer the bits from the source to the
11863 target type without any modification. This usage is well defined, and
11864 for simple types whose representation is typically the same across
11865 all implementations, gives a portable method of performing such
11868 If the types do not have the same size, then the result is implementation
11869 defined, and thus may be non-portable. The following describes how GNAT
11870 handles such unchecked conversion cases.
11872 If the types are of different sizes, and are both discrete types, then
11873 the effect is of a normal type conversion without any constraint checking.
11874 In particular if the result type has a larger size, the result will be
11875 zero or sign extended. If the result type has a smaller size, the result
11876 will be truncated by ignoring high order bits.
11878 If the types are of different sizes, and are not both discrete types,
11879 then the conversion works as though pointers were created to the source
11880 and target, and the pointer value is converted. The effect is that bits
11881 are copied from successive low order storage units and bits of the source
11882 up to the length of the target type.
11884 A warning is issued if the lengths differ, since the effect in this
11885 case is implementation dependent, and the above behavior may not match
11886 that of some other compiler.
11888 A pointer to one type may be converted to a pointer to another type using
11889 unchecked conversion. The only case in which the effect is undefined is
11890 when one or both pointers are pointers to unconstrained array types. In
11891 this case, the bounds information may get incorrectly transferred, and in
11892 particular, GNAT uses double size pointers for such types, and it is
11893 meaningless to convert between such pointer types. GNAT will issue a
11894 warning if the alignment of the target designated type is more strict
11895 than the alignment of the source designated type (since the result may
11896 be unaligned in this case).
11898 A pointer other than a pointer to an unconstrained array type may be
11899 converted to and from System.Address. Such usage is common in Ada 83
11900 programs, but note that Ada.Address_To_Access_Conversions is the
11901 preferred method of performing such conversions in Ada 95 and Ada 2005.
11903 unchecked conversion nor Ada.Address_To_Access_Conversions should be
11904 used in conjunction with pointers to unconstrained objects, since
11905 the bounds information cannot be handled correctly in this case.
11907 @item Ada.Unchecked_Deallocation (13.11.2)
11908 This generic package allows explicit freeing of storage previously
11909 allocated by use of an allocator.
11911 @item Ada.Wide_Text_IO (A.11)
11912 This package is similar to @code{Ada.Text_IO}, except that the external
11913 file supports wide character representations, and the internal types are
11914 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11915 and @code{String}. It contains generic subpackages listed next.
11917 @item Ada.Wide_Text_IO.Decimal_IO
11918 Provides input-output facilities for decimal fixed-point types
11920 @item Ada.Wide_Text_IO.Enumeration_IO
11921 Provides input-output facilities for enumeration types.
11923 @item Ada.Wide_Text_IO.Fixed_IO
11924 Provides input-output facilities for ordinary fixed-point types.
11926 @item Ada.Wide_Text_IO.Float_IO
11927 Provides input-output facilities for float types. The following
11928 predefined instantiations of this generic package are available:
11932 @code{Short_Float_Wide_Text_IO}
11934 @code{Float_Wide_Text_IO}
11936 @code{Long_Float_Wide_Text_IO}
11939 @item Ada.Wide_Text_IO.Integer_IO
11940 Provides input-output facilities for integer types. The following
11941 predefined instantiations of this generic package are available:
11944 @item Short_Short_Integer
11945 @code{Ada.Short_Short_Integer_Wide_Text_IO}
11946 @item Short_Integer
11947 @code{Ada.Short_Integer_Wide_Text_IO}
11949 @code{Ada.Integer_Wide_Text_IO}
11951 @code{Ada.Long_Integer_Wide_Text_IO}
11952 @item Long_Long_Integer
11953 @code{Ada.Long_Long_Integer_Wide_Text_IO}
11956 @item Ada.Wide_Text_IO.Modular_IO
11957 Provides input-output facilities for modular (unsigned) types
11959 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
11960 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11961 external file supports wide character representations.
11963 @item Ada.Wide_Text_IO.Editing (F.3.4)
11964 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11965 types are @code{Wide_Character} and @code{Wide_String} instead of
11966 @code{Character} and @code{String}.
11968 @item Ada.Wide_Text_IO.Streams (A.12.3)
11969 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11970 types are @code{Wide_Character} and @code{Wide_String} instead of
11971 @code{Character} and @code{String}.
11973 @item Ada.Wide_Wide_Text_IO (A.11)
11974 This package is similar to @code{Ada.Text_IO}, except that the external
11975 file supports wide character representations, and the internal types are
11976 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11977 and @code{String}. It contains generic subpackages listed next.
11979 @item Ada.Wide_Wide_Text_IO.Decimal_IO
11980 Provides input-output facilities for decimal fixed-point types
11982 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
11983 Provides input-output facilities for enumeration types.
11985 @item Ada.Wide_Wide_Text_IO.Fixed_IO
11986 Provides input-output facilities for ordinary fixed-point types.
11988 @item Ada.Wide_Wide_Text_IO.Float_IO
11989 Provides input-output facilities for float types. The following
11990 predefined instantiations of this generic package are available:
11994 @code{Short_Float_Wide_Wide_Text_IO}
11996 @code{Float_Wide_Wide_Text_IO}
11998 @code{Long_Float_Wide_Wide_Text_IO}
12001 @item Ada.Wide_Wide_Text_IO.Integer_IO
12002 Provides input-output facilities for integer types. The following
12003 predefined instantiations of this generic package are available:
12006 @item Short_Short_Integer
12007 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12008 @item Short_Integer
12009 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12011 @code{Ada.Integer_Wide_Wide_Text_IO}
12013 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12014 @item Long_Long_Integer
12015 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12018 @item Ada.Wide_Wide_Text_IO.Modular_IO
12019 Provides input-output facilities for modular (unsigned) types
12021 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12022 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12023 external file supports wide character representations.
12025 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12026 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12027 types are @code{Wide_Character} and @code{Wide_String} instead of
12028 @code{Character} and @code{String}.
12030 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12031 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12032 types are @code{Wide_Character} and @code{Wide_String} instead of
12033 @code{Character} and @code{String}.
12038 @node The Implementation of Standard I/O
12039 @chapter The Implementation of Standard I/O
12042 GNAT implements all the required input-output facilities described in
12043 A.6 through A.14. These sections of the Ada Reference Manual describe the
12044 required behavior of these packages from the Ada point of view, and if
12045 you are writing a portable Ada program that does not need to know the
12046 exact manner in which Ada maps to the outside world when it comes to
12047 reading or writing external files, then you do not need to read this
12048 chapter. As long as your files are all regular files (not pipes or
12049 devices), and as long as you write and read the files only from Ada, the
12050 description in the Ada Reference Manual is sufficient.
12052 However, if you want to do input-output to pipes or other devices, such
12053 as the keyboard or screen, or if the files you are dealing with are
12054 either generated by some other language, or to be read by some other
12055 language, then you need to know more about the details of how the GNAT
12056 implementation of these input-output facilities behaves.
12058 In this chapter we give a detailed description of exactly how GNAT
12059 interfaces to the file system. As always, the sources of the system are
12060 available to you for answering questions at an even more detailed level,
12061 but for most purposes the information in this chapter will suffice.
12063 Another reason that you may need to know more about how input-output is
12064 implemented arises when you have a program written in mixed languages
12065 where, for example, files are shared between the C and Ada sections of
12066 the same program. GNAT provides some additional facilities, in the form
12067 of additional child library packages, that facilitate this sharing, and
12068 these additional facilities are also described in this chapter.
12071 * Standard I/O Packages::
12077 * Wide_Wide_Text_IO::
12080 * Filenames encoding::
12082 * Operations on C Streams::
12083 * Interfacing to C Streams::
12086 @node Standard I/O Packages
12087 @section Standard I/O Packages
12090 The Standard I/O packages described in Annex A for
12096 Ada.Text_IO.Complex_IO
12098 Ada.Text_IO.Text_Streams
12102 Ada.Wide_Text_IO.Complex_IO
12104 Ada.Wide_Text_IO.Text_Streams
12106 Ada.Wide_Wide_Text_IO
12108 Ada.Wide_Wide_Text_IO.Complex_IO
12110 Ada.Wide_Wide_Text_IO.Text_Streams
12120 are implemented using the C
12121 library streams facility; where
12125 All files are opened using @code{fopen}.
12127 All input/output operations use @code{fread}/@code{fwrite}.
12131 There is no internal buffering of any kind at the Ada library level. The only
12132 buffering is that provided at the system level in the implementation of the
12133 library routines that support streams. This facilitates shared use of these
12134 streams by mixed language programs. Note though that system level buffering is
12135 explicitly enabled at elaboration of the standard I/O packages and that can
12136 have an impact on mixed language programs, in particular those using I/O before
12137 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12138 the Ada elaboration routine before performing any I/O or when impractical,
12139 flush the common I/O streams and in particular Standard_Output before
12140 elaborating the Ada code.
12143 @section FORM Strings
12146 The format of a FORM string in GNAT is:
12149 "keyword=value,keyword=value,@dots{},keyword=value"
12153 where letters may be in upper or lower case, and there are no spaces
12154 between values. The order of the entries is not important. Currently
12155 there are two keywords defined.
12159 WCEM=[n|h|u|s|e|8|b]
12163 The use of these parameters is described later in this section.
12169 Direct_IO can only be instantiated for definite types. This is a
12170 restriction of the Ada language, which means that the records are fixed
12171 length (the length being determined by @code{@var{type}'Size}, rounded
12172 up to the next storage unit boundary if necessary).
12174 The records of a Direct_IO file are simply written to the file in index
12175 sequence, with the first record starting at offset zero, and subsequent
12176 records following. There is no control information of any kind. For
12177 example, if 32-bit integers are being written, each record takes
12178 4-bytes, so the record at index @var{K} starts at offset
12179 (@var{K}@minus{}1)*4.
12181 There is no limit on the size of Direct_IO files, they are expanded as
12182 necessary to accommodate whatever records are written to the file.
12184 @node Sequential_IO
12185 @section Sequential_IO
12188 Sequential_IO may be instantiated with either a definite (constrained)
12189 or indefinite (unconstrained) type.
12191 For the definite type case, the elements written to the file are simply
12192 the memory images of the data values with no control information of any
12193 kind. The resulting file should be read using the same type, no validity
12194 checking is performed on input.
12196 For the indefinite type case, the elements written consist of two
12197 parts. First is the size of the data item, written as the memory image
12198 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12199 the data value. The resulting file can only be read using the same
12200 (unconstrained) type. Normal assignment checks are performed on these
12201 read operations, and if these checks fail, @code{Data_Error} is
12202 raised. In particular, in the array case, the lengths must match, and in
12203 the variant record case, if the variable for a particular read operation
12204 is constrained, the discriminants must match.
12206 Note that it is not possible to use Sequential_IO to write variable
12207 length array items, and then read the data back into different length
12208 arrays. For example, the following will raise @code{Data_Error}:
12210 @smallexample @c ada
12211 package IO is new Sequential_IO (String);
12216 IO.Write (F, "hello!")
12217 IO.Reset (F, Mode=>In_File);
12224 On some Ada implementations, this will print @code{hell}, but the program is
12225 clearly incorrect, since there is only one element in the file, and that
12226 element is the string @code{hello!}.
12228 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12229 using Stream_IO, and this is the preferred mechanism. In particular, the
12230 above program fragment rewritten to use Stream_IO will work correctly.
12236 Text_IO files consist of a stream of characters containing the following
12237 special control characters:
12240 LF (line feed, 16#0A#) Line Mark
12241 FF (form feed, 16#0C#) Page Mark
12245 A canonical Text_IO file is defined as one in which the following
12246 conditions are met:
12250 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12254 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12255 end of a page and consequently can appear only immediately following a
12256 @code{LF} (line mark) character.
12259 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12260 (line mark, page mark). In the former case, the page mark is implicitly
12261 assumed to be present.
12265 A file written using Text_IO will be in canonical form provided that no
12266 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12267 or @code{Put_Line}. There will be no @code{FF} character at the end of
12268 the file unless an explicit @code{New_Page} operation was performed
12269 before closing the file.
12271 A canonical Text_IO file that is a regular file (i.e., not a device or a
12272 pipe) can be read using any of the routines in Text_IO@. The
12273 semantics in this case will be exactly as defined in the Ada Reference
12274 Manual, and all the routines in Text_IO are fully implemented.
12276 A text file that does not meet the requirements for a canonical Text_IO
12277 file has one of the following:
12281 The file contains @code{FF} characters not immediately following a
12282 @code{LF} character.
12285 The file contains @code{LF} or @code{FF} characters written by
12286 @code{Put} or @code{Put_Line}, which are not logically considered to be
12287 line marks or page marks.
12290 The file ends in a character other than @code{LF} or @code{FF},
12291 i.e.@: there is no explicit line mark or page mark at the end of the file.
12295 Text_IO can be used to read such non-standard text files but subprograms
12296 to do with line or page numbers do not have defined meanings. In
12297 particular, a @code{FF} character that does not follow a @code{LF}
12298 character may or may not be treated as a page mark from the point of
12299 view of page and line numbering. Every @code{LF} character is considered
12300 to end a line, and there is an implied @code{LF} character at the end of
12304 * Text_IO Stream Pointer Positioning::
12305 * Text_IO Reading and Writing Non-Regular Files::
12307 * Treating Text_IO Files as Streams::
12308 * Text_IO Extensions::
12309 * Text_IO Facilities for Unbounded Strings::
12312 @node Text_IO Stream Pointer Positioning
12313 @subsection Stream Pointer Positioning
12316 @code{Ada.Text_IO} has a definition of current position for a file that
12317 is being read. No internal buffering occurs in Text_IO, and usually the
12318 physical position in the stream used to implement the file corresponds
12319 to this logical position defined by Text_IO@. There are two exceptions:
12323 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12324 is positioned past the @code{LF} (line mark) that precedes the page
12325 mark. Text_IO maintains an internal flag so that subsequent read
12326 operations properly handle the logical position which is unchanged by
12327 the @code{End_Of_Page} call.
12330 After a call to @code{End_Of_File} that returns @code{True}, if the
12331 Text_IO file was positioned before the line mark at the end of file
12332 before the call, then the logical position is unchanged, but the stream
12333 is physically positioned right at the end of file (past the line mark,
12334 and past a possible page mark following the line mark. Again Text_IO
12335 maintains internal flags so that subsequent read operations properly
12336 handle the logical position.
12340 These discrepancies have no effect on the observable behavior of
12341 Text_IO, but if a single Ada stream is shared between a C program and
12342 Ada program, or shared (using @samp{shared=yes} in the form string)
12343 between two Ada files, then the difference may be observable in some
12346 @node Text_IO Reading and Writing Non-Regular Files
12347 @subsection Reading and Writing Non-Regular Files
12350 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
12351 can be used for reading and writing. Writing is not affected and the
12352 sequence of characters output is identical to the normal file case, but
12353 for reading, the behavior of Text_IO is modified to avoid undesirable
12354 look-ahead as follows:
12356 An input file that is not a regular file is considered to have no page
12357 marks. Any @code{Ascii.FF} characters (the character normally used for a
12358 page mark) appearing in the file are considered to be data
12359 characters. In particular:
12363 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12364 following a line mark. If a page mark appears, it will be treated as a
12368 This avoids the need to wait for an extra character to be typed or
12369 entered from the pipe to complete one of these operations.
12372 @code{End_Of_Page} always returns @code{False}
12375 @code{End_Of_File} will return @code{False} if there is a page mark at
12376 the end of the file.
12380 Output to non-regular files is the same as for regular files. Page marks
12381 may be written to non-regular files using @code{New_Page}, but as noted
12382 above they will not be treated as page marks on input if the output is
12383 piped to another Ada program.
12385 Another important discrepancy when reading non-regular files is that the end
12386 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
12387 pressing the @key{EOT} key,
12389 is signaled once (i.e.@: the test @code{End_Of_File}
12390 will yield @code{True}, or a read will
12391 raise @code{End_Error}), but then reading can resume
12392 to read data past that end of
12393 file indication, until another end of file indication is entered.
12395 @node Get_Immediate
12396 @subsection Get_Immediate
12397 @cindex Get_Immediate
12400 Get_Immediate returns the next character (including control characters)
12401 from the input file. In particular, Get_Immediate will return LF or FF
12402 characters used as line marks or page marks. Such operations leave the
12403 file positioned past the control character, and it is thus not treated
12404 as having its normal function. This means that page, line and column
12405 counts after this kind of Get_Immediate call are set as though the mark
12406 did not occur. In the case where a Get_Immediate leaves the file
12407 positioned between the line mark and page mark (which is not normally
12408 possible), it is undefined whether the FF character will be treated as a
12411 @node Treating Text_IO Files as Streams
12412 @subsection Treating Text_IO Files as Streams
12413 @cindex Stream files
12416 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12417 as a stream. Data written to a Text_IO file in this stream mode is
12418 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
12419 16#0C# (@code{FF}), the resulting file may have non-standard
12420 format. Similarly if read operations are used to read from a Text_IO
12421 file treated as a stream, then @code{LF} and @code{FF} characters may be
12422 skipped and the effect is similar to that described above for
12423 @code{Get_Immediate}.
12425 @node Text_IO Extensions
12426 @subsection Text_IO Extensions
12427 @cindex Text_IO extensions
12430 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12431 to the standard @code{Text_IO} package:
12434 @item function File_Exists (Name : String) return Boolean;
12435 Determines if a file of the given name exists.
12437 @item function Get_Line return String;
12438 Reads a string from the standard input file. The value returned is exactly
12439 the length of the line that was read.
12441 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12442 Similar, except that the parameter File specifies the file from which
12443 the string is to be read.
12447 @node Text_IO Facilities for Unbounded Strings
12448 @subsection Text_IO Facilities for Unbounded Strings
12449 @cindex Text_IO for unbounded strings
12450 @cindex Unbounded_String, Text_IO operations
12453 The package @code{Ada.Strings.Unbounded.Text_IO}
12454 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12455 subprograms useful for Text_IO operations on unbounded strings:
12459 @item function Get_Line (File : File_Type) return Unbounded_String;
12460 Reads a line from the specified file
12461 and returns the result as an unbounded string.
12463 @item procedure Put (File : File_Type; U : Unbounded_String);
12464 Writes the value of the given unbounded string to the specified file
12465 Similar to the effect of
12466 @code{Put (To_String (U))} except that an extra copy is avoided.
12468 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12469 Writes the value of the given unbounded string to the specified file,
12470 followed by a @code{New_Line}.
12471 Similar to the effect of @code{Put_Line (To_String (U))} except
12472 that an extra copy is avoided.
12476 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12477 and is optional. If the parameter is omitted, then the standard input or
12478 output file is referenced as appropriate.
12480 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12481 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12482 @code{Wide_Text_IO} functionality for unbounded wide strings.
12484 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12485 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12486 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12489 @section Wide_Text_IO
12492 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12493 both input and output files may contain special sequences that represent
12494 wide character values. The encoding scheme for a given file may be
12495 specified using a FORM parameter:
12502 as part of the FORM string (WCEM = wide character encoding method),
12503 where @var{x} is one of the following characters
12509 Upper half encoding
12521 The encoding methods match those that
12522 can be used in a source
12523 program, but there is no requirement that the encoding method used for
12524 the source program be the same as the encoding method used for files,
12525 and different files may use different encoding methods.
12527 The default encoding method for the standard files, and for opened files
12528 for which no WCEM parameter is given in the FORM string matches the
12529 wide character encoding specified for the main program (the default
12530 being brackets encoding if no coding method was specified with -gnatW).
12534 In this encoding, a wide character is represented by a five character
12542 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12543 characters (using upper case letters) of the wide character code. For
12544 example, ESC A345 is used to represent the wide character with code
12545 16#A345#. This scheme is compatible with use of the full
12546 @code{Wide_Character} set.
12548 @item Upper Half Coding
12549 The wide character with encoding 16#abcd#, where the upper bit is on
12550 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12551 16#cd#. The second byte may never be a format control character, but is
12552 not required to be in the upper half. This method can be also used for
12553 shift-JIS or EUC where the internal coding matches the external coding.
12555 @item Shift JIS Coding
12556 A wide character is represented by a two character sequence 16#ab# and
12557 16#cd#, with the restrictions described for upper half encoding as
12558 described above. The internal character code is the corresponding JIS
12559 character according to the standard algorithm for Shift-JIS
12560 conversion. Only characters defined in the JIS code set table can be
12561 used with this encoding method.
12564 A wide character is represented by a two character sequence 16#ab# and
12565 16#cd#, with both characters being in the upper half. The internal
12566 character code is the corresponding JIS character according to the EUC
12567 encoding algorithm. Only characters defined in the JIS code set table
12568 can be used with this encoding method.
12571 A wide character is represented using
12572 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12573 10646-1/Am.2. Depending on the character value, the representation
12574 is a one, two, or three byte sequence:
12577 16#0000#-16#007f#: 2#0xxxxxxx#
12578 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12579 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12583 where the @var{xxx} bits correspond to the left-padded bits of the
12584 16-bit character value. Note that all lower half ASCII characters
12585 are represented as ASCII bytes and all upper half characters and
12586 other wide characters are represented as sequences of upper-half
12587 (The full UTF-8 scheme allows for encoding 31-bit characters as
12588 6-byte sequences, but in this implementation, all UTF-8 sequences
12589 of four or more bytes length will raise a Constraint_Error, as
12590 will all invalid UTF-8 sequences.)
12592 @item Brackets Coding
12593 In this encoding, a wide character is represented by the following eight
12594 character sequence:
12601 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12602 characters (using uppercase letters) of the wide character code. For
12603 example, @code{["A345"]} is used to represent the wide character with code
12605 This scheme is compatible with use of the full Wide_Character set.
12606 On input, brackets coding can also be used for upper half characters,
12607 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12608 is only used for wide characters with a code greater than @code{16#FF#}.
12610 Note that brackets coding is not normally used in the context of
12611 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12612 a portable way of encoding source files. In the context of Wide_Text_IO
12613 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12614 any instance of the left bracket character other than to encode wide
12615 character values using the brackets encoding method. In practice it is
12616 expected that some standard wide character encoding method such
12617 as UTF-8 will be used for text input output.
12619 If brackets notation is used, then any occurrence of a left bracket
12620 in the input file which is not the start of a valid wide character
12621 sequence will cause Constraint_Error to be raised. It is possible to
12622 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12623 input will interpret this as a left bracket.
12625 However, when a left bracket is output, it will be output as a left bracket
12626 and not as ["5B"]. We make this decision because for normal use of
12627 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12628 brackets. For example, if we write:
12631 Put_Line ("Start of output [first run]");
12635 we really do not want to have the left bracket in this message clobbered so
12636 that the output reads:
12639 Start of output ["5B"]first run]
12643 In practice brackets encoding is reasonably useful for normal Put_Line use
12644 since we won't get confused between left brackets and wide character
12645 sequences in the output. But for input, or when files are written out
12646 and read back in, it really makes better sense to use one of the standard
12647 encoding methods such as UTF-8.
12652 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12653 not all wide character
12654 values can be represented. An attempt to output a character that cannot
12655 be represented using the encoding scheme for the file causes
12656 Constraint_Error to be raised. An invalid wide character sequence on
12657 input also causes Constraint_Error to be raised.
12660 * Wide_Text_IO Stream Pointer Positioning::
12661 * Wide_Text_IO Reading and Writing Non-Regular Files::
12664 @node Wide_Text_IO Stream Pointer Positioning
12665 @subsection Stream Pointer Positioning
12668 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12669 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12672 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12673 normal lower ASCII set (i.e.@: a character in the range:
12675 @smallexample @c ada
12676 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12680 then although the logical position of the file pointer is unchanged by
12681 the @code{Look_Ahead} call, the stream is physically positioned past the
12682 wide character sequence. Again this is to avoid the need for buffering
12683 or backup, and all @code{Wide_Text_IO} routines check the internal
12684 indication that this situation has occurred so that this is not visible
12685 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
12686 can be observed if the wide text file shares a stream with another file.
12688 @node Wide_Text_IO Reading and Writing Non-Regular Files
12689 @subsection Reading and Writing Non-Regular Files
12692 As in the case of Text_IO, when a non-regular file is read, it is
12693 assumed that the file contains no page marks (any form characters are
12694 treated as data characters), and @code{End_Of_Page} always returns
12695 @code{False}. Similarly, the end of file indication is not sticky, so
12696 it is possible to read beyond an end of file.
12698 @node Wide_Wide_Text_IO
12699 @section Wide_Wide_Text_IO
12702 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12703 both input and output files may contain special sequences that represent
12704 wide wide character values. The encoding scheme for a given file may be
12705 specified using a FORM parameter:
12712 as part of the FORM string (WCEM = wide character encoding method),
12713 where @var{x} is one of the following characters
12719 Upper half encoding
12731 The encoding methods match those that
12732 can be used in a source
12733 program, but there is no requirement that the encoding method used for
12734 the source program be the same as the encoding method used for files,
12735 and different files may use different encoding methods.
12737 The default encoding method for the standard files, and for opened files
12738 for which no WCEM parameter is given in the FORM string matches the
12739 wide character encoding specified for the main program (the default
12740 being brackets encoding if no coding method was specified with -gnatW).
12745 A wide character is represented using
12746 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12747 10646-1/Am.2. Depending on the character value, the representation
12748 is a one, two, three, or four byte sequence:
12751 16#000000#-16#00007f#: 2#0xxxxxxx#
12752 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12753 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12754 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12758 where the @var{xxx} bits correspond to the left-padded bits of the
12759 21-bit character value. Note that all lower half ASCII characters
12760 are represented as ASCII bytes and all upper half characters and
12761 other wide characters are represented as sequences of upper-half
12764 @item Brackets Coding
12765 In this encoding, a wide wide character is represented by the following eight
12766 character sequence if is in wide character range
12772 and by the following ten character sequence if not
12775 [ " a b c d e f " ]
12779 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12780 are the four or six hexadecimal
12781 characters (using uppercase letters) of the wide wide character code. For
12782 example, @code{["01A345"]} is used to represent the wide wide character
12783 with code @code{16#01A345#}.
12785 This scheme is compatible with use of the full Wide_Wide_Character set.
12786 On input, brackets coding can also be used for upper half characters,
12787 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12788 is only used for wide characters with a code greater than @code{16#FF#}.
12793 If is also possible to use the other Wide_Character encoding methods,
12794 such as Shift-JIS, but the other schemes cannot support the full range
12795 of wide wide characters.
12796 An attempt to output a character that cannot
12797 be represented using the encoding scheme for the file causes
12798 Constraint_Error to be raised. An invalid wide character sequence on
12799 input also causes Constraint_Error to be raised.
12802 * Wide_Wide_Text_IO Stream Pointer Positioning::
12803 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12806 @node Wide_Wide_Text_IO Stream Pointer Positioning
12807 @subsection Stream Pointer Positioning
12810 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12811 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12814 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12815 normal lower ASCII set (i.e.@: a character in the range:
12817 @smallexample @c ada
12818 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12822 then although the logical position of the file pointer is unchanged by
12823 the @code{Look_Ahead} call, the stream is physically positioned past the
12824 wide character sequence. Again this is to avoid the need for buffering
12825 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
12826 indication that this situation has occurred so that this is not visible
12827 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
12828 can be observed if the wide text file shares a stream with another file.
12830 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
12831 @subsection Reading and Writing Non-Regular Files
12834 As in the case of Text_IO, when a non-regular file is read, it is
12835 assumed that the file contains no page marks (any form characters are
12836 treated as data characters), and @code{End_Of_Page} always returns
12837 @code{False}. Similarly, the end of file indication is not sticky, so
12838 it is possible to read beyond an end of file.
12844 A stream file is a sequence of bytes, where individual elements are
12845 written to the file as described in the Ada Reference Manual. The type
12846 @code{Stream_Element} is simply a byte. There are two ways to read or
12847 write a stream file.
12851 The operations @code{Read} and @code{Write} directly read or write a
12852 sequence of stream elements with no control information.
12855 The stream attributes applied to a stream file transfer data in the
12856 manner described for stream attributes.
12860 @section Shared Files
12863 Section A.14 of the Ada Reference Manual allows implementations to
12864 provide a wide variety of behavior if an attempt is made to access the
12865 same external file with two or more internal files.
12867 To provide a full range of functionality, while at the same time
12868 minimizing the problems of portability caused by this implementation
12869 dependence, GNAT handles file sharing as follows:
12873 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
12874 to open two or more files with the same full name is considered an error
12875 and is not supported. The exception @code{Use_Error} will be
12876 raised. Note that a file that is not explicitly closed by the program
12877 remains open until the program terminates.
12880 If the form parameter @samp{shared=no} appears in the form string, the
12881 file can be opened or created with its own separate stream identifier,
12882 regardless of whether other files sharing the same external file are
12883 opened. The exact effect depends on how the C stream routines handle
12884 multiple accesses to the same external files using separate streams.
12887 If the form parameter @samp{shared=yes} appears in the form string for
12888 each of two or more files opened using the same full name, the same
12889 stream is shared between these files, and the semantics are as described
12890 in Ada Reference Manual, Section A.14.
12894 When a program that opens multiple files with the same name is ported
12895 from another Ada compiler to GNAT, the effect will be that
12896 @code{Use_Error} is raised.
12898 The documentation of the original compiler and the documentation of the
12899 program should then be examined to determine if file sharing was
12900 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
12901 and @code{Create} calls as required.
12903 When a program is ported from GNAT to some other Ada compiler, no
12904 special attention is required unless the @samp{shared=@var{xxx}} form
12905 parameter is used in the program. In this case, you must examine the
12906 documentation of the new compiler to see if it supports the required
12907 file sharing semantics, and form strings modified appropriately. Of
12908 course it may be the case that the program cannot be ported if the
12909 target compiler does not support the required functionality. The best
12910 approach in writing portable code is to avoid file sharing (and hence
12911 the use of the @samp{shared=@var{xxx}} parameter in the form string)
12914 One common use of file sharing in Ada 83 is the use of instantiations of
12915 Sequential_IO on the same file with different types, to achieve
12916 heterogeneous input-output. Although this approach will work in GNAT if
12917 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
12918 for this purpose (using the stream attributes)
12920 @node Filenames encoding
12921 @section Filenames encoding
12924 An encoding form parameter can be used to specify the filename
12925 encoding @samp{encoding=@var{xxx}}.
12929 If the form parameter @samp{encoding=utf8} appears in the form string, the
12930 filename must be encoded in UTF-8.
12933 If the form parameter @samp{encoding=8bits} appears in the form
12934 string, the filename must be a standard 8bits string.
12937 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
12938 value UTF-8 is used. This encoding form parameter is only supported on
12939 the Windows platform. On the other Operating Systems the runtime is
12940 supporting UTF-8 natively.
12943 @section Open Modes
12946 @code{Open} and @code{Create} calls result in a call to @code{fopen}
12947 using the mode shown in the following table:
12950 @center @code{Open} and @code{Create} Call Modes
12952 @b{OPEN } @b{CREATE}
12953 Append_File "r+" "w+"
12955 Out_File (Direct_IO) "r+" "w"
12956 Out_File (all other cases) "w" "w"
12957 Inout_File "r+" "w+"
12961 If text file translation is required, then either @samp{b} or @samp{t}
12962 is added to the mode, depending on the setting of Text. Text file
12963 translation refers to the mapping of CR/LF sequences in an external file
12964 to LF characters internally. This mapping only occurs in DOS and
12965 DOS-like systems, and is not relevant to other systems.
12967 A special case occurs with Stream_IO@. As shown in the above table, the
12968 file is initially opened in @samp{r} or @samp{w} mode for the
12969 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
12970 subsequently requires switching from reading to writing or vice-versa,
12971 then the file is reopened in @samp{r+} mode to permit the required operation.
12973 @node Operations on C Streams
12974 @section Operations on C Streams
12975 The package @code{Interfaces.C_Streams} provides an Ada program with direct
12976 access to the C library functions for operations on C streams:
12978 @smallexample @c adanocomment
12979 package Interfaces.C_Streams is
12980 -- Note: the reason we do not use the types that are in
12981 -- Interfaces.C is that we want to avoid dragging in the
12982 -- code in this unit if possible.
12983 subtype chars is System.Address;
12984 -- Pointer to null-terminated array of characters
12985 subtype FILEs is System.Address;
12986 -- Corresponds to the C type FILE*
12987 subtype voids is System.Address;
12988 -- Corresponds to the C type void*
12989 subtype int is Integer;
12990 subtype long is Long_Integer;
12991 -- Note: the above types are subtypes deliberately, and it
12992 -- is part of this spec that the above correspondences are
12993 -- guaranteed. This means that it is legitimate to, for
12994 -- example, use Integer instead of int. We provide these
12995 -- synonyms for clarity, but in some cases it may be
12996 -- convenient to use the underlying types (for example to
12997 -- avoid an unnecessary dependency of a spec on the spec
12999 type size_t is mod 2 ** Standard'Address_Size;
13000 NULL_Stream : constant FILEs;
13001 -- Value returned (NULL in C) to indicate an
13002 -- fdopen/fopen/tmpfile error
13003 ----------------------------------
13004 -- Constants Defined in stdio.h --
13005 ----------------------------------
13006 EOF : constant int;
13007 -- Used by a number of routines to indicate error or
13009 IOFBF : constant int;
13010 IOLBF : constant int;
13011 IONBF : constant int;
13012 -- Used to indicate buffering mode for setvbuf call
13013 SEEK_CUR : constant int;
13014 SEEK_END : constant int;
13015 SEEK_SET : constant int;
13016 -- Used to indicate origin for fseek call
13017 function stdin return FILEs;
13018 function stdout return FILEs;
13019 function stderr return FILEs;
13020 -- Streams associated with standard files
13021 --------------------------
13022 -- Standard C functions --
13023 --------------------------
13024 -- The functions selected below are ones that are
13025 -- available in DOS, OS/2, UNIX and Xenix (but not
13026 -- necessarily in ANSI C). These are very thin interfaces
13027 -- which copy exactly the C headers. For more
13028 -- documentation on these functions, see the Microsoft C
13029 -- "Run-Time Library Reference" (Microsoft Press, 1990,
13030 -- ISBN 1-55615-225-6), which includes useful information
13031 -- on system compatibility.
13032 procedure clearerr (stream : FILEs);
13033 function fclose (stream : FILEs) return int;
13034 function fdopen (handle : int; mode : chars) return FILEs;
13035 function feof (stream : FILEs) return int;
13036 function ferror (stream : FILEs) return int;
13037 function fflush (stream : FILEs) return int;
13038 function fgetc (stream : FILEs) return int;
13039 function fgets (strng : chars; n : int; stream : FILEs)
13041 function fileno (stream : FILEs) return int;
13042 function fopen (filename : chars; Mode : chars)
13044 -- Note: to maintain target independence, use
13045 -- text_translation_required, a boolean variable defined in
13046 -- a-sysdep.c to deal with the target dependent text
13047 -- translation requirement. If this variable is set,
13048 -- then b/t should be appended to the standard mode
13049 -- argument to set the text translation mode off or on
13051 function fputc (C : int; stream : FILEs) return int;
13052 function fputs (Strng : chars; Stream : FILEs) return int;
13069 function ftell (stream : FILEs) return long;
13076 function isatty (handle : int) return int;
13077 procedure mktemp (template : chars);
13078 -- The return value (which is just a pointer to template)
13080 procedure rewind (stream : FILEs);
13081 function rmtmp return int;
13089 function tmpfile return FILEs;
13090 function ungetc (c : int; stream : FILEs) return int;
13091 function unlink (filename : chars) return int;
13092 ---------------------
13093 -- Extra functions --
13094 ---------------------
13095 -- These functions supply slightly thicker bindings than
13096 -- those above. They are derived from functions in the
13097 -- C Run-Time Library, but may do a bit more work than
13098 -- just directly calling one of the Library functions.
13099 function is_regular_file (handle : int) return int;
13100 -- Tests if given handle is for a regular file (result 1)
13101 -- or for a non-regular file (pipe or device, result 0).
13102 ---------------------------------
13103 -- Control of Text/Binary Mode --
13104 ---------------------------------
13105 -- If text_translation_required is true, then the following
13106 -- functions may be used to dynamically switch a file from
13107 -- binary to text mode or vice versa. These functions have
13108 -- no effect if text_translation_required is false (i.e.@: in
13109 -- normal UNIX mode). Use fileno to get a stream handle.
13110 procedure set_binary_mode (handle : int);
13111 procedure set_text_mode (handle : int);
13112 ----------------------------
13113 -- Full Path Name support --
13114 ----------------------------
13115 procedure full_name (nam : chars; buffer : chars);
13116 -- Given a NUL terminated string representing a file
13117 -- name, returns in buffer a NUL terminated string
13118 -- representing the full path name for the file name.
13119 -- On systems where it is relevant the drive is also
13120 -- part of the full path name. It is the responsibility
13121 -- of the caller to pass an actual parameter for buffer
13122 -- that is big enough for any full path name. Use
13123 -- max_path_len given below as the size of buffer.
13124 max_path_len : integer;
13125 -- Maximum length of an allowable full path name on the
13126 -- system, including a terminating NUL character.
13127 end Interfaces.C_Streams;
13130 @node Interfacing to C Streams
13131 @section Interfacing to C Streams
13134 The packages in this section permit interfacing Ada files to C Stream
13137 @smallexample @c ada
13138 with Interfaces.C_Streams;
13139 package Ada.Sequential_IO.C_Streams is
13140 function C_Stream (F : File_Type)
13141 return Interfaces.C_Streams.FILEs;
13143 (File : in out File_Type;
13144 Mode : in File_Mode;
13145 C_Stream : in Interfaces.C_Streams.FILEs;
13146 Form : in String := "");
13147 end Ada.Sequential_IO.C_Streams;
13149 with Interfaces.C_Streams;
13150 package Ada.Direct_IO.C_Streams is
13151 function C_Stream (F : File_Type)
13152 return Interfaces.C_Streams.FILEs;
13154 (File : in out File_Type;
13155 Mode : in File_Mode;
13156 C_Stream : in Interfaces.C_Streams.FILEs;
13157 Form : in String := "");
13158 end Ada.Direct_IO.C_Streams;
13160 with Interfaces.C_Streams;
13161 package Ada.Text_IO.C_Streams is
13162 function C_Stream (F : File_Type)
13163 return Interfaces.C_Streams.FILEs;
13165 (File : in out File_Type;
13166 Mode : in File_Mode;
13167 C_Stream : in Interfaces.C_Streams.FILEs;
13168 Form : in String := "");
13169 end Ada.Text_IO.C_Streams;
13171 with Interfaces.C_Streams;
13172 package Ada.Wide_Text_IO.C_Streams is
13173 function C_Stream (F : File_Type)
13174 return Interfaces.C_Streams.FILEs;
13176 (File : in out File_Type;
13177 Mode : in File_Mode;
13178 C_Stream : in Interfaces.C_Streams.FILEs;
13179 Form : in String := "");
13180 end Ada.Wide_Text_IO.C_Streams;
13182 with Interfaces.C_Streams;
13183 package Ada.Wide_Wide_Text_IO.C_Streams is
13184 function C_Stream (F : File_Type)
13185 return Interfaces.C_Streams.FILEs;
13187 (File : in out File_Type;
13188 Mode : in File_Mode;
13189 C_Stream : in Interfaces.C_Streams.FILEs;
13190 Form : in String := "");
13191 end Ada.Wide_Wide_Text_IO.C_Streams;
13193 with Interfaces.C_Streams;
13194 package Ada.Stream_IO.C_Streams is
13195 function C_Stream (F : File_Type)
13196 return Interfaces.C_Streams.FILEs;
13198 (File : in out File_Type;
13199 Mode : in File_Mode;
13200 C_Stream : in Interfaces.C_Streams.FILEs;
13201 Form : in String := "");
13202 end Ada.Stream_IO.C_Streams;
13206 In each of these six packages, the @code{C_Stream} function obtains the
13207 @code{FILE} pointer from a currently opened Ada file. It is then
13208 possible to use the @code{Interfaces.C_Streams} package to operate on
13209 this stream, or the stream can be passed to a C program which can
13210 operate on it directly. Of course the program is responsible for
13211 ensuring that only appropriate sequences of operations are executed.
13213 One particular use of relevance to an Ada program is that the
13214 @code{setvbuf} function can be used to control the buffering of the
13215 stream used by an Ada file. In the absence of such a call the standard
13216 default buffering is used.
13218 The @code{Open} procedures in these packages open a file giving an
13219 existing C Stream instead of a file name. Typically this stream is
13220 imported from a C program, allowing an Ada file to operate on an
13223 @node The GNAT Library
13224 @chapter The GNAT Library
13227 The GNAT library contains a number of general and special purpose packages.
13228 It represents functionality that the GNAT developers have found useful, and
13229 which is made available to GNAT users. The packages described here are fully
13230 supported, and upwards compatibility will be maintained in future releases,
13231 so you can use these facilities with the confidence that the same functionality
13232 will be available in future releases.
13234 The chapter here simply gives a brief summary of the facilities available.
13235 The full documentation is found in the spec file for the package. The full
13236 sources of these library packages, including both spec and body, are provided
13237 with all GNAT releases. For example, to find out the full specifications of
13238 the SPITBOL pattern matching capability, including a full tutorial and
13239 extensive examples, look in the @file{g-spipat.ads} file in the library.
13241 For each entry here, the package name (as it would appear in a @code{with}
13242 clause) is given, followed by the name of the corresponding spec file in
13243 parentheses. The packages are children in four hierarchies, @code{Ada},
13244 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13245 GNAT-specific hierarchy.
13247 Note that an application program should only use packages in one of these
13248 four hierarchies if the package is defined in the Ada Reference Manual,
13249 or is listed in this section of the GNAT Programmers Reference Manual.
13250 All other units should be considered internal implementation units and
13251 should not be directly @code{with}'ed by application code. The use of
13252 a @code{with} statement that references one of these internal implementation
13253 units makes an application potentially dependent on changes in versions
13254 of GNAT, and will generate a warning message.
13257 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13258 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13259 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13260 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13261 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13262 * Ada.Command_Line.Environment (a-colien.ads)::
13263 * Ada.Command_Line.Remove (a-colire.ads)::
13264 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13265 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13266 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13267 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13268 * Ada.Exceptions.Traceback (a-exctra.ads)::
13269 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13270 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13271 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13272 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13273 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13274 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13275 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13276 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13277 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13278 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13279 * GNAT.Altivec (g-altive.ads)::
13280 * GNAT.Altivec.Conversions (g-altcon.ads)::
13281 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13282 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13283 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13284 * GNAT.Array_Split (g-arrspl.ads)::
13285 * GNAT.AWK (g-awk.ads)::
13286 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13287 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13288 * GNAT.Bubble_Sort (g-bubsor.ads)::
13289 * GNAT.Bubble_Sort_A (g-busora.ads)::
13290 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13291 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13292 * GNAT.Byte_Swapping (g-bytswa.ads)::
13293 * GNAT.Calendar (g-calend.ads)::
13294 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13295 * GNAT.Case_Util (g-casuti.ads)::
13296 * GNAT.CGI (g-cgi.ads)::
13297 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13298 * GNAT.CGI.Debug (g-cgideb.ads)::
13299 * GNAT.Command_Line (g-comlin.ads)::
13300 * GNAT.Compiler_Version (g-comver.ads)::
13301 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13302 * GNAT.CRC32 (g-crc32.ads)::
13303 * GNAT.Current_Exception (g-curexc.ads)::
13304 * GNAT.Debug_Pools (g-debpoo.ads)::
13305 * GNAT.Debug_Utilities (g-debuti.ads)::
13306 * GNAT.Decode_String (g-decstr.ads)::
13307 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13308 * GNAT.Directory_Operations (g-dirope.ads)::
13309 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13310 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13311 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13312 * GNAT.Encode_String (g-encstr.ads)::
13313 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13314 * GNAT.Exception_Actions (g-excact.ads)::
13315 * GNAT.Exception_Traces (g-exctra.ads)::
13316 * GNAT.Exceptions (g-except.ads)::
13317 * GNAT.Expect (g-expect.ads)::
13318 * GNAT.Float_Control (g-flocon.ads)::
13319 * GNAT.Heap_Sort (g-heasor.ads)::
13320 * GNAT.Heap_Sort_A (g-hesora.ads)::
13321 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13322 * GNAT.HTable (g-htable.ads)::
13323 * GNAT.IO (g-io.ads)::
13324 * GNAT.IO_Aux (g-io_aux.ads)::
13325 * GNAT.Lock_Files (g-locfil.ads)::
13326 * GNAT.MD5 (g-md5.ads)::
13327 * GNAT.Memory_Dump (g-memdum.ads)::
13328 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13329 * GNAT.OS_Lib (g-os_lib.ads)::
13330 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13331 * GNAT.Random_Numbers (g-rannum.ads)::
13332 * GNAT.Regexp (g-regexp.ads)::
13333 * GNAT.Registry (g-regist.ads)::
13334 * GNAT.Regpat (g-regpat.ads)::
13335 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13336 * GNAT.Semaphores (g-semaph.ads)::
13337 * GNAT.Serial_Communications (g-sercom.ads)::
13338 * GNAT.SHA1 (g-sha1.ads)::
13339 * GNAT.Signals (g-signal.ads)::
13340 * GNAT.Sockets (g-socket.ads)::
13341 * GNAT.Source_Info (g-souinf.ads)::
13342 * GNAT.Spelling_Checker (g-speche.ads)::
13343 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13344 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13345 * GNAT.Spitbol (g-spitbo.ads)::
13346 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13347 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13348 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13349 * GNAT.Strings (g-string.ads)::
13350 * GNAT.String_Split (g-strspl.ads)::
13351 * GNAT.Table (g-table.ads)::
13352 * GNAT.Task_Lock (g-tasloc.ads)::
13353 * GNAT.Threads (g-thread.ads)::
13354 * GNAT.Time_Stamp (g-timsta.ads)::
13355 * GNAT.Traceback (g-traceb.ads)::
13356 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13357 * GNAT.UTF_32 (g-utf_32.ads)::
13358 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13359 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13360 * GNAT.Wide_String_Split (g-wistsp.ads)::
13361 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13362 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13363 * Interfaces.C.Extensions (i-cexten.ads)::
13364 * Interfaces.C.Streams (i-cstrea.ads)::
13365 * Interfaces.CPP (i-cpp.ads)::
13366 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13367 * Interfaces.VxWorks (i-vxwork.ads)::
13368 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13369 * System.Address_Image (s-addima.ads)::
13370 * System.Assertions (s-assert.ads)::
13371 * System.Memory (s-memory.ads)::
13372 * System.Partition_Interface (s-parint.ads)::
13373 * System.Pool_Global (s-pooglo.ads)::
13374 * System.Pool_Local (s-pooloc.ads)::
13375 * System.Restrictions (s-restri.ads)::
13376 * System.Rident (s-rident.ads)::
13377 * System.Task_Info (s-tasinf.ads)::
13378 * System.Wch_Cnv (s-wchcnv.ads)::
13379 * System.Wch_Con (s-wchcon.ads)::
13382 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13383 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13384 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13385 @cindex Latin_9 constants for Character
13388 This child of @code{Ada.Characters}
13389 provides a set of definitions corresponding to those in the
13390 RM-defined package @code{Ada.Characters.Latin_1} but with the
13391 few modifications required for @code{Latin-9}
13392 The provision of such a package
13393 is specifically authorized by the Ada Reference Manual
13396 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13397 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13398 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13399 @cindex Latin_1 constants for Wide_Character
13402 This child of @code{Ada.Characters}
13403 provides a set of definitions corresponding to those in the
13404 RM-defined package @code{Ada.Characters.Latin_1} but with the
13405 types of the constants being @code{Wide_Character}
13406 instead of @code{Character}. The provision of such a package
13407 is specifically authorized by the Ada Reference Manual
13410 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13411 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13412 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13413 @cindex Latin_9 constants for Wide_Character
13416 This child of @code{Ada.Characters}
13417 provides a set of definitions corresponding to those in the
13418 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13419 types of the constants being @code{Wide_Character}
13420 instead of @code{Character}. The provision of such a package
13421 is specifically authorized by the Ada Reference Manual
13424 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13425 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13426 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13427 @cindex Latin_1 constants for Wide_Wide_Character
13430 This child of @code{Ada.Characters}
13431 provides a set of definitions corresponding to those in the
13432 RM-defined package @code{Ada.Characters.Latin_1} but with the
13433 types of the constants being @code{Wide_Wide_Character}
13434 instead of @code{Character}. The provision of such a package
13435 is specifically authorized by the Ada Reference Manual
13438 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13439 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13440 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13441 @cindex Latin_9 constants for Wide_Wide_Character
13444 This child of @code{Ada.Characters}
13445 provides a set of definitions corresponding to those in the
13446 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13447 types of the constants being @code{Wide_Wide_Character}
13448 instead of @code{Character}. The provision of such a package
13449 is specifically authorized by the Ada Reference Manual
13452 @node Ada.Command_Line.Environment (a-colien.ads)
13453 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13454 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13455 @cindex Environment entries
13458 This child of @code{Ada.Command_Line}
13459 provides a mechanism for obtaining environment values on systems
13460 where this concept makes sense.
13462 @node Ada.Command_Line.Remove (a-colire.ads)
13463 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13464 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13465 @cindex Removing command line arguments
13466 @cindex Command line, argument removal
13469 This child of @code{Ada.Command_Line}
13470 provides a mechanism for logically removing
13471 arguments from the argument list. Once removed, an argument is not visible
13472 to further calls on the subprograms in @code{Ada.Command_Line} will not
13473 see the removed argument.
13475 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13476 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13477 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13478 @cindex Response file for command line
13479 @cindex Command line, response file
13480 @cindex Command line, handling long command lines
13483 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13484 getting command line arguments from a text file, called a "response file".
13485 Using a response file allow passing a set of arguments to an executable longer
13486 than the maximum allowed by the system on the command line.
13488 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13489 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13490 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13491 @cindex C Streams, Interfacing with Direct_IO
13494 This package provides subprograms that allow interfacing between
13495 C streams and @code{Direct_IO}. The stream identifier can be
13496 extracted from a file opened on the Ada side, and an Ada file
13497 can be constructed from a stream opened on the C side.
13499 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13500 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13501 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13502 @cindex Null_Occurrence, testing for
13505 This child subprogram provides a way of testing for the null
13506 exception occurrence (@code{Null_Occurrence}) without raising
13509 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13510 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13511 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13512 @cindex Null_Occurrence, testing for
13515 This child subprogram is used for handling otherwise unhandled
13516 exceptions (hence the name last chance), and perform clean ups before
13517 terminating the program. Note that this subprogram never returns.
13519 @node Ada.Exceptions.Traceback (a-exctra.ads)
13520 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13521 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13522 @cindex Traceback for Exception Occurrence
13525 This child package provides the subprogram (@code{Tracebacks}) to
13526 give a traceback array of addresses based on an exception
13529 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13530 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13531 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13532 @cindex C Streams, Interfacing with Sequential_IO
13535 This package provides subprograms that allow interfacing between
13536 C streams and @code{Sequential_IO}. The stream identifier can be
13537 extracted from a file opened on the Ada side, and an Ada file
13538 can be constructed from a stream opened on the C side.
13540 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13541 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13542 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13543 @cindex C Streams, Interfacing with Stream_IO
13546 This package provides subprograms that allow interfacing between
13547 C streams and @code{Stream_IO}. The stream identifier can be
13548 extracted from a file opened on the Ada side, and an Ada file
13549 can be constructed from a stream opened on the C side.
13551 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13552 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13553 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13554 @cindex @code{Unbounded_String}, IO support
13555 @cindex @code{Text_IO}, extensions for unbounded strings
13558 This package provides subprograms for Text_IO for unbounded
13559 strings, avoiding the necessity for an intermediate operation
13560 with ordinary strings.
13562 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13563 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13564 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13565 @cindex @code{Unbounded_Wide_String}, IO support
13566 @cindex @code{Text_IO}, extensions for unbounded wide strings
13569 This package provides subprograms for Text_IO for unbounded
13570 wide strings, avoiding the necessity for an intermediate operation
13571 with ordinary wide strings.
13573 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13574 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13575 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13576 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13577 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13580 This package provides subprograms for Text_IO for unbounded
13581 wide wide strings, avoiding the necessity for an intermediate operation
13582 with ordinary wide wide strings.
13584 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13585 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13586 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13587 @cindex C Streams, Interfacing with @code{Text_IO}
13590 This package provides subprograms that allow interfacing between
13591 C streams and @code{Text_IO}. The stream identifier can be
13592 extracted from a file opened on the Ada side, and an Ada file
13593 can be constructed from a stream opened on the C side.
13595 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
13596 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13597 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13598 @cindex Unicode categorization, Wide_Character
13601 This package provides subprograms that allow categorization of
13602 Wide_Character values according to Unicode categories.
13604 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13605 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13606 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13607 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13610 This package provides subprograms that allow interfacing between
13611 C streams and @code{Wide_Text_IO}. The stream identifier can be
13612 extracted from a file opened on the Ada side, and an Ada file
13613 can be constructed from a stream opened on the C side.
13615 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13616 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13617 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13618 @cindex Unicode categorization, Wide_Wide_Character
13621 This package provides subprograms that allow categorization of
13622 Wide_Wide_Character values according to Unicode categories.
13624 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13625 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13626 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13627 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13630 This package provides subprograms that allow interfacing between
13631 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
13632 extracted from a file opened on the Ada side, and an Ada file
13633 can be constructed from a stream opened on the C side.
13635 @node GNAT.Altivec (g-altive.ads)
13636 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13637 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13641 This is the root package of the GNAT AltiVec binding. It provides
13642 definitions of constants and types common to all the versions of the
13645 @node GNAT.Altivec.Conversions (g-altcon.ads)
13646 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13647 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13651 This package provides the Vector/View conversion routines.
13653 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13654 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13655 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13659 This package exposes the Ada interface to the AltiVec operations on
13660 vector objects. A soft emulation is included by default in the GNAT
13661 library. The hard binding is provided as a separate package. This unit
13662 is common to both bindings.
13664 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13665 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13666 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13670 This package exposes the various vector types part of the Ada binding
13671 to AltiVec facilities.
13673 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13674 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13675 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13679 This package provides public 'View' data types from/to which private
13680 vector representations can be converted via
13681 GNAT.Altivec.Conversions. This allows convenient access to individual
13682 vector elements and provides a simple way to initialize vector
13685 @node GNAT.Array_Split (g-arrspl.ads)
13686 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13687 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13688 @cindex Array splitter
13691 Useful array-manipulation routines: given a set of separators, split
13692 an array wherever the separators appear, and provide direct access
13693 to the resulting slices.
13695 @node GNAT.AWK (g-awk.ads)
13696 @section @code{GNAT.AWK} (@file{g-awk.ads})
13697 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13702 Provides AWK-like parsing functions, with an easy interface for parsing one
13703 or more files containing formatted data. The file is viewed as a database
13704 where each record is a line and a field is a data element in this line.
13706 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13707 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13708 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13710 @cindex Bounded Buffers
13713 Provides a concurrent generic bounded buffer abstraction. Instances are
13714 useful directly or as parts of the implementations of other abstractions,
13717 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13718 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13719 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13724 Provides a thread-safe asynchronous intertask mailbox communication facility.
13726 @node GNAT.Bubble_Sort (g-bubsor.ads)
13727 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13728 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13730 @cindex Bubble sort
13733 Provides a general implementation of bubble sort usable for sorting arbitrary
13734 data items. Exchange and comparison procedures are provided by passing
13735 access-to-procedure values.
13737 @node GNAT.Bubble_Sort_A (g-busora.ads)
13738 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13739 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13741 @cindex Bubble sort
13744 Provides a general implementation of bubble sort usable for sorting arbitrary
13745 data items. Move and comparison procedures are provided by passing
13746 access-to-procedure values. This is an older version, retained for
13747 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13749 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13750 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13751 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13753 @cindex Bubble sort
13756 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13757 are provided as generic parameters, this improves efficiency, especially
13758 if the procedures can be inlined, at the expense of duplicating code for
13759 multiple instantiations.
13761 @node GNAT.Byte_Order_Mark (g-byorma.ads)
13762 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13763 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13764 @cindex UTF-8 representation
13765 @cindex Wide characte representations
13768 Provides a routine which given a string, reads the start of the string to
13769 see whether it is one of the standard byte order marks (BOM's) which signal
13770 the encoding of the string. The routine includes detection of special XML
13771 sequences for various UCS input formats.
13773 @node GNAT.Byte_Swapping (g-bytswa.ads)
13774 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13775 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13776 @cindex Byte swapping
13780 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13781 Machine-specific implementations are available in some cases.
13783 @node GNAT.Calendar (g-calend.ads)
13784 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13785 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13786 @cindex @code{Calendar}
13789 Extends the facilities provided by @code{Ada.Calendar} to include handling
13790 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13791 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
13792 C @code{timeval} format.
13794 @node GNAT.Calendar.Time_IO (g-catiio.ads)
13795 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13796 @cindex @code{Calendar}
13798 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13800 @node GNAT.CRC32 (g-crc32.ads)
13801 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
13802 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
13804 @cindex Cyclic Redundancy Check
13807 This package implements the CRC-32 algorithm. For a full description
13808 of this algorithm see
13809 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
13810 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
13811 Aug.@: 1988. Sarwate, D.V@.
13813 @node GNAT.Case_Util (g-casuti.ads)
13814 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
13815 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
13816 @cindex Casing utilities
13817 @cindex Character handling (@code{GNAT.Case_Util})
13820 A set of simple routines for handling upper and lower casing of strings
13821 without the overhead of the full casing tables
13822 in @code{Ada.Characters.Handling}.
13824 @node GNAT.CGI (g-cgi.ads)
13825 @section @code{GNAT.CGI} (@file{g-cgi.ads})
13826 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
13827 @cindex CGI (Common Gateway Interface)
13830 This is a package for interfacing a GNAT program with a Web server via the
13831 Common Gateway Interface (CGI)@. Basically this package parses the CGI
13832 parameters, which are a set of key/value pairs sent by the Web server. It
13833 builds a table whose index is the key and provides some services to deal
13836 @node GNAT.CGI.Cookie (g-cgicoo.ads)
13837 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13838 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13839 @cindex CGI (Common Gateway Interface) cookie support
13840 @cindex Cookie support in CGI
13843 This is a package to interface a GNAT program with a Web server via the
13844 Common Gateway Interface (CGI). It exports services to deal with Web
13845 cookies (piece of information kept in the Web client software).
13847 @node GNAT.CGI.Debug (g-cgideb.ads)
13848 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13849 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13850 @cindex CGI (Common Gateway Interface) debugging
13853 This is a package to help debugging CGI (Common Gateway Interface)
13854 programs written in Ada.
13856 @node GNAT.Command_Line (g-comlin.ads)
13857 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
13858 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
13859 @cindex Command line
13862 Provides a high level interface to @code{Ada.Command_Line} facilities,
13863 including the ability to scan for named switches with optional parameters
13864 and expand file names using wild card notations.
13866 @node GNAT.Compiler_Version (g-comver.ads)
13867 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13868 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13869 @cindex Compiler Version
13870 @cindex Version, of compiler
13873 Provides a routine for obtaining the version of the compiler used to
13874 compile the program. More accurately this is the version of the binder
13875 used to bind the program (this will normally be the same as the version
13876 of the compiler if a consistent tool set is used to compile all units
13879 @node GNAT.Ctrl_C (g-ctrl_c.ads)
13880 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13881 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13885 Provides a simple interface to handle Ctrl-C keyboard events.
13887 @node GNAT.Current_Exception (g-curexc.ads)
13888 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13889 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13890 @cindex Current exception
13891 @cindex Exception retrieval
13894 Provides access to information on the current exception that has been raised
13895 without the need for using the Ada 95 / Ada 2005 exception choice parameter
13896 specification syntax.
13897 This is particularly useful in simulating typical facilities for
13898 obtaining information about exceptions provided by Ada 83 compilers.
13900 @node GNAT.Debug_Pools (g-debpoo.ads)
13901 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13902 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13904 @cindex Debug pools
13905 @cindex Memory corruption debugging
13908 Provide a debugging storage pools that helps tracking memory corruption
13909 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
13910 @value{EDITION} User's Guide}.
13912 @node GNAT.Debug_Utilities (g-debuti.ads)
13913 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13914 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13918 Provides a few useful utilities for debugging purposes, including conversion
13919 to and from string images of address values. Supports both C and Ada formats
13920 for hexadecimal literals.
13922 @node GNAT.Decode_String (g-decstr.ads)
13923 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
13924 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
13925 @cindex Decoding strings
13926 @cindex String decoding
13927 @cindex Wide character encoding
13932 A generic package providing routines for decoding wide character and wide wide
13933 character strings encoded as sequences of 8-bit characters using a specified
13934 encoding method. Includes validation routines, and also routines for stepping
13935 to next or previous encoded character in an encoded string.
13936 Useful in conjunction with Unicode character coding. Note there is a
13937 preinstantiation for UTF-8. See next entry.
13939 @node GNAT.Decode_UTF8_String (g-deutst.ads)
13940 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13941 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13942 @cindex Decoding strings
13943 @cindex Decoding UTF-8 strings
13944 @cindex UTF-8 string decoding
13945 @cindex Wide character decoding
13950 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
13952 @node GNAT.Directory_Operations (g-dirope.ads)
13953 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13954 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13955 @cindex Directory operations
13958 Provides a set of routines for manipulating directories, including changing
13959 the current directory, making new directories, and scanning the files in a
13962 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
13963 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
13964 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
13965 @cindex Directory operations iteration
13968 A child unit of GNAT.Directory_Operations providing additional operations
13969 for iterating through directories.
13971 @node GNAT.Dynamic_HTables (g-dynhta.ads)
13972 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13973 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13974 @cindex Hash tables
13977 A generic implementation of hash tables that can be used to hash arbitrary
13978 data. Provided in two forms, a simple form with built in hash functions,
13979 and a more complex form in which the hash function is supplied.
13982 This package provides a facility similar to that of @code{GNAT.HTable},
13983 except that this package declares a type that can be used to define
13984 dynamic instances of the hash table, while an instantiation of
13985 @code{GNAT.HTable} creates a single instance of the hash table.
13987 @node GNAT.Dynamic_Tables (g-dyntab.ads)
13988 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13989 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13990 @cindex Table implementation
13991 @cindex Arrays, extendable
13994 A generic package providing a single dimension array abstraction where the
13995 length of the array can be dynamically modified.
13998 This package provides a facility similar to that of @code{GNAT.Table},
13999 except that this package declares a type that can be used to define
14000 dynamic instances of the table, while an instantiation of
14001 @code{GNAT.Table} creates a single instance of the table type.
14003 @node GNAT.Encode_String (g-encstr.ads)
14004 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14005 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14006 @cindex Encoding strings
14007 @cindex String encoding
14008 @cindex Wide character encoding
14013 A generic package providing routines for encoding wide character and wide
14014 wide character strings as sequences of 8-bit characters using a specified
14015 encoding method. Useful in conjunction with Unicode character coding.
14016 Note there is a preinstantiation for UTF-8. See next entry.
14018 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14019 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14020 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14021 @cindex Encoding strings
14022 @cindex Encoding UTF-8 strings
14023 @cindex UTF-8 string encoding
14024 @cindex Wide character encoding
14029 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14031 @node GNAT.Exception_Actions (g-excact.ads)
14032 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14033 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14034 @cindex Exception actions
14037 Provides callbacks when an exception is raised. Callbacks can be registered
14038 for specific exceptions, or when any exception is raised. This
14039 can be used for instance to force a core dump to ease debugging.
14041 @node GNAT.Exception_Traces (g-exctra.ads)
14042 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14043 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14044 @cindex Exception traces
14048 Provides an interface allowing to control automatic output upon exception
14051 @node GNAT.Exceptions (g-except.ads)
14052 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14053 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14054 @cindex Exceptions, Pure
14055 @cindex Pure packages, exceptions
14058 Normally it is not possible to raise an exception with
14059 a message from a subprogram in a pure package, since the
14060 necessary types and subprograms are in @code{Ada.Exceptions}
14061 which is not a pure unit. @code{GNAT.Exceptions} provides a
14062 facility for getting around this limitation for a few
14063 predefined exceptions, and for example allow raising
14064 @code{Constraint_Error} with a message from a pure subprogram.
14066 @node GNAT.Expect (g-expect.ads)
14067 @section @code{GNAT.Expect} (@file{g-expect.ads})
14068 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14071 Provides a set of subprograms similar to what is available
14072 with the standard Tcl Expect tool.
14073 It allows you to easily spawn and communicate with an external process.
14074 You can send commands or inputs to the process, and compare the output
14075 with some expected regular expression. Currently @code{GNAT.Expect}
14076 is implemented on all native GNAT ports except for OpenVMS@.
14077 It is not implemented for cross ports, and in particular is not
14078 implemented for VxWorks or LynxOS@.
14080 @node GNAT.Float_Control (g-flocon.ads)
14081 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14082 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14083 @cindex Floating-Point Processor
14086 Provides an interface for resetting the floating-point processor into the
14087 mode required for correct semantic operation in Ada. Some third party
14088 library calls may cause this mode to be modified, and the Reset procedure
14089 in this package can be used to reestablish the required mode.
14091 @node GNAT.Heap_Sort (g-heasor.ads)
14092 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14093 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14097 Provides a general implementation of heap sort usable for sorting arbitrary
14098 data items. Exchange and comparison procedures are provided by passing
14099 access-to-procedure values. The algorithm used is a modified heap sort
14100 that performs approximately N*log(N) comparisons in the worst case.
14102 @node GNAT.Heap_Sort_A (g-hesora.ads)
14103 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14104 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14108 Provides a general implementation of heap sort usable for sorting arbitrary
14109 data items. Move and comparison procedures are provided by passing
14110 access-to-procedure values. The algorithm used is a modified heap sort
14111 that performs approximately N*log(N) comparisons in the worst case.
14112 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14113 interface, but may be slightly more efficient.
14115 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14116 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14117 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14121 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14122 are provided as generic parameters, this improves efficiency, especially
14123 if the procedures can be inlined, at the expense of duplicating code for
14124 multiple instantiations.
14126 @node GNAT.HTable (g-htable.ads)
14127 @section @code{GNAT.HTable} (@file{g-htable.ads})
14128 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14129 @cindex Hash tables
14132 A generic implementation of hash tables that can be used to hash arbitrary
14133 data. Provides two approaches, one a simple static approach, and the other
14134 allowing arbitrary dynamic hash tables.
14136 @node GNAT.IO (g-io.ads)
14137 @section @code{GNAT.IO} (@file{g-io.ads})
14138 @cindex @code{GNAT.IO} (@file{g-io.ads})
14140 @cindex Input/Output facilities
14143 A simple preelaborable input-output package that provides a subset of
14144 simple Text_IO functions for reading characters and strings from
14145 Standard_Input, and writing characters, strings and integers to either
14146 Standard_Output or Standard_Error.
14148 @node GNAT.IO_Aux (g-io_aux.ads)
14149 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14150 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14152 @cindex Input/Output facilities
14154 Provides some auxiliary functions for use with Text_IO, including a test
14155 for whether a file exists, and functions for reading a line of text.
14157 @node GNAT.Lock_Files (g-locfil.ads)
14158 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14159 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14160 @cindex File locking
14161 @cindex Locking using files
14164 Provides a general interface for using files as locks. Can be used for
14165 providing program level synchronization.
14167 @node GNAT.MD5 (g-md5.ads)
14168 @section @code{GNAT.MD5} (@file{g-md5.ads})
14169 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14170 @cindex Message Digest MD5
14173 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14175 @node GNAT.Memory_Dump (g-memdum.ads)
14176 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14177 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14178 @cindex Dump Memory
14181 Provides a convenient routine for dumping raw memory to either the
14182 standard output or standard error files. Uses GNAT.IO for actual
14185 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14186 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14187 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14188 @cindex Exception, obtaining most recent
14191 Provides access to the most recently raised exception. Can be used for
14192 various logging purposes, including duplicating functionality of some
14193 Ada 83 implementation dependent extensions.
14195 @node GNAT.OS_Lib (g-os_lib.ads)
14196 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14197 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14198 @cindex Operating System interface
14199 @cindex Spawn capability
14202 Provides a range of target independent operating system interface functions,
14203 including time/date management, file operations, subprocess management,
14204 including a portable spawn procedure, and access to environment variables
14205 and error return codes.
14207 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14208 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14209 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14210 @cindex Hash functions
14213 Provides a generator of static minimal perfect hash functions. No
14214 collisions occur and each item can be retrieved from the table in one
14215 probe (perfect property). The hash table size corresponds to the exact
14216 size of the key set and no larger (minimal property). The key set has to
14217 be know in advance (static property). The hash functions are also order
14218 preserving. If w2 is inserted after w1 in the generator, their
14219 hashcode are in the same order. These hashing functions are very
14220 convenient for use with realtime applications.
14222 @node GNAT.Random_Numbers (g-rannum.ads)
14223 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14224 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14225 @cindex Random number generation
14228 Provides random number capabilities which extend those available in the
14229 standard Ada library and are more convenient to use.
14231 @node GNAT.Regexp (g-regexp.ads)
14232 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14233 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14234 @cindex Regular expressions
14235 @cindex Pattern matching
14238 A simple implementation of regular expressions, using a subset of regular
14239 expression syntax copied from familiar Unix style utilities. This is the
14240 simples of the three pattern matching packages provided, and is particularly
14241 suitable for ``file globbing'' applications.
14243 @node GNAT.Registry (g-regist.ads)
14244 @section @code{GNAT.Registry} (@file{g-regist.ads})
14245 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14246 @cindex Windows Registry
14249 This is a high level binding to the Windows registry. It is possible to
14250 do simple things like reading a key value, creating a new key. For full
14251 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14252 package provided with the Win32Ada binding
14254 @node GNAT.Regpat (g-regpat.ads)
14255 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14256 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14257 @cindex Regular expressions
14258 @cindex Pattern matching
14261 A complete implementation of Unix-style regular expression matching, copied
14262 from the original V7 style regular expression library written in C by
14263 Henry Spencer (and binary compatible with this C library).
14265 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14266 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14267 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14268 @cindex Secondary Stack Info
14271 Provide the capability to query the high water mark of the current task's
14274 @node GNAT.Semaphores (g-semaph.ads)
14275 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14276 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14280 Provides classic counting and binary semaphores using protected types.
14282 @node GNAT.Serial_Communications (g-sercom.ads)
14283 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14284 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14285 @cindex Serial_Communications
14288 Provides a simple interface to send and receive data over a serial
14289 port. This is only supported on GNU/Linux and Windows.
14291 @node GNAT.SHA1 (g-sha1.ads)
14292 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14293 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14294 @cindex Secure Hash Algorithm SHA-1
14297 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
14299 @node GNAT.Signals (g-signal.ads)
14300 @section @code{GNAT.Signals} (@file{g-signal.ads})
14301 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14305 Provides the ability to manipulate the blocked status of signals on supported
14308 @node GNAT.Sockets (g-socket.ads)
14309 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14310 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14314 A high level and portable interface to develop sockets based applications.
14315 This package is based on the sockets thin binding found in
14316 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14317 on all native GNAT ports except for OpenVMS@. It is not implemented
14318 for the LynxOS@ cross port.
14320 @node GNAT.Source_Info (g-souinf.ads)
14321 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14322 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14323 @cindex Source Information
14326 Provides subprograms that give access to source code information known at
14327 compile time, such as the current file name and line number.
14329 @node GNAT.Spelling_Checker (g-speche.ads)
14330 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14331 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14332 @cindex Spell checking
14335 Provides a function for determining whether one string is a plausible
14336 near misspelling of another string.
14338 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14339 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14340 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14341 @cindex Spell checking
14344 Provides a generic function that can be instantiated with a string type for
14345 determining whether one string is a plausible near misspelling of another
14348 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14349 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14350 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14351 @cindex SPITBOL pattern matching
14352 @cindex Pattern matching
14355 A complete implementation of SNOBOL4 style pattern matching. This is the
14356 most elaborate of the pattern matching packages provided. It fully duplicates
14357 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14358 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14360 @node GNAT.Spitbol (g-spitbo.ads)
14361 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14362 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14363 @cindex SPITBOL interface
14366 The top level package of the collection of SPITBOL-style functionality, this
14367 package provides basic SNOBOL4 string manipulation functions, such as
14368 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14369 useful for constructing arbitrary mappings from strings in the style of
14370 the SNOBOL4 TABLE function.
14372 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14373 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14374 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14375 @cindex Sets of strings
14376 @cindex SPITBOL Tables
14379 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14380 for type @code{Standard.Boolean}, giving an implementation of sets of
14383 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14384 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14385 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14386 @cindex Integer maps
14388 @cindex SPITBOL Tables
14391 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14392 for type @code{Standard.Integer}, giving an implementation of maps
14393 from string to integer values.
14395 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14396 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14397 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14398 @cindex String maps
14400 @cindex SPITBOL Tables
14403 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14404 a variable length string type, giving an implementation of general
14405 maps from strings to strings.
14407 @node GNAT.Strings (g-string.ads)
14408 @section @code{GNAT.Strings} (@file{g-string.ads})
14409 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14412 Common String access types and related subprograms. Basically it
14413 defines a string access and an array of string access types.
14415 @node GNAT.String_Split (g-strspl.ads)
14416 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14417 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14418 @cindex String splitter
14421 Useful string manipulation routines: given a set of separators, split
14422 a string wherever the separators appear, and provide direct access
14423 to the resulting slices. This package is instantiated from
14424 @code{GNAT.Array_Split}.
14426 @node GNAT.Table (g-table.ads)
14427 @section @code{GNAT.Table} (@file{g-table.ads})
14428 @cindex @code{GNAT.Table} (@file{g-table.ads})
14429 @cindex Table implementation
14430 @cindex Arrays, extendable
14433 A generic package providing a single dimension array abstraction where the
14434 length of the array can be dynamically modified.
14437 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14438 except that this package declares a single instance of the table type,
14439 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14440 used to define dynamic instances of the table.
14442 @node GNAT.Task_Lock (g-tasloc.ads)
14443 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14444 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14445 @cindex Task synchronization
14446 @cindex Task locking
14450 A very simple facility for locking and unlocking sections of code using a
14451 single global task lock. Appropriate for use in situations where contention
14452 between tasks is very rarely expected.
14454 @node GNAT.Time_Stamp (g-timsta.ads)
14455 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14456 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14458 @cindex Current time
14461 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14462 represents the current date and time in ISO 8601 format. This is a very simple
14463 routine with minimal code and there are no dependencies on any other unit.
14465 @node GNAT.Threads (g-thread.ads)
14466 @section @code{GNAT.Threads} (@file{g-thread.ads})
14467 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14468 @cindex Foreign threads
14469 @cindex Threads, foreign
14472 Provides facilities for dealing with foreign threads which need to be known
14473 by the GNAT run-time system. Consult the documentation of this package for
14474 further details if your program has threads that are created by a non-Ada
14475 environment which then accesses Ada code.
14477 @node GNAT.Traceback (g-traceb.ads)
14478 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14479 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14480 @cindex Trace back facilities
14483 Provides a facility for obtaining non-symbolic traceback information, useful
14484 in various debugging situations.
14486 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14487 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14488 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14489 @cindex Trace back facilities
14491 @node GNAT.UTF_32 (g-utf_32.ads)
14492 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14493 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14494 @cindex Wide character codes
14497 This is a package intended to be used in conjunction with the
14498 @code{Wide_Character} type in Ada 95 and the
14499 @code{Wide_Wide_Character} type in Ada 2005 (available
14500 in @code{GNAT} in Ada 2005 mode). This package contains
14501 Unicode categorization routines, as well as lexical
14502 categorization routines corresponding to the Ada 2005
14503 lexical rules for identifiers and strings, and also a
14504 lower case to upper case fold routine corresponding to
14505 the Ada 2005 rules for identifier equivalence.
14507 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14508 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14509 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14510 @cindex Spell checking
14513 Provides a function for determining whether one wide wide string is a plausible
14514 near misspelling of another wide wide string, where the strings are represented
14515 using the UTF_32_String type defined in System.Wch_Cnv.
14517 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14518 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14519 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14520 @cindex Spell checking
14523 Provides a function for determining whether one wide string is a plausible
14524 near misspelling of another wide string.
14526 @node GNAT.Wide_String_Split (g-wistsp.ads)
14527 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14528 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14529 @cindex Wide_String splitter
14532 Useful wide string manipulation routines: given a set of separators, split
14533 a wide string wherever the separators appear, and provide direct access
14534 to the resulting slices. This package is instantiated from
14535 @code{GNAT.Array_Split}.
14537 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14538 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14539 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14540 @cindex Spell checking
14543 Provides a function for determining whether one wide wide string is a plausible
14544 near misspelling of another wide wide string.
14546 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14547 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14548 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14549 @cindex Wide_Wide_String splitter
14552 Useful wide wide string manipulation routines: given a set of separators, split
14553 a wide wide string wherever the separators appear, and provide direct access
14554 to the resulting slices. This package is instantiated from
14555 @code{GNAT.Array_Split}.
14557 @node Interfaces.C.Extensions (i-cexten.ads)
14558 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14559 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14562 This package contains additional C-related definitions, intended
14563 for use with either manually or automatically generated bindings
14566 @node Interfaces.C.Streams (i-cstrea.ads)
14567 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14568 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14569 @cindex C streams, interfacing
14572 This package is a binding for the most commonly used operations
14575 @node Interfaces.CPP (i-cpp.ads)
14576 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
14577 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14578 @cindex C++ interfacing
14579 @cindex Interfacing, to C++
14582 This package provides facilities for use in interfacing to C++. It
14583 is primarily intended to be used in connection with automated tools
14584 for the generation of C++ interfaces.
14586 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14587 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14588 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14589 @cindex IBM Packed Format
14590 @cindex Packed Decimal
14593 This package provides a set of routines for conversions to and
14594 from a packed decimal format compatible with that used on IBM
14597 @node Interfaces.VxWorks (i-vxwork.ads)
14598 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14599 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14600 @cindex Interfacing to VxWorks
14601 @cindex VxWorks, interfacing
14604 This package provides a limited binding to the VxWorks API.
14605 In particular, it interfaces with the
14606 VxWorks hardware interrupt facilities.
14608 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14609 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14610 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14611 @cindex Interfacing to VxWorks' I/O
14612 @cindex VxWorks, I/O interfacing
14613 @cindex VxWorks, Get_Immediate
14614 @cindex Get_Immediate, VxWorks
14617 This package provides a binding to the ioctl (IO/Control)
14618 function of VxWorks, defining a set of option values and
14619 function codes. A particular use of this package is
14620 to enable the use of Get_Immediate under VxWorks.
14622 @node System.Address_Image (s-addima.ads)
14623 @section @code{System.Address_Image} (@file{s-addima.ads})
14624 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14625 @cindex Address image
14626 @cindex Image, of an address
14629 This function provides a useful debugging
14630 function that gives an (implementation dependent)
14631 string which identifies an address.
14633 @node System.Assertions (s-assert.ads)
14634 @section @code{System.Assertions} (@file{s-assert.ads})
14635 @cindex @code{System.Assertions} (@file{s-assert.ads})
14637 @cindex Assert_Failure, exception
14640 This package provides the declaration of the exception raised
14641 by an run-time assertion failure, as well as the routine that
14642 is used internally to raise this assertion.
14644 @node System.Memory (s-memory.ads)
14645 @section @code{System.Memory} (@file{s-memory.ads})
14646 @cindex @code{System.Memory} (@file{s-memory.ads})
14647 @cindex Memory allocation
14650 This package provides the interface to the low level routines used
14651 by the generated code for allocation and freeing storage for the
14652 default storage pool (analogous to the C routines malloc and free.
14653 It also provides a reallocation interface analogous to the C routine
14654 realloc. The body of this unit may be modified to provide alternative
14655 allocation mechanisms for the default pool, and in addition, direct
14656 calls to this unit may be made for low level allocation uses (for
14657 example see the body of @code{GNAT.Tables}).
14659 @node System.Partition_Interface (s-parint.ads)
14660 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14661 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14662 @cindex Partition interfacing functions
14665 This package provides facilities for partition interfacing. It
14666 is used primarily in a distribution context when using Annex E
14669 @node System.Pool_Global (s-pooglo.ads)
14670 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
14671 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
14672 @cindex Storage pool, global
14673 @cindex Global storage pool
14676 This package provides a storage pool that is equivalent to the default
14677 storage pool used for access types for which no pool is specifically
14678 declared. It uses malloc/free to allocate/free and does not attempt to
14679 do any automatic reclamation.
14681 @node System.Pool_Local (s-pooloc.ads)
14682 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
14683 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
14684 @cindex Storage pool, local
14685 @cindex Local storage pool
14688 This package provides a storage pool that is intended for use with locally
14689 defined access types. It uses malloc/free for allocate/free, and maintains
14690 a list of allocated blocks, so that all storage allocated for the pool can
14691 be freed automatically when the pool is finalized.
14693 @node System.Restrictions (s-restri.ads)
14694 @section @code{System.Restrictions} (@file{s-restri.ads})
14695 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14696 @cindex Run-time restrictions access
14699 This package provides facilities for accessing at run time
14700 the status of restrictions specified at compile time for
14701 the partition. Information is available both with regard
14702 to actual restrictions specified, and with regard to
14703 compiler determined information on which restrictions
14704 are violated by one or more packages in the partition.
14706 @node System.Rident (s-rident.ads)
14707 @section @code{System.Rident} (@file{s-rident.ads})
14708 @cindex @code{System.Rident} (@file{s-rident.ads})
14709 @cindex Restrictions definitions
14712 This package provides definitions of the restrictions
14713 identifiers supported by GNAT, and also the format of
14714 the restrictions provided in package System.Restrictions.
14715 It is not normally necessary to @code{with} this generic package
14716 since the necessary instantiation is included in
14717 package System.Restrictions.
14719 @node System.Task_Info (s-tasinf.ads)
14720 @section @code{System.Task_Info} (@file{s-tasinf.ads})
14721 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
14722 @cindex Task_Info pragma
14725 This package provides target dependent functionality that is used
14726 to support the @code{Task_Info} pragma
14728 @node System.Wch_Cnv (s-wchcnv.ads)
14729 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14730 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14731 @cindex Wide Character, Representation
14732 @cindex Wide String, Conversion
14733 @cindex Representation of wide characters
14736 This package provides routines for converting between
14737 wide and wide wide characters and a representation as a value of type
14738 @code{Standard.String}, using a specified wide character
14739 encoding method. It uses definitions in
14740 package @code{System.Wch_Con}.
14742 @node System.Wch_Con (s-wchcon.ads)
14743 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
14744 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
14747 This package provides definitions and descriptions of
14748 the various methods used for encoding wide characters
14749 in ordinary strings. These definitions are used by
14750 the package @code{System.Wch_Cnv}.
14752 @node Interfacing to Other Languages
14753 @chapter Interfacing to Other Languages
14755 The facilities in annex B of the Ada Reference Manual are fully
14756 implemented in GNAT, and in addition, a full interface to C++ is
14760 * Interfacing to C::
14761 * Interfacing to C++::
14762 * Interfacing to COBOL::
14763 * Interfacing to Fortran::
14764 * Interfacing to non-GNAT Ada code::
14767 @node Interfacing to C
14768 @section Interfacing to C
14771 Interfacing to C with GNAT can use one of two approaches:
14775 The types in the package @code{Interfaces.C} may be used.
14777 Standard Ada types may be used directly. This may be less portable to
14778 other compilers, but will work on all GNAT compilers, which guarantee
14779 correspondence between the C and Ada types.
14783 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
14784 effect, since this is the default. The following table shows the
14785 correspondence between Ada scalar types and the corresponding C types.
14790 @item Short_Integer
14792 @item Short_Short_Integer
14796 @item Long_Long_Integer
14804 @item Long_Long_Float
14805 This is the longest floating-point type supported by the hardware.
14809 Additionally, there are the following general correspondences between Ada
14813 Ada enumeration types map to C enumeration types directly if pragma
14814 @code{Convention C} is specified, which causes them to have int
14815 length. Without pragma @code{Convention C}, Ada enumeration types map to
14816 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
14817 @code{int}, respectively) depending on the number of values passed.
14818 This is the only case in which pragma @code{Convention C} affects the
14819 representation of an Ada type.
14822 Ada access types map to C pointers, except for the case of pointers to
14823 unconstrained types in Ada, which have no direct C equivalent.
14826 Ada arrays map directly to C arrays.
14829 Ada records map directly to C structures.
14832 Packed Ada records map to C structures where all members are bit fields
14833 of the length corresponding to the @code{@var{type}'Size} value in Ada.
14836 @node Interfacing to C++
14837 @section Interfacing to C++
14840 The interface to C++ makes use of the following pragmas, which are
14841 primarily intended to be constructed automatically using a binding generator
14842 tool, although it is possible to construct them by hand. No suitable binding
14843 generator tool is supplied with GNAT though.
14845 Using these pragmas it is possible to achieve complete
14846 inter-operability between Ada tagged types and C++ class definitions.
14847 See @ref{Implementation Defined Pragmas}, for more details.
14850 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
14851 The argument denotes an entity in the current declarative region that is
14852 declared as a tagged or untagged record type. It indicates that the type
14853 corresponds to an externally declared C++ class type, and is to be laid
14854 out the same way that C++ would lay out the type.
14856 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
14857 for backward compatibility but its functionality is available
14858 using pragma @code{Import} with @code{Convention} = @code{CPP}.
14860 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
14861 This pragma identifies an imported function (imported in the usual way
14862 with pragma @code{Import}) as corresponding to a C++ constructor.
14865 @node Interfacing to COBOL
14866 @section Interfacing to COBOL
14869 Interfacing to COBOL is achieved as described in section B.4 of
14870 the Ada Reference Manual.
14872 @node Interfacing to Fortran
14873 @section Interfacing to Fortran
14876 Interfacing to Fortran is achieved as described in section B.5 of the
14877 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
14878 multi-dimensional array causes the array to be stored in column-major
14879 order as required for convenient interface to Fortran.
14881 @node Interfacing to non-GNAT Ada code
14882 @section Interfacing to non-GNAT Ada code
14884 It is possible to specify the convention @code{Ada} in a pragma
14885 @code{Import} or pragma @code{Export}. However this refers to
14886 the calling conventions used by GNAT, which may or may not be
14887 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
14888 compiler to allow interoperation.
14890 If arguments types are kept simple, and if the foreign compiler generally
14891 follows system calling conventions, then it may be possible to integrate
14892 files compiled by other Ada compilers, provided that the elaboration
14893 issues are adequately addressed (for example by eliminating the
14894 need for any load time elaboration).
14896 In particular, GNAT running on VMS is designed to
14897 be highly compatible with the DEC Ada 83 compiler, so this is one
14898 case in which it is possible to import foreign units of this type,
14899 provided that the data items passed are restricted to simple scalar
14900 values or simple record types without variants, or simple array
14901 types with fixed bounds.
14903 @node Specialized Needs Annexes
14904 @chapter Specialized Needs Annexes
14907 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
14908 required in all implementations. However, as described in this chapter,
14909 GNAT implements all of these annexes:
14912 @item Systems Programming (Annex C)
14913 The Systems Programming Annex is fully implemented.
14915 @item Real-Time Systems (Annex D)
14916 The Real-Time Systems Annex is fully implemented.
14918 @item Distributed Systems (Annex E)
14919 Stub generation is fully implemented in the GNAT compiler. In addition,
14920 a complete compatible PCS is available as part of the GLADE system,
14921 a separate product. When the two
14922 products are used in conjunction, this annex is fully implemented.
14924 @item Information Systems (Annex F)
14925 The Information Systems annex is fully implemented.
14927 @item Numerics (Annex G)
14928 The Numerics Annex is fully implemented.
14930 @item Safety and Security / High-Integrity Systems (Annex H)
14931 The Safety and Security Annex (termed the High-Integrity Systems Annex
14932 in Ada 2005) is fully implemented.
14935 @node Implementation of Specific Ada Features
14936 @chapter Implementation of Specific Ada Features
14939 This chapter describes the GNAT implementation of several Ada language
14943 * Machine Code Insertions::
14944 * GNAT Implementation of Tasking::
14945 * GNAT Implementation of Shared Passive Packages::
14946 * Code Generation for Array Aggregates::
14947 * The Size of Discriminated Records with Default Discriminants::
14948 * Strict Conformance to the Ada Reference Manual::
14951 @node Machine Code Insertions
14952 @section Machine Code Insertions
14953 @cindex Machine Code insertions
14956 Package @code{Machine_Code} provides machine code support as described
14957 in the Ada Reference Manual in two separate forms:
14960 Machine code statements, consisting of qualified expressions that
14961 fit the requirements of RM section 13.8.
14963 An intrinsic callable procedure, providing an alternative mechanism of
14964 including machine instructions in a subprogram.
14968 The two features are similar, and both are closely related to the mechanism
14969 provided by the asm instruction in the GNU C compiler. Full understanding
14970 and use of the facilities in this package requires understanding the asm
14971 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
14972 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
14974 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
14975 semantic restrictions and effects as described below. Both are provided so
14976 that the procedure call can be used as a statement, and the function call
14977 can be used to form a code_statement.
14979 The first example given in the GCC documentation is the C @code{asm}
14982 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
14986 The equivalent can be written for GNAT as:
14988 @smallexample @c ada
14989 Asm ("fsinx %1 %0",
14990 My_Float'Asm_Output ("=f", result),
14991 My_Float'Asm_Input ("f", angle));
14995 The first argument to @code{Asm} is the assembler template, and is
14996 identical to what is used in GNU C@. This string must be a static
14997 expression. The second argument is the output operand list. It is
14998 either a single @code{Asm_Output} attribute reference, or a list of such
14999 references enclosed in parentheses (technically an array aggregate of
15002 The @code{Asm_Output} attribute denotes a function that takes two
15003 parameters. The first is a string, the second is the name of a variable
15004 of the type designated by the attribute prefix. The first (string)
15005 argument is required to be a static expression and designates the
15006 constraint for the parameter (e.g.@: what kind of register is
15007 required). The second argument is the variable to be updated with the
15008 result. The possible values for constraint are the same as those used in
15009 the RTL, and are dependent on the configuration file used to build the
15010 GCC back end. If there are no output operands, then this argument may
15011 either be omitted, or explicitly given as @code{No_Output_Operands}.
15013 The second argument of @code{@var{my_float}'Asm_Output} functions as
15014 though it were an @code{out} parameter, which is a little curious, but
15015 all names have the form of expressions, so there is no syntactic
15016 irregularity, even though normally functions would not be permitted
15017 @code{out} parameters. The third argument is the list of input
15018 operands. It is either a single @code{Asm_Input} attribute reference, or
15019 a list of such references enclosed in parentheses (technically an array
15020 aggregate of such references).
15022 The @code{Asm_Input} attribute denotes a function that takes two
15023 parameters. The first is a string, the second is an expression of the
15024 type designated by the prefix. The first (string) argument is required
15025 to be a static expression, and is the constraint for the parameter,
15026 (e.g.@: what kind of register is required). The second argument is the
15027 value to be used as the input argument. The possible values for the
15028 constant are the same as those used in the RTL, and are dependent on
15029 the configuration file used to built the GCC back end.
15031 If there are no input operands, this argument may either be omitted, or
15032 explicitly given as @code{No_Input_Operands}. The fourth argument, not
15033 present in the above example, is a list of register names, called the
15034 @dfn{clobber} argument. This argument, if given, must be a static string
15035 expression, and is a space or comma separated list of names of registers
15036 that must be considered destroyed as a result of the @code{Asm} call. If
15037 this argument is the null string (the default value), then the code
15038 generator assumes that no additional registers are destroyed.
15040 The fifth argument, not present in the above example, called the
15041 @dfn{volatile} argument, is by default @code{False}. It can be set to
15042 the literal value @code{True} to indicate to the code generator that all
15043 optimizations with respect to the instruction specified should be
15044 suppressed, and that in particular, for an instruction that has outputs,
15045 the instruction will still be generated, even if none of the outputs are
15046 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15047 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15048 Generally it is strongly advisable to use Volatile for any ASM statement
15049 that is missing either input or output operands, or when two or more ASM
15050 statements appear in sequence, to avoid unwanted optimizations. A warning
15051 is generated if this advice is not followed.
15053 The @code{Asm} subprograms may be used in two ways. First the procedure
15054 forms can be used anywhere a procedure call would be valid, and
15055 correspond to what the RM calls ``intrinsic'' routines. Such calls can
15056 be used to intersperse machine instructions with other Ada statements.
15057 Second, the function forms, which return a dummy value of the limited
15058 private type @code{Asm_Insn}, can be used in code statements, and indeed
15059 this is the only context where such calls are allowed. Code statements
15060 appear as aggregates of the form:
15062 @smallexample @c ada
15063 Asm_Insn'(Asm (@dots{}));
15064 Asm_Insn'(Asm_Volatile (@dots{}));
15068 In accordance with RM rules, such code statements are allowed only
15069 within subprograms whose entire body consists of such statements. It is
15070 not permissible to intermix such statements with other Ada statements.
15072 Typically the form using intrinsic procedure calls is more convenient
15073 and more flexible. The code statement form is provided to meet the RM
15074 suggestion that such a facility should be made available. The following
15075 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15076 is used, the arguments may be given in arbitrary order, following the
15077 normal rules for use of positional and named arguments)
15081 [Template =>] static_string_EXPRESSION
15082 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
15083 [,[Inputs =>] INPUT_OPERAND_LIST ]
15084 [,[Clobber =>] static_string_EXPRESSION ]
15085 [,[Volatile =>] static_boolean_EXPRESSION] )
15087 OUTPUT_OPERAND_LIST ::=
15088 [PREFIX.]No_Output_Operands
15089 | OUTPUT_OPERAND_ATTRIBUTE
15090 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15092 OUTPUT_OPERAND_ATTRIBUTE ::=
15093 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15095 INPUT_OPERAND_LIST ::=
15096 [PREFIX.]No_Input_Operands
15097 | INPUT_OPERAND_ATTRIBUTE
15098 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15100 INPUT_OPERAND_ATTRIBUTE ::=
15101 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15105 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15106 are declared in the package @code{Machine_Code} and must be referenced
15107 according to normal visibility rules. In particular if there is no
15108 @code{use} clause for this package, then appropriate package name
15109 qualification is required.
15111 @node GNAT Implementation of Tasking
15112 @section GNAT Implementation of Tasking
15115 This chapter outlines the basic GNAT approach to tasking (in particular,
15116 a multi-layered library for portability) and discusses issues related
15117 to compliance with the Real-Time Systems Annex.
15120 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15121 * Ensuring Compliance with the Real-Time Annex::
15124 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15125 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15128 GNAT's run-time support comprises two layers:
15131 @item GNARL (GNAT Run-time Layer)
15132 @item GNULL (GNAT Low-level Library)
15136 In GNAT, Ada's tasking services rely on a platform and OS independent
15137 layer known as GNARL@. This code is responsible for implementing the
15138 correct semantics of Ada's task creation, rendezvous, protected
15141 GNARL decomposes Ada's tasking semantics into simpler lower level
15142 operations such as create a thread, set the priority of a thread,
15143 yield, create a lock, lock/unlock, etc. The spec for these low-level
15144 operations constitutes GNULLI, the GNULL Interface. This interface is
15145 directly inspired from the POSIX real-time API@.
15147 If the underlying executive or OS implements the POSIX standard
15148 faithfully, the GNULL Interface maps as is to the services offered by
15149 the underlying kernel. Otherwise, some target dependent glue code maps
15150 the services offered by the underlying kernel to the semantics expected
15153 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
15154 key point is that each Ada task is mapped on a thread in the underlying
15155 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
15157 In addition Ada task priorities map onto the underlying thread priorities.
15158 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15162 The underlying scheduler is used to schedule the Ada tasks. This
15163 makes Ada tasks as efficient as kernel threads from a scheduling
15167 Interaction with code written in C containing threads is eased
15168 since at the lowest level Ada tasks and C threads map onto the same
15169 underlying kernel concept.
15172 When an Ada task is blocked during I/O the remaining Ada tasks are
15176 On multiprocessor systems Ada tasks can execute in parallel.
15180 Some threads libraries offer a mechanism to fork a new process, with the
15181 child process duplicating the threads from the parent.
15183 support this functionality when the parent contains more than one task.
15184 @cindex Forking a new process
15186 @node Ensuring Compliance with the Real-Time Annex
15187 @subsection Ensuring Compliance with the Real-Time Annex
15188 @cindex Real-Time Systems Annex compliance
15191 Although mapping Ada tasks onto
15192 the underlying threads has significant advantages, it does create some
15193 complications when it comes to respecting the scheduling semantics
15194 specified in the real-time annex (Annex D).
15196 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15197 scheduling policy states:
15200 @emph{When the active priority of a ready task that is not running
15201 changes, or the setting of its base priority takes effect, the
15202 task is removed from the ready queue for its old active priority
15203 and is added at the tail of the ready queue for its new active
15204 priority, except in the case where the active priority is lowered
15205 due to the loss of inherited priority, in which case the task is
15206 added at the head of the ready queue for its new active priority.}
15210 While most kernels do put tasks at the end of the priority queue when
15211 a task changes its priority, (which respects the main
15212 FIFO_Within_Priorities requirement), almost none keep a thread at the
15213 beginning of its priority queue when its priority drops from the loss
15214 of inherited priority.
15216 As a result most vendors have provided incomplete Annex D implementations.
15218 The GNAT run-time, has a nice cooperative solution to this problem
15219 which ensures that accurate FIFO_Within_Priorities semantics are
15222 The principle is as follows. When an Ada task T is about to start
15223 running, it checks whether some other Ada task R with the same
15224 priority as T has been suspended due to the loss of priority
15225 inheritance. If this is the case, T yields and is placed at the end of
15226 its priority queue. When R arrives at the front of the queue it
15229 Note that this simple scheme preserves the relative order of the tasks
15230 that were ready to execute in the priority queue where R has been
15233 @node GNAT Implementation of Shared Passive Packages
15234 @section GNAT Implementation of Shared Passive Packages
15235 @cindex Shared passive packages
15238 GNAT fully implements the pragma @code{Shared_Passive} for
15239 @cindex pragma @code{Shared_Passive}
15240 the purpose of designating shared passive packages.
15241 This allows the use of passive partitions in the
15242 context described in the Ada Reference Manual; i.e., for communication
15243 between separate partitions of a distributed application using the
15244 features in Annex E.
15246 @cindex Distribution Systems Annex
15248 However, the implementation approach used by GNAT provides for more
15249 extensive usage as follows:
15252 @item Communication between separate programs
15254 This allows separate programs to access the data in passive
15255 partitions, using protected objects for synchronization where
15256 needed. The only requirement is that the two programs have a
15257 common shared file system. It is even possible for programs
15258 running on different machines with different architectures
15259 (e.g.@: different endianness) to communicate via the data in
15260 a passive partition.
15262 @item Persistence between program runs
15264 The data in a passive package can persist from one run of a
15265 program to another, so that a later program sees the final
15266 values stored by a previous run of the same program.
15271 The implementation approach used is to store the data in files. A
15272 separate stream file is created for each object in the package, and
15273 an access to an object causes the corresponding file to be read or
15276 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15277 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15278 set to the directory to be used for these files.
15279 The files in this directory
15280 have names that correspond to their fully qualified names. For
15281 example, if we have the package
15283 @smallexample @c ada
15285 pragma Shared_Passive (X);
15292 and the environment variable is set to @code{/stemp/}, then the files created
15293 will have the names:
15301 These files are created when a value is initially written to the object, and
15302 the files are retained until manually deleted. This provides the persistence
15303 semantics. If no file exists, it means that no partition has assigned a value
15304 to the variable; in this case the initial value declared in the package
15305 will be used. This model ensures that there are no issues in synchronizing
15306 the elaboration process, since elaboration of passive packages elaborates the
15307 initial values, but does not create the files.
15309 The files are written using normal @code{Stream_IO} access.
15310 If you want to be able
15311 to communicate between programs or partitions running on different
15312 architectures, then you should use the XDR versions of the stream attribute
15313 routines, since these are architecture independent.
15315 If active synchronization is required for access to the variables in the
15316 shared passive package, then as described in the Ada Reference Manual, the
15317 package may contain protected objects used for this purpose. In this case
15318 a lock file (whose name is @file{___lock} (three underscores)
15319 is created in the shared memory directory.
15320 @cindex @file{___lock} file (for shared passive packages)
15321 This is used to provide the required locking
15322 semantics for proper protected object synchronization.
15324 As of January 2003, GNAT supports shared passive packages on all platforms
15325 except for OpenVMS.
15327 @node Code Generation for Array Aggregates
15328 @section Code Generation for Array Aggregates
15331 * Static constant aggregates with static bounds::
15332 * Constant aggregates with unconstrained nominal types::
15333 * Aggregates with static bounds::
15334 * Aggregates with non-static bounds::
15335 * Aggregates in assignment statements::
15339 Aggregates have a rich syntax and allow the user to specify the values of
15340 complex data structures by means of a single construct. As a result, the
15341 code generated for aggregates can be quite complex and involve loops, case
15342 statements and multiple assignments. In the simplest cases, however, the
15343 compiler will recognize aggregates whose components and constraints are
15344 fully static, and in those cases the compiler will generate little or no
15345 executable code. The following is an outline of the code that GNAT generates
15346 for various aggregate constructs. For further details, you will find it
15347 useful to examine the output produced by the -gnatG flag to see the expanded
15348 source that is input to the code generator. You may also want to examine
15349 the assembly code generated at various levels of optimization.
15351 The code generated for aggregates depends on the context, the component values,
15352 and the type. In the context of an object declaration the code generated is
15353 generally simpler than in the case of an assignment. As a general rule, static
15354 component values and static subtypes also lead to simpler code.
15356 @node Static constant aggregates with static bounds
15357 @subsection Static constant aggregates with static bounds
15360 For the declarations:
15361 @smallexample @c ada
15362 type One_Dim is array (1..10) of integer;
15363 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15367 GNAT generates no executable code: the constant ar0 is placed in static memory.
15368 The same is true for constant aggregates with named associations:
15370 @smallexample @c ada
15371 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15372 Cr3 : constant One_Dim := (others => 7777);
15376 The same is true for multidimensional constant arrays such as:
15378 @smallexample @c ada
15379 type two_dim is array (1..3, 1..3) of integer;
15380 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15384 The same is true for arrays of one-dimensional arrays: the following are
15387 @smallexample @c ada
15388 type ar1b is array (1..3) of boolean;
15389 type ar_ar is array (1..3) of ar1b;
15390 None : constant ar1b := (others => false); -- fully static
15391 None2 : constant ar_ar := (1..3 => None); -- fully static
15395 However, for multidimensional aggregates with named associations, GNAT will
15396 generate assignments and loops, even if all associations are static. The
15397 following two declarations generate a loop for the first dimension, and
15398 individual component assignments for the second dimension:
15400 @smallexample @c ada
15401 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15402 Zero2: constant two_dim := (others => (others => 0));
15405 @node Constant aggregates with unconstrained nominal types
15406 @subsection Constant aggregates with unconstrained nominal types
15409 In such cases the aggregate itself establishes the subtype, so that
15410 associations with @code{others} cannot be used. GNAT determines the
15411 bounds for the actual subtype of the aggregate, and allocates the
15412 aggregate statically as well. No code is generated for the following:
15414 @smallexample @c ada
15415 type One_Unc is array (natural range <>) of integer;
15416 Cr_Unc : constant One_Unc := (12,24,36);
15419 @node Aggregates with static bounds
15420 @subsection Aggregates with static bounds
15423 In all previous examples the aggregate was the initial (and immutable) value
15424 of a constant. If the aggregate initializes a variable, then code is generated
15425 for it as a combination of individual assignments and loops over the target
15426 object. The declarations
15428 @smallexample @c ada
15429 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15430 Cr_Var2 : One_Dim := (others > -1);
15434 generate the equivalent of
15436 @smallexample @c ada
15442 for I in Cr_Var2'range loop
15447 @node Aggregates with non-static bounds
15448 @subsection Aggregates with non-static bounds
15451 If the bounds of the aggregate are not statically compatible with the bounds
15452 of the nominal subtype of the target, then constraint checks have to be
15453 generated on the bounds. For a multidimensional array, constraint checks may
15454 have to be applied to sub-arrays individually, if they do not have statically
15455 compatible subtypes.
15457 @node Aggregates in assignment statements
15458 @subsection Aggregates in assignment statements
15461 In general, aggregate assignment requires the construction of a temporary,
15462 and a copy from the temporary to the target of the assignment. This is because
15463 it is not always possible to convert the assignment into a series of individual
15464 component assignments. For example, consider the simple case:
15466 @smallexample @c ada
15471 This cannot be converted into:
15473 @smallexample @c ada
15479 So the aggregate has to be built first in a separate location, and then
15480 copied into the target. GNAT recognizes simple cases where this intermediate
15481 step is not required, and the assignments can be performed in place, directly
15482 into the target. The following sufficient criteria are applied:
15486 The bounds of the aggregate are static, and the associations are static.
15488 The components of the aggregate are static constants, names of
15489 simple variables that are not renamings, or expressions not involving
15490 indexed components whose operands obey these rules.
15494 If any of these conditions are violated, the aggregate will be built in
15495 a temporary (created either by the front-end or the code generator) and then
15496 that temporary will be copied onto the target.
15499 @node The Size of Discriminated Records with Default Discriminants
15500 @section The Size of Discriminated Records with Default Discriminants
15503 If a discriminated type @code{T} has discriminants with default values, it is
15504 possible to declare an object of this type without providing an explicit
15507 @smallexample @c ada
15509 type Size is range 1..100;
15511 type Rec (D : Size := 15) is record
15512 Name : String (1..D);
15520 Such an object is said to be @emph{unconstrained}.
15521 The discriminant of the object
15522 can be modified by a full assignment to the object, as long as it preserves the
15523 relation between the value of the discriminant, and the value of the components
15526 @smallexample @c ada
15528 Word := (3, "yes");
15530 Word := (5, "maybe");
15532 Word := (5, "no"); -- raises Constraint_Error
15537 In order to support this behavior efficiently, an unconstrained object is
15538 given the maximum size that any value of the type requires. In the case
15539 above, @code{Word} has storage for the discriminant and for
15540 a @code{String} of length 100.
15541 It is important to note that unconstrained objects do not require dynamic
15542 allocation. It would be an improper implementation to place on the heap those
15543 components whose size depends on discriminants. (This improper implementation
15544 was used by some Ada83 compilers, where the @code{Name} component above
15546 been stored as a pointer to a dynamic string). Following the principle that
15547 dynamic storage management should never be introduced implicitly,
15548 an Ada compiler should reserve the full size for an unconstrained declared
15549 object, and place it on the stack.
15551 This maximum size approach
15552 has been a source of surprise to some users, who expect the default
15553 values of the discriminants to determine the size reserved for an
15554 unconstrained object: ``If the default is 15, why should the object occupy
15556 The answer, of course, is that the discriminant may be later modified,
15557 and its full range of values must be taken into account. This is why the
15562 type Rec (D : Positive := 15) is record
15563 Name : String (1..D);
15571 is flagged by the compiler with a warning:
15572 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15573 because the required size includes @code{Positive'Last}
15574 bytes. As the first example indicates, the proper approach is to declare an
15575 index type of ``reasonable'' range so that unconstrained objects are not too
15578 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15579 created in the heap by means of an allocator, then it is @emph{not}
15581 it is constrained by the default values of the discriminants, and those values
15582 cannot be modified by full assignment. This is because in the presence of
15583 aliasing all views of the object (which may be manipulated by different tasks,
15584 say) must be consistent, so it is imperative that the object, once created,
15587 @node Strict Conformance to the Ada Reference Manual
15588 @section Strict Conformance to the Ada Reference Manual
15591 The dynamic semantics defined by the Ada Reference Manual impose a set of
15592 run-time checks to be generated. By default, the GNAT compiler will insert many
15593 run-time checks into the compiled code, including most of those required by the
15594 Ada Reference Manual. However, there are three checks that are not enabled
15595 in the default mode for efficiency reasons: arithmetic overflow checking for
15596 integer operations (including division by zero), checks for access before
15597 elaboration on subprogram calls, and stack overflow checking (most operating
15598 systems do not perform this check by default).
15600 Strict conformance to the Ada Reference Manual can be achieved by adding
15601 three compiler options for overflow checking for integer operations
15602 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15603 calls and generic instantiations (@option{-gnatE}), and stack overflow
15604 checking (@option{-fstack-check}).
15606 Note that the result of a floating point arithmetic operation in overflow and
15607 invalid situations, when the @code{Machine_Overflows} attribute of the result
15608 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15609 case for machines compliant with the IEEE floating-point standard, but on
15610 machines that are not fully compliant with this standard, such as Alpha, the
15611 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15612 behavior (although at the cost of a significant performance penalty), so
15613 infinite and and NaN values are properly generated.
15616 @node Project File Reference
15617 @chapter Project File Reference
15620 This chapter describes the syntax and semantics of project files.
15621 Project files specify the options to be used when building a system.
15622 Project files can specify global settings for all tools,
15623 as well as tool-specific settings.
15624 @xref{Examples of Project Files,,, gnat_ugn, @value{EDITION} User's Guide},
15625 for examples of use.
15629 * Lexical Elements::
15631 * Empty declarations::
15632 * Typed string declarations::
15636 * Project Attributes::
15637 * Attribute References::
15638 * External Values::
15639 * Case Construction::
15641 * Package Renamings::
15643 * Project Extensions::
15644 * Project File Elaboration::
15647 @node Reserved Words
15648 @section Reserved Words
15651 All Ada reserved words are reserved in project files, and cannot be used
15652 as variable names or project names. In addition, the following are
15653 also reserved in project files:
15656 @item @code{extends}
15658 @item @code{external}
15660 @item @code{project}
15664 @node Lexical Elements
15665 @section Lexical Elements
15668 Rules for identifiers are the same as in Ada. Identifiers
15669 are case-insensitive. Strings are case sensitive, except where noted.
15670 Comments have the same form as in Ada.
15680 simple_name @{. simple_name@}
15684 @section Declarations
15687 Declarations introduce new entities that denote types, variables, attributes,
15688 and packages. Some declarations can only appear immediately within a project
15689 declaration. Others can appear within a project or within a package.
15693 declarative_item ::=
15694 simple_declarative_item |
15695 typed_string_declaration |
15696 package_declaration
15698 simple_declarative_item ::=
15699 variable_declaration |
15700 typed_variable_declaration |
15701 attribute_declaration |
15702 case_construction |
15706 @node Empty declarations
15707 @section Empty declarations
15710 empty_declaration ::=
15714 An empty declaration is allowed anywhere a declaration is allowed.
15717 @node Typed string declarations
15718 @section Typed string declarations
15721 Typed strings are sequences of string literals. Typed strings are the only
15722 named types in project files. They are used in case constructions, where they
15723 provide support for conditional attribute definitions.
15727 typed_string_declaration ::=
15728 @b{type} <typed_string_>_simple_name @b{is}
15729 ( string_literal @{, string_literal@} );
15733 A typed string declaration can only appear immediately within a project
15736 All the string literals in a typed string declaration must be distinct.
15742 Variables denote values, and appear as constituents of expressions.
15745 typed_variable_declaration ::=
15746 <typed_variable_>simple_name : <typed_string_>name := string_expression ;
15748 variable_declaration ::=
15749 <variable_>simple_name := expression;
15753 The elaboration of a variable declaration introduces the variable and
15754 assigns to it the value of the expression. The name of the variable is
15755 available after the assignment symbol.
15758 A typed_variable can only be declare once.
15761 a non-typed variable can be declared multiple times.
15764 Before the completion of its first declaration, the value of variable
15765 is the null string.
15768 @section Expressions
15771 An expression is a formula that defines a computation or retrieval of a value.
15772 In a project file the value of an expression is either a string or a list
15773 of strings. A string value in an expression is either a literal, the current
15774 value of a variable, an external value, an attribute reference, or a
15775 concatenation operation.
15788 attribute_reference
15794 ( <string_>expression @{ , <string_>expression @} )
15797 @subsection Concatenation
15799 The following concatenation functions are defined:
15801 @smallexample @c ada
15802 function "&" (X : String; Y : String) return String;
15803 function "&" (X : String_List; Y : String) return String_List;
15804 function "&" (X : String_List; Y : String_List) return String_List;
15808 @section Attributes
15811 An attribute declaration defines a property of a project or package. This
15812 property can later be queried by means of an attribute reference.
15813 Attribute values are strings or string lists.
15815 Some attributes are associative arrays. These attributes are mappings whose
15816 domain is a set of strings. These attributes are declared one association
15817 at a time, by specifying a point in the domain and the corresponding image
15818 of the attribute. They may also be declared as a full associative array,
15819 getting the same associations as the corresponding attribute in an imported
15820 or extended project.
15822 Attributes that are not associative arrays are called simple attributes.
15826 attribute_declaration ::=
15827 full_associative_array_declaration |
15828 @b{for} attribute_designator @b{use} expression ;
15830 full_associative_array_declaration ::=
15831 @b{for} <associative_array_attribute_>simple_name @b{use}
15832 <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
15834 attribute_designator ::=
15835 <simple_attribute_>simple_name |
15836 <associative_array_attribute_>simple_name ( string_literal )
15840 Some attributes are project-specific, and can only appear immediately within
15841 a project declaration. Others are package-specific, and can only appear within
15842 the proper package.
15844 The expression in an attribute definition must be a string or a string_list.
15845 The string literal appearing in the attribute_designator of an associative
15846 array attribute is case-insensitive.
15848 @node Project Attributes
15849 @section Project Attributes
15852 The following attributes apply to a project. All of them are simple
15857 Expression must be a path name. The attribute defines the
15858 directory in which the object files created by the build are to be placed. If
15859 not specified, object files are placed in the project directory.
15862 Expression must be a path name. The attribute defines the
15863 directory in which the executables created by the build are to be placed.
15864 If not specified, executables are placed in the object directory.
15867 Expression must be a list of path names. The attribute
15868 defines the directories in which the source files for the project are to be
15869 found. If not specified, source files are found in the project directory.
15870 If a string in the list ends with "/**", then the directory that precedes
15871 "/**" and all of its subdirectories (recursively) are included in the list
15872 of source directories.
15874 @item Excluded_Source_Dirs
15875 Expression must be a list of strings. Each entry designates a directory that
15876 is not to be included in the list of source directories of the project.
15877 This is normally used when there are strings ending with "/**" in the value
15878 of attribute Source_Dirs.
15881 Expression must be a list of file names. The attribute
15882 defines the individual files, in the project directory, which are to be used
15883 as sources for the project. File names are path_names that contain no directory
15884 information. If the project has no sources the attribute must be declared
15885 explicitly with an empty list.
15887 @item Excluded_Source_Files (Locally_Removed_Files)
15888 Expression must be a list of strings that are legal file names.
15889 Each file name must designate a source that would normally be a source file
15890 in the source directories of the project or, if the project file is an
15891 extending project file, inherited by the current project file. It cannot
15892 designate an immediate source that is not inherited. Each of the source files
15893 in the list are not considered to be sources of the project file: they are not
15894 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
15895 Excluded_Source_Files is preferred.
15897 @item Source_List_File
15898 Expression must a single path name. The attribute
15899 defines a text file that contains a list of source file names to be used
15900 as sources for the project
15903 Expression must be a path name. The attribute defines the
15904 directory in which a library is to be built. The directory must exist, must
15905 be distinct from the project's object directory, and must be writable.
15908 Expression must be a string that is a legal file name,
15909 without extension. The attribute defines a string that is used to generate
15910 the name of the library to be built by the project.
15913 Argument must be a string value that must be one of the
15914 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
15915 string is case-insensitive. If this attribute is not specified, the library is
15916 a static library. Otherwise, the library may be dynamic or relocatable. This
15917 distinction is operating-system dependent.
15919 @item Library_Version
15920 Expression must be a string value whose interpretation
15921 is platform dependent. On UNIX, it is used only for dynamic/relocatable
15922 libraries as the internal name of the library (the @code{"soname"}). If the
15923 library file name (built from the @code{Library_Name}) is different from the
15924 @code{Library_Version}, then the library file will be a symbolic link to the
15925 actual file whose name will be @code{Library_Version}.
15927 @item Library_Interface
15928 Expression must be a string list. Each element of the string list
15929 must designate a unit of the project.
15930 If this attribute is present in a Library Project File, then the project
15931 file is a Stand-alone Library_Project_File.
15933 @item Library_Auto_Init
15934 Expression must be a single string "true" or "false", case-insensitive.
15935 If this attribute is present in a Stand-alone Library Project File,
15936 it indicates if initialization is automatic when the dynamic library
15939 @item Library_Options
15940 Expression must be a string list. Indicates additional switches that
15941 are to be used when building a shared library.
15944 Expression must be a single string. Designates an alternative to "gcc"
15945 for building shared libraries.
15947 @item Library_Src_Dir
15948 Expression must be a path name. The attribute defines the
15949 directory in which the sources of the interfaces of a Stand-alone Library will
15950 be copied. The directory must exist, must be distinct from the project's
15951 object directory and source directories of all projects in the project tree,
15952 and must be writable.
15954 @item Library_Src_Dir
15955 Expression must be a path name. The attribute defines the
15956 directory in which the ALI files of a Library will
15957 be copied. The directory must exist, must be distinct from the project's
15958 object directory and source directories of all projects in the project tree,
15959 and must be writable.
15961 @item Library_Symbol_File
15962 Expression must be a single string. Its value is the single file name of a
15963 symbol file to be created when building a stand-alone library when the
15964 symbol policy is either "compliant", "controlled" or "restricted",
15965 on platforms that support symbol control, such as VMS. When symbol policy
15966 is "direct", then a file with this name must exist in the object directory.
15968 @item Library_Reference_Symbol_File
15969 Expression must be a single string. Its value is the path name of a
15970 reference symbol file that is read when the symbol policy is either
15971 "compliant" or "controlled", on platforms that support symbol control,
15972 such as VMS, when building a stand-alone library. The path may be an absolute
15973 path or a path relative to the project directory.
15975 @item Library_Symbol_Policy
15976 Expression must be a single string. Its case-insensitive value can only be
15977 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
15979 This attribute is not taken into account on all platforms. It controls the
15980 policy for exported symbols and, on some platforms (like VMS) that have the
15981 notions of major and minor IDs built in the library files, it controls
15982 the setting of these IDs.
15984 "autonomous" or "default": exported symbols are not controlled.
15986 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
15987 it is equivalent to policy "autonomous". If there are exported symbols in
15988 the reference symbol file that are not in the object files of the interfaces,
15989 the major ID of the library is increased. If there are symbols in the
15990 object files of the interfaces that are not in the reference symbol file,
15991 these symbols are put at the end of the list in the newly created symbol file
15992 and the minor ID is increased.
15994 "controlled": the attribute Library_Reference_Symbol_File must be defined.
15995 The library will fail to build if the exported symbols in the object files of
15996 the interfaces do not match exactly the symbol in the symbol file.
15998 "restricted": The attribute Library_Symbol_File must be defined. The library
15999 will fail to build if there are symbols in the symbol file that are not in
16000 the exported symbols of the object files of the interfaces. Additional symbols
16001 in the object files are not added to the symbol file.
16003 "direct": The attribute Library_Symbol_File must be defined and must designate
16004 an existing file in the object directory. This symbol file is passed directly
16005 to the underlying linker without any symbol processing.
16008 Expression must be a list of strings that are legal file names.
16009 These file names designate existing compilation units in the source directory
16010 that are legal main subprograms.
16012 When a project file is elaborated, as part of the execution of a gnatmake
16013 command, one or several executables are built and placed in the Exec_Dir.
16014 If the gnatmake command does not include explicit file names, the executables
16015 that are built correspond to the files specified by this attribute.
16017 @item Externally_Built
16018 Expression must be a single string. Its value must be either "true" of "false",
16019 case-insensitive. The default is "false". When the value of this attribute is
16020 "true", no attempt is made to compile the sources or to build the library,
16021 when the project is a library project.
16023 @item Main_Language
16024 This is a simple attribute. Its value is a string that specifies the
16025 language of the main program.
16028 Expression must be a string list. Each string designates
16029 a programming language that is known to GNAT. The strings are case-insensitive.
16033 @node Attribute References
16034 @section Attribute References
16037 Attribute references are used to retrieve the value of previously defined
16038 attribute for a package or project.
16041 attribute_reference ::=
16042 attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
16044 attribute_prefix ::=
16046 <project_simple_name | package_identifier |
16047 <project_>simple_name . package_identifier
16051 If an attribute has not been specified for a given package or project, its
16052 value is the null string or the empty list.
16054 @node External Values
16055 @section External Values
16058 An external value is an expression whose value is obtained from the command
16059 that invoked the processing of the current project file (typically a
16065 @b{external} ( string_literal [, string_literal] )
16069 The first string_literal is the string to be used on the command line or
16070 in the environment to specify the external value. The second string_literal,
16071 if present, is the default to use if there is no specification for this
16072 external value either on the command line or in the environment.
16074 @node Case Construction
16075 @section Case Construction
16078 A case construction supports attribute and variable declarations that depend
16079 on the value of a previously declared variable.
16083 case_construction ::=
16084 @b{case} <typed_variable_>name @b{is}
16089 @b{when} discrete_choice_list =>
16090 @{case_construction |
16091 attribute_declaration |
16092 variable_declaration |
16093 empty_declaration@}
16095 discrete_choice_list ::=
16096 string_literal @{| string_literal@} |
16101 Inside a case construction, variable declarations must be for variables that
16102 have already been declared before the case construction.
16104 All choices in a choice list must be distinct. The choice lists of two
16105 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
16106 alternatives do not need to include all values of the type. An @code{others}
16107 choice must appear last in the list of alternatives.
16113 A package provides a grouping of variable declarations and attribute
16114 declarations to be used when invoking various GNAT tools. The name of
16115 the package indicates the tool(s) to which it applies.
16119 package_declaration ::=
16120 package_spec | package_renaming
16123 @b{package} package_identifier @b{is}
16124 @{simple_declarative_item@}
16125 @b{end} package_identifier ;
16127 package_identifier ::=
16128 @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
16129 @code{Linker} | @code{Finder} | @code{Cross_Reference} |
16130 @code{gnatls} | @code{IDE} | @code{Pretty_Printer}
16133 @subsection Package Naming
16136 The attributes of a @code{Naming} package specifies the naming conventions
16137 that apply to the source files in a project. When invoking other GNAT tools,
16138 they will use the sources in the source directories that satisfy these
16139 naming conventions.
16141 The following attributes apply to a @code{Naming} package:
16145 This is a simple attribute whose value is a string. Legal values of this
16146 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
16147 These strings are themselves case insensitive.
16150 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
16152 @item Dot_Replacement
16153 This is a simple attribute whose string value satisfies the following
16157 @item It must not be empty
16158 @item It cannot start or end with an alphanumeric character
16159 @item It cannot be a single underscore
16160 @item It cannot start with an underscore followed by an alphanumeric
16161 @item It cannot contain a dot @code{'.'} if longer than one character
16165 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
16168 This is an associative array attribute, defined on language names,
16169 whose image is a string that must satisfy the following
16173 @item It must not be empty
16174 @item It cannot start with an alphanumeric character
16175 @item It cannot start with an underscore followed by an alphanumeric character
16179 For Ada, the attribute denotes the suffix used in file names that contain
16180 library unit declarations, that is to say units that are package and
16181 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
16182 specified, then the default is @code{".ads"}.
16184 For C and C++, the attribute denotes the suffix used in file names that
16185 contain prototypes.
16188 This is an associative array attribute defined on language names,
16189 whose image is a string that must satisfy the following
16193 @item It must not be empty
16194 @item It cannot start with an alphanumeric character
16195 @item It cannot start with an underscore followed by an alphanumeric character
16196 @item It cannot be a suffix of @code{Spec_Suffix}
16200 For Ada, the attribute denotes the suffix used in file names that contain
16201 library bodies, that is to say units that are package and subprogram bodies.
16202 If @code{Body_Suffix ("Ada")} is not specified, then the default is
16205 For C and C++, the attribute denotes the suffix used in file names that contain
16208 @item Separate_Suffix
16209 This is a simple attribute whose value satisfies the same conditions as
16210 @code{Body_Suffix}.
16212 This attribute is specific to Ada. It denotes the suffix used in file names
16213 that contain separate bodies. If it is not specified, then it defaults to same
16214 value as @code{Body_Suffix ("Ada")}.
16217 This is an associative array attribute, specific to Ada, defined over
16218 compilation unit names. The image is a string that is the name of the file
16219 that contains that library unit. The file name is case sensitive if the
16220 conventions of the host operating system require it.
16223 This is an associative array attribute, specific to Ada, defined over
16224 compilation unit names. The image is a string that is the name of the file
16225 that contains the library unit body for the named unit. The file name is case
16226 sensitive if the conventions of the host operating system require it.
16228 @item Specification_Exceptions
16229 This is an associative array attribute defined on language names,
16230 whose value is a list of strings.
16232 This attribute is not significant for Ada.
16234 For C and C++, each string in the list denotes the name of a file that
16235 contains prototypes, but whose suffix is not necessarily the
16236 @code{Spec_Suffix} for the language.
16238 @item Implementation_Exceptions
16239 This is an associative array attribute defined on language names,
16240 whose value is a list of strings.
16242 This attribute is not significant for Ada.
16244 For C and C++, each string in the list denotes the name of a file that
16245 contains source code, but whose suffix is not necessarily the
16246 @code{Body_Suffix} for the language.
16249 The following attributes of package @code{Naming} are obsolescent. They are
16250 kept as synonyms of other attributes for compatibility with previous versions
16251 of the Project Manager.
16254 @item Specification_Suffix
16255 This is a synonym of @code{Spec_Suffix}.
16257 @item Implementation_Suffix
16258 This is a synonym of @code{Body_Suffix}.
16260 @item Specification
16261 This is a synonym of @code{Spec}.
16263 @item Implementation
16264 This is a synonym of @code{Body}.
16267 @subsection package Compiler
16270 The attributes of the @code{Compiler} package specify the compilation options
16271 to be used by the underlying compiler.
16274 @item Default_Switches
16275 This is an associative array attribute. Its
16276 domain is a set of language names. Its range is a string list that
16277 specifies the compilation options to be used when compiling a component
16278 written in that language, for which no file-specific switches have been
16282 This is an associative array attribute. Its domain is
16283 a set of file names. Its range is a string list that specifies the
16284 compilation options to be used when compiling the named file. If a file
16285 is not specified in the Switches attribute, it is compiled with the
16286 options specified by Default_Switches of its language, if defined.
16288 @item Local_Configuration_Pragmas.
16289 This is a simple attribute, whose
16290 value is a path name that designates a file containing configuration pragmas
16291 to be used for all invocations of the compiler for immediate sources of the
16295 @subsection package Builder
16298 The attributes of package @code{Builder} specify the compilation, binding, and
16299 linking options to be used when building an executable for a project. The
16300 following attributes apply to package @code{Builder}:
16303 @item Default_Switches
16304 This is an associative array attribute. Its
16305 domain is a set of language names. Its range is a string list that
16306 specifies options to be used when building a main
16307 written in that language, for which no file-specific switches have been
16311 This is an associative array attribute. Its domain is
16312 a set of file names. Its range is a string list that specifies
16313 options to be used when building the named main file. If a main file
16314 is not specified in the Switches attribute, it is built with the
16315 options specified by Default_Switches of its language, if defined.
16317 @item Global_Configuration_Pragmas
16318 This is a simple attribute, whose
16319 value is a path name that designates a file that contains configuration pragmas
16320 to be used in every build of an executable. If both local and global
16321 configuration pragmas are specified, a compilation makes use of both sets.
16325 This is an associative array attribute. Its domain is
16326 a set of main source file names. Its range is a simple string that specifies
16327 the executable file name to be used when linking the specified main source.
16328 If a main source is not specified in the Executable attribute, the executable
16329 file name is deducted from the main source file name.
16330 This attribute has no effect if its value is the empty string.
16332 @item Executable_Suffix
16333 This is a simple attribute whose value is the suffix to be added to
16334 the executables that don't have an attribute Executable specified.
16337 @subsection package Gnatls
16340 The attributes of package @code{Gnatls} specify the tool options to be used
16341 when invoking the library browser @command{gnatls}.
16342 The following attributes apply to package @code{Gnatls}:
16346 This is a single attribute with a string list value. Each nonempty string
16347 in the list is an option when invoking @code{gnatls}.
16350 @subsection package Binder
16353 The attributes of package @code{Binder} specify the options to be used
16354 when invoking the binder in the construction of an executable.
16355 The following attributes apply to package @code{Binder}:
16358 @item Default_Switches
16359 This is an associative array attribute. Its
16360 domain is a set of language names. Its range is a string list that
16361 specifies options to be used when binding a main
16362 written in that language, for which no file-specific switches have been
16366 This is an associative array attribute. Its domain is
16367 a set of file names. Its range is a string list that specifies
16368 options to be used when binding the named main file. If a main file
16369 is not specified in the Switches attribute, it is bound with the
16370 options specified by Default_Switches of its language, if defined.
16373 @subsection package Linker
16376 The attributes of package @code{Linker} specify the options to be used when
16377 invoking the linker in the construction of an executable.
16378 The following attributes apply to package @code{Linker}:
16381 @item Default_Switches
16382 This is an associative array attribute. Its
16383 domain is a set of language names. Its range is a string list that
16384 specifies options to be used when linking a main
16385 written in that language, for which no file-specific switches have been
16389 This is an associative array attribute. Its domain is
16390 a set of file names. Its range is a string list that specifies
16391 options to be used when linking the named main file. If a main file
16392 is not specified in the Switches attribute, it is linked with the
16393 options specified by Default_Switches of its language, if defined.
16395 @item Linker_Options
16396 This is a string list attribute. Its value specifies additional options that
16397 be given to the linker when linking an executable. This attribute is not
16398 used in the main project, only in projects imported directly or indirectly.
16402 @subsection package Cross_Reference
16405 The attributes of package @code{Cross_Reference} specify the tool options
16407 when invoking the library tool @command{gnatxref}.
16408 The following attributes apply to package @code{Cross_Reference}:
16411 @item Default_Switches
16412 This is an associative array attribute. Its
16413 domain is a set of language names. Its range is a string list that
16414 specifies options to be used when calling @command{gnatxref} on a source
16415 written in that language, for which no file-specific switches have been
16419 This is an associative array attribute. Its domain is
16420 a set of file names. Its range is a string list that specifies
16421 options to be used when calling @command{gnatxref} on the named main source.
16422 If a source is not specified in the Switches attribute, @command{gnatxref} will
16423 be called with the options specified by Default_Switches of its language,
16427 @subsection package Finder
16430 The attributes of package @code{Finder} specify the tool options to be used
16431 when invoking the search tool @command{gnatfind}.
16432 The following attributes apply to package @code{Finder}:
16435 @item Default_Switches
16436 This is an associative array attribute. Its
16437 domain is a set of language names. Its range is a string list that
16438 specifies options to be used when calling @command{gnatfind} on a source
16439 written in that language, for which no file-specific switches have been
16443 This is an associative array attribute. Its domain is
16444 a set of file names. Its range is a string list that specifies
16445 options to be used when calling @command{gnatfind} on the named main source.
16446 If a source is not specified in the Switches attribute, @command{gnatfind} will
16447 be called with the options specified by Default_Switches of its language,
16451 @subsection package Pretty_Printer
16454 The attributes of package @code{Pretty_Printer}
16455 specify the tool options to be used
16456 when invoking the formatting tool @command{gnatpp}.
16457 The following attributes apply to package @code{Pretty_Printer}:
16460 @item Default_switches
16461 This is an associative array attribute. Its
16462 domain is a set of language names. Its range is a string list that
16463 specifies options to be used when calling @command{gnatpp} on a source
16464 written in that language, for which no file-specific switches have been
16468 This is an associative array attribute. Its domain is
16469 a set of file names. Its range is a string list that specifies
16470 options to be used when calling @command{gnatpp} on the named main source.
16471 If a source is not specified in the Switches attribute, @command{gnatpp} will
16472 be called with the options specified by Default_Switches of its language,
16476 @subsection package gnatstub
16479 The attributes of package @code{gnatstub}
16480 specify the tool options to be used
16481 when invoking the tool @command{gnatstub}.
16482 The following attributes apply to package @code{gnatstub}:
16485 @item Default_switches
16486 This is an associative array attribute. Its
16487 domain is a set of language names. Its range is a string list that
16488 specifies options to be used when calling @command{gnatstub} on a source
16489 written in that language, for which no file-specific switches have been
16493 This is an associative array attribute. Its domain is
16494 a set of file names. Its range is a string list that specifies
16495 options to be used when calling @command{gnatstub} on the named main source.
16496 If a source is not specified in the Switches attribute, @command{gnatpp} will
16497 be called with the options specified by Default_Switches of its language,
16501 @subsection package Eliminate
16504 The attributes of package @code{Eliminate}
16505 specify the tool options to be used
16506 when invoking the tool @command{gnatelim}.
16507 The following attributes apply to package @code{Eliminate}:
16510 @item Default_switches
16511 This is an associative array attribute. Its
16512 domain is a set of language names. Its range is a string list that
16513 specifies options to be used when calling @command{gnatelim} on a source
16514 written in that language, for which no file-specific switches have been
16518 This is an associative array attribute. Its domain is
16519 a set of file names. Its range is a string list that specifies
16520 options to be used when calling @command{gnatelim} on the named main source.
16521 If a source is not specified in the Switches attribute, @command{gnatelim} will
16522 be called with the options specified by Default_Switches of its language,
16526 @subsection package Metrics
16529 The attributes of package @code{Metrics}
16530 specify the tool options to be used
16531 when invoking the tool @command{gnatmetric}.
16532 The following attributes apply to package @code{Metrics}:
16535 @item Default_switches
16536 This is an associative array attribute. Its
16537 domain is a set of language names. Its range is a string list that
16538 specifies options to be used when calling @command{gnatmetric} on a source
16539 written in that language, for which no file-specific switches have been
16543 This is an associative array attribute. Its domain is
16544 a set of file names. Its range is a string list that specifies
16545 options to be used when calling @command{gnatmetric} on the named main source.
16546 If a source is not specified in the Switches attribute, @command{gnatmetric}
16547 will be called with the options specified by Default_Switches of its language,
16551 @subsection package IDE
16554 The attributes of package @code{IDE} specify the options to be used when using
16555 an Integrated Development Environment such as @command{GPS}.
16559 This is a simple attribute. Its value is a string that designates the remote
16560 host in a cross-compilation environment, to be used for remote compilation and
16561 debugging. This field should not be specified when running on the local
16565 This is a simple attribute. Its value is a string that specifies the
16566 name of IP address of the embedded target in a cross-compilation environment,
16567 on which the program should execute.
16569 @item Communication_Protocol
16570 This is a simple string attribute. Its value is the name of the protocol
16571 to use to communicate with the target in a cross-compilation environment,
16572 e.g.@: @code{"wtx"} or @code{"vxworks"}.
16574 @item Compiler_Command
16575 This is an associative array attribute, whose domain is a language name. Its
16576 value is string that denotes the command to be used to invoke the compiler.
16577 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16578 gnatmake, in particular in the handling of switches.
16580 @item Debugger_Command
16581 This is simple attribute, Its value is a string that specifies the name of
16582 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16584 @item Default_Switches
16585 This is an associative array attribute. Its indexes are the name of the
16586 external tools that the GNAT Programming System (GPS) is supporting. Its
16587 value is a list of switches to use when invoking that tool.
16590 This is a simple attribute. Its value is a string that specifies the name
16591 of the @command{gnatls} utility to be used to retrieve information about the
16592 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16595 This is a simple attribute. Its value is a string used to specify the
16596 Version Control System (VCS) to be used for this project, e.g.@: CVS, RCS
16597 ClearCase or Perforce.
16599 @item VCS_File_Check
16600 This is a simple attribute. Its value is a string that specifies the
16601 command used by the VCS to check the validity of a file, either
16602 when the user explicitly asks for a check, or as a sanity check before
16603 doing the check-in.
16605 @item VCS_Log_Check
16606 This is a simple attribute. Its value is a string that specifies
16607 the command used by the VCS to check the validity of a log file.
16609 @item VCS_Repository_Root
16610 The VCS repository root path. This is used to create tags or branches
16611 of the repository. For subversion the value should be the @code{URL}
16612 as specified to check-out the working copy of the repository.
16614 @item VCS_Patch_Root
16615 The local root directory to use for building patch file. All patch chunks
16616 will be relative to this path. The root project directory is used if
16617 this value is not defined.
16621 @node Package Renamings
16622 @section Package Renamings
16625 A package can be defined by a renaming declaration. The new package renames
16626 a package declared in a different project file, and has the same attributes
16627 as the package it renames.
16630 package_renaming ::==
16631 @b{package} package_identifier @b{renames}
16632 <project_>simple_name.package_identifier ;
16636 The package_identifier of the renamed package must be the same as the
16637 package_identifier. The project whose name is the prefix of the renamed
16638 package must contain a package declaration with this name. This project
16639 must appear in the context_clause of the enclosing project declaration,
16640 or be the parent project of the enclosing child project.
16646 A project file specifies a set of rules for constructing a software system.
16647 A project file can be self-contained, or depend on other project files.
16648 Dependencies are expressed through a context clause that names other projects.
16654 context_clause project_declaration
16656 project_declaration ::=
16657 simple_project_declaration | project_extension
16659 simple_project_declaration ::=
16660 @b{project} <project_>simple_name @b{is}
16661 @{declarative_item@}
16662 @b{end} <project_>simple_name;
16668 [@b{limited}] @b{with} path_name @{ , path_name @} ;
16675 A path name denotes a project file. A path name can be absolute or relative.
16676 An absolute path name includes a sequence of directories, in the syntax of
16677 the host operating system, that identifies uniquely the project file in the
16678 file system. A relative path name identifies the project file, relative
16679 to the directory that contains the current project, or relative to a
16680 directory listed in the environment variable ADA_PROJECT_PATH.
16681 Path names are case sensitive if file names in the host operating system
16682 are case sensitive.
16684 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16685 directory names separated by colons (semicolons on Windows).
16687 A given project name can appear only once in a context_clause.
16689 It is illegal for a project imported by a context clause to refer, directly
16690 or indirectly, to the project in which this context clause appears (the
16691 dependency graph cannot contain cycles), except when one of the with_clause
16692 in the cycle is a @code{limited with}.
16694 @node Project Extensions
16695 @section Project Extensions
16698 A project extension introduces a new project, which inherits the declarations
16699 of another project.
16703 project_extension ::=
16704 @b{project} <project_>simple_name @b{extends} path_name @b{is}
16705 @{declarative_item@}
16706 @b{end} <project_>simple_name;
16710 The project extension declares a child project. The child project inherits
16711 all the declarations and all the files of the parent project, These inherited
16712 declaration can be overridden in the child project, by means of suitable
16715 @node Project File Elaboration
16716 @section Project File Elaboration
16719 A project file is processed as part of the invocation of a gnat tool that
16720 uses the project option. Elaboration of the process file consists in the
16721 sequential elaboration of all its declarations. The computed values of
16722 attributes and variables in the project are then used to establish the
16723 environment in which the gnat tool will execute.
16725 @node Obsolescent Features
16726 @chapter Obsolescent Features
16729 This chapter describes features that are provided by GNAT, but are
16730 considered obsolescent since there are preferred ways of achieving
16731 the same effect. These features are provided solely for historical
16732 compatibility purposes.
16735 * pragma No_Run_Time::
16736 * pragma Ravenscar::
16737 * pragma Restricted_Run_Time::
16740 @node pragma No_Run_Time
16741 @section pragma No_Run_Time
16743 The pragma @code{No_Run_Time} is used to achieve an affect similar
16744 to the use of the "Zero Foot Print" configurable run time, but without
16745 requiring a specially configured run time. The result of using this
16746 pragma, which must be used for all units in a partition, is to restrict
16747 the use of any language features requiring run-time support code. The
16748 preferred usage is to use an appropriately configured run-time that
16749 includes just those features that are to be made accessible.
16751 @node pragma Ravenscar
16752 @section pragma Ravenscar
16754 The pragma @code{Ravenscar} has exactly the same effect as pragma
16755 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16756 is part of the new Ada 2005 standard.
16758 @node pragma Restricted_Run_Time
16759 @section pragma Restricted_Run_Time
16761 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16762 pragma @code{Profile (Restricted)}. The latter usage is
16763 preferred since the Ada 2005 pragma @code{Profile} is intended for
16764 this kind of implementation dependent addition.
16767 @c GNU Free Documentation License
16769 @node Index,,GNU Free Documentation License, Top