1 \input texinfo @c -*-texinfo-*-
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
7 @c GNAT DOCUMENTATION o
11 @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
15 @setfilename gnat_rm.info
18 Copyright @copyright{} 1995-2008, Free Software Foundation, Inc.
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.2 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24 Manual'', and with no Back-Cover Texts. A copy of the license is
25 included in the section entitled ``GNU Free Documentation License''.
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
32 @settitle GNAT Reference Manual
34 @setchapternewpage odd
37 @include gcc-common.texi
39 @dircategory GNU Ada tools
41 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
50 @vskip 0pt plus 1filll
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
72 * Implementation Defined Pragmas::
73 * Implementation Defined Attributes::
74 * Implementation Advice::
75 * Implementation Defined Characteristics::
76 * Intrinsic Subprograms::
77 * Representation Clauses and Pragmas::
78 * Standard Library Routines::
79 * The Implementation of Standard I/O::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Project File Reference::
85 * Obsolescent Features::
86 * GNU Free Documentation License::
89 --- The Detailed Node Listing ---
93 * What This Reference Manual Contains::
94 * Related Information::
96 Implementation Defined Pragmas
98 * Pragma Abort_Defer::
106 * Pragma C_Pass_By_Copy::
108 * Pragma Check_Name::
109 * Pragma Check_Policy::
111 * Pragma Common_Object::
112 * Pragma Compile_Time_Error::
113 * Pragma Compile_Time_Warning::
114 * Pragma Complete_Representation::
115 * Pragma Complex_Representation::
116 * Pragma Component_Alignment::
117 * Pragma Convention_Identifier::
119 * Pragma CPP_Constructor::
120 * Pragma CPP_Virtual::
121 * Pragma CPP_Vtable::
123 * Pragma Debug_Policy::
124 * Pragma Detect_Blocking::
125 * Pragma Elaboration_Checks::
127 * Pragma Export_Exception::
128 * Pragma Export_Function::
129 * Pragma Export_Object::
130 * Pragma Export_Procedure::
131 * Pragma Export_Value::
132 * Pragma Export_Valued_Procedure::
133 * Pragma Extend_System::
135 * Pragma External_Name_Casing::
137 * Pragma Favor_Top_Level::
138 * Pragma Finalize_Storage_Only::
139 * Pragma Float_Representation::
141 * Pragma Implemented_By_Entry::
142 * Pragma Implicit_Packing::
143 * Pragma Import_Exception::
144 * Pragma Import_Function::
145 * Pragma Import_Object::
146 * Pragma Import_Procedure::
147 * Pragma Import_Valued_Procedure::
148 * Pragma Initialize_Scalars::
149 * Pragma Inline_Always::
150 * Pragma Inline_Generic::
152 * Pragma Interface_Name::
153 * Pragma Interrupt_Handler::
154 * Pragma Interrupt_State::
155 * Pragma Keep_Names::
158 * Pragma Linker_Alias::
159 * Pragma Linker_Constructor::
160 * Pragma Linker_Destructor::
161 * Pragma Linker_Section::
162 * Pragma Long_Float::
163 * Pragma Machine_Attribute::
165 * Pragma Main_Storage::
168 * Pragma No_Strict_Aliasing ::
169 * Pragma Normalize_Scalars::
170 * Pragma Obsolescent::
171 * Pragma Optimize_Alignment::
173 * Pragma Persistent_BSS::
175 * Pragma Postcondition::
176 * Pragma Precondition::
177 * Pragma Profile (Ravenscar)::
178 * Pragma Profile (Restricted)::
179 * Pragma Psect_Object::
180 * Pragma Pure_Function::
181 * Pragma Restriction_Warnings::
183 * Pragma Source_File_Name::
184 * Pragma Source_File_Name_Project::
185 * Pragma Source_Reference::
186 * Pragma Stream_Convert::
187 * Pragma Style_Checks::
190 * Pragma Suppress_All::
191 * Pragma Suppress_Exception_Locations::
192 * Pragma Suppress_Initialization::
195 * Pragma Task_Storage::
196 * Pragma Time_Slice::
198 * Pragma Unchecked_Union::
199 * Pragma Unimplemented_Unit::
200 * Pragma Universal_Aliasing ::
201 * Pragma Universal_Data::
202 * Pragma Unmodified::
203 * Pragma Unreferenced::
204 * Pragma Unreferenced_Objects::
205 * Pragma Unreserve_All_Interrupts::
206 * Pragma Unsuppress::
207 * Pragma Use_VADS_Size::
208 * Pragma Validity_Checks::
211 * Pragma Weak_External::
212 * Pragma Wide_Character_Encoding::
214 Implementation Defined Attributes
224 * Default_Bit_Order::
234 * Has_Access_Values::
235 * Has_Discriminants::
242 * Max_Interrupt_Priority::
244 * Maximum_Alignment::
249 * Passed_By_Reference::
262 * Unconstrained_Array::
263 * Universal_Literal_String::
264 * Unrestricted_Access::
270 The Implementation of Standard I/O
272 * Standard I/O Packages::
278 * Wide_Wide_Text_IO::
281 * Filenames encoding::
283 * Operations on C Streams::
284 * Interfacing to C Streams::
288 * Ada.Characters.Latin_9 (a-chlat9.ads)::
289 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
290 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
291 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
292 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
293 * Ada.Command_Line.Environment (a-colien.ads)::
294 * Ada.Command_Line.Remove (a-colire.ads)::
295 * Ada.Command_Line.Response_File (a-clrefi.ads)::
296 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
297 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
298 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
299 * Ada.Exceptions.Traceback (a-exctra.ads)::
300 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
301 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
302 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
303 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
304 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
305 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
306 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
307 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
308 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
309 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
310 * GNAT.Altivec (g-altive.ads)::
311 * GNAT.Altivec.Conversions (g-altcon.ads)::
312 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
313 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
314 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
315 * GNAT.Array_Split (g-arrspl.ads)::
316 * GNAT.AWK (g-awk.ads)::
317 * GNAT.Bounded_Buffers (g-boubuf.ads)::
318 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
319 * GNAT.Bubble_Sort (g-bubsor.ads)::
320 * GNAT.Bubble_Sort_A (g-busora.ads)::
321 * GNAT.Bubble_Sort_G (g-busorg.ads)::
322 * GNAT.Byte_Order_Mark (g-byorma.ads)::
323 * GNAT.Byte_Swapping (g-bytswa.ads)::
324 * GNAT.Calendar (g-calend.ads)::
325 * GNAT.Calendar.Time_IO (g-catiio.ads)::
326 * GNAT.Case_Util (g-casuti.ads)::
327 * GNAT.CGI (g-cgi.ads)::
328 * GNAT.CGI.Cookie (g-cgicoo.ads)::
329 * GNAT.CGI.Debug (g-cgideb.ads)::
330 * GNAT.Command_Line (g-comlin.ads)::
331 * GNAT.Compiler_Version (g-comver.ads)::
332 * GNAT.Ctrl_C (g-ctrl_c.ads)::
333 * GNAT.CRC32 (g-crc32.ads)::
334 * GNAT.Current_Exception (g-curexc.ads)::
335 * GNAT.Debug_Pools (g-debpoo.ads)::
336 * GNAT.Debug_Utilities (g-debuti.ads)::
337 * GNAT.Decode_String (g-decstr.ads)::
338 * GNAT.Decode_UTF8_String (g-deutst.ads)::
339 * GNAT.Directory_Operations (g-dirope.ads)::
340 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
341 * GNAT.Dynamic_HTables (g-dynhta.ads)::
342 * GNAT.Dynamic_Tables (g-dyntab.ads)::
343 * GNAT.Encode_String (g-encstr.ads)::
344 * GNAT.Encode_UTF8_String (g-enutst.ads)::
345 * GNAT.Exception_Actions (g-excact.ads)::
346 * GNAT.Exception_Traces (g-exctra.ads)::
347 * GNAT.Exceptions (g-except.ads)::
348 * GNAT.Expect (g-expect.ads)::
349 * GNAT.Float_Control (g-flocon.ads)::
350 * GNAT.Heap_Sort (g-heasor.ads)::
351 * GNAT.Heap_Sort_A (g-hesora.ads)::
352 * GNAT.Heap_Sort_G (g-hesorg.ads)::
353 * GNAT.HTable (g-htable.ads)::
354 * GNAT.IO (g-io.ads)::
355 * GNAT.IO_Aux (g-io_aux.ads)::
356 * GNAT.Lock_Files (g-locfil.ads)::
357 * GNAT.MD5 (g-md5.ads)::
358 * GNAT.Memory_Dump (g-memdum.ads)::
359 * GNAT.Most_Recent_Exception (g-moreex.ads)::
360 * GNAT.OS_Lib (g-os_lib.ads)::
361 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
362 * GNAT.Random_Numbers (g-rannum.ads)::
363 * GNAT.Regexp (g-regexp.ads)::
364 * GNAT.Registry (g-regist.ads)::
365 * GNAT.Regpat (g-regpat.ads)::
366 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
367 * GNAT.Semaphores (g-semaph.ads)::
368 * GNAT.Serial_Communications (g-sercom.ads)::
369 * GNAT.SHA1 (g-sha1.ads)::
370 * GNAT.Signals (g-signal.ads)::
371 * GNAT.Sockets (g-socket.ads)::
372 * GNAT.Source_Info (g-souinf.ads)::
373 * GNAT.Spelling_Checker (g-speche.ads)::
374 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
375 * GNAT.Spitbol.Patterns (g-spipat.ads)::
376 * GNAT.Spitbol (g-spitbo.ads)::
377 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
378 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
379 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
380 * GNAT.Strings (g-string.ads)::
381 * GNAT.String_Split (g-strspl.ads)::
382 * GNAT.Table (g-table.ads)::
383 * GNAT.Task_Lock (g-tasloc.ads)::
384 * GNAT.Threads (g-thread.ads)::
385 * GNAT.Time_Stamp (g-timsta.ads)::
386 * GNAT.Traceback (g-traceb.ads)::
387 * GNAT.Traceback.Symbolic (g-trasym.ads)::
388 * GNAT.UTF_32 (g-utf_32.ads)::
389 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
390 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
391 * GNAT.Wide_String_Split (g-wistsp.ads)::
392 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
393 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
394 * Interfaces.C.Extensions (i-cexten.ads)::
395 * Interfaces.C.Streams (i-cstrea.ads)::
396 * Interfaces.CPP (i-cpp.ads)::
397 * Interfaces.Packed_Decimal (i-pacdec.ads)::
398 * Interfaces.VxWorks (i-vxwork.ads)::
399 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
400 * System.Address_Image (s-addima.ads)::
401 * System.Assertions (s-assert.ads)::
402 * System.Memory (s-memory.ads)::
403 * System.Partition_Interface (s-parint.ads)::
404 * System.Pool_Global (s-pooglo.ads)::
405 * System.Pool_Local (s-pooloc.ads)::
406 * System.Restrictions (s-restri.ads)::
407 * System.Rident (s-rident.ads)::
408 * System.Task_Info (s-tasinf.ads)::
409 * System.Wch_Cnv (s-wchcnv.ads)::
410 * System.Wch_Con (s-wchcon.ads)::
414 * Text_IO Stream Pointer Positioning::
415 * Text_IO Reading and Writing Non-Regular Files::
417 * Treating Text_IO Files as Streams::
418 * Text_IO Extensions::
419 * Text_IO Facilities for Unbounded Strings::
423 * Wide_Text_IO Stream Pointer Positioning::
424 * Wide_Text_IO Reading and Writing Non-Regular Files::
428 * Wide_Wide_Text_IO Stream Pointer Positioning::
429 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
431 Interfacing to Other Languages
434 * Interfacing to C++::
435 * Interfacing to COBOL::
436 * Interfacing to Fortran::
437 * Interfacing to non-GNAT Ada code::
439 Specialized Needs Annexes
441 Implementation of Specific Ada Features
442 * Machine Code Insertions::
443 * GNAT Implementation of Tasking::
444 * GNAT Implementation of Shared Passive Packages::
445 * Code Generation for Array Aggregates::
446 * The Size of Discriminated Records with Default Discriminants::
447 * Strict Conformance to the Ada Reference Manual::
449 Project File Reference
453 GNU Free Documentation License
460 @node About This Guide
461 @unnumbered About This Guide
464 This manual contains useful information in writing programs using the
465 @value{EDITION} compiler. It includes information on implementation dependent
466 characteristics of @value{EDITION}, including all the information required by
467 Annex M of the Ada language standard.
469 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
470 Ada 83 compatibility mode.
471 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
472 but you can override with a compiler switch
473 to explicitly specify the language version.
474 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
475 @value{EDITION} User's Guide}, for details on these switches.)
476 Throughout this manual, references to ``Ada'' without a year suffix
477 apply to both the Ada 95 and Ada 2005 versions of the language.
479 Ada is designed to be highly portable.
480 In general, a program will have the same effect even when compiled by
481 different compilers on different platforms.
482 However, since Ada is designed to be used in a
483 wide variety of applications, it also contains a number of system
484 dependent features to be used in interfacing to the external world.
485 @cindex Implementation-dependent features
488 Note: Any program that makes use of implementation-dependent features
489 may be non-portable. You should follow good programming practice and
490 isolate and clearly document any sections of your program that make use
491 of these features in a non-portable manner.
494 For ease of exposition, ``GNAT Pro'' will be referred to simply as
495 ``GNAT'' in the remainder of this document.
499 * What This Reference Manual Contains::
501 * Related Information::
504 @node What This Reference Manual Contains
505 @unnumberedsec What This Reference Manual Contains
508 This reference manual contains the following chapters:
512 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
513 pragmas, which can be used to extend and enhance the functionality of the
517 @ref{Implementation Defined Attributes}, lists GNAT
518 implementation-dependent attributes which can be used to extend and
519 enhance the functionality of the compiler.
522 @ref{Implementation Advice}, provides information on generally
523 desirable behavior which are not requirements that all compilers must
524 follow since it cannot be provided on all systems, or which may be
525 undesirable on some systems.
528 @ref{Implementation Defined Characteristics}, provides a guide to
529 minimizing implementation dependent features.
532 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
533 implemented by GNAT, and how they can be imported into user
534 application programs.
537 @ref{Representation Clauses and Pragmas}, describes in detail the
538 way that GNAT represents data, and in particular the exact set
539 of representation clauses and pragmas that is accepted.
542 @ref{Standard Library Routines}, provides a listing of packages and a
543 brief description of the functionality that is provided by Ada's
544 extensive set of standard library routines as implemented by GNAT@.
547 @ref{The Implementation of Standard I/O}, details how the GNAT
548 implementation of the input-output facilities.
551 @ref{The GNAT Library}, is a catalog of packages that complement
552 the Ada predefined library.
555 @ref{Interfacing to Other Languages}, describes how programs
556 written in Ada using GNAT can be interfaced to other programming
559 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
560 of the specialized needs annexes.
563 @ref{Implementation of Specific Ada Features}, discusses issues related
564 to GNAT's implementation of machine code insertions, tasking, and several
568 @ref{Project File Reference}, presents the syntax and semantics
572 @ref{Obsolescent Features} documents implementation dependent features,
573 including pragmas and attributes, which are considered obsolescent, since
574 there are other preferred ways of achieving the same results. These
575 obsolescent forms are retained for backwards compatibility.
579 @cindex Ada 95 Language Reference Manual
580 @cindex Ada 2005 Language Reference Manual
582 This reference manual assumes a basic familiarity with the Ada 95 language, as
583 described in the International Standard ANSI/ISO/IEC-8652:1995,
585 It does not require knowledge of the new features introduced by Ada 2005,
586 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
588 Both reference manuals are included in the GNAT documentation
592 @unnumberedsec Conventions
593 @cindex Conventions, typographical
594 @cindex Typographical conventions
597 Following are examples of the typographical and graphic conventions used
602 @code{Functions}, @code{utility program names}, @code{standard names},
609 @file{File names}, @samp{button names}, and @samp{field names}.
612 @code{Variables}, @env{environment variables}, and @var{metasyntactic
619 [optional information or parameters]
622 Examples are described by text
624 and then shown this way.
629 Commands that are entered by the user are preceded in this manual by the
630 characters @samp{$ } (dollar sign followed by space). If your system uses this
631 sequence as a prompt, then the commands will appear exactly as you see them
632 in the manual. If your system uses some other prompt, then the command will
633 appear with the @samp{$} replaced by whatever prompt character you are using.
635 @node Related Information
636 @unnumberedsec Related Information
638 See the following documents for further information on GNAT:
642 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
643 @value{EDITION} User's Guide}, which provides information on how to use the
644 GNAT compiler system.
647 @cite{Ada 95 Reference Manual}, which contains all reference
648 material for the Ada 95 programming language.
651 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
652 of the Ada 95 standard. The annotations describe
653 detailed aspects of the design decision, and in particular contain useful
654 sections on Ada 83 compatibility.
657 @cite{Ada 2005 Reference Manual}, which contains all reference
658 material for the Ada 2005 programming language.
661 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
662 of the Ada 2005 standard. The annotations describe
663 detailed aspects of the design decision, and in particular contain useful
664 sections on Ada 83 and Ada 95 compatibility.
667 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
668 which contains specific information on compatibility between GNAT and
672 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
673 describes in detail the pragmas and attributes provided by the DEC Ada 83
678 @node Implementation Defined Pragmas
679 @chapter Implementation Defined Pragmas
682 Ada defines a set of pragmas that can be used to supply additional
683 information to the compiler. These language defined pragmas are
684 implemented in GNAT and work as described in the Ada Reference
687 In addition, Ada allows implementations to define additional pragmas
688 whose meaning is defined by the implementation. GNAT provides a number
689 of these implementation-defined pragmas, which can be used to extend
690 and enhance the functionality of the compiler. This section of the GNAT
691 Reference Manual describes these additional pragmas.
693 Note that any program using these pragmas might not be portable to other
694 compilers (although GNAT implements this set of pragmas on all
695 platforms). Therefore if portability to other compilers is an important
696 consideration, the use of these pragmas should be minimized.
699 * Pragma Abort_Defer::
707 * Pragma C_Pass_By_Copy::
709 * Pragma Check_Name::
710 * Pragma Check_Policy::
712 * Pragma Common_Object::
713 * Pragma Compile_Time_Error::
714 * Pragma Compile_Time_Warning::
715 * Pragma Complete_Representation::
716 * Pragma Complex_Representation::
717 * Pragma Component_Alignment::
718 * Pragma Convention_Identifier::
720 * Pragma CPP_Constructor::
721 * Pragma CPP_Virtual::
722 * Pragma CPP_Vtable::
724 * Pragma Debug_Policy::
725 * Pragma Detect_Blocking::
726 * Pragma Elaboration_Checks::
728 * Pragma Export_Exception::
729 * Pragma Export_Function::
730 * Pragma Export_Object::
731 * Pragma Export_Procedure::
732 * Pragma Export_Value::
733 * Pragma Export_Valued_Procedure::
734 * Pragma Extend_System::
736 * Pragma External_Name_Casing::
738 * Pragma Favor_Top_Level::
739 * Pragma Finalize_Storage_Only::
740 * Pragma Float_Representation::
742 * Pragma Implemented_By_Entry::
743 * Pragma Implicit_Packing::
744 * Pragma Import_Exception::
745 * Pragma Import_Function::
746 * Pragma Import_Object::
747 * Pragma Import_Procedure::
748 * Pragma Import_Valued_Procedure::
749 * Pragma Initialize_Scalars::
750 * Pragma Inline_Always::
751 * Pragma Inline_Generic::
753 * Pragma Interface_Name::
754 * Pragma Interrupt_Handler::
755 * Pragma Interrupt_State::
756 * Pragma Keep_Names::
759 * Pragma Linker_Alias::
760 * Pragma Linker_Constructor::
761 * Pragma Linker_Destructor::
762 * Pragma Linker_Section::
763 * Pragma Long_Float::
764 * Pragma Machine_Attribute::
766 * Pragma Main_Storage::
769 * Pragma No_Strict_Aliasing::
770 * Pragma Normalize_Scalars::
771 * Pragma Obsolescent::
772 * Pragma Optimize_Alignment::
774 * Pragma Persistent_BSS::
776 * Pragma Postcondition::
777 * Pragma Precondition::
778 * Pragma Profile (Ravenscar)::
779 * Pragma Profile (Restricted)::
780 * Pragma Psect_Object::
781 * Pragma Pure_Function::
782 * Pragma Restriction_Warnings::
784 * Pragma Source_File_Name::
785 * Pragma Source_File_Name_Project::
786 * Pragma Source_Reference::
787 * Pragma Stream_Convert::
788 * Pragma Style_Checks::
791 * Pragma Suppress_All::
792 * Pragma Suppress_Exception_Locations::
793 * Pragma Suppress_Initialization::
796 * Pragma Task_Storage::
797 * Pragma Time_Slice::
799 * Pragma Unchecked_Union::
800 * Pragma Unimplemented_Unit::
801 * Pragma Universal_Aliasing ::
802 * Pragma Universal_Data::
803 * Pragma Unmodified::
804 * Pragma Unreferenced::
805 * Pragma Unreferenced_Objects::
806 * Pragma Unreserve_All_Interrupts::
807 * Pragma Unsuppress::
808 * Pragma Use_VADS_Size::
809 * Pragma Validity_Checks::
812 * Pragma Weak_External::
813 * Pragma Wide_Character_Encoding::
816 @node Pragma Abort_Defer
817 @unnumberedsec Pragma Abort_Defer
819 @cindex Deferring aborts
827 This pragma must appear at the start of the statement sequence of a
828 handled sequence of statements (right after the @code{begin}). It has
829 the effect of deferring aborts for the sequence of statements (but not
830 for the declarations or handlers, if any, associated with this statement
834 @unnumberedsec Pragma Ada_83
843 A configuration pragma that establishes Ada 83 mode for the unit to
844 which it applies, regardless of the mode set by the command line
845 switches. In Ada 83 mode, GNAT attempts to be as compatible with
846 the syntax and semantics of Ada 83, as defined in the original Ada
847 83 Reference Manual as possible. In particular, the keywords added by Ada 95
848 and Ada 2005 are not recognized, optional package bodies are allowed,
849 and generics may name types with unknown discriminants without using
850 the @code{(<>)} notation. In addition, some but not all of the additional
851 restrictions of Ada 83 are enforced.
853 Ada 83 mode is intended for two purposes. Firstly, it allows existing
854 Ada 83 code to be compiled and adapted to GNAT with less effort.
855 Secondly, it aids in keeping code backwards compatible with Ada 83.
856 However, there is no guarantee that code that is processed correctly
857 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
858 83 compiler, since GNAT does not enforce all the additional checks
862 @unnumberedsec Pragma Ada_95
871 A configuration pragma that establishes Ada 95 mode for the unit to which
872 it applies, regardless of the mode set by the command line switches.
873 This mode is set automatically for the @code{Ada} and @code{System}
874 packages and their children, so you need not specify it in these
875 contexts. This pragma is useful when writing a reusable component that
876 itself uses Ada 95 features, but which is intended to be usable from
877 either Ada 83 or Ada 95 programs.
880 @unnumberedsec Pragma Ada_05
889 A configuration pragma that establishes Ada 2005 mode for the unit to which
890 it applies, regardless of the mode set by the command line switches.
891 This mode is set automatically for the @code{Ada} and @code{System}
892 packages and their children, so you need not specify it in these
893 contexts. This pragma is useful when writing a reusable component that
894 itself uses Ada 2005 features, but which is intended to be usable from
895 either Ada 83 or Ada 95 programs.
897 @node Pragma Ada_2005
898 @unnumberedsec Pragma Ada_2005
907 This configuration pragma is a synonym for pragma Ada_05 and has the
908 same syntax and effect.
910 @node Pragma Annotate
911 @unnumberedsec Pragma Annotate
916 pragma Annotate (IDENTIFIER @{, ARG@});
918 ARG ::= NAME | EXPRESSION
922 This pragma is used to annotate programs. @var{identifier} identifies
923 the type of annotation. GNAT verifies that it is an identifier, but does
924 not otherwise analyze it. The @var{arg} argument
925 can be either a string literal or an
926 expression. String literals are assumed to be of type
927 @code{Standard.String}. Names of entities are simply analyzed as entity
928 names. All other expressions are analyzed as expressions, and must be
931 The analyzed pragma is retained in the tree, but not otherwise processed
932 by any part of the GNAT compiler. This pragma is intended for use by
933 external tools, including ASIS@.
936 @unnumberedsec Pragma Assert
943 [, string_EXPRESSION]);
947 The effect of this pragma depends on whether the corresponding command
948 line switch is set to activate assertions. The pragma expands into code
949 equivalent to the following:
952 if assertions-enabled then
953 if not boolean_EXPRESSION then
954 System.Assertions.Raise_Assert_Failure
961 The string argument, if given, is the message that will be associated
962 with the exception occurrence if the exception is raised. If no second
963 argument is given, the default message is @samp{@var{file}:@var{nnn}},
964 where @var{file} is the name of the source file containing the assert,
965 and @var{nnn} is the line number of the assert. A pragma is not a
966 statement, so if a statement sequence contains nothing but a pragma
967 assert, then a null statement is required in addition, as in:
972 pragma Assert (K > 3, "Bad value for K");
978 Note that, as with the @code{if} statement to which it is equivalent, the
979 type of the expression is either @code{Standard.Boolean}, or any type derived
980 from this standard type.
982 If assertions are disabled (switch @option{-gnata} not used), then there
983 is no run-time effect (and in particular, any side effects from the
984 expression will not occur at run time). (The expression is still
985 analyzed at compile time, and may cause types to be frozen if they are
986 mentioned here for the first time).
988 If assertions are enabled, then the given expression is tested, and if
989 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
990 which results in the raising of @code{Assert_Failure} with the given message.
992 You should generally avoid side effects in the expression arguments of
993 this pragma, because these side effects will turn on and off with the
994 setting of the assertions mode, resulting in assertions that have an
995 effect on the program. However, the expressions are analyzed for
996 semantic correctness whether or not assertions are enabled, so turning
997 assertions on and off cannot affect the legality of a program.
999 @node Pragma Ast_Entry
1000 @unnumberedsec Pragma Ast_Entry
1005 @smallexample @c ada
1006 pragma AST_Entry (entry_IDENTIFIER);
1010 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1011 argument is the simple name of a single entry; at most one @code{AST_Entry}
1012 pragma is allowed for any given entry. This pragma must be used in
1013 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1014 the entry declaration and in the same task type specification or single task
1015 as the entry to which it applies. This pragma specifies that the given entry
1016 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1017 resulting from an OpenVMS system service call. The pragma does not affect
1018 normal use of the entry. For further details on this pragma, see the
1019 DEC Ada Language Reference Manual, section 9.12a.
1021 @node Pragma C_Pass_By_Copy
1022 @unnumberedsec Pragma C_Pass_By_Copy
1023 @cindex Passing by copy
1024 @findex C_Pass_By_Copy
1027 @smallexample @c ada
1028 pragma C_Pass_By_Copy
1029 ([Max_Size =>] static_integer_EXPRESSION);
1033 Normally the default mechanism for passing C convention records to C
1034 convention subprograms is to pass them by reference, as suggested by RM
1035 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1036 this default, by requiring that record formal parameters be passed by
1037 copy if all of the following conditions are met:
1041 The size of the record type does not exceed the value specified for
1044 The record type has @code{Convention C}.
1046 The formal parameter has this record type, and the subprogram has a
1047 foreign (non-Ada) convention.
1051 If these conditions are met the argument is passed by copy, i.e.@: in a
1052 manner consistent with what C expects if the corresponding formal in the
1053 C prototype is a struct (rather than a pointer to a struct).
1055 You can also pass records by copy by specifying the convention
1056 @code{C_Pass_By_Copy} for the record type, or by using the extended
1057 @code{Import} and @code{Export} pragmas, which allow specification of
1058 passing mechanisms on a parameter by parameter basis.
1061 @unnumberedsec Pragma Check
1063 @cindex Named assertions
1067 @smallexample @c ada
1069 [Name =>] Identifier,
1070 [Check =>] Boolean_EXPRESSION
1071 [, [Message =>] string_EXPRESSION] );
1075 This pragma is similar to the predefined pragma @code{Assert} except that an
1076 extra identifier argument is present. In conjunction with pragma
1077 @code{Check_Policy}, this can be used to define groups of assertions that can
1078 be independently controlled. The identifier @code{Assertion} is special, it
1079 refers to the normal set of pragma @code{Assert} statements. The identifiers
1080 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1081 names, so these three names would normally not be used directly in a pragma
1084 Checks introduced by this pragma are normally deactivated by default. They can
1085 be activated either by the command line option @option{-gnata}, which turns on
1086 all checks, or individually controlled using pragma @code{Check_Policy}.
1088 @node Pragma Check_Name
1089 @unnumberedsec Pragma Check_Name
1090 @cindex Defining check names
1091 @cindex Check names, defining
1095 @smallexample @c ada
1096 pragma Check_Name (check_name_IDENTIFIER);
1100 This is a configuration pragma that defines a new implementation
1101 defined check name (unless IDENTIFIER matches one of the predefined
1102 check names, in which case the pragma has no effect). Check names
1103 are global to a partition, so if two or more configuration pragmas
1104 are present in a partition mentioning the same name, only one new
1105 check name is introduced.
1107 An implementation defined check name introduced with this pragma may
1108 be used in only three contexts: @code{pragma Suppress},
1109 @code{pragma Unsuppress},
1110 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1111 any of these three cases, the check name must be visible. A check
1112 name is visible if it is in the configuration pragmas applying to
1113 the current unit, or if it appears at the start of any unit that
1114 is part of the dependency set of the current unit (e.g., units that
1115 are mentioned in @code{with} clauses).
1117 @node Pragma Check_Policy
1118 @unnumberedsec Pragma Check_Policy
1119 @cindex Controlling assertions
1120 @cindex Assertions, control
1121 @cindex Check pragma control
1122 @cindex Named assertions
1126 @smallexample @c ada
1127 pragma Check_Policy ([Name =>] Identifier, POLICY_IDENTIFIER);
1129 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1133 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1134 except that it controls sets of named assertions introduced using the
1135 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1136 @code{Assertion_Policy}) can be used within a declarative part, in which case
1137 it controls the status to the end of the corresponding construct (in a manner
1138 identical to pragma @code{Suppress)}.
1140 The identifier given as the first argument corresponds to a name used in
1141 associated @code{Check} pragmas. For example, if the pragma:
1143 @smallexample @c ada
1144 pragma Check_Policy (Critical_Error, Off);
1148 is given, then subsequent @code{Check} pragmas whose first argument is also
1149 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1150 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1151 @code{Check_Policy} with this identifier is similar to the normal
1152 @code{Assertion_Policy} pragma except that it can appear within a
1155 The special identifiers @code{Precondition} and @code{Postcondition} control
1156 the status of preconditions and postconditions. If a @code{Precondition} pragma
1157 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1158 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1159 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1162 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1163 to turn on corresponding checks. The default for a set of checks for which no
1164 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1165 @option{-gnata} is given, which turns on all checks by default.
1167 The check policy settings @code{Check} and @code{Ignore} are also recognized
1168 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1169 compatibility with the standard @code{Assertion_Policy} pragma.
1171 @node Pragma Comment
1172 @unnumberedsec Pragma Comment
1177 @smallexample @c ada
1178 pragma Comment (static_string_EXPRESSION);
1182 This is almost identical in effect to pragma @code{Ident}. It allows the
1183 placement of a comment into the object file and hence into the
1184 executable file if the operating system permits such usage. The
1185 difference is that @code{Comment}, unlike @code{Ident}, has
1186 no limitations on placement of the pragma (it can be placed
1187 anywhere in the main source unit), and if more than one pragma
1188 is used, all comments are retained.
1190 @node Pragma Common_Object
1191 @unnumberedsec Pragma Common_Object
1192 @findex Common_Object
1196 @smallexample @c ada
1197 pragma Common_Object (
1198 [Internal =>] LOCAL_NAME
1199 [, [External =>] EXTERNAL_SYMBOL]
1200 [, [Size =>] EXTERNAL_SYMBOL] );
1204 | static_string_EXPRESSION
1208 This pragma enables the shared use of variables stored in overlaid
1209 linker areas corresponding to the use of @code{COMMON}
1210 in Fortran. The single
1211 object @var{LOCAL_NAME} is assigned to the area designated by
1212 the @var{External} argument.
1213 You may define a record to correspond to a series
1214 of fields. The @var{Size} argument
1215 is syntax checked in GNAT, but otherwise ignored.
1217 @code{Common_Object} is not supported on all platforms. If no
1218 support is available, then the code generator will issue a message
1219 indicating that the necessary attribute for implementation of this
1220 pragma is not available.
1222 @node Pragma Compile_Time_Error
1223 @unnumberedsec Pragma Compile_Time_Error
1224 @findex Compile_Time_Error
1228 @smallexample @c ada
1229 pragma Compile_Time_Error
1230 (boolean_EXPRESSION, static_string_EXPRESSION);
1234 This pragma can be used to generate additional compile time
1236 is particularly useful in generics, where errors can be issued for
1237 specific problematic instantiations. The first parameter is a boolean
1238 expression. The pragma is effective only if the value of this expression
1239 is known at compile time, and has the value True. The set of expressions
1240 whose values are known at compile time includes all static boolean
1241 expressions, and also other values which the compiler can determine
1242 at compile time (e.g., the size of a record type set by an explicit
1243 size representation clause, or the value of a variable which was
1244 initialized to a constant and is known not to have been modified).
1245 If these conditions are met, an error message is generated using
1246 the value given as the second argument. This string value may contain
1247 embedded ASCII.LF characters to break the message into multiple lines.
1249 @node Pragma Compile_Time_Warning
1250 @unnumberedsec Pragma Compile_Time_Warning
1251 @findex Compile_Time_Warning
1255 @smallexample @c ada
1256 pragma Compile_Time_Warning
1257 (boolean_EXPRESSION, static_string_EXPRESSION);
1261 Same as pragma Compile_Time_Error, except a warning is issued instead
1262 of an error message. Note that if this pragma is used in a package that
1263 is with'ed by a client, the client will get the warning even though it
1264 is issued by a with'ed package (normally warnings in with'ed units are
1265 suppressed, but this is a special exception to that rule).
1267 One typical use is within a generic where compile time known characteristics
1268 of formal parameters are tested, and warnings given appropriately. Another use
1269 with a first parameter of True is to warn a client about use of a package,
1270 for example that it is not fully implemented.
1272 @node Pragma Complete_Representation
1273 @unnumberedsec Pragma Complete_Representation
1274 @findex Complete_Representation
1278 @smallexample @c ada
1279 pragma Complete_Representation;
1283 This pragma must appear immediately within a record representation
1284 clause. Typical placements are before the first component clause
1285 or after the last component clause. The effect is to give an error
1286 message if any component is missing a component clause. This pragma
1287 may be used to ensure that a record representation clause is
1288 complete, and that this invariant is maintained if fields are
1289 added to the record in the future.
1291 @node Pragma Complex_Representation
1292 @unnumberedsec Pragma Complex_Representation
1293 @findex Complex_Representation
1297 @smallexample @c ada
1298 pragma Complex_Representation
1299 ([Entity =>] LOCAL_NAME);
1303 The @var{Entity} argument must be the name of a record type which has
1304 two fields of the same floating-point type. The effect of this pragma is
1305 to force gcc to use the special internal complex representation form for
1306 this record, which may be more efficient. Note that this may result in
1307 the code for this type not conforming to standard ABI (application
1308 binary interface) requirements for the handling of record types. For
1309 example, in some environments, there is a requirement for passing
1310 records by pointer, and the use of this pragma may result in passing
1311 this type in floating-point registers.
1313 @node Pragma Component_Alignment
1314 @unnumberedsec Pragma Component_Alignment
1315 @cindex Alignments of components
1316 @findex Component_Alignment
1320 @smallexample @c ada
1321 pragma Component_Alignment (
1322 [Form =>] ALIGNMENT_CHOICE
1323 [, [Name =>] type_LOCAL_NAME]);
1325 ALIGNMENT_CHOICE ::=
1333 Specifies the alignment of components in array or record types.
1334 The meaning of the @var{Form} argument is as follows:
1337 @findex Component_Size
1338 @item Component_Size
1339 Aligns scalar components and subcomponents of the array or record type
1340 on boundaries appropriate to their inherent size (naturally
1341 aligned). For example, 1-byte components are aligned on byte boundaries,
1342 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1343 integer components are aligned on 4-byte boundaries and so on. These
1344 alignment rules correspond to the normal rules for C compilers on all
1345 machines except the VAX@.
1347 @findex Component_Size_4
1348 @item Component_Size_4
1349 Naturally aligns components with a size of four or fewer
1350 bytes. Components that are larger than 4 bytes are placed on the next
1353 @findex Storage_Unit
1355 Specifies that array or record components are byte aligned, i.e.@:
1356 aligned on boundaries determined by the value of the constant
1357 @code{System.Storage_Unit}.
1361 Specifies that array or record components are aligned on default
1362 boundaries, appropriate to the underlying hardware or operating system or
1363 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1364 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1365 the @code{Default} choice is the same as @code{Component_Size} (natural
1370 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1371 refer to a local record or array type, and the specified alignment
1372 choice applies to the specified type. The use of
1373 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1374 @code{Component_Alignment} pragma to be ignored. The use of
1375 @code{Component_Alignment} together with a record representation clause
1376 is only effective for fields not specified by the representation clause.
1378 If the @code{Name} parameter is absent, the pragma can be used as either
1379 a configuration pragma, in which case it applies to one or more units in
1380 accordance with the normal rules for configuration pragmas, or it can be
1381 used within a declarative part, in which case it applies to types that
1382 are declared within this declarative part, or within any nested scope
1383 within this declarative part. In either case it specifies the alignment
1384 to be applied to any record or array type which has otherwise standard
1387 If the alignment for a record or array type is not specified (using
1388 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1389 clause), the GNAT uses the default alignment as described previously.
1391 @node Pragma Convention_Identifier
1392 @unnumberedsec Pragma Convention_Identifier
1393 @findex Convention_Identifier
1394 @cindex Conventions, synonyms
1398 @smallexample @c ada
1399 pragma Convention_Identifier (
1400 [Name =>] IDENTIFIER,
1401 [Convention =>] convention_IDENTIFIER);
1405 This pragma provides a mechanism for supplying synonyms for existing
1406 convention identifiers. The @code{Name} identifier can subsequently
1407 be used as a synonym for the given convention in other pragmas (including
1408 for example pragma @code{Import} or another @code{Convention_Identifier}
1409 pragma). As an example of the use of this, suppose you had legacy code
1410 which used Fortran77 as the identifier for Fortran. Then the pragma:
1412 @smallexample @c ada
1413 pragma Convention_Identifier (Fortran77, Fortran);
1417 would allow the use of the convention identifier @code{Fortran77} in
1418 subsequent code, avoiding the need to modify the sources. As another
1419 example, you could use this to parametrize convention requirements
1420 according to systems. Suppose you needed to use @code{Stdcall} on
1421 windows systems, and @code{C} on some other system, then you could
1422 define a convention identifier @code{Library} and use a single
1423 @code{Convention_Identifier} pragma to specify which convention
1424 would be used system-wide.
1426 @node Pragma CPP_Class
1427 @unnumberedsec Pragma CPP_Class
1429 @cindex Interfacing with C++
1433 @smallexample @c ada
1434 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1438 The argument denotes an entity in the current declarative region that is
1439 declared as a tagged record type. It indicates that the type corresponds
1440 to an externally declared C++ class type, and is to be laid out the same
1441 way that C++ would lay out the type.
1443 Types for which @code{CPP_Class} is specified do not have assignment or
1444 equality operators defined (such operations can be imported or declared
1445 as subprograms as required). Initialization is allowed only by constructor
1446 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1447 limited if not explicitly declared as limited or derived from a limited
1448 type, and a warning is issued in that case.
1450 Pragma @code{CPP_Class} is intended primarily for automatic generation
1451 using an automatic binding generator tool.
1452 See @ref{Interfacing to C++} for related information.
1454 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1455 for backward compatibility but its functionality is available
1456 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1458 @node Pragma CPP_Constructor
1459 @unnumberedsec Pragma CPP_Constructor
1460 @cindex Interfacing with C++
1461 @findex CPP_Constructor
1465 @smallexample @c ada
1466 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1467 [, [External_Name =>] static_string_EXPRESSION ]
1468 [, [Link_Name =>] static_string_EXPRESSION ]);
1472 This pragma identifies an imported function (imported in the usual way
1473 with pragma @code{Import}) as corresponding to a C++ constructor. If
1474 @code{External_Name} and @code{Link_Name} are not specified then the
1475 @code{Entity} argument is a name that must have been previously mentioned
1476 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1477 must be of one of the following forms:
1481 @code{function @var{Fname} return @var{T}'Class}
1484 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1488 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1490 The first form is the default constructor, used when an object of type
1491 @var{T} is created on the Ada side with no explicit constructor. Other
1492 constructors (including the copy constructor, which is simply a special
1493 case of the second form in which the one and only argument is of type
1494 @var{T}), can only appear in two contexts:
1498 On the right side of an initialization of an object of type @var{T}.
1500 In an extension aggregate for an object of a type derived from @var{T}.
1504 Although the constructor is described as a function that returns a value
1505 on the Ada side, it is typically a procedure with an extra implicit
1506 argument (the object being initialized) at the implementation
1507 level. GNAT issues the appropriate call, whatever it is, to get the
1508 object properly initialized.
1510 In the case of derived objects, you may use one of two possible forms
1511 for declaring and creating an object:
1514 @item @code{New_Object : Derived_T}
1515 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1519 In the first case the default constructor is called and extension fields
1520 if any are initialized according to the default initialization
1521 expressions in the Ada declaration. In the second case, the given
1522 constructor is called and the extension aggregate indicates the explicit
1523 values of the extension fields.
1525 If no constructors are imported, it is impossible to create any objects
1526 on the Ada side. If no default constructor is imported, only the
1527 initialization forms using an explicit call to a constructor are
1530 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1531 using an automatic binding generator tool.
1532 See @ref{Interfacing to C++} for more related information.
1534 @node Pragma CPP_Virtual
1535 @unnumberedsec Pragma CPP_Virtual
1536 @cindex Interfacing to C++
1539 This pragma is now obsolete has has no effect because GNAT generates
1540 the same object layout than the G++ compiler.
1542 See @ref{Interfacing to C++} for related information.
1544 @node Pragma CPP_Vtable
1545 @unnumberedsec Pragma CPP_Vtable
1546 @cindex Interfacing with C++
1549 This pragma is now obsolete has has no effect because GNAT generates
1550 the same object layout than the G++ compiler.
1552 See @ref{Interfacing to C++} for related information.
1555 @unnumberedsec Pragma Debug
1560 @smallexample @c ada
1561 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1563 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1565 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1569 The procedure call argument has the syntactic form of an expression, meeting
1570 the syntactic requirements for pragmas.
1572 If debug pragmas are not enabled or if the condition is present and evaluates
1573 to False, this pragma has no effect. If debug pragmas are enabled, the
1574 semantics of the pragma is exactly equivalent to the procedure call statement
1575 corresponding to the argument with a terminating semicolon. Pragmas are
1576 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1577 intersperse calls to debug procedures in the middle of declarations. Debug
1578 pragmas can be enabled either by use of the command line switch @option{-gnata}
1579 or by use of the configuration pragma @code{Debug_Policy}.
1581 @node Pragma Debug_Policy
1582 @unnumberedsec Pragma Debug_Policy
1583 @findex Debug_Policy
1587 @smallexample @c ada
1588 pragma Debug_Policy (CHECK | IGNORE);
1592 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1593 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1594 This pragma overrides the effect of the @option{-gnata} switch on the
1597 @node Pragma Detect_Blocking
1598 @unnumberedsec Pragma Detect_Blocking
1599 @findex Detect_Blocking
1603 @smallexample @c ada
1604 pragma Detect_Blocking;
1608 This is a configuration pragma that forces the detection of potentially
1609 blocking operations within a protected operation, and to raise Program_Error
1612 @node Pragma Elaboration_Checks
1613 @unnumberedsec Pragma Elaboration_Checks
1614 @cindex Elaboration control
1615 @findex Elaboration_Checks
1619 @smallexample @c ada
1620 pragma Elaboration_Checks (Dynamic | Static);
1624 This is a configuration pragma that provides control over the
1625 elaboration model used by the compilation affected by the
1626 pragma. If the parameter is @code{Dynamic},
1627 then the dynamic elaboration
1628 model described in the Ada Reference Manual is used, as though
1629 the @option{-gnatE} switch had been specified on the command
1630 line. If the parameter is @code{Static}, then the default GNAT static
1631 model is used. This configuration pragma overrides the setting
1632 of the command line. For full details on the elaboration models
1633 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1634 gnat_ugn, @value{EDITION} User's Guide}.
1636 @node Pragma Eliminate
1637 @unnumberedsec Pragma Eliminate
1638 @cindex Elimination of unused subprograms
1643 @smallexample @c ada
1645 [Unit_Name =>] IDENTIFIER |
1646 SELECTED_COMPONENT);
1649 [Unit_Name =>] IDENTIFIER |
1651 [Entity =>] IDENTIFIER |
1652 SELECTED_COMPONENT |
1654 [,OVERLOADING_RESOLUTION]);
1656 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1659 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1662 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1664 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1665 Result_Type => result_SUBTYPE_NAME]
1667 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1668 SUBTYPE_NAME ::= STRING_VALUE
1670 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1671 SOURCE_TRACE ::= STRING_VALUE
1673 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1677 This pragma indicates that the given entity is not used outside the
1678 compilation unit it is defined in. The entity must be an explicitly declared
1679 subprogram; this includes generic subprogram instances and
1680 subprograms declared in generic package instances.
1682 If the entity to be eliminated is a library level subprogram, then
1683 the first form of pragma @code{Eliminate} is used with only a single argument.
1684 In this form, the @code{Unit_Name} argument specifies the name of the
1685 library level unit to be eliminated.
1687 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1688 are required. If item is an entity of a library package, then the first
1689 argument specifies the unit name, and the second argument specifies
1690 the particular entity. If the second argument is in string form, it must
1691 correspond to the internal manner in which GNAT stores entity names (see
1692 compilation unit Namet in the compiler sources for details).
1694 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1695 to distinguish between overloaded subprograms. If a pragma does not contain
1696 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1697 subprograms denoted by the first two parameters.
1699 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1700 to be eliminated in a manner similar to that used for the extended
1701 @code{Import} and @code{Export} pragmas, except that the subtype names are
1702 always given as strings. At the moment, this form of distinguishing
1703 overloaded subprograms is implemented only partially, so we do not recommend
1704 using it for practical subprogram elimination.
1706 Note that in case of a parameterless procedure its profile is represented
1707 as @code{Parameter_Types => ("")}
1709 Alternatively, the @code{Source_Location} parameter is used to specify
1710 which overloaded alternative is to be eliminated by pointing to the
1711 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1712 source text. The string literal (or concatenation of string literals)
1713 given as SOURCE_TRACE must have the following format:
1715 @smallexample @c ada
1716 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1721 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1722 FILE_NAME ::= STRING_LITERAL
1723 LINE_NUMBER ::= DIGIT @{DIGIT@}
1726 SOURCE_TRACE should be the short name of the source file (with no directory
1727 information), and LINE_NUMBER is supposed to point to the line where the
1728 defining name of the subprogram is located.
1730 For the subprograms that are not a part of generic instantiations, only one
1731 SOURCE_LOCATION is used. If a subprogram is declared in a package
1732 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1733 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1734 second one denotes the declaration of the corresponding subprogram in the
1735 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1736 in case of nested instantiations.
1738 The effect of the pragma is to allow the compiler to eliminate
1739 the code or data associated with the named entity. Any reference to
1740 an eliminated entity outside the compilation unit it is defined in,
1741 causes a compile time or link time error.
1743 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1744 in a system independent manner, with unused entities eliminated, without
1745 the requirement of modifying the source text. Normally the required set
1746 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1747 tool. Elimination of unused entities local to a compilation unit is
1748 automatic, without requiring the use of pragma @code{Eliminate}.
1750 Note that the reason this pragma takes string literals where names might
1751 be expected is that a pragma @code{Eliminate} can appear in a context where the
1752 relevant names are not visible.
1754 Note that any change in the source files that includes removing, splitting of
1755 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1758 It is legal to use pragma Eliminate where the referenced entity is a
1759 dispatching operation, but it is not clear what this would mean, since
1760 in general the call does not know which entity is actually being called.
1761 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1763 @node Pragma Export_Exception
1764 @unnumberedsec Pragma Export_Exception
1766 @findex Export_Exception
1770 @smallexample @c ada
1771 pragma Export_Exception (
1772 [Internal =>] LOCAL_NAME
1773 [, [External =>] EXTERNAL_SYMBOL]
1774 [, [Form =>] Ada | VMS]
1775 [, [Code =>] static_integer_EXPRESSION]);
1779 | static_string_EXPRESSION
1783 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1784 causes the specified exception to be propagated outside of the Ada program,
1785 so that it can be handled by programs written in other OpenVMS languages.
1786 This pragma establishes an external name for an Ada exception and makes the
1787 name available to the OpenVMS Linker as a global symbol. For further details
1788 on this pragma, see the
1789 DEC Ada Language Reference Manual, section 13.9a3.2.
1791 @node Pragma Export_Function
1792 @unnumberedsec Pragma Export_Function
1793 @cindex Argument passing mechanisms
1794 @findex Export_Function
1799 @smallexample @c ada
1800 pragma Export_Function (
1801 [Internal =>] LOCAL_NAME
1802 [, [External =>] EXTERNAL_SYMBOL]
1803 [, [Parameter_Types =>] PARAMETER_TYPES]
1804 [, [Result_Type =>] result_SUBTYPE_MARK]
1805 [, [Mechanism =>] MECHANISM]
1806 [, [Result_Mechanism =>] MECHANISM_NAME]);
1810 | static_string_EXPRESSION
1815 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1819 | subtype_Name ' Access
1823 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1825 MECHANISM_ASSOCIATION ::=
1826 [formal_parameter_NAME =>] MECHANISM_NAME
1831 | Descriptor [([Class =>] CLASS_NAME)]
1832 | Short_Descriptor [([Class =>] CLASS_NAME)]
1834 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1838 Use this pragma to make a function externally callable and optionally
1839 provide information on mechanisms to be used for passing parameter and
1840 result values. We recommend, for the purposes of improving portability,
1841 this pragma always be used in conjunction with a separate pragma
1842 @code{Export}, which must precede the pragma @code{Export_Function}.
1843 GNAT does not require a separate pragma @code{Export}, but if none is
1844 present, @code{Convention Ada} is assumed, which is usually
1845 not what is wanted, so it is usually appropriate to use this
1846 pragma in conjunction with a @code{Export} or @code{Convention}
1847 pragma that specifies the desired foreign convention.
1848 Pragma @code{Export_Function}
1849 (and @code{Export}, if present) must appear in the same declarative
1850 region as the function to which they apply.
1852 @var{internal_name} must uniquely designate the function to which the
1853 pragma applies. If more than one function name exists of this name in
1854 the declarative part you must use the @code{Parameter_Types} and
1855 @code{Result_Type} parameters is mandatory to achieve the required
1856 unique designation. @var{subtype_mark}s in these parameters must
1857 exactly match the subtypes in the corresponding function specification,
1858 using positional notation to match parameters with subtype marks.
1859 The form with an @code{'Access} attribute can be used to match an
1860 anonymous access parameter.
1863 @cindex Passing by descriptor
1864 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1865 The default behavior for Export_Function is to accept either 64bit or
1866 32bit descriptors unless short_descriptor is specified, then only 32bit
1867 descriptors are accepted.
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)]
1937 | Short_Descriptor [([Class =>] CLASS_NAME)]
1939 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1943 This pragma is identical to @code{Export_Function} except that it
1944 applies to a procedure rather than a function and the parameters
1945 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1946 GNAT does not require a separate pragma @code{Export}, but if none is
1947 present, @code{Convention Ada} is assumed, which is usually
1948 not what is wanted, so it is usually appropriate to use this
1949 pragma in conjunction with a @code{Export} or @code{Convention}
1950 pragma that specifies the desired foreign convention.
1953 @cindex Passing by descriptor
1954 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1955 The default behavior for Export_Procedure is to accept either 64bit or
1956 32bit descriptors unless short_descriptor is specified, then only 32bit
1957 descriptors are accepted.
1959 @cindex Suppressing external name
1960 Special treatment is given if the EXTERNAL is an explicit null
1961 string or a static string expressions that evaluates to the null
1962 string. In this case, no external name is generated. This form
1963 still allows the specification of parameter mechanisms.
1965 @node Pragma Export_Value
1966 @unnumberedsec Pragma Export_Value
1967 @findex Export_Value
1971 @smallexample @c ada
1972 pragma Export_Value (
1973 [Value =>] static_integer_EXPRESSION,
1974 [Link_Name =>] static_string_EXPRESSION);
1978 This pragma serves to export a static integer value for external use.
1979 The first argument specifies the value to be exported. The Link_Name
1980 argument specifies the symbolic name to be associated with the integer
1981 value. This pragma is useful for defining a named static value in Ada
1982 that can be referenced in assembly language units to be linked with
1983 the application. This pragma is currently supported only for the
1984 AAMP target and is ignored for other targets.
1986 @node Pragma Export_Valued_Procedure
1987 @unnumberedsec Pragma Export_Valued_Procedure
1988 @findex Export_Valued_Procedure
1992 @smallexample @c ada
1993 pragma Export_Valued_Procedure (
1994 [Internal =>] LOCAL_NAME
1995 [, [External =>] EXTERNAL_SYMBOL]
1996 [, [Parameter_Types =>] PARAMETER_TYPES]
1997 [, [Mechanism =>] MECHANISM]);
2001 | static_string_EXPRESSION
2006 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2010 | subtype_Name ' Access
2014 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2016 MECHANISM_ASSOCIATION ::=
2017 [formal_parameter_NAME =>] MECHANISM_NAME
2022 | Descriptor [([Class =>] CLASS_NAME)]
2023 | Short_Descriptor [([Class =>] CLASS_NAME)]
2025 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2029 This pragma is identical to @code{Export_Procedure} except that the
2030 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2031 mode @code{OUT}, and externally the subprogram is treated as a function
2032 with this parameter as the result of the function. GNAT provides for
2033 this capability to allow the use of @code{OUT} and @code{IN OUT}
2034 parameters in interfacing to external functions (which are not permitted
2036 GNAT does not require a separate pragma @code{Export}, but if none is
2037 present, @code{Convention Ada} is assumed, which is almost certainly
2038 not what is wanted since the whole point of this pragma is to interface
2039 with foreign language functions, so it is usually appropriate to use this
2040 pragma in conjunction with a @code{Export} or @code{Convention}
2041 pragma that specifies the desired foreign convention.
2044 @cindex Passing by descriptor
2045 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2046 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2047 32bit descriptors unless short_descriptor is specified, then only 32bit
2048 descriptors are accepted.
2050 @cindex Suppressing external name
2051 Special treatment is given if the EXTERNAL is an explicit null
2052 string or a static string expressions that evaluates to the null
2053 string. In this case, no external name is generated. This form
2054 still allows the specification of parameter mechanisms.
2056 @node Pragma Extend_System
2057 @unnumberedsec Pragma Extend_System
2058 @cindex @code{system}, extending
2060 @findex Extend_System
2064 @smallexample @c ada
2065 pragma Extend_System ([Name =>] IDENTIFIER);
2069 This pragma is used to provide backwards compatibility with other
2070 implementations that extend the facilities of package @code{System}. In
2071 GNAT, @code{System} contains only the definitions that are present in
2072 the Ada RM@. However, other implementations, notably the DEC Ada 83
2073 implementation, provide many extensions to package @code{System}.
2075 For each such implementation accommodated by this pragma, GNAT provides a
2076 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2077 implementation, which provides the required additional definitions. You
2078 can use this package in two ways. You can @code{with} it in the normal
2079 way and access entities either by selection or using a @code{use}
2080 clause. In this case no special processing is required.
2082 However, if existing code contains references such as
2083 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2084 definitions provided in package @code{System}, you may use this pragma
2085 to extend visibility in @code{System} in a non-standard way that
2086 provides greater compatibility with the existing code. Pragma
2087 @code{Extend_System} is a configuration pragma whose single argument is
2088 the name of the package containing the extended definition
2089 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2090 control of this pragma will be processed using special visibility
2091 processing that looks in package @code{System.Aux_@var{xxx}} where
2092 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2093 package @code{System}, but not found in package @code{System}.
2095 You can use this pragma either to access a predefined @code{System}
2096 extension supplied with the compiler, for example @code{Aux_DEC} or
2097 you can construct your own extension unit following the above
2098 definition. Note that such a package is a child of @code{System}
2099 and thus is considered part of the implementation. To compile
2100 it you will have to use the appropriate switch for compiling
2101 system units. @xref{Top, @value{EDITION} User's Guide, About This
2102 Guide,, gnat_ugn, @value{EDITION} User's Guide}, for details.
2104 @node Pragma External
2105 @unnumberedsec Pragma External
2110 @smallexample @c ada
2112 [ Convention =>] convention_IDENTIFIER,
2113 [ Entity =>] LOCAL_NAME
2114 [, [External_Name =>] static_string_EXPRESSION ]
2115 [, [Link_Name =>] static_string_EXPRESSION ]);
2119 This pragma is identical in syntax and semantics to pragma
2120 @code{Export} as defined in the Ada Reference Manual. It is
2121 provided for compatibility with some Ada 83 compilers that
2122 used this pragma for exactly the same purposes as pragma
2123 @code{Export} before the latter was standardized.
2125 @node Pragma External_Name_Casing
2126 @unnumberedsec Pragma External_Name_Casing
2127 @cindex Dec Ada 83 casing compatibility
2128 @cindex External Names, casing
2129 @cindex Casing of External names
2130 @findex External_Name_Casing
2134 @smallexample @c ada
2135 pragma External_Name_Casing (
2136 Uppercase | Lowercase
2137 [, Uppercase | Lowercase | As_Is]);
2141 This pragma provides control over the casing of external names associated
2142 with Import and Export pragmas. There are two cases to consider:
2145 @item Implicit external names
2146 Implicit external names are derived from identifiers. The most common case
2147 arises when a standard Ada Import or Export pragma is used with only two
2150 @smallexample @c ada
2151 pragma Import (C, C_Routine);
2155 Since Ada is a case-insensitive language, the spelling of the identifier in
2156 the Ada source program does not provide any information on the desired
2157 casing of the external name, and so a convention is needed. In GNAT the
2158 default treatment is that such names are converted to all lower case
2159 letters. This corresponds to the normal C style in many environments.
2160 The first argument of pragma @code{External_Name_Casing} can be used to
2161 control this treatment. If @code{Uppercase} is specified, then the name
2162 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2163 then the normal default of all lower case letters will be used.
2165 This same implicit treatment is also used in the case of extended DEC Ada 83
2166 compatible Import and Export pragmas where an external name is explicitly
2167 specified using an identifier rather than a string.
2169 @item Explicit external names
2170 Explicit external names are given as string literals. The most common case
2171 arises when a standard Ada Import or Export pragma is used with three
2174 @smallexample @c ada
2175 pragma Import (C, C_Routine, "C_routine");
2179 In this case, the string literal normally provides the exact casing required
2180 for the external name. The second argument of pragma
2181 @code{External_Name_Casing} may be used to modify this behavior.
2182 If @code{Uppercase} is specified, then the name
2183 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2184 then the name will be forced to all lowercase letters. A specification of
2185 @code{As_Is} provides the normal default behavior in which the casing is
2186 taken from the string provided.
2190 This pragma may appear anywhere that a pragma is valid. In particular, it
2191 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2192 case it applies to all subsequent compilations, or it can be used as a program
2193 unit pragma, in which case it only applies to the current unit, or it can
2194 be used more locally to control individual Import/Export pragmas.
2196 It is primarily intended for use with OpenVMS systems, where many
2197 compilers convert all symbols to upper case by default. For interfacing to
2198 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2201 @smallexample @c ada
2202 pragma External_Name_Casing (Uppercase, Uppercase);
2206 to enforce the upper casing of all external symbols.
2208 @node Pragma Fast_Math
2209 @unnumberedsec Pragma Fast_Math
2214 @smallexample @c ada
2219 This is a configuration pragma which activates a mode in which speed is
2220 considered more important for floating-point operations than absolutely
2221 accurate adherence to the requirements of the standard. Currently the
2222 following operations are affected:
2225 @item Complex Multiplication
2226 The normal simple formula for complex multiplication can result in intermediate
2227 overflows for numbers near the end of the range. The Ada standard requires that
2228 this situation be detected and corrected by scaling, but in Fast_Math mode such
2229 cases will simply result in overflow. Note that to take advantage of this you
2230 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2231 under control of the pragma, rather than use the preinstantiated versions.
2234 @node Pragma Favor_Top_Level
2235 @unnumberedsec Pragma Favor_Top_Level
2236 @findex Favor_Top_Level
2240 @smallexample @c ada
2241 pragma Favor_Top_Level (type_NAME);
2245 The named type must be an access-to-subprogram type. This pragma is an
2246 efficiency hint to the compiler, regarding the use of 'Access or
2247 'Unrestricted_Access on nested (non-library-level) subprograms. The
2248 pragma means that nested subprograms are not used with this type, or
2249 are rare, so that the generated code should be efficient in the
2250 top-level case. When this pragma is used, dynamically generated
2251 trampolines may be used on some targets for nested subprograms.
2252 See also the No_Implicit_Dynamic_Code restriction.
2254 @node Pragma Finalize_Storage_Only
2255 @unnumberedsec Pragma Finalize_Storage_Only
2256 @findex Finalize_Storage_Only
2260 @smallexample @c ada
2261 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2265 This pragma allows the compiler not to emit a Finalize call for objects
2266 defined at the library level. This is mostly useful for types where
2267 finalization is only used to deal with storage reclamation since in most
2268 environments it is not necessary to reclaim memory just before terminating
2269 execution, hence the name.
2271 @node Pragma Float_Representation
2272 @unnumberedsec Pragma Float_Representation
2274 @findex Float_Representation
2278 @smallexample @c ada
2279 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2281 FLOAT_REP ::= VAX_Float | IEEE_Float
2285 In the one argument form, this pragma is a configuration pragma which
2286 allows control over the internal representation chosen for the predefined
2287 floating point types declared in the packages @code{Standard} and
2288 @code{System}. On all systems other than OpenVMS, the argument must
2289 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2290 argument may be @code{VAX_Float} to specify the use of the VAX float
2291 format for the floating-point types in Standard. This requires that
2292 the standard runtime libraries be recompiled. @xref{The GNAT Run-Time
2293 Library Builder gnatlbr,,, gnat_ugn, @value{EDITION} User's Guide
2294 OpenVMS}, for a description of the @code{GNAT LIBRARY} command.
2296 The two argument form specifies the representation to be used for
2297 the specified floating-point type. On all systems other than OpenVMS,
2299 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2300 argument may be @code{VAX_Float} to specify the use of the VAX float
2305 For digits values up to 6, F float format will be used.
2307 For digits values from 7 to 9, G float format will be used.
2309 For digits values from 10 to 15, F float format will be used.
2311 Digits values above 15 are not allowed.
2315 @unnumberedsec Pragma Ident
2320 @smallexample @c ada
2321 pragma Ident (static_string_EXPRESSION);
2325 This pragma provides a string identification in the generated object file,
2326 if the system supports the concept of this kind of identification string.
2327 This pragma is allowed only in the outermost declarative part or
2328 declarative items of a compilation unit. If more than one @code{Ident}
2329 pragma is given, only the last one processed is effective.
2331 On OpenVMS systems, the effect of the pragma is identical to the effect of
2332 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2333 maximum allowed length is 31 characters, so if it is important to
2334 maintain compatibility with this compiler, you should obey this length
2337 @node Pragma Implemented_By_Entry
2338 @unnumberedsec Pragma Implemented_By_Entry
2339 @findex Implemented_By_Entry
2343 @smallexample @c ada
2344 pragma Implemented_By_Entry (LOCAL_NAME);
2348 This is a representation pragma which applies to protected, synchronized and
2349 task interface primitives. If the pragma is applied to primitive operation Op
2350 of interface Iface, it is illegal to override Op in a type that implements
2351 Iface, with anything other than an entry.
2353 @smallexample @c ada
2354 type Iface is protected interface;
2355 procedure Do_Something (Object : in out Iface) is abstract;
2356 pragma Implemented_By_Entry (Do_Something);
2358 protected type P is new Iface with
2359 procedure Do_Something; -- Illegal
2362 task type T is new Iface with
2363 entry Do_Something; -- Legal
2368 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2369 is intended to be used in conjunction with dispatching requeue statements as
2370 described in AI05-0030. Should the ARG decide on an official name and syntax,
2371 this pragma will become language-defined rather than GNAT-specific.
2373 @node Pragma Implicit_Packing
2374 @unnumberedsec Pragma Implicit_Packing
2375 @findex Implicit_Packing
2379 @smallexample @c ada
2380 pragma Implicit_Packing;
2384 This is a configuration pragma that requests implicit packing for packed
2385 arrays for which a size clause is given but no explicit pragma Pack or
2386 specification of Component_Size is present. Consider this example:
2388 @smallexample @c ada
2389 type R is array (0 .. 7) of Boolean;
2394 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2395 does not change the layout of a composite object. So the Size clause in the
2396 above example is normally rejected, since the default layout of the array uses
2397 8-bit components, and thus the array requires a minimum of 64 bits.
2399 If this declaration is compiled in a region of code covered by an occurrence
2400 of the configuration pragma Implicit_Packing, then the Size clause in this
2401 and similar examples will cause implicit packing and thus be accepted. For
2402 this implicit packing to occur, the type in question must be an array of small
2403 components whose size is known at compile time, and the Size clause must
2404 specify the exact size that corresponds to the length of the array multiplied
2405 by the size in bits of the component type.
2406 @cindex Array packing
2408 @node Pragma Import_Exception
2409 @unnumberedsec Pragma Import_Exception
2411 @findex Import_Exception
2415 @smallexample @c ada
2416 pragma Import_Exception (
2417 [Internal =>] LOCAL_NAME
2418 [, [External =>] EXTERNAL_SYMBOL]
2419 [, [Form =>] Ada | VMS]
2420 [, [Code =>] static_integer_EXPRESSION]);
2424 | static_string_EXPRESSION
2428 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2429 It allows OpenVMS conditions (for example, from OpenVMS system services or
2430 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2431 The pragma specifies that the exception associated with an exception
2432 declaration in an Ada program be defined externally (in non-Ada code).
2433 For further details on this pragma, see the
2434 DEC Ada Language Reference Manual, section 13.9a.3.1.
2436 @node Pragma Import_Function
2437 @unnumberedsec Pragma Import_Function
2438 @findex Import_Function
2442 @smallexample @c ada
2443 pragma Import_Function (
2444 [Internal =>] LOCAL_NAME,
2445 [, [External =>] EXTERNAL_SYMBOL]
2446 [, [Parameter_Types =>] PARAMETER_TYPES]
2447 [, [Result_Type =>] SUBTYPE_MARK]
2448 [, [Mechanism =>] MECHANISM]
2449 [, [Result_Mechanism =>] MECHANISM_NAME]
2450 [, [First_Optional_Parameter =>] IDENTIFIER]);
2454 | static_string_EXPRESSION
2458 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2462 | subtype_Name ' Access
2466 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2468 MECHANISM_ASSOCIATION ::=
2469 [formal_parameter_NAME =>] MECHANISM_NAME
2474 | Descriptor [([Class =>] CLASS_NAME)]
2475 | Short_Descriptor [([Class =>] CLASS_NAME)]
2477 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2481 This pragma is used in conjunction with a pragma @code{Import} to
2482 specify additional information for an imported function. The pragma
2483 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2484 @code{Import_Function} pragma and both must appear in the same
2485 declarative part as the function specification.
2487 The @var{Internal} argument must uniquely designate
2488 the function to which the
2489 pragma applies. If more than one function name exists of this name in
2490 the declarative part you must use the @code{Parameter_Types} and
2491 @var{Result_Type} parameters to achieve the required unique
2492 designation. Subtype marks in these parameters must exactly match the
2493 subtypes in the corresponding function specification, using positional
2494 notation to match parameters with subtype marks.
2495 The form with an @code{'Access} attribute can be used to match an
2496 anonymous access parameter.
2498 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2499 parameters to specify passing mechanisms for the
2500 parameters and result. If you specify a single mechanism name, it
2501 applies to all parameters. Otherwise you may specify a mechanism on a
2502 parameter by parameter basis using either positional or named
2503 notation. If the mechanism is not specified, the default mechanism
2507 @cindex Passing by descriptor
2508 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2509 The default behavior for Import_Function is to pass a 64bit descriptor
2510 unless short_descriptor is specified, then a 32bit descriptor is passed.
2512 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2513 It specifies that the designated parameter and all following parameters
2514 are optional, meaning that they are not passed at the generated code
2515 level (this is distinct from the notion of optional parameters in Ada
2516 where the parameters are passed anyway with the designated optional
2517 parameters). All optional parameters must be of mode @code{IN} and have
2518 default parameter values that are either known at compile time
2519 expressions, or uses of the @code{'Null_Parameter} attribute.
2521 @node Pragma Import_Object
2522 @unnumberedsec Pragma Import_Object
2523 @findex Import_Object
2527 @smallexample @c ada
2528 pragma Import_Object
2529 [Internal =>] LOCAL_NAME
2530 [, [External =>] EXTERNAL_SYMBOL]
2531 [, [Size =>] EXTERNAL_SYMBOL]);
2535 | static_string_EXPRESSION
2539 This pragma designates an object as imported, and apart from the
2540 extended rules for external symbols, is identical in effect to the use of
2541 the normal @code{Import} pragma applied to an object. Unlike the
2542 subprogram case, you need not use a separate @code{Import} pragma,
2543 although you may do so (and probably should do so from a portability
2544 point of view). @var{size} is syntax checked, but otherwise ignored by
2547 @node Pragma Import_Procedure
2548 @unnumberedsec Pragma Import_Procedure
2549 @findex Import_Procedure
2553 @smallexample @c ada
2554 pragma Import_Procedure (
2555 [Internal =>] LOCAL_NAME
2556 [, [External =>] EXTERNAL_SYMBOL]
2557 [, [Parameter_Types =>] PARAMETER_TYPES]
2558 [, [Mechanism =>] MECHANISM]
2559 [, [First_Optional_Parameter =>] IDENTIFIER]);
2563 | static_string_EXPRESSION
2567 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2571 | subtype_Name ' Access
2575 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2577 MECHANISM_ASSOCIATION ::=
2578 [formal_parameter_NAME =>] MECHANISM_NAME
2583 | Descriptor [([Class =>] CLASS_NAME)]
2584 | Short_Descriptor [([Class =>] CLASS_NAME)]
2586 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2590 This pragma is identical to @code{Import_Function} except that it
2591 applies to a procedure rather than a function and the parameters
2592 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2594 @node Pragma Import_Valued_Procedure
2595 @unnumberedsec Pragma Import_Valued_Procedure
2596 @findex Import_Valued_Procedure
2600 @smallexample @c ada
2601 pragma Import_Valued_Procedure (
2602 [Internal =>] LOCAL_NAME
2603 [, [External =>] EXTERNAL_SYMBOL]
2604 [, [Parameter_Types =>] PARAMETER_TYPES]
2605 [, [Mechanism =>] MECHANISM]
2606 [, [First_Optional_Parameter =>] IDENTIFIER]);
2610 | static_string_EXPRESSION
2614 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2618 | subtype_Name ' Access
2622 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2624 MECHANISM_ASSOCIATION ::=
2625 [formal_parameter_NAME =>] MECHANISM_NAME
2630 | Descriptor [([Class =>] CLASS_NAME)]
2631 | Short_Descriptor [([Class =>] CLASS_NAME)]
2633 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2637 This pragma is identical to @code{Import_Procedure} except that the
2638 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2639 mode @code{OUT}, and externally the subprogram is treated as a function
2640 with this parameter as the result of the function. The purpose of this
2641 capability is to allow the use of @code{OUT} and @code{IN OUT}
2642 parameters in interfacing to external functions (which are not permitted
2643 in Ada functions). You may optionally use the @code{Mechanism}
2644 parameters to specify passing mechanisms for the parameters.
2645 If you specify a single mechanism name, it applies to all parameters.
2646 Otherwise you may specify a mechanism on a parameter by parameter
2647 basis using either positional or named notation. If the mechanism is not
2648 specified, the default mechanism is used.
2650 Note that it is important to use this pragma in conjunction with a separate
2651 pragma Import that specifies the desired convention, since otherwise the
2652 default convention is Ada, which is almost certainly not what is required.
2654 @node Pragma Initialize_Scalars
2655 @unnumberedsec Pragma Initialize_Scalars
2656 @findex Initialize_Scalars
2657 @cindex debugging with Initialize_Scalars
2661 @smallexample @c ada
2662 pragma Initialize_Scalars;
2666 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2667 two important differences. First, there is no requirement for the pragma
2668 to be used uniformly in all units of a partition, in particular, it is fine
2669 to use this just for some or all of the application units of a partition,
2670 without needing to recompile the run-time library.
2672 In the case where some units are compiled with the pragma, and some without,
2673 then a declaration of a variable where the type is defined in package
2674 Standard or is locally declared will always be subject to initialization,
2675 as will any declaration of a scalar variable. For composite variables,
2676 whether the variable is initialized may also depend on whether the package
2677 in which the type of the variable is declared is compiled with the pragma.
2679 The other important difference is that you can control the value used
2680 for initializing scalar objects. At bind time, you can select several
2681 options for initialization. You can
2682 initialize with invalid values (similar to Normalize_Scalars, though for
2683 Initialize_Scalars it is not always possible to determine the invalid
2684 values in complex cases like signed component fields with non-standard
2685 sizes). You can also initialize with high or
2686 low values, or with a specified bit pattern. See the users guide for binder
2687 options for specifying these cases.
2689 This means that you can compile a program, and then without having to
2690 recompile the program, you can run it with different values being used
2691 for initializing otherwise uninitialized values, to test if your program
2692 behavior depends on the choice. Of course the behavior should not change,
2693 and if it does, then most likely you have an erroneous reference to an
2694 uninitialized value.
2696 It is even possible to change the value at execution time eliminating even
2697 the need to rebind with a different switch using an environment variable.
2698 See the GNAT users guide for details.
2700 Note that pragma @code{Initialize_Scalars} is particularly useful in
2701 conjunction with the enhanced validity checking that is now provided
2702 in GNAT, which checks for invalid values under more conditions.
2703 Using this feature (see description of the @option{-gnatV} flag in the
2704 users guide) in conjunction with pragma @code{Initialize_Scalars}
2705 provides a powerful new tool to assist in the detection of problems
2706 caused by uninitialized variables.
2708 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2709 effect on the generated code. This may cause your code to be
2710 substantially larger. It may also cause an increase in the amount
2711 of stack required, so it is probably a good idea to turn on stack
2712 checking (see description of stack checking in the GNAT users guide)
2713 when using this pragma.
2715 @node Pragma Inline_Always
2716 @unnumberedsec Pragma Inline_Always
2717 @findex Inline_Always
2721 @smallexample @c ada
2722 pragma Inline_Always (NAME [, NAME]);
2726 Similar to pragma @code{Inline} except that inlining is not subject to
2727 the use of option @option{-gnatn} and the inlining happens regardless of
2728 whether this option is used.
2730 @node Pragma Inline_Generic
2731 @unnumberedsec Pragma Inline_Generic
2732 @findex Inline_Generic
2736 @smallexample @c ada
2737 pragma Inline_Generic (generic_package_NAME);
2741 This is implemented for compatibility with DEC Ada 83 and is recognized,
2742 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2743 by default when using GNAT@.
2745 @node Pragma Interface
2746 @unnumberedsec Pragma Interface
2751 @smallexample @c ada
2753 [Convention =>] convention_identifier,
2754 [Entity =>] local_NAME
2755 [, [External_Name =>] static_string_expression]
2756 [, [Link_Name =>] static_string_expression]);
2760 This pragma is identical in syntax and semantics to
2761 the standard Ada pragma @code{Import}. It is provided for compatibility
2762 with Ada 83. The definition is upwards compatible both with pragma
2763 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2764 with some extended implementations of this pragma in certain Ada 83
2767 @node Pragma Interface_Name
2768 @unnumberedsec Pragma Interface_Name
2769 @findex Interface_Name
2773 @smallexample @c ada
2774 pragma Interface_Name (
2775 [Entity =>] LOCAL_NAME
2776 [, [External_Name =>] static_string_EXPRESSION]
2777 [, [Link_Name =>] static_string_EXPRESSION]);
2781 This pragma provides an alternative way of specifying the interface name
2782 for an interfaced subprogram, and is provided for compatibility with Ada
2783 83 compilers that use the pragma for this purpose. You must provide at
2784 least one of @var{External_Name} or @var{Link_Name}.
2786 @node Pragma Interrupt_Handler
2787 @unnumberedsec Pragma Interrupt_Handler
2788 @findex Interrupt_Handler
2792 @smallexample @c ada
2793 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2797 This program unit pragma is supported for parameterless protected procedures
2798 as described in Annex C of the Ada Reference Manual. On the AAMP target
2799 the pragma can also be specified for nonprotected parameterless procedures
2800 that are declared at the library level (which includes procedures
2801 declared at the top level of a library package). In the case of AAMP,
2802 when this pragma is applied to a nonprotected procedure, the instruction
2803 @code{IERET} is generated for returns from the procedure, enabling
2804 maskable interrupts, in place of the normal return instruction.
2806 @node Pragma Interrupt_State
2807 @unnumberedsec Pragma Interrupt_State
2808 @findex Interrupt_State
2812 @smallexample @c ada
2813 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2817 Normally certain interrupts are reserved to the implementation. Any attempt
2818 to attach an interrupt causes Program_Error to be raised, as described in
2819 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
2820 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
2821 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2822 interrupt execution. Additionally, signals such as @code{SIGSEGV},
2823 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2824 Ada exceptions, or used to implement run-time functions such as the
2825 @code{abort} statement and stack overflow checking.
2827 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2828 such uses of interrupts. It subsumes the functionality of pragma
2829 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
2830 available on OS/2, Windows or VMS. On all other platforms than VxWorks,
2831 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2832 and may be used to mark interrupts required by the board support package
2835 Interrupts can be in one of three states:
2839 The interrupt is reserved (no Ada handler can be installed), and the
2840 Ada run-time may not install a handler. As a result you are guaranteed
2841 standard system default action if this interrupt is raised.
2845 The interrupt is reserved (no Ada handler can be installed). The run time
2846 is allowed to install a handler for internal control purposes, but is
2847 not required to do so.
2851 The interrupt is unreserved. The user may install a handler to provide
2856 These states are the allowed values of the @code{State} parameter of the
2857 pragma. The @code{Name} parameter is a value of the type
2858 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
2859 @code{Ada.Interrupts.Names}.
2861 This is a configuration pragma, and the binder will check that there
2862 are no inconsistencies between different units in a partition in how a
2863 given interrupt is specified. It may appear anywhere a pragma is legal.
2865 The effect is to move the interrupt to the specified state.
2867 By declaring interrupts to be SYSTEM, you guarantee the standard system
2868 action, such as a core dump.
2870 By declaring interrupts to be USER, you guarantee that you can install
2873 Note that certain signals on many operating systems cannot be caught and
2874 handled by applications. In such cases, the pragma is ignored. See the
2875 operating system documentation, or the value of the array @code{Reserved}
2876 declared in the spec of package @code{System.OS_Interface}.
2878 Overriding the default state of signals used by the Ada runtime may interfere
2879 with an application's runtime behavior in the cases of the synchronous signals,
2880 and in the case of the signal used to implement the @code{abort} statement.
2882 @node Pragma Keep_Names
2883 @unnumberedsec Pragma Keep_Names
2888 @smallexample @c ada
2889 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2893 The @var{LOCAL_NAME} argument
2894 must refer to an enumeration first subtype
2895 in the current declarative part. The effect is to retain the enumeration
2896 literal names for use by @code{Image} and @code{Value} even if a global
2897 @code{Discard_Names} pragma applies. This is useful when you want to
2898 generally suppress enumeration literal names and for example you therefore
2899 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2900 want to retain the names for specific enumeration types.
2902 @node Pragma License
2903 @unnumberedsec Pragma License
2905 @cindex License checking
2909 @smallexample @c ada
2910 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2914 This pragma is provided to allow automated checking for appropriate license
2915 conditions with respect to the standard and modified GPL@. A pragma
2916 @code{License}, which is a configuration pragma that typically appears at
2917 the start of a source file or in a separate @file{gnat.adc} file, specifies
2918 the licensing conditions of a unit as follows:
2922 This is used for a unit that can be freely used with no license restrictions.
2923 Examples of such units are public domain units, and units from the Ada
2927 This is used for a unit that is licensed under the unmodified GPL, and which
2928 therefore cannot be @code{with}'ed by a restricted unit.
2931 This is used for a unit licensed under the GNAT modified GPL that includes
2932 a special exception paragraph that specifically permits the inclusion of
2933 the unit in programs without requiring the entire program to be released
2937 This is used for a unit that is restricted in that it is not permitted to
2938 depend on units that are licensed under the GPL@. Typical examples are
2939 proprietary code that is to be released under more restrictive license
2940 conditions. Note that restricted units are permitted to @code{with} units
2941 which are licensed under the modified GPL (this is the whole point of the
2947 Normally a unit with no @code{License} pragma is considered to have an
2948 unknown license, and no checking is done. However, standard GNAT headers
2949 are recognized, and license information is derived from them as follows.
2953 A GNAT license header starts with a line containing 78 hyphens. The following
2954 comment text is searched for the appearance of any of the following strings.
2956 If the string ``GNU General Public License'' is found, then the unit is assumed
2957 to have GPL license, unless the string ``As a special exception'' follows, in
2958 which case the license is assumed to be modified GPL@.
2960 If one of the strings
2961 ``This specification is adapted from the Ada Semantic Interface'' or
2962 ``This specification is derived from the Ada Reference Manual'' is found
2963 then the unit is assumed to be unrestricted.
2967 These default actions means that a program with a restricted license pragma
2968 will automatically get warnings if a GPL unit is inappropriately
2969 @code{with}'ed. For example, the program:
2971 @smallexample @c ada
2974 procedure Secret_Stuff is
2980 if compiled with pragma @code{License} (@code{Restricted}) in a
2981 @file{gnat.adc} file will generate the warning:
2986 >>> license of withed unit "Sem_Ch3" is incompatible
2988 2. with GNAT.Sockets;
2989 3. procedure Secret_Stuff is
2993 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2994 compiler and is licensed under the
2995 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2996 run time, and is therefore licensed under the modified GPL@.
2998 @node Pragma Link_With
2999 @unnumberedsec Pragma Link_With
3004 @smallexample @c ada
3005 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3009 This pragma is provided for compatibility with certain Ada 83 compilers.
3010 It has exactly the same effect as pragma @code{Linker_Options} except
3011 that spaces occurring within one of the string expressions are treated
3012 as separators. For example, in the following case:
3014 @smallexample @c ada
3015 pragma Link_With ("-labc -ldef");
3019 results in passing the strings @code{-labc} and @code{-ldef} as two
3020 separate arguments to the linker. In addition pragma Link_With allows
3021 multiple arguments, with the same effect as successive pragmas.
3023 @node Pragma Linker_Alias
3024 @unnumberedsec Pragma Linker_Alias
3025 @findex Linker_Alias
3029 @smallexample @c ada
3030 pragma Linker_Alias (
3031 [Entity =>] LOCAL_NAME,
3032 [Target =>] static_string_EXPRESSION);
3036 @var{LOCAL_NAME} must refer to an object that is declared at the library
3037 level. This pragma establishes the given entity as a linker alias for the
3038 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3039 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3040 @var{static_string_EXPRESSION} in the object file, that is to say no space
3041 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3042 to the same address as @var{static_string_EXPRESSION} by the linker.
3044 The actual linker name for the target must be used (e.g.@: the fully
3045 encoded name with qualification in Ada, or the mangled name in C++),
3046 or it must be declared using the C convention with @code{pragma Import}
3047 or @code{pragma Export}.
3049 Not all target machines support this pragma. On some of them it is accepted
3050 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3052 @smallexample @c ada
3053 -- Example of the use of pragma Linker_Alias
3057 pragma Export (C, i);
3059 new_name_for_i : Integer;
3060 pragma Linker_Alias (new_name_for_i, "i");
3064 @node Pragma Linker_Constructor
3065 @unnumberedsec Pragma Linker_Constructor
3066 @findex Linker_Constructor
3070 @smallexample @c ada
3071 pragma Linker_Constructor (procedure_LOCAL_NAME);
3075 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3076 is declared at the library level. A procedure to which this pragma is
3077 applied will be treated as an initialization routine by the linker.
3078 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3079 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3080 of the executable is called (or immediately after the shared library is
3081 loaded if the procedure is linked in a shared library), in particular
3082 before the Ada run-time environment is set up.
3084 Because of these specific contexts, the set of operations such a procedure
3085 can perform is very limited and the type of objects it can manipulate is
3086 essentially restricted to the elementary types. In particular, it must only
3087 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3089 This pragma is used by GNAT to implement auto-initialization of shared Stand
3090 Alone Libraries, which provides a related capability without the restrictions
3091 listed above. Where possible, the use of Stand Alone Libraries is preferable
3092 to the use of this pragma.
3094 @node Pragma Linker_Destructor
3095 @unnumberedsec Pragma Linker_Destructor
3096 @findex Linker_Destructor
3100 @smallexample @c ada
3101 pragma Linker_Destructor (procedure_LOCAL_NAME);
3105 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3106 is declared at the library level. A procedure to which this pragma is
3107 applied will be treated as a finalization routine by the linker.
3108 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3109 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3110 of the executable has exited (or immediately before the shared library
3111 is unloaded if the procedure is linked in a shared library), in particular
3112 after the Ada run-time environment is shut down.
3114 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3115 because of these specific contexts.
3117 @node Pragma Linker_Section
3118 @unnumberedsec Pragma Linker_Section
3119 @findex Linker_Section
3123 @smallexample @c ada
3124 pragma Linker_Section (
3125 [Entity =>] LOCAL_NAME,
3126 [Section =>] static_string_EXPRESSION);
3130 @var{LOCAL_NAME} must refer to an object that is declared at the library
3131 level. This pragma specifies the name of the linker section for the given
3132 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3133 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3134 section of the executable (assuming the linker doesn't rename the section).
3136 The compiler normally places library-level objects in standard sections
3137 depending on their type: procedures and functions generally go in the
3138 @code{.text} section, initialized variables in the @code{.data} section
3139 and uninitialized variables in the @code{.bss} section.
3141 Other, special sections may exist on given target machines to map special
3142 hardware, for example I/O ports or flash memory. This pragma is a means to
3143 defer the final layout of the executable to the linker, thus fully working
3144 at the symbolic level with the compiler.
3146 Some file formats do not support arbitrary sections so not all target
3147 machines support this pragma. The use of this pragma may cause a program
3148 execution to be erroneous if it is used to place an entity into an
3149 inappropriate section (e.g.@: a modified variable into the @code{.text}
3150 section). See also @code{pragma Persistent_BSS}.
3152 @smallexample @c ada
3153 -- Example of the use of pragma Linker_Section
3157 pragma Volatile (Port_A);
3158 pragma Linker_Section (Port_A, ".bss.port_a");
3161 pragma Volatile (Port_B);
3162 pragma Linker_Section (Port_B, ".bss.port_b");
3166 @node Pragma Long_Float
3167 @unnumberedsec Pragma Long_Float
3173 @smallexample @c ada
3174 pragma Long_Float (FLOAT_FORMAT);
3176 FLOAT_FORMAT ::= D_Float | G_Float
3180 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3181 It allows control over the internal representation chosen for the predefined
3182 type @code{Long_Float} and for floating point type representations with
3183 @code{digits} specified in the range 7 through 15.
3184 For further details on this pragma, see the
3185 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3186 this pragma, the standard runtime libraries must be recompiled.
3187 @xref{The GNAT Run-Time Library Builder gnatlbr,,, gnat_ugn,
3188 @value{EDITION} User's Guide OpenVMS}, for a description of the
3189 @code{GNAT LIBRARY} command.
3191 @node Pragma Machine_Attribute
3192 @unnumberedsec Pragma Machine_Attribute
3193 @findex Machine_Attribute
3197 @smallexample @c ada
3198 pragma Machine_Attribute (
3199 [Entity =>] LOCAL_NAME,
3200 [Attribute_Name =>] static_string_EXPRESSION
3201 [, [Info =>] static_string_EXPRESSION] );
3205 Machine-dependent attributes can be specified for types and/or
3206 declarations. This pragma is semantically equivalent to
3207 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3208 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3209 in GNU C, where @code{@var{attribute_name}} is recognized by the
3210 target macro @code{TARGET_ATTRIBUTE_TABLE} which is defined for each
3211 machine. The optional parameter @var{info} is transformed into an
3212 identifier, which may make this pragma unusable for some attributes
3213 (parameter of some attributes must be a number or a string).
3214 @xref{Target Attributes,, Defining target-specific uses of
3215 @code{__attribute__}, gccint, GNU Compiler Colletion (GCC) Internals},
3216 further information. It is not possible to specify
3217 attributes defined by other languages, only attributes defined by the
3218 machine the code is intended to run on.
3221 @unnumberedsec Pragma Main
3227 @smallexample @c ada
3229 (MAIN_OPTION [, MAIN_OPTION]);
3232 [STACK_SIZE =>] static_integer_EXPRESSION
3233 | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
3234 | [TIME_SLICING_ENABLED =>] static_boolean_EXPRESSION
3238 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3239 no effect in GNAT, other than being syntax checked.
3241 @node Pragma Main_Storage
3242 @unnumberedsec Pragma Main_Storage
3244 @findex Main_Storage
3248 @smallexample @c ada
3250 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3252 MAIN_STORAGE_OPTION ::=
3253 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3254 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3258 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3259 no effect in GNAT, other than being syntax checked. Note that the pragma
3260 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3262 @node Pragma No_Body
3263 @unnumberedsec Pragma No_Body
3268 @smallexample @c ada
3273 There are a number of cases in which a package spec does not require a body,
3274 and in fact a body is not permitted. GNAT will not permit the spec to be
3275 compiled if there is a body around. The pragma No_Body allows you to provide
3276 a body file, even in a case where no body is allowed. The body file must
3277 contain only comments and a single No_Body pragma. This is recognized by
3278 the compiler as indicating that no body is logically present.
3280 This is particularly useful during maintenance when a package is modified in
3281 such a way that a body needed before is no longer needed. The provision of a
3282 dummy body with a No_Body pragma ensures that there is no interference from
3283 earlier versions of the package body.
3285 @node Pragma No_Return
3286 @unnumberedsec Pragma No_Return
3291 @smallexample @c ada
3292 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3296 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3297 declarations in the current declarative part. A procedure to which this
3298 pragma is applied may not contain any explicit @code{return} statements.
3299 In addition, if the procedure contains any implicit returns from falling
3300 off the end of a statement sequence, then execution of that implicit
3301 return will cause Program_Error to be raised.
3303 One use of this pragma is to identify procedures whose only purpose is to raise
3304 an exception. Another use of this pragma is to suppress incorrect warnings
3305 about missing returns in functions, where the last statement of a function
3306 statement sequence is a call to such a procedure.
3308 Note that in Ada 2005 mode, this pragma is part of the language, and is
3309 identical in effect to the pragma as implemented in Ada 95 mode.
3311 @node Pragma No_Strict_Aliasing
3312 @unnumberedsec Pragma No_Strict_Aliasing
3313 @findex No_Strict_Aliasing
3317 @smallexample @c ada
3318 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3322 @var{type_LOCAL_NAME} must refer to an access type
3323 declaration in the current declarative part. The effect is to inhibit
3324 strict aliasing optimization for the given type. The form with no
3325 arguments is a configuration pragma which applies to all access types
3326 declared in units to which the pragma applies. For a detailed
3327 description of the strict aliasing optimization, and the situations
3328 in which it must be suppressed, see @ref{Optimization and Strict
3329 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3331 @node Pragma Normalize_Scalars
3332 @unnumberedsec Pragma Normalize_Scalars
3333 @findex Normalize_Scalars
3337 @smallexample @c ada
3338 pragma Normalize_Scalars;
3342 This is a language defined pragma which is fully implemented in GNAT@. The
3343 effect is to cause all scalar objects that are not otherwise initialized
3344 to be initialized. The initial values are implementation dependent and
3348 @item Standard.Character
3350 Objects whose root type is Standard.Character are initialized to
3351 Character'Last unless the subtype range excludes NUL (in which case
3352 NUL is used). This choice will always generate an invalid value if
3355 @item Standard.Wide_Character
3357 Objects whose root type is Standard.Wide_Character are initialized to
3358 Wide_Character'Last unless the subtype range excludes NUL (in which case
3359 NUL is used). This choice will always generate an invalid value if
3362 @item Standard.Wide_Wide_Character
3364 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3365 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3366 which case NUL is used). This choice will always generate an invalid value if
3371 Objects of an integer type are treated differently depending on whether
3372 negative values are present in the subtype. If no negative values are
3373 present, then all one bits is used as the initial value except in the
3374 special case where zero is excluded from the subtype, in which case
3375 all zero bits are used. This choice will always generate an invalid
3376 value if one exists.
3378 For subtypes with negative values present, the largest negative number
3379 is used, except in the unusual case where this largest negative number
3380 is in the subtype, and the largest positive number is not, in which case
3381 the largest positive value is used. This choice will always generate
3382 an invalid value if one exists.
3384 @item Floating-Point Types
3385 Objects of all floating-point types are initialized to all 1-bits. For
3386 standard IEEE format, this corresponds to a NaN (not a number) which is
3387 indeed an invalid value.
3389 @item Fixed-Point Types
3390 Objects of all fixed-point types are treated as described above for integers,
3391 with the rules applying to the underlying integer value used to represent
3392 the fixed-point value.
3395 Objects of a modular type are initialized to all one bits, except in
3396 the special case where zero is excluded from the subtype, in which
3397 case all zero bits are used. This choice will always generate an
3398 invalid value if one exists.
3400 @item Enumeration types
3401 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3402 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3403 whose Pos value is zero, in which case a code of zero is used. This choice
3404 will always generate an invalid value if one exists.
3408 @node Pragma Obsolescent
3409 @unnumberedsec Pragma Obsolescent
3414 @smallexample @c ada
3416 [(Entity => NAME [, static_string_EXPRESSION [,Ada_05]])];
3420 This pragma can occur immediately following a declaration of an entity,
3421 including the case of a record component, and usually the Entity name
3422 must match the name of the entity declared by this declaration.
3423 Alternatively, the pragma can immediately follow an
3424 enumeration type declaration, where the entity argument names one of the
3425 enumeration literals.
3427 This pragma is used to indicate that the named entity
3428 is considered obsolescent and should not be used. Typically this is
3429 used when an API must be modified by eventually removing or modifying
3430 existing subprograms or other entities. The pragma can be used at an
3431 intermediate stage when the entity is still present, but will be
3434 The effect of this pragma is to output a warning message on
3435 a call to a program thus marked that the
3436 subprogram is obsolescent if the appropriate warning option in the
3437 compiler is activated. If the string parameter is present, then a second
3438 warning message is given containing this text.
3439 In addition, a call to such a program is considered a violation of
3440 pragma Restrictions (No_Obsolescent_Features).
3442 This pragma can also be used as a program unit pragma for a package,
3443 in which case the entity name is the name of the package, and the
3444 pragma indicates that the entire package is considered
3445 obsolescent. In this case a client @code{with}'ing such a package
3446 violates the restriction, and the @code{with} statement is
3447 flagged with warnings if the warning option is set.
3449 If the optional third parameter is present (which must be exactly
3450 the identifier Ada_05, no other argument is allowed), then the
3451 indication of obsolescence applies only when compiling in Ada 2005
3452 mode. This is primarily intended for dealing with the situations
3453 in the predefined library where subprograms or packages
3454 have become defined as obsolescent in Ada 2005
3455 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3457 The following examples show typical uses of this pragma:
3459 @smallexample @c ada
3462 (Entity => p, "use pp instead of p");
3468 (Entity => q2, "use q2new instead");
3470 type R is new integer;
3472 (Entity => R, "use RR in Ada 2005", Ada_05);
3477 pragma Obsolescent (Entity => F2);
3481 type E is (a, bc, 'd', quack);
3482 pragma Obsolescent (Entity => bc)
3483 pragma Obsolescent (Entity => 'd')
3486 (a, b : character) return character;
3487 pragma Obsolescent (Entity => "+");
3492 In an earlier version of GNAT, the Entity parameter was not required,
3493 and this form is still accepted for compatibility purposes. If the
3494 Entity parameter is omitted, then the pragma applies to the declaration
3495 immediately preceding the pragma (this form cannot be used for the
3496 enumeration literal case).
3498 @node Pragma Optimize_Alignment
3499 @unnumberedsec Pragma Optimize_Alignment
3500 @findex Optimize_Alignment
3501 @cindex Alignment, default settings
3505 @smallexample @c ada
3506 pragma Optimize_Alignment (TIME | SPACE | OFF);
3510 This is a configuration pragma which affects the choice of default alignments
3511 for types where no alignment is explicitly specified. There is a time/space
3512 trade-off in the selection of these values. Large alignments result in more
3513 efficient code, at the expense of larger data space, since sizes have to be
3514 increased to match these alignments. Smaller alignments save space, but the
3515 access code is slower. The normal choice of default alignments (which is what
3516 you get if you do not use this pragma, or if you use an argument of OFF),
3517 tries to balance these two requirements.
3519 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3520 First any packed record is given an alignment of 1. Second, if a size is given
3521 for the type, then the alignment is chosen to avoid increasing this size. For
3524 @smallexample @c ada
3534 In the default mode, this type gets an alignment of 4, so that access to the
3535 Integer field X are efficient. But this means that objects of the type end up
3536 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3537 allowed to be bigger than the size of the type, but it can waste space if for
3538 example fields of type R appear in an enclosing record. If the above type is
3539 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3541 Specifying TIME causes larger default alignments to be chosen in the case of
3542 small types with sizes that are not a power of 2. For example, consider:
3544 @smallexample @c ada
3556 The default alignment for this record is normally 1, but if this type is
3557 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3558 to 4, which wastes space for objects of the type, since they are now 4 bytes
3559 long, but results in more efficient access when the whole record is referenced.
3561 As noted above, this is a configuration pragma, and there is a requirement
3562 that all units in a partition be compiled with a consistent setting of the
3563 optimization setting. This would normally be achieved by use of a configuration
3564 pragma file containing the appropriate setting. The exception to this rule is
3565 that units with an explicit configuration pragma in the same file as the source
3566 unit are excluded from the consistency check, as are all predefined units. The
3567 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3568 pragma appears at the start of the file.
3570 @node Pragma Passive
3571 @unnumberedsec Pragma Passive
3576 @smallexample @c ada
3577 pragma Passive [(Semaphore | No)];
3581 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3582 compatibility with DEC Ada 83 implementations, where it is used within a
3583 task definition to request that a task be made passive. If the argument
3584 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3585 treats the pragma as an assertion that the containing task is passive
3586 and that optimization of context switch with this task is permitted and
3587 desired. If the argument @code{No} is present, the task must not be
3588 optimized. GNAT does not attempt to optimize any tasks in this manner
3589 (since protected objects are available in place of passive tasks).
3591 @node Pragma Persistent_BSS
3592 @unnumberedsec Pragma Persistent_BSS
3593 @findex Persistent_BSS
3597 @smallexample @c ada
3598 pragma Persistent_BSS [(LOCAL_NAME)]
3602 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3603 section. On some targets the linker and loader provide for special
3604 treatment of this section, allowing a program to be reloaded without
3605 affecting the contents of this data (hence the name persistent).
3607 There are two forms of usage. If an argument is given, it must be the
3608 local name of a library level object, with no explicit initialization
3609 and whose type is potentially persistent. If no argument is given, then
3610 the pragma is a configuration pragma, and applies to all library level
3611 objects with no explicit initialization of potentially persistent types.
3613 A potentially persistent type is a scalar type, or a non-tagged,
3614 non-discriminated record, all of whose components have no explicit
3615 initialization and are themselves of a potentially persistent type,
3616 or an array, all of whose constraints are static, and whose component
3617 type is potentially persistent.
3619 If this pragma is used on a target where this feature is not supported,
3620 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3622 @node Pragma Polling
3623 @unnumberedsec Pragma Polling
3628 @smallexample @c ada
3629 pragma Polling (ON | OFF);
3633 This pragma controls the generation of polling code. This is normally off.
3634 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3635 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3636 runtime library, and can be found in file @file{a-excpol.adb}.
3638 Pragma @code{Polling} can appear as a configuration pragma (for example it
3639 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3640 can be used in the statement or declaration sequence to control polling
3643 A call to the polling routine is generated at the start of every loop and
3644 at the start of every subprogram call. This guarantees that the @code{Poll}
3645 routine is called frequently, and places an upper bound (determined by
3646 the complexity of the code) on the period between two @code{Poll} calls.
3648 The primary purpose of the polling interface is to enable asynchronous
3649 aborts on targets that cannot otherwise support it (for example Windows
3650 NT), but it may be used for any other purpose requiring periodic polling.
3651 The standard version is null, and can be replaced by a user program. This
3652 will require re-compilation of the @code{Ada.Exceptions} package that can
3653 be found in files @file{a-except.ads} and @file{a-except.adb}.
3655 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3656 distribution) is used to enable the asynchronous abort capability on
3657 targets that do not normally support the capability. The version of
3658 @code{Poll} in this file makes a call to the appropriate runtime routine
3659 to test for an abort condition.
3661 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3662 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3665 @node Pragma Postcondition
3666 @unnumberedsec Pragma Postcondition
3667 @cindex Postconditions
3668 @cindex Checks, postconditions
3669 @findex Postconditions
3673 @smallexample @c ada
3674 pragma Postcondition (
3675 [Check =>] Boolean_Expression
3676 [,[Message =>] String_Expression]);
3680 The @code{Postcondition} pragma allows specification of automatic
3681 postcondition checks for subprograms. These checks are similar to
3682 assertions, but are automatically inserted just prior to the return
3683 statements of the subprogram with which they are associated.
3684 Furthermore, the boolean expression which is the condition which
3685 must be true may contain references to function'Result in the case
3686 of a function to refer to the returned value.
3688 @code{Postcondition} pragmas may appear either immediate following the
3689 (separate) declaration of a subprogram, or at the start of the
3690 declarations of a subprogram body. Only other pragmas may intervene
3691 (that is appear between the subprogram declaration and its
3692 postconditions, or appear before the postcondition in the
3693 declaration sequence in a subprogram body). In the case of a
3694 postcondition appearing after a subprogram declaration, the
3695 formal arguments of the subprogram are visible, and can be
3696 referenced in the postcondition expressions.
3698 The postconditions are collected and automatically tested just
3699 before any return (implicit or explicit) in the subprogram body.
3700 A postcondition is only recognized if postconditions are active
3701 at the time the pragma is encountered. The compiler switch @option{gnata}
3702 turns on all postconditions by default, and pragma @code{Check_Policy}
3703 with an identifier of @code{Postcondition} can also be used to
3704 control whether postconditions are active.
3706 The general approach is that postconditions are placed in the spec
3707 if they represent functional aspects which make sense to the client.
3708 For example we might have:
3710 @smallexample @c ada
3711 function Direction return Integer;
3712 pragma Postcondition
3713 (Direction'Result = +1
3715 Direction'Result = -1);
3719 which serves to document that the result must be +1 or -1, and
3720 will test that this is the case at run time if postcondition
3723 Postconditions within the subprogram body can be used to
3724 check that some internal aspect of the implementation,
3725 not visible to the client, is operating as expected.
3726 For instance if a square root routine keeps an internal
3727 counter of the number of times it is called, then we
3728 might have the following postcondition:
3730 @smallexample @c ada
3731 Sqrt_Calls : Natural := 0;
3733 function Sqrt (Arg : Float) return Float is
3734 pragma Postcondition
3735 (Sqrt_Calls = Sqrt_Calls'Old + 1);
3741 As this example, shows, the use of the @code{Old} attribute
3742 is often useful in postconditions to refer to the state on
3743 entry to the subprogram.
3745 Note that postconditions are only checked on normal returns
3746 from the subprogram. If an abnormal return results from
3747 raising an exception, then the postconditions are not checked.
3749 If a postcondition fails, then the exception
3750 @code{System.Assertions.Assert_Failure} is raised. If
3751 a message argument was supplied, then the given string
3752 will be used as the exception message. If no message
3753 argument was supplied, then the default message has
3754 the form "Postcondition failed at file:line". The
3755 exception is raised in the context of the subprogram
3756 body, so it is possible to catch postcondition failures
3757 within the subprogram body itself.
3759 Within a package spec, normal visibility rules
3760 in Ada would prevent forward references within a
3761 postcondition pragma to functions defined later in
3762 the same package. This would introduce undesirable
3763 ordering constraints. To avoid this problem, all
3764 postcondition pragmas are analyzed at the end of
3765 the package spec, allowing forward references.
3767 The following example shows that this even allows
3768 mutually recursive postconditions as in:
3770 @smallexample @c ada
3771 package Parity_Functions is
3772 function Odd (X : Natural) return Boolean;
3773 pragma Postcondition
3777 (x /= 0 and then Even (X - 1))));
3779 function Even (X : Natural) return Boolean;
3780 pragma Postcondition
3784 (x /= 1 and then Odd (X - 1))));
3786 end Parity_Functions;
3790 There are no restrictions on the complexity or form of
3791 conditions used within @code{Postcondition} pragmas.
3792 The following example shows that it is even possible
3793 to verify performance behavior.
3795 @smallexample @c ada
3798 Performance : constant Float;
3799 -- Performance constant set by implementation
3800 -- to match target architecture behavior.
3802 procedure Treesort (Arg : String);
3803 -- Sorts characters of argument using N*logN sort
3804 pragma Postcondition
3805 (Float (Clock - Clock'Old) <=
3806 Float (Arg'Length) *
3807 log (Float (Arg'Length)) *
3813 Note: postcondition pragmas associated with subprograms that are
3814 marked as Inline_Always, or those marked as Inline with front-end
3815 inlining (-gnatN option set) are accepted and legality-checked
3816 by the compiler, but are ignored at run-time even if postcondition
3817 checking is enabled.
3819 @node Pragma Precondition
3820 @unnumberedsec Pragma Precondition
3821 @cindex Preconditions
3822 @cindex Checks, preconditions
3823 @findex Preconditions
3827 @smallexample @c ada
3828 pragma Precondition (
3829 [Check =>] Boolean_Expression
3830 [,[Message =>] String_Expression]);
3834 The @code{Precondition} pragma is similar to @code{Postcondition}
3835 except that the corresponding checks take place immediately upon
3836 entry to the subprogram, and if a precondition fails, the exception
3837 is raised in the context of the caller, and the attribute 'Result
3838 cannot be used within the precondition expression.
3840 Otherwise, the placement and visibility rules are identical to those
3841 described for postconditions. The following is an example of use
3842 within a package spec:
3844 @smallexample @c ada
3845 package Math_Functions is
3847 function Sqrt (Arg : Float) return Float;
3848 pragma Precondition (Arg >= 0.0)
3854 @code{Precondition} pragmas may appear either immediate following the
3855 (separate) declaration of a subprogram, or at the start of the
3856 declarations of a subprogram body. Only other pragmas may intervene
3857 (that is appear between the subprogram declaration and its
3858 postconditions, or appear before the postcondition in the
3859 declaration sequence in a subprogram body).
3861 Note: postcondition pragmas associated with subprograms that are
3862 marked as Inline_Always, or those marked as Inline with front-end
3863 inlining (-gnatN option set) are accepted and legality-checked
3864 by the compiler, but are ignored at run-time even if postcondition
3865 checking is enabled.
3869 @node Pragma Profile (Ravenscar)
3870 @unnumberedsec Pragma Profile (Ravenscar)
3875 @smallexample @c ada
3876 pragma Profile (Ravenscar);
3880 A configuration pragma that establishes the following set of configuration
3884 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3885 [RM D.2.2] Tasks are dispatched following a preemptive
3886 priority-ordered scheduling policy.
3888 @item Locking_Policy (Ceiling_Locking)
3889 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3890 the ceiling priority of the corresponding protected object.
3892 @c @item Detect_Blocking
3893 @c This pragma forces the detection of potentially blocking operations within a
3894 @c protected operation, and to raise Program_Error if that happens.
3898 plus the following set of restrictions:
3901 @item Max_Entry_Queue_Length = 1
3902 Defines the maximum number of calls that are queued on a (protected) entry.
3903 Note that this restrictions is checked at run time. Violation of this
3904 restriction results in the raising of Program_Error exception at the point of
3905 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3906 always 1 and hence no task can be queued on a protected entry.
3908 @item Max_Protected_Entries = 1
3909 [RM D.7] Specifies the maximum number of entries per protected type. The
3910 bounds of every entry family of a protected unit shall be static, or shall be
3911 defined by a discriminant of a subtype whose corresponding bound is static.
3912 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3914 @item Max_Task_Entries = 0
3915 [RM D.7] Specifies the maximum number of entries
3916 per task. The bounds of every entry family
3917 of a task unit shall be static, or shall be
3918 defined by a discriminant of a subtype whose
3919 corresponding bound is static. A value of zero
3920 indicates that no rendezvous are possible. For
3921 the Profile (Ravenscar), the value of Max_Task_Entries is always
3924 @item No_Abort_Statements
3925 [RM D.7] There are no abort_statements, and there are
3926 no calls to Task_Identification.Abort_Task.
3928 @item No_Asynchronous_Control
3929 There are no semantic dependences on the package
3930 Asynchronous_Task_Control.
3933 There are no semantic dependencies on the package Ada.Calendar.
3935 @item No_Dynamic_Attachment
3936 There is no call to any of the operations defined in package Ada.Interrupts
3937 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3938 Detach_Handler, and Reference).
3940 @item No_Dynamic_Priorities
3941 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3943 @item No_Implicit_Heap_Allocations
3944 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3946 @item No_Local_Protected_Objects
3947 Protected objects and access types that designate
3948 such objects shall be declared only at library level.
3950 @item No_Local_Timing_Events
3951 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
3952 declared at the library level.
3954 @item No_Protected_Type_Allocators
3955 There are no allocators for protected types or
3956 types containing protected subcomponents.
3958 @item No_Relative_Delay
3959 There are no delay_relative statements.
3961 @item No_Requeue_Statements
3962 Requeue statements are not allowed.
3964 @item No_Select_Statements
3965 There are no select_statements.
3967 @item No_Specific_Termination_Handlers
3968 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
3969 or to Ada.Task_Termination.Specific_Handler.
3971 @item No_Task_Allocators
3972 [RM D.7] There are no allocators for task types
3973 or types containing task subcomponents.
3975 @item No_Task_Attributes_Package
3976 There are no semantic dependencies on the Ada.Task_Attributes package.
3978 @item No_Task_Hierarchy
3979 [RM D.7] All (non-environment) tasks depend
3980 directly on the environment task of the partition.
3982 @item No_Task_Termination
3983 Tasks which terminate are erroneous.
3985 @item No_Unchecked_Conversion
3986 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
3988 @item No_Unchecked_Deallocation
3989 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
3991 @item Simple_Barriers
3992 Entry barrier condition expressions shall be either static
3993 boolean expressions or boolean objects which are declared in
3994 the protected type which contains the entry.
3998 This set of configuration pragmas and restrictions correspond to the
3999 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4000 published by the @cite{International Real-Time Ada Workshop}, 1997,
4001 and whose most recent description is available at
4002 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4004 The original definition of the profile was revised at subsequent IRTAW
4005 meetings. It has been included in the ISO
4006 @cite{Guide for the Use of the Ada Programming Language in High
4007 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4008 the next revision of the standard. The formal definition given by
4009 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4010 AI-305) available at
4011 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
4012 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
4015 The above set is a superset of the restrictions provided by pragma
4016 @code{Profile (Restricted)}, it includes six additional restrictions
4017 (@code{Simple_Barriers}, @code{No_Select_Statements},
4018 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4019 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4020 that pragma @code{Profile (Ravenscar)}, like the pragma
4021 @code{Profile (Restricted)},
4022 automatically causes the use of a simplified,
4023 more efficient version of the tasking run-time system.
4025 @node Pragma Profile (Restricted)
4026 @unnumberedsec Pragma Profile (Restricted)
4027 @findex Restricted Run Time
4031 @smallexample @c ada
4032 pragma Profile (Restricted);
4036 A configuration pragma that establishes the following set of restrictions:
4039 @item No_Abort_Statements
4040 @item No_Entry_Queue
4041 @item No_Task_Hierarchy
4042 @item No_Task_Allocators
4043 @item No_Dynamic_Priorities
4044 @item No_Terminate_Alternatives
4045 @item No_Dynamic_Attachment
4046 @item No_Protected_Type_Allocators
4047 @item No_Local_Protected_Objects
4048 @item No_Requeue_Statements
4049 @item No_Task_Attributes_Package
4050 @item Max_Asynchronous_Select_Nesting = 0
4051 @item Max_Task_Entries = 0
4052 @item Max_Protected_Entries = 1
4053 @item Max_Select_Alternatives = 0
4057 This set of restrictions causes the automatic selection of a simplified
4058 version of the run time that provides improved performance for the
4059 limited set of tasking functionality permitted by this set of restrictions.
4061 @node Pragma Psect_Object
4062 @unnumberedsec Pragma Psect_Object
4063 @findex Psect_Object
4067 @smallexample @c ada
4068 pragma Psect_Object (
4069 [Internal =>] LOCAL_NAME,
4070 [, [External =>] EXTERNAL_SYMBOL]
4071 [, [Size =>] EXTERNAL_SYMBOL]);
4075 | static_string_EXPRESSION
4079 This pragma is identical in effect to pragma @code{Common_Object}.
4081 @node Pragma Pure_Function
4082 @unnumberedsec Pragma Pure_Function
4083 @findex Pure_Function
4087 @smallexample @c ada
4088 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4092 This pragma appears in the same declarative part as a function
4093 declaration (or a set of function declarations if more than one
4094 overloaded declaration exists, in which case the pragma applies
4095 to all entities). It specifies that the function @code{Entity} is
4096 to be considered pure for the purposes of code generation. This means
4097 that the compiler can assume that there are no side effects, and
4098 in particular that two calls with identical arguments produce the
4099 same result. It also means that the function can be used in an
4102 Note that, quite deliberately, there are no static checks to try
4103 to ensure that this promise is met, so @code{Pure_Function} can be used
4104 with functions that are conceptually pure, even if they do modify
4105 global variables. For example, a square root function that is
4106 instrumented to count the number of times it is called is still
4107 conceptually pure, and can still be optimized, even though it
4108 modifies a global variable (the count). Memo functions are another
4109 example (where a table of previous calls is kept and consulted to
4110 avoid re-computation).
4113 Note: Most functions in a @code{Pure} package are automatically pure, and
4114 there is no need to use pragma @code{Pure_Function} for such functions. One
4115 exception is any function that has at least one formal of type
4116 @code{System.Address} or a type derived from it. Such functions are not
4117 considered pure by default, since the compiler assumes that the
4118 @code{Address} parameter may be functioning as a pointer and that the
4119 referenced data may change even if the address value does not.
4120 Similarly, imported functions are not considered to be pure by default,
4121 since there is no way of checking that they are in fact pure. The use
4122 of pragma @code{Pure_Function} for such a function will override these default
4123 assumption, and cause the compiler to treat a designated subprogram as pure
4126 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4127 applies to the underlying renamed function. This can be used to
4128 disambiguate cases of overloading where some but not all functions
4129 in a set of overloaded functions are to be designated as pure.
4131 If pragma @code{Pure_Function} is applied to a library level function, the
4132 function is also considered pure from an optimization point of view, but the
4133 unit is not a Pure unit in the categorization sense. So for example, a function
4134 thus marked is free to @code{with} non-pure units.
4136 @node Pragma Restriction_Warnings
4137 @unnumberedsec Pragma Restriction_Warnings
4138 @findex Restriction_Warnings
4142 @smallexample @c ada
4143 pragma Restriction_Warnings
4144 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4148 This pragma allows a series of restriction identifiers to be
4149 specified (the list of allowed identifiers is the same as for
4150 pragma @code{Restrictions}). For each of these identifiers
4151 the compiler checks for violations of the restriction, but
4152 generates a warning message rather than an error message
4153 if the restriction is violated.
4156 @unnumberedsec Pragma Shared
4160 This pragma is provided for compatibility with Ada 83. The syntax and
4161 semantics are identical to pragma Atomic.
4163 @node Pragma Source_File_Name
4164 @unnumberedsec Pragma Source_File_Name
4165 @findex Source_File_Name
4169 @smallexample @c ada
4170 pragma Source_File_Name (
4171 [Unit_Name =>] unit_NAME,
4172 Spec_File_Name => STRING_LITERAL);
4174 pragma Source_File_Name (
4175 [Unit_Name =>] unit_NAME,
4176 Body_File_Name => STRING_LITERAL);
4180 Use this to override the normal naming convention. It is a configuration
4181 pragma, and so has the usual applicability of configuration pragmas
4182 (i.e.@: it applies to either an entire partition, or to all units in a
4183 compilation, or to a single unit, depending on how it is used.
4184 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4185 the second argument is required, and indicates whether this is the file
4186 name for the spec or for the body.
4188 Another form of the @code{Source_File_Name} pragma allows
4189 the specification of patterns defining alternative file naming schemes
4190 to apply to all files.
4192 @smallexample @c ada
4193 pragma Source_File_Name
4194 (Spec_File_Name => STRING_LITERAL
4195 [,Casing => CASING_SPEC]
4196 [,Dot_Replacement => STRING_LITERAL]);
4198 pragma Source_File_Name
4199 (Body_File_Name => STRING_LITERAL
4200 [,Casing => CASING_SPEC]
4201 [,Dot_Replacement => STRING_LITERAL]);
4203 pragma Source_File_Name
4204 (Subunit_File_Name => STRING_LITERAL
4205 [,Casing => CASING_SPEC]
4206 [,Dot_Replacement => STRING_LITERAL]);
4208 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4212 The first argument is a pattern that contains a single asterisk indicating
4213 the point at which the unit name is to be inserted in the pattern string
4214 to form the file name. The second argument is optional. If present it
4215 specifies the casing of the unit name in the resulting file name string.
4216 The default is lower case. Finally the third argument allows for systematic
4217 replacement of any dots in the unit name by the specified string literal.
4219 A pragma Source_File_Name cannot appear after a
4220 @ref{Pragma Source_File_Name_Project}.
4222 For more details on the use of the @code{Source_File_Name} pragma,
4223 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4224 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4227 @node Pragma Source_File_Name_Project
4228 @unnumberedsec Pragma Source_File_Name_Project
4229 @findex Source_File_Name_Project
4232 This pragma has the same syntax and semantics as pragma Source_File_Name.
4233 It is only allowed as a stand alone configuration pragma.
4234 It cannot appear after a @ref{Pragma Source_File_Name}, and
4235 most importantly, once pragma Source_File_Name_Project appears,
4236 no further Source_File_Name pragmas are allowed.
4238 The intention is that Source_File_Name_Project pragmas are always
4239 generated by the Project Manager in a manner consistent with the naming
4240 specified in a project file, and when naming is controlled in this manner,
4241 it is not permissible to attempt to modify this naming scheme using
4242 Source_File_Name pragmas (which would not be known to the project manager).
4244 @node Pragma Source_Reference
4245 @unnumberedsec Pragma Source_Reference
4246 @findex Source_Reference
4250 @smallexample @c ada
4251 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4255 This pragma must appear as the first line of a source file.
4256 @var{integer_literal} is the logical line number of the line following
4257 the pragma line (for use in error messages and debugging
4258 information). @var{string_literal} is a static string constant that
4259 specifies the file name to be used in error messages and debugging
4260 information. This is most notably used for the output of @code{gnatchop}
4261 with the @option{-r} switch, to make sure that the original unchopped
4262 source file is the one referred to.
4264 The second argument must be a string literal, it cannot be a static
4265 string expression other than a string literal. This is because its value
4266 is needed for error messages issued by all phases of the compiler.
4268 @node Pragma Stream_Convert
4269 @unnumberedsec Pragma Stream_Convert
4270 @findex Stream_Convert
4274 @smallexample @c ada
4275 pragma Stream_Convert (
4276 [Entity =>] type_LOCAL_NAME,
4277 [Read =>] function_NAME,
4278 [Write =>] function_NAME);
4282 This pragma provides an efficient way of providing stream functions for
4283 types defined in packages. Not only is it simpler to use than declaring
4284 the necessary functions with attribute representation clauses, but more
4285 significantly, it allows the declaration to made in such a way that the
4286 stream packages are not loaded unless they are needed. The use of
4287 the Stream_Convert pragma adds no overhead at all, unless the stream
4288 attributes are actually used on the designated type.
4290 The first argument specifies the type for which stream functions are
4291 provided. The second parameter provides a function used to read values
4292 of this type. It must name a function whose argument type may be any
4293 subtype, and whose returned type must be the type given as the first
4294 argument to the pragma.
4296 The meaning of the @var{Read}
4297 parameter is that if a stream attribute directly
4298 or indirectly specifies reading of the type given as the first parameter,
4299 then a value of the type given as the argument to the Read function is
4300 read from the stream, and then the Read function is used to convert this
4301 to the required target type.
4303 Similarly the @var{Write} parameter specifies how to treat write attributes
4304 that directly or indirectly apply to the type given as the first parameter.
4305 It must have an input parameter of the type specified by the first parameter,
4306 and the return type must be the same as the input type of the Read function.
4307 The effect is to first call the Write function to convert to the given stream
4308 type, and then write the result type to the stream.
4310 The Read and Write functions must not be overloaded subprograms. If necessary
4311 renamings can be supplied to meet this requirement.
4312 The usage of this attribute is best illustrated by a simple example, taken
4313 from the GNAT implementation of package Ada.Strings.Unbounded:
4315 @smallexample @c ada
4316 function To_Unbounded (S : String)
4317 return Unbounded_String
4318 renames To_Unbounded_String;
4320 pragma Stream_Convert
4321 (Unbounded_String, To_Unbounded, To_String);
4325 The specifications of the referenced functions, as given in the Ada
4326 Reference Manual are:
4328 @smallexample @c ada
4329 function To_Unbounded_String (Source : String)
4330 return Unbounded_String;
4332 function To_String (Source : Unbounded_String)
4337 The effect is that if the value of an unbounded string is written to a
4338 stream, then the representation of the item in the stream is in the same
4339 format used for @code{Standard.String}, and this same representation is
4340 expected when a value of this type is read from the stream.
4342 @node Pragma Style_Checks
4343 @unnumberedsec Pragma Style_Checks
4344 @findex Style_Checks
4348 @smallexample @c ada
4349 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4350 On | Off [, LOCAL_NAME]);
4354 This pragma is used in conjunction with compiler switches to control the
4355 built in style checking provided by GNAT@. The compiler switches, if set,
4356 provide an initial setting for the switches, and this pragma may be used
4357 to modify these settings, or the settings may be provided entirely by
4358 the use of the pragma. This pragma can be used anywhere that a pragma
4359 is legal, including use as a configuration pragma (including use in
4360 the @file{gnat.adc} file).
4362 The form with a string literal specifies which style options are to be
4363 activated. These are additive, so they apply in addition to any previously
4364 set style check options. The codes for the options are the same as those
4365 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4366 For example the following two methods can be used to enable
4371 @smallexample @c ada
4372 pragma Style_Checks ("l");
4377 gcc -c -gnatyl @dots{}
4382 The form ALL_CHECKS activates all standard checks (its use is equivalent
4383 to the use of the @code{gnaty} switch with no options. @xref{Top,
4384 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4385 @value{EDITION} User's Guide}, for details.
4387 The forms with @code{Off} and @code{On}
4388 can be used to temporarily disable style checks
4389 as shown in the following example:
4391 @smallexample @c ada
4395 pragma Style_Checks ("k"); -- requires keywords in lower case
4396 pragma Style_Checks (Off); -- turn off style checks
4397 NULL; -- this will not generate an error message
4398 pragma Style_Checks (On); -- turn style checks back on
4399 NULL; -- this will generate an error message
4403 Finally the two argument form is allowed only if the first argument is
4404 @code{On} or @code{Off}. The effect is to turn of semantic style checks
4405 for the specified entity, as shown in the following example:
4407 @smallexample @c ada
4411 pragma Style_Checks ("r"); -- require consistency of identifier casing
4413 Rf1 : Integer := ARG; -- incorrect, wrong case
4414 pragma Style_Checks (Off, Arg);
4415 Rf2 : Integer := ARG; -- OK, no error
4418 @node Pragma Subtitle
4419 @unnumberedsec Pragma Subtitle
4424 @smallexample @c ada
4425 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4429 This pragma is recognized for compatibility with other Ada compilers
4430 but is ignored by GNAT@.
4432 @node Pragma Suppress
4433 @unnumberedsec Pragma Suppress
4438 @smallexample @c ada
4439 pragma Suppress (Identifier [, [On =>] Name]);
4443 This is a standard pragma, and supports all the check names required in
4444 the RM. It is included here because GNAT recognizes one additional check
4445 name: @code{Alignment_Check} which can be used to suppress alignment checks
4446 on addresses used in address clauses. Such checks can also be suppressed
4447 by suppressing range checks, but the specific use of @code{Alignment_Check}
4448 allows suppression of alignment checks without suppressing other range checks.
4450 Note that pragma Suppress gives the compiler permission to omit
4451 checks, but does not require the compiler to omit checks. The compiler
4452 will generate checks if they are essentially free, even when they are
4453 suppressed. In particular, if the compiler can prove that a certain
4454 check will necessarily fail, it will generate code to do an
4455 unconditional ``raise'', even if checks are suppressed. The compiler
4458 Of course, run-time checks are omitted whenever the compiler can prove
4459 that they will not fail, whether or not checks are suppressed.
4461 @node Pragma Suppress_All
4462 @unnumberedsec Pragma Suppress_All
4463 @findex Suppress_All
4467 @smallexample @c ada
4468 pragma Suppress_All;
4472 This pragma can only appear immediately following a compilation
4473 unit. The effect is to apply @code{Suppress (All_Checks)} to the unit
4474 which it follows. This pragma is implemented for compatibility with DEC
4475 Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal
4476 configuration pragma is the preferred usage in GNAT@.
4478 @node Pragma Suppress_Exception_Locations
4479 @unnumberedsec Pragma Suppress_Exception_Locations
4480 @findex Suppress_Exception_Locations
4484 @smallexample @c ada
4485 pragma Suppress_Exception_Locations;
4489 In normal mode, a raise statement for an exception by default generates
4490 an exception message giving the file name and line number for the location
4491 of the raise. This is useful for debugging and logging purposes, but this
4492 entails extra space for the strings for the messages. The configuration
4493 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4494 generation of these strings, with the result that space is saved, but the
4495 exception message for such raises is null. This configuration pragma may
4496 appear in a global configuration pragma file, or in a specific unit as
4497 usual. It is not required that this pragma be used consistently within
4498 a partition, so it is fine to have some units within a partition compiled
4499 with this pragma and others compiled in normal mode without it.
4501 @node Pragma Suppress_Initialization
4502 @unnumberedsec Pragma Suppress_Initialization
4503 @findex Suppress_Initialization
4504 @cindex Suppressing initialization
4505 @cindex Initialization, suppression of
4509 @smallexample @c ada
4510 pragma Suppress_Initialization ([Entity =>] type_Name);
4514 This pragma suppresses any implicit or explicit initialization
4515 associated with the given type name for all variables of this type.
4517 @node Pragma Task_Info
4518 @unnumberedsec Pragma Task_Info
4523 @smallexample @c ada
4524 pragma Task_Info (EXPRESSION);
4528 This pragma appears within a task definition (like pragma
4529 @code{Priority}) and applies to the task in which it appears. The
4530 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4531 The @code{Task_Info} pragma provides system dependent control over
4532 aspects of tasking implementation, for example, the ability to map
4533 tasks to specific processors. For details on the facilities available
4534 for the version of GNAT that you are using, see the documentation
4535 in the spec of package System.Task_Info in the runtime
4538 @node Pragma Task_Name
4539 @unnumberedsec Pragma Task_Name
4544 @smallexample @c ada
4545 pragma Task_Name (string_EXPRESSION);
4549 This pragma appears within a task definition (like pragma
4550 @code{Priority}) and applies to the task in which it appears. The
4551 argument must be of type String, and provides a name to be used for
4552 the task instance when the task is created. Note that this expression
4553 is not required to be static, and in particular, it can contain
4554 references to task discriminants. This facility can be used to
4555 provide different names for different tasks as they are created,
4556 as illustrated in the example below.
4558 The task name is recorded internally in the run-time structures
4559 and is accessible to tools like the debugger. In addition the
4560 routine @code{Ada.Task_Identification.Image} will return this
4561 string, with a unique task address appended.
4563 @smallexample @c ada
4564 -- Example of the use of pragma Task_Name
4566 with Ada.Task_Identification;
4567 use Ada.Task_Identification;
4568 with Text_IO; use Text_IO;
4571 type Astring is access String;
4573 task type Task_Typ (Name : access String) is
4574 pragma Task_Name (Name.all);
4577 task body Task_Typ is
4578 Nam : constant String := Image (Current_Task);
4580 Put_Line ("-->" & Nam (1 .. 14) & "<--");
4583 type Ptr_Task is access Task_Typ;
4584 Task_Var : Ptr_Task;
4588 new Task_Typ (new String'("This is task 1"));
4590 new Task_Typ (new String'("This is task 2"));
4594 @node Pragma Task_Storage
4595 @unnumberedsec Pragma Task_Storage
4596 @findex Task_Storage
4599 @smallexample @c ada
4600 pragma Task_Storage (
4601 [Task_Type =>] LOCAL_NAME,
4602 [Top_Guard =>] static_integer_EXPRESSION);
4606 This pragma specifies the length of the guard area for tasks. The guard
4607 area is an additional storage area allocated to a task. A value of zero
4608 means that either no guard area is created or a minimal guard area is
4609 created, depending on the target. This pragma can appear anywhere a
4610 @code{Storage_Size} attribute definition clause is allowed for a task
4613 @node Pragma Time_Slice
4614 @unnumberedsec Pragma Time_Slice
4619 @smallexample @c ada
4620 pragma Time_Slice (static_duration_EXPRESSION);
4624 For implementations of GNAT on operating systems where it is possible
4625 to supply a time slice value, this pragma may be used for this purpose.
4626 It is ignored if it is used in a system that does not allow this control,
4627 or if it appears in other than the main program unit.
4629 Note that the effect of this pragma is identical to the effect of the
4630 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4633 @unnumberedsec Pragma Title
4638 @smallexample @c ada
4639 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4642 [Title =>] STRING_LITERAL,
4643 | [Subtitle =>] STRING_LITERAL
4647 Syntax checked but otherwise ignored by GNAT@. This is a listing control
4648 pragma used in DEC Ada 83 implementations to provide a title and/or
4649 subtitle for the program listing. The program listing generated by GNAT
4650 does not have titles or subtitles.
4652 Unlike other pragmas, the full flexibility of named notation is allowed
4653 for this pragma, i.e.@: the parameters may be given in any order if named
4654 notation is used, and named and positional notation can be mixed
4655 following the normal rules for procedure calls in Ada.
4657 @node Pragma Unchecked_Union
4658 @unnumberedsec Pragma Unchecked_Union
4660 @findex Unchecked_Union
4664 @smallexample @c ada
4665 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4669 This pragma is used to specify a representation of a record type that is
4670 equivalent to a C union. It was introduced as a GNAT implementation defined
4671 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4672 pragma, making it language defined, and GNAT fully implements this extended
4673 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4674 details, consult the Ada 2005 Reference Manual, section B.3.3.
4676 @node Pragma Unimplemented_Unit
4677 @unnumberedsec Pragma Unimplemented_Unit
4678 @findex Unimplemented_Unit
4682 @smallexample @c ada
4683 pragma Unimplemented_Unit;
4687 If this pragma occurs in a unit that is processed by the compiler, GNAT
4688 aborts with the message @samp{@var{xxx} not implemented}, where
4689 @var{xxx} is the name of the current compilation unit. This pragma is
4690 intended to allow the compiler to handle unimplemented library units in
4693 The abort only happens if code is being generated. Thus you can use
4694 specs of unimplemented packages in syntax or semantic checking mode.
4696 @node Pragma Universal_Aliasing
4697 @unnumberedsec Pragma Universal_Aliasing
4698 @findex Universal_Aliasing
4702 @smallexample @c ada
4703 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4707 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4708 declarative part. The effect is to inhibit strict type-based aliasing
4709 optimization for the given type. In other words, the effect is as though
4710 access types designating this type were subject to pragma No_Strict_Aliasing.
4711 For a detailed description of the strict aliasing optimization, and the
4712 situations in which it must be suppressed, @xref{Optimization and Strict
4713 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4715 @node Pragma Universal_Data
4716 @unnumberedsec Pragma Universal_Data
4717 @findex Universal_Data
4721 @smallexample @c ada
4722 pragma Universal_Data [(library_unit_Name)];
4726 This pragma is supported only for the AAMP target and is ignored for
4727 other targets. The pragma specifies that all library-level objects
4728 (Counter 0 data) associated with the library unit are to be accessed
4729 and updated using universal addressing (24-bit addresses for AAMP5)
4730 rather than the default of 16-bit Data Environment (DENV) addressing.
4731 Use of this pragma will generally result in less efficient code for
4732 references to global data associated with the library unit, but
4733 allows such data to be located anywhere in memory. This pragma is
4734 a library unit pragma, but can also be used as a configuration pragma
4735 (including use in the @file{gnat.adc} file). The functionality
4736 of this pragma is also available by applying the -univ switch on the
4737 compilations of units where universal addressing of the data is desired.
4739 @node Pragma Unmodified
4740 @unnumberedsec Pragma Unmodified
4742 @cindex Warnings, unmodified
4746 @smallexample @c ada
4747 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4751 This pragma signals that the assignable entities (variables,
4752 @code{out} parameters, @code{in out} parameters) whose names are listed are
4753 deliberately not assigned in the current source unit. This
4754 suppresses warnings about the
4755 entities being referenced but not assigned, and in addition a warning will be
4756 generated if one of these entities is in fact assigned in the
4757 same unit as the pragma (or in the corresponding body, or one
4760 This is particularly useful for clearly signaling that a particular
4761 parameter is not modified, even though the spec suggests that it might
4764 @node Pragma Unreferenced
4765 @unnumberedsec Pragma Unreferenced
4766 @findex Unreferenced
4767 @cindex Warnings, unreferenced
4771 @smallexample @c ada
4772 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4773 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4777 This pragma signals that the entities whose names are listed are
4778 deliberately not referenced in the current source unit. This
4779 suppresses warnings about the
4780 entities being unreferenced, and in addition a warning will be
4781 generated if one of these entities is in fact referenced in the
4782 same unit as the pragma (or in the corresponding body, or one
4785 This is particularly useful for clearly signaling that a particular
4786 parameter is not referenced in some particular subprogram implementation
4787 and that this is deliberate. It can also be useful in the case of
4788 objects declared only for their initialization or finalization side
4791 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4792 current scope, then the entity most recently declared is the one to which
4793 the pragma applies. Note that in the case of accept formals, the pragma
4794 Unreferenced may appear immediately after the keyword @code{do} which
4795 allows the indication of whether or not accept formals are referenced
4796 or not to be given individually for each accept statement.
4798 The left hand side of an assignment does not count as a reference for the
4799 purpose of this pragma. Thus it is fine to assign to an entity for which
4800 pragma Unreferenced is given.
4802 Note that if a warning is desired for all calls to a given subprogram,
4803 regardless of whether they occur in the same unit as the subprogram
4804 declaration, then this pragma should not be used (calls from another
4805 unit would not be flagged); pragma Obsolescent can be used instead
4806 for this purpose, see @xref{Pragma Obsolescent}.
4808 The second form of pragma @code{Unreferenced} is used within a context
4809 clause. In this case the arguments must be unit names of units previously
4810 mentioned in @code{with} clauses (similar to the usage of pragma
4811 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4812 units and unreferenced entities within these units.
4814 @node Pragma Unreferenced_Objects
4815 @unnumberedsec Pragma Unreferenced_Objects
4816 @findex Unreferenced_Objects
4817 @cindex Warnings, unreferenced
4821 @smallexample @c ada
4822 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4826 This pragma signals that for the types or subtypes whose names are
4827 listed, objects which are declared with one of these types or subtypes may
4828 not be referenced, and if no references appear, no warnings are given.
4830 This is particularly useful for objects which are declared solely for their
4831 initialization and finalization effect. Such variables are sometimes referred
4832 to as RAII variables (Resource Acquisition Is Initialization). Using this
4833 pragma on the relevant type (most typically a limited controlled type), the
4834 compiler will automatically suppress unwanted warnings about these variables
4835 not being referenced.
4837 @node Pragma Unreserve_All_Interrupts
4838 @unnumberedsec Pragma Unreserve_All_Interrupts
4839 @findex Unreserve_All_Interrupts
4843 @smallexample @c ada
4844 pragma Unreserve_All_Interrupts;
4848 Normally certain interrupts are reserved to the implementation. Any attempt
4849 to attach an interrupt causes Program_Error to be raised, as described in
4850 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
4851 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
4852 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4853 interrupt execution.
4855 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4856 a program, then all such interrupts are unreserved. This allows the
4857 program to handle these interrupts, but disables their standard
4858 functions. For example, if this pragma is used, then pressing
4859 @kbd{Ctrl-C} will not automatically interrupt execution. However,
4860 a program can then handle the @code{SIGINT} interrupt as it chooses.
4862 For a full list of the interrupts handled in a specific implementation,
4863 see the source code for the spec of @code{Ada.Interrupts.Names} in
4864 file @file{a-intnam.ads}. This is a target dependent file that contains the
4865 list of interrupts recognized for a given target. The documentation in
4866 this file also specifies what interrupts are affected by the use of
4867 the @code{Unreserve_All_Interrupts} pragma.
4869 For a more general facility for controlling what interrupts can be
4870 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4871 of the @code{Unreserve_All_Interrupts} pragma.
4873 @node Pragma Unsuppress
4874 @unnumberedsec Pragma Unsuppress
4879 @smallexample @c ada
4880 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4884 This pragma undoes the effect of a previous pragma @code{Suppress}. If
4885 there is no corresponding pragma @code{Suppress} in effect, it has no
4886 effect. The range of the effect is the same as for pragma
4887 @code{Suppress}. The meaning of the arguments is identical to that used
4888 in pragma @code{Suppress}.
4890 One important application is to ensure that checks are on in cases where
4891 code depends on the checks for its correct functioning, so that the code
4892 will compile correctly even if the compiler switches are set to suppress
4895 @node Pragma Use_VADS_Size
4896 @unnumberedsec Pragma Use_VADS_Size
4897 @cindex @code{Size}, VADS compatibility
4898 @findex Use_VADS_Size
4902 @smallexample @c ada
4903 pragma Use_VADS_Size;
4907 This is a configuration pragma. In a unit to which it applies, any use
4908 of the 'Size attribute is automatically interpreted as a use of the
4909 'VADS_Size attribute. Note that this may result in incorrect semantic
4910 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
4911 the handling of existing code which depends on the interpretation of Size
4912 as implemented in the VADS compiler. See description of the VADS_Size
4913 attribute for further details.
4915 @node Pragma Validity_Checks
4916 @unnumberedsec Pragma Validity_Checks
4917 @findex Validity_Checks
4921 @smallexample @c ada
4922 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4926 This pragma is used in conjunction with compiler switches to control the
4927 built-in validity checking provided by GNAT@. The compiler switches, if set
4928 provide an initial setting for the switches, and this pragma may be used
4929 to modify these settings, or the settings may be provided entirely by
4930 the use of the pragma. This pragma can be used anywhere that a pragma
4931 is legal, including use as a configuration pragma (including use in
4932 the @file{gnat.adc} file).
4934 The form with a string literal specifies which validity options are to be
4935 activated. The validity checks are first set to include only the default
4936 reference manual settings, and then a string of letters in the string
4937 specifies the exact set of options required. The form of this string
4938 is exactly as described for the @option{-gnatVx} compiler switch (see the
4939 GNAT users guide for details). For example the following two methods
4940 can be used to enable validity checking for mode @code{in} and
4941 @code{in out} subprogram parameters:
4945 @smallexample @c ada
4946 pragma Validity_Checks ("im");
4951 gcc -c -gnatVim @dots{}
4956 The form ALL_CHECKS activates all standard checks (its use is equivalent
4957 to the use of the @code{gnatva} switch.
4959 The forms with @code{Off} and @code{On}
4960 can be used to temporarily disable validity checks
4961 as shown in the following example:
4963 @smallexample @c ada
4967 pragma Validity_Checks ("c"); -- validity checks for copies
4968 pragma Validity_Checks (Off); -- turn off validity checks
4969 A := B; -- B will not be validity checked
4970 pragma Validity_Checks (On); -- turn validity checks back on
4971 A := C; -- C will be validity checked
4974 @node Pragma Volatile
4975 @unnumberedsec Pragma Volatile
4980 @smallexample @c ada
4981 pragma Volatile (LOCAL_NAME);
4985 This pragma is defined by the Ada Reference Manual, and the GNAT
4986 implementation is fully conformant with this definition. The reason it
4987 is mentioned in this section is that a pragma of the same name was supplied
4988 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
4989 implementation of pragma Volatile is upwards compatible with the
4990 implementation in DEC Ada 83.
4992 @node Pragma Warnings
4993 @unnumberedsec Pragma Warnings
4998 @smallexample @c ada
4999 pragma Warnings (On | Off);
5000 pragma Warnings (On | Off, LOCAL_NAME);
5001 pragma Warnings (static_string_EXPRESSION);
5002 pragma Warnings (On | Off, static_string_EXPRESSION);
5006 Normally warnings are enabled, with the output being controlled by
5007 the command line switch. Warnings (@code{Off}) turns off generation of
5008 warnings until a Warnings (@code{On}) is encountered or the end of the
5009 current unit. If generation of warnings is turned off using this
5010 pragma, then no warning messages are output, regardless of the
5011 setting of the command line switches.
5013 The form with a single argument may be used as a configuration pragma.
5015 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5016 the specified entity. This suppression is effective from the point where
5017 it occurs till the end of the extended scope of the variable (similar to
5018 the scope of @code{Suppress}).
5020 The form with a single static_string_EXPRESSION argument provides more precise
5021 control over which warnings are active. The string is a list of letters
5022 specifying which warnings are to be activated and which deactivated. The
5023 code for these letters is the same as the string used in the command
5024 line switch controlling warnings. The following is a brief summary. For
5025 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5029 a turn on all optional warnings (except d h l .o)
5030 A turn off all optional warnings
5031 .a* turn on warnings for failing assertions
5032 .A turn off warnings for failing assertions
5033 b turn on warnings for bad fixed value (not multiple of small)
5034 B* turn off warnings for bad fixed value (not multiple of small)
5035 c turn on warnings for constant conditional
5036 C* turn off warnings for constant conditional
5037 .c turn on warnings for unrepped components
5038 .C* turn off warnings for unrepped components
5039 d turn on warnings for implicit dereference
5040 D* turn off warnings for implicit dereference
5041 e treat all warnings as errors
5042 f turn on warnings for unreferenced formal
5043 F* turn off warnings for unreferenced formal
5044 g* turn on warnings for unrecognized pragma
5045 G turn off warnings for unrecognized pragma
5046 h turn on warnings for hiding variable
5047 H* turn off warnings for hiding variable
5048 i* turn on warnings for implementation unit
5049 I turn off warnings for implementation unit
5050 j turn on warnings for obsolescent (annex J) feature
5051 J* turn off warnings for obsolescent (annex J) feature
5052 k turn on warnings on constant variable
5053 K* turn off warnings on constant variable
5054 l turn on warnings for missing elaboration pragma
5055 L* turn off warnings for missing elaboration pragma
5056 m turn on warnings for variable assigned but not read
5057 M* turn off warnings for variable assigned but not read
5058 n* normal warning mode (cancels -gnatws/-gnatwe)
5059 o* turn on warnings for address clause overlay
5060 O turn off warnings for address clause overlay
5061 .o turn on warnings for out parameters assigned but not read
5062 .O* turn off warnings for out parameters assigned but not read
5063 p turn on warnings for ineffective pragma Inline in frontend
5064 P* turn off warnings for ineffective pragma Inline in frontend
5065 q* turn on warnings for questionable missing parentheses
5066 Q turn off warnings for questionable missing parentheses
5067 r turn on warnings for redundant construct
5068 R* turn off warnings for redundant construct
5069 .r turn on warnings for object renaming function
5070 .R* turn off warnings for object renaming function
5071 s suppress all warnings
5072 t turn on warnings for tracking deleted code
5073 T* turn off warnings for tracking deleted code
5074 u turn on warnings for unused entity
5075 U* turn off warnings for unused entity
5076 v* turn on warnings for unassigned variable
5077 V turn off warnings for unassigned variable
5078 w* turn on warnings for wrong low bound assumption
5079 W turn off warnings for wrong low bound assumption
5080 x* turn on warnings for export/import
5081 X turn off warnings for export/import
5082 .x turn on warnings for non-local exceptions
5083 .X* turn off warnings for non-local exceptions
5084 y* turn on warnings for Ada 2005 incompatibility
5085 Y turn off warnings for Ada 2005 incompatibility
5086 z* turn on convention/size/align warnings for unchecked conversion
5087 Z turn off convention/size/align warnings for unchecked conversion
5088 * indicates default in above list
5092 The specified warnings will be in effect until the end of the program
5093 or another pragma Warnings is encountered. The effect of the pragma is
5094 cumulative. Initially the set of warnings is the standard default set
5095 as possibly modified by compiler switches. Then each pragma Warning
5096 modifies this set of warnings as specified. This form of the pragma may
5097 also be used as a configuration pragma.
5099 The fourth form, with an On|Off parameter and a string, is used to
5100 control individual messages, based on their text. The string argument
5101 is a pattern that is used to match against the text of individual
5102 warning messages (not including the initial "warnings: " tag).
5104 The pattern may contain asterisks which match zero or more characters in
5105 the message. For example, you can use
5106 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5107 message @code{warning: 960 bits of "a" unused}. No other regular
5108 expression notations are permitted. All characters other than asterisk in
5109 these three specific cases are treated as literal characters in the match.
5111 There are two ways to use this pragma. The OFF form can be used as a
5112 configuration pragma. The effect is to suppress all warnings (if any)
5113 that match the pattern string throughout the compilation.
5115 The second usage is to suppress a warning locally, and in this case, two
5116 pragmas must appear in sequence:
5118 @smallexample @c ada
5119 pragma Warnings (Off, Pattern);
5120 @dots{} code where given warning is to be suppressed
5121 pragma Warnings (On, Pattern);
5125 In this usage, the pattern string must match in the Off and On pragmas,
5126 and at least one matching warning must be suppressed.
5128 @node Pragma Weak_External
5129 @unnumberedsec Pragma Weak_External
5130 @findex Weak_External
5134 @smallexample @c ada
5135 pragma Weak_External ([Entity =>] LOCAL_NAME);
5139 @var{LOCAL_NAME} must refer to an object that is declared at the library
5140 level. This pragma specifies that the given entity should be marked as a
5141 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5142 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5143 of a regular symbol, that is to say a symbol that does not have to be
5144 resolved by the linker if used in conjunction with a pragma Import.
5146 When a weak symbol is not resolved by the linker, its address is set to
5147 zero. This is useful in writing interfaces to external modules that may
5148 or may not be linked in the final executable, for example depending on
5149 configuration settings.
5151 If a program references at run time an entity to which this pragma has been
5152 applied, and the corresponding symbol was not resolved at link time, then
5153 the execution of the program is erroneous. It is not erroneous to take the
5154 Address of such an entity, for example to guard potential references,
5155 as shown in the example below.
5157 Some file formats do not support weak symbols so not all target machines
5158 support this pragma.
5160 @smallexample @c ada
5161 -- Example of the use of pragma Weak_External
5163 package External_Module is
5165 pragma Import (C, key);
5166 pragma Weak_External (key);
5167 function Present return boolean;
5168 end External_Module;
5170 with System; use System;
5171 package body External_Module is
5172 function Present return boolean is
5174 return key'Address /= System.Null_Address;
5176 end External_Module;
5179 @node Pragma Wide_Character_Encoding
5180 @unnumberedsec Pragma Wide_Character_Encoding
5181 @findex Wide_Character_Encoding
5185 @smallexample @c ada
5186 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5190 This pragma specifies the wide character encoding to be used in program
5191 source text appearing subsequently. It is a configuration pragma, but may
5192 also be used at any point that a pragma is allowed, and it is permissible
5193 to have more than one such pragma in a file, allowing multiple encodings
5194 to appear within the same file.
5196 The argument can be an identifier or a character literal. In the identifier
5197 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5198 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5199 case it is correspondingly one of the characters @samp{h}, @samp{u},
5200 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5202 Note that when the pragma is used within a file, it affects only the
5203 encoding within that file, and does not affect withed units, specs,
5206 @node Implementation Defined Attributes
5207 @chapter Implementation Defined Attributes
5208 Ada defines (throughout the Ada reference manual,
5209 summarized in Annex K),
5210 a set of attributes that provide useful additional functionality in all
5211 areas of the language. These language defined attributes are implemented
5212 in GNAT and work as described in the Ada Reference Manual.
5214 In addition, Ada allows implementations to define additional
5215 attributes whose meaning is defined by the implementation. GNAT provides
5216 a number of these implementation-dependent attributes which can be used
5217 to extend and enhance the functionality of the compiler. This section of
5218 the GNAT reference manual describes these additional attributes.
5220 Note that any program using these attributes may not be portable to
5221 other compilers (although GNAT implements this set of attributes on all
5222 platforms). Therefore if portability to other compilers is an important
5223 consideration, you should minimize the use of these attributes.
5234 * Default_Bit_Order::
5244 * Has_Access_Values::
5245 * Has_Discriminants::
5252 * Max_Interrupt_Priority::
5254 * Maximum_Alignment::
5259 * Passed_By_Reference::
5272 * Unconstrained_Array::
5273 * Universal_Literal_String::
5274 * Unrestricted_Access::
5282 @unnumberedsec Abort_Signal
5283 @findex Abort_Signal
5285 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5286 prefix) provides the entity for the special exception used to signal
5287 task abort or asynchronous transfer of control. Normally this attribute
5288 should only be used in the tasking runtime (it is highly peculiar, and
5289 completely outside the normal semantics of Ada, for a user program to
5290 intercept the abort exception).
5293 @unnumberedsec Address_Size
5294 @cindex Size of @code{Address}
5295 @findex Address_Size
5297 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5298 prefix) is a static constant giving the number of bits in an
5299 @code{Address}. It is the same value as System.Address'Size,
5300 but has the advantage of being static, while a direct
5301 reference to System.Address'Size is non-static because Address
5305 @unnumberedsec Asm_Input
5308 The @code{Asm_Input} attribute denotes a function that takes two
5309 parameters. The first is a string, the second is an expression of the
5310 type designated by the prefix. The first (string) argument is required
5311 to be a static expression, and is the constraint for the parameter,
5312 (e.g.@: what kind of register is required). The second argument is the
5313 value to be used as the input argument. The possible values for the
5314 constant are the same as those used in the RTL, and are dependent on
5315 the configuration file used to built the GCC back end.
5316 @ref{Machine Code Insertions}
5319 @unnumberedsec Asm_Output
5322 The @code{Asm_Output} attribute denotes a function that takes two
5323 parameters. The first is a string, the second is the name of a variable
5324 of the type designated by the attribute prefix. The first (string)
5325 argument is required to be a static expression and designates the
5326 constraint for the parameter (e.g.@: what kind of register is
5327 required). The second argument is the variable to be updated with the
5328 result. The possible values for constraint are the same as those used in
5329 the RTL, and are dependent on the configuration file used to build the
5330 GCC back end. If there are no output operands, then this argument may
5331 either be omitted, or explicitly given as @code{No_Output_Operands}.
5332 @ref{Machine Code Insertions}
5335 @unnumberedsec AST_Entry
5339 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
5340 the name of an entry, it yields a value of the predefined type AST_Handler
5341 (declared in the predefined package System, as extended by the use of
5342 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
5343 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
5344 Language Reference Manual}, section 9.12a.
5349 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5350 offset within the storage unit (byte) that contains the first bit of
5351 storage allocated for the object. The value of this attribute is of the
5352 type @code{Universal_Integer}, and is always a non-negative number not
5353 exceeding the value of @code{System.Storage_Unit}.
5355 For an object that is a variable or a constant allocated in a register,
5356 the value is zero. (The use of this attribute does not force the
5357 allocation of a variable to memory).
5359 For an object that is a formal parameter, this attribute applies
5360 to either the matching actual parameter or to a copy of the
5361 matching actual parameter.
5363 For an access object the value is zero. Note that
5364 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5365 designated object. Similarly for a record component
5366 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5367 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5368 are subject to index checks.
5370 This attribute is designed to be compatible with the DEC Ada 83 definition
5371 and implementation of the @code{Bit} attribute.
5374 @unnumberedsec Bit_Position
5375 @findex Bit_Position
5377 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5378 of the fields of the record type, yields the bit
5379 offset within the record contains the first bit of
5380 storage allocated for the object. The value of this attribute is of the
5381 type @code{Universal_Integer}. The value depends only on the field
5382 @var{C} and is independent of the alignment of
5383 the containing record @var{R}.
5386 @unnumberedsec Code_Address
5387 @findex Code_Address
5388 @cindex Subprogram address
5389 @cindex Address of subprogram code
5392 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5393 intended effect seems to be to provide
5394 an address value which can be used to call the subprogram by means of
5395 an address clause as in the following example:
5397 @smallexample @c ada
5398 procedure K is @dots{}
5401 for L'Address use K'Address;
5402 pragma Import (Ada, L);
5406 A call to @code{L} is then expected to result in a call to @code{K}@.
5407 In Ada 83, where there were no access-to-subprogram values, this was
5408 a common work-around for getting the effect of an indirect call.
5409 GNAT implements the above use of @code{Address} and the technique
5410 illustrated by the example code works correctly.
5412 However, for some purposes, it is useful to have the address of the start
5413 of the generated code for the subprogram. On some architectures, this is
5414 not necessarily the same as the @code{Address} value described above.
5415 For example, the @code{Address} value may reference a subprogram
5416 descriptor rather than the subprogram itself.
5418 The @code{'Code_Address} attribute, which can only be applied to
5419 subprogram entities, always returns the address of the start of the
5420 generated code of the specified subprogram, which may or may not be
5421 the same value as is returned by the corresponding @code{'Address}
5424 @node Default_Bit_Order
5425 @unnumberedsec Default_Bit_Order
5427 @cindex Little endian
5428 @findex Default_Bit_Order
5430 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5431 permissible prefix), provides the value @code{System.Default_Bit_Order}
5432 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5433 @code{Low_Order_First}). This is used to construct the definition of
5434 @code{Default_Bit_Order} in package @code{System}.
5437 @unnumberedsec Elaborated
5440 The prefix of the @code{'Elaborated} attribute must be a unit name. The
5441 value is a Boolean which indicates whether or not the given unit has been
5442 elaborated. This attribute is primarily intended for internal use by the
5443 generated code for dynamic elaboration checking, but it can also be used
5444 in user programs. The value will always be True once elaboration of all
5445 units has been completed. An exception is for units which need no
5446 elaboration, the value is always False for such units.
5449 @unnumberedsec Elab_Body
5452 This attribute can only be applied to a program unit name. It returns
5453 the entity for the corresponding elaboration procedure for elaborating
5454 the body of the referenced unit. This is used in the main generated
5455 elaboration procedure by the binder and is not normally used in any
5456 other context. However, there may be specialized situations in which it
5457 is useful to be able to call this elaboration procedure from Ada code,
5458 e.g.@: if it is necessary to do selective re-elaboration to fix some
5462 @unnumberedsec Elab_Spec
5465 This attribute can only be applied to a program unit name. It returns
5466 the entity for the corresponding elaboration procedure for elaborating
5467 the spec of the referenced unit. This is used in the main
5468 generated elaboration procedure by the binder and is not normally used
5469 in any other context. However, there may be specialized situations in
5470 which it is useful to be able to call this elaboration procedure from
5471 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5476 @cindex Ada 83 attributes
5479 The @code{Emax} attribute is provided for compatibility with Ada 83. See
5480 the Ada 83 reference manual for an exact description of the semantics of
5484 @unnumberedsec Enabled
5487 The @code{Enabled} attribute allows an application program to check at compile
5488 time to see if the designated check is currently enabled. The prefix is a
5489 simple identifier, referencing any predefined check name (other than
5490 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5491 no argument is given for the attribute, the check is for the general state
5492 of the check, if an argument is given, then it is an entity name, and the
5493 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5494 given naming the entity (if not, then the argument is ignored).
5496 Note that instantiations inherit the check status at the point of the
5497 instantiation, so a useful idiom is to have a library package that
5498 introduces a check name with @code{pragma Check_Name}, and then contains
5499 generic packages or subprograms which use the @code{Enabled} attribute
5500 to see if the check is enabled. A user of this package can then issue
5501 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5502 the package or subprogram, controlling whether the check will be present.
5505 @unnumberedsec Enum_Rep
5506 @cindex Representation of enums
5509 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5510 function with the following spec:
5512 @smallexample @c ada
5513 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5514 return @i{Universal_Integer};
5518 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5519 enumeration type or to a non-overloaded enumeration
5520 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
5521 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5522 enumeration literal or object.
5524 The function returns the representation value for the given enumeration
5525 value. This will be equal to value of the @code{Pos} attribute in the
5526 absence of an enumeration representation clause. This is a static
5527 attribute (i.e.@: the result is static if the argument is static).
5529 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5530 in which case it simply returns the integer value. The reason for this
5531 is to allow it to be used for @code{(<>)} discrete formal arguments in
5532 a generic unit that can be instantiated with either enumeration types
5533 or integer types. Note that if @code{Enum_Rep} is used on a modular
5534 type whose upper bound exceeds the upper bound of the largest signed
5535 integer type, and the argument is a variable, so that the universal
5536 integer calculation is done at run time, then the call to @code{Enum_Rep}
5537 may raise @code{Constraint_Error}.
5540 @unnumberedsec Enum_Val
5541 @cindex Representation of enums
5544 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5545 function with the following spec:
5547 @smallexample @c ada
5548 function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5549 return @var{S}'Base};
5553 The function returns the enumeration value whose representation matches the
5554 argument, or raises Constraint_Error if no enumeration literal of the type
5555 has the matching value.
5556 This will be equal to value of the @code{Val} attribute in the
5557 absence of an enumeration representation clause. This is a static
5558 attribute (i.e.@: the result is static if the argument is static).
5561 @unnumberedsec Epsilon
5562 @cindex Ada 83 attributes
5565 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
5566 the Ada 83 reference manual for an exact description of the semantics of
5570 @unnumberedsec Fixed_Value
5573 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5574 function with the following specification:
5576 @smallexample @c ada
5577 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5582 The value returned is the fixed-point value @var{V} such that
5584 @smallexample @c ada
5585 @var{V} = Arg * @var{S}'Small
5589 The effect is thus similar to first converting the argument to the
5590 integer type used to represent @var{S}, and then doing an unchecked
5591 conversion to the fixed-point type. The difference is
5592 that there are full range checks, to ensure that the result is in range.
5593 This attribute is primarily intended for use in implementation of the
5594 input-output functions for fixed-point values.
5596 @node Has_Access_Values
5597 @unnumberedsec Has_Access_Values
5598 @cindex Access values, testing for
5599 @findex Has_Access_Values
5601 The prefix of the @code{Has_Access_Values} attribute is a type. The result
5602 is a Boolean value which is True if the is an access type, or is a composite
5603 type with a component (at any nesting depth) that is an access type, and is
5605 The intended use of this attribute is in conjunction with generic
5606 definitions. If the attribute is applied to a generic private type, it
5607 indicates whether or not the corresponding actual type has access values.
5609 @node Has_Discriminants
5610 @unnumberedsec Has_Discriminants
5611 @cindex Discriminants, testing for
5612 @findex Has_Discriminants
5614 The prefix of the @code{Has_Discriminants} attribute is a type. The result
5615 is a Boolean value which is True if the type has discriminants, and False
5616 otherwise. The intended use of this attribute is in conjunction with generic
5617 definitions. If the attribute is applied to a generic private type, it
5618 indicates whether or not the corresponding actual type has discriminants.
5624 The @code{Img} attribute differs from @code{Image} in that it may be
5625 applied to objects as well as types, in which case it gives the
5626 @code{Image} for the subtype of the object. This is convenient for
5629 @smallexample @c ada
5630 Put_Line ("X = " & X'Img);
5634 has the same meaning as the more verbose:
5636 @smallexample @c ada
5637 Put_Line ("X = " & @var{T}'Image (X));
5641 where @var{T} is the (sub)type of the object @code{X}.
5644 @unnumberedsec Integer_Value
5645 @findex Integer_Value
5647 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5648 function with the following spec:
5650 @smallexample @c ada
5651 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5656 The value returned is the integer value @var{V}, such that
5658 @smallexample @c ada
5659 Arg = @var{V} * @var{T}'Small
5663 where @var{T} is the type of @code{Arg}.
5664 The effect is thus similar to first doing an unchecked conversion from
5665 the fixed-point type to its corresponding implementation type, and then
5666 converting the result to the target integer type. The difference is
5667 that there are full range checks, to ensure that the result is in range.
5668 This attribute is primarily intended for use in implementation of the
5669 standard input-output functions for fixed-point values.
5672 @unnumberedsec Invalid_Value
5673 @findex Invalid_Value
5675 For every scalar type S, S'Invalid_Value returns an undefined value of the
5676 type. If possible this value is an invalid representation for the type. The
5677 value returned is identical to the value used to initialize an otherwise
5678 uninitialized value of the type if pragma Initialize_Scalars is used,
5679 including the ability to modify the value with the binder -Sxx flag and
5680 relevant environment variables at run time.
5683 @unnumberedsec Large
5684 @cindex Ada 83 attributes
5687 The @code{Large} attribute is provided for compatibility with Ada 83. See
5688 the Ada 83 reference manual for an exact description of the semantics of
5692 @unnumberedsec Machine_Size
5693 @findex Machine_Size
5695 This attribute is identical to the @code{Object_Size} attribute. It is
5696 provided for compatibility with the DEC Ada 83 attribute of this name.
5699 @unnumberedsec Mantissa
5700 @cindex Ada 83 attributes
5703 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
5704 the Ada 83 reference manual for an exact description of the semantics of
5707 @node Max_Interrupt_Priority
5708 @unnumberedsec Max_Interrupt_Priority
5709 @cindex Interrupt priority, maximum
5710 @findex Max_Interrupt_Priority
5712 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5713 permissible prefix), provides the same value as
5714 @code{System.Max_Interrupt_Priority}.
5717 @unnumberedsec Max_Priority
5718 @cindex Priority, maximum
5719 @findex Max_Priority
5721 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5722 prefix) provides the same value as @code{System.Max_Priority}.
5724 @node Maximum_Alignment
5725 @unnumberedsec Maximum_Alignment
5726 @cindex Alignment, maximum
5727 @findex Maximum_Alignment
5729 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5730 permissible prefix) provides the maximum useful alignment value for the
5731 target. This is a static value that can be used to specify the alignment
5732 for an object, guaranteeing that it is properly aligned in all
5735 @node Mechanism_Code
5736 @unnumberedsec Mechanism_Code
5737 @cindex Return values, passing mechanism
5738 @cindex Parameters, passing mechanism
5739 @findex Mechanism_Code
5741 @code{@var{function}'Mechanism_Code} yields an integer code for the
5742 mechanism used for the result of function, and
5743 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5744 used for formal parameter number @var{n} (a static integer value with 1
5745 meaning the first parameter) of @var{subprogram}. The code returned is:
5753 by descriptor (default descriptor class)
5755 by descriptor (UBS: unaligned bit string)
5757 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5759 by descriptor (UBA: unaligned bit array)
5761 by descriptor (S: string, also scalar access type parameter)
5763 by descriptor (SB: string with arbitrary bounds)
5765 by descriptor (A: contiguous array)
5767 by descriptor (NCA: non-contiguous array)
5771 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5774 @node Null_Parameter
5775 @unnumberedsec Null_Parameter
5776 @cindex Zero address, passing
5777 @findex Null_Parameter
5779 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5780 type or subtype @var{T} allocated at machine address zero. The attribute
5781 is allowed only as the default expression of a formal parameter, or as
5782 an actual expression of a subprogram call. In either case, the
5783 subprogram must be imported.
5785 The identity of the object is represented by the address zero in the
5786 argument list, independent of the passing mechanism (explicit or
5789 This capability is needed to specify that a zero address should be
5790 passed for a record or other composite object passed by reference.
5791 There is no way of indicating this without the @code{Null_Parameter}
5795 @unnumberedsec Object_Size
5796 @cindex Size, used for objects
5799 The size of an object is not necessarily the same as the size of the type
5800 of an object. This is because by default object sizes are increased to be
5801 a multiple of the alignment of the object. For example,
5802 @code{Natural'Size} is
5803 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5804 Similarly, a record containing an integer and a character:
5806 @smallexample @c ada
5814 will have a size of 40 (that is @code{Rec'Size} will be 40. The
5815 alignment will be 4, because of the
5816 integer field, and so the default size of record objects for this type
5817 will be 64 (8 bytes).
5821 @cindex Capturing Old values
5822 @cindex Postconditions
5824 The attribute Prefix'Old can be used within a
5825 subprogram to refer to the value of the prefix on entry. So for
5826 example if you have an argument of a record type X called Arg1,
5827 you can refer to Arg1.Field'Old which yields the value of
5828 Arg1.Field on entry. The implementation simply involves generating
5829 an object declaration which captures the value on entry. Any
5830 prefix is allowed except one of a limited type (since limited
5831 types cannot be copied to capture their values) or a local variable
5832 (since it does not exist at subprogram entry time).
5834 The following example shows the use of 'Old to implement
5835 a test of a postcondition:
5837 @smallexample @c ada
5848 package body Old_Pkg is
5849 Count : Natural := 0;
5853 ... code manipulating the value of Count
5855 pragma Assert (Count = Count'Old + 1);
5861 Note that it is allowed to apply 'Old to a constant entity, but this will
5862 result in a warning, since the old and new values will always be the same.
5864 @node Passed_By_Reference
5865 @unnumberedsec Passed_By_Reference
5866 @cindex Parameters, when passed by reference
5867 @findex Passed_By_Reference
5869 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5870 a value of type @code{Boolean} value that is @code{True} if the type is
5871 normally passed by reference and @code{False} if the type is normally
5872 passed by copy in calls. For scalar types, the result is always @code{False}
5873 and is static. For non-scalar types, the result is non-static.
5876 @unnumberedsec Pool_Address
5877 @cindex Parameters, when passed by reference
5878 @findex Pool_Address
5880 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
5881 of X within its storage pool. This is the same as
5882 @code{@var{X}'Address}, except that for an unconstrained array whose
5883 bounds are allocated just before the first component,
5884 @code{@var{X}'Pool_Address} returns the address of those bounds,
5885 whereas @code{@var{X}'Address} returns the address of the first
5888 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
5889 the object is allocated'', which could be a user-defined storage pool,
5890 the global heap, on the stack, or in a static memory area. For an
5891 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
5892 what is passed to @code{Allocate} and returned from @code{Deallocate}.
5895 @unnumberedsec Range_Length
5896 @findex Range_Length
5898 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5899 the number of values represented by the subtype (zero for a null
5900 range). The result is static for static subtypes. @code{Range_Length}
5901 applied to the index subtype of a one dimensional array always gives the
5902 same result as @code{Range} applied to the array itself.
5905 @unnumberedsec Safe_Emax
5906 @cindex Ada 83 attributes
5909 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
5910 the Ada 83 reference manual for an exact description of the semantics of
5914 @unnumberedsec Safe_Large
5915 @cindex Ada 83 attributes
5918 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
5919 the Ada 83 reference manual for an exact description of the semantics of
5923 @unnumberedsec Small
5924 @cindex Ada 83 attributes
5927 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
5929 GNAT also allows this attribute to be applied to floating-point types
5930 for compatibility with Ada 83. See
5931 the Ada 83 reference manual for an exact description of the semantics of
5932 this attribute when applied to floating-point types.
5935 @unnumberedsec Storage_Unit
5936 @findex Storage_Unit
5938 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
5939 prefix) provides the same value as @code{System.Storage_Unit}.
5942 @unnumberedsec Stub_Type
5945 The GNAT implementation of remote access-to-classwide types is
5946 organized as described in AARM section E.4 (20.t): a value of an RACW type
5947 (designating a remote object) is represented as a normal access
5948 value, pointing to a "stub" object which in turn contains the
5949 necessary information to contact the designated remote object. A
5950 call on any dispatching operation of such a stub object does the
5951 remote call, if necessary, using the information in the stub object
5952 to locate the target partition, etc.
5954 For a prefix @code{T} that denotes a remote access-to-classwide type,
5955 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
5957 By construction, the layout of @code{T'Stub_Type} is identical to that of
5958 type @code{RACW_Stub_Type} declared in the internal implementation-defined
5959 unit @code{System.Partition_Interface}. Use of this attribute will create
5960 an implicit dependency on this unit.
5963 @unnumberedsec Target_Name
5966 @code{Standard'Target_Name} (@code{Standard} is the only permissible
5967 prefix) provides a static string value that identifies the target
5968 for the current compilation. For GCC implementations, this is the
5969 standard gcc target name without the terminating slash (for
5970 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
5976 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
5977 provides the same value as @code{System.Tick},
5980 @unnumberedsec To_Address
5983 The @code{System'To_Address}
5984 (@code{System} is the only permissible prefix)
5985 denotes a function identical to
5986 @code{System.Storage_Elements.To_Address} except that
5987 it is a static attribute. This means that if its argument is
5988 a static expression, then the result of the attribute is a
5989 static expression. The result is that such an expression can be
5990 used in contexts (e.g.@: preelaborable packages) which require a
5991 static expression and where the function call could not be used
5992 (since the function call is always non-static, even if its
5993 argument is static).
5996 @unnumberedsec Type_Class
5999 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6000 the value of the type class for the full type of @var{type}. If
6001 @var{type} is a generic formal type, the value is the value for the
6002 corresponding actual subtype. The value of this attribute is of type
6003 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6005 @smallexample @c ada
6007 (Type_Class_Enumeration,
6009 Type_Class_Fixed_Point,
6010 Type_Class_Floating_Point,
6015 Type_Class_Address);
6019 Protected types yield the value @code{Type_Class_Task}, which thus
6020 applies to all concurrent types. This attribute is designed to
6021 be compatible with the DEC Ada 83 attribute of the same name.
6024 @unnumberedsec UET_Address
6027 The @code{UET_Address} attribute can only be used for a prefix which
6028 denotes a library package. It yields the address of the unit exception
6029 table when zero cost exception handling is used. This attribute is
6030 intended only for use within the GNAT implementation. See the unit
6031 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6032 for details on how this attribute is used in the implementation.
6034 @node Unconstrained_Array
6035 @unnumberedsec Unconstrained_Array
6036 @findex Unconstrained_Array
6038 The @code{Unconstrained_Array} attribute can be used with a prefix that
6039 denotes any type or subtype. It is a static attribute that yields
6040 @code{True} if the prefix designates an unconstrained array,
6041 and @code{False} otherwise. In a generic instance, the result is
6042 still static, and yields the result of applying this test to the
6045 @node Universal_Literal_String
6046 @unnumberedsec Universal_Literal_String
6047 @cindex Named numbers, representation of
6048 @findex Universal_Literal_String
6050 The prefix of @code{Universal_Literal_String} must be a named
6051 number. The static result is the string consisting of the characters of
6052 the number as defined in the original source. This allows the user
6053 program to access the actual text of named numbers without intermediate
6054 conversions and without the need to enclose the strings in quotes (which
6055 would preclude their use as numbers). This is used internally for the
6056 construction of values of the floating-point attributes from the file
6057 @file{ttypef.ads}, but may also be used by user programs.
6059 For example, the following program prints the first 50 digits of pi:
6061 @smallexample @c ada
6062 with Text_IO; use Text_IO;
6066 Put (Ada.Numerics.Pi'Universal_Literal_String);
6070 @node Unrestricted_Access
6071 @unnumberedsec Unrestricted_Access
6072 @cindex @code{Access}, unrestricted
6073 @findex Unrestricted_Access
6075 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6076 except that all accessibility and aliased view checks are omitted. This
6077 is a user-beware attribute. It is similar to
6078 @code{Address}, for which it is a desirable replacement where the value
6079 desired is an access type. In other words, its effect is identical to
6080 first applying the @code{Address} attribute and then doing an unchecked
6081 conversion to a desired access type. In GNAT, but not necessarily in
6082 other implementations, the use of static chains for inner level
6083 subprograms means that @code{Unrestricted_Access} applied to a
6084 subprogram yields a value that can be called as long as the subprogram
6085 is in scope (normal Ada accessibility rules restrict this usage).
6087 It is possible to use @code{Unrestricted_Access} for any type, but care
6088 must be exercised if it is used to create pointers to unconstrained
6089 objects. In this case, the resulting pointer has the same scope as the
6090 context of the attribute, and may not be returned to some enclosing
6091 scope. For instance, a function cannot use @code{Unrestricted_Access}
6092 to create a unconstrained pointer and then return that value to the
6096 @unnumberedsec VADS_Size
6097 @cindex @code{Size}, VADS compatibility
6100 The @code{'VADS_Size} attribute is intended to make it easier to port
6101 legacy code which relies on the semantics of @code{'Size} as implemented
6102 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
6103 same semantic interpretation. In particular, @code{'VADS_Size} applied
6104 to a predefined or other primitive type with no Size clause yields the
6105 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6106 typical machines). In addition @code{'VADS_Size} applied to an object
6107 gives the result that would be obtained by applying the attribute to
6108 the corresponding type.
6111 @unnumberedsec Value_Size
6112 @cindex @code{Size}, setting for not-first subtype
6114 @code{@var{type}'Value_Size} is the number of bits required to represent
6115 a value of the given subtype. It is the same as @code{@var{type}'Size},
6116 but, unlike @code{Size}, may be set for non-first subtypes.
6119 @unnumberedsec Wchar_T_Size
6120 @findex Wchar_T_Size
6121 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6122 prefix) provides the size in bits of the C @code{wchar_t} type
6123 primarily for constructing the definition of this type in
6124 package @code{Interfaces.C}.
6127 @unnumberedsec Word_Size
6129 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6130 prefix) provides the value @code{System.Word_Size}.
6132 @c ------------------------
6133 @node Implementation Advice
6134 @chapter Implementation Advice
6136 The main text of the Ada Reference Manual describes the required
6137 behavior of all Ada compilers, and the GNAT compiler conforms to
6140 In addition, there are sections throughout the Ada Reference Manual headed
6141 by the phrase ``Implementation advice''. These sections are not normative,
6142 i.e., they do not specify requirements that all compilers must
6143 follow. Rather they provide advice on generally desirable behavior. You
6144 may wonder why they are not requirements. The most typical answer is
6145 that they describe behavior that seems generally desirable, but cannot
6146 be provided on all systems, or which may be undesirable on some systems.
6148 As far as practical, GNAT follows the implementation advice sections in
6149 the Ada Reference Manual. This chapter contains a table giving the
6150 reference manual section number, paragraph number and several keywords
6151 for each advice. Each entry consists of the text of the advice followed
6152 by the GNAT interpretation of this advice. Most often, this simply says
6153 ``followed'', which means that GNAT follows the advice. However, in a
6154 number of cases, GNAT deliberately deviates from this advice, in which
6155 case the text describes what GNAT does and why.
6157 @cindex Error detection
6158 @unnumberedsec 1.1.3(20): Error Detection
6161 If an implementation detects the use of an unsupported Specialized Needs
6162 Annex feature at run time, it should raise @code{Program_Error} if
6165 Not relevant. All specialized needs annex features are either supported,
6166 or diagnosed at compile time.
6169 @unnumberedsec 1.1.3(31): Child Units
6172 If an implementation wishes to provide implementation-defined
6173 extensions to the functionality of a language-defined library unit, it
6174 should normally do so by adding children to the library unit.
6178 @cindex Bounded errors
6179 @unnumberedsec 1.1.5(12): Bounded Errors
6182 If an implementation detects a bounded error or erroneous
6183 execution, it should raise @code{Program_Error}.
6185 Followed in all cases in which the implementation detects a bounded
6186 error or erroneous execution. Not all such situations are detected at
6190 @unnumberedsec 2.8(16): Pragmas
6193 Normally, implementation-defined pragmas should have no semantic effect
6194 for error-free programs; that is, if the implementation-defined pragmas
6195 are removed from a working program, the program should still be legal,
6196 and should still have the same semantics.
6198 The following implementation defined pragmas are exceptions to this
6210 @item CPP_Constructor
6214 @item Interface_Name
6216 @item Machine_Attribute
6218 @item Unimplemented_Unit
6220 @item Unchecked_Union
6225 In each of the above cases, it is essential to the purpose of the pragma
6226 that this advice not be followed. For details see the separate section
6227 on implementation defined pragmas.
6229 @unnumberedsec 2.8(17-19): Pragmas
6232 Normally, an implementation should not define pragmas that can
6233 make an illegal program legal, except as follows:
6237 A pragma used to complete a declaration, such as a pragma @code{Import};
6241 A pragma used to configure the environment by adding, removing, or
6242 replacing @code{library_items}.
6244 See response to paragraph 16 of this same section.
6246 @cindex Character Sets
6247 @cindex Alternative Character Sets
6248 @unnumberedsec 3.5.2(5): Alternative Character Sets
6251 If an implementation supports a mode with alternative interpretations
6252 for @code{Character} and @code{Wide_Character}, the set of graphic
6253 characters of @code{Character} should nevertheless remain a proper
6254 subset of the set of graphic characters of @code{Wide_Character}. Any
6255 character set ``localizations'' should be reflected in the results of
6256 the subprograms defined in the language-defined package
6257 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
6258 an alternative interpretation of @code{Character}, the implementation should
6259 also support a corresponding change in what is a legal
6260 @code{identifier_letter}.
6262 Not all wide character modes follow this advice, in particular the JIS
6263 and IEC modes reflect standard usage in Japan, and in these encoding,
6264 the upper half of the Latin-1 set is not part of the wide-character
6265 subset, since the most significant bit is used for wide character
6266 encoding. However, this only applies to the external forms. Internally
6267 there is no such restriction.
6269 @cindex Integer types
6270 @unnumberedsec 3.5.4(28): Integer Types
6274 An implementation should support @code{Long_Integer} in addition to
6275 @code{Integer} if the target machine supports 32-bit (or longer)
6276 arithmetic. No other named integer subtypes are recommended for package
6277 @code{Standard}. Instead, appropriate named integer subtypes should be
6278 provided in the library package @code{Interfaces} (see B.2).
6280 @code{Long_Integer} is supported. Other standard integer types are supported
6281 so this advice is not fully followed. These types
6282 are supported for convenient interface to C, and so that all hardware
6283 types of the machine are easily available.
6284 @unnumberedsec 3.5.4(29): Integer Types
6288 An implementation for a two's complement machine should support
6289 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
6290 implementation should support a non-binary modules up to @code{Integer'Last}.
6294 @cindex Enumeration values
6295 @unnumberedsec 3.5.5(8): Enumeration Values
6298 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6299 subtype, if the value of the operand does not correspond to the internal
6300 code for any enumeration literal of its type (perhaps due to an
6301 un-initialized variable), then the implementation should raise
6302 @code{Program_Error}. This is particularly important for enumeration
6303 types with noncontiguous internal codes specified by an
6304 enumeration_representation_clause.
6309 @unnumberedsec 3.5.7(17): Float Types
6312 An implementation should support @code{Long_Float} in addition to
6313 @code{Float} if the target machine supports 11 or more digits of
6314 precision. No other named floating point subtypes are recommended for
6315 package @code{Standard}. Instead, appropriate named floating point subtypes
6316 should be provided in the library package @code{Interfaces} (see B.2).
6318 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
6319 former provides improved compatibility with other implementations
6320 supporting this type. The latter corresponds to the highest precision
6321 floating-point type supported by the hardware. On most machines, this
6322 will be the same as @code{Long_Float}, but on some machines, it will
6323 correspond to the IEEE extended form. The notable case is all ia32
6324 (x86) implementations, where @code{Long_Long_Float} corresponds to
6325 the 80-bit extended precision format supported in hardware on this
6326 processor. Note that the 128-bit format on SPARC is not supported,
6327 since this is a software rather than a hardware format.
6329 @cindex Multidimensional arrays
6330 @cindex Arrays, multidimensional
6331 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6334 An implementation should normally represent multidimensional arrays in
6335 row-major order, consistent with the notation used for multidimensional
6336 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
6337 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6338 column-major order should be used instead (see B.5, ``Interfacing with
6343 @findex Duration'Small
6344 @unnumberedsec 9.6(30-31): Duration'Small
6347 Whenever possible in an implementation, the value of @code{Duration'Small}
6348 should be no greater than 100 microseconds.
6350 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
6354 The time base for @code{delay_relative_statements} should be monotonic;
6355 it need not be the same time base as used for @code{Calendar.Clock}.
6359 @unnumberedsec 10.2.1(12): Consistent Representation
6362 In an implementation, a type declared in a pre-elaborated package should
6363 have the same representation in every elaboration of a given version of
6364 the package, whether the elaborations occur in distinct executions of
6365 the same program, or in executions of distinct programs or partitions
6366 that include the given version.
6368 Followed, except in the case of tagged types. Tagged types involve
6369 implicit pointers to a local copy of a dispatch table, and these pointers
6370 have representations which thus depend on a particular elaboration of the
6371 package. It is not easy to see how it would be possible to follow this
6372 advice without severely impacting efficiency of execution.
6374 @cindex Exception information
6375 @unnumberedsec 11.4.1(19): Exception Information
6378 @code{Exception_Message} by default and @code{Exception_Information}
6379 should produce information useful for
6380 debugging. @code{Exception_Message} should be short, about one
6381 line. @code{Exception_Information} can be long. @code{Exception_Message}
6382 should not include the
6383 @code{Exception_Name}. @code{Exception_Information} should include both
6384 the @code{Exception_Name} and the @code{Exception_Message}.
6386 Followed. For each exception that doesn't have a specified
6387 @code{Exception_Message}, the compiler generates one containing the location
6388 of the raise statement. This location has the form ``file:line'', where
6389 file is the short file name (without path information) and line is the line
6390 number in the file. Note that in the case of the Zero Cost Exception
6391 mechanism, these messages become redundant with the Exception_Information that
6392 contains a full backtrace of the calling sequence, so they are disabled.
6393 To disable explicitly the generation of the source location message, use the
6394 Pragma @code{Discard_Names}.
6396 @cindex Suppression of checks
6397 @cindex Checks, suppression of
6398 @unnumberedsec 11.5(28): Suppression of Checks
6401 The implementation should minimize the code executed for checks that
6402 have been suppressed.
6406 @cindex Representation clauses
6407 @unnumberedsec 13.1 (21-24): Representation Clauses
6410 The recommended level of support for all representation items is
6411 qualified as follows:
6415 An implementation need not support representation items containing
6416 non-static expressions, except that an implementation should support a
6417 representation item for a given entity if each non-static expression in
6418 the representation item is a name that statically denotes a constant
6419 declared before the entity.
6421 Followed. In fact, GNAT goes beyond the recommended level of support
6422 by allowing nonstatic expressions in some representation clauses even
6423 without the need to declare constants initialized with the values of
6427 @smallexample @c ada
6430 for Y'Address use X'Address;>>
6436 An implementation need not support a specification for the @code{Size}
6437 for a given composite subtype, nor the size or storage place for an
6438 object (including a component) of a given composite subtype, unless the
6439 constraints on the subtype and its composite subcomponents (if any) are
6440 all static constraints.
6442 Followed. Size Clauses are not permitted on non-static components, as
6447 An aliased component, or a component whose type is by-reference, should
6448 always be allocated at an addressable location.
6452 @cindex Packed types
6453 @unnumberedsec 13.2(6-8): Packed Types
6456 If a type is packed, then the implementation should try to minimize
6457 storage allocated to objects of the type, possibly at the expense of
6458 speed of accessing components, subject to reasonable complexity in
6459 addressing calculations.
6463 The recommended level of support pragma @code{Pack} is:
6465 For a packed record type, the components should be packed as tightly as
6466 possible subject to the Sizes of the component subtypes, and subject to
6467 any @code{record_representation_clause} that applies to the type; the
6468 implementation may, but need not, reorder components or cross aligned
6469 word boundaries to improve the packing. A component whose @code{Size} is
6470 greater than the word size may be allocated an integral number of words.
6472 Followed. Tight packing of arrays is supported for all component sizes
6473 up to 64-bits. If the array component size is 1 (that is to say, if
6474 the component is a boolean type or an enumeration type with two values)
6475 then values of the type are implicitly initialized to zero. This
6476 happens both for objects of the packed type, and for objects that have a
6477 subcomponent of the packed type.
6481 An implementation should support Address clauses for imported
6485 @cindex @code{Address} clauses
6486 @unnumberedsec 13.3(14-19): Address Clauses
6490 For an array @var{X}, @code{@var{X}'Address} should point at the first
6491 component of the array, and not at the array bounds.
6497 The recommended level of support for the @code{Address} attribute is:
6499 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6500 object that is aliased or of a by-reference type, or is an entity whose
6501 @code{Address} has been specified.
6503 Followed. A valid address will be produced even if none of those
6504 conditions have been met. If necessary, the object is forced into
6505 memory to ensure the address is valid.
6509 An implementation should support @code{Address} clauses for imported
6516 Objects (including subcomponents) that are aliased or of a by-reference
6517 type should be allocated on storage element boundaries.
6523 If the @code{Address} of an object is specified, or it is imported or exported,
6524 then the implementation should not perform optimizations based on
6525 assumptions of no aliases.
6529 @cindex @code{Alignment} clauses
6530 @unnumberedsec 13.3(29-35): Alignment Clauses
6533 The recommended level of support for the @code{Alignment} attribute for
6536 An implementation should support specified Alignments that are factors
6537 and multiples of the number of storage elements per word, subject to the
6544 An implementation need not support specified @code{Alignment}s for
6545 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6546 loaded and stored by available machine instructions.
6552 An implementation need not support specified @code{Alignment}s that are
6553 greater than the maximum @code{Alignment} the implementation ever returns by
6560 The recommended level of support for the @code{Alignment} attribute for
6563 Same as above, for subtypes, but in addition:
6569 For stand-alone library-level objects of statically constrained
6570 subtypes, the implementation should support all @code{Alignment}s
6571 supported by the target linker. For example, page alignment is likely to
6572 be supported for such objects, but not for subtypes.
6576 @cindex @code{Size} clauses
6577 @unnumberedsec 13.3(42-43): Size Clauses
6580 The recommended level of support for the @code{Size} attribute of
6583 A @code{Size} clause should be supported for an object if the specified
6584 @code{Size} is at least as large as its subtype's @code{Size}, and
6585 corresponds to a size in storage elements that is a multiple of the
6586 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6590 @unnumberedsec 13.3(50-56): Size Clauses
6593 If the @code{Size} of a subtype is specified, and allows for efficient
6594 independent addressability (see 9.10) on the target architecture, then
6595 the @code{Size} of the following objects of the subtype should equal the
6596 @code{Size} of the subtype:
6598 Aliased objects (including components).
6604 @code{Size} clause on a composite subtype should not affect the
6605 internal layout of components.
6607 Followed. But note that this can be overridden by use of the implementation
6608 pragma Implicit_Packing in the case of packed arrays.
6612 The recommended level of support for the @code{Size} attribute of subtypes is:
6616 The @code{Size} (if not specified) of a static discrete or fixed point
6617 subtype should be the number of bits needed to represent each value
6618 belonging to the subtype using an unbiased representation, leaving space
6619 for a sign bit only if the subtype contains negative values. If such a
6620 subtype is a first subtype, then an implementation should support a
6621 specified @code{Size} for it that reflects this representation.
6627 For a subtype implemented with levels of indirection, the @code{Size}
6628 should include the size of the pointers, but not the size of what they
6633 @cindex @code{Component_Size} clauses
6634 @unnumberedsec 13.3(71-73): Component Size Clauses
6637 The recommended level of support for the @code{Component_Size}
6642 An implementation need not support specified @code{Component_Sizes} that are
6643 less than the @code{Size} of the component subtype.
6649 An implementation should support specified @code{Component_Size}s that
6650 are factors and multiples of the word size. For such
6651 @code{Component_Size}s, the array should contain no gaps between
6652 components. For other @code{Component_Size}s (if supported), the array
6653 should contain no gaps between components when packing is also
6654 specified; the implementation should forbid this combination in cases
6655 where it cannot support a no-gaps representation.
6659 @cindex Enumeration representation clauses
6660 @cindex Representation clauses, enumeration
6661 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6664 The recommended level of support for enumeration representation clauses
6667 An implementation need not support enumeration representation clauses
6668 for boolean types, but should at minimum support the internal codes in
6669 the range @code{System.Min_Int.System.Max_Int}.
6673 @cindex Record representation clauses
6674 @cindex Representation clauses, records
6675 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6678 The recommended level of support for
6679 @*@code{record_representation_clauses} is:
6681 An implementation should support storage places that can be extracted
6682 with a load, mask, shift sequence of machine code, and set with a load,
6683 shift, mask, store sequence, given the available machine instructions
6690 A storage place should be supported if its size is equal to the
6691 @code{Size} of the component subtype, and it starts and ends on a
6692 boundary that obeys the @code{Alignment} of the component subtype.
6698 If the default bit ordering applies to the declaration of a given type,
6699 then for a component whose subtype's @code{Size} is less than the word
6700 size, any storage place that does not cross an aligned word boundary
6701 should be supported.
6707 An implementation may reserve a storage place for the tag field of a
6708 tagged type, and disallow other components from overlapping that place.
6710 Followed. The storage place for the tag field is the beginning of the tagged
6711 record, and its size is Address'Size. GNAT will reject an explicit component
6712 clause for the tag field.
6716 An implementation need not support a @code{component_clause} for a
6717 component of an extension part if the storage place is not after the
6718 storage places of all components of the parent type, whether or not
6719 those storage places had been specified.
6721 Followed. The above advice on record representation clauses is followed,
6722 and all mentioned features are implemented.
6724 @cindex Storage place attributes
6725 @unnumberedsec 13.5.2(5): Storage Place Attributes
6728 If a component is represented using some form of pointer (such as an
6729 offset) to the actual data of the component, and this data is contiguous
6730 with the rest of the object, then the storage place attributes should
6731 reflect the place of the actual data, not the pointer. If a component is
6732 allocated discontinuously from the rest of the object, then a warning
6733 should be generated upon reference to one of its storage place
6736 Followed. There are no such components in GNAT@.
6738 @cindex Bit ordering
6739 @unnumberedsec 13.5.3(7-8): Bit Ordering
6742 The recommended level of support for the non-default bit ordering is:
6746 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6747 should support the non-default bit ordering in addition to the default
6750 Followed. Word size does not equal storage size in this implementation.
6751 Thus non-default bit ordering is not supported.
6753 @cindex @code{Address}, as private type
6754 @unnumberedsec 13.7(37): Address as Private
6757 @code{Address} should be of a private type.
6761 @cindex Operations, on @code{Address}
6762 @cindex @code{Address}, operations of
6763 @unnumberedsec 13.7.1(16): Address Operations
6766 Operations in @code{System} and its children should reflect the target
6767 environment semantics as closely as is reasonable. For example, on most
6768 machines, it makes sense for address arithmetic to ``wrap around''.
6769 Operations that do not make sense should raise @code{Program_Error}.
6771 Followed. Address arithmetic is modular arithmetic that wraps around. No
6772 operation raises @code{Program_Error}, since all operations make sense.
6774 @cindex Unchecked conversion
6775 @unnumberedsec 13.9(14-17): Unchecked Conversion
6778 The @code{Size} of an array object should not include its bounds; hence,
6779 the bounds should not be part of the converted data.
6785 The implementation should not generate unnecessary run-time checks to
6786 ensure that the representation of @var{S} is a representation of the
6787 target type. It should take advantage of the permission to return by
6788 reference when possible. Restrictions on unchecked conversions should be
6789 avoided unless required by the target environment.
6791 Followed. There are no restrictions on unchecked conversion. A warning is
6792 generated if the source and target types do not have the same size since
6793 the semantics in this case may be target dependent.
6797 The recommended level of support for unchecked conversions is:
6801 Unchecked conversions should be supported and should be reversible in
6802 the cases where this clause defines the result. To enable meaningful use
6803 of unchecked conversion, a contiguous representation should be used for
6804 elementary subtypes, for statically constrained array subtypes whose
6805 component subtype is one of the subtypes described in this paragraph,
6806 and for record subtypes without discriminants whose component subtypes
6807 are described in this paragraph.
6811 @cindex Heap usage, implicit
6812 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6815 An implementation should document any cases in which it dynamically
6816 allocates heap storage for a purpose other than the evaluation of an
6819 Followed, the only other points at which heap storage is dynamically
6820 allocated are as follows:
6824 At initial elaboration time, to allocate dynamically sized global
6828 To allocate space for a task when a task is created.
6831 To extend the secondary stack dynamically when needed. The secondary
6832 stack is used for returning variable length results.
6837 A default (implementation-provided) storage pool for an
6838 access-to-constant type should not have overhead to support deallocation of
6845 A storage pool for an anonymous access type should be created at the
6846 point of an allocator for the type, and be reclaimed when the designated
6847 object becomes inaccessible.
6851 @cindex Unchecked deallocation
6852 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6855 For a standard storage pool, @code{Free} should actually reclaim the
6860 @cindex Stream oriented attributes
6861 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6864 If a stream element is the same size as a storage element, then the
6865 normal in-memory representation should be used by @code{Read} and
6866 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
6867 should use the smallest number of stream elements needed to represent
6868 all values in the base range of the scalar type.
6871 Followed. By default, GNAT uses the interpretation suggested by AI-195,
6872 which specifies using the size of the first subtype.
6873 However, such an implementation is based on direct binary
6874 representations and is therefore target- and endianness-dependent.
6875 To address this issue, GNAT also supplies an alternate implementation
6876 of the stream attributes @code{Read} and @code{Write},
6877 which uses the target-independent XDR standard representation
6879 @cindex XDR representation
6880 @cindex @code{Read} attribute
6881 @cindex @code{Write} attribute
6882 @cindex Stream oriented attributes
6883 The XDR implementation is provided as an alternative body of the
6884 @code{System.Stream_Attributes} package, in the file
6885 @file{s-strxdr.adb} in the GNAT library.
6886 There is no @file{s-strxdr.ads} file.
6887 In order to install the XDR implementation, do the following:
6889 @item Replace the default implementation of the
6890 @code{System.Stream_Attributes} package with the XDR implementation.
6891 For example on a Unix platform issue the commands:
6893 $ mv s-stratt.adb s-strold.adb
6894 $ mv s-strxdr.adb s-stratt.adb
6898 Rebuild the GNAT run-time library as documented in
6899 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
6902 @unnumberedsec A.1(52): Names of Predefined Numeric Types
6905 If an implementation provides additional named predefined integer types,
6906 then the names should end with @samp{Integer} as in
6907 @samp{Long_Integer}. If an implementation provides additional named
6908 predefined floating point types, then the names should end with
6909 @samp{Float} as in @samp{Long_Float}.
6913 @findex Ada.Characters.Handling
6914 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
6917 If an implementation provides a localized definition of @code{Character}
6918 or @code{Wide_Character}, then the effects of the subprograms in
6919 @code{Characters.Handling} should reflect the localizations. See also
6922 Followed. GNAT provides no such localized definitions.
6924 @cindex Bounded-length strings
6925 @unnumberedsec A.4.4(106): Bounded-Length String Handling
6928 Bounded string objects should not be implemented by implicit pointers
6929 and dynamic allocation.
6931 Followed. No implicit pointers or dynamic allocation are used.
6933 @cindex Random number generation
6934 @unnumberedsec A.5.2(46-47): Random Number Generation
6937 Any storage associated with an object of type @code{Generator} should be
6938 reclaimed on exit from the scope of the object.
6944 If the generator period is sufficiently long in relation to the number
6945 of distinct initiator values, then each possible value of
6946 @code{Initiator} passed to @code{Reset} should initiate a sequence of
6947 random numbers that does not, in a practical sense, overlap the sequence
6948 initiated by any other value. If this is not possible, then the mapping
6949 between initiator values and generator states should be a rapidly
6950 varying function of the initiator value.
6952 Followed. The generator period is sufficiently long for the first
6953 condition here to hold true.
6955 @findex Get_Immediate
6956 @unnumberedsec A.10.7(23): @code{Get_Immediate}
6959 The @code{Get_Immediate} procedures should be implemented with
6960 unbuffered input. For a device such as a keyboard, input should be
6961 @dfn{available} if a key has already been typed, whereas for a disk
6962 file, input should always be available except at end of file. For a file
6963 associated with a keyboard-like device, any line-editing features of the
6964 underlying operating system should be disabled during the execution of
6965 @code{Get_Immediate}.
6967 Followed on all targets except VxWorks. For VxWorks, there is no way to
6968 provide this functionality that does not result in the input buffer being
6969 flushed before the @code{Get_Immediate} call. A special unit
6970 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
6974 @unnumberedsec B.1(39-41): Pragma @code{Export}
6977 If an implementation supports pragma @code{Export} to a given language,
6978 then it should also allow the main subprogram to be written in that
6979 language. It should support some mechanism for invoking the elaboration
6980 of the Ada library units included in the system, and for invoking the
6981 finalization of the environment task. On typical systems, the
6982 recommended mechanism is to provide two subprograms whose link names are
6983 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
6984 elaboration code for library units. @code{adafinal} should contain the
6985 finalization code. These subprograms should have no effect the second
6986 and subsequent time they are called.
6992 Automatic elaboration of pre-elaborated packages should be
6993 provided when pragma @code{Export} is supported.
6995 Followed when the main program is in Ada. If the main program is in a
6996 foreign language, then
6997 @code{adainit} must be called to elaborate pre-elaborated
7002 For each supported convention @var{L} other than @code{Intrinsic}, an
7003 implementation should support @code{Import} and @code{Export} pragmas
7004 for objects of @var{L}-compatible types and for subprograms, and pragma
7005 @code{Convention} for @var{L}-eligible types and for subprograms,
7006 presuming the other language has corresponding features. Pragma
7007 @code{Convention} need not be supported for scalar types.
7011 @cindex Package @code{Interfaces}
7013 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7016 For each implementation-defined convention identifier, there should be a
7017 child package of package Interfaces with the corresponding name. This
7018 package should contain any declarations that would be useful for
7019 interfacing to the language (implementation) represented by the
7020 convention. Any declarations useful for interfacing to any language on
7021 the given hardware architecture should be provided directly in
7024 Followed. An additional package not defined
7025 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7026 for interfacing to C++.
7030 An implementation supporting an interface to C, COBOL, or Fortran should
7031 provide the corresponding package or packages described in the following
7034 Followed. GNAT provides all the packages described in this section.
7036 @cindex C, interfacing with
7037 @unnumberedsec B.3(63-71): Interfacing with C
7040 An implementation should support the following interface correspondences
7047 An Ada procedure corresponds to a void-returning C function.
7053 An Ada function corresponds to a non-void C function.
7059 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7066 An Ada @code{in} parameter of an access-to-object type with designated
7067 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7068 where @var{t} is the C type corresponding to the Ada type @var{T}.
7074 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7075 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7076 argument to a C function, where @var{t} is the C type corresponding to
7077 the Ada type @var{T}. In the case of an elementary @code{out} or
7078 @code{in out} parameter, a pointer to a temporary copy is used to
7079 preserve by-copy semantics.
7085 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7086 @code{@var{t}*} argument to a C function, where @var{t} is the C
7087 structure corresponding to the Ada type @var{T}.
7089 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
7090 pragma, or Convention, or by explicitly specifying the mechanism for a given
7091 call using an extended import or export pragma.
7095 An Ada parameter of an array type with component type @var{T}, of any
7096 mode, is passed as a @code{@var{t}*} argument to a C function, where
7097 @var{t} is the C type corresponding to the Ada type @var{T}.
7103 An Ada parameter of an access-to-subprogram type is passed as a pointer
7104 to a C function whose prototype corresponds to the designated
7105 subprogram's specification.
7109 @cindex COBOL, interfacing with
7110 @unnumberedsec B.4(95-98): Interfacing with COBOL
7113 An Ada implementation should support the following interface
7114 correspondences between Ada and COBOL@.
7120 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7121 the COBOL type corresponding to @var{T}.
7127 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7128 the corresponding COBOL type.
7134 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7135 COBOL type corresponding to the Ada parameter type; for scalars, a local
7136 copy is used if necessary to ensure by-copy semantics.
7140 @cindex Fortran, interfacing with
7141 @unnumberedsec B.5(22-26): Interfacing with Fortran
7144 An Ada implementation should support the following interface
7145 correspondences between Ada and Fortran:
7151 An Ada procedure corresponds to a Fortran subroutine.
7157 An Ada function corresponds to a Fortran function.
7163 An Ada parameter of an elementary, array, or record type @var{T} is
7164 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7165 the Fortran type corresponding to the Ada type @var{T}, and where the
7166 INTENT attribute of the corresponding dummy argument matches the Ada
7167 formal parameter mode; the Fortran implementation's parameter passing
7168 conventions are used. For elementary types, a local copy is used if
7169 necessary to ensure by-copy semantics.
7175 An Ada parameter of an access-to-subprogram type is passed as a
7176 reference to a Fortran procedure whose interface corresponds to the
7177 designated subprogram's specification.
7181 @cindex Machine operations
7182 @unnumberedsec C.1(3-5): Access to Machine Operations
7185 The machine code or intrinsic support should allow access to all
7186 operations normally available to assembly language programmers for the
7187 target environment, including privileged instructions, if any.
7193 The interfacing pragmas (see Annex B) should support interface to
7194 assembler; the default assembler should be associated with the
7195 convention identifier @code{Assembler}.
7201 If an entity is exported to assembly language, then the implementation
7202 should allocate it at an addressable location, and should ensure that it
7203 is retained by the linking process, even if not otherwise referenced
7204 from the Ada code. The implementation should assume that any call to a
7205 machine code or assembler subprogram is allowed to read or update every
7206 object that is specified as exported.
7210 @unnumberedsec C.1(10-16): Access to Machine Operations
7213 The implementation should ensure that little or no overhead is
7214 associated with calling intrinsic and machine-code subprograms.
7216 Followed for both intrinsics and machine-code subprograms.
7220 It is recommended that intrinsic subprograms be provided for convenient
7221 access to any machine operations that provide special capabilities or
7222 efficiency and that are not otherwise available through the language
7225 Followed. A full set of machine operation intrinsic subprograms is provided.
7229 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7230 swap, decrement and test, enqueue/dequeue.
7232 Followed on any target supporting such operations.
7236 Standard numeric functions---e.g.@:, sin, log.
7238 Followed on any target supporting such operations.
7242 String manipulation operations---e.g.@:, translate and test.
7244 Followed on any target supporting such operations.
7248 Vector operations---e.g.@:, compare vector against thresholds.
7250 Followed on any target supporting such operations.
7254 Direct operations on I/O ports.
7256 Followed on any target supporting such operations.
7258 @cindex Interrupt support
7259 @unnumberedsec C.3(28): Interrupt Support
7262 If the @code{Ceiling_Locking} policy is not in effect, the
7263 implementation should provide means for the application to specify which
7264 interrupts are to be blocked during protected actions, if the underlying
7265 system allows for a finer-grain control of interrupt blocking.
7267 Followed. The underlying system does not allow for finer-grain control
7268 of interrupt blocking.
7270 @cindex Protected procedure handlers
7271 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7274 Whenever possible, the implementation should allow interrupt handlers to
7275 be called directly by the hardware.
7279 This is never possible under IRIX, so this is followed by default.
7281 Followed on any target where the underlying operating system permits
7286 Whenever practical, violations of any
7287 implementation-defined restrictions should be detected before run time.
7289 Followed. Compile time warnings are given when possible.
7291 @cindex Package @code{Interrupts}
7293 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7297 If implementation-defined forms of interrupt handler procedures are
7298 supported, such as protected procedures with parameters, then for each
7299 such form of a handler, a type analogous to @code{Parameterless_Handler}
7300 should be specified in a child package of @code{Interrupts}, with the
7301 same operations as in the predefined package Interrupts.
7305 @cindex Pre-elaboration requirements
7306 @unnumberedsec C.4(14): Pre-elaboration Requirements
7309 It is recommended that pre-elaborated packages be implemented in such a
7310 way that there should be little or no code executed at run time for the
7311 elaboration of entities not already covered by the Implementation
7314 Followed. Executable code is generated in some cases, e.g.@: loops
7315 to initialize large arrays.
7317 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7321 If the pragma applies to an entity, then the implementation should
7322 reduce the amount of storage used for storing names associated with that
7327 @cindex Package @code{Task_Attributes}
7328 @findex Task_Attributes
7329 @unnumberedsec C.7.2(30): The Package Task_Attributes
7332 Some implementations are targeted to domains in which memory use at run
7333 time must be completely deterministic. For such implementations, it is
7334 recommended that the storage for task attributes will be pre-allocated
7335 statically and not from the heap. This can be accomplished by either
7336 placing restrictions on the number and the size of the task's
7337 attributes, or by using the pre-allocated storage for the first @var{N}
7338 attribute objects, and the heap for the others. In the latter case,
7339 @var{N} should be documented.
7341 Not followed. This implementation is not targeted to such a domain.
7343 @cindex Locking Policies
7344 @unnumberedsec D.3(17): Locking Policies
7348 The implementation should use names that end with @samp{_Locking} for
7349 locking policies defined by the implementation.
7351 Followed. A single implementation-defined locking policy is defined,
7352 whose name (@code{Inheritance_Locking}) follows this suggestion.
7354 @cindex Entry queuing policies
7355 @unnumberedsec D.4(16): Entry Queuing Policies
7358 Names that end with @samp{_Queuing} should be used
7359 for all implementation-defined queuing policies.
7361 Followed. No such implementation-defined queuing policies exist.
7363 @cindex Preemptive abort
7364 @unnumberedsec D.6(9-10): Preemptive Abort
7367 Even though the @code{abort_statement} is included in the list of
7368 potentially blocking operations (see 9.5.1), it is recommended that this
7369 statement be implemented in a way that never requires the task executing
7370 the @code{abort_statement} to block.
7376 On a multi-processor, the delay associated with aborting a task on
7377 another processor should be bounded; the implementation should use
7378 periodic polling, if necessary, to achieve this.
7382 @cindex Tasking restrictions
7383 @unnumberedsec D.7(21): Tasking Restrictions
7386 When feasible, the implementation should take advantage of the specified
7387 restrictions to produce a more efficient implementation.
7389 GNAT currently takes advantage of these restrictions by providing an optimized
7390 run time when the Ravenscar profile and the GNAT restricted run time set
7391 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
7392 pragma @code{Profile (Restricted)} for more details.
7394 @cindex Time, monotonic
7395 @unnumberedsec D.8(47-49): Monotonic Time
7398 When appropriate, implementations should provide configuration
7399 mechanisms to change the value of @code{Tick}.
7401 Such configuration mechanisms are not appropriate to this implementation
7402 and are thus not supported.
7406 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7407 be implemented as transformations of the same time base.
7413 It is recommended that the @dfn{best} time base which exists in
7414 the underlying system be available to the application through
7415 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
7419 @cindex Partition communication subsystem
7421 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7424 Whenever possible, the PCS on the called partition should allow for
7425 multiple tasks to call the RPC-receiver with different messages and
7426 should allow them to block until the corresponding subprogram body
7429 Followed by GLADE, a separately supplied PCS that can be used with
7434 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7435 should raise @code{Storage_Error} if it runs out of space trying to
7436 write the @code{Item} into the stream.
7438 Followed by GLADE, a separately supplied PCS that can be used with
7441 @cindex COBOL support
7442 @unnumberedsec F(7): COBOL Support
7445 If COBOL (respectively, C) is widely supported in the target
7446 environment, implementations supporting the Information Systems Annex
7447 should provide the child package @code{Interfaces.COBOL} (respectively,
7448 @code{Interfaces.C}) specified in Annex B and should support a
7449 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7450 pragmas (see Annex B), thus allowing Ada programs to interface with
7451 programs written in that language.
7455 @cindex Decimal radix support
7456 @unnumberedsec F.1(2): Decimal Radix Support
7459 Packed decimal should be used as the internal representation for objects
7460 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7462 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
7466 @unnumberedsec G: Numerics
7469 If Fortran (respectively, C) is widely supported in the target
7470 environment, implementations supporting the Numerics Annex
7471 should provide the child package @code{Interfaces.Fortran} (respectively,
7472 @code{Interfaces.C}) specified in Annex B and should support a
7473 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7474 pragmas (see Annex B), thus allowing Ada programs to interface with
7475 programs written in that language.
7479 @cindex Complex types
7480 @unnumberedsec G.1.1(56-58): Complex Types
7483 Because the usual mathematical meaning of multiplication of a complex
7484 operand and a real operand is that of the scaling of both components of
7485 the former by the latter, an implementation should not perform this
7486 operation by first promoting the real operand to complex type and then
7487 performing a full complex multiplication. In systems that, in the
7488 future, support an Ada binding to IEC 559:1989, the latter technique
7489 will not generate the required result when one of the components of the
7490 complex operand is infinite. (Explicit multiplication of the infinite
7491 component by the zero component obtained during promotion yields a NaN
7492 that propagates into the final result.) Analogous advice applies in the
7493 case of multiplication of a complex operand and a pure-imaginary
7494 operand, and in the case of division of a complex operand by a real or
7495 pure-imaginary operand.
7501 Similarly, because the usual mathematical meaning of addition of a
7502 complex operand and a real operand is that the imaginary operand remains
7503 unchanged, an implementation should not perform this operation by first
7504 promoting the real operand to complex type and then performing a full
7505 complex addition. In implementations in which the @code{Signed_Zeros}
7506 attribute of the component type is @code{True} (and which therefore
7507 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7508 predefined arithmetic operations), the latter technique will not
7509 generate the required result when the imaginary component of the complex
7510 operand is a negatively signed zero. (Explicit addition of the negative
7511 zero to the zero obtained during promotion yields a positive zero.)
7512 Analogous advice applies in the case of addition of a complex operand
7513 and a pure-imaginary operand, and in the case of subtraction of a
7514 complex operand and a real or pure-imaginary operand.
7520 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7521 attempt to provide a rational treatment of the signs of zero results and
7522 result components. As one example, the result of the @code{Argument}
7523 function should have the sign of the imaginary component of the
7524 parameter @code{X} when the point represented by that parameter lies on
7525 the positive real axis; as another, the sign of the imaginary component
7526 of the @code{Compose_From_Polar} function should be the same as
7527 (respectively, the opposite of) that of the @code{Argument} parameter when that
7528 parameter has a value of zero and the @code{Modulus} parameter has a
7529 nonnegative (respectively, negative) value.
7533 @cindex Complex elementary functions
7534 @unnumberedsec G.1.2(49): Complex Elementary Functions
7537 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7538 @code{True} should attempt to provide a rational treatment of the signs
7539 of zero results and result components. For example, many of the complex
7540 elementary functions have components that are odd functions of one of
7541 the parameter components; in these cases, the result component should
7542 have the sign of the parameter component at the origin. Other complex
7543 elementary functions have zero components whose sign is opposite that of
7544 a parameter component at the origin, or is always positive or always
7549 @cindex Accuracy requirements
7550 @unnumberedsec G.2.4(19): Accuracy Requirements
7553 The versions of the forward trigonometric functions without a
7554 @code{Cycle} parameter should not be implemented by calling the
7555 corresponding version with a @code{Cycle} parameter of
7556 @code{2.0*Numerics.Pi}, since this will not provide the required
7557 accuracy in some portions of the domain. For the same reason, the
7558 version of @code{Log} without a @code{Base} parameter should not be
7559 implemented by calling the corresponding version with a @code{Base}
7560 parameter of @code{Numerics.e}.
7564 @cindex Complex arithmetic accuracy
7565 @cindex Accuracy, complex arithmetic
7566 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7570 The version of the @code{Compose_From_Polar} function without a
7571 @code{Cycle} parameter should not be implemented by calling the
7572 corresponding version with a @code{Cycle} parameter of
7573 @code{2.0*Numerics.Pi}, since this will not provide the required
7574 accuracy in some portions of the domain.
7578 @c -----------------------------------------
7579 @node Implementation Defined Characteristics
7580 @chapter Implementation Defined Characteristics
7583 In addition to the implementation dependent pragmas and attributes, and
7584 the implementation advice, there are a number of other Ada features
7585 that are potentially implementation dependent. These are mentioned
7586 throughout the Ada Reference Manual, and are summarized in annex M@.
7588 A requirement for conforming Ada compilers is that they provide
7589 documentation describing how the implementation deals with each of these
7590 issues. In this chapter, you will find each point in annex M listed
7591 followed by a description in italic font of how GNAT
7595 implementation on IRIX 5.3 operating system or greater
7597 handles the implementation dependence.
7599 You can use this chapter as a guide to minimizing implementation
7600 dependent features in your programs if portability to other compilers
7601 and other operating systems is an important consideration. The numbers
7602 in each section below correspond to the paragraph number in the Ada
7608 @strong{2}. Whether or not each recommendation given in Implementation
7609 Advice is followed. See 1.1.2(37).
7612 @xref{Implementation Advice}.
7617 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
7620 The complexity of programs that can be processed is limited only by the
7621 total amount of available virtual memory, and disk space for the
7622 generated object files.
7627 @strong{4}. Variations from the standard that are impractical to avoid
7628 given the implementation's execution environment. See 1.1.3(6).
7631 There are no variations from the standard.
7636 @strong{5}. Which @code{code_statement}s cause external
7637 interactions. See 1.1.3(10).
7640 Any @code{code_statement} can potentially cause external interactions.
7645 @strong{6}. The coded representation for the text of an Ada
7646 program. See 2.1(4).
7649 See separate section on source representation.
7654 @strong{7}. The control functions allowed in comments. See 2.1(14).
7657 See separate section on source representation.
7662 @strong{8}. The representation for an end of line. See 2.2(2).
7665 See separate section on source representation.
7670 @strong{9}. Maximum supported line length and lexical element
7671 length. See 2.2(15).
7674 The maximum line length is 255 characters and the maximum length of a
7675 lexical element is also 255 characters.
7680 @strong{10}. Implementation defined pragmas. See 2.8(14).
7684 @xref{Implementation Defined Pragmas}.
7689 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
7692 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7693 parameter, checks that the optimization flag is set, and aborts if it is
7699 @strong{12}. The sequence of characters of the value returned by
7700 @code{@var{S}'Image} when some of the graphic characters of
7701 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
7705 The sequence of characters is as defined by the wide character encoding
7706 method used for the source. See section on source representation for
7712 @strong{13}. The predefined integer types declared in
7713 @code{Standard}. See 3.5.4(25).
7717 @item Short_Short_Integer
7720 (Short) 16 bit signed
7724 64 bit signed (Alpha OpenVMS only)
7725 32 bit signed (all other targets)
7726 @item Long_Long_Integer
7733 @strong{14}. Any nonstandard integer types and the operators defined
7734 for them. See 3.5.4(26).
7737 There are no nonstandard integer types.
7742 @strong{15}. Any nonstandard real types and the operators defined for
7746 There are no nonstandard real types.
7751 @strong{16}. What combinations of requested decimal precision and range
7752 are supported for floating point types. See 3.5.7(7).
7755 The precision and range is as defined by the IEEE standard.
7760 @strong{17}. The predefined floating point types declared in
7761 @code{Standard}. See 3.5.7(16).
7768 (Short) 32 bit IEEE short
7771 @item Long_Long_Float
7772 64 bit IEEE long (80 bit IEEE long on x86 processors)
7778 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
7781 @code{Fine_Delta} is 2**(@minus{}63)
7786 @strong{19}. What combinations of small, range, and digits are
7787 supported for fixed point types. See 3.5.9(10).
7790 Any combinations are permitted that do not result in a small less than
7791 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7792 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7793 is 64 bits (true of all architectures except ia32), then the output from
7794 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
7795 is because floating-point conversions are used to convert fixed point.
7800 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
7801 within an unnamed @code{block_statement}. See 3.9(10).
7804 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7805 decimal integer are allocated.
7810 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
7813 @xref{Implementation Defined Attributes}.
7818 @strong{22}. Any implementation-defined time types. See 9.6(6).
7821 There are no implementation-defined time types.
7826 @strong{23}. The time base associated with relative delays.
7829 See 9.6(20). The time base used is that provided by the C library
7830 function @code{gettimeofday}.
7835 @strong{24}. The time base of the type @code{Calendar.Time}. See
7839 The time base used is that provided by the C library function
7840 @code{gettimeofday}.
7845 @strong{25}. The time zone used for package @code{Calendar}
7846 operations. See 9.6(24).
7849 The time zone used by package @code{Calendar} is the current system time zone
7850 setting for local time, as accessed by the C library function
7856 @strong{26}. Any limit on @code{delay_until_statements} of
7857 @code{select_statements}. See 9.6(29).
7860 There are no such limits.
7865 @strong{27}. Whether or not two non-overlapping parts of a composite
7866 object are independently addressable, in the case where packing, record
7867 layout, or @code{Component_Size} is specified for the object. See
7871 Separate components are independently addressable if they do not share
7872 overlapping storage units.
7877 @strong{28}. The representation for a compilation. See 10.1(2).
7880 A compilation is represented by a sequence of files presented to the
7881 compiler in a single invocation of the @command{gcc} command.
7886 @strong{29}. Any restrictions on compilations that contain multiple
7887 compilation_units. See 10.1(4).
7890 No single file can contain more than one compilation unit, but any
7891 sequence of files can be presented to the compiler as a single
7897 @strong{30}. The mechanisms for creating an environment and for adding
7898 and replacing compilation units. See 10.1.4(3).
7901 See separate section on compilation model.
7906 @strong{31}. The manner of explicitly assigning library units to a
7907 partition. See 10.2(2).
7910 If a unit contains an Ada main program, then the Ada units for the partition
7911 are determined by recursive application of the rules in the Ada Reference
7912 Manual section 10.2(2-6). In other words, the Ada units will be those that
7913 are needed by the main program, and then this definition of need is applied
7914 recursively to those units, and the partition contains the transitive
7915 closure determined by this relationship. In short, all the necessary units
7916 are included, with no need to explicitly specify the list. If additional
7917 units are required, e.g.@: by foreign language units, then all units must be
7918 mentioned in the context clause of one of the needed Ada units.
7920 If the partition contains no main program, or if the main program is in
7921 a language other than Ada, then GNAT
7922 provides the binder options @option{-z} and @option{-n} respectively, and in
7923 this case a list of units can be explicitly supplied to the binder for
7924 inclusion in the partition (all units needed by these units will also
7925 be included automatically). For full details on the use of these
7926 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
7927 @value{EDITION} User's Guide}.
7932 @strong{32}. The implementation-defined means, if any, of specifying
7933 which compilation units are needed by a given compilation unit. See
7937 The units needed by a given compilation unit are as defined in
7938 the Ada Reference Manual section 10.2(2-6). There are no
7939 implementation-defined pragmas or other implementation-defined
7940 means for specifying needed units.
7945 @strong{33}. The manner of designating the main subprogram of a
7946 partition. See 10.2(7).
7949 The main program is designated by providing the name of the
7950 corresponding @file{ALI} file as the input parameter to the binder.
7955 @strong{34}. The order of elaboration of @code{library_items}. See
7959 The first constraint on ordering is that it meets the requirements of
7960 Chapter 10 of the Ada Reference Manual. This still leaves some
7961 implementation dependent choices, which are resolved by first
7962 elaborating bodies as early as possible (i.e., in preference to specs
7963 where there is a choice), and second by evaluating the immediate with
7964 clauses of a unit to determine the probably best choice, and
7965 third by elaborating in alphabetical order of unit names
7966 where a choice still remains.
7971 @strong{35}. Parameter passing and function return for the main
7972 subprogram. See 10.2(21).
7975 The main program has no parameters. It may be a procedure, or a function
7976 returning an integer type. In the latter case, the returned integer
7977 value is the return code of the program (overriding any value that
7978 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
7983 @strong{36}. The mechanisms for building and running partitions. See
7987 GNAT itself supports programs with only a single partition. The GNATDIST
7988 tool provided with the GLADE package (which also includes an implementation
7989 of the PCS) provides a completely flexible method for building and running
7990 programs consisting of multiple partitions. See the separate GLADE manual
7996 @strong{37}. The details of program execution, including program
7997 termination. See 10.2(25).
8000 See separate section on compilation model.
8005 @strong{38}. The semantics of any non-active partitions supported by the
8006 implementation. See 10.2(28).
8009 Passive partitions are supported on targets where shared memory is
8010 provided by the operating system. See the GLADE reference manual for
8016 @strong{39}. The information returned by @code{Exception_Message}. See
8020 Exception message returns the null string unless a specific message has
8021 been passed by the program.
8026 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
8027 declared within an unnamed @code{block_statement}. See 11.4.1(12).
8030 Blocks have implementation defined names of the form @code{B@var{nnn}}
8031 where @var{nnn} is an integer.
8036 @strong{41}. The information returned by
8037 @code{Exception_Information}. See 11.4.1(13).
8040 @code{Exception_Information} returns a string in the following format:
8043 @emph{Exception_Name:} nnnnn
8044 @emph{Message:} mmmmm
8046 @emph{Call stack traceback locations:}
8047 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8055 @code{nnnn} is the fully qualified name of the exception in all upper
8056 case letters. This line is always present.
8059 @code{mmmm} is the message (this line present only if message is non-null)
8062 @code{ppp} is the Process Id value as a decimal integer (this line is
8063 present only if the Process Id is nonzero). Currently we are
8064 not making use of this field.
8067 The Call stack traceback locations line and the following values
8068 are present only if at least one traceback location was recorded.
8069 The values are given in C style format, with lower case letters
8070 for a-f, and only as many digits present as are necessary.
8074 The line terminator sequence at the end of each line, including
8075 the last line is a single @code{LF} character (@code{16#0A#}).
8080 @strong{42}. Implementation-defined check names. See 11.5(27).
8083 The implementation defined check name Alignment_Check controls checking of
8084 address clause values for proper alignment (that is, the address supplied
8085 must be consistent with the alignment of the type).
8087 In addition, a user program can add implementation-defined check names
8088 by means of the pragma Check_Name.
8093 @strong{43}. The interpretation of each aspect of representation. See
8097 See separate section on data representations.
8102 @strong{44}. Any restrictions placed upon representation items. See
8106 See separate section on data representations.
8111 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
8115 Size for an indefinite subtype is the maximum possible size, except that
8116 for the case of a subprogram parameter, the size of the parameter object
8122 @strong{46}. The default external representation for a type tag. See
8126 The default external representation for a type tag is the fully expanded
8127 name of the type in upper case letters.
8132 @strong{47}. What determines whether a compilation unit is the same in
8133 two different partitions. See 13.3(76).
8136 A compilation unit is the same in two different partitions if and only
8137 if it derives from the same source file.
8142 @strong{48}. Implementation-defined components. See 13.5.1(15).
8145 The only implementation defined component is the tag for a tagged type,
8146 which contains a pointer to the dispatching table.
8151 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
8152 ordering. See 13.5.3(5).
8155 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8156 implementation, so no non-default bit ordering is supported. The default
8157 bit ordering corresponds to the natural endianness of the target architecture.
8162 @strong{50}. The contents of the visible part of package @code{System}
8163 and its language-defined children. See 13.7(2).
8166 See the definition of these packages in files @file{system.ads} and
8167 @file{s-stoele.ads}.
8172 @strong{51}. The contents of the visible part of package
8173 @code{System.Machine_Code}, and the meaning of
8174 @code{code_statements}. See 13.8(7).
8177 See the definition and documentation in file @file{s-maccod.ads}.
8182 @strong{52}. The effect of unchecked conversion. See 13.9(11).
8185 Unchecked conversion between types of the same size
8186 results in an uninterpreted transmission of the bits from one type
8187 to the other. If the types are of unequal sizes, then in the case of
8188 discrete types, a shorter source is first zero or sign extended as
8189 necessary, and a shorter target is simply truncated on the left.
8190 For all non-discrete types, the source is first copied if necessary
8191 to ensure that the alignment requirements of the target are met, then
8192 a pointer is constructed to the source value, and the result is obtained
8193 by dereferencing this pointer after converting it to be a pointer to the
8194 target type. Unchecked conversions where the target subtype is an
8195 unconstrained array are not permitted. If the target alignment is
8196 greater than the source alignment, then a copy of the result is
8197 made with appropriate alignment
8202 @strong{53}. The manner of choosing a storage pool for an access type
8203 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
8206 There are 3 different standard pools used by the compiler when
8207 @code{Storage_Pool} is not specified depending whether the type is local
8208 to a subprogram or defined at the library level and whether
8209 @code{Storage_Size}is specified or not. See documentation in the runtime
8210 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8211 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8212 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8218 @strong{54}. Whether or not the implementation provides user-accessible
8219 names for the standard pool type(s). See 13.11(17).
8223 See documentation in the sources of the run time mentioned in paragraph
8224 @strong{53} . All these pools are accessible by means of @code{with}'ing
8230 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
8233 @code{Storage_Size} is measured in storage units, and refers to the
8234 total space available for an access type collection, or to the primary
8235 stack space for a task.
8240 @strong{56}. Implementation-defined aspects of storage pools. See
8244 See documentation in the sources of the run time mentioned in paragraph
8245 @strong{53} for details on GNAT-defined aspects of storage pools.
8250 @strong{57}. The set of restrictions allowed in a pragma
8251 @code{Restrictions}. See 13.12(7).
8254 All RM defined Restriction identifiers are implemented. The following
8255 additional restriction identifiers are provided. There are two separate
8256 lists of implementation dependent restriction identifiers. The first
8257 set requires consistency throughout a partition (in other words, if the
8258 restriction identifier is used for any compilation unit in the partition,
8259 then all compilation units in the partition must obey the restriction.
8263 @item Simple_Barriers
8264 @findex Simple_Barriers
8265 This restriction ensures at compile time that barriers in entry declarations
8266 for protected types are restricted to either static boolean expressions or
8267 references to simple boolean variables defined in the private part of the
8268 protected type. No other form of entry barriers is permitted. This is one
8269 of the restrictions of the Ravenscar profile for limited tasking (see also
8270 pragma @code{Profile (Ravenscar)}).
8272 @item Max_Entry_Queue_Length => Expr
8273 @findex Max_Entry_Queue_Length
8274 This restriction is a declaration that any protected entry compiled in
8275 the scope of the restriction has at most the specified number of
8276 tasks waiting on the entry
8277 at any one time, and so no queue is required. This restriction is not
8278 checked at compile time. A program execution is erroneous if an attempt
8279 is made to queue more than the specified number of tasks on such an entry.
8283 This restriction ensures at compile time that there is no implicit or
8284 explicit dependence on the package @code{Ada.Calendar}.
8286 @item No_Default_Initialization
8287 @findex No_Default_Initialization
8289 This restriction prohibits any instance of default initialization of variables.
8290 The binder implements a consistency rule which prevents any unit compiled
8291 without the restriction from with'ing a unit with the restriction (this allows
8292 the generation of initialization procedures to be skipped, since you can be
8293 sure that no call is ever generated to an initialization procedure in a unit
8294 with the restriction active). If used in conjunction with Initialize_Scalars or
8295 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8296 without a specific initializer (including the case of OUT scalar parameters).
8298 @item No_Direct_Boolean_Operators
8299 @findex No_Direct_Boolean_Operators
8300 This restriction ensures that no logical (and/or/xor) or comparison
8301 operators are used on operands of type Boolean (or any type derived
8302 from Boolean). This is intended for use in safety critical programs
8303 where the certification protocol requires the use of short-circuit
8304 (and then, or else) forms for all composite boolean operations.
8306 @item No_Dispatching_Calls
8307 @findex No_Dispatching_Calls
8308 This restriction ensures at compile time that the code generated by the
8309 compiler involves no dispatching calls. The use of this restriction allows the
8310 safe use of record extensions, classwide membership tests and other classwide
8311 features not involving implicit dispatching. This restriction ensures that
8312 the code contains no indirect calls through a dispatching mechanism. Note that
8313 this includes internally-generated calls created by the compiler, for example
8314 in the implementation of class-wide objects assignments. The
8315 membership test is allowed in the presence of this restriction, because its
8316 implementation requires no dispatching.
8317 This restriction is comparable to the official Ada restriction
8318 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8319 all classwide constructs that do not imply dispatching.
8320 The following example indicates constructs that violate this restriction.
8324 type T is tagged record
8327 procedure P (X : T);
8329 type DT is new T with record
8330 More_Data : Natural;
8332 procedure Q (X : DT);
8336 procedure Example is
8337 procedure Test (O : T'Class) is
8338 N : Natural := O'Size;-- Error: Dispatching call
8339 C : T'Class := O; -- Error: implicit Dispatching Call
8341 if O in DT'Class then -- OK : Membership test
8342 Q (DT (O)); -- OK : Type conversion plus direct call
8344 P (O); -- Error: Dispatching call
8350 P (Obj); -- OK : Direct call
8351 P (T (Obj)); -- OK : Type conversion plus direct call
8352 P (T'Class (Obj)); -- Error: Dispatching call
8354 Test (Obj); -- OK : Type conversion
8356 if Obj in T'Class then -- OK : Membership test
8362 @item No_Dynamic_Attachment
8363 @findex No_Dynamic_Attachment
8364 This restriction ensures that there is no call to any of the operations
8365 defined in package Ada.Interrupts.
8367 @item No_Enumeration_Maps
8368 @findex No_Enumeration_Maps
8369 This restriction ensures at compile time that no operations requiring
8370 enumeration maps are used (that is Image and Value attributes applied
8371 to enumeration types).
8373 @item No_Entry_Calls_In_Elaboration_Code
8374 @findex No_Entry_Calls_In_Elaboration_Code
8375 This restriction ensures at compile time that no task or protected entry
8376 calls are made during elaboration code. As a result of the use of this
8377 restriction, the compiler can assume that no code past an accept statement
8378 in a task can be executed at elaboration time.
8380 @item No_Exception_Handlers
8381 @findex No_Exception_Handlers
8382 This restriction ensures at compile time that there are no explicit
8383 exception handlers. It also indicates that no exception propagation will
8384 be provided. In this mode, exceptions may be raised but will result in
8385 an immediate call to the last chance handler, a routine that the user
8386 must define with the following profile:
8388 @smallexample @c ada
8389 procedure Last_Chance_Handler
8390 (Source_Location : System.Address; Line : Integer);
8391 pragma Export (C, Last_Chance_Handler,
8392 "__gnat_last_chance_handler");
8395 The parameter is a C null-terminated string representing a message to be
8396 associated with the exception (typically the source location of the raise
8397 statement generated by the compiler). The Line parameter when nonzero
8398 represents the line number in the source program where the raise occurs.
8400 @item No_Exception_Propagation
8401 @findex No_Exception_Propagation
8402 This restriction guarantees that exceptions are never propagated to an outer
8403 subprogram scope). The only case in which an exception may be raised is when
8404 the handler is statically in the same subprogram, so that the effect of a raise
8405 is essentially like a goto statement. Any other raise statement (implicit or
8406 explicit) will be considered unhandled. Exception handlers are allowed, but may
8407 not contain an exception occurrence identifier (exception choice). In addition
8408 use of the package GNAT.Current_Exception is not permitted, and reraise
8409 statements (raise with no operand) are not permitted.
8411 @item No_Exception_Registration
8412 @findex No_Exception_Registration
8413 This restriction ensures at compile time that no stream operations for
8414 types Exception_Id or Exception_Occurrence are used. This also makes it
8415 impossible to pass exceptions to or from a partition with this restriction
8416 in a distributed environment. If this exception is active, then the generated
8417 code is simplified by omitting the otherwise-required global registration
8418 of exceptions when they are declared.
8420 @item No_Implicit_Conditionals
8421 @findex No_Implicit_Conditionals
8422 This restriction ensures that the generated code does not contain any
8423 implicit conditionals, either by modifying the generated code where possible,
8424 or by rejecting any construct that would otherwise generate an implicit
8425 conditional. Note that this check does not include run time constraint
8426 checks, which on some targets may generate implicit conditionals as
8427 well. To control the latter, constraint checks can be suppressed in the
8428 normal manner. Constructs generating implicit conditionals include comparisons
8429 of composite objects and the Max/Min attributes.
8431 @item No_Implicit_Dynamic_Code
8432 @findex No_Implicit_Dynamic_Code
8434 This restriction prevents the compiler from building ``trampolines''.
8435 This is a structure that is built on the stack and contains dynamic
8436 code to be executed at run time. On some targets, a trampoline is
8437 built for the following features: @code{Access},
8438 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8439 nested task bodies; primitive operations of nested tagged types.
8440 Trampolines do not work on machines that prevent execution of stack
8441 data. For example, on windows systems, enabling DEP (data execution
8442 protection) will cause trampolines to raise an exception.
8443 Trampolines are also quite slow at run time.
8445 On many targets, trampolines have been largely eliminated. Look at the
8446 version of system.ads for your target --- if it has
8447 Always_Compatible_Rep equal to False, then trampolines are largely
8448 eliminated. In particular, a trampoline is built for the following
8449 features: @code{Address} of a nested subprogram;
8450 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8451 but only if pragma Favor_Top_Level applies, or the access type has a
8452 foreign-language convention; primitive operations of nested tagged
8455 @item No_Implicit_Loops
8456 @findex No_Implicit_Loops
8457 This restriction ensures that the generated code does not contain any
8458 implicit @code{for} loops, either by modifying
8459 the generated code where possible,
8460 or by rejecting any construct that would otherwise generate an implicit
8461 @code{for} loop. If this restriction is active, it is possible to build
8462 large array aggregates with all static components without generating an
8463 intermediate temporary, and without generating a loop to initialize individual
8464 components. Otherwise, a loop is created for arrays larger than about 5000
8467 @item No_Initialize_Scalars
8468 @findex No_Initialize_Scalars
8469 This restriction ensures that no unit in the partition is compiled with
8470 pragma Initialize_Scalars. This allows the generation of more efficient
8471 code, and in particular eliminates dummy null initialization routines that
8472 are otherwise generated for some record and array types.
8474 @item No_Local_Protected_Objects
8475 @findex No_Local_Protected_Objects
8476 This restriction ensures at compile time that protected objects are
8477 only declared at the library level.
8479 @item No_Protected_Type_Allocators
8480 @findex No_Protected_Type_Allocators
8481 This restriction ensures at compile time that there are no allocator
8482 expressions that attempt to allocate protected objects.
8484 @item No_Secondary_Stack
8485 @findex No_Secondary_Stack
8486 This restriction ensures at compile time that the generated code does not
8487 contain any reference to the secondary stack. The secondary stack is used
8488 to implement functions returning unconstrained objects (arrays or records)
8491 @item No_Select_Statements
8492 @findex No_Select_Statements
8493 This restriction ensures at compile time no select statements of any kind
8494 are permitted, that is the keyword @code{select} may not appear.
8495 This is one of the restrictions of the Ravenscar
8496 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8498 @item No_Standard_Storage_Pools
8499 @findex No_Standard_Storage_Pools
8500 This restriction ensures at compile time that no access types
8501 use the standard default storage pool. Any access type declared must
8502 have an explicit Storage_Pool attribute defined specifying a
8503 user-defined storage pool.
8507 This restriction ensures at compile/bind time that there are no
8508 stream objects created (and therefore no actual stream operations).
8509 This restriction does not forbid dependences on the package
8510 @code{Ada.Streams}. So it is permissible to with
8511 @code{Ada.Streams} (or another package that does so itself)
8512 as long as no actual stream objects are created.
8514 @item No_Task_Attributes_Package
8515 @findex No_Task_Attributes_Package
8516 This restriction ensures at compile time that there are no implicit or
8517 explicit dependencies on the package @code{Ada.Task_Attributes}.
8519 @item No_Task_Termination
8520 @findex No_Task_Termination
8521 This restriction ensures at compile time that no terminate alternatives
8522 appear in any task body.
8526 This restriction prevents the declaration of tasks or task types throughout
8527 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
8528 except that violations are caught at compile time and cause an error message
8529 to be output either by the compiler or binder.
8531 @item Static_Priorities
8532 @findex Static_Priorities
8533 This restriction ensures at compile time that all priority expressions
8534 are static, and that there are no dependencies on the package
8535 @code{Ada.Dynamic_Priorities}.
8537 @item Static_Storage_Size
8538 @findex Static_Storage_Size
8539 This restriction ensures at compile time that any expression appearing
8540 in a Storage_Size pragma or attribute definition clause is static.
8545 The second set of implementation dependent restriction identifiers
8546 does not require partition-wide consistency.
8547 The restriction may be enforced for a single
8548 compilation unit without any effect on any of the
8549 other compilation units in the partition.
8553 @item No_Elaboration_Code
8554 @findex No_Elaboration_Code
8555 This restriction ensures at compile time that no elaboration code is
8556 generated. Note that this is not the same condition as is enforced
8557 by pragma @code{Preelaborate}. There are cases in which pragma
8558 @code{Preelaborate} still permits code to be generated (e.g.@: code
8559 to initialize a large array to all zeroes), and there are cases of units
8560 which do not meet the requirements for pragma @code{Preelaborate},
8561 but for which no elaboration code is generated. Generally, it is
8562 the case that preelaborable units will meet the restrictions, with
8563 the exception of large aggregates initialized with an others_clause,
8564 and exception declarations (which generate calls to a run-time
8565 registry procedure). This restriction is enforced on
8566 a unit by unit basis, it need not be obeyed consistently
8567 throughout a partition.
8569 In the case of aggregates with others, if the aggregate has a dynamic
8570 size, there is no way to eliminate the elaboration code (such dynamic
8571 bounds would be incompatible with @code{Preelaborate} in any case). If
8572 the bounds are static, then use of this restriction actually modifies
8573 the code choice of the compiler to avoid generating a loop, and instead
8574 generate the aggregate statically if possible, no matter how many times
8575 the data for the others clause must be repeatedly generated.
8577 It is not possible to precisely document
8578 the constructs which are compatible with this restriction, since,
8579 unlike most other restrictions, this is not a restriction on the
8580 source code, but a restriction on the generated object code. For
8581 example, if the source contains a declaration:
8584 Val : constant Integer := X;
8588 where X is not a static constant, it may be possible, depending
8589 on complex optimization circuitry, for the compiler to figure
8590 out the value of X at compile time, in which case this initialization
8591 can be done by the loader, and requires no initialization code. It
8592 is not possible to document the precise conditions under which the
8593 optimizer can figure this out.
8595 Note that this the implementation of this restriction requires full
8596 code generation. If it is used in conjunction with "semantics only"
8597 checking, then some cases of violations may be missed.
8599 @item No_Entry_Queue
8600 @findex No_Entry_Queue
8601 This restriction is a declaration that any protected entry compiled in
8602 the scope of the restriction has at most one task waiting on the entry
8603 at any one time, and so no queue is required. This restriction is not
8604 checked at compile time. A program execution is erroneous if an attempt
8605 is made to queue a second task on such an entry.
8607 @item No_Implementation_Attributes
8608 @findex No_Implementation_Attributes
8609 This restriction checks at compile time that no GNAT-defined attributes
8610 are present. With this restriction, the only attributes that can be used
8611 are those defined in the Ada Reference Manual.
8613 @item No_Implementation_Pragmas
8614 @findex No_Implementation_Pragmas
8615 This restriction checks at compile time that no GNAT-defined pragmas
8616 are present. With this restriction, the only pragmas that can be used
8617 are those defined in the Ada Reference Manual.
8619 @item No_Implementation_Restrictions
8620 @findex No_Implementation_Restrictions
8621 This restriction checks at compile time that no GNAT-defined restriction
8622 identifiers (other than @code{No_Implementation_Restrictions} itself)
8623 are present. With this restriction, the only other restriction identifiers
8624 that can be used are those defined in the Ada Reference Manual.
8626 @item No_Wide_Characters
8627 @findex No_Wide_Characters
8628 This restriction ensures at compile time that no uses of the types
8629 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8631 appear, and that no wide or wide wide string or character literals
8632 appear in the program (that is literals representing characters not in
8633 type @code{Character}.
8640 @strong{58}. The consequences of violating limitations on
8641 @code{Restrictions} pragmas. See 13.12(9).
8644 Restrictions that can be checked at compile time result in illegalities
8645 if violated. Currently there are no other consequences of violating
8651 @strong{59}. The representation used by the @code{Read} and
8652 @code{Write} attributes of elementary types in terms of stream
8653 elements. See 13.13.2(9).
8656 The representation is the in-memory representation of the base type of
8657 the type, using the number of bits corresponding to the
8658 @code{@var{type}'Size} value, and the natural ordering of the machine.
8663 @strong{60}. The names and characteristics of the numeric subtypes
8664 declared in the visible part of package @code{Standard}. See A.1(3).
8667 See items describing the integer and floating-point types supported.
8672 @strong{61}. The accuracy actually achieved by the elementary
8673 functions. See A.5.1(1).
8676 The elementary functions correspond to the functions available in the C
8677 library. Only fast math mode is implemented.
8682 @strong{62}. The sign of a zero result from some of the operators or
8683 functions in @code{Numerics.Generic_Elementary_Functions}, when
8684 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
8687 The sign of zeroes follows the requirements of the IEEE 754 standard on
8693 @strong{63}. The value of
8694 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
8697 Maximum image width is 649, see library file @file{a-numran.ads}.
8702 @strong{64}. The value of
8703 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
8706 Maximum image width is 80, see library file @file{a-nudira.ads}.
8711 @strong{65}. The algorithms for random number generation. See
8715 The algorithm is documented in the source files @file{a-numran.ads} and
8716 @file{a-numran.adb}.
8721 @strong{66}. The string representation of a random number generator's
8722 state. See A.5.2(38).
8725 See the documentation contained in the file @file{a-numran.adb}.
8730 @strong{67}. The minimum time interval between calls to the
8731 time-dependent Reset procedure that are guaranteed to initiate different
8732 random number sequences. See A.5.2(45).
8735 The minimum period between reset calls to guarantee distinct series of
8736 random numbers is one microsecond.
8741 @strong{68}. The values of the @code{Model_Mantissa},
8742 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8743 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8744 Annex is not supported. See A.5.3(72).
8747 See the source file @file{ttypef.ads} for the values of all numeric
8753 @strong{69}. Any implementation-defined characteristics of the
8754 input-output packages. See A.7(14).
8757 There are no special implementation defined characteristics for these
8763 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
8767 All type representations are contiguous, and the @code{Buffer_Size} is
8768 the value of @code{@var{type}'Size} rounded up to the next storage unit
8774 @strong{71}. External files for standard input, standard output, and
8775 standard error See A.10(5).
8778 These files are mapped onto the files provided by the C streams
8779 libraries. See source file @file{i-cstrea.ads} for further details.
8784 @strong{72}. The accuracy of the value produced by @code{Put}. See
8788 If more digits are requested in the output than are represented by the
8789 precision of the value, zeroes are output in the corresponding least
8790 significant digit positions.
8795 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
8796 @code{Command_Name}. See A.15(1).
8799 These are mapped onto the @code{argv} and @code{argc} parameters of the
8800 main program in the natural manner.
8805 @strong{74}. Implementation-defined convention names. See B.1(11).
8808 The following convention names are supported
8816 Synonym for Assembler
8818 Synonym for Assembler
8821 @item C_Pass_By_Copy
8822 Allowed only for record types, like C, but also notes that record
8823 is to be passed by copy rather than reference.
8826 @item C_Plus_Plus (or CPP)
8829 Treated the same as C
8831 Treated the same as C
8835 For support of pragma @code{Import} with convention Intrinsic, see
8836 separate section on Intrinsic Subprograms.
8838 Stdcall (used for Windows implementations only). This convention correspond
8839 to the WINAPI (previously called Pascal convention) C/C++ convention under
8840 Windows. A function with this convention cleans the stack before exit.
8846 Stubbed is a special convention used to indicate that the body of the
8847 subprogram will be entirely ignored. Any call to the subprogram
8848 is converted into a raise of the @code{Program_Error} exception. If a
8849 pragma @code{Import} specifies convention @code{stubbed} then no body need
8850 be present at all. This convention is useful during development for the
8851 inclusion of subprograms whose body has not yet been written.
8855 In addition, all otherwise unrecognized convention names are also
8856 treated as being synonymous with convention C@. In all implementations
8857 except for VMS, use of such other names results in a warning. In VMS
8858 implementations, these names are accepted silently.
8863 @strong{75}. The meaning of link names. See B.1(36).
8866 Link names are the actual names used by the linker.
8871 @strong{76}. The manner of choosing link names when neither the link
8872 name nor the address of an imported or exported entity is specified. See
8876 The default linker name is that which would be assigned by the relevant
8877 external language, interpreting the Ada name as being in all lower case
8883 @strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37).
8886 The string passed to @code{Linker_Options} is presented uninterpreted as
8887 an argument to the link command, unless it contains ASCII.NUL characters.
8888 NUL characters if they appear act as argument separators, so for example
8890 @smallexample @c ada
8891 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
8895 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8896 linker. The order of linker options is preserved for a given unit. The final
8897 list of options passed to the linker is in reverse order of the elaboration
8898 order. For example, linker options for a body always appear before the options
8899 from the corresponding package spec.
8904 @strong{78}. The contents of the visible part of package
8905 @code{Interfaces} and its language-defined descendants. See B.2(1).
8908 See files with prefix @file{i-} in the distributed library.
8913 @strong{79}. Implementation-defined children of package
8914 @code{Interfaces}. The contents of the visible part of package
8915 @code{Interfaces}. See B.2(11).
8918 See files with prefix @file{i-} in the distributed library.
8923 @strong{80}. The types @code{Floating}, @code{Long_Floating},
8924 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
8925 @code{COBOL_Character}; and the initialization of the variables
8926 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
8927 @code{Interfaces.COBOL}. See B.4(50).
8934 (Floating) Long_Float
8939 @item Decimal_Element
8941 @item COBOL_Character
8946 For initialization, see the file @file{i-cobol.ads} in the distributed library.
8951 @strong{81}. Support for access to machine instructions. See C.1(1).
8954 See documentation in file @file{s-maccod.ads} in the distributed library.
8959 @strong{82}. Implementation-defined aspects of access to machine
8960 operations. See C.1(9).
8963 See documentation in file @file{s-maccod.ads} in the distributed library.
8968 @strong{83}. Implementation-defined aspects of interrupts. See C.3(2).
8971 Interrupts are mapped to signals or conditions as appropriate. See
8973 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
8974 on the interrupts supported on a particular target.
8979 @strong{84}. Implementation-defined aspects of pre-elaboration. See
8983 GNAT does not permit a partition to be restarted without reloading,
8984 except under control of the debugger.
8989 @strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7).
8992 Pragma @code{Discard_Names} causes names of enumeration literals to
8993 be suppressed. In the presence of this pragma, the Image attribute
8994 provides the image of the Pos of the literal, and Value accepts
9000 @strong{86}. The result of the @code{Task_Identification.Image}
9001 attribute. See C.7.1(7).
9004 The result of this attribute is a string that identifies
9005 the object or component that denotes a given task. If a variable @code{Var}
9006 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9008 is the hexadecimal representation of the virtual address of the corresponding
9009 task control block. If the variable is an array of tasks, the image of each
9010 task will have the form of an indexed component indicating the position of a
9011 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9012 component of a record, the image of the task will have the form of a selected
9013 component. These rules are fully recursive, so that the image of a task that
9014 is a subcomponent of a composite object corresponds to the expression that
9015 designates this task.
9017 If a task is created by an allocator, its image depends on the context. If the
9018 allocator is part of an object declaration, the rules described above are used
9019 to construct its image, and this image is not affected by subsequent
9020 assignments. If the allocator appears within an expression, the image
9021 includes only the name of the task type.
9023 If the configuration pragma Discard_Names is present, or if the restriction
9024 No_Implicit_Heap_Allocation is in effect, the image reduces to
9025 the numeric suffix, that is to say the hexadecimal representation of the
9026 virtual address of the control block of the task.
9030 @strong{87}. The value of @code{Current_Task} when in a protected entry
9031 or interrupt handler. See C.7.1(17).
9034 Protected entries or interrupt handlers can be executed by any
9035 convenient thread, so the value of @code{Current_Task} is undefined.
9040 @strong{88}. The effect of calling @code{Current_Task} from an entry
9041 body or interrupt handler. See C.7.1(19).
9044 The effect of calling @code{Current_Task} from an entry body or
9045 interrupt handler is to return the identification of the task currently
9051 @strong{89}. Implementation-defined aspects of
9052 @code{Task_Attributes}. See C.7.2(19).
9055 There are no implementation-defined aspects of @code{Task_Attributes}.
9060 @strong{90}. Values of all @code{Metrics}. See D(2).
9063 The metrics information for GNAT depends on the performance of the
9064 underlying operating system. The sources of the run-time for tasking
9065 implementation, together with the output from @option{-gnatG} can be
9066 used to determine the exact sequence of operating systems calls made
9067 to implement various tasking constructs. Together with appropriate
9068 information on the performance of the underlying operating system,
9069 on the exact target in use, this information can be used to determine
9070 the required metrics.
9075 @strong{91}. The declarations of @code{Any_Priority} and
9076 @code{Priority}. See D.1(11).
9079 See declarations in file @file{system.ads}.
9084 @strong{92}. Implementation-defined execution resources. See D.1(15).
9087 There are no implementation-defined execution resources.
9092 @strong{93}. Whether, on a multiprocessor, a task that is waiting for
9093 access to a protected object keeps its processor busy. See D.2.1(3).
9096 On a multi-processor, a task that is waiting for access to a protected
9097 object does not keep its processor busy.
9102 @strong{94}. The affect of implementation defined execution resources
9103 on task dispatching. See D.2.1(9).
9108 Tasks map to IRIX threads, and the dispatching policy is as defined by
9109 the IRIX implementation of threads.
9111 Tasks map to threads in the threads package used by GNAT@. Where possible
9112 and appropriate, these threads correspond to native threads of the
9113 underlying operating system.
9118 @strong{95}. Implementation-defined @code{policy_identifiers} allowed
9119 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
9122 There are no implementation-defined policy-identifiers allowed in this
9128 @strong{96}. Implementation-defined aspects of priority inversion. See
9132 Execution of a task cannot be preempted by the implementation processing
9133 of delay expirations for lower priority tasks.
9138 @strong{97}. Implementation defined task dispatching. See D.2.2(18).
9143 Tasks map to IRIX threads, and the dispatching policy is as defined by
9144 the IRIX implementation of threads.
9146 The policy is the same as that of the underlying threads implementation.
9151 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
9152 in a pragma @code{Locking_Policy}. See D.3(4).
9155 The only implementation defined policy permitted in GNAT is
9156 @code{Inheritance_Locking}. On targets that support this policy, locking
9157 is implemented by inheritance, i.e.@: the task owning the lock operates
9158 at a priority equal to the highest priority of any task currently
9159 requesting the lock.
9164 @strong{99}. Default ceiling priorities. See D.3(10).
9167 The ceiling priority of protected objects of the type
9168 @code{System.Interrupt_Priority'Last} as described in the Ada
9169 Reference Manual D.3(10),
9174 @strong{100}. The ceiling of any protected object used internally by
9175 the implementation. See D.3(16).
9178 The ceiling priority of internal protected objects is
9179 @code{System.Priority'Last}.
9184 @strong{101}. Implementation-defined queuing policies. See D.4(1).
9187 There are no implementation-defined queuing policies.
9192 @strong{102}. On a multiprocessor, any conditions that cause the
9193 completion of an aborted construct to be delayed later than what is
9194 specified for a single processor. See D.6(3).
9197 The semantics for abort on a multi-processor is the same as on a single
9198 processor, there are no further delays.
9203 @strong{103}. Any operations that implicitly require heap storage
9204 allocation. See D.7(8).
9207 The only operation that implicitly requires heap storage allocation is
9213 @strong{104}. Implementation-defined aspects of pragma
9214 @code{Restrictions}. See D.7(20).
9217 There are no such implementation-defined aspects.
9222 @strong{105}. Implementation-defined aspects of package
9223 @code{Real_Time}. See D.8(17).
9226 There are no implementation defined aspects of package @code{Real_Time}.
9231 @strong{106}. Implementation-defined aspects of
9232 @code{delay_statements}. See D.9(8).
9235 Any difference greater than one microsecond will cause the task to be
9236 delayed (see D.9(7)).
9241 @strong{107}. The upper bound on the duration of interrupt blocking
9242 caused by the implementation. See D.12(5).
9245 The upper bound is determined by the underlying operating system. In
9246 no cases is it more than 10 milliseconds.
9251 @strong{108}. The means for creating and executing distributed
9255 The GLADE package provides a utility GNATDIST for creating and executing
9256 distributed programs. See the GLADE reference manual for further details.
9261 @strong{109}. Any events that can result in a partition becoming
9262 inaccessible. See E.1(7).
9265 See the GLADE reference manual for full details on such events.
9270 @strong{110}. The scheduling policies, treatment of priorities, and
9271 management of shared resources between partitions in certain cases. See
9275 See the GLADE reference manual for full details on these aspects of
9276 multi-partition execution.
9281 @strong{111}. Events that cause the version of a compilation unit to
9285 Editing the source file of a compilation unit, or the source files of
9286 any units on which it is dependent in a significant way cause the version
9287 to change. No other actions cause the version number to change. All changes
9288 are significant except those which affect only layout, capitalization or
9294 @strong{112}. Whether the execution of the remote subprogram is
9295 immediately aborted as a result of cancellation. See E.4(13).
9298 See the GLADE reference manual for details on the effect of abort in
9299 a distributed application.
9304 @strong{113}. Implementation-defined aspects of the PCS@. See E.5(25).
9307 See the GLADE reference manual for a full description of all implementation
9308 defined aspects of the PCS@.
9313 @strong{114}. Implementation-defined interfaces in the PCS@. See
9317 See the GLADE reference manual for a full description of all
9318 implementation defined interfaces.
9323 @strong{115}. The values of named numbers in the package
9324 @code{Decimal}. See F.2(7).
9336 @item Max_Decimal_Digits
9343 @strong{116}. The value of @code{Max_Picture_Length} in the package
9344 @code{Text_IO.Editing}. See F.3.3(16).
9352 @strong{117}. The value of @code{Max_Picture_Length} in the package
9353 @code{Wide_Text_IO.Editing}. See F.3.4(5).
9361 @strong{118}. The accuracy actually achieved by the complex elementary
9362 functions and by other complex arithmetic operations. See G.1(1).
9365 Standard library functions are used for the complex arithmetic
9366 operations. Only fast math mode is currently supported.
9371 @strong{119}. The sign of a zero result (or a component thereof) from
9372 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9373 @code{Real'Signed_Zeros} is True. See G.1.1(53).
9376 The signs of zero values are as recommended by the relevant
9377 implementation advice.
9382 @strong{120}. The sign of a zero result (or a component thereof) from
9383 any operator or function in
9384 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9385 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
9388 The signs of zero values are as recommended by the relevant
9389 implementation advice.
9394 @strong{121}. Whether the strict mode or the relaxed mode is the
9395 default. See G.2(2).
9398 The strict mode is the default. There is no separate relaxed mode. GNAT
9399 provides a highly efficient implementation of strict mode.
9404 @strong{122}. The result interval in certain cases of fixed-to-float
9405 conversion. See G.2.1(10).
9408 For cases where the result interval is implementation dependent, the
9409 accuracy is that provided by performing all operations in 64-bit IEEE
9410 floating-point format.
9415 @strong{123}. The result of a floating point arithmetic operation in
9416 overflow situations, when the @code{Machine_Overflows} attribute of the
9417 result type is @code{False}. See G.2.1(13).
9420 Infinite and NaN values are produced as dictated by the IEEE
9421 floating-point standard.
9423 Note that on machines that are not fully compliant with the IEEE
9424 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9425 must be used for achieving IEEE confirming behavior (although at the cost
9426 of a significant performance penalty), so infinite and NaN values are
9432 @strong{124}. The result interval for division (or exponentiation by a
9433 negative exponent), when the floating point hardware implements division
9434 as multiplication by a reciprocal. See G.2.1(16).
9437 Not relevant, division is IEEE exact.
9442 @strong{125}. The definition of close result set, which determines the
9443 accuracy of certain fixed point multiplications and divisions. See
9447 Operations in the close result set are performed using IEEE long format
9448 floating-point arithmetic. The input operands are converted to
9449 floating-point, the operation is done in floating-point, and the result
9450 is converted to the target type.
9455 @strong{126}. Conditions on a @code{universal_real} operand of a fixed
9456 point multiplication or division for which the result shall be in the
9457 perfect result set. See G.2.3(22).
9460 The result is only defined to be in the perfect result set if the result
9461 can be computed by a single scaling operation involving a scale factor
9462 representable in 64-bits.
9467 @strong{127}. The result of a fixed point arithmetic operation in
9468 overflow situations, when the @code{Machine_Overflows} attribute of the
9469 result type is @code{False}. See G.2.3(27).
9472 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9478 @strong{128}. The result of an elementary function reference in
9479 overflow situations, when the @code{Machine_Overflows} attribute of the
9480 result type is @code{False}. See G.2.4(4).
9483 IEEE infinite and Nan values are produced as appropriate.
9488 @strong{129}. The value of the angle threshold, within which certain
9489 elementary functions, complex arithmetic operations, and complex
9490 elementary functions yield results conforming to a maximum relative
9491 error bound. See G.2.4(10).
9494 Information on this subject is not yet available.
9499 @strong{130}. The accuracy of certain elementary functions for
9500 parameters beyond the angle threshold. See G.2.4(10).
9503 Information on this subject is not yet available.
9508 @strong{131}. The result of a complex arithmetic operation or complex
9509 elementary function reference in overflow situations, when the
9510 @code{Machine_Overflows} attribute of the corresponding real type is
9511 @code{False}. See G.2.6(5).
9514 IEEE infinite and Nan values are produced as appropriate.
9519 @strong{132}. The accuracy of certain complex arithmetic operations and
9520 certain complex elementary functions for parameters (or components
9521 thereof) beyond the angle threshold. See G.2.6(8).
9524 Information on those subjects is not yet available.
9529 @strong{133}. Information regarding bounded errors and erroneous
9530 execution. See H.2(1).
9533 Information on this subject is not yet available.
9538 @strong{134}. Implementation-defined aspects of pragma
9539 @code{Inspection_Point}. See H.3.2(8).
9542 Pragma @code{Inspection_Point} ensures that the variable is live and can
9543 be examined by the debugger at the inspection point.
9548 @strong{135}. Implementation-defined aspects of pragma
9549 @code{Restrictions}. See H.4(25).
9552 There are no implementation-defined aspects of pragma @code{Restrictions}. The
9553 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9554 generated code. Checks must suppressed by use of pragma @code{Suppress}.
9559 @strong{136}. Any restrictions on pragma @code{Restrictions}. See
9563 There are no restrictions on pragma @code{Restrictions}.
9565 @node Intrinsic Subprograms
9566 @chapter Intrinsic Subprograms
9567 @cindex Intrinsic Subprograms
9570 * Intrinsic Operators::
9571 * Enclosing_Entity::
9572 * Exception_Information::
9573 * Exception_Message::
9581 * Shift_Right_Arithmetic::
9586 GNAT allows a user application program to write the declaration:
9588 @smallexample @c ada
9589 pragma Import (Intrinsic, name);
9593 providing that the name corresponds to one of the implemented intrinsic
9594 subprograms in GNAT, and that the parameter profile of the referenced
9595 subprogram meets the requirements. This chapter describes the set of
9596 implemented intrinsic subprograms, and the requirements on parameter profiles.
9597 Note that no body is supplied; as with other uses of pragma Import, the
9598 body is supplied elsewhere (in this case by the compiler itself). Note
9599 that any use of this feature is potentially non-portable, since the
9600 Ada standard does not require Ada compilers to implement this feature.
9602 @node Intrinsic Operators
9603 @section Intrinsic Operators
9604 @cindex Intrinsic operator
9607 All the predefined numeric operators in package Standard
9608 in @code{pragma Import (Intrinsic,..)}
9609 declarations. In the binary operator case, the operands must have the same
9610 size. The operand or operands must also be appropriate for
9611 the operator. For example, for addition, the operands must
9612 both be floating-point or both be fixed-point, and the
9613 right operand for @code{"**"} must have a root type of
9614 @code{Standard.Integer'Base}.
9615 You can use an intrinsic operator declaration as in the following example:
9617 @smallexample @c ada
9618 type Int1 is new Integer;
9619 type Int2 is new Integer;
9621 function "+" (X1 : Int1; X2 : Int2) return Int1;
9622 function "+" (X1 : Int1; X2 : Int2) return Int2;
9623 pragma Import (Intrinsic, "+");
9627 This declaration would permit ``mixed mode'' arithmetic on items
9628 of the differing types @code{Int1} and @code{Int2}.
9629 It is also possible to specify such operators for private types, if the
9630 full views are appropriate arithmetic types.
9632 @node Enclosing_Entity
9633 @section Enclosing_Entity
9634 @cindex Enclosing_Entity
9636 This intrinsic subprogram is used in the implementation of the
9637 library routine @code{GNAT.Source_Info}. The only useful use of the
9638 intrinsic import in this case is the one in this unit, so an
9639 application program should simply call the function
9640 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9641 the current subprogram, package, task, entry, or protected subprogram.
9643 @node Exception_Information
9644 @section Exception_Information
9645 @cindex Exception_Information'
9647 This intrinsic subprogram is used in the implementation of the
9648 library routine @code{GNAT.Current_Exception}. The only useful
9649 use of the intrinsic import in this case is the one in this unit,
9650 so an application program should simply call the function
9651 @code{GNAT.Current_Exception.Exception_Information} to obtain
9652 the exception information associated with the current exception.
9654 @node Exception_Message
9655 @section Exception_Message
9656 @cindex Exception_Message
9658 This intrinsic subprogram is used in the implementation of the
9659 library routine @code{GNAT.Current_Exception}. The only useful
9660 use of the intrinsic import in this case is the one in this unit,
9661 so an application program should simply call the function
9662 @code{GNAT.Current_Exception.Exception_Message} to obtain
9663 the message associated with the current exception.
9665 @node Exception_Name
9666 @section Exception_Name
9667 @cindex Exception_Name
9669 This intrinsic subprogram is used in the implementation of the
9670 library routine @code{GNAT.Current_Exception}. The only useful
9671 use of the intrinsic import in this case is the one in this unit,
9672 so an application program should simply call the function
9673 @code{GNAT.Current_Exception.Exception_Name} to obtain
9674 the name of the current exception.
9680 This intrinsic subprogram is used in the implementation of the
9681 library routine @code{GNAT.Source_Info}. The only useful use of the
9682 intrinsic import in this case is the one in this unit, so an
9683 application program should simply call the function
9684 @code{GNAT.Source_Info.File} to obtain the name of the current
9691 This intrinsic subprogram is used in the implementation of the
9692 library routine @code{GNAT.Source_Info}. The only useful use of the
9693 intrinsic import in this case is the one in this unit, so an
9694 application program should simply call the function
9695 @code{GNAT.Source_Info.Line} to obtain the number of the current
9699 @section Rotate_Left
9702 In standard Ada, the @code{Rotate_Left} function is available only
9703 for the predefined modular types in package @code{Interfaces}. However, in
9704 GNAT it is possible to define a Rotate_Left function for a user
9705 defined modular type or any signed integer type as in this example:
9707 @smallexample @c ada
9709 (Value : My_Modular_Type;
9711 return My_Modular_Type;
9715 The requirements are that the profile be exactly as in the example
9716 above. The only modifications allowed are in the formal parameter
9717 names, and in the type of @code{Value} and the return type, which
9718 must be the same, and must be either a signed integer type, or
9719 a modular integer type with a binary modulus, and the size must
9720 be 8. 16, 32 or 64 bits.
9723 @section Rotate_Right
9724 @cindex Rotate_Right
9726 A @code{Rotate_Right} function can be defined for any user defined
9727 binary modular integer type, or signed integer type, as described
9728 above for @code{Rotate_Left}.
9734 A @code{Shift_Left} function can be defined for any user defined
9735 binary modular integer type, or signed integer type, as described
9736 above for @code{Rotate_Left}.
9739 @section Shift_Right
9742 A @code{Shift_Right} function can be defined for any user defined
9743 binary modular integer type, or signed integer type, as described
9744 above for @code{Rotate_Left}.
9746 @node Shift_Right_Arithmetic
9747 @section Shift_Right_Arithmetic
9748 @cindex Shift_Right_Arithmetic
9750 A @code{Shift_Right_Arithmetic} function can be defined for any user
9751 defined binary modular integer type, or signed integer type, as described
9752 above for @code{Rotate_Left}.
9754 @node Source_Location
9755 @section Source_Location
9756 @cindex Source_Location
9758 This intrinsic subprogram is used in the implementation of the
9759 library routine @code{GNAT.Source_Info}. The only useful use of the
9760 intrinsic import in this case is the one in this unit, so an
9761 application program should simply call the function
9762 @code{GNAT.Source_Info.Source_Location} to obtain the current
9763 source file location.
9765 @node Representation Clauses and Pragmas
9766 @chapter Representation Clauses and Pragmas
9767 @cindex Representation Clauses
9770 * Alignment Clauses::
9772 * Storage_Size Clauses::
9773 * Size of Variant Record Objects::
9774 * Biased Representation ::
9775 * Value_Size and Object_Size Clauses::
9776 * Component_Size Clauses::
9777 * Bit_Order Clauses::
9778 * Effect of Bit_Order on Byte Ordering::
9779 * Pragma Pack for Arrays::
9780 * Pragma Pack for Records::
9781 * Record Representation Clauses::
9782 * Enumeration Clauses::
9784 * Effect of Convention on Representation::
9785 * Determining the Representations chosen by GNAT::
9789 @cindex Representation Clause
9790 @cindex Representation Pragma
9791 @cindex Pragma, representation
9792 This section describes the representation clauses accepted by GNAT, and
9793 their effect on the representation of corresponding data objects.
9795 GNAT fully implements Annex C (Systems Programming). This means that all
9796 the implementation advice sections in chapter 13 are fully implemented.
9797 However, these sections only require a minimal level of support for
9798 representation clauses. GNAT provides much more extensive capabilities,
9799 and this section describes the additional capabilities provided.
9801 @node Alignment Clauses
9802 @section Alignment Clauses
9803 @cindex Alignment Clause
9806 GNAT requires that all alignment clauses specify a power of 2, and all
9807 default alignments are always a power of 2. The default alignment
9808 values are as follows:
9811 @item @emph{Primitive Types}.
9812 For primitive types, the alignment is the minimum of the actual size of
9813 objects of the type divided by @code{Storage_Unit},
9814 and the maximum alignment supported by the target.
9815 (This maximum alignment is given by the GNAT-specific attribute
9816 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9817 @cindex @code{Maximum_Alignment} attribute
9818 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9819 default alignment will be 8 on any target that supports alignments
9820 this large, but on some targets, the maximum alignment may be smaller
9821 than 8, in which case objects of type @code{Long_Float} will be maximally
9824 @item @emph{Arrays}.
9825 For arrays, the alignment is equal to the alignment of the component type
9826 for the normal case where no packing or component size is given. If the
9827 array is packed, and the packing is effective (see separate section on
9828 packed arrays), then the alignment will be one for long packed arrays,
9829 or arrays whose length is not known at compile time. For short packed
9830 arrays, which are handled internally as modular types, the alignment
9831 will be as described for primitive types, e.g.@: a packed array of length
9832 31 bits will have an object size of four bytes, and an alignment of 4.
9834 @item @emph{Records}.
9835 For the normal non-packed case, the alignment of a record is equal to
9836 the maximum alignment of any of its components. For tagged records, this
9837 includes the implicit access type used for the tag. If a pragma @code{Pack}
9838 is used and all components are packable (see separate section on pragma
9839 @code{Pack}), then the resulting alignment is 1, unless the layout of the
9840 record makes it profitable to increase it.
9842 A special case is when:
9845 the size of the record is given explicitly, or a
9846 full record representation clause is given, and
9848 the size of the record is 2, 4, or 8 bytes.
9851 In this case, an alignment is chosen to match the
9852 size of the record. For example, if we have:
9854 @smallexample @c ada
9855 type Small is record
9858 for Small'Size use 16;
9862 then the default alignment of the record type @code{Small} is 2, not 1. This
9863 leads to more efficient code when the record is treated as a unit, and also
9864 allows the type to specified as @code{Atomic} on architectures requiring
9870 An alignment clause may specify a larger alignment than the default value
9871 up to some maximum value dependent on the target (obtainable by using the
9872 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
9873 a smaller alignment than the default value for enumeration, integer and
9874 fixed point types, as well as for record types, for example
9876 @smallexample @c ada
9881 for V'alignment use 1;
9885 @cindex Alignment, default
9886 The default alignment for the type @code{V} is 4, as a result of the
9887 Integer field in the record, but it is permissible, as shown, to
9888 override the default alignment of the record with a smaller value.
9891 @section Size Clauses
9895 The default size for a type @code{T} is obtainable through the
9896 language-defined attribute @code{T'Size} and also through the
9897 equivalent GNAT-defined attribute @code{T'Value_Size}.
9898 For objects of type @code{T}, GNAT will generally increase the type size
9899 so that the object size (obtainable through the GNAT-defined attribute
9900 @code{T'Object_Size})
9901 is a multiple of @code{T'Alignment * Storage_Unit}.
9904 @smallexample @c ada
9905 type Smallint is range 1 .. 6;
9914 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
9915 as specified by the RM rules,
9916 but objects of this type will have a size of 8
9917 (@code{Smallint'Object_Size} = 8),
9918 since objects by default occupy an integral number
9919 of storage units. On some targets, notably older
9920 versions of the Digital Alpha, the size of stand
9921 alone objects of this type may be 32, reflecting
9922 the inability of the hardware to do byte load/stores.
9924 Similarly, the size of type @code{Rec} is 40 bits
9925 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
9926 the alignment is 4, so objects of this type will have
9927 their size increased to 64 bits so that it is a multiple
9928 of the alignment (in bits). This decision is
9929 in accordance with the specific Implementation Advice in RM 13.3(43):
9932 A @code{Size} clause should be supported for an object if the specified
9933 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
9934 to a size in storage elements that is a multiple of the object's
9935 @code{Alignment} (if the @code{Alignment} is nonzero).
9939 An explicit size clause may be used to override the default size by
9940 increasing it. For example, if we have:
9942 @smallexample @c ada
9943 type My_Boolean is new Boolean;
9944 for My_Boolean'Size use 32;
9948 then values of this type will always be 32 bits long. In the case of
9949 discrete types, the size can be increased up to 64 bits, with the effect
9950 that the entire specified field is used to hold the value, sign- or
9951 zero-extended as appropriate. If more than 64 bits is specified, then
9952 padding space is allocated after the value, and a warning is issued that
9953 there are unused bits.
9955 Similarly the size of records and arrays may be increased, and the effect
9956 is to add padding bits after the value. This also causes a warning message
9959 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
9960 Size in bits, this corresponds to an object of size 256 megabytes (minus
9961 one). This limitation is true on all targets. The reason for this
9962 limitation is that it improves the quality of the code in many cases
9963 if it is known that a Size value can be accommodated in an object of
9966 @node Storage_Size Clauses
9967 @section Storage_Size Clauses
9968 @cindex Storage_Size Clause
9971 For tasks, the @code{Storage_Size} clause specifies the amount of space
9972 to be allocated for the task stack. This cannot be extended, and if the
9973 stack is exhausted, then @code{Storage_Error} will be raised (if stack
9974 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
9975 or a @code{Storage_Size} pragma in the task definition to set the
9976 appropriate required size. A useful technique is to include in every
9977 task definition a pragma of the form:
9979 @smallexample @c ada
9980 pragma Storage_Size (Default_Stack_Size);
9984 Then @code{Default_Stack_Size} can be defined in a global package, and
9985 modified as required. Any tasks requiring stack sizes different from the
9986 default can have an appropriate alternative reference in the pragma.
9988 You can also use the @option{-d} binder switch to modify the default stack
9991 For access types, the @code{Storage_Size} clause specifies the maximum
9992 space available for allocation of objects of the type. If this space is
9993 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9994 In the case where the access type is declared local to a subprogram, the
9995 use of a @code{Storage_Size} clause triggers automatic use of a special
9996 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9997 space for the pool is automatically reclaimed on exit from the scope in
9998 which the type is declared.
10000 A special case recognized by the compiler is the specification of a
10001 @code{Storage_Size} of zero for an access type. This means that no
10002 items can be allocated from the pool, and this is recognized at compile
10003 time, and all the overhead normally associated with maintaining a fixed
10004 size storage pool is eliminated. Consider the following example:
10006 @smallexample @c ada
10008 type R is array (Natural) of Character;
10009 type P is access all R;
10010 for P'Storage_Size use 0;
10011 -- Above access type intended only for interfacing purposes
10015 procedure g (m : P);
10016 pragma Import (C, g);
10027 As indicated in this example, these dummy storage pools are often useful in
10028 connection with interfacing where no object will ever be allocated. If you
10029 compile the above example, you get the warning:
10032 p.adb:16:09: warning: allocation from empty storage pool
10033 p.adb:16:09: warning: Storage_Error will be raised at run time
10037 Of course in practice, there will not be any explicit allocators in the
10038 case of such an access declaration.
10040 @node Size of Variant Record Objects
10041 @section Size of Variant Record Objects
10042 @cindex Size, variant record objects
10043 @cindex Variant record objects, size
10046 In the case of variant record objects, there is a question whether Size gives
10047 information about a particular variant, or the maximum size required
10048 for any variant. Consider the following program
10050 @smallexample @c ada
10051 with Text_IO; use Text_IO;
10053 type R1 (A : Boolean := False) is record
10055 when True => X : Character;
10056 when False => null;
10064 Put_Line (Integer'Image (V1'Size));
10065 Put_Line (Integer'Image (V2'Size));
10070 Here we are dealing with a variant record, where the True variant
10071 requires 16 bits, and the False variant requires 8 bits.
10072 In the above example, both V1 and V2 contain the False variant,
10073 which is only 8 bits long. However, the result of running the
10082 The reason for the difference here is that the discriminant value of
10083 V1 is fixed, and will always be False. It is not possible to assign
10084 a True variant value to V1, therefore 8 bits is sufficient. On the
10085 other hand, in the case of V2, the initial discriminant value is
10086 False (from the default), but it is possible to assign a True
10087 variant value to V2, therefore 16 bits must be allocated for V2
10088 in the general case, even fewer bits may be needed at any particular
10089 point during the program execution.
10091 As can be seen from the output of this program, the @code{'Size}
10092 attribute applied to such an object in GNAT gives the actual allocated
10093 size of the variable, which is the largest size of any of the variants.
10094 The Ada Reference Manual is not completely clear on what choice should
10095 be made here, but the GNAT behavior seems most consistent with the
10096 language in the RM@.
10098 In some cases, it may be desirable to obtain the size of the current
10099 variant, rather than the size of the largest variant. This can be
10100 achieved in GNAT by making use of the fact that in the case of a
10101 subprogram parameter, GNAT does indeed return the size of the current
10102 variant (because a subprogram has no way of knowing how much space
10103 is actually allocated for the actual).
10105 Consider the following modified version of the above program:
10107 @smallexample @c ada
10108 with Text_IO; use Text_IO;
10110 type R1 (A : Boolean := False) is record
10112 when True => X : Character;
10113 when False => null;
10119 function Size (V : R1) return Integer is
10125 Put_Line (Integer'Image (V2'Size));
10126 Put_Line (Integer'IMage (Size (V2)));
10128 Put_Line (Integer'Image (V2'Size));
10129 Put_Line (Integer'IMage (Size (V2)));
10134 The output from this program is
10144 Here we see that while the @code{'Size} attribute always returns
10145 the maximum size, regardless of the current variant value, the
10146 @code{Size} function does indeed return the size of the current
10149 @node Biased Representation
10150 @section Biased Representation
10151 @cindex Size for biased representation
10152 @cindex Biased representation
10155 In the case of scalars with a range starting at other than zero, it is
10156 possible in some cases to specify a size smaller than the default minimum
10157 value, and in such cases, GNAT uses an unsigned biased representation,
10158 in which zero is used to represent the lower bound, and successive values
10159 represent successive values of the type.
10161 For example, suppose we have the declaration:
10163 @smallexample @c ada
10164 type Small is range -7 .. -4;
10165 for Small'Size use 2;
10169 Although the default size of type @code{Small} is 4, the @code{Size}
10170 clause is accepted by GNAT and results in the following representation
10174 -7 is represented as 2#00#
10175 -6 is represented as 2#01#
10176 -5 is represented as 2#10#
10177 -4 is represented as 2#11#
10181 Biased representation is only used if the specified @code{Size} clause
10182 cannot be accepted in any other manner. These reduced sizes that force
10183 biased representation can be used for all discrete types except for
10184 enumeration types for which a representation clause is given.
10186 @node Value_Size and Object_Size Clauses
10187 @section Value_Size and Object_Size Clauses
10189 @findex Object_Size
10190 @cindex Size, of objects
10193 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10194 number of bits required to hold values of type @code{T}.
10195 Although this interpretation was allowed in Ada 83, it was not required,
10196 and this requirement in practice can cause some significant difficulties.
10197 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10198 However, in Ada 95 and Ada 2005,
10199 @code{Natural'Size} is
10200 typically 31. This means that code may change in behavior when moving
10201 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
10203 @smallexample @c ada
10204 type Rec is record;
10210 at 0 range 0 .. Natural'Size - 1;
10211 at 0 range Natural'Size .. 2 * Natural'Size - 1;
10216 In the above code, since the typical size of @code{Natural} objects
10217 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10218 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10219 there are cases where the fact that the object size can exceed the
10220 size of the type causes surprises.
10222 To help get around this problem GNAT provides two implementation
10223 defined attributes, @code{Value_Size} and @code{Object_Size}. When
10224 applied to a type, these attributes yield the size of the type
10225 (corresponding to the RM defined size attribute), and the size of
10226 objects of the type respectively.
10228 The @code{Object_Size} is used for determining the default size of
10229 objects and components. This size value can be referred to using the
10230 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
10231 the basis of the determination of the size. The backend is free to
10232 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10233 character might be stored in 32 bits on a machine with no efficient
10234 byte access instructions such as the Alpha.
10236 The default rules for the value of @code{Object_Size} for
10237 discrete types are as follows:
10241 The @code{Object_Size} for base subtypes reflect the natural hardware
10242 size in bits (run the compiler with @option{-gnatS} to find those values
10243 for numeric types). Enumeration types and fixed-point base subtypes have
10244 8, 16, 32 or 64 bits for this size, depending on the range of values
10248 The @code{Object_Size} of a subtype is the same as the
10249 @code{Object_Size} of
10250 the type from which it is obtained.
10253 The @code{Object_Size} of a derived base type is copied from the parent
10254 base type, and the @code{Object_Size} of a derived first subtype is copied
10255 from the parent first subtype.
10259 The @code{Value_Size} attribute
10260 is the (minimum) number of bits required to store a value
10262 This value is used to determine how tightly to pack
10263 records or arrays with components of this type, and also affects
10264 the semantics of unchecked conversion (unchecked conversions where
10265 the @code{Value_Size} values differ generate a warning, and are potentially
10268 The default rules for the value of @code{Value_Size} are as follows:
10272 The @code{Value_Size} for a base subtype is the minimum number of bits
10273 required to store all values of the type (including the sign bit
10274 only if negative values are possible).
10277 If a subtype statically matches the first subtype of a given type, then it has
10278 by default the same @code{Value_Size} as the first subtype. This is a
10279 consequence of RM 13.1(14) (``if two subtypes statically match,
10280 then their subtype-specific aspects are the same''.)
10283 All other subtypes have a @code{Value_Size} corresponding to the minimum
10284 number of bits required to store all values of the subtype. For
10285 dynamic bounds, it is assumed that the value can range down or up
10286 to the corresponding bound of the ancestor
10290 The RM defined attribute @code{Size} corresponds to the
10291 @code{Value_Size} attribute.
10293 The @code{Size} attribute may be defined for a first-named subtype. This sets
10294 the @code{Value_Size} of
10295 the first-named subtype to the given value, and the
10296 @code{Object_Size} of this first-named subtype to the given value padded up
10297 to an appropriate boundary. It is a consequence of the default rules
10298 above that this @code{Object_Size} will apply to all further subtypes. On the
10299 other hand, @code{Value_Size} is affected only for the first subtype, any
10300 dynamic subtypes obtained from it directly, and any statically matching
10301 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
10303 @code{Value_Size} and
10304 @code{Object_Size} may be explicitly set for any subtype using
10305 an attribute definition clause. Note that the use of these attributes
10306 can cause the RM 13.1(14) rule to be violated. If two access types
10307 reference aliased objects whose subtypes have differing @code{Object_Size}
10308 values as a result of explicit attribute definition clauses, then it
10309 is erroneous to convert from one access subtype to the other.
10311 At the implementation level, Esize stores the Object_Size and the
10312 RM_Size field stores the @code{Value_Size} (and hence the value of the
10313 @code{Size} attribute,
10314 which, as noted above, is equivalent to @code{Value_Size}).
10316 To get a feel for the difference, consider the following examples (note
10317 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10320 Object_Size Value_Size
10322 type x1 is range 0 .. 5; 8 3
10324 type x2 is range 0 .. 5;
10325 for x2'size use 12; 16 12
10327 subtype x3 is x2 range 0 .. 3; 16 2
10329 subtype x4 is x2'base range 0 .. 10; 8 4
10331 subtype x5 is x2 range 0 .. dynamic; 16 3*
10333 subtype x6 is x2'base range 0 .. dynamic; 8 3*
10338 Note: the entries marked ``3*'' are not actually specified by the Ada
10339 Reference Manual, but it seems in the spirit of the RM rules to allocate
10340 the minimum number of bits (here 3, given the range for @code{x2})
10341 known to be large enough to hold the given range of values.
10343 So far, so good, but GNAT has to obey the RM rules, so the question is
10344 under what conditions must the RM @code{Size} be used.
10345 The following is a list
10346 of the occasions on which the RM @code{Size} must be used:
10350 Component size for packed arrays or records
10353 Value of the attribute @code{Size} for a type
10356 Warning about sizes not matching for unchecked conversion
10360 For record types, the @code{Object_Size} is always a multiple of the
10361 alignment of the type (this is true for all types). In some cases the
10362 @code{Value_Size} can be smaller. Consider:
10372 On a typical 32-bit architecture, the X component will be four bytes, and
10373 require four-byte alignment, and the Y component will be one byte. In this
10374 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10375 required to store a value of this type, and for example, it is permissible
10376 to have a component of type R in an outer record whose component size is
10377 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10378 since it must be rounded up so that this value is a multiple of the
10379 alignment (4 bytes = 32 bits).
10382 For all other types, the @code{Object_Size}
10383 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10384 Only @code{Size} may be specified for such types.
10386 @node Component_Size Clauses
10387 @section Component_Size Clauses
10388 @cindex Component_Size Clause
10391 Normally, the value specified in a component size clause must be consistent
10392 with the subtype of the array component with regard to size and alignment.
10393 In other words, the value specified must be at least equal to the size
10394 of this subtype, and must be a multiple of the alignment value.
10396 In addition, component size clauses are allowed which cause the array
10397 to be packed, by specifying a smaller value. A first case is for
10398 component size values in the range 1 through 63. The value specified
10399 must not be smaller than the Size of the subtype. GNAT will accurately
10400 honor all packing requests in this range. For example, if we have:
10402 @smallexample @c ada
10403 type r is array (1 .. 8) of Natural;
10404 for r'Component_Size use 31;
10408 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10409 Of course access to the components of such an array is considerably
10410 less efficient than if the natural component size of 32 is used.
10411 A second case is when the subtype of the component is a record type
10412 padded because of its default alignment. For example, if we have:
10414 @smallexample @c ada
10421 type a is array (1 .. 8) of r;
10422 for a'Component_Size use 72;
10426 then the resulting array has a length of 72 bytes, instead of 96 bytes
10427 if the alignment of the record (4) was obeyed.
10429 Note that there is no point in giving both a component size clause
10430 and a pragma Pack for the same array type. if such duplicate
10431 clauses are given, the pragma Pack will be ignored.
10433 @node Bit_Order Clauses
10434 @section Bit_Order Clauses
10435 @cindex Bit_Order Clause
10436 @cindex bit ordering
10437 @cindex ordering, of bits
10440 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10441 attribute. The specification may either correspond to the default bit
10442 order for the target, in which case the specification has no effect and
10443 places no additional restrictions, or it may be for the non-standard
10444 setting (that is the opposite of the default).
10446 In the case where the non-standard value is specified, the effect is
10447 to renumber bits within each byte, but the ordering of bytes is not
10448 affected. There are certain
10449 restrictions placed on component clauses as follows:
10453 @item Components fitting within a single storage unit.
10455 These are unrestricted, and the effect is merely to renumber bits. For
10456 example if we are on a little-endian machine with @code{Low_Order_First}
10457 being the default, then the following two declarations have exactly
10460 @smallexample @c ada
10463 B : Integer range 1 .. 120;
10467 A at 0 range 0 .. 0;
10468 B at 0 range 1 .. 7;
10473 B : Integer range 1 .. 120;
10476 for R2'Bit_Order use High_Order_First;
10479 A at 0 range 7 .. 7;
10480 B at 0 range 0 .. 6;
10485 The useful application here is to write the second declaration with the
10486 @code{Bit_Order} attribute definition clause, and know that it will be treated
10487 the same, regardless of whether the target is little-endian or big-endian.
10489 @item Components occupying an integral number of bytes.
10491 These are components that exactly fit in two or more bytes. Such component
10492 declarations are allowed, but have no effect, since it is important to realize
10493 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10494 In particular, the following attempt at getting an endian-independent integer
10497 @smallexample @c ada
10502 for R2'Bit_Order use High_Order_First;
10505 A at 0 range 0 .. 31;
10510 This declaration will result in a little-endian integer on a
10511 little-endian machine, and a big-endian integer on a big-endian machine.
10512 If byte flipping is required for interoperability between big- and
10513 little-endian machines, this must be explicitly programmed. This capability
10514 is not provided by @code{Bit_Order}.
10516 @item Components that are positioned across byte boundaries
10518 but do not occupy an integral number of bytes. Given that bytes are not
10519 reordered, such fields would occupy a non-contiguous sequence of bits
10520 in memory, requiring non-trivial code to reassemble. They are for this
10521 reason not permitted, and any component clause specifying such a layout
10522 will be flagged as illegal by GNAT@.
10527 Since the misconception that Bit_Order automatically deals with all
10528 endian-related incompatibilities is a common one, the specification of
10529 a component field that is an integral number of bytes will always
10530 generate a warning. This warning may be suppressed using @code{pragma
10531 Warnings (Off)} if desired. The following section contains additional
10532 details regarding the issue of byte ordering.
10534 @node Effect of Bit_Order on Byte Ordering
10535 @section Effect of Bit_Order on Byte Ordering
10536 @cindex byte ordering
10537 @cindex ordering, of bytes
10540 In this section we will review the effect of the @code{Bit_Order} attribute
10541 definition clause on byte ordering. Briefly, it has no effect at all, but
10542 a detailed example will be helpful. Before giving this
10543 example, let us review the precise
10544 definition of the effect of defining @code{Bit_Order}. The effect of a
10545 non-standard bit order is described in section 15.5.3 of the Ada
10549 2 A bit ordering is a method of interpreting the meaning of
10550 the storage place attributes.
10554 To understand the precise definition of storage place attributes in
10555 this context, we visit section 13.5.1 of the manual:
10558 13 A record_representation_clause (without the mod_clause)
10559 specifies the layout. The storage place attributes (see 13.5.2)
10560 are taken from the values of the position, first_bit, and last_bit
10561 expressions after normalizing those values so that first_bit is
10562 less than Storage_Unit.
10566 The critical point here is that storage places are taken from
10567 the values after normalization, not before. So the @code{Bit_Order}
10568 interpretation applies to normalized values. The interpretation
10569 is described in the later part of the 15.5.3 paragraph:
10572 2 A bit ordering is a method of interpreting the meaning of
10573 the storage place attributes. High_Order_First (known in the
10574 vernacular as ``big endian'') means that the first bit of a
10575 storage element (bit 0) is the most significant bit (interpreting
10576 the sequence of bits that represent a component as an unsigned
10577 integer value). Low_Order_First (known in the vernacular as
10578 ``little endian'') means the opposite: the first bit is the
10583 Note that the numbering is with respect to the bits of a storage
10584 unit. In other words, the specification affects only the numbering
10585 of bits within a single storage unit.
10587 We can make the effect clearer by giving an example.
10589 Suppose that we have an external device which presents two bytes, the first
10590 byte presented, which is the first (low addressed byte) of the two byte
10591 record is called Master, and the second byte is called Slave.
10593 The left most (most significant bit is called Control for each byte, and
10594 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10595 (least significant) bit.
10597 On a big-endian machine, we can write the following representation clause
10599 @smallexample @c ada
10600 type Data is record
10601 Master_Control : Bit;
10609 Slave_Control : Bit;
10619 for Data use record
10620 Master_Control at 0 range 0 .. 0;
10621 Master_V1 at 0 range 1 .. 1;
10622 Master_V2 at 0 range 2 .. 2;
10623 Master_V3 at 0 range 3 .. 3;
10624 Master_V4 at 0 range 4 .. 4;
10625 Master_V5 at 0 range 5 .. 5;
10626 Master_V6 at 0 range 6 .. 6;
10627 Master_V7 at 0 range 7 .. 7;
10628 Slave_Control at 1 range 0 .. 0;
10629 Slave_V1 at 1 range 1 .. 1;
10630 Slave_V2 at 1 range 2 .. 2;
10631 Slave_V3 at 1 range 3 .. 3;
10632 Slave_V4 at 1 range 4 .. 4;
10633 Slave_V5 at 1 range 5 .. 5;
10634 Slave_V6 at 1 range 6 .. 6;
10635 Slave_V7 at 1 range 7 .. 7;
10640 Now if we move this to a little endian machine, then the bit ordering within
10641 the byte is backwards, so we have to rewrite the record rep clause as:
10643 @smallexample @c ada
10644 for Data use record
10645 Master_Control at 0 range 7 .. 7;
10646 Master_V1 at 0 range 6 .. 6;
10647 Master_V2 at 0 range 5 .. 5;
10648 Master_V3 at 0 range 4 .. 4;
10649 Master_V4 at 0 range 3 .. 3;
10650 Master_V5 at 0 range 2 .. 2;
10651 Master_V6 at 0 range 1 .. 1;
10652 Master_V7 at 0 range 0 .. 0;
10653 Slave_Control at 1 range 7 .. 7;
10654 Slave_V1 at 1 range 6 .. 6;
10655 Slave_V2 at 1 range 5 .. 5;
10656 Slave_V3 at 1 range 4 .. 4;
10657 Slave_V4 at 1 range 3 .. 3;
10658 Slave_V5 at 1 range 2 .. 2;
10659 Slave_V6 at 1 range 1 .. 1;
10660 Slave_V7 at 1 range 0 .. 0;
10665 It is a nuisance to have to rewrite the clause, especially if
10666 the code has to be maintained on both machines. However,
10667 this is a case that we can handle with the
10668 @code{Bit_Order} attribute if it is implemented.
10669 Note that the implementation is not required on byte addressed
10670 machines, but it is indeed implemented in GNAT.
10671 This means that we can simply use the
10672 first record clause, together with the declaration
10674 @smallexample @c ada
10675 for Data'Bit_Order use High_Order_First;
10679 and the effect is what is desired, namely the layout is exactly the same,
10680 independent of whether the code is compiled on a big-endian or little-endian
10683 The important point to understand is that byte ordering is not affected.
10684 A @code{Bit_Order} attribute definition never affects which byte a field
10685 ends up in, only where it ends up in that byte.
10686 To make this clear, let us rewrite the record rep clause of the previous
10689 @smallexample @c ada
10690 for Data'Bit_Order use High_Order_First;
10691 for Data use record
10692 Master_Control at 0 range 0 .. 0;
10693 Master_V1 at 0 range 1 .. 1;
10694 Master_V2 at 0 range 2 .. 2;
10695 Master_V3 at 0 range 3 .. 3;
10696 Master_V4 at 0 range 4 .. 4;
10697 Master_V5 at 0 range 5 .. 5;
10698 Master_V6 at 0 range 6 .. 6;
10699 Master_V7 at 0 range 7 .. 7;
10700 Slave_Control at 0 range 8 .. 8;
10701 Slave_V1 at 0 range 9 .. 9;
10702 Slave_V2 at 0 range 10 .. 10;
10703 Slave_V3 at 0 range 11 .. 11;
10704 Slave_V4 at 0 range 12 .. 12;
10705 Slave_V5 at 0 range 13 .. 13;
10706 Slave_V6 at 0 range 14 .. 14;
10707 Slave_V7 at 0 range 15 .. 15;
10712 This is exactly equivalent to saying (a repeat of the first example):
10714 @smallexample @c ada
10715 for Data'Bit_Order use High_Order_First;
10716 for Data use record
10717 Master_Control at 0 range 0 .. 0;
10718 Master_V1 at 0 range 1 .. 1;
10719 Master_V2 at 0 range 2 .. 2;
10720 Master_V3 at 0 range 3 .. 3;
10721 Master_V4 at 0 range 4 .. 4;
10722 Master_V5 at 0 range 5 .. 5;
10723 Master_V6 at 0 range 6 .. 6;
10724 Master_V7 at 0 range 7 .. 7;
10725 Slave_Control at 1 range 0 .. 0;
10726 Slave_V1 at 1 range 1 .. 1;
10727 Slave_V2 at 1 range 2 .. 2;
10728 Slave_V3 at 1 range 3 .. 3;
10729 Slave_V4 at 1 range 4 .. 4;
10730 Slave_V5 at 1 range 5 .. 5;
10731 Slave_V6 at 1 range 6 .. 6;
10732 Slave_V7 at 1 range 7 .. 7;
10737 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10738 field. The storage place attributes are obtained by normalizing the
10739 values given so that the @code{First_Bit} value is less than 8. After
10740 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10741 we specified in the other case.
10743 Now one might expect that the @code{Bit_Order} attribute might affect
10744 bit numbering within the entire record component (two bytes in this
10745 case, thus affecting which byte fields end up in), but that is not
10746 the way this feature is defined, it only affects numbering of bits,
10747 not which byte they end up in.
10749 Consequently it never makes sense to specify a starting bit number
10750 greater than 7 (for a byte addressable field) if an attribute
10751 definition for @code{Bit_Order} has been given, and indeed it
10752 may be actively confusing to specify such a value, so the compiler
10753 generates a warning for such usage.
10755 If you do need to control byte ordering then appropriate conditional
10756 values must be used. If in our example, the slave byte came first on
10757 some machines we might write:
10759 @smallexample @c ada
10760 Master_Byte_First constant Boolean := @dots{};
10762 Master_Byte : constant Natural :=
10763 1 - Boolean'Pos (Master_Byte_First);
10764 Slave_Byte : constant Natural :=
10765 Boolean'Pos (Master_Byte_First);
10767 for Data'Bit_Order use High_Order_First;
10768 for Data use record
10769 Master_Control at Master_Byte range 0 .. 0;
10770 Master_V1 at Master_Byte range 1 .. 1;
10771 Master_V2 at Master_Byte range 2 .. 2;
10772 Master_V3 at Master_Byte range 3 .. 3;
10773 Master_V4 at Master_Byte range 4 .. 4;
10774 Master_V5 at Master_Byte range 5 .. 5;
10775 Master_V6 at Master_Byte range 6 .. 6;
10776 Master_V7 at Master_Byte range 7 .. 7;
10777 Slave_Control at Slave_Byte range 0 .. 0;
10778 Slave_V1 at Slave_Byte range 1 .. 1;
10779 Slave_V2 at Slave_Byte range 2 .. 2;
10780 Slave_V3 at Slave_Byte range 3 .. 3;
10781 Slave_V4 at Slave_Byte range 4 .. 4;
10782 Slave_V5 at Slave_Byte range 5 .. 5;
10783 Slave_V6 at Slave_Byte range 6 .. 6;
10784 Slave_V7 at Slave_Byte range 7 .. 7;
10789 Now to switch between machines, all that is necessary is
10790 to set the boolean constant @code{Master_Byte_First} in
10791 an appropriate manner.
10793 @node Pragma Pack for Arrays
10794 @section Pragma Pack for Arrays
10795 @cindex Pragma Pack (for arrays)
10798 Pragma @code{Pack} applied to an array has no effect unless the component type
10799 is packable. For a component type to be packable, it must be one of the
10806 Any type whose size is specified with a size clause
10808 Any packed array type with a static size
10810 Any record type padded because of its default alignment
10814 For all these cases, if the component subtype size is in the range
10815 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10816 component size were specified giving the component subtype size.
10817 For example if we have:
10819 @smallexample @c ada
10820 type r is range 0 .. 17;
10822 type ar is array (1 .. 8) of r;
10827 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10828 and the size of the array @code{ar} will be exactly 40 bits.
10830 Note that in some cases this rather fierce approach to packing can produce
10831 unexpected effects. For example, in Ada 95 and Ada 2005,
10832 subtype @code{Natural} typically has a size of 31, meaning that if you
10833 pack an array of @code{Natural}, you get 31-bit
10834 close packing, which saves a few bits, but results in far less efficient
10835 access. Since many other Ada compilers will ignore such a packing request,
10836 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10837 might not be what is intended. You can easily remove this warning by
10838 using an explicit @code{Component_Size} setting instead, which never generates
10839 a warning, since the intention of the programmer is clear in this case.
10841 GNAT treats packed arrays in one of two ways. If the size of the array is
10842 known at compile time and is less than 64 bits, then internally the array
10843 is represented as a single modular type, of exactly the appropriate number
10844 of bits. If the length is greater than 63 bits, or is not known at compile
10845 time, then the packed array is represented as an array of bytes, and the
10846 length is always a multiple of 8 bits.
10848 Note that to represent a packed array as a modular type, the alignment must
10849 be suitable for the modular type involved. For example, on typical machines
10850 a 32-bit packed array will be represented by a 32-bit modular integer with
10851 an alignment of four bytes. If you explicitly override the default alignment
10852 with an alignment clause that is too small, the modular representation
10853 cannot be used. For example, consider the following set of declarations:
10855 @smallexample @c ada
10856 type R is range 1 .. 3;
10857 type S is array (1 .. 31) of R;
10858 for S'Component_Size use 2;
10860 for S'Alignment use 1;
10864 If the alignment clause were not present, then a 62-bit modular
10865 representation would be chosen (typically with an alignment of 4 or 8
10866 bytes depending on the target). But the default alignment is overridden
10867 with the explicit alignment clause. This means that the modular
10868 representation cannot be used, and instead the array of bytes
10869 representation must be used, meaning that the length must be a multiple
10870 of 8. Thus the above set of declarations will result in a diagnostic
10871 rejecting the size clause and noting that the minimum size allowed is 64.
10873 @cindex Pragma Pack (for type Natural)
10874 @cindex Pragma Pack warning
10876 One special case that is worth noting occurs when the base type of the
10877 component size is 8/16/32 and the subtype is one bit less. Notably this
10878 occurs with subtype @code{Natural}. Consider:
10880 @smallexample @c ada
10881 type Arr is array (1 .. 32) of Natural;
10886 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10887 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10888 Ada 83 compilers did not attempt 31 bit packing.
10890 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
10891 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
10892 substantial unintended performance penalty when porting legacy Ada 83 code.
10893 To help prevent this, GNAT generates a warning in such cases. If you really
10894 want 31 bit packing in a case like this, you can set the component size
10897 @smallexample @c ada
10898 type Arr is array (1 .. 32) of Natural;
10899 for Arr'Component_Size use 31;
10903 Here 31-bit packing is achieved as required, and no warning is generated,
10904 since in this case the programmer intention is clear.
10906 @node Pragma Pack for Records
10907 @section Pragma Pack for Records
10908 @cindex Pragma Pack (for records)
10911 Pragma @code{Pack} applied to a record will pack the components to reduce
10912 wasted space from alignment gaps and by reducing the amount of space
10913 taken by components. We distinguish between @emph{packable} components and
10914 @emph{non-packable} components.
10915 Components of the following types are considered packable:
10918 All primitive types are packable.
10921 Small packed arrays, whose size does not exceed 64 bits, and where the
10922 size is statically known at compile time, are represented internally
10923 as modular integers, and so they are also packable.
10928 All packable components occupy the exact number of bits corresponding to
10929 their @code{Size} value, and are packed with no padding bits, i.e.@: they
10930 can start on an arbitrary bit boundary.
10932 All other types are non-packable, they occupy an integral number of
10934 are placed at a boundary corresponding to their alignment requirements.
10936 For example, consider the record
10938 @smallexample @c ada
10939 type Rb1 is array (1 .. 13) of Boolean;
10942 type Rb2 is array (1 .. 65) of Boolean;
10957 The representation for the record x2 is as follows:
10959 @smallexample @c ada
10960 for x2'Size use 224;
10962 l1 at 0 range 0 .. 0;
10963 l2 at 0 range 1 .. 64;
10964 l3 at 12 range 0 .. 31;
10965 l4 at 16 range 0 .. 0;
10966 l5 at 16 range 1 .. 13;
10967 l6 at 18 range 0 .. 71;
10972 Studying this example, we see that the packable fields @code{l1}
10974 of length equal to their sizes, and placed at specific bit boundaries (and
10975 not byte boundaries) to
10976 eliminate padding. But @code{l3} is of a non-packable float type, so
10977 it is on the next appropriate alignment boundary.
10979 The next two fields are fully packable, so @code{l4} and @code{l5} are
10980 minimally packed with no gaps. However, type @code{Rb2} is a packed
10981 array that is longer than 64 bits, so it is itself non-packable. Thus
10982 the @code{l6} field is aligned to the next byte boundary, and takes an
10983 integral number of bytes, i.e.@: 72 bits.
10985 @node Record Representation Clauses
10986 @section Record Representation Clauses
10987 @cindex Record Representation Clause
10990 Record representation clauses may be given for all record types, including
10991 types obtained by record extension. Component clauses are allowed for any
10992 static component. The restrictions on component clauses depend on the type
10995 @cindex Component Clause
10996 For all components of an elementary type, the only restriction on component
10997 clauses is that the size must be at least the 'Size value of the type
10998 (actually the Value_Size). There are no restrictions due to alignment,
10999 and such components may freely cross storage boundaries.
11001 Packed arrays with a size up to and including 64 bits are represented
11002 internally using a modular type with the appropriate number of bits, and
11003 thus the same lack of restriction applies. For example, if you declare:
11005 @smallexample @c ada
11006 type R is array (1 .. 49) of Boolean;
11012 then a component clause for a component of type R may start on any
11013 specified bit boundary, and may specify a value of 49 bits or greater.
11015 For packed bit arrays that are longer than 64 bits, there are two
11016 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11017 including the important case of single bits or boolean values, then
11018 there are no limitations on placement of such components, and they
11019 may start and end at arbitrary bit boundaries.
11021 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11022 an array of this type longer than 64 bits must always be placed on
11023 on a storage unit (byte) boundary and occupy an integral number
11024 of storage units (bytes). Any component clause that does not
11025 meet this requirement will be rejected.
11027 Any aliased component, or component of an aliased type, must
11028 have its normal alignment and size. A component clause that
11029 does not meet this requirement will be rejected.
11031 The tag field of a tagged type always occupies an address sized field at
11032 the start of the record. No component clause may attempt to overlay this
11033 tag. When a tagged type appears as a component, the tag field must have
11036 In the case of a record extension T1, of a type T, no component clause applied
11037 to the type T1 can specify a storage location that would overlap the first
11038 T'Size bytes of the record.
11040 For all other component types, including non-bit-packed arrays,
11041 the component can be placed at an arbitrary bit boundary,
11042 so for example, the following is permitted:
11044 @smallexample @c ada
11045 type R is array (1 .. 10) of Boolean;
11054 G at 0 range 0 .. 0;
11055 H at 0 range 1 .. 1;
11056 L at 0 range 2 .. 81;
11057 R at 0 range 82 .. 161;
11062 Note: the above rules apply to recent releases of GNAT 5.
11063 In GNAT 3, there are more severe restrictions on larger components.
11064 For non-primitive types, including packed arrays with a size greater than
11065 64 bits, component clauses must respect the alignment requirement of the
11066 type, in particular, always starting on a byte boundary, and the length
11067 must be a multiple of the storage unit.
11069 @node Enumeration Clauses
11070 @section Enumeration Clauses
11072 The only restriction on enumeration clauses is that the range of values
11073 must be representable. For the signed case, if one or more of the
11074 representation values are negative, all values must be in the range:
11076 @smallexample @c ada
11077 System.Min_Int .. System.Max_Int
11081 For the unsigned case, where all values are nonnegative, the values must
11084 @smallexample @c ada
11085 0 .. System.Max_Binary_Modulus;
11089 A @emph{confirming} representation clause is one in which the values range
11090 from 0 in sequence, i.e.@: a clause that confirms the default representation
11091 for an enumeration type.
11092 Such a confirming representation
11093 is permitted by these rules, and is specially recognized by the compiler so
11094 that no extra overhead results from the use of such a clause.
11096 If an array has an index type which is an enumeration type to which an
11097 enumeration clause has been applied, then the array is stored in a compact
11098 manner. Consider the declarations:
11100 @smallexample @c ada
11101 type r is (A, B, C);
11102 for r use (A => 1, B => 5, C => 10);
11103 type t is array (r) of Character;
11107 The array type t corresponds to a vector with exactly three elements and
11108 has a default size equal to @code{3*Character'Size}. This ensures efficient
11109 use of space, but means that accesses to elements of the array will incur
11110 the overhead of converting representation values to the corresponding
11111 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11113 @node Address Clauses
11114 @section Address Clauses
11115 @cindex Address Clause
11117 The reference manual allows a general restriction on representation clauses,
11118 as found in RM 13.1(22):
11121 An implementation need not support representation
11122 items containing nonstatic expressions, except that
11123 an implementation should support a representation item
11124 for a given entity if each nonstatic expression in the
11125 representation item is a name that statically denotes
11126 a constant declared before the entity.
11130 In practice this is applicable only to address clauses, since this is the
11131 only case in which a non-static expression is permitted by the syntax. As
11132 the AARM notes in sections 13.1 (22.a-22.h):
11135 22.a Reason: This is to avoid the following sort of thing:
11137 22.b X : Integer := F(@dots{});
11138 Y : Address := G(@dots{});
11139 for X'Address use Y;
11141 22.c In the above, we have to evaluate the
11142 initialization expression for X before we
11143 know where to put the result. This seems
11144 like an unreasonable implementation burden.
11146 22.d The above code should instead be written
11149 22.e Y : constant Address := G(@dots{});
11150 X : Integer := F(@dots{});
11151 for X'Address use Y;
11153 22.f This allows the expression ``Y'' to be safely
11154 evaluated before X is created.
11156 22.g The constant could be a formal parameter of mode in.
11158 22.h An implementation can support other nonstatic
11159 expressions if it wants to. Expressions of type
11160 Address are hardly ever static, but their value
11161 might be known at compile time anyway in many
11166 GNAT does indeed permit many additional cases of non-static expressions. In
11167 particular, if the type involved is elementary there are no restrictions
11168 (since in this case, holding a temporary copy of the initialization value,
11169 if one is present, is inexpensive). In addition, if there is no implicit or
11170 explicit initialization, then there are no restrictions. GNAT will reject
11171 only the case where all three of these conditions hold:
11176 The type of the item is non-elementary (e.g.@: a record or array).
11179 There is explicit or implicit initialization required for the object.
11180 Note that access values are always implicitly initialized, and also
11181 in GNAT, certain bit-packed arrays (those having a dynamic length or
11182 a length greater than 64) will also be implicitly initialized to zero.
11185 The address value is non-static. Here GNAT is more permissive than the
11186 RM, and allows the address value to be the address of a previously declared
11187 stand-alone variable, as long as it does not itself have an address clause.
11189 @smallexample @c ada
11190 Anchor : Some_Initialized_Type;
11191 Overlay : Some_Initialized_Type;
11192 for Overlay'Address use Anchor'Address;
11196 However, the prefix of the address clause cannot be an array component, or
11197 a component of a discriminated record.
11202 As noted above in section 22.h, address values are typically non-static. In
11203 particular the To_Address function, even if applied to a literal value, is
11204 a non-static function call. To avoid this minor annoyance, GNAT provides
11205 the implementation defined attribute 'To_Address. The following two
11206 expressions have identical values:
11210 @smallexample @c ada
11211 To_Address (16#1234_0000#)
11212 System'To_Address (16#1234_0000#);
11216 except that the second form is considered to be a static expression, and
11217 thus when used as an address clause value is always permitted.
11220 Additionally, GNAT treats as static an address clause that is an
11221 unchecked_conversion of a static integer value. This simplifies the porting
11222 of legacy code, and provides a portable equivalent to the GNAT attribute
11225 Another issue with address clauses is the interaction with alignment
11226 requirements. When an address clause is given for an object, the address
11227 value must be consistent with the alignment of the object (which is usually
11228 the same as the alignment of the type of the object). If an address clause
11229 is given that specifies an inappropriately aligned address value, then the
11230 program execution is erroneous.
11232 Since this source of erroneous behavior can have unfortunate effects, GNAT
11233 checks (at compile time if possible, generating a warning, or at execution
11234 time with a run-time check) that the alignment is appropriate. If the
11235 run-time check fails, then @code{Program_Error} is raised. This run-time
11236 check is suppressed if range checks are suppressed, or if the special GNAT
11237 check Alignment_Check is suppressed, or if
11238 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11240 Finally, GNAT does not permit overlaying of objects of controlled types or
11241 composite types containing a controlled component. In most cases, the compiler
11242 can detect an attempt at such overlays and will generate a warning at compile
11243 time and a Program_Error exception at run time.
11246 An address clause cannot be given for an exported object. More
11247 understandably the real restriction is that objects with an address
11248 clause cannot be exported. This is because such variables are not
11249 defined by the Ada program, so there is no external object to export.
11252 It is permissible to give an address clause and a pragma Import for the
11253 same object. In this case, the variable is not really defined by the
11254 Ada program, so there is no external symbol to be linked. The link name
11255 and the external name are ignored in this case. The reason that we allow this
11256 combination is that it provides a useful idiom to avoid unwanted
11257 initializations on objects with address clauses.
11259 When an address clause is given for an object that has implicit or
11260 explicit initialization, then by default initialization takes place. This
11261 means that the effect of the object declaration is to overwrite the
11262 memory at the specified address. This is almost always not what the
11263 programmer wants, so GNAT will output a warning:
11273 for Ext'Address use System'To_Address (16#1234_1234#);
11275 >>> warning: implicit initialization of "Ext" may
11276 modify overlaid storage
11277 >>> warning: use pragma Import for "Ext" to suppress
11278 initialization (RM B(24))
11284 As indicated by the warning message, the solution is to use a (dummy) pragma
11285 Import to suppress this initialization. The pragma tell the compiler that the
11286 object is declared and initialized elsewhere. The following package compiles
11287 without warnings (and the initialization is suppressed):
11289 @smallexample @c ada
11297 for Ext'Address use System'To_Address (16#1234_1234#);
11298 pragma Import (Ada, Ext);
11303 A final issue with address clauses involves their use for overlaying
11304 variables, as in the following example:
11305 @cindex Overlaying of objects
11307 @smallexample @c ada
11310 for B'Address use A'Address;
11314 or alternatively, using the form recommended by the RM:
11316 @smallexample @c ada
11318 Addr : constant Address := A'Address;
11320 for B'Address use Addr;
11324 In both of these cases, @code{A}
11325 and @code{B} become aliased to one another via the
11326 address clause. This use of address clauses to overlay
11327 variables, achieving an effect similar to unchecked
11328 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11329 the effect is implementation defined. Furthermore, the
11330 Ada RM specifically recommends that in a situation
11331 like this, @code{B} should be subject to the following
11332 implementation advice (RM 13.3(19)):
11335 19 If the Address of an object is specified, or it is imported
11336 or exported, then the implementation should not perform
11337 optimizations based on assumptions of no aliases.
11341 GNAT follows this recommendation, and goes further by also applying
11342 this recommendation to the overlaid variable (@code{A}
11343 in the above example) in this case. This means that the overlay
11344 works "as expected", in that a modification to one of the variables
11345 will affect the value of the other.
11347 @node Effect of Convention on Representation
11348 @section Effect of Convention on Representation
11349 @cindex Convention, effect on representation
11352 Normally the specification of a foreign language convention for a type or
11353 an object has no effect on the chosen representation. In particular, the
11354 representation chosen for data in GNAT generally meets the standard system
11355 conventions, and for example records are laid out in a manner that is
11356 consistent with C@. This means that specifying convention C (for example)
11359 There are four exceptions to this general rule:
11363 @item Convention Fortran and array subtypes
11364 If pragma Convention Fortran is specified for an array subtype, then in
11365 accordance with the implementation advice in section 3.6.2(11) of the
11366 Ada Reference Manual, the array will be stored in a Fortran-compatible
11367 column-major manner, instead of the normal default row-major order.
11369 @item Convention C and enumeration types
11370 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11371 to accommodate all values of the type. For example, for the enumeration
11374 @smallexample @c ada
11375 type Color is (Red, Green, Blue);
11379 8 bits is sufficient to store all values of the type, so by default, objects
11380 of type @code{Color} will be represented using 8 bits. However, normal C
11381 convention is to use 32 bits for all enum values in C, since enum values
11382 are essentially of type int. If pragma @code{Convention C} is specified for an
11383 Ada enumeration type, then the size is modified as necessary (usually to
11384 32 bits) to be consistent with the C convention for enum values.
11386 Note that this treatment applies only to types. If Convention C is given for
11387 an enumeration object, where the enumeration type is not Convention C, then
11388 Object_Size bits are allocated. For example, for a normal enumeration type,
11389 with less than 256 elements, only 8 bits will be allocated for the object.
11390 Since this may be a surprise in terms of what C expects, GNAT will issue a
11391 warning in this situation. The warning can be suppressed by giving an explicit
11392 size clause specifying the desired size.
11394 @item Convention C/Fortran and Boolean types
11395 In C, the usual convention for boolean values, that is values used for
11396 conditions, is that zero represents false, and nonzero values represent
11397 true. In Ada, the normal convention is that two specific values, typically
11398 0/1, are used to represent false/true respectively.
11400 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11401 value represents true).
11403 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11404 C or Fortran convention for a derived Boolean, as in the following example:
11406 @smallexample @c ada
11407 type C_Switch is new Boolean;
11408 pragma Convention (C, C_Switch);
11412 then the GNAT generated code will treat any nonzero value as true. For truth
11413 values generated by GNAT, the conventional value 1 will be used for True, but
11414 when one of these values is read, any nonzero value is treated as True.
11416 @item Access types on OpenVMS
11417 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11418 arrays) are 64-bits long. An exception to this rule is for the case of
11419 C-convention access types where there is no explicit size clause present (or
11420 inherited for derived types). In this case, GNAT chooses to make these
11421 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11422 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11426 @node Determining the Representations chosen by GNAT
11427 @section Determining the Representations chosen by GNAT
11428 @cindex Representation, determination of
11429 @cindex @option{-gnatR} switch
11432 Although the descriptions in this section are intended to be complete, it is
11433 often easier to simply experiment to see what GNAT accepts and what the
11434 effect is on the layout of types and objects.
11436 As required by the Ada RM, if a representation clause is not accepted, then
11437 it must be rejected as illegal by the compiler. However, when a
11438 representation clause or pragma is accepted, there can still be questions
11439 of what the compiler actually does. For example, if a partial record
11440 representation clause specifies the location of some components and not
11441 others, then where are the non-specified components placed? Or if pragma
11442 @code{Pack} is used on a record, then exactly where are the resulting
11443 fields placed? The section on pragma @code{Pack} in this chapter can be
11444 used to answer the second question, but it is often easier to just see
11445 what the compiler does.
11447 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
11448 with this option, then the compiler will output information on the actual
11449 representations chosen, in a format similar to source representation
11450 clauses. For example, if we compile the package:
11452 @smallexample @c ada
11454 type r (x : boolean) is tagged record
11456 when True => S : String (1 .. 100);
11457 when False => null;
11461 type r2 is new r (false) with record
11466 y2 at 16 range 0 .. 31;
11473 type x1 is array (1 .. 10) of x;
11474 for x1'component_size use 11;
11476 type ia is access integer;
11478 type Rb1 is array (1 .. 13) of Boolean;
11481 type Rb2 is array (1 .. 65) of Boolean;
11497 using the switch @option{-gnatR} we obtain the following output:
11500 Representation information for unit q
11501 -------------------------------------
11504 for r'Alignment use 4;
11506 x at 4 range 0 .. 7;
11507 _tag at 0 range 0 .. 31;
11508 s at 5 range 0 .. 799;
11511 for r2'Size use 160;
11512 for r2'Alignment use 4;
11514 x at 4 range 0 .. 7;
11515 _tag at 0 range 0 .. 31;
11516 _parent at 0 range 0 .. 63;
11517 y2 at 16 range 0 .. 31;
11521 for x'Alignment use 1;
11523 y at 0 range 0 .. 7;
11526 for x1'Size use 112;
11527 for x1'Alignment use 1;
11528 for x1'Component_Size use 11;
11530 for rb1'Size use 13;
11531 for rb1'Alignment use 2;
11532 for rb1'Component_Size use 1;
11534 for rb2'Size use 72;
11535 for rb2'Alignment use 1;
11536 for rb2'Component_Size use 1;
11538 for x2'Size use 224;
11539 for x2'Alignment use 4;
11541 l1 at 0 range 0 .. 0;
11542 l2 at 0 range 1 .. 64;
11543 l3 at 12 range 0 .. 31;
11544 l4 at 16 range 0 .. 0;
11545 l5 at 16 range 1 .. 13;
11546 l6 at 18 range 0 .. 71;
11551 The Size values are actually the Object_Size, i.e.@: the default size that
11552 will be allocated for objects of the type.
11553 The ?? size for type r indicates that we have a variant record, and the
11554 actual size of objects will depend on the discriminant value.
11556 The Alignment values show the actual alignment chosen by the compiler
11557 for each record or array type.
11559 The record representation clause for type r shows where all fields
11560 are placed, including the compiler generated tag field (whose location
11561 cannot be controlled by the programmer).
11563 The record representation clause for the type extension r2 shows all the
11564 fields present, including the parent field, which is a copy of the fields
11565 of the parent type of r2, i.e.@: r1.
11567 The component size and size clauses for types rb1 and rb2 show
11568 the exact effect of pragma @code{Pack} on these arrays, and the record
11569 representation clause for type x2 shows how pragma @code{Pack} affects
11572 In some cases, it may be useful to cut and paste the representation clauses
11573 generated by the compiler into the original source to fix and guarantee
11574 the actual representation to be used.
11576 @node Standard Library Routines
11577 @chapter Standard Library Routines
11580 The Ada Reference Manual contains in Annex A a full description of an
11581 extensive set of standard library routines that can be used in any Ada
11582 program, and which must be provided by all Ada compilers. They are
11583 analogous to the standard C library used by C programs.
11585 GNAT implements all of the facilities described in annex A, and for most
11586 purposes the description in the Ada Reference Manual, or appropriate Ada
11587 text book, will be sufficient for making use of these facilities.
11589 In the case of the input-output facilities,
11590 @xref{The Implementation of Standard I/O},
11591 gives details on exactly how GNAT interfaces to the
11592 file system. For the remaining packages, the Ada Reference Manual
11593 should be sufficient. The following is a list of the packages included,
11594 together with a brief description of the functionality that is provided.
11596 For completeness, references are included to other predefined library
11597 routines defined in other sections of the Ada Reference Manual (these are
11598 cross-indexed from Annex A).
11602 This is a parent package for all the standard library packages. It is
11603 usually included implicitly in your program, and itself contains no
11604 useful data or routines.
11606 @item Ada.Calendar (9.6)
11607 @code{Calendar} provides time of day access, and routines for
11608 manipulating times and durations.
11610 @item Ada.Characters (A.3.1)
11611 This is a dummy parent package that contains no useful entities
11613 @item Ada.Characters.Handling (A.3.2)
11614 This package provides some basic character handling capabilities,
11615 including classification functions for classes of characters (e.g.@: test
11616 for letters, or digits).
11618 @item Ada.Characters.Latin_1 (A.3.3)
11619 This package includes a complete set of definitions of the characters
11620 that appear in type CHARACTER@. It is useful for writing programs that
11621 will run in international environments. For example, if you want an
11622 upper case E with an acute accent in a string, it is often better to use
11623 the definition of @code{UC_E_Acute} in this package. Then your program
11624 will print in an understandable manner even if your environment does not
11625 support these extended characters.
11627 @item Ada.Command_Line (A.15)
11628 This package provides access to the command line parameters and the name
11629 of the current program (analogous to the use of @code{argc} and @code{argv}
11630 in C), and also allows the exit status for the program to be set in a
11631 system-independent manner.
11633 @item Ada.Decimal (F.2)
11634 This package provides constants describing the range of decimal numbers
11635 implemented, and also a decimal divide routine (analogous to the COBOL
11636 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11638 @item Ada.Direct_IO (A.8.4)
11639 This package provides input-output using a model of a set of records of
11640 fixed-length, containing an arbitrary definite Ada type, indexed by an
11641 integer record number.
11643 @item Ada.Dynamic_Priorities (D.5)
11644 This package allows the priorities of a task to be adjusted dynamically
11645 as the task is running.
11647 @item Ada.Exceptions (11.4.1)
11648 This package provides additional information on exceptions, and also
11649 contains facilities for treating exceptions as data objects, and raising
11650 exceptions with associated messages.
11652 @item Ada.Finalization (7.6)
11653 This package contains the declarations and subprograms to support the
11654 use of controlled types, providing for automatic initialization and
11655 finalization (analogous to the constructors and destructors of C++)
11657 @item Ada.Interrupts (C.3.2)
11658 This package provides facilities for interfacing to interrupts, which
11659 includes the set of signals or conditions that can be raised and
11660 recognized as interrupts.
11662 @item Ada.Interrupts.Names (C.3.2)
11663 This package provides the set of interrupt names (actually signal
11664 or condition names) that can be handled by GNAT@.
11666 @item Ada.IO_Exceptions (A.13)
11667 This package defines the set of exceptions that can be raised by use of
11668 the standard IO packages.
11671 This package contains some standard constants and exceptions used
11672 throughout the numerics packages. Note that the constants pi and e are
11673 defined here, and it is better to use these definitions than rolling
11676 @item Ada.Numerics.Complex_Elementary_Functions
11677 Provides the implementation of standard elementary functions (such as
11678 log and trigonometric functions) operating on complex numbers using the
11679 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11680 created by the package @code{Numerics.Complex_Types}.
11682 @item Ada.Numerics.Complex_Types
11683 This is a predefined instantiation of
11684 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11685 build the type @code{Complex} and @code{Imaginary}.
11687 @item Ada.Numerics.Discrete_Random
11688 This package provides a random number generator suitable for generating
11689 random integer values from a specified range.
11691 @item Ada.Numerics.Float_Random
11692 This package provides a random number generator suitable for generating
11693 uniformly distributed floating point values.
11695 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11696 This is a generic version of the package that provides the
11697 implementation of standard elementary functions (such as log and
11698 trigonometric functions) for an arbitrary complex type.
11700 The following predefined instantiations of this package are provided:
11704 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11706 @code{Ada.Numerics.Complex_Elementary_Functions}
11708 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
11711 @item Ada.Numerics.Generic_Complex_Types
11712 This is a generic package that allows the creation of complex types,
11713 with associated complex arithmetic operations.
11715 The following predefined instantiations of this package exist
11718 @code{Ada.Numerics.Short_Complex_Complex_Types}
11720 @code{Ada.Numerics.Complex_Complex_Types}
11722 @code{Ada.Numerics.Long_Complex_Complex_Types}
11725 @item Ada.Numerics.Generic_Elementary_Functions
11726 This is a generic package that provides the implementation of standard
11727 elementary functions (such as log an trigonometric functions) for an
11728 arbitrary float type.
11730 The following predefined instantiations of this package exist
11734 @code{Ada.Numerics.Short_Elementary_Functions}
11736 @code{Ada.Numerics.Elementary_Functions}
11738 @code{Ada.Numerics.Long_Elementary_Functions}
11741 @item Ada.Real_Time (D.8)
11742 This package provides facilities similar to those of @code{Calendar}, but
11743 operating with a finer clock suitable for real time control. Note that
11744 annex D requires that there be no backward clock jumps, and GNAT generally
11745 guarantees this behavior, but of course if the external clock on which
11746 the GNAT runtime depends is deliberately reset by some external event,
11747 then such a backward jump may occur.
11749 @item Ada.Sequential_IO (A.8.1)
11750 This package provides input-output facilities for sequential files,
11751 which can contain a sequence of values of a single type, which can be
11752 any Ada type, including indefinite (unconstrained) types.
11754 @item Ada.Storage_IO (A.9)
11755 This package provides a facility for mapping arbitrary Ada types to and
11756 from a storage buffer. It is primarily intended for the creation of new
11759 @item Ada.Streams (13.13.1)
11760 This is a generic package that provides the basic support for the
11761 concept of streams as used by the stream attributes (@code{Input},
11762 @code{Output}, @code{Read} and @code{Write}).
11764 @item Ada.Streams.Stream_IO (A.12.1)
11765 This package is a specialization of the type @code{Streams} defined in
11766 package @code{Streams} together with a set of operations providing
11767 Stream_IO capability. The Stream_IO model permits both random and
11768 sequential access to a file which can contain an arbitrary set of values
11769 of one or more Ada types.
11771 @item Ada.Strings (A.4.1)
11772 This package provides some basic constants used by the string handling
11775 @item Ada.Strings.Bounded (A.4.4)
11776 This package provides facilities for handling variable length
11777 strings. The bounded model requires a maximum length. It is thus
11778 somewhat more limited than the unbounded model, but avoids the use of
11779 dynamic allocation or finalization.
11781 @item Ada.Strings.Fixed (A.4.3)
11782 This package provides facilities for handling fixed length strings.
11784 @item Ada.Strings.Maps (A.4.2)
11785 This package provides facilities for handling character mappings and
11786 arbitrarily defined subsets of characters. For instance it is useful in
11787 defining specialized translation tables.
11789 @item Ada.Strings.Maps.Constants (A.4.6)
11790 This package provides a standard set of predefined mappings and
11791 predefined character sets. For example, the standard upper to lower case
11792 conversion table is found in this package. Note that upper to lower case
11793 conversion is non-trivial if you want to take the entire set of
11794 characters, including extended characters like E with an acute accent,
11795 into account. You should use the mappings in this package (rather than
11796 adding 32 yourself) to do case mappings.
11798 @item Ada.Strings.Unbounded (A.4.5)
11799 This package provides facilities for handling variable length
11800 strings. The unbounded model allows arbitrary length strings, but
11801 requires the use of dynamic allocation and finalization.
11803 @item Ada.Strings.Wide_Bounded (A.4.7)
11804 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11805 @itemx Ada.Strings.Wide_Maps (A.4.7)
11806 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11807 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11808 These packages provide analogous capabilities to the corresponding
11809 packages without @samp{Wide_} in the name, but operate with the types
11810 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11811 and @code{Character}.
11813 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11814 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11815 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11816 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11817 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11818 These packages provide analogous capabilities to the corresponding
11819 packages without @samp{Wide_} in the name, but operate with the types
11820 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11821 of @code{String} and @code{Character}.
11823 @item Ada.Synchronous_Task_Control (D.10)
11824 This package provides some standard facilities for controlling task
11825 communication in a synchronous manner.
11828 This package contains definitions for manipulation of the tags of tagged
11831 @item Ada.Task_Attributes
11832 This package provides the capability of associating arbitrary
11833 task-specific data with separate tasks.
11836 This package provides basic text input-output capabilities for
11837 character, string and numeric data. The subpackages of this
11838 package are listed next.
11840 @item Ada.Text_IO.Decimal_IO
11841 Provides input-output facilities for decimal fixed-point types
11843 @item Ada.Text_IO.Enumeration_IO
11844 Provides input-output facilities for enumeration types.
11846 @item Ada.Text_IO.Fixed_IO
11847 Provides input-output facilities for ordinary fixed-point types.
11849 @item Ada.Text_IO.Float_IO
11850 Provides input-output facilities for float types. The following
11851 predefined instantiations of this generic package are available:
11855 @code{Short_Float_Text_IO}
11857 @code{Float_Text_IO}
11859 @code{Long_Float_Text_IO}
11862 @item Ada.Text_IO.Integer_IO
11863 Provides input-output facilities for integer types. The following
11864 predefined instantiations of this generic package are available:
11867 @item Short_Short_Integer
11868 @code{Ada.Short_Short_Integer_Text_IO}
11869 @item Short_Integer
11870 @code{Ada.Short_Integer_Text_IO}
11872 @code{Ada.Integer_Text_IO}
11874 @code{Ada.Long_Integer_Text_IO}
11875 @item Long_Long_Integer
11876 @code{Ada.Long_Long_Integer_Text_IO}
11879 @item Ada.Text_IO.Modular_IO
11880 Provides input-output facilities for modular (unsigned) types
11882 @item Ada.Text_IO.Complex_IO (G.1.3)
11883 This package provides basic text input-output capabilities for complex
11886 @item Ada.Text_IO.Editing (F.3.3)
11887 This package contains routines for edited output, analogous to the use
11888 of pictures in COBOL@. The picture formats used by this package are a
11889 close copy of the facility in COBOL@.
11891 @item Ada.Text_IO.Text_Streams (A.12.2)
11892 This package provides a facility that allows Text_IO files to be treated
11893 as streams, so that the stream attributes can be used for writing
11894 arbitrary data, including binary data, to Text_IO files.
11896 @item Ada.Unchecked_Conversion (13.9)
11897 This generic package allows arbitrary conversion from one type to
11898 another of the same size, providing for breaking the type safety in
11899 special circumstances.
11901 If the types have the same Size (more accurately the same Value_Size),
11902 then the effect is simply to transfer the bits from the source to the
11903 target type without any modification. This usage is well defined, and
11904 for simple types whose representation is typically the same across
11905 all implementations, gives a portable method of performing such
11908 If the types do not have the same size, then the result is implementation
11909 defined, and thus may be non-portable. The following describes how GNAT
11910 handles such unchecked conversion cases.
11912 If the types are of different sizes, and are both discrete types, then
11913 the effect is of a normal type conversion without any constraint checking.
11914 In particular if the result type has a larger size, the result will be
11915 zero or sign extended. If the result type has a smaller size, the result
11916 will be truncated by ignoring high order bits.
11918 If the types are of different sizes, and are not both discrete types,
11919 then the conversion works as though pointers were created to the source
11920 and target, and the pointer value is converted. The effect is that bits
11921 are copied from successive low order storage units and bits of the source
11922 up to the length of the target type.
11924 A warning is issued if the lengths differ, since the effect in this
11925 case is implementation dependent, and the above behavior may not match
11926 that of some other compiler.
11928 A pointer to one type may be converted to a pointer to another type using
11929 unchecked conversion. The only case in which the effect is undefined is
11930 when one or both pointers are pointers to unconstrained array types. In
11931 this case, the bounds information may get incorrectly transferred, and in
11932 particular, GNAT uses double size pointers for such types, and it is
11933 meaningless to convert between such pointer types. GNAT will issue a
11934 warning if the alignment of the target designated type is more strict
11935 than the alignment of the source designated type (since the result may
11936 be unaligned in this case).
11938 A pointer other than a pointer to an unconstrained array type may be
11939 converted to and from System.Address. Such usage is common in Ada 83
11940 programs, but note that Ada.Address_To_Access_Conversions is the
11941 preferred method of performing such conversions in Ada 95 and Ada 2005.
11943 unchecked conversion nor Ada.Address_To_Access_Conversions should be
11944 used in conjunction with pointers to unconstrained objects, since
11945 the bounds information cannot be handled correctly in this case.
11947 @item Ada.Unchecked_Deallocation (13.11.2)
11948 This generic package allows explicit freeing of storage previously
11949 allocated by use of an allocator.
11951 @item Ada.Wide_Text_IO (A.11)
11952 This package is similar to @code{Ada.Text_IO}, except that the external
11953 file supports wide character representations, and the internal types are
11954 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11955 and @code{String}. It contains generic subpackages listed next.
11957 @item Ada.Wide_Text_IO.Decimal_IO
11958 Provides input-output facilities for decimal fixed-point types
11960 @item Ada.Wide_Text_IO.Enumeration_IO
11961 Provides input-output facilities for enumeration types.
11963 @item Ada.Wide_Text_IO.Fixed_IO
11964 Provides input-output facilities for ordinary fixed-point types.
11966 @item Ada.Wide_Text_IO.Float_IO
11967 Provides input-output facilities for float types. The following
11968 predefined instantiations of this generic package are available:
11972 @code{Short_Float_Wide_Text_IO}
11974 @code{Float_Wide_Text_IO}
11976 @code{Long_Float_Wide_Text_IO}
11979 @item Ada.Wide_Text_IO.Integer_IO
11980 Provides input-output facilities for integer types. The following
11981 predefined instantiations of this generic package are available:
11984 @item Short_Short_Integer
11985 @code{Ada.Short_Short_Integer_Wide_Text_IO}
11986 @item Short_Integer
11987 @code{Ada.Short_Integer_Wide_Text_IO}
11989 @code{Ada.Integer_Wide_Text_IO}
11991 @code{Ada.Long_Integer_Wide_Text_IO}
11992 @item Long_Long_Integer
11993 @code{Ada.Long_Long_Integer_Wide_Text_IO}
11996 @item Ada.Wide_Text_IO.Modular_IO
11997 Provides input-output facilities for modular (unsigned) types
11999 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12000 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12001 external file supports wide character representations.
12003 @item Ada.Wide_Text_IO.Editing (F.3.4)
12004 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12005 types are @code{Wide_Character} and @code{Wide_String} instead of
12006 @code{Character} and @code{String}.
12008 @item Ada.Wide_Text_IO.Streams (A.12.3)
12009 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12010 types are @code{Wide_Character} and @code{Wide_String} instead of
12011 @code{Character} and @code{String}.
12013 @item Ada.Wide_Wide_Text_IO (A.11)
12014 This package is similar to @code{Ada.Text_IO}, except that the external
12015 file supports wide character representations, and the internal types are
12016 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12017 and @code{String}. It contains generic subpackages listed next.
12019 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12020 Provides input-output facilities for decimal fixed-point types
12022 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12023 Provides input-output facilities for enumeration types.
12025 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12026 Provides input-output facilities for ordinary fixed-point types.
12028 @item Ada.Wide_Wide_Text_IO.Float_IO
12029 Provides input-output facilities for float types. The following
12030 predefined instantiations of this generic package are available:
12034 @code{Short_Float_Wide_Wide_Text_IO}
12036 @code{Float_Wide_Wide_Text_IO}
12038 @code{Long_Float_Wide_Wide_Text_IO}
12041 @item Ada.Wide_Wide_Text_IO.Integer_IO
12042 Provides input-output facilities for integer types. The following
12043 predefined instantiations of this generic package are available:
12046 @item Short_Short_Integer
12047 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12048 @item Short_Integer
12049 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12051 @code{Ada.Integer_Wide_Wide_Text_IO}
12053 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12054 @item Long_Long_Integer
12055 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12058 @item Ada.Wide_Wide_Text_IO.Modular_IO
12059 Provides input-output facilities for modular (unsigned) types
12061 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12062 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12063 external file supports wide character representations.
12065 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12066 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12067 types are @code{Wide_Character} and @code{Wide_String} instead of
12068 @code{Character} and @code{String}.
12070 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12071 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12072 types are @code{Wide_Character} and @code{Wide_String} instead of
12073 @code{Character} and @code{String}.
12078 @node The Implementation of Standard I/O
12079 @chapter The Implementation of Standard I/O
12082 GNAT implements all the required input-output facilities described in
12083 A.6 through A.14. These sections of the Ada Reference Manual describe the
12084 required behavior of these packages from the Ada point of view, and if
12085 you are writing a portable Ada program that does not need to know the
12086 exact manner in which Ada maps to the outside world when it comes to
12087 reading or writing external files, then you do not need to read this
12088 chapter. As long as your files are all regular files (not pipes or
12089 devices), and as long as you write and read the files only from Ada, the
12090 description in the Ada Reference Manual is sufficient.
12092 However, if you want to do input-output to pipes or other devices, such
12093 as the keyboard or screen, or if the files you are dealing with are
12094 either generated by some other language, or to be read by some other
12095 language, then you need to know more about the details of how the GNAT
12096 implementation of these input-output facilities behaves.
12098 In this chapter we give a detailed description of exactly how GNAT
12099 interfaces to the file system. As always, the sources of the system are
12100 available to you for answering questions at an even more detailed level,
12101 but for most purposes the information in this chapter will suffice.
12103 Another reason that you may need to know more about how input-output is
12104 implemented arises when you have a program written in mixed languages
12105 where, for example, files are shared between the C and Ada sections of
12106 the same program. GNAT provides some additional facilities, in the form
12107 of additional child library packages, that facilitate this sharing, and
12108 these additional facilities are also described in this chapter.
12111 * Standard I/O Packages::
12117 * Wide_Wide_Text_IO::
12120 * Filenames encoding::
12122 * Operations on C Streams::
12123 * Interfacing to C Streams::
12126 @node Standard I/O Packages
12127 @section Standard I/O Packages
12130 The Standard I/O packages described in Annex A for
12136 Ada.Text_IO.Complex_IO
12138 Ada.Text_IO.Text_Streams
12142 Ada.Wide_Text_IO.Complex_IO
12144 Ada.Wide_Text_IO.Text_Streams
12146 Ada.Wide_Wide_Text_IO
12148 Ada.Wide_Wide_Text_IO.Complex_IO
12150 Ada.Wide_Wide_Text_IO.Text_Streams
12160 are implemented using the C
12161 library streams facility; where
12165 All files are opened using @code{fopen}.
12167 All input/output operations use @code{fread}/@code{fwrite}.
12171 There is no internal buffering of any kind at the Ada library level. The only
12172 buffering is that provided at the system level in the implementation of the
12173 library routines that support streams. This facilitates shared use of these
12174 streams by mixed language programs. Note though that system level buffering is
12175 explicitly enabled at elaboration of the standard I/O packages and that can
12176 have an impact on mixed language programs, in particular those using I/O before
12177 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12178 the Ada elaboration routine before performing any I/O or when impractical,
12179 flush the common I/O streams and in particular Standard_Output before
12180 elaborating the Ada code.
12183 @section FORM Strings
12186 The format of a FORM string in GNAT is:
12189 "keyword=value,keyword=value,@dots{},keyword=value"
12193 where letters may be in upper or lower case, and there are no spaces
12194 between values. The order of the entries is not important. Currently
12195 there are two keywords defined.
12199 WCEM=[n|h|u|s|e|8|b]
12203 The use of these parameters is described later in this section.
12209 Direct_IO can only be instantiated for definite types. This is a
12210 restriction of the Ada language, which means that the records are fixed
12211 length (the length being determined by @code{@var{type}'Size}, rounded
12212 up to the next storage unit boundary if necessary).
12214 The records of a Direct_IO file are simply written to the file in index
12215 sequence, with the first record starting at offset zero, and subsequent
12216 records following. There is no control information of any kind. For
12217 example, if 32-bit integers are being written, each record takes
12218 4-bytes, so the record at index @var{K} starts at offset
12219 (@var{K}@minus{}1)*4.
12221 There is no limit on the size of Direct_IO files, they are expanded as
12222 necessary to accommodate whatever records are written to the file.
12224 @node Sequential_IO
12225 @section Sequential_IO
12228 Sequential_IO may be instantiated with either a definite (constrained)
12229 or indefinite (unconstrained) type.
12231 For the definite type case, the elements written to the file are simply
12232 the memory images of the data values with no control information of any
12233 kind. The resulting file should be read using the same type, no validity
12234 checking is performed on input.
12236 For the indefinite type case, the elements written consist of two
12237 parts. First is the size of the data item, written as the memory image
12238 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12239 the data value. The resulting file can only be read using the same
12240 (unconstrained) type. Normal assignment checks are performed on these
12241 read operations, and if these checks fail, @code{Data_Error} is
12242 raised. In particular, in the array case, the lengths must match, and in
12243 the variant record case, if the variable for a particular read operation
12244 is constrained, the discriminants must match.
12246 Note that it is not possible to use Sequential_IO to write variable
12247 length array items, and then read the data back into different length
12248 arrays. For example, the following will raise @code{Data_Error}:
12250 @smallexample @c ada
12251 package IO is new Sequential_IO (String);
12256 IO.Write (F, "hello!")
12257 IO.Reset (F, Mode=>In_File);
12264 On some Ada implementations, this will print @code{hell}, but the program is
12265 clearly incorrect, since there is only one element in the file, and that
12266 element is the string @code{hello!}.
12268 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12269 using Stream_IO, and this is the preferred mechanism. In particular, the
12270 above program fragment rewritten to use Stream_IO will work correctly.
12276 Text_IO files consist of a stream of characters containing the following
12277 special control characters:
12280 LF (line feed, 16#0A#) Line Mark
12281 FF (form feed, 16#0C#) Page Mark
12285 A canonical Text_IO file is defined as one in which the following
12286 conditions are met:
12290 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12294 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12295 end of a page and consequently can appear only immediately following a
12296 @code{LF} (line mark) character.
12299 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12300 (line mark, page mark). In the former case, the page mark is implicitly
12301 assumed to be present.
12305 A file written using Text_IO will be in canonical form provided that no
12306 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12307 or @code{Put_Line}. There will be no @code{FF} character at the end of
12308 the file unless an explicit @code{New_Page} operation was performed
12309 before closing the file.
12311 A canonical Text_IO file that is a regular file (i.e., not a device or a
12312 pipe) can be read using any of the routines in Text_IO@. The
12313 semantics in this case will be exactly as defined in the Ada Reference
12314 Manual, and all the routines in Text_IO are fully implemented.
12316 A text file that does not meet the requirements for a canonical Text_IO
12317 file has one of the following:
12321 The file contains @code{FF} characters not immediately following a
12322 @code{LF} character.
12325 The file contains @code{LF} or @code{FF} characters written by
12326 @code{Put} or @code{Put_Line}, which are not logically considered to be
12327 line marks or page marks.
12330 The file ends in a character other than @code{LF} or @code{FF},
12331 i.e.@: there is no explicit line mark or page mark at the end of the file.
12335 Text_IO can be used to read such non-standard text files but subprograms
12336 to do with line or page numbers do not have defined meanings. In
12337 particular, a @code{FF} character that does not follow a @code{LF}
12338 character may or may not be treated as a page mark from the point of
12339 view of page and line numbering. Every @code{LF} character is considered
12340 to end a line, and there is an implied @code{LF} character at the end of
12344 * Text_IO Stream Pointer Positioning::
12345 * Text_IO Reading and Writing Non-Regular Files::
12347 * Treating Text_IO Files as Streams::
12348 * Text_IO Extensions::
12349 * Text_IO Facilities for Unbounded Strings::
12352 @node Text_IO Stream Pointer Positioning
12353 @subsection Stream Pointer Positioning
12356 @code{Ada.Text_IO} has a definition of current position for a file that
12357 is being read. No internal buffering occurs in Text_IO, and usually the
12358 physical position in the stream used to implement the file corresponds
12359 to this logical position defined by Text_IO@. There are two exceptions:
12363 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12364 is positioned past the @code{LF} (line mark) that precedes the page
12365 mark. Text_IO maintains an internal flag so that subsequent read
12366 operations properly handle the logical position which is unchanged by
12367 the @code{End_Of_Page} call.
12370 After a call to @code{End_Of_File} that returns @code{True}, if the
12371 Text_IO file was positioned before the line mark at the end of file
12372 before the call, then the logical position is unchanged, but the stream
12373 is physically positioned right at the end of file (past the line mark,
12374 and past a possible page mark following the line mark. Again Text_IO
12375 maintains internal flags so that subsequent read operations properly
12376 handle the logical position.
12380 These discrepancies have no effect on the observable behavior of
12381 Text_IO, but if a single Ada stream is shared between a C program and
12382 Ada program, or shared (using @samp{shared=yes} in the form string)
12383 between two Ada files, then the difference may be observable in some
12386 @node Text_IO Reading and Writing Non-Regular Files
12387 @subsection Reading and Writing Non-Regular Files
12390 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
12391 can be used for reading and writing. Writing is not affected and the
12392 sequence of characters output is identical to the normal file case, but
12393 for reading, the behavior of Text_IO is modified to avoid undesirable
12394 look-ahead as follows:
12396 An input file that is not a regular file is considered to have no page
12397 marks. Any @code{Ascii.FF} characters (the character normally used for a
12398 page mark) appearing in the file are considered to be data
12399 characters. In particular:
12403 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12404 following a line mark. If a page mark appears, it will be treated as a
12408 This avoids the need to wait for an extra character to be typed or
12409 entered from the pipe to complete one of these operations.
12412 @code{End_Of_Page} always returns @code{False}
12415 @code{End_Of_File} will return @code{False} if there is a page mark at
12416 the end of the file.
12420 Output to non-regular files is the same as for regular files. Page marks
12421 may be written to non-regular files using @code{New_Page}, but as noted
12422 above they will not be treated as page marks on input if the output is
12423 piped to another Ada program.
12425 Another important discrepancy when reading non-regular files is that the end
12426 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
12427 pressing the @key{EOT} key,
12429 is signaled once (i.e.@: the test @code{End_Of_File}
12430 will yield @code{True}, or a read will
12431 raise @code{End_Error}), but then reading can resume
12432 to read data past that end of
12433 file indication, until another end of file indication is entered.
12435 @node Get_Immediate
12436 @subsection Get_Immediate
12437 @cindex Get_Immediate
12440 Get_Immediate returns the next character (including control characters)
12441 from the input file. In particular, Get_Immediate will return LF or FF
12442 characters used as line marks or page marks. Such operations leave the
12443 file positioned past the control character, and it is thus not treated
12444 as having its normal function. This means that page, line and column
12445 counts after this kind of Get_Immediate call are set as though the mark
12446 did not occur. In the case where a Get_Immediate leaves the file
12447 positioned between the line mark and page mark (which is not normally
12448 possible), it is undefined whether the FF character will be treated as a
12451 @node Treating Text_IO Files as Streams
12452 @subsection Treating Text_IO Files as Streams
12453 @cindex Stream files
12456 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12457 as a stream. Data written to a Text_IO file in this stream mode is
12458 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
12459 16#0C# (@code{FF}), the resulting file may have non-standard
12460 format. Similarly if read operations are used to read from a Text_IO
12461 file treated as a stream, then @code{LF} and @code{FF} characters may be
12462 skipped and the effect is similar to that described above for
12463 @code{Get_Immediate}.
12465 @node Text_IO Extensions
12466 @subsection Text_IO Extensions
12467 @cindex Text_IO extensions
12470 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12471 to the standard @code{Text_IO} package:
12474 @item function File_Exists (Name : String) return Boolean;
12475 Determines if a file of the given name exists.
12477 @item function Get_Line return String;
12478 Reads a string from the standard input file. The value returned is exactly
12479 the length of the line that was read.
12481 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12482 Similar, except that the parameter File specifies the file from which
12483 the string is to be read.
12487 @node Text_IO Facilities for Unbounded Strings
12488 @subsection Text_IO Facilities for Unbounded Strings
12489 @cindex Text_IO for unbounded strings
12490 @cindex Unbounded_String, Text_IO operations
12493 The package @code{Ada.Strings.Unbounded.Text_IO}
12494 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12495 subprograms useful for Text_IO operations on unbounded strings:
12499 @item function Get_Line (File : File_Type) return Unbounded_String;
12500 Reads a line from the specified file
12501 and returns the result as an unbounded string.
12503 @item procedure Put (File : File_Type; U : Unbounded_String);
12504 Writes the value of the given unbounded string to the specified file
12505 Similar to the effect of
12506 @code{Put (To_String (U))} except that an extra copy is avoided.
12508 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12509 Writes the value of the given unbounded string to the specified file,
12510 followed by a @code{New_Line}.
12511 Similar to the effect of @code{Put_Line (To_String (U))} except
12512 that an extra copy is avoided.
12516 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12517 and is optional. If the parameter is omitted, then the standard input or
12518 output file is referenced as appropriate.
12520 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12521 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12522 @code{Wide_Text_IO} functionality for unbounded wide strings.
12524 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12525 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12526 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12529 @section Wide_Text_IO
12532 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12533 both input and output files may contain special sequences that represent
12534 wide character values. The encoding scheme for a given file may be
12535 specified using a FORM parameter:
12542 as part of the FORM string (WCEM = wide character encoding method),
12543 where @var{x} is one of the following characters
12549 Upper half encoding
12561 The encoding methods match those that
12562 can be used in a source
12563 program, but there is no requirement that the encoding method used for
12564 the source program be the same as the encoding method used for files,
12565 and different files may use different encoding methods.
12567 The default encoding method for the standard files, and for opened files
12568 for which no WCEM parameter is given in the FORM string matches the
12569 wide character encoding specified for the main program (the default
12570 being brackets encoding if no coding method was specified with -gnatW).
12574 In this encoding, a wide character is represented by a five character
12582 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12583 characters (using upper case letters) of the wide character code. For
12584 example, ESC A345 is used to represent the wide character with code
12585 16#A345#. This scheme is compatible with use of the full
12586 @code{Wide_Character} set.
12588 @item Upper Half Coding
12589 The wide character with encoding 16#abcd#, where the upper bit is on
12590 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12591 16#cd#. The second byte may never be a format control character, but is
12592 not required to be in the upper half. This method can be also used for
12593 shift-JIS or EUC where the internal coding matches the external coding.
12595 @item Shift JIS Coding
12596 A wide character is represented by a two character sequence 16#ab# and
12597 16#cd#, with the restrictions described for upper half encoding as
12598 described above. The internal character code is the corresponding JIS
12599 character according to the standard algorithm for Shift-JIS
12600 conversion. Only characters defined in the JIS code set table can be
12601 used with this encoding method.
12604 A wide character is represented by a two character sequence 16#ab# and
12605 16#cd#, with both characters being in the upper half. The internal
12606 character code is the corresponding JIS character according to the EUC
12607 encoding algorithm. Only characters defined in the JIS code set table
12608 can be used with this encoding method.
12611 A wide character is represented using
12612 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12613 10646-1/Am.2. Depending on the character value, the representation
12614 is a one, two, or three byte sequence:
12617 16#0000#-16#007f#: 2#0xxxxxxx#
12618 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12619 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12623 where the @var{xxx} bits correspond to the left-padded bits of the
12624 16-bit character value. Note that all lower half ASCII characters
12625 are represented as ASCII bytes and all upper half characters and
12626 other wide characters are represented as sequences of upper-half
12627 (The full UTF-8 scheme allows for encoding 31-bit characters as
12628 6-byte sequences, but in this implementation, all UTF-8 sequences
12629 of four or more bytes length will raise a Constraint_Error, as
12630 will all invalid UTF-8 sequences.)
12632 @item Brackets Coding
12633 In this encoding, a wide character is represented by the following eight
12634 character sequence:
12641 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12642 characters (using uppercase letters) of the wide character code. For
12643 example, @code{["A345"]} is used to represent the wide character with code
12645 This scheme is compatible with use of the full Wide_Character set.
12646 On input, brackets coding can also be used for upper half characters,
12647 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12648 is only used for wide characters with a code greater than @code{16#FF#}.
12650 Note that brackets coding is not normally used in the context of
12651 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12652 a portable way of encoding source files. In the context of Wide_Text_IO
12653 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12654 any instance of the left bracket character other than to encode wide
12655 character values using the brackets encoding method. In practice it is
12656 expected that some standard wide character encoding method such
12657 as UTF-8 will be used for text input output.
12659 If brackets notation is used, then any occurrence of a left bracket
12660 in the input file which is not the start of a valid wide character
12661 sequence will cause Constraint_Error to be raised. It is possible to
12662 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12663 input will interpret this as a left bracket.
12665 However, when a left bracket is output, it will be output as a left bracket
12666 and not as ["5B"]. We make this decision because for normal use of
12667 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12668 brackets. For example, if we write:
12671 Put_Line ("Start of output [first run]");
12675 we really do not want to have the left bracket in this message clobbered so
12676 that the output reads:
12679 Start of output ["5B"]first run]
12683 In practice brackets encoding is reasonably useful for normal Put_Line use
12684 since we won't get confused between left brackets and wide character
12685 sequences in the output. But for input, or when files are written out
12686 and read back in, it really makes better sense to use one of the standard
12687 encoding methods such as UTF-8.
12692 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12693 not all wide character
12694 values can be represented. An attempt to output a character that cannot
12695 be represented using the encoding scheme for the file causes
12696 Constraint_Error to be raised. An invalid wide character sequence on
12697 input also causes Constraint_Error to be raised.
12700 * Wide_Text_IO Stream Pointer Positioning::
12701 * Wide_Text_IO Reading and Writing Non-Regular Files::
12704 @node Wide_Text_IO Stream Pointer Positioning
12705 @subsection Stream Pointer Positioning
12708 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12709 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12712 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12713 normal lower ASCII set (i.e.@: a character in the range:
12715 @smallexample @c ada
12716 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12720 then although the logical position of the file pointer is unchanged by
12721 the @code{Look_Ahead} call, the stream is physically positioned past the
12722 wide character sequence. Again this is to avoid the need for buffering
12723 or backup, and all @code{Wide_Text_IO} routines check the internal
12724 indication that this situation has occurred so that this is not visible
12725 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
12726 can be observed if the wide text file shares a stream with another file.
12728 @node Wide_Text_IO Reading and Writing Non-Regular Files
12729 @subsection Reading and Writing Non-Regular Files
12732 As in the case of Text_IO, when a non-regular file is read, it is
12733 assumed that the file contains no page marks (any form characters are
12734 treated as data characters), and @code{End_Of_Page} always returns
12735 @code{False}. Similarly, the end of file indication is not sticky, so
12736 it is possible to read beyond an end of file.
12738 @node Wide_Wide_Text_IO
12739 @section Wide_Wide_Text_IO
12742 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12743 both input and output files may contain special sequences that represent
12744 wide wide character values. The encoding scheme for a given file may be
12745 specified using a FORM parameter:
12752 as part of the FORM string (WCEM = wide character encoding method),
12753 where @var{x} is one of the following characters
12759 Upper half encoding
12771 The encoding methods match those that
12772 can be used in a source
12773 program, but there is no requirement that the encoding method used for
12774 the source program be the same as the encoding method used for files,
12775 and different files may use different encoding methods.
12777 The default encoding method for the standard files, and for opened files
12778 for which no WCEM parameter is given in the FORM string matches the
12779 wide character encoding specified for the main program (the default
12780 being brackets encoding if no coding method was specified with -gnatW).
12785 A wide character is represented using
12786 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12787 10646-1/Am.2. Depending on the character value, the representation
12788 is a one, two, three, or four byte sequence:
12791 16#000000#-16#00007f#: 2#0xxxxxxx#
12792 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12793 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12794 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12798 where the @var{xxx} bits correspond to the left-padded bits of the
12799 21-bit character value. Note that all lower half ASCII characters
12800 are represented as ASCII bytes and all upper half characters and
12801 other wide characters are represented as sequences of upper-half
12804 @item Brackets Coding
12805 In this encoding, a wide wide character is represented by the following eight
12806 character sequence if is in wide character range
12812 and by the following ten character sequence if not
12815 [ " a b c d e f " ]
12819 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12820 are the four or six hexadecimal
12821 characters (using uppercase letters) of the wide wide character code. For
12822 example, @code{["01A345"]} is used to represent the wide wide character
12823 with code @code{16#01A345#}.
12825 This scheme is compatible with use of the full Wide_Wide_Character set.
12826 On input, brackets coding can also be used for upper half characters,
12827 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12828 is only used for wide characters with a code greater than @code{16#FF#}.
12833 If is also possible to use the other Wide_Character encoding methods,
12834 such as Shift-JIS, but the other schemes cannot support the full range
12835 of wide wide characters.
12836 An attempt to output a character that cannot
12837 be represented using the encoding scheme for the file causes
12838 Constraint_Error to be raised. An invalid wide character sequence on
12839 input also causes Constraint_Error to be raised.
12842 * Wide_Wide_Text_IO Stream Pointer Positioning::
12843 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12846 @node Wide_Wide_Text_IO Stream Pointer Positioning
12847 @subsection Stream Pointer Positioning
12850 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12851 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12854 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12855 normal lower ASCII set (i.e.@: a character in the range:
12857 @smallexample @c ada
12858 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12862 then although the logical position of the file pointer is unchanged by
12863 the @code{Look_Ahead} call, the stream is physically positioned past the
12864 wide character sequence. Again this is to avoid the need for buffering
12865 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
12866 indication that this situation has occurred so that this is not visible
12867 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
12868 can be observed if the wide text file shares a stream with another file.
12870 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
12871 @subsection Reading and Writing Non-Regular Files
12874 As in the case of Text_IO, when a non-regular file is read, it is
12875 assumed that the file contains no page marks (any form characters are
12876 treated as data characters), and @code{End_Of_Page} always returns
12877 @code{False}. Similarly, the end of file indication is not sticky, so
12878 it is possible to read beyond an end of file.
12884 A stream file is a sequence of bytes, where individual elements are
12885 written to the file as described in the Ada Reference Manual. The type
12886 @code{Stream_Element} is simply a byte. There are two ways to read or
12887 write a stream file.
12891 The operations @code{Read} and @code{Write} directly read or write a
12892 sequence of stream elements with no control information.
12895 The stream attributes applied to a stream file transfer data in the
12896 manner described for stream attributes.
12900 @section Shared Files
12903 Section A.14 of the Ada Reference Manual allows implementations to
12904 provide a wide variety of behavior if an attempt is made to access the
12905 same external file with two or more internal files.
12907 To provide a full range of functionality, while at the same time
12908 minimizing the problems of portability caused by this implementation
12909 dependence, GNAT handles file sharing as follows:
12913 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
12914 to open two or more files with the same full name is considered an error
12915 and is not supported. The exception @code{Use_Error} will be
12916 raised. Note that a file that is not explicitly closed by the program
12917 remains open until the program terminates.
12920 If the form parameter @samp{shared=no} appears in the form string, the
12921 file can be opened or created with its own separate stream identifier,
12922 regardless of whether other files sharing the same external file are
12923 opened. The exact effect depends on how the C stream routines handle
12924 multiple accesses to the same external files using separate streams.
12927 If the form parameter @samp{shared=yes} appears in the form string for
12928 each of two or more files opened using the same full name, the same
12929 stream is shared between these files, and the semantics are as described
12930 in Ada Reference Manual, Section A.14.
12934 When a program that opens multiple files with the same name is ported
12935 from another Ada compiler to GNAT, the effect will be that
12936 @code{Use_Error} is raised.
12938 The documentation of the original compiler and the documentation of the
12939 program should then be examined to determine if file sharing was
12940 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
12941 and @code{Create} calls as required.
12943 When a program is ported from GNAT to some other Ada compiler, no
12944 special attention is required unless the @samp{shared=@var{xxx}} form
12945 parameter is used in the program. In this case, you must examine the
12946 documentation of the new compiler to see if it supports the required
12947 file sharing semantics, and form strings modified appropriately. Of
12948 course it may be the case that the program cannot be ported if the
12949 target compiler does not support the required functionality. The best
12950 approach in writing portable code is to avoid file sharing (and hence
12951 the use of the @samp{shared=@var{xxx}} parameter in the form string)
12954 One common use of file sharing in Ada 83 is the use of instantiations of
12955 Sequential_IO on the same file with different types, to achieve
12956 heterogeneous input-output. Although this approach will work in GNAT if
12957 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
12958 for this purpose (using the stream attributes)
12960 @node Filenames encoding
12961 @section Filenames encoding
12964 An encoding form parameter can be used to specify the filename
12965 encoding @samp{encoding=@var{xxx}}.
12969 If the form parameter @samp{encoding=utf8} appears in the form string, the
12970 filename must be encoded in UTF-8.
12973 If the form parameter @samp{encoding=8bits} appears in the form
12974 string, the filename must be a standard 8bits string.
12977 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
12978 value UTF-8 is used. This encoding form parameter is only supported on
12979 the Windows platform. On the other Operating Systems the runtime is
12980 supporting UTF-8 natively.
12983 @section Open Modes
12986 @code{Open} and @code{Create} calls result in a call to @code{fopen}
12987 using the mode shown in the following table:
12990 @center @code{Open} and @code{Create} Call Modes
12992 @b{OPEN } @b{CREATE}
12993 Append_File "r+" "w+"
12995 Out_File (Direct_IO) "r+" "w"
12996 Out_File (all other cases) "w" "w"
12997 Inout_File "r+" "w+"
13001 If text file translation is required, then either @samp{b} or @samp{t}
13002 is added to the mode, depending on the setting of Text. Text file
13003 translation refers to the mapping of CR/LF sequences in an external file
13004 to LF characters internally. This mapping only occurs in DOS and
13005 DOS-like systems, and is not relevant to other systems.
13007 A special case occurs with Stream_IO@. As shown in the above table, the
13008 file is initially opened in @samp{r} or @samp{w} mode for the
13009 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
13010 subsequently requires switching from reading to writing or vice-versa,
13011 then the file is reopened in @samp{r+} mode to permit the required operation.
13013 @node Operations on C Streams
13014 @section Operations on C Streams
13015 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13016 access to the C library functions for operations on C streams:
13018 @smallexample @c adanocomment
13019 package Interfaces.C_Streams is
13020 -- Note: the reason we do not use the types that are in
13021 -- Interfaces.C is that we want to avoid dragging in the
13022 -- code in this unit if possible.
13023 subtype chars is System.Address;
13024 -- Pointer to null-terminated array of characters
13025 subtype FILEs is System.Address;
13026 -- Corresponds to the C type FILE*
13027 subtype voids is System.Address;
13028 -- Corresponds to the C type void*
13029 subtype int is Integer;
13030 subtype long is Long_Integer;
13031 -- Note: the above types are subtypes deliberately, and it
13032 -- is part of this spec that the above correspondences are
13033 -- guaranteed. This means that it is legitimate to, for
13034 -- example, use Integer instead of int. We provide these
13035 -- synonyms for clarity, but in some cases it may be
13036 -- convenient to use the underlying types (for example to
13037 -- avoid an unnecessary dependency of a spec on the spec
13039 type size_t is mod 2 ** Standard'Address_Size;
13040 NULL_Stream : constant FILEs;
13041 -- Value returned (NULL in C) to indicate an
13042 -- fdopen/fopen/tmpfile error
13043 ----------------------------------
13044 -- Constants Defined in stdio.h --
13045 ----------------------------------
13046 EOF : constant int;
13047 -- Used by a number of routines to indicate error or
13049 IOFBF : constant int;
13050 IOLBF : constant int;
13051 IONBF : constant int;
13052 -- Used to indicate buffering mode for setvbuf call
13053 SEEK_CUR : constant int;
13054 SEEK_END : constant int;
13055 SEEK_SET : constant int;
13056 -- Used to indicate origin for fseek call
13057 function stdin return FILEs;
13058 function stdout return FILEs;
13059 function stderr return FILEs;
13060 -- Streams associated with standard files
13061 --------------------------
13062 -- Standard C functions --
13063 --------------------------
13064 -- The functions selected below are ones that are
13065 -- available in DOS, OS/2, UNIX and Xenix (but not
13066 -- necessarily in ANSI C). These are very thin interfaces
13067 -- which copy exactly the C headers. For more
13068 -- documentation on these functions, see the Microsoft C
13069 -- "Run-Time Library Reference" (Microsoft Press, 1990,
13070 -- ISBN 1-55615-225-6), which includes useful information
13071 -- on system compatibility.
13072 procedure clearerr (stream : FILEs);
13073 function fclose (stream : FILEs) return int;
13074 function fdopen (handle : int; mode : chars) return FILEs;
13075 function feof (stream : FILEs) return int;
13076 function ferror (stream : FILEs) return int;
13077 function fflush (stream : FILEs) return int;
13078 function fgetc (stream : FILEs) return int;
13079 function fgets (strng : chars; n : int; stream : FILEs)
13081 function fileno (stream : FILEs) return int;
13082 function fopen (filename : chars; Mode : chars)
13084 -- Note: to maintain target independence, use
13085 -- text_translation_required, a boolean variable defined in
13086 -- a-sysdep.c to deal with the target dependent text
13087 -- translation requirement. If this variable is set,
13088 -- then b/t should be appended to the standard mode
13089 -- argument to set the text translation mode off or on
13091 function fputc (C : int; stream : FILEs) return int;
13092 function fputs (Strng : chars; Stream : FILEs) return int;
13109 function ftell (stream : FILEs) return long;
13116 function isatty (handle : int) return int;
13117 procedure mktemp (template : chars);
13118 -- The return value (which is just a pointer to template)
13120 procedure rewind (stream : FILEs);
13121 function rmtmp return int;
13129 function tmpfile return FILEs;
13130 function ungetc (c : int; stream : FILEs) return int;
13131 function unlink (filename : chars) return int;
13132 ---------------------
13133 -- Extra functions --
13134 ---------------------
13135 -- These functions supply slightly thicker bindings than
13136 -- those above. They are derived from functions in the
13137 -- C Run-Time Library, but may do a bit more work than
13138 -- just directly calling one of the Library functions.
13139 function is_regular_file (handle : int) return int;
13140 -- Tests if given handle is for a regular file (result 1)
13141 -- or for a non-regular file (pipe or device, result 0).
13142 ---------------------------------
13143 -- Control of Text/Binary Mode --
13144 ---------------------------------
13145 -- If text_translation_required is true, then the following
13146 -- functions may be used to dynamically switch a file from
13147 -- binary to text mode or vice versa. These functions have
13148 -- no effect if text_translation_required is false (i.e.@: in
13149 -- normal UNIX mode). Use fileno to get a stream handle.
13150 procedure set_binary_mode (handle : int);
13151 procedure set_text_mode (handle : int);
13152 ----------------------------
13153 -- Full Path Name support --
13154 ----------------------------
13155 procedure full_name (nam : chars; buffer : chars);
13156 -- Given a NUL terminated string representing a file
13157 -- name, returns in buffer a NUL terminated string
13158 -- representing the full path name for the file name.
13159 -- On systems where it is relevant the drive is also
13160 -- part of the full path name. It is the responsibility
13161 -- of the caller to pass an actual parameter for buffer
13162 -- that is big enough for any full path name. Use
13163 -- max_path_len given below as the size of buffer.
13164 max_path_len : integer;
13165 -- Maximum length of an allowable full path name on the
13166 -- system, including a terminating NUL character.
13167 end Interfaces.C_Streams;
13170 @node Interfacing to C Streams
13171 @section Interfacing to C Streams
13174 The packages in this section permit interfacing Ada files to C Stream
13177 @smallexample @c ada
13178 with Interfaces.C_Streams;
13179 package Ada.Sequential_IO.C_Streams is
13180 function C_Stream (F : File_Type)
13181 return Interfaces.C_Streams.FILEs;
13183 (File : in out File_Type;
13184 Mode : in File_Mode;
13185 C_Stream : in Interfaces.C_Streams.FILEs;
13186 Form : in String := "");
13187 end Ada.Sequential_IO.C_Streams;
13189 with Interfaces.C_Streams;
13190 package Ada.Direct_IO.C_Streams is
13191 function C_Stream (F : File_Type)
13192 return Interfaces.C_Streams.FILEs;
13194 (File : in out File_Type;
13195 Mode : in File_Mode;
13196 C_Stream : in Interfaces.C_Streams.FILEs;
13197 Form : in String := "");
13198 end Ada.Direct_IO.C_Streams;
13200 with Interfaces.C_Streams;
13201 package Ada.Text_IO.C_Streams is
13202 function C_Stream (F : File_Type)
13203 return Interfaces.C_Streams.FILEs;
13205 (File : in out File_Type;
13206 Mode : in File_Mode;
13207 C_Stream : in Interfaces.C_Streams.FILEs;
13208 Form : in String := "");
13209 end Ada.Text_IO.C_Streams;
13211 with Interfaces.C_Streams;
13212 package Ada.Wide_Text_IO.C_Streams is
13213 function C_Stream (F : File_Type)
13214 return Interfaces.C_Streams.FILEs;
13216 (File : in out File_Type;
13217 Mode : in File_Mode;
13218 C_Stream : in Interfaces.C_Streams.FILEs;
13219 Form : in String := "");
13220 end Ada.Wide_Text_IO.C_Streams;
13222 with Interfaces.C_Streams;
13223 package Ada.Wide_Wide_Text_IO.C_Streams is
13224 function C_Stream (F : File_Type)
13225 return Interfaces.C_Streams.FILEs;
13227 (File : in out File_Type;
13228 Mode : in File_Mode;
13229 C_Stream : in Interfaces.C_Streams.FILEs;
13230 Form : in String := "");
13231 end Ada.Wide_Wide_Text_IO.C_Streams;
13233 with Interfaces.C_Streams;
13234 package Ada.Stream_IO.C_Streams is
13235 function C_Stream (F : File_Type)
13236 return Interfaces.C_Streams.FILEs;
13238 (File : in out File_Type;
13239 Mode : in File_Mode;
13240 C_Stream : in Interfaces.C_Streams.FILEs;
13241 Form : in String := "");
13242 end Ada.Stream_IO.C_Streams;
13246 In each of these six packages, the @code{C_Stream} function obtains the
13247 @code{FILE} pointer from a currently opened Ada file. It is then
13248 possible to use the @code{Interfaces.C_Streams} package to operate on
13249 this stream, or the stream can be passed to a C program which can
13250 operate on it directly. Of course the program is responsible for
13251 ensuring that only appropriate sequences of operations are executed.
13253 One particular use of relevance to an Ada program is that the
13254 @code{setvbuf} function can be used to control the buffering of the
13255 stream used by an Ada file. In the absence of such a call the standard
13256 default buffering is used.
13258 The @code{Open} procedures in these packages open a file giving an
13259 existing C Stream instead of a file name. Typically this stream is
13260 imported from a C program, allowing an Ada file to operate on an
13263 @node The GNAT Library
13264 @chapter The GNAT Library
13267 The GNAT library contains a number of general and special purpose packages.
13268 It represents functionality that the GNAT developers have found useful, and
13269 which is made available to GNAT users. The packages described here are fully
13270 supported, and upwards compatibility will be maintained in future releases,
13271 so you can use these facilities with the confidence that the same functionality
13272 will be available in future releases.
13274 The chapter here simply gives a brief summary of the facilities available.
13275 The full documentation is found in the spec file for the package. The full
13276 sources of these library packages, including both spec and body, are provided
13277 with all GNAT releases. For example, to find out the full specifications of
13278 the SPITBOL pattern matching capability, including a full tutorial and
13279 extensive examples, look in the @file{g-spipat.ads} file in the library.
13281 For each entry here, the package name (as it would appear in a @code{with}
13282 clause) is given, followed by the name of the corresponding spec file in
13283 parentheses. The packages are children in four hierarchies, @code{Ada},
13284 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13285 GNAT-specific hierarchy.
13287 Note that an application program should only use packages in one of these
13288 four hierarchies if the package is defined in the Ada Reference Manual,
13289 or is listed in this section of the GNAT Programmers Reference Manual.
13290 All other units should be considered internal implementation units and
13291 should not be directly @code{with}'ed by application code. The use of
13292 a @code{with} statement that references one of these internal implementation
13293 units makes an application potentially dependent on changes in versions
13294 of GNAT, and will generate a warning message.
13297 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13298 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13299 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13300 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13301 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13302 * Ada.Command_Line.Environment (a-colien.ads)::
13303 * Ada.Command_Line.Remove (a-colire.ads)::
13304 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13305 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13306 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13307 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13308 * Ada.Exceptions.Traceback (a-exctra.ads)::
13309 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13310 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13311 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13312 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13313 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13314 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13315 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13316 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13317 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13318 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13319 * GNAT.Altivec (g-altive.ads)::
13320 * GNAT.Altivec.Conversions (g-altcon.ads)::
13321 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13322 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13323 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13324 * GNAT.Array_Split (g-arrspl.ads)::
13325 * GNAT.AWK (g-awk.ads)::
13326 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13327 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13328 * GNAT.Bubble_Sort (g-bubsor.ads)::
13329 * GNAT.Bubble_Sort_A (g-busora.ads)::
13330 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13331 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13332 * GNAT.Byte_Swapping (g-bytswa.ads)::
13333 * GNAT.Calendar (g-calend.ads)::
13334 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13335 * GNAT.Case_Util (g-casuti.ads)::
13336 * GNAT.CGI (g-cgi.ads)::
13337 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13338 * GNAT.CGI.Debug (g-cgideb.ads)::
13339 * GNAT.Command_Line (g-comlin.ads)::
13340 * GNAT.Compiler_Version (g-comver.ads)::
13341 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13342 * GNAT.CRC32 (g-crc32.ads)::
13343 * GNAT.Current_Exception (g-curexc.ads)::
13344 * GNAT.Debug_Pools (g-debpoo.ads)::
13345 * GNAT.Debug_Utilities (g-debuti.ads)::
13346 * GNAT.Decode_String (g-decstr.ads)::
13347 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13348 * GNAT.Directory_Operations (g-dirope.ads)::
13349 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13350 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13351 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13352 * GNAT.Encode_String (g-encstr.ads)::
13353 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13354 * GNAT.Exception_Actions (g-excact.ads)::
13355 * GNAT.Exception_Traces (g-exctra.ads)::
13356 * GNAT.Exceptions (g-except.ads)::
13357 * GNAT.Expect (g-expect.ads)::
13358 * GNAT.Float_Control (g-flocon.ads)::
13359 * GNAT.Heap_Sort (g-heasor.ads)::
13360 * GNAT.Heap_Sort_A (g-hesora.ads)::
13361 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13362 * GNAT.HTable (g-htable.ads)::
13363 * GNAT.IO (g-io.ads)::
13364 * GNAT.IO_Aux (g-io_aux.ads)::
13365 * GNAT.Lock_Files (g-locfil.ads)::
13366 * GNAT.MD5 (g-md5.ads)::
13367 * GNAT.Memory_Dump (g-memdum.ads)::
13368 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13369 * GNAT.OS_Lib (g-os_lib.ads)::
13370 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13371 * GNAT.Random_Numbers (g-rannum.ads)::
13372 * GNAT.Regexp (g-regexp.ads)::
13373 * GNAT.Registry (g-regist.ads)::
13374 * GNAT.Regpat (g-regpat.ads)::
13375 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13376 * GNAT.Semaphores (g-semaph.ads)::
13377 * GNAT.Serial_Communications (g-sercom.ads)::
13378 * GNAT.SHA1 (g-sha1.ads)::
13379 * GNAT.Signals (g-signal.ads)::
13380 * GNAT.Sockets (g-socket.ads)::
13381 * GNAT.Source_Info (g-souinf.ads)::
13382 * GNAT.Spelling_Checker (g-speche.ads)::
13383 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13384 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13385 * GNAT.Spitbol (g-spitbo.ads)::
13386 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13387 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13388 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13389 * GNAT.Strings (g-string.ads)::
13390 * GNAT.String_Split (g-strspl.ads)::
13391 * GNAT.Table (g-table.ads)::
13392 * GNAT.Task_Lock (g-tasloc.ads)::
13393 * GNAT.Threads (g-thread.ads)::
13394 * GNAT.Time_Stamp (g-timsta.ads)::
13395 * GNAT.Traceback (g-traceb.ads)::
13396 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13397 * GNAT.UTF_32 (g-utf_32.ads)::
13398 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13399 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13400 * GNAT.Wide_String_Split (g-wistsp.ads)::
13401 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13402 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13403 * Interfaces.C.Extensions (i-cexten.ads)::
13404 * Interfaces.C.Streams (i-cstrea.ads)::
13405 * Interfaces.CPP (i-cpp.ads)::
13406 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13407 * Interfaces.VxWorks (i-vxwork.ads)::
13408 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13409 * System.Address_Image (s-addima.ads)::
13410 * System.Assertions (s-assert.ads)::
13411 * System.Memory (s-memory.ads)::
13412 * System.Partition_Interface (s-parint.ads)::
13413 * System.Pool_Global (s-pooglo.ads)::
13414 * System.Pool_Local (s-pooloc.ads)::
13415 * System.Restrictions (s-restri.ads)::
13416 * System.Rident (s-rident.ads)::
13417 * System.Task_Info (s-tasinf.ads)::
13418 * System.Wch_Cnv (s-wchcnv.ads)::
13419 * System.Wch_Con (s-wchcon.ads)::
13422 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13423 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13424 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13425 @cindex Latin_9 constants for Character
13428 This child of @code{Ada.Characters}
13429 provides a set of definitions corresponding to those in the
13430 RM-defined package @code{Ada.Characters.Latin_1} but with the
13431 few modifications required for @code{Latin-9}
13432 The provision of such a package
13433 is specifically authorized by the Ada Reference Manual
13436 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13437 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13438 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13439 @cindex Latin_1 constants for Wide_Character
13442 This child of @code{Ada.Characters}
13443 provides a set of definitions corresponding to those in the
13444 RM-defined package @code{Ada.Characters.Latin_1} but with the
13445 types of the constants being @code{Wide_Character}
13446 instead of @code{Character}. The provision of such a package
13447 is specifically authorized by the Ada Reference Manual
13450 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13451 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13452 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13453 @cindex Latin_9 constants for Wide_Character
13456 This child of @code{Ada.Characters}
13457 provides a set of definitions corresponding to those in the
13458 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13459 types of the constants being @code{Wide_Character}
13460 instead of @code{Character}. The provision of such a package
13461 is specifically authorized by the Ada Reference Manual
13464 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13465 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13466 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13467 @cindex Latin_1 constants for Wide_Wide_Character
13470 This child of @code{Ada.Characters}
13471 provides a set of definitions corresponding to those in the
13472 RM-defined package @code{Ada.Characters.Latin_1} but with the
13473 types of the constants being @code{Wide_Wide_Character}
13474 instead of @code{Character}. The provision of such a package
13475 is specifically authorized by the Ada Reference Manual
13478 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13479 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13480 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13481 @cindex Latin_9 constants for Wide_Wide_Character
13484 This child of @code{Ada.Characters}
13485 provides a set of definitions corresponding to those in the
13486 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13487 types of the constants being @code{Wide_Wide_Character}
13488 instead of @code{Character}. The provision of such a package
13489 is specifically authorized by the Ada Reference Manual
13492 @node Ada.Command_Line.Environment (a-colien.ads)
13493 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13494 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13495 @cindex Environment entries
13498 This child of @code{Ada.Command_Line}
13499 provides a mechanism for obtaining environment values on systems
13500 where this concept makes sense.
13502 @node Ada.Command_Line.Remove (a-colire.ads)
13503 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13504 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13505 @cindex Removing command line arguments
13506 @cindex Command line, argument removal
13509 This child of @code{Ada.Command_Line}
13510 provides a mechanism for logically removing
13511 arguments from the argument list. Once removed, an argument is not visible
13512 to further calls on the subprograms in @code{Ada.Command_Line} will not
13513 see the removed argument.
13515 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13516 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13517 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13518 @cindex Response file for command line
13519 @cindex Command line, response file
13520 @cindex Command line, handling long command lines
13523 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13524 getting command line arguments from a text file, called a "response file".
13525 Using a response file allow passing a set of arguments to an executable longer
13526 than the maximum allowed by the system on the command line.
13528 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13529 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13530 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13531 @cindex C Streams, Interfacing with Direct_IO
13534 This package provides subprograms that allow interfacing between
13535 C streams and @code{Direct_IO}. The stream identifier can be
13536 extracted from a file opened on the Ada side, and an Ada file
13537 can be constructed from a stream opened on the C side.
13539 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13540 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13541 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13542 @cindex Null_Occurrence, testing for
13545 This child subprogram provides a way of testing for the null
13546 exception occurrence (@code{Null_Occurrence}) without raising
13549 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13550 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13551 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13552 @cindex Null_Occurrence, testing for
13555 This child subprogram is used for handling otherwise unhandled
13556 exceptions (hence the name last chance), and perform clean ups before
13557 terminating the program. Note that this subprogram never returns.
13559 @node Ada.Exceptions.Traceback (a-exctra.ads)
13560 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13561 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13562 @cindex Traceback for Exception Occurrence
13565 This child package provides the subprogram (@code{Tracebacks}) to
13566 give a traceback array of addresses based on an exception
13569 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13570 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13571 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13572 @cindex C Streams, Interfacing with Sequential_IO
13575 This package provides subprograms that allow interfacing between
13576 C streams and @code{Sequential_IO}. The stream identifier can be
13577 extracted from a file opened on the Ada side, and an Ada file
13578 can be constructed from a stream opened on the C side.
13580 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13581 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13582 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13583 @cindex C Streams, Interfacing with Stream_IO
13586 This package provides subprograms that allow interfacing between
13587 C streams and @code{Stream_IO}. The stream identifier can be
13588 extracted from a file opened on the Ada side, and an Ada file
13589 can be constructed from a stream opened on the C side.
13591 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13592 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13593 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13594 @cindex @code{Unbounded_String}, IO support
13595 @cindex @code{Text_IO}, extensions for unbounded strings
13598 This package provides subprograms for Text_IO for unbounded
13599 strings, avoiding the necessity for an intermediate operation
13600 with ordinary strings.
13602 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13603 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13604 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13605 @cindex @code{Unbounded_Wide_String}, IO support
13606 @cindex @code{Text_IO}, extensions for unbounded wide strings
13609 This package provides subprograms for Text_IO for unbounded
13610 wide strings, avoiding the necessity for an intermediate operation
13611 with ordinary wide strings.
13613 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13614 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13615 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13616 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13617 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13620 This package provides subprograms for Text_IO for unbounded
13621 wide wide strings, avoiding the necessity for an intermediate operation
13622 with ordinary wide wide strings.
13624 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13625 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13626 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13627 @cindex C Streams, Interfacing with @code{Text_IO}
13630 This package provides subprograms that allow interfacing between
13631 C streams and @code{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 Ada.Wide_Characters.Unicode (a-wichun.ads)
13636 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13637 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13638 @cindex Unicode categorization, Wide_Character
13641 This package provides subprograms that allow categorization of
13642 Wide_Character values according to Unicode categories.
13644 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13645 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13646 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13647 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13650 This package provides subprograms that allow interfacing between
13651 C streams and @code{Wide_Text_IO}. The stream identifier can be
13652 extracted from a file opened on the Ada side, and an Ada file
13653 can be constructed from a stream opened on the C side.
13655 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13656 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13657 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13658 @cindex Unicode categorization, Wide_Wide_Character
13661 This package provides subprograms that allow categorization of
13662 Wide_Wide_Character values according to Unicode categories.
13664 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13665 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13666 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13667 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13670 This package provides subprograms that allow interfacing between
13671 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
13672 extracted from a file opened on the Ada side, and an Ada file
13673 can be constructed from a stream opened on the C side.
13675 @node GNAT.Altivec (g-altive.ads)
13676 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13677 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13681 This is the root package of the GNAT AltiVec binding. It provides
13682 definitions of constants and types common to all the versions of the
13685 @node GNAT.Altivec.Conversions (g-altcon.ads)
13686 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13687 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13691 This package provides the Vector/View conversion routines.
13693 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13694 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13695 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13699 This package exposes the Ada interface to the AltiVec operations on
13700 vector objects. A soft emulation is included by default in the GNAT
13701 library. The hard binding is provided as a separate package. This unit
13702 is common to both bindings.
13704 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13705 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13706 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13710 This package exposes the various vector types part of the Ada binding
13711 to AltiVec facilities.
13713 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13714 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13715 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13719 This package provides public 'View' data types from/to which private
13720 vector representations can be converted via
13721 GNAT.Altivec.Conversions. This allows convenient access to individual
13722 vector elements and provides a simple way to initialize vector
13725 @node GNAT.Array_Split (g-arrspl.ads)
13726 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13727 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13728 @cindex Array splitter
13731 Useful array-manipulation routines: given a set of separators, split
13732 an array wherever the separators appear, and provide direct access
13733 to the resulting slices.
13735 @node GNAT.AWK (g-awk.ads)
13736 @section @code{GNAT.AWK} (@file{g-awk.ads})
13737 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13742 Provides AWK-like parsing functions, with an easy interface for parsing one
13743 or more files containing formatted data. The file is viewed as a database
13744 where each record is a line and a field is a data element in this line.
13746 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13747 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13748 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13750 @cindex Bounded Buffers
13753 Provides a concurrent generic bounded buffer abstraction. Instances are
13754 useful directly or as parts of the implementations of other abstractions,
13757 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13758 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13759 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13764 Provides a thread-safe asynchronous intertask mailbox communication facility.
13766 @node GNAT.Bubble_Sort (g-bubsor.ads)
13767 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13768 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13770 @cindex Bubble sort
13773 Provides a general implementation of bubble sort usable for sorting arbitrary
13774 data items. Exchange and comparison procedures are provided by passing
13775 access-to-procedure values.
13777 @node GNAT.Bubble_Sort_A (g-busora.ads)
13778 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13779 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13781 @cindex Bubble sort
13784 Provides a general implementation of bubble sort usable for sorting arbitrary
13785 data items. Move and comparison procedures are provided by passing
13786 access-to-procedure values. This is an older version, retained for
13787 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13789 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13790 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13791 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13793 @cindex Bubble sort
13796 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13797 are provided as generic parameters, this improves efficiency, especially
13798 if the procedures can be inlined, at the expense of duplicating code for
13799 multiple instantiations.
13801 @node GNAT.Byte_Order_Mark (g-byorma.ads)
13802 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13803 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13804 @cindex UTF-8 representation
13805 @cindex Wide characte representations
13808 Provides a routine which given a string, reads the start of the string to
13809 see whether it is one of the standard byte order marks (BOM's) which signal
13810 the encoding of the string. The routine includes detection of special XML
13811 sequences for various UCS input formats.
13813 @node GNAT.Byte_Swapping (g-bytswa.ads)
13814 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13815 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13816 @cindex Byte swapping
13820 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13821 Machine-specific implementations are available in some cases.
13823 @node GNAT.Calendar (g-calend.ads)
13824 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13825 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13826 @cindex @code{Calendar}
13829 Extends the facilities provided by @code{Ada.Calendar} to include handling
13830 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13831 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
13832 C @code{timeval} format.
13834 @node GNAT.Calendar.Time_IO (g-catiio.ads)
13835 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13836 @cindex @code{Calendar}
13838 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13840 @node GNAT.CRC32 (g-crc32.ads)
13841 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
13842 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
13844 @cindex Cyclic Redundancy Check
13847 This package implements the CRC-32 algorithm. For a full description
13848 of this algorithm see
13849 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
13850 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
13851 Aug.@: 1988. Sarwate, D.V@.
13853 @node GNAT.Case_Util (g-casuti.ads)
13854 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
13855 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
13856 @cindex Casing utilities
13857 @cindex Character handling (@code{GNAT.Case_Util})
13860 A set of simple routines for handling upper and lower casing of strings
13861 without the overhead of the full casing tables
13862 in @code{Ada.Characters.Handling}.
13864 @node GNAT.CGI (g-cgi.ads)
13865 @section @code{GNAT.CGI} (@file{g-cgi.ads})
13866 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
13867 @cindex CGI (Common Gateway Interface)
13870 This is a package for interfacing a GNAT program with a Web server via the
13871 Common Gateway Interface (CGI)@. Basically this package parses the CGI
13872 parameters, which are a set of key/value pairs sent by the Web server. It
13873 builds a table whose index is the key and provides some services to deal
13876 @node GNAT.CGI.Cookie (g-cgicoo.ads)
13877 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13878 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13879 @cindex CGI (Common Gateway Interface) cookie support
13880 @cindex Cookie support in CGI
13883 This is a package to interface a GNAT program with a Web server via the
13884 Common Gateway Interface (CGI). It exports services to deal with Web
13885 cookies (piece of information kept in the Web client software).
13887 @node GNAT.CGI.Debug (g-cgideb.ads)
13888 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13889 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13890 @cindex CGI (Common Gateway Interface) debugging
13893 This is a package to help debugging CGI (Common Gateway Interface)
13894 programs written in Ada.
13896 @node GNAT.Command_Line (g-comlin.ads)
13897 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
13898 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
13899 @cindex Command line
13902 Provides a high level interface to @code{Ada.Command_Line} facilities,
13903 including the ability to scan for named switches with optional parameters
13904 and expand file names using wild card notations.
13906 @node GNAT.Compiler_Version (g-comver.ads)
13907 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13908 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13909 @cindex Compiler Version
13910 @cindex Version, of compiler
13913 Provides a routine for obtaining the version of the compiler used to
13914 compile the program. More accurately this is the version of the binder
13915 used to bind the program (this will normally be the same as the version
13916 of the compiler if a consistent tool set is used to compile all units
13919 @node GNAT.Ctrl_C (g-ctrl_c.ads)
13920 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13921 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13925 Provides a simple interface to handle Ctrl-C keyboard events.
13927 @node GNAT.Current_Exception (g-curexc.ads)
13928 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13929 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13930 @cindex Current exception
13931 @cindex Exception retrieval
13934 Provides access to information on the current exception that has been raised
13935 without the need for using the Ada 95 / Ada 2005 exception choice parameter
13936 specification syntax.
13937 This is particularly useful in simulating typical facilities for
13938 obtaining information about exceptions provided by Ada 83 compilers.
13940 @node GNAT.Debug_Pools (g-debpoo.ads)
13941 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13942 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13944 @cindex Debug pools
13945 @cindex Memory corruption debugging
13948 Provide a debugging storage pools that helps tracking memory corruption
13949 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
13950 @value{EDITION} User's Guide}.
13952 @node GNAT.Debug_Utilities (g-debuti.ads)
13953 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13954 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13958 Provides a few useful utilities for debugging purposes, including conversion
13959 to and from string images of address values. Supports both C and Ada formats
13960 for hexadecimal literals.
13962 @node GNAT.Decode_String (g-decstr.ads)
13963 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
13964 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
13965 @cindex Decoding strings
13966 @cindex String decoding
13967 @cindex Wide character encoding
13972 A generic package providing routines for decoding wide character and wide wide
13973 character strings encoded as sequences of 8-bit characters using a specified
13974 encoding method. Includes validation routines, and also routines for stepping
13975 to next or previous encoded character in an encoded string.
13976 Useful in conjunction with Unicode character coding. Note there is a
13977 preinstantiation for UTF-8. See next entry.
13979 @node GNAT.Decode_UTF8_String (g-deutst.ads)
13980 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13981 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13982 @cindex Decoding strings
13983 @cindex Decoding UTF-8 strings
13984 @cindex UTF-8 string decoding
13985 @cindex Wide character decoding
13990 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
13992 @node GNAT.Directory_Operations (g-dirope.ads)
13993 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13994 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13995 @cindex Directory operations
13998 Provides a set of routines for manipulating directories, including changing
13999 the current directory, making new directories, and scanning the files in a
14002 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14003 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14004 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14005 @cindex Directory operations iteration
14008 A child unit of GNAT.Directory_Operations providing additional operations
14009 for iterating through directories.
14011 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14012 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14013 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14014 @cindex Hash tables
14017 A generic implementation of hash tables that can be used to hash arbitrary
14018 data. Provided in two forms, a simple form with built in hash functions,
14019 and a more complex form in which the hash function is supplied.
14022 This package provides a facility similar to that of @code{GNAT.HTable},
14023 except that this package declares a type that can be used to define
14024 dynamic instances of the hash table, while an instantiation of
14025 @code{GNAT.HTable} creates a single instance of the hash table.
14027 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14028 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14029 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14030 @cindex Table implementation
14031 @cindex Arrays, extendable
14034 A generic package providing a single dimension array abstraction where the
14035 length of the array can be dynamically modified.
14038 This package provides a facility similar to that of @code{GNAT.Table},
14039 except that this package declares a type that can be used to define
14040 dynamic instances of the table, while an instantiation of
14041 @code{GNAT.Table} creates a single instance of the table type.
14043 @node GNAT.Encode_String (g-encstr.ads)
14044 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14045 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14046 @cindex Encoding strings
14047 @cindex String encoding
14048 @cindex Wide character encoding
14053 A generic package providing routines for encoding wide character and wide
14054 wide character strings as sequences of 8-bit characters using a specified
14055 encoding method. Useful in conjunction with Unicode character coding.
14056 Note there is a preinstantiation for UTF-8. See next entry.
14058 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14059 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14060 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14061 @cindex Encoding strings
14062 @cindex Encoding UTF-8 strings
14063 @cindex UTF-8 string encoding
14064 @cindex Wide character encoding
14069 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14071 @node GNAT.Exception_Actions (g-excact.ads)
14072 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14073 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14074 @cindex Exception actions
14077 Provides callbacks when an exception is raised. Callbacks can be registered
14078 for specific exceptions, or when any exception is raised. This
14079 can be used for instance to force a core dump to ease debugging.
14081 @node GNAT.Exception_Traces (g-exctra.ads)
14082 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14083 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14084 @cindex Exception traces
14088 Provides an interface allowing to control automatic output upon exception
14091 @node GNAT.Exceptions (g-except.ads)
14092 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14093 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14094 @cindex Exceptions, Pure
14095 @cindex Pure packages, exceptions
14098 Normally it is not possible to raise an exception with
14099 a message from a subprogram in a pure package, since the
14100 necessary types and subprograms are in @code{Ada.Exceptions}
14101 which is not a pure unit. @code{GNAT.Exceptions} provides a
14102 facility for getting around this limitation for a few
14103 predefined exceptions, and for example allow raising
14104 @code{Constraint_Error} with a message from a pure subprogram.
14106 @node GNAT.Expect (g-expect.ads)
14107 @section @code{GNAT.Expect} (@file{g-expect.ads})
14108 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14111 Provides a set of subprograms similar to what is available
14112 with the standard Tcl Expect tool.
14113 It allows you to easily spawn and communicate with an external process.
14114 You can send commands or inputs to the process, and compare the output
14115 with some expected regular expression. Currently @code{GNAT.Expect}
14116 is implemented on all native GNAT ports except for OpenVMS@.
14117 It is not implemented for cross ports, and in particular is not
14118 implemented for VxWorks or LynxOS@.
14120 @node GNAT.Float_Control (g-flocon.ads)
14121 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14122 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14123 @cindex Floating-Point Processor
14126 Provides an interface for resetting the floating-point processor into the
14127 mode required for correct semantic operation in Ada. Some third party
14128 library calls may cause this mode to be modified, and the Reset procedure
14129 in this package can be used to reestablish the required mode.
14131 @node GNAT.Heap_Sort (g-heasor.ads)
14132 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14133 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14137 Provides a general implementation of heap sort usable for sorting arbitrary
14138 data items. Exchange and comparison procedures are provided by passing
14139 access-to-procedure values. The algorithm used is a modified heap sort
14140 that performs approximately N*log(N) comparisons in the worst case.
14142 @node GNAT.Heap_Sort_A (g-hesora.ads)
14143 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14144 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14148 Provides a general implementation of heap sort usable for sorting arbitrary
14149 data items. Move and comparison procedures are provided by passing
14150 access-to-procedure values. The algorithm used is a modified heap sort
14151 that performs approximately N*log(N) comparisons in the worst case.
14152 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14153 interface, but may be slightly more efficient.
14155 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14156 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14157 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14161 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14162 are provided as generic parameters, this improves efficiency, especially
14163 if the procedures can be inlined, at the expense of duplicating code for
14164 multiple instantiations.
14166 @node GNAT.HTable (g-htable.ads)
14167 @section @code{GNAT.HTable} (@file{g-htable.ads})
14168 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14169 @cindex Hash tables
14172 A generic implementation of hash tables that can be used to hash arbitrary
14173 data. Provides two approaches, one a simple static approach, and the other
14174 allowing arbitrary dynamic hash tables.
14176 @node GNAT.IO (g-io.ads)
14177 @section @code{GNAT.IO} (@file{g-io.ads})
14178 @cindex @code{GNAT.IO} (@file{g-io.ads})
14180 @cindex Input/Output facilities
14183 A simple preelaborable input-output package that provides a subset of
14184 simple Text_IO functions for reading characters and strings from
14185 Standard_Input, and writing characters, strings and integers to either
14186 Standard_Output or Standard_Error.
14188 @node GNAT.IO_Aux (g-io_aux.ads)
14189 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14190 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14192 @cindex Input/Output facilities
14194 Provides some auxiliary functions for use with Text_IO, including a test
14195 for whether a file exists, and functions for reading a line of text.
14197 @node GNAT.Lock_Files (g-locfil.ads)
14198 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14199 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14200 @cindex File locking
14201 @cindex Locking using files
14204 Provides a general interface for using files as locks. Can be used for
14205 providing program level synchronization.
14207 @node GNAT.MD5 (g-md5.ads)
14208 @section @code{GNAT.MD5} (@file{g-md5.ads})
14209 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14210 @cindex Message Digest MD5
14213 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14215 @node GNAT.Memory_Dump (g-memdum.ads)
14216 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14217 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14218 @cindex Dump Memory
14221 Provides a convenient routine for dumping raw memory to either the
14222 standard output or standard error files. Uses GNAT.IO for actual
14225 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14226 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14227 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14228 @cindex Exception, obtaining most recent
14231 Provides access to the most recently raised exception. Can be used for
14232 various logging purposes, including duplicating functionality of some
14233 Ada 83 implementation dependent extensions.
14235 @node GNAT.OS_Lib (g-os_lib.ads)
14236 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14237 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14238 @cindex Operating System interface
14239 @cindex Spawn capability
14242 Provides a range of target independent operating system interface functions,
14243 including time/date management, file operations, subprocess management,
14244 including a portable spawn procedure, and access to environment variables
14245 and error return codes.
14247 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14248 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14249 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14250 @cindex Hash functions
14253 Provides a generator of static minimal perfect hash functions. No
14254 collisions occur and each item can be retrieved from the table in one
14255 probe (perfect property). The hash table size corresponds to the exact
14256 size of the key set and no larger (minimal property). The key set has to
14257 be know in advance (static property). The hash functions are also order
14258 preserving. If w2 is inserted after w1 in the generator, their
14259 hashcode are in the same order. These hashing functions are very
14260 convenient for use with realtime applications.
14262 @node GNAT.Random_Numbers (g-rannum.ads)
14263 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14264 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14265 @cindex Random number generation
14268 Provides random number capabilities which extend those available in the
14269 standard Ada library and are more convenient to use.
14271 @node GNAT.Regexp (g-regexp.ads)
14272 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14273 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14274 @cindex Regular expressions
14275 @cindex Pattern matching
14278 A simple implementation of regular expressions, using a subset of regular
14279 expression syntax copied from familiar Unix style utilities. This is the
14280 simples of the three pattern matching packages provided, and is particularly
14281 suitable for ``file globbing'' applications.
14283 @node GNAT.Registry (g-regist.ads)
14284 @section @code{GNAT.Registry} (@file{g-regist.ads})
14285 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14286 @cindex Windows Registry
14289 This is a high level binding to the Windows registry. It is possible to
14290 do simple things like reading a key value, creating a new key. For full
14291 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14292 package provided with the Win32Ada binding
14294 @node GNAT.Regpat (g-regpat.ads)
14295 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14296 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14297 @cindex Regular expressions
14298 @cindex Pattern matching
14301 A complete implementation of Unix-style regular expression matching, copied
14302 from the original V7 style regular expression library written in C by
14303 Henry Spencer (and binary compatible with this C library).
14305 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14306 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14307 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14308 @cindex Secondary Stack Info
14311 Provide the capability to query the high water mark of the current task's
14314 @node GNAT.Semaphores (g-semaph.ads)
14315 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14316 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14320 Provides classic counting and binary semaphores using protected types.
14322 @node GNAT.Serial_Communications (g-sercom.ads)
14323 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14324 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14325 @cindex Serial_Communications
14328 Provides a simple interface to send and receive data over a serial
14329 port. This is only supported on GNU/Linux and Windows.
14331 @node GNAT.SHA1 (g-sha1.ads)
14332 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14333 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14334 @cindex Secure Hash Algorithm SHA-1
14337 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
14339 @node GNAT.Signals (g-signal.ads)
14340 @section @code{GNAT.Signals} (@file{g-signal.ads})
14341 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14345 Provides the ability to manipulate the blocked status of signals on supported
14348 @node GNAT.Sockets (g-socket.ads)
14349 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14350 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14354 A high level and portable interface to develop sockets based applications.
14355 This package is based on the sockets thin binding found in
14356 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14357 on all native GNAT ports except for OpenVMS@. It is not implemented
14358 for the LynxOS@ cross port.
14360 @node GNAT.Source_Info (g-souinf.ads)
14361 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14362 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14363 @cindex Source Information
14366 Provides subprograms that give access to source code information known at
14367 compile time, such as the current file name and line number.
14369 @node GNAT.Spelling_Checker (g-speche.ads)
14370 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14371 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14372 @cindex Spell checking
14375 Provides a function for determining whether one string is a plausible
14376 near misspelling of another string.
14378 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14379 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14380 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14381 @cindex Spell checking
14384 Provides a generic function that can be instantiated with a string type for
14385 determining whether one string is a plausible near misspelling of another
14388 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14389 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14390 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14391 @cindex SPITBOL pattern matching
14392 @cindex Pattern matching
14395 A complete implementation of SNOBOL4 style pattern matching. This is the
14396 most elaborate of the pattern matching packages provided. It fully duplicates
14397 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14398 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14400 @node GNAT.Spitbol (g-spitbo.ads)
14401 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14402 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14403 @cindex SPITBOL interface
14406 The top level package of the collection of SPITBOL-style functionality, this
14407 package provides basic SNOBOL4 string manipulation functions, such as
14408 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14409 useful for constructing arbitrary mappings from strings in the style of
14410 the SNOBOL4 TABLE function.
14412 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14413 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14414 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14415 @cindex Sets of strings
14416 @cindex SPITBOL Tables
14419 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14420 for type @code{Standard.Boolean}, giving an implementation of sets of
14423 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14424 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14425 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14426 @cindex Integer maps
14428 @cindex SPITBOL Tables
14431 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14432 for type @code{Standard.Integer}, giving an implementation of maps
14433 from string to integer values.
14435 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14436 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14437 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14438 @cindex String maps
14440 @cindex SPITBOL Tables
14443 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14444 a variable length string type, giving an implementation of general
14445 maps from strings to strings.
14447 @node GNAT.Strings (g-string.ads)
14448 @section @code{GNAT.Strings} (@file{g-string.ads})
14449 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14452 Common String access types and related subprograms. Basically it
14453 defines a string access and an array of string access types.
14455 @node GNAT.String_Split (g-strspl.ads)
14456 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14457 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14458 @cindex String splitter
14461 Useful string manipulation routines: given a set of separators, split
14462 a string wherever the separators appear, and provide direct access
14463 to the resulting slices. This package is instantiated from
14464 @code{GNAT.Array_Split}.
14466 @node GNAT.Table (g-table.ads)
14467 @section @code{GNAT.Table} (@file{g-table.ads})
14468 @cindex @code{GNAT.Table} (@file{g-table.ads})
14469 @cindex Table implementation
14470 @cindex Arrays, extendable
14473 A generic package providing a single dimension array abstraction where the
14474 length of the array can be dynamically modified.
14477 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14478 except that this package declares a single instance of the table type,
14479 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14480 used to define dynamic instances of the table.
14482 @node GNAT.Task_Lock (g-tasloc.ads)
14483 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14484 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14485 @cindex Task synchronization
14486 @cindex Task locking
14490 A very simple facility for locking and unlocking sections of code using a
14491 single global task lock. Appropriate for use in situations where contention
14492 between tasks is very rarely expected.
14494 @node GNAT.Time_Stamp (g-timsta.ads)
14495 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14496 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14498 @cindex Current time
14501 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14502 represents the current date and time in ISO 8601 format. This is a very simple
14503 routine with minimal code and there are no dependencies on any other unit.
14505 @node GNAT.Threads (g-thread.ads)
14506 @section @code{GNAT.Threads} (@file{g-thread.ads})
14507 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14508 @cindex Foreign threads
14509 @cindex Threads, foreign
14512 Provides facilities for dealing with foreign threads which need to be known
14513 by the GNAT run-time system. Consult the documentation of this package for
14514 further details if your program has threads that are created by a non-Ada
14515 environment which then accesses Ada code.
14517 @node GNAT.Traceback (g-traceb.ads)
14518 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14519 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14520 @cindex Trace back facilities
14523 Provides a facility for obtaining non-symbolic traceback information, useful
14524 in various debugging situations.
14526 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14527 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14528 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14529 @cindex Trace back facilities
14531 @node GNAT.UTF_32 (g-utf_32.ads)
14532 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14533 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14534 @cindex Wide character codes
14537 This is a package intended to be used in conjunction with the
14538 @code{Wide_Character} type in Ada 95 and the
14539 @code{Wide_Wide_Character} type in Ada 2005 (available
14540 in @code{GNAT} in Ada 2005 mode). This package contains
14541 Unicode categorization routines, as well as lexical
14542 categorization routines corresponding to the Ada 2005
14543 lexical rules for identifiers and strings, and also a
14544 lower case to upper case fold routine corresponding to
14545 the Ada 2005 rules for identifier equivalence.
14547 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14548 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14549 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14550 @cindex Spell checking
14553 Provides a function for determining whether one wide wide string is a plausible
14554 near misspelling of another wide wide string, where the strings are represented
14555 using the UTF_32_String type defined in System.Wch_Cnv.
14557 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14558 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14559 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14560 @cindex Spell checking
14563 Provides a function for determining whether one wide string is a plausible
14564 near misspelling of another wide string.
14566 @node GNAT.Wide_String_Split (g-wistsp.ads)
14567 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14568 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14569 @cindex Wide_String splitter
14572 Useful wide string manipulation routines: given a set of separators, split
14573 a wide string wherever the separators appear, and provide direct access
14574 to the resulting slices. This package is instantiated from
14575 @code{GNAT.Array_Split}.
14577 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14578 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14579 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14580 @cindex Spell checking
14583 Provides a function for determining whether one wide wide string is a plausible
14584 near misspelling of another wide wide string.
14586 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14587 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14588 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14589 @cindex Wide_Wide_String splitter
14592 Useful wide wide string manipulation routines: given a set of separators, split
14593 a wide wide string wherever the separators appear, and provide direct access
14594 to the resulting slices. This package is instantiated from
14595 @code{GNAT.Array_Split}.
14597 @node Interfaces.C.Extensions (i-cexten.ads)
14598 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14599 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14602 This package contains additional C-related definitions, intended
14603 for use with either manually or automatically generated bindings
14606 @node Interfaces.C.Streams (i-cstrea.ads)
14607 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14608 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14609 @cindex C streams, interfacing
14612 This package is a binding for the most commonly used operations
14615 @node Interfaces.CPP (i-cpp.ads)
14616 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
14617 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14618 @cindex C++ interfacing
14619 @cindex Interfacing, to C++
14622 This package provides facilities for use in interfacing to C++. It
14623 is primarily intended to be used in connection with automated tools
14624 for the generation of C++ interfaces.
14626 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14627 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14628 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14629 @cindex IBM Packed Format
14630 @cindex Packed Decimal
14633 This package provides a set of routines for conversions to and
14634 from a packed decimal format compatible with that used on IBM
14637 @node Interfaces.VxWorks (i-vxwork.ads)
14638 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14639 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14640 @cindex Interfacing to VxWorks
14641 @cindex VxWorks, interfacing
14644 This package provides a limited binding to the VxWorks API.
14645 In particular, it interfaces with the
14646 VxWorks hardware interrupt facilities.
14648 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14649 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14650 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14651 @cindex Interfacing to VxWorks' I/O
14652 @cindex VxWorks, I/O interfacing
14653 @cindex VxWorks, Get_Immediate
14654 @cindex Get_Immediate, VxWorks
14657 This package provides a binding to the ioctl (IO/Control)
14658 function of VxWorks, defining a set of option values and
14659 function codes. A particular use of this package is
14660 to enable the use of Get_Immediate under VxWorks.
14662 @node System.Address_Image (s-addima.ads)
14663 @section @code{System.Address_Image} (@file{s-addima.ads})
14664 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14665 @cindex Address image
14666 @cindex Image, of an address
14669 This function provides a useful debugging
14670 function that gives an (implementation dependent)
14671 string which identifies an address.
14673 @node System.Assertions (s-assert.ads)
14674 @section @code{System.Assertions} (@file{s-assert.ads})
14675 @cindex @code{System.Assertions} (@file{s-assert.ads})
14677 @cindex Assert_Failure, exception
14680 This package provides the declaration of the exception raised
14681 by an run-time assertion failure, as well as the routine that
14682 is used internally to raise this assertion.
14684 @node System.Memory (s-memory.ads)
14685 @section @code{System.Memory} (@file{s-memory.ads})
14686 @cindex @code{System.Memory} (@file{s-memory.ads})
14687 @cindex Memory allocation
14690 This package provides the interface to the low level routines used
14691 by the generated code for allocation and freeing storage for the
14692 default storage pool (analogous to the C routines malloc and free.
14693 It also provides a reallocation interface analogous to the C routine
14694 realloc. The body of this unit may be modified to provide alternative
14695 allocation mechanisms for the default pool, and in addition, direct
14696 calls to this unit may be made for low level allocation uses (for
14697 example see the body of @code{GNAT.Tables}).
14699 @node System.Partition_Interface (s-parint.ads)
14700 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14701 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14702 @cindex Partition interfacing functions
14705 This package provides facilities for partition interfacing. It
14706 is used primarily in a distribution context when using Annex E
14709 @node System.Pool_Global (s-pooglo.ads)
14710 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
14711 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
14712 @cindex Storage pool, global
14713 @cindex Global storage pool
14716 This package provides a storage pool that is equivalent to the default
14717 storage pool used for access types for which no pool is specifically
14718 declared. It uses malloc/free to allocate/free and does not attempt to
14719 do any automatic reclamation.
14721 @node System.Pool_Local (s-pooloc.ads)
14722 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
14723 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
14724 @cindex Storage pool, local
14725 @cindex Local storage pool
14728 This package provides a storage pool that is intended for use with locally
14729 defined access types. It uses malloc/free for allocate/free, and maintains
14730 a list of allocated blocks, so that all storage allocated for the pool can
14731 be freed automatically when the pool is finalized.
14733 @node System.Restrictions (s-restri.ads)
14734 @section @code{System.Restrictions} (@file{s-restri.ads})
14735 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14736 @cindex Run-time restrictions access
14739 This package provides facilities for accessing at run time
14740 the status of restrictions specified at compile time for
14741 the partition. Information is available both with regard
14742 to actual restrictions specified, and with regard to
14743 compiler determined information on which restrictions
14744 are violated by one or more packages in the partition.
14746 @node System.Rident (s-rident.ads)
14747 @section @code{System.Rident} (@file{s-rident.ads})
14748 @cindex @code{System.Rident} (@file{s-rident.ads})
14749 @cindex Restrictions definitions
14752 This package provides definitions of the restrictions
14753 identifiers supported by GNAT, and also the format of
14754 the restrictions provided in package System.Restrictions.
14755 It is not normally necessary to @code{with} this generic package
14756 since the necessary instantiation is included in
14757 package System.Restrictions.
14759 @node System.Task_Info (s-tasinf.ads)
14760 @section @code{System.Task_Info} (@file{s-tasinf.ads})
14761 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
14762 @cindex Task_Info pragma
14765 This package provides target dependent functionality that is used
14766 to support the @code{Task_Info} pragma
14768 @node System.Wch_Cnv (s-wchcnv.ads)
14769 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14770 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14771 @cindex Wide Character, Representation
14772 @cindex Wide String, Conversion
14773 @cindex Representation of wide characters
14776 This package provides routines for converting between
14777 wide and wide wide characters and a representation as a value of type
14778 @code{Standard.String}, using a specified wide character
14779 encoding method. It uses definitions in
14780 package @code{System.Wch_Con}.
14782 @node System.Wch_Con (s-wchcon.ads)
14783 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
14784 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
14787 This package provides definitions and descriptions of
14788 the various methods used for encoding wide characters
14789 in ordinary strings. These definitions are used by
14790 the package @code{System.Wch_Cnv}.
14792 @node Interfacing to Other Languages
14793 @chapter Interfacing to Other Languages
14795 The facilities in annex B of the Ada Reference Manual are fully
14796 implemented in GNAT, and in addition, a full interface to C++ is
14800 * Interfacing to C::
14801 * Interfacing to C++::
14802 * Interfacing to COBOL::
14803 * Interfacing to Fortran::
14804 * Interfacing to non-GNAT Ada code::
14807 @node Interfacing to C
14808 @section Interfacing to C
14811 Interfacing to C with GNAT can use one of two approaches:
14815 The types in the package @code{Interfaces.C} may be used.
14817 Standard Ada types may be used directly. This may be less portable to
14818 other compilers, but will work on all GNAT compilers, which guarantee
14819 correspondence between the C and Ada types.
14823 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
14824 effect, since this is the default. The following table shows the
14825 correspondence between Ada scalar types and the corresponding C types.
14830 @item Short_Integer
14832 @item Short_Short_Integer
14836 @item Long_Long_Integer
14844 @item Long_Long_Float
14845 This is the longest floating-point type supported by the hardware.
14849 Additionally, there are the following general correspondences between Ada
14853 Ada enumeration types map to C enumeration types directly if pragma
14854 @code{Convention C} is specified, which causes them to have int
14855 length. Without pragma @code{Convention C}, Ada enumeration types map to
14856 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
14857 @code{int}, respectively) depending on the number of values passed.
14858 This is the only case in which pragma @code{Convention C} affects the
14859 representation of an Ada type.
14862 Ada access types map to C pointers, except for the case of pointers to
14863 unconstrained types in Ada, which have no direct C equivalent.
14866 Ada arrays map directly to C arrays.
14869 Ada records map directly to C structures.
14872 Packed Ada records map to C structures where all members are bit fields
14873 of the length corresponding to the @code{@var{type}'Size} value in Ada.
14876 @node Interfacing to C++
14877 @section Interfacing to C++
14880 The interface to C++ makes use of the following pragmas, which are
14881 primarily intended to be constructed automatically using a binding generator
14882 tool, although it is possible to construct them by hand. No suitable binding
14883 generator tool is supplied with GNAT though.
14885 Using these pragmas it is possible to achieve complete
14886 inter-operability between Ada tagged types and C++ class definitions.
14887 See @ref{Implementation Defined Pragmas}, for more details.
14890 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
14891 The argument denotes an entity in the current declarative region that is
14892 declared as a tagged or untagged record type. It indicates that the type
14893 corresponds to an externally declared C++ class type, and is to be laid
14894 out the same way that C++ would lay out the type.
14896 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
14897 for backward compatibility but its functionality is available
14898 using pragma @code{Import} with @code{Convention} = @code{CPP}.
14900 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
14901 This pragma identifies an imported function (imported in the usual way
14902 with pragma @code{Import}) as corresponding to a C++ constructor.
14905 @node Interfacing to COBOL
14906 @section Interfacing to COBOL
14909 Interfacing to COBOL is achieved as described in section B.4 of
14910 the Ada Reference Manual.
14912 @node Interfacing to Fortran
14913 @section Interfacing to Fortran
14916 Interfacing to Fortran is achieved as described in section B.5 of the
14917 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
14918 multi-dimensional array causes the array to be stored in column-major
14919 order as required for convenient interface to Fortran.
14921 @node Interfacing to non-GNAT Ada code
14922 @section Interfacing to non-GNAT Ada code
14924 It is possible to specify the convention @code{Ada} in a pragma
14925 @code{Import} or pragma @code{Export}. However this refers to
14926 the calling conventions used by GNAT, which may or may not be
14927 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
14928 compiler to allow interoperation.
14930 If arguments types are kept simple, and if the foreign compiler generally
14931 follows system calling conventions, then it may be possible to integrate
14932 files compiled by other Ada compilers, provided that the elaboration
14933 issues are adequately addressed (for example by eliminating the
14934 need for any load time elaboration).
14936 In particular, GNAT running on VMS is designed to
14937 be highly compatible with the DEC Ada 83 compiler, so this is one
14938 case in which it is possible to import foreign units of this type,
14939 provided that the data items passed are restricted to simple scalar
14940 values or simple record types without variants, or simple array
14941 types with fixed bounds.
14943 @node Specialized Needs Annexes
14944 @chapter Specialized Needs Annexes
14947 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
14948 required in all implementations. However, as described in this chapter,
14949 GNAT implements all of these annexes:
14952 @item Systems Programming (Annex C)
14953 The Systems Programming Annex is fully implemented.
14955 @item Real-Time Systems (Annex D)
14956 The Real-Time Systems Annex is fully implemented.
14958 @item Distributed Systems (Annex E)
14959 Stub generation is fully implemented in the GNAT compiler. In addition,
14960 a complete compatible PCS is available as part of the GLADE system,
14961 a separate product. When the two
14962 products are used in conjunction, this annex is fully implemented.
14964 @item Information Systems (Annex F)
14965 The Information Systems annex is fully implemented.
14967 @item Numerics (Annex G)
14968 The Numerics Annex is fully implemented.
14970 @item Safety and Security / High-Integrity Systems (Annex H)
14971 The Safety and Security Annex (termed the High-Integrity Systems Annex
14972 in Ada 2005) is fully implemented.
14975 @node Implementation of Specific Ada Features
14976 @chapter Implementation of Specific Ada Features
14979 This chapter describes the GNAT implementation of several Ada language
14983 * Machine Code Insertions::
14984 * GNAT Implementation of Tasking::
14985 * GNAT Implementation of Shared Passive Packages::
14986 * Code Generation for Array Aggregates::
14987 * The Size of Discriminated Records with Default Discriminants::
14988 * Strict Conformance to the Ada Reference Manual::
14991 @node Machine Code Insertions
14992 @section Machine Code Insertions
14993 @cindex Machine Code insertions
14996 Package @code{Machine_Code} provides machine code support as described
14997 in the Ada Reference Manual in two separate forms:
15000 Machine code statements, consisting of qualified expressions that
15001 fit the requirements of RM section 13.8.
15003 An intrinsic callable procedure, providing an alternative mechanism of
15004 including machine instructions in a subprogram.
15008 The two features are similar, and both are closely related to the mechanism
15009 provided by the asm instruction in the GNU C compiler. Full understanding
15010 and use of the facilities in this package requires understanding the asm
15011 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15012 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15014 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15015 semantic restrictions and effects as described below. Both are provided so
15016 that the procedure call can be used as a statement, and the function call
15017 can be used to form a code_statement.
15019 The first example given in the GCC documentation is the C @code{asm}
15022 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15026 The equivalent can be written for GNAT as:
15028 @smallexample @c ada
15029 Asm ("fsinx %1 %0",
15030 My_Float'Asm_Output ("=f", result),
15031 My_Float'Asm_Input ("f", angle));
15035 The first argument to @code{Asm} is the assembler template, and is
15036 identical to what is used in GNU C@. This string must be a static
15037 expression. The second argument is the output operand list. It is
15038 either a single @code{Asm_Output} attribute reference, or a list of such
15039 references enclosed in parentheses (technically an array aggregate of
15042 The @code{Asm_Output} attribute denotes a function that takes two
15043 parameters. The first is a string, the second is the name of a variable
15044 of the type designated by the attribute prefix. The first (string)
15045 argument is required to be a static expression and designates the
15046 constraint for the parameter (e.g.@: what kind of register is
15047 required). The second argument is the variable to be updated with the
15048 result. The possible values for constraint are the same as those used in
15049 the RTL, and are dependent on the configuration file used to build the
15050 GCC back end. If there are no output operands, then this argument may
15051 either be omitted, or explicitly given as @code{No_Output_Operands}.
15053 The second argument of @code{@var{my_float}'Asm_Output} functions as
15054 though it were an @code{out} parameter, which is a little curious, but
15055 all names have the form of expressions, so there is no syntactic
15056 irregularity, even though normally functions would not be permitted
15057 @code{out} parameters. The third argument is the list of input
15058 operands. It is either a single @code{Asm_Input} attribute reference, or
15059 a list of such references enclosed in parentheses (technically an array
15060 aggregate of such references).
15062 The @code{Asm_Input} attribute denotes a function that takes two
15063 parameters. The first is a string, the second is an expression of the
15064 type designated by the prefix. The first (string) argument is required
15065 to be a static expression, and is the constraint for the parameter,
15066 (e.g.@: what kind of register is required). The second argument is the
15067 value to be used as the input argument. The possible values for the
15068 constant are the same as those used in the RTL, and are dependent on
15069 the configuration file used to built the GCC back end.
15071 If there are no input operands, this argument may either be omitted, or
15072 explicitly given as @code{No_Input_Operands}. The fourth argument, not
15073 present in the above example, is a list of register names, called the
15074 @dfn{clobber} argument. This argument, if given, must be a static string
15075 expression, and is a space or comma separated list of names of registers
15076 that must be considered destroyed as a result of the @code{Asm} call. If
15077 this argument is the null string (the default value), then the code
15078 generator assumes that no additional registers are destroyed.
15080 The fifth argument, not present in the above example, called the
15081 @dfn{volatile} argument, is by default @code{False}. It can be set to
15082 the literal value @code{True} to indicate to the code generator that all
15083 optimizations with respect to the instruction specified should be
15084 suppressed, and that in particular, for an instruction that has outputs,
15085 the instruction will still be generated, even if none of the outputs are
15086 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15087 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15088 Generally it is strongly advisable to use Volatile for any ASM statement
15089 that is missing either input or output operands, or when two or more ASM
15090 statements appear in sequence, to avoid unwanted optimizations. A warning
15091 is generated if this advice is not followed.
15093 The @code{Asm} subprograms may be used in two ways. First the procedure
15094 forms can be used anywhere a procedure call would be valid, and
15095 correspond to what the RM calls ``intrinsic'' routines. Such calls can
15096 be used to intersperse machine instructions with other Ada statements.
15097 Second, the function forms, which return a dummy value of the limited
15098 private type @code{Asm_Insn}, can be used in code statements, and indeed
15099 this is the only context where such calls are allowed. Code statements
15100 appear as aggregates of the form:
15102 @smallexample @c ada
15103 Asm_Insn'(Asm (@dots{}));
15104 Asm_Insn'(Asm_Volatile (@dots{}));
15108 In accordance with RM rules, such code statements are allowed only
15109 within subprograms whose entire body consists of such statements. It is
15110 not permissible to intermix such statements with other Ada statements.
15112 Typically the form using intrinsic procedure calls is more convenient
15113 and more flexible. The code statement form is provided to meet the RM
15114 suggestion that such a facility should be made available. The following
15115 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15116 is used, the arguments may be given in arbitrary order, following the
15117 normal rules for use of positional and named arguments)
15121 [Template =>] static_string_EXPRESSION
15122 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
15123 [,[Inputs =>] INPUT_OPERAND_LIST ]
15124 [,[Clobber =>] static_string_EXPRESSION ]
15125 [,[Volatile =>] static_boolean_EXPRESSION] )
15127 OUTPUT_OPERAND_LIST ::=
15128 [PREFIX.]No_Output_Operands
15129 | OUTPUT_OPERAND_ATTRIBUTE
15130 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15132 OUTPUT_OPERAND_ATTRIBUTE ::=
15133 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15135 INPUT_OPERAND_LIST ::=
15136 [PREFIX.]No_Input_Operands
15137 | INPUT_OPERAND_ATTRIBUTE
15138 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15140 INPUT_OPERAND_ATTRIBUTE ::=
15141 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15145 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15146 are declared in the package @code{Machine_Code} and must be referenced
15147 according to normal visibility rules. In particular if there is no
15148 @code{use} clause for this package, then appropriate package name
15149 qualification is required.
15151 @node GNAT Implementation of Tasking
15152 @section GNAT Implementation of Tasking
15155 This chapter outlines the basic GNAT approach to tasking (in particular,
15156 a multi-layered library for portability) and discusses issues related
15157 to compliance with the Real-Time Systems Annex.
15160 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15161 * Ensuring Compliance with the Real-Time Annex::
15164 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15165 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15168 GNAT's run-time support comprises two layers:
15171 @item GNARL (GNAT Run-time Layer)
15172 @item GNULL (GNAT Low-level Library)
15176 In GNAT, Ada's tasking services rely on a platform and OS independent
15177 layer known as GNARL@. This code is responsible for implementing the
15178 correct semantics of Ada's task creation, rendezvous, protected
15181 GNARL decomposes Ada's tasking semantics into simpler lower level
15182 operations such as create a thread, set the priority of a thread,
15183 yield, create a lock, lock/unlock, etc. The spec for these low-level
15184 operations constitutes GNULLI, the GNULL Interface. This interface is
15185 directly inspired from the POSIX real-time API@.
15187 If the underlying executive or OS implements the POSIX standard
15188 faithfully, the GNULL Interface maps as is to the services offered by
15189 the underlying kernel. Otherwise, some target dependent glue code maps
15190 the services offered by the underlying kernel to the semantics expected
15193 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
15194 key point is that each Ada task is mapped on a thread in the underlying
15195 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
15197 In addition Ada task priorities map onto the underlying thread priorities.
15198 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15202 The underlying scheduler is used to schedule the Ada tasks. This
15203 makes Ada tasks as efficient as kernel threads from a scheduling
15207 Interaction with code written in C containing threads is eased
15208 since at the lowest level Ada tasks and C threads map onto the same
15209 underlying kernel concept.
15212 When an Ada task is blocked during I/O the remaining Ada tasks are
15216 On multiprocessor systems Ada tasks can execute in parallel.
15220 Some threads libraries offer a mechanism to fork a new process, with the
15221 child process duplicating the threads from the parent.
15223 support this functionality when the parent contains more than one task.
15224 @cindex Forking a new process
15226 @node Ensuring Compliance with the Real-Time Annex
15227 @subsection Ensuring Compliance with the Real-Time Annex
15228 @cindex Real-Time Systems Annex compliance
15231 Although mapping Ada tasks onto
15232 the underlying threads has significant advantages, it does create some
15233 complications when it comes to respecting the scheduling semantics
15234 specified in the real-time annex (Annex D).
15236 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15237 scheduling policy states:
15240 @emph{When the active priority of a ready task that is not running
15241 changes, or the setting of its base priority takes effect, the
15242 task is removed from the ready queue for its old active priority
15243 and is added at the tail of the ready queue for its new active
15244 priority, except in the case where the active priority is lowered
15245 due to the loss of inherited priority, in which case the task is
15246 added at the head of the ready queue for its new active priority.}
15250 While most kernels do put tasks at the end of the priority queue when
15251 a task changes its priority, (which respects the main
15252 FIFO_Within_Priorities requirement), almost none keep a thread at the
15253 beginning of its priority queue when its priority drops from the loss
15254 of inherited priority.
15256 As a result most vendors have provided incomplete Annex D implementations.
15258 The GNAT run-time, has a nice cooperative solution to this problem
15259 which ensures that accurate FIFO_Within_Priorities semantics are
15262 The principle is as follows. When an Ada task T is about to start
15263 running, it checks whether some other Ada task R with the same
15264 priority as T has been suspended due to the loss of priority
15265 inheritance. If this is the case, T yields and is placed at the end of
15266 its priority queue. When R arrives at the front of the queue it
15269 Note that this simple scheme preserves the relative order of the tasks
15270 that were ready to execute in the priority queue where R has been
15273 @node GNAT Implementation of Shared Passive Packages
15274 @section GNAT Implementation of Shared Passive Packages
15275 @cindex Shared passive packages
15278 GNAT fully implements the pragma @code{Shared_Passive} for
15279 @cindex pragma @code{Shared_Passive}
15280 the purpose of designating shared passive packages.
15281 This allows the use of passive partitions in the
15282 context described in the Ada Reference Manual; i.e., for communication
15283 between separate partitions of a distributed application using the
15284 features in Annex E.
15286 @cindex Distribution Systems Annex
15288 However, the implementation approach used by GNAT provides for more
15289 extensive usage as follows:
15292 @item Communication between separate programs
15294 This allows separate programs to access the data in passive
15295 partitions, using protected objects for synchronization where
15296 needed. The only requirement is that the two programs have a
15297 common shared file system. It is even possible for programs
15298 running on different machines with different architectures
15299 (e.g.@: different endianness) to communicate via the data in
15300 a passive partition.
15302 @item Persistence between program runs
15304 The data in a passive package can persist from one run of a
15305 program to another, so that a later program sees the final
15306 values stored by a previous run of the same program.
15311 The implementation approach used is to store the data in files. A
15312 separate stream file is created for each object in the package, and
15313 an access to an object causes the corresponding file to be read or
15316 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15317 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15318 set to the directory to be used for these files.
15319 The files in this directory
15320 have names that correspond to their fully qualified names. For
15321 example, if we have the package
15323 @smallexample @c ada
15325 pragma Shared_Passive (X);
15332 and the environment variable is set to @code{/stemp/}, then the files created
15333 will have the names:
15341 These files are created when a value is initially written to the object, and
15342 the files are retained until manually deleted. This provides the persistence
15343 semantics. If no file exists, it means that no partition has assigned a value
15344 to the variable; in this case the initial value declared in the package
15345 will be used. This model ensures that there are no issues in synchronizing
15346 the elaboration process, since elaboration of passive packages elaborates the
15347 initial values, but does not create the files.
15349 The files are written using normal @code{Stream_IO} access.
15350 If you want to be able
15351 to communicate between programs or partitions running on different
15352 architectures, then you should use the XDR versions of the stream attribute
15353 routines, since these are architecture independent.
15355 If active synchronization is required for access to the variables in the
15356 shared passive package, then as described in the Ada Reference Manual, the
15357 package may contain protected objects used for this purpose. In this case
15358 a lock file (whose name is @file{___lock} (three underscores)
15359 is created in the shared memory directory.
15360 @cindex @file{___lock} file (for shared passive packages)
15361 This is used to provide the required locking
15362 semantics for proper protected object synchronization.
15364 As of January 2003, GNAT supports shared passive packages on all platforms
15365 except for OpenVMS.
15367 @node Code Generation for Array Aggregates
15368 @section Code Generation for Array Aggregates
15371 * Static constant aggregates with static bounds::
15372 * Constant aggregates with unconstrained nominal types::
15373 * Aggregates with static bounds::
15374 * Aggregates with non-static bounds::
15375 * Aggregates in assignment statements::
15379 Aggregates have a rich syntax and allow the user to specify the values of
15380 complex data structures by means of a single construct. As a result, the
15381 code generated for aggregates can be quite complex and involve loops, case
15382 statements and multiple assignments. In the simplest cases, however, the
15383 compiler will recognize aggregates whose components and constraints are
15384 fully static, and in those cases the compiler will generate little or no
15385 executable code. The following is an outline of the code that GNAT generates
15386 for various aggregate constructs. For further details, you will find it
15387 useful to examine the output produced by the -gnatG flag to see the expanded
15388 source that is input to the code generator. You may also want to examine
15389 the assembly code generated at various levels of optimization.
15391 The code generated for aggregates depends on the context, the component values,
15392 and the type. In the context of an object declaration the code generated is
15393 generally simpler than in the case of an assignment. As a general rule, static
15394 component values and static subtypes also lead to simpler code.
15396 @node Static constant aggregates with static bounds
15397 @subsection Static constant aggregates with static bounds
15400 For the declarations:
15401 @smallexample @c ada
15402 type One_Dim is array (1..10) of integer;
15403 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15407 GNAT generates no executable code: the constant ar0 is placed in static memory.
15408 The same is true for constant aggregates with named associations:
15410 @smallexample @c ada
15411 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15412 Cr3 : constant One_Dim := (others => 7777);
15416 The same is true for multidimensional constant arrays such as:
15418 @smallexample @c ada
15419 type two_dim is array (1..3, 1..3) of integer;
15420 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15424 The same is true for arrays of one-dimensional arrays: the following are
15427 @smallexample @c ada
15428 type ar1b is array (1..3) of boolean;
15429 type ar_ar is array (1..3) of ar1b;
15430 None : constant ar1b := (others => false); -- fully static
15431 None2 : constant ar_ar := (1..3 => None); -- fully static
15435 However, for multidimensional aggregates with named associations, GNAT will
15436 generate assignments and loops, even if all associations are static. The
15437 following two declarations generate a loop for the first dimension, and
15438 individual component assignments for the second dimension:
15440 @smallexample @c ada
15441 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15442 Zero2: constant two_dim := (others => (others => 0));
15445 @node Constant aggregates with unconstrained nominal types
15446 @subsection Constant aggregates with unconstrained nominal types
15449 In such cases the aggregate itself establishes the subtype, so that
15450 associations with @code{others} cannot be used. GNAT determines the
15451 bounds for the actual subtype of the aggregate, and allocates the
15452 aggregate statically as well. No code is generated for the following:
15454 @smallexample @c ada
15455 type One_Unc is array (natural range <>) of integer;
15456 Cr_Unc : constant One_Unc := (12,24,36);
15459 @node Aggregates with static bounds
15460 @subsection Aggregates with static bounds
15463 In all previous examples the aggregate was the initial (and immutable) value
15464 of a constant. If the aggregate initializes a variable, then code is generated
15465 for it as a combination of individual assignments and loops over the target
15466 object. The declarations
15468 @smallexample @c ada
15469 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15470 Cr_Var2 : One_Dim := (others > -1);
15474 generate the equivalent of
15476 @smallexample @c ada
15482 for I in Cr_Var2'range loop
15487 @node Aggregates with non-static bounds
15488 @subsection Aggregates with non-static bounds
15491 If the bounds of the aggregate are not statically compatible with the bounds
15492 of the nominal subtype of the target, then constraint checks have to be
15493 generated on the bounds. For a multidimensional array, constraint checks may
15494 have to be applied to sub-arrays individually, if they do not have statically
15495 compatible subtypes.
15497 @node Aggregates in assignment statements
15498 @subsection Aggregates in assignment statements
15501 In general, aggregate assignment requires the construction of a temporary,
15502 and a copy from the temporary to the target of the assignment. This is because
15503 it is not always possible to convert the assignment into a series of individual
15504 component assignments. For example, consider the simple case:
15506 @smallexample @c ada
15511 This cannot be converted into:
15513 @smallexample @c ada
15519 So the aggregate has to be built first in a separate location, and then
15520 copied into the target. GNAT recognizes simple cases where this intermediate
15521 step is not required, and the assignments can be performed in place, directly
15522 into the target. The following sufficient criteria are applied:
15526 The bounds of the aggregate are static, and the associations are static.
15528 The components of the aggregate are static constants, names of
15529 simple variables that are not renamings, or expressions not involving
15530 indexed components whose operands obey these rules.
15534 If any of these conditions are violated, the aggregate will be built in
15535 a temporary (created either by the front-end or the code generator) and then
15536 that temporary will be copied onto the target.
15539 @node The Size of Discriminated Records with Default Discriminants
15540 @section The Size of Discriminated Records with Default Discriminants
15543 If a discriminated type @code{T} has discriminants with default values, it is
15544 possible to declare an object of this type without providing an explicit
15547 @smallexample @c ada
15549 type Size is range 1..100;
15551 type Rec (D : Size := 15) is record
15552 Name : String (1..D);
15560 Such an object is said to be @emph{unconstrained}.
15561 The discriminant of the object
15562 can be modified by a full assignment to the object, as long as it preserves the
15563 relation between the value of the discriminant, and the value of the components
15566 @smallexample @c ada
15568 Word := (3, "yes");
15570 Word := (5, "maybe");
15572 Word := (5, "no"); -- raises Constraint_Error
15577 In order to support this behavior efficiently, an unconstrained object is
15578 given the maximum size that any value of the type requires. In the case
15579 above, @code{Word} has storage for the discriminant and for
15580 a @code{String} of length 100.
15581 It is important to note that unconstrained objects do not require dynamic
15582 allocation. It would be an improper implementation to place on the heap those
15583 components whose size depends on discriminants. (This improper implementation
15584 was used by some Ada83 compilers, where the @code{Name} component above
15586 been stored as a pointer to a dynamic string). Following the principle that
15587 dynamic storage management should never be introduced implicitly,
15588 an Ada compiler should reserve the full size for an unconstrained declared
15589 object, and place it on the stack.
15591 This maximum size approach
15592 has been a source of surprise to some users, who expect the default
15593 values of the discriminants to determine the size reserved for an
15594 unconstrained object: ``If the default is 15, why should the object occupy
15596 The answer, of course, is that the discriminant may be later modified,
15597 and its full range of values must be taken into account. This is why the
15602 type Rec (D : Positive := 15) is record
15603 Name : String (1..D);
15611 is flagged by the compiler with a warning:
15612 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15613 because the required size includes @code{Positive'Last}
15614 bytes. As the first example indicates, the proper approach is to declare an
15615 index type of ``reasonable'' range so that unconstrained objects are not too
15618 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15619 created in the heap by means of an allocator, then it is @emph{not}
15621 it is constrained by the default values of the discriminants, and those values
15622 cannot be modified by full assignment. This is because in the presence of
15623 aliasing all views of the object (which may be manipulated by different tasks,
15624 say) must be consistent, so it is imperative that the object, once created,
15627 @node Strict Conformance to the Ada Reference Manual
15628 @section Strict Conformance to the Ada Reference Manual
15631 The dynamic semantics defined by the Ada Reference Manual impose a set of
15632 run-time checks to be generated. By default, the GNAT compiler will insert many
15633 run-time checks into the compiled code, including most of those required by the
15634 Ada Reference Manual. However, there are three checks that are not enabled
15635 in the default mode for efficiency reasons: arithmetic overflow checking for
15636 integer operations (including division by zero), checks for access before
15637 elaboration on subprogram calls, and stack overflow checking (most operating
15638 systems do not perform this check by default).
15640 Strict conformance to the Ada Reference Manual can be achieved by adding
15641 three compiler options for overflow checking for integer operations
15642 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15643 calls and generic instantiations (@option{-gnatE}), and stack overflow
15644 checking (@option{-fstack-check}).
15646 Note that the result of a floating point arithmetic operation in overflow and
15647 invalid situations, when the @code{Machine_Overflows} attribute of the result
15648 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15649 case for machines compliant with the IEEE floating-point standard, but on
15650 machines that are not fully compliant with this standard, such as Alpha, the
15651 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15652 behavior (although at the cost of a significant performance penalty), so
15653 infinite and and NaN values are properly generated.
15656 @node Project File Reference
15657 @chapter Project File Reference
15660 This chapter describes the syntax and semantics of project files.
15661 Project files specify the options to be used when building a system.
15662 Project files can specify global settings for all tools,
15663 as well as tool-specific settings.
15664 @xref{Examples of Project Files,,, gnat_ugn, @value{EDITION} User's Guide},
15665 for examples of use.
15669 * Lexical Elements::
15671 * Empty declarations::
15672 * Typed string declarations::
15676 * Project Attributes::
15677 * Attribute References::
15678 * External Values::
15679 * Case Construction::
15681 * Package Renamings::
15683 * Project Extensions::
15684 * Project File Elaboration::
15687 @node Reserved Words
15688 @section Reserved Words
15691 All Ada reserved words are reserved in project files, and cannot be used
15692 as variable names or project names. In addition, the following are
15693 also reserved in project files:
15696 @item @code{extends}
15698 @item @code{external}
15700 @item @code{project}
15704 @node Lexical Elements
15705 @section Lexical Elements
15708 Rules for identifiers are the same as in Ada. Identifiers
15709 are case-insensitive. Strings are case sensitive, except where noted.
15710 Comments have the same form as in Ada.
15720 simple_name @{. simple_name@}
15724 @section Declarations
15727 Declarations introduce new entities that denote types, variables, attributes,
15728 and packages. Some declarations can only appear immediately within a project
15729 declaration. Others can appear within a project or within a package.
15733 declarative_item ::=
15734 simple_declarative_item |
15735 typed_string_declaration |
15736 package_declaration
15738 simple_declarative_item ::=
15739 variable_declaration |
15740 typed_variable_declaration |
15741 attribute_declaration |
15742 case_construction |
15746 @node Empty declarations
15747 @section Empty declarations
15750 empty_declaration ::=
15754 An empty declaration is allowed anywhere a declaration is allowed.
15757 @node Typed string declarations
15758 @section Typed string declarations
15761 Typed strings are sequences of string literals. Typed strings are the only
15762 named types in project files. They are used in case constructions, where they
15763 provide support for conditional attribute definitions.
15767 typed_string_declaration ::=
15768 @b{type} <typed_string_>_simple_name @b{is}
15769 ( string_literal @{, string_literal@} );
15773 A typed string declaration can only appear immediately within a project
15776 All the string literals in a typed string declaration must be distinct.
15782 Variables denote values, and appear as constituents of expressions.
15785 typed_variable_declaration ::=
15786 <typed_variable_>simple_name : <typed_string_>name := string_expression ;
15788 variable_declaration ::=
15789 <variable_>simple_name := expression;
15793 The elaboration of a variable declaration introduces the variable and
15794 assigns to it the value of the expression. The name of the variable is
15795 available after the assignment symbol.
15798 A typed_variable can only be declare once.
15801 a non-typed variable can be declared multiple times.
15804 Before the completion of its first declaration, the value of variable
15805 is the null string.
15808 @section Expressions
15811 An expression is a formula that defines a computation or retrieval of a value.
15812 In a project file the value of an expression is either a string or a list
15813 of strings. A string value in an expression is either a literal, the current
15814 value of a variable, an external value, an attribute reference, or a
15815 concatenation operation.
15828 attribute_reference
15834 ( <string_>expression @{ , <string_>expression @} )
15837 @subsection Concatenation
15839 The following concatenation functions are defined:
15841 @smallexample @c ada
15842 function "&" (X : String; Y : String) return String;
15843 function "&" (X : String_List; Y : String) return String_List;
15844 function "&" (X : String_List; Y : String_List) return String_List;
15848 @section Attributes
15851 An attribute declaration defines a property of a project or package. This
15852 property can later be queried by means of an attribute reference.
15853 Attribute values are strings or string lists.
15855 Some attributes are associative arrays. These attributes are mappings whose
15856 domain is a set of strings. These attributes are declared one association
15857 at a time, by specifying a point in the domain and the corresponding image
15858 of the attribute. They may also be declared as a full associative array,
15859 getting the same associations as the corresponding attribute in an imported
15860 or extended project.
15862 Attributes that are not associative arrays are called simple attributes.
15866 attribute_declaration ::=
15867 full_associative_array_declaration |
15868 @b{for} attribute_designator @b{use} expression ;
15870 full_associative_array_declaration ::=
15871 @b{for} <associative_array_attribute_>simple_name @b{use}
15872 <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
15874 attribute_designator ::=
15875 <simple_attribute_>simple_name |
15876 <associative_array_attribute_>simple_name ( string_literal )
15880 Some attributes are project-specific, and can only appear immediately within
15881 a project declaration. Others are package-specific, and can only appear within
15882 the proper package.
15884 The expression in an attribute definition must be a string or a string_list.
15885 The string literal appearing in the attribute_designator of an associative
15886 array attribute is case-insensitive.
15888 @node Project Attributes
15889 @section Project Attributes
15892 The following attributes apply to a project. All of them are simple
15897 Expression must be a path name. The attribute defines the
15898 directory in which the object files created by the build are to be placed. If
15899 not specified, object files are placed in the project directory.
15902 Expression must be a path name. The attribute defines the
15903 directory in which the executables created by the build are to be placed.
15904 If not specified, executables are placed in the object directory.
15907 Expression must be a list of path names. The attribute
15908 defines the directories in which the source files for the project are to be
15909 found. If not specified, source files are found in the project directory.
15910 If a string in the list ends with "/**", then the directory that precedes
15911 "/**" and all of its subdirectories (recursively) are included in the list
15912 of source directories.
15914 @item Excluded_Source_Dirs
15915 Expression must be a list of strings. Each entry designates a directory that
15916 is not to be included in the list of source directories of the project.
15917 This is normally used when there are strings ending with "/**" in the value
15918 of attribute Source_Dirs.
15921 Expression must be a list of file names. The attribute
15922 defines the individual files, in the project directory, which are to be used
15923 as sources for the project. File names are path_names that contain no directory
15924 information. If the project has no sources the attribute must be declared
15925 explicitly with an empty list.
15927 @item Excluded_Source_Files (Locally_Removed_Files)
15928 Expression must be a list of strings that are legal file names.
15929 Each file name must designate a source that would normally be a source file
15930 in the source directories of the project or, if the project file is an
15931 extending project file, inherited by the current project file. It cannot
15932 designate an immediate source that is not inherited. Each of the source files
15933 in the list are not considered to be sources of the project file: they are not
15934 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
15935 Excluded_Source_Files is preferred.
15937 @item Source_List_File
15938 Expression must a single path name. The attribute
15939 defines a text file that contains a list of source file names to be used
15940 as sources for the project
15943 Expression must be a path name. The attribute defines the
15944 directory in which a library is to be built. The directory must exist, must
15945 be distinct from the project's object directory, and must be writable.
15948 Expression must be a string that is a legal file name,
15949 without extension. The attribute defines a string that is used to generate
15950 the name of the library to be built by the project.
15953 Argument must be a string value that must be one of the
15954 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
15955 string is case-insensitive. If this attribute is not specified, the library is
15956 a static library. Otherwise, the library may be dynamic or relocatable. This
15957 distinction is operating-system dependent.
15959 @item Library_Version
15960 Expression must be a string value whose interpretation
15961 is platform dependent. On UNIX, it is used only for dynamic/relocatable
15962 libraries as the internal name of the library (the @code{"soname"}). If the
15963 library file name (built from the @code{Library_Name}) is different from the
15964 @code{Library_Version}, then the library file will be a symbolic link to the
15965 actual file whose name will be @code{Library_Version}.
15967 @item Library_Interface
15968 Expression must be a string list. Each element of the string list
15969 must designate a unit of the project.
15970 If this attribute is present in a Library Project File, then the project
15971 file is a Stand-alone Library_Project_File.
15973 @item Library_Auto_Init
15974 Expression must be a single string "true" or "false", case-insensitive.
15975 If this attribute is present in a Stand-alone Library Project File,
15976 it indicates if initialization is automatic when the dynamic library
15979 @item Library_Options
15980 Expression must be a string list. Indicates additional switches that
15981 are to be used when building a shared library.
15984 Expression must be a single string. Designates an alternative to "gcc"
15985 for building shared libraries.
15987 @item Library_Src_Dir
15988 Expression must be a path name. The attribute defines the
15989 directory in which the sources of the interfaces of a Stand-alone Library will
15990 be copied. The directory must exist, must be distinct from the project's
15991 object directory and source directories of all projects in the project tree,
15992 and must be writable.
15994 @item Library_Src_Dir
15995 Expression must be a path name. The attribute defines the
15996 directory in which the ALI files of a Library will
15997 be copied. The directory must exist, must be distinct from the project's
15998 object directory and source directories of all projects in the project tree,
15999 and must be writable.
16001 @item Library_Symbol_File
16002 Expression must be a single string. Its value is the single file name of a
16003 symbol file to be created when building a stand-alone library when the
16004 symbol policy is either "compliant", "controlled" or "restricted",
16005 on platforms that support symbol control, such as VMS. When symbol policy
16006 is "direct", then a file with this name must exist in the object directory.
16008 @item Library_Reference_Symbol_File
16009 Expression must be a single string. Its value is the path name of a
16010 reference symbol file that is read when the symbol policy is either
16011 "compliant" or "controlled", on platforms that support symbol control,
16012 such as VMS, when building a stand-alone library. The path may be an absolute
16013 path or a path relative to the project directory.
16015 @item Library_Symbol_Policy
16016 Expression must be a single string. Its case-insensitive value can only be
16017 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
16019 This attribute is not taken into account on all platforms. It controls the
16020 policy for exported symbols and, on some platforms (like VMS) that have the
16021 notions of major and minor IDs built in the library files, it controls
16022 the setting of these IDs.
16024 "autonomous" or "default": exported symbols are not controlled.
16026 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
16027 it is equivalent to policy "autonomous". If there are exported symbols in
16028 the reference symbol file that are not in the object files of the interfaces,
16029 the major ID of the library is increased. If there are symbols in the
16030 object files of the interfaces that are not in the reference symbol file,
16031 these symbols are put at the end of the list in the newly created symbol file
16032 and the minor ID is increased.
16034 "controlled": the attribute Library_Reference_Symbol_File must be defined.
16035 The library will fail to build if the exported symbols in the object files of
16036 the interfaces do not match exactly the symbol in the symbol file.
16038 "restricted": The attribute Library_Symbol_File must be defined. The library
16039 will fail to build if there are symbols in the symbol file that are not in
16040 the exported symbols of the object files of the interfaces. Additional symbols
16041 in the object files are not added to the symbol file.
16043 "direct": The attribute Library_Symbol_File must be defined and must designate
16044 an existing file in the object directory. This symbol file is passed directly
16045 to the underlying linker without any symbol processing.
16048 Expression must be a list of strings that are legal file names.
16049 These file names designate existing compilation units in the source directory
16050 that are legal main subprograms.
16052 When a project file is elaborated, as part of the execution of a gnatmake
16053 command, one or several executables are built and placed in the Exec_Dir.
16054 If the gnatmake command does not include explicit file names, the executables
16055 that are built correspond to the files specified by this attribute.
16057 @item Externally_Built
16058 Expression must be a single string. Its value must be either "true" of "false",
16059 case-insensitive. The default is "false". When the value of this attribute is
16060 "true", no attempt is made to compile the sources or to build the library,
16061 when the project is a library project.
16063 @item Main_Language
16064 This is a simple attribute. Its value is a string that specifies the
16065 language of the main program.
16068 Expression must be a string list. Each string designates
16069 a programming language that is known to GNAT. The strings are case-insensitive.
16073 @node Attribute References
16074 @section Attribute References
16077 Attribute references are used to retrieve the value of previously defined
16078 attribute for a package or project.
16081 attribute_reference ::=
16082 attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
16084 attribute_prefix ::=
16086 <project_simple_name | package_identifier |
16087 <project_>simple_name . package_identifier
16091 If an attribute has not been specified for a given package or project, its
16092 value is the null string or the empty list.
16094 @node External Values
16095 @section External Values
16098 An external value is an expression whose value is obtained from the command
16099 that invoked the processing of the current project file (typically a
16105 @b{external} ( string_literal [, string_literal] )
16109 The first string_literal is the string to be used on the command line or
16110 in the environment to specify the external value. The second string_literal,
16111 if present, is the default to use if there is no specification for this
16112 external value either on the command line or in the environment.
16114 @node Case Construction
16115 @section Case Construction
16118 A case construction supports attribute and variable declarations that depend
16119 on the value of a previously declared variable.
16123 case_construction ::=
16124 @b{case} <typed_variable_>name @b{is}
16129 @b{when} discrete_choice_list =>
16130 @{case_construction |
16131 attribute_declaration |
16132 variable_declaration |
16133 empty_declaration@}
16135 discrete_choice_list ::=
16136 string_literal @{| string_literal@} |
16141 Inside a case construction, variable declarations must be for variables that
16142 have already been declared before the case construction.
16144 All choices in a choice list must be distinct. The choice lists of two
16145 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
16146 alternatives do not need to include all values of the type. An @code{others}
16147 choice must appear last in the list of alternatives.
16153 A package provides a grouping of variable declarations and attribute
16154 declarations to be used when invoking various GNAT tools. The name of
16155 the package indicates the tool(s) to which it applies.
16159 package_declaration ::=
16160 package_spec | package_renaming
16163 @b{package} package_identifier @b{is}
16164 @{simple_declarative_item@}
16165 @b{end} package_identifier ;
16167 package_identifier ::=
16168 @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
16169 @code{Linker} | @code{Finder} | @code{Cross_Reference} |
16170 @code{gnatls} | @code{IDE} | @code{Pretty_Printer}
16173 @subsection Package Naming
16176 The attributes of a @code{Naming} package specifies the naming conventions
16177 that apply to the source files in a project. When invoking other GNAT tools,
16178 they will use the sources in the source directories that satisfy these
16179 naming conventions.
16181 The following attributes apply to a @code{Naming} package:
16185 This is a simple attribute whose value is a string. Legal values of this
16186 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
16187 These strings are themselves case insensitive.
16190 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
16192 @item Dot_Replacement
16193 This is a simple attribute whose string value satisfies the following
16197 @item It must not be empty
16198 @item It cannot start or end with an alphanumeric character
16199 @item It cannot be a single underscore
16200 @item It cannot start with an underscore followed by an alphanumeric
16201 @item It cannot contain a dot @code{'.'} if longer than one character
16205 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
16208 This is an associative array attribute, defined on language names,
16209 whose image is a string that must satisfy the following
16213 @item It must not be empty
16214 @item It cannot start with an alphanumeric character
16215 @item It cannot start with an underscore followed by an alphanumeric character
16219 For Ada, the attribute denotes the suffix used in file names that contain
16220 library unit declarations, that is to say units that are package and
16221 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
16222 specified, then the default is @code{".ads"}.
16224 For C and C++, the attribute denotes the suffix used in file names that
16225 contain prototypes.
16228 This is an associative array attribute defined on language names,
16229 whose image is a string that must satisfy the following
16233 @item It must not be empty
16234 @item It cannot start with an alphanumeric character
16235 @item It cannot start with an underscore followed by an alphanumeric character
16236 @item It cannot be a suffix of @code{Spec_Suffix}
16240 For Ada, the attribute denotes the suffix used in file names that contain
16241 library bodies, that is to say units that are package and subprogram bodies.
16242 If @code{Body_Suffix ("Ada")} is not specified, then the default is
16245 For C and C++, the attribute denotes the suffix used in file names that contain
16248 @item Separate_Suffix
16249 This is a simple attribute whose value satisfies the same conditions as
16250 @code{Body_Suffix}.
16252 This attribute is specific to Ada. It denotes the suffix used in file names
16253 that contain separate bodies. If it is not specified, then it defaults to same
16254 value as @code{Body_Suffix ("Ada")}.
16257 This is an associative array attribute, specific to Ada, defined over
16258 compilation unit names. The image is a string that is the name of the file
16259 that contains that library unit. The file name is case sensitive if the
16260 conventions of the host operating system require it.
16263 This is an associative array attribute, specific to Ada, defined over
16264 compilation unit names. The image is a string that is the name of the file
16265 that contains the library unit body for the named unit. The file name is case
16266 sensitive if the conventions of the host operating system require it.
16268 @item Specification_Exceptions
16269 This is an associative array attribute defined on language names,
16270 whose value is a list of strings.
16272 This attribute is not significant for Ada.
16274 For C and C++, each string in the list denotes the name of a file that
16275 contains prototypes, but whose suffix is not necessarily the
16276 @code{Spec_Suffix} for the language.
16278 @item Implementation_Exceptions
16279 This is an associative array attribute defined on language names,
16280 whose value is a list of strings.
16282 This attribute is not significant for Ada.
16284 For C and C++, each string in the list denotes the name of a file that
16285 contains source code, but whose suffix is not necessarily the
16286 @code{Body_Suffix} for the language.
16289 The following attributes of package @code{Naming} are obsolescent. They are
16290 kept as synonyms of other attributes for compatibility with previous versions
16291 of the Project Manager.
16294 @item Specification_Suffix
16295 This is a synonym of @code{Spec_Suffix}.
16297 @item Implementation_Suffix
16298 This is a synonym of @code{Body_Suffix}.
16300 @item Specification
16301 This is a synonym of @code{Spec}.
16303 @item Implementation
16304 This is a synonym of @code{Body}.
16307 @subsection package Compiler
16310 The attributes of the @code{Compiler} package specify the compilation options
16311 to be used by the underlying compiler.
16314 @item Default_Switches
16315 This is an associative array attribute. Its
16316 domain is a set of language names. Its range is a string list that
16317 specifies the compilation options to be used when compiling a component
16318 written in that language, for which no file-specific switches have been
16322 This is an associative array attribute. Its domain is
16323 a set of file names. Its range is a string list that specifies the
16324 compilation options to be used when compiling the named file. If a file
16325 is not specified in the Switches attribute, it is compiled with the
16326 options specified by Default_Switches of its language, if defined.
16328 @item Local_Configuration_Pragmas.
16329 This is a simple attribute, whose
16330 value is a path name that designates a file containing configuration pragmas
16331 to be used for all invocations of the compiler for immediate sources of the
16335 @subsection package Builder
16338 The attributes of package @code{Builder} specify the compilation, binding, and
16339 linking options to be used when building an executable for a project. The
16340 following attributes apply to package @code{Builder}:
16343 @item Default_Switches
16344 This is an associative array attribute. Its
16345 domain is a set of language names. Its range is a string list that
16346 specifies options to be used when building a main
16347 written in that language, for which no file-specific switches have been
16351 This is an associative array attribute. Its domain is
16352 a set of file names. Its range is a string list that specifies
16353 options to be used when building the named main file. If a main file
16354 is not specified in the Switches attribute, it is built with the
16355 options specified by Default_Switches of its language, if defined.
16357 @item Global_Configuration_Pragmas
16358 This is a simple attribute, whose
16359 value is a path name that designates a file that contains configuration pragmas
16360 to be used in every build of an executable. If both local and global
16361 configuration pragmas are specified, a compilation makes use of both sets.
16365 This is an associative array attribute. Its domain is
16366 a set of main source file names. Its range is a simple string that specifies
16367 the executable file name to be used when linking the specified main source.
16368 If a main source is not specified in the Executable attribute, the executable
16369 file name is deducted from the main source file name.
16370 This attribute has no effect if its value is the empty string.
16372 @item Executable_Suffix
16373 This is a simple attribute whose value is the suffix to be added to
16374 the executables that don't have an attribute Executable specified.
16377 @subsection package Gnatls
16380 The attributes of package @code{Gnatls} specify the tool options to be used
16381 when invoking the library browser @command{gnatls}.
16382 The following attributes apply to package @code{Gnatls}:
16386 This is a single attribute with a string list value. Each nonempty string
16387 in the list is an option when invoking @code{gnatls}.
16390 @subsection package Binder
16393 The attributes of package @code{Binder} specify the options to be used
16394 when invoking the binder in the construction of an executable.
16395 The following attributes apply to package @code{Binder}:
16398 @item Default_Switches
16399 This is an associative array attribute. Its
16400 domain is a set of language names. Its range is a string list that
16401 specifies options to be used when binding a main
16402 written in that language, for which no file-specific switches have been
16406 This is an associative array attribute. Its domain is
16407 a set of file names. Its range is a string list that specifies
16408 options to be used when binding the named main file. If a main file
16409 is not specified in the Switches attribute, it is bound with the
16410 options specified by Default_Switches of its language, if defined.
16413 @subsection package Linker
16416 The attributes of package @code{Linker} specify the options to be used when
16417 invoking the linker in the construction of an executable.
16418 The following attributes apply to package @code{Linker}:
16421 @item Default_Switches
16422 This is an associative array attribute. Its
16423 domain is a set of language names. Its range is a string list that
16424 specifies options to be used when linking a main
16425 written in that language, for which no file-specific switches have been
16429 This is an associative array attribute. Its domain is
16430 a set of file names. Its range is a string list that specifies
16431 options to be used when linking the named main file. If a main file
16432 is not specified in the Switches attribute, it is linked with the
16433 options specified by Default_Switches of its language, if defined.
16435 @item Linker_Options
16436 This is a string list attribute. Its value specifies additional options that
16437 be given to the linker when linking an executable. This attribute is not
16438 used in the main project, only in projects imported directly or indirectly.
16442 @subsection package Cross_Reference
16445 The attributes of package @code{Cross_Reference} specify the tool options
16447 when invoking the library tool @command{gnatxref}.
16448 The following attributes apply to package @code{Cross_Reference}:
16451 @item Default_Switches
16452 This is an associative array attribute. Its
16453 domain is a set of language names. Its range is a string list that
16454 specifies options to be used when calling @command{gnatxref} on a source
16455 written in that language, for which no file-specific switches have been
16459 This is an associative array attribute. Its domain is
16460 a set of file names. Its range is a string list that specifies
16461 options to be used when calling @command{gnatxref} on the named main source.
16462 If a source is not specified in the Switches attribute, @command{gnatxref} will
16463 be called with the options specified by Default_Switches of its language,
16467 @subsection package Finder
16470 The attributes of package @code{Finder} specify the tool options to be used
16471 when invoking the search tool @command{gnatfind}.
16472 The following attributes apply to package @code{Finder}:
16475 @item Default_Switches
16476 This is an associative array attribute. Its
16477 domain is a set of language names. Its range is a string list that
16478 specifies options to be used when calling @command{gnatfind} on a source
16479 written in that language, for which no file-specific switches have been
16483 This is an associative array attribute. Its domain is
16484 a set of file names. Its range is a string list that specifies
16485 options to be used when calling @command{gnatfind} on the named main source.
16486 If a source is not specified in the Switches attribute, @command{gnatfind} will
16487 be called with the options specified by Default_Switches of its language,
16491 @subsection package Pretty_Printer
16494 The attributes of package @code{Pretty_Printer}
16495 specify the tool options to be used
16496 when invoking the formatting tool @command{gnatpp}.
16497 The following attributes apply to package @code{Pretty_Printer}:
16500 @item Default_switches
16501 This is an associative array attribute. Its
16502 domain is a set of language names. Its range is a string list that
16503 specifies options to be used when calling @command{gnatpp} on a source
16504 written in that language, for which no file-specific switches have been
16508 This is an associative array attribute. Its domain is
16509 a set of file names. Its range is a string list that specifies
16510 options to be used when calling @command{gnatpp} on the named main source.
16511 If a source is not specified in the Switches attribute, @command{gnatpp} will
16512 be called with the options specified by Default_Switches of its language,
16516 @subsection package gnatstub
16519 The attributes of package @code{gnatstub}
16520 specify the tool options to be used
16521 when invoking the tool @command{gnatstub}.
16522 The following attributes apply to package @code{gnatstub}:
16525 @item Default_switches
16526 This is an associative array attribute. Its
16527 domain is a set of language names. Its range is a string list that
16528 specifies options to be used when calling @command{gnatstub} on a source
16529 written in that language, for which no file-specific switches have been
16533 This is an associative array attribute. Its domain is
16534 a set of file names. Its range is a string list that specifies
16535 options to be used when calling @command{gnatstub} on the named main source.
16536 If a source is not specified in the Switches attribute, @command{gnatpp} will
16537 be called with the options specified by Default_Switches of its language,
16541 @subsection package Eliminate
16544 The attributes of package @code{Eliminate}
16545 specify the tool options to be used
16546 when invoking the tool @command{gnatelim}.
16547 The following attributes apply to package @code{Eliminate}:
16550 @item Default_switches
16551 This is an associative array attribute. Its
16552 domain is a set of language names. Its range is a string list that
16553 specifies options to be used when calling @command{gnatelim} on a source
16554 written in that language, for which no file-specific switches have been
16558 This is an associative array attribute. Its domain is
16559 a set of file names. Its range is a string list that specifies
16560 options to be used when calling @command{gnatelim} on the named main source.
16561 If a source is not specified in the Switches attribute, @command{gnatelim} will
16562 be called with the options specified by Default_Switches of its language,
16566 @subsection package Metrics
16569 The attributes of package @code{Metrics}
16570 specify the tool options to be used
16571 when invoking the tool @command{gnatmetric}.
16572 The following attributes apply to package @code{Metrics}:
16575 @item Default_switches
16576 This is an associative array attribute. Its
16577 domain is a set of language names. Its range is a string list that
16578 specifies options to be used when calling @command{gnatmetric} on a source
16579 written in that language, for which no file-specific switches have been
16583 This is an associative array attribute. Its domain is
16584 a set of file names. Its range is a string list that specifies
16585 options to be used when calling @command{gnatmetric} on the named main source.
16586 If a source is not specified in the Switches attribute, @command{gnatmetric}
16587 will be called with the options specified by Default_Switches of its language,
16591 @subsection package IDE
16594 The attributes of package @code{IDE} specify the options to be used when using
16595 an Integrated Development Environment such as @command{GPS}.
16599 This is a simple attribute. Its value is a string that designates the remote
16600 host in a cross-compilation environment, to be used for remote compilation and
16601 debugging. This field should not be specified when running on the local
16605 This is a simple attribute. Its value is a string that specifies the
16606 name of IP address of the embedded target in a cross-compilation environment,
16607 on which the program should execute.
16609 @item Communication_Protocol
16610 This is a simple string attribute. Its value is the name of the protocol
16611 to use to communicate with the target in a cross-compilation environment,
16612 e.g.@: @code{"wtx"} or @code{"vxworks"}.
16614 @item Compiler_Command
16615 This is an associative array attribute, whose domain is a language name. Its
16616 value is string that denotes the command to be used to invoke the compiler.
16617 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16618 gnatmake, in particular in the handling of switches.
16620 @item Debugger_Command
16621 This is simple attribute, Its value is a string that specifies the name of
16622 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16624 @item Default_Switches
16625 This is an associative array attribute. Its indexes are the name of the
16626 external tools that the GNAT Programming System (GPS) is supporting. Its
16627 value is a list of switches to use when invoking that tool.
16630 This is a simple attribute. Its value is a string that specifies the name
16631 of the @command{gnatls} utility to be used to retrieve information about the
16632 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16635 This is a simple attribute. Its value is a string used to specify the
16636 Version Control System (VCS) to be used for this project, e.g.@: CVS, RCS
16637 ClearCase or Perforce.
16639 @item VCS_File_Check
16640 This is a simple attribute. Its value is a string that specifies the
16641 command used by the VCS to check the validity of a file, either
16642 when the user explicitly asks for a check, or as a sanity check before
16643 doing the check-in.
16645 @item VCS_Log_Check
16646 This is a simple attribute. Its value is a string that specifies
16647 the command used by the VCS to check the validity of a log file.
16649 @item VCS_Repository_Root
16650 The VCS repository root path. This is used to create tags or branches
16651 of the repository. For subversion the value should be the @code{URL}
16652 as specified to check-out the working copy of the repository.
16654 @item VCS_Patch_Root
16655 The local root directory to use for building patch file. All patch chunks
16656 will be relative to this path. The root project directory is used if
16657 this value is not defined.
16661 @node Package Renamings
16662 @section Package Renamings
16665 A package can be defined by a renaming declaration. The new package renames
16666 a package declared in a different project file, and has the same attributes
16667 as the package it renames.
16670 package_renaming ::==
16671 @b{package} package_identifier @b{renames}
16672 <project_>simple_name.package_identifier ;
16676 The package_identifier of the renamed package must be the same as the
16677 package_identifier. The project whose name is the prefix of the renamed
16678 package must contain a package declaration with this name. This project
16679 must appear in the context_clause of the enclosing project declaration,
16680 or be the parent project of the enclosing child project.
16686 A project file specifies a set of rules for constructing a software system.
16687 A project file can be self-contained, or depend on other project files.
16688 Dependencies are expressed through a context clause that names other projects.
16694 context_clause project_declaration
16696 project_declaration ::=
16697 simple_project_declaration | project_extension
16699 simple_project_declaration ::=
16700 @b{project} <project_>simple_name @b{is}
16701 @{declarative_item@}
16702 @b{end} <project_>simple_name;
16708 [@b{limited}] @b{with} path_name @{ , path_name @} ;
16715 A path name denotes a project file. A path name can be absolute or relative.
16716 An absolute path name includes a sequence of directories, in the syntax of
16717 the host operating system, that identifies uniquely the project file in the
16718 file system. A relative path name identifies the project file, relative
16719 to the directory that contains the current project, or relative to a
16720 directory listed in the environment variable ADA_PROJECT_PATH.
16721 Path names are case sensitive if file names in the host operating system
16722 are case sensitive.
16724 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16725 directory names separated by colons (semicolons on Windows).
16727 A given project name can appear only once in a context_clause.
16729 It is illegal for a project imported by a context clause to refer, directly
16730 or indirectly, to the project in which this context clause appears (the
16731 dependency graph cannot contain cycles), except when one of the with_clause
16732 in the cycle is a @code{limited with}.
16734 @node Project Extensions
16735 @section Project Extensions
16738 A project extension introduces a new project, which inherits the declarations
16739 of another project.
16743 project_extension ::=
16744 @b{project} <project_>simple_name @b{extends} path_name @b{is}
16745 @{declarative_item@}
16746 @b{end} <project_>simple_name;
16750 The project extension declares a child project. The child project inherits
16751 all the declarations and all the files of the parent project, These inherited
16752 declaration can be overridden in the child project, by means of suitable
16755 @node Project File Elaboration
16756 @section Project File Elaboration
16759 A project file is processed as part of the invocation of a gnat tool that
16760 uses the project option. Elaboration of the process file consists in the
16761 sequential elaboration of all its declarations. The computed values of
16762 attributes and variables in the project are then used to establish the
16763 environment in which the gnat tool will execute.
16765 @node Obsolescent Features
16766 @chapter Obsolescent Features
16769 This chapter describes features that are provided by GNAT, but are
16770 considered obsolescent since there are preferred ways of achieving
16771 the same effect. These features are provided solely for historical
16772 compatibility purposes.
16775 * pragma No_Run_Time::
16776 * pragma Ravenscar::
16777 * pragma Restricted_Run_Time::
16780 @node pragma No_Run_Time
16781 @section pragma No_Run_Time
16783 The pragma @code{No_Run_Time} is used to achieve an affect similar
16784 to the use of the "Zero Foot Print" configurable run time, but without
16785 requiring a specially configured run time. The result of using this
16786 pragma, which must be used for all units in a partition, is to restrict
16787 the use of any language features requiring run-time support code. The
16788 preferred usage is to use an appropriately configured run-time that
16789 includes just those features that are to be made accessible.
16791 @node pragma Ravenscar
16792 @section pragma Ravenscar
16794 The pragma @code{Ravenscar} has exactly the same effect as pragma
16795 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16796 is part of the new Ada 2005 standard.
16798 @node pragma Restricted_Run_Time
16799 @section pragma Restricted_Run_Time
16801 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16802 pragma @code{Profile (Restricted)}. The latter usage is
16803 preferred since the Ada 2005 pragma @code{Profile} is intended for
16804 this kind of implementation dependent addition.
16807 @c GNU Free Documentation License
16809 @node Index,,GNU Free Documentation License, Top