1 \input texinfo @c -*-texinfo-*-
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
7 @c GNAT DOCUMENTATION o
11 @c Copyright (C) 1995-2007, Free Software Foundation o
14 @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o
16 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
18 @setfilename gnat_rm.info
21 @set DEFAULTLANGUAGEVERSION Ada 2005
22 @set NONDEFAULTLANGUAGEVERSION Ada 95
24 @settitle GNAT Reference Manual
26 @setchapternewpage odd
29 @include gcc-common.texi
31 @dircategory GNU Ada tools
33 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
37 Copyright @copyright{} 1995-2007, 2008 Free Software Foundation, Inc.
39 Permission is granted to copy, distribute and/or modify this document
40 under the terms of the GNU Free Documentation License, Version 1.2
41 or any later version published by the Free Software Foundation;
42 with the Invariant Sections being ``GNU Free Documentation License'',
43 with the Front-Cover Texts being ``GNAT Reference Manual'', and with
44 no Back-Cover Texts. A copy of the license is included in the section
45 entitled ``GNU Free Documentation License''.
49 @title GNAT Reference Manual
50 @subtitle GNAT, The GNU Ada Compiler
54 @vskip 0pt plus 1filll
61 @node Top, About This Guide, (dir), (dir)
62 @top GNAT Reference Manual
68 GNAT, The GNU Ada Compiler@*
69 GCC version @value{version-GCC}@*
76 * Implementation Defined Pragmas::
77 * Implementation Defined Attributes::
78 * Implementation Advice::
79 * Implementation Defined Characteristics::
80 * Intrinsic Subprograms::
81 * Representation Clauses and Pragmas::
82 * Standard Library Routines::
83 * The Implementation of Standard I/O::
85 * Interfacing to Other Languages::
86 * Specialized Needs Annexes::
87 * Implementation of Specific Ada Features::
88 * Project File Reference::
89 * Obsolescent Features::
90 * GNU Free Documentation License::
93 --- The Detailed Node Listing ---
97 * What This Reference Manual Contains::
98 * Related Information::
100 Implementation Defined Pragmas
102 * Pragma Abort_Defer::
110 * Pragma C_Pass_By_Copy::
111 * Pragma Check_Name::
113 * Pragma Common_Object::
114 * Pragma Compile_Time_Error::
115 * Pragma Compile_Time_Warning::
116 * Pragma Complete_Representation::
117 * Pragma Complex_Representation::
118 * Pragma Component_Alignment::
119 * Pragma Convention_Identifier::
121 * Pragma CPP_Constructor::
122 * Pragma CPP_Virtual::
123 * Pragma CPP_Vtable::
125 * Pragma Debug_Policy::
126 * Pragma Detect_Blocking::
127 * Pragma Elaboration_Checks::
129 * Pragma Export_Exception::
130 * Pragma Export_Function::
131 * Pragma Export_Object::
132 * Pragma Export_Procedure::
133 * Pragma Export_Value::
134 * Pragma Export_Valued_Procedure::
135 * Pragma Extend_System::
137 * Pragma External_Name_Casing::
139 * Pragma Favor_Top_Level::
140 * Pragma Finalize_Storage_Only::
141 * Pragma Float_Representation::
143 * Pragma Implemented_By_Entry::
144 * Pragma Implicit_Packing::
145 * Pragma Import_Exception::
146 * Pragma Import_Function::
147 * Pragma Import_Object::
148 * Pragma Import_Procedure::
149 * Pragma Import_Valued_Procedure::
150 * Pragma Initialize_Scalars::
151 * Pragma Inline_Always::
152 * Pragma Inline_Generic::
154 * Pragma Interface_Name::
155 * Pragma Interrupt_Handler::
156 * Pragma Interrupt_State::
157 * Pragma Keep_Names::
160 * Pragma Linker_Alias::
161 * Pragma Linker_Constructor::
162 * Pragma Linker_Destructor::
163 * Pragma Linker_Section::
164 * Pragma Long_Float::
165 * Pragma Machine_Attribute::
167 * Pragma Main_Storage::
170 * Pragma No_Strict_Aliasing ::
171 * Pragma Normalize_Scalars::
172 * Pragma Obsolescent::
174 * Pragma Persistent_BSS::
176 * Pragma Profile (Ravenscar)::
177 * Pragma Profile (Restricted)::
178 * Pragma Psect_Object::
179 * Pragma Pure_Function::
180 * Pragma Restriction_Warnings::
182 * Pragma Source_File_Name::
183 * Pragma Source_File_Name_Project::
184 * Pragma Source_Reference::
185 * Pragma Stream_Convert::
186 * Pragma Style_Checks::
189 * Pragma Suppress_All::
190 * Pragma Suppress_Exception_Locations::
191 * Pragma Suppress_Initialization::
194 * Pragma Task_Storage::
195 * Pragma Time_Slice::
197 * Pragma Unchecked_Union::
198 * Pragma Unimplemented_Unit::
199 * Pragma Universal_Aliasing ::
200 * Pragma Universal_Data::
201 * Pragma Unreferenced::
202 * Pragma Unreferenced_Objects::
203 * Pragma Unreserve_All_Interrupts::
204 * Pragma Unsuppress::
205 * Pragma Use_VADS_Size::
206 * Pragma Validity_Checks::
209 * Pragma Weak_External::
210 * Pragma Wide_Character_Encoding::
212 Implementation Defined Attributes
222 * Default_Bit_Order::
231 * Has_Access_Values::
232 * Has_Discriminants::
238 * Max_Interrupt_Priority::
240 * Maximum_Alignment::
244 * Passed_By_Reference::
257 * Unconstrained_Array::
258 * Universal_Literal_String::
259 * Unrestricted_Access::
265 The Implementation of Standard I/O
267 * Standard I/O Packages::
273 * Wide_Wide_Text_IO::
276 * Filenames encoding::
278 * Operations on C Streams::
279 * Interfacing to C Streams::
283 * Ada.Characters.Latin_9 (a-chlat9.ads)::
284 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
285 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
286 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
287 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
288 * Ada.Command_Line.Remove (a-colire.ads)::
289 * Ada.Command_Line.Environment (a-colien.ads)::
290 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
291 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
292 * Ada.Exceptions.Traceback (a-exctra.ads)::
293 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
294 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
295 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
296 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
297 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
298 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
299 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
300 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
301 * GNAT.Altivec (g-altive.ads)::
302 * GNAT.Altivec.Conversions (g-altcon.ads)::
303 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
304 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
305 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
306 * GNAT.Array_Split (g-arrspl.ads)::
307 * GNAT.AWK (g-awk.ads)::
308 * GNAT.Bounded_Buffers (g-boubuf.ads)::
309 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
310 * GNAT.Bubble_Sort (g-bubsor.ads)::
311 * GNAT.Bubble_Sort_A (g-busora.ads)::
312 * GNAT.Bubble_Sort_G (g-busorg.ads)::
313 * GNAT.Byte_Order_Mark (g-byorma.ads)::
314 * GNAT.Byte_Swapping (g-bytswa.ads)::
315 * GNAT.Calendar (g-calend.ads)::
316 * GNAT.Calendar.Time_IO (g-catiio.ads)::
317 * GNAT.Case_Util (g-casuti.ads)::
318 * GNAT.CGI (g-cgi.ads)::
319 * GNAT.CGI.Cookie (g-cgicoo.ads)::
320 * GNAT.CGI.Debug (g-cgideb.ads)::
321 * GNAT.Command_Line (g-comlin.ads)::
322 * GNAT.Compiler_Version (g-comver.ads)::
323 * GNAT.Ctrl_C (g-ctrl_c.ads)::
324 * GNAT.CRC32 (g-crc32.ads)::
325 * GNAT.Current_Exception (g-curexc.ads)::
326 * GNAT.Debug_Pools (g-debpoo.ads)::
327 * GNAT.Debug_Utilities (g-debuti.ads)::
328 * GNAT.Decode_String (g-decstr.ads)::
329 * GNAT.Decode_UTF8_String (g-deutst.ads)::
330 * GNAT.Directory_Operations (g-dirope.ads)::
331 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
332 * GNAT.Dynamic_HTables (g-dynhta.ads)::
333 * GNAT.Dynamic_Tables (g-dyntab.ads)::
334 * GNAT.Encode_String (g-encstr.ads)::
335 * GNAT.Encode_UTF8_String (g-enutst.ads)::
336 * GNAT.Exception_Actions (g-excact.ads)::
337 * GNAT.Exception_Traces (g-exctra.ads)::
338 * GNAT.Exceptions (g-except.ads)::
339 * GNAT.Expect (g-expect.ads)::
340 * GNAT.Float_Control (g-flocon.ads)::
341 * GNAT.Heap_Sort (g-heasor.ads)::
342 * GNAT.Heap_Sort_A (g-hesora.ads)::
343 * GNAT.Heap_Sort_G (g-hesorg.ads)::
344 * GNAT.HTable (g-htable.ads)::
345 * GNAT.IO (g-io.ads)::
346 * GNAT.IO_Aux (g-io_aux.ads)::
347 * GNAT.Lock_Files (g-locfil.ads)::
348 * GNAT.MD5 (g-md5.ads)::
349 * GNAT.Memory_Dump (g-memdum.ads)::
350 * GNAT.Most_Recent_Exception (g-moreex.ads)::
351 * GNAT.OS_Lib (g-os_lib.ads)::
352 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
353 * GNAT.Random_Numbers (g-rannum.ads)
354 * GNAT.Regexp (g-regexp.ads)::
355 * GNAT.Registry (g-regist.ads)::
356 * GNAT.Regpat (g-regpat.ads)::
357 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
358 * GNAT.Semaphores (g-semaph.ads)::
359 * GNAT.SHA1 (g-sha1.ads)::
360 * GNAT.Signals (g-signal.ads)::
361 * GNAT.Sockets (g-socket.ads)::
362 * GNAT.Source_Info (g-souinf.ads)::
363 * GNAT.Spelling_Checker (g-speche.ads)::
364 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
365 * GNAT.Spitbol.Patterns (g-spipat.ads)::
366 * GNAT.Spitbol (g-spitbo.ads)::
367 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
368 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
369 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
370 * GNAT.Strings (g-string.ads)::
371 * GNAT.String_Split (g-strspl.ads)::
372 * GNAT.Table (g-table.ads)::
373 * GNAT.Task_Lock (g-tasloc.ads)::
374 * GNAT.Threads (g-thread.ads)::
375 * GNAT.Traceback (g-traceb.ads)::
376 * GNAT.Traceback.Symbolic (g-trasym.ads)::
377 * GNAT.UTF_32 (g-utf_32.ads)::
378 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
379 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
380 * GNAT.Wide_String_Split (g-wistsp.ads)::
381 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
382 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
383 * Interfaces.C.Extensions (i-cexten.ads)::
384 * Interfaces.C.Streams (i-cstrea.ads)::
385 * Interfaces.CPP (i-cpp.ads)::
386 * Interfaces.Os2lib (i-os2lib.ads)::
387 * Interfaces.Os2lib.Errors (i-os2err.ads)::
388 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
389 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
390 * Interfaces.Packed_Decimal (i-pacdec.ads)::
391 * Interfaces.VxWorks (i-vxwork.ads)::
392 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
393 * System.Address_Image (s-addima.ads)::
394 * System.Assertions (s-assert.ads)::
395 * System.Memory (s-memory.ads)::
396 * System.Partition_Interface (s-parint.ads)::
397 * System.Restrictions (s-restri.ads)::
398 * System.Rident (s-rident.ads)::
399 * System.Task_Info (s-tasinf.ads)::
400 * System.Wch_Cnv (s-wchcnv.ads)::
401 * System.Wch_Con (s-wchcon.ads)::
405 * Text_IO Stream Pointer Positioning::
406 * Text_IO Reading and Writing Non-Regular Files::
408 * Treating Text_IO Files as Streams::
409 * Text_IO Extensions::
410 * Text_IO Facilities for Unbounded Strings::
414 * Wide_Text_IO Stream Pointer Positioning::
415 * Wide_Text_IO Reading and Writing Non-Regular Files::
419 * Wide_Wide_Text_IO Stream Pointer Positioning::
420 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
422 Interfacing to Other Languages
425 * Interfacing to C++::
426 * Interfacing to COBOL::
427 * Interfacing to Fortran::
428 * Interfacing to non-GNAT Ada code::
430 Specialized Needs Annexes
432 Implementation of Specific Ada Features
433 * Machine Code Insertions::
434 * GNAT Implementation of Tasking::
435 * GNAT Implementation of Shared Passive Packages::
436 * Code Generation for Array Aggregates::
437 * The Size of Discriminated Records with Default Discriminants::
438 * Strict Conformance to the Ada Reference Manual::
440 Project File Reference
444 GNU Free Documentation License
451 @node About This Guide
452 @unnumbered About This Guide
455 This manual contains useful information in writing programs using the
456 @value{EDITION} compiler. It includes information on implementation dependent
457 characteristics of @value{EDITION}, including all the information required by
458 Annex M of the Ada language standard.
460 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
461 Ada 83 compatibility mode.
462 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
463 but you can override with a compiler switch
464 to explicitly specify the language version.
465 (Please refer to the section ``Compiling Different Versions of Ada'', in
466 @cite{@value{EDITION} User's Guide}, for details on these switches.)
467 Throughout this manual, references to ``Ada'' without a year suffix
468 apply to both the Ada 95 and Ada 2005 versions of the language.
470 Ada is designed to be highly portable.
471 In general, a program will have the same effect even when compiled by
472 different compilers on different platforms.
473 However, since Ada is designed to be used in a
474 wide variety of applications, it also contains a number of system
475 dependent features to be used in interfacing to the external world.
476 @cindex Implementation-dependent features
479 Note: Any program that makes use of implementation-dependent features
480 may be non-portable. You should follow good programming practice and
481 isolate and clearly document any sections of your program that make use
482 of these features in a non-portable manner.
485 For ease of exposition, ``GNAT Pro'' will be referred to simply as
486 ``GNAT'' in the remainder of this document.
490 * What This Reference Manual Contains::
492 * Related Information::
495 @node What This Reference Manual Contains
496 @unnumberedsec What This Reference Manual Contains
499 This reference manual contains the following chapters:
503 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
504 pragmas, which can be used to extend and enhance the functionality of the
508 @ref{Implementation Defined Attributes}, lists GNAT
509 implementation-dependent attributes which can be used to extend and
510 enhance the functionality of the compiler.
513 @ref{Implementation Advice}, provides information on generally
514 desirable behavior which are not requirements that all compilers must
515 follow since it cannot be provided on all systems, or which may be
516 undesirable on some systems.
519 @ref{Implementation Defined Characteristics}, provides a guide to
520 minimizing implementation dependent features.
523 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
524 implemented by GNAT, and how they can be imported into user
525 application programs.
528 @ref{Representation Clauses and Pragmas}, describes in detail the
529 way that GNAT represents data, and in particular the exact set
530 of representation clauses and pragmas that is accepted.
533 @ref{Standard Library Routines}, provides a listing of packages and a
534 brief description of the functionality that is provided by Ada's
535 extensive set of standard library routines as implemented by GNAT@.
538 @ref{The Implementation of Standard I/O}, details how the GNAT
539 implementation of the input-output facilities.
542 @ref{The GNAT Library}, is a catalog of packages that complement
543 the Ada predefined library.
546 @ref{Interfacing to Other Languages}, describes how programs
547 written in Ada using GNAT can be interfaced to other programming
550 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
551 of the specialized needs annexes.
554 @ref{Implementation of Specific Ada Features}, discusses issues related
555 to GNAT's implementation of machine code insertions, tasking, and several
559 @ref{Project File Reference}, presents the syntax and semantics
563 @ref{Obsolescent Features} documents implementation dependent features,
564 including pragmas and attributes, which are considered obsolescent, since
565 there are other preferred ways of achieving the same results. These
566 obsolescent forms are retained for backwards compatibility.
570 @cindex Ada 95 Language Reference Manual
571 @cindex Ada 2005 Language Reference Manual
573 This reference manual assumes a basic familiarity with the Ada 95 language, as
574 described in the International Standard ANSI/ISO/IEC-8652:1995,
576 It does not require knowledge of the new features introduced by Ada 2005,
577 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
579 Both reference manuals are included in the GNAT documentation
583 @unnumberedsec Conventions
584 @cindex Conventions, typographical
585 @cindex Typographical conventions
588 Following are examples of the typographical and graphic conventions used
593 @code{Functions}, @code{utility program names}, @code{standard names},
600 @file{File names}, @samp{button names}, and @samp{field names}.
603 @code{Variables}, @env{environment variables}, and @var{metasyntactic
610 [optional information or parameters]
613 Examples are described by text
615 and then shown this way.
620 Commands that are entered by the user are preceded in this manual by the
621 characters @samp{$ } (dollar sign followed by space). If your system uses this
622 sequence as a prompt, then the commands will appear exactly as you see them
623 in the manual. If your system uses some other prompt, then the command will
624 appear with the @samp{$} replaced by whatever prompt character you are using.
626 @node Related Information
627 @unnumberedsec Related Information
629 See the following documents for further information on GNAT:
633 @cite{GNAT User's Guide}, which provides information on how to use
634 the GNAT compiler system.
637 @cite{Ada 95 Reference Manual}, which contains all reference
638 material for the Ada 95 programming language.
641 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
642 of the Ada 95 standard. The annotations describe
643 detailed aspects of the design decision, and in particular contain useful
644 sections on Ada 83 compatibility.
647 @cite{Ada 2005 Reference Manual}, which contains all reference
648 material for the Ada 2005 programming language.
651 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
652 of the Ada 2005 standard. The annotations describe
653 detailed aspects of the design decision, and in particular contain useful
654 sections on Ada 83 and Ada 95 compatibility.
657 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
658 which contains specific information on compatibility between GNAT and
662 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
663 describes in detail the pragmas and attributes provided by the DEC Ada 83
668 @node Implementation Defined Pragmas
669 @chapter Implementation Defined Pragmas
672 Ada defines a set of pragmas that can be used to supply additional
673 information to the compiler. These language defined pragmas are
674 implemented in GNAT and work as described in the Ada Reference
677 In addition, Ada allows implementations to define additional pragmas
678 whose meaning is defined by the implementation. GNAT provides a number
679 of these implementation-defined pragmas, which can be used to extend
680 and enhance the functionality of the compiler. This section of the GNAT
681 Reference Manual describes these additional pragmas.
683 Note that any program using these pragmas might not be portable to other
684 compilers (although GNAT implements this set of pragmas on all
685 platforms). Therefore if portability to other compilers is an important
686 consideration, the use of these pragmas should be minimized.
689 * Pragma Abort_Defer::
697 * Pragma C_Pass_By_Copy::
698 * Pragma Check_Name::
700 * Pragma Common_Object::
701 * Pragma Compile_Time_Error::
702 * Pragma Compile_Time_Warning::
703 * Pragma Complete_Representation::
704 * Pragma Complex_Representation::
705 * Pragma Component_Alignment::
706 * Pragma Convention_Identifier::
708 * Pragma CPP_Constructor::
709 * Pragma CPP_Virtual::
710 * Pragma CPP_Vtable::
712 * Pragma Debug_Policy::
713 * Pragma Detect_Blocking::
714 * Pragma Elaboration_Checks::
716 * Pragma Export_Exception::
717 * Pragma Export_Function::
718 * Pragma Export_Object::
719 * Pragma Export_Procedure::
720 * Pragma Export_Value::
721 * Pragma Export_Valued_Procedure::
722 * Pragma Extend_System::
724 * Pragma External_Name_Casing::
726 * Pragma Favor_Top_Level::
727 * Pragma Finalize_Storage_Only::
728 * Pragma Float_Representation::
730 * Pragma Implemented_By_Entry::
731 * Pragma Implicit_Packing::
732 * Pragma Import_Exception::
733 * Pragma Import_Function::
734 * Pragma Import_Object::
735 * Pragma Import_Procedure::
736 * Pragma Import_Valued_Procedure::
737 * Pragma Initialize_Scalars::
738 * Pragma Inline_Always::
739 * Pragma Inline_Generic::
741 * Pragma Interface_Name::
742 * Pragma Interrupt_Handler::
743 * Pragma Interrupt_State::
744 * Pragma Keep_Names::
747 * Pragma Linker_Alias::
748 * Pragma Linker_Constructor::
749 * Pragma Linker_Destructor::
750 * Pragma Linker_Section::
751 * Pragma Long_Float::
752 * Pragma Machine_Attribute::
754 * Pragma Main_Storage::
757 * Pragma No_Strict_Aliasing::
758 * Pragma Normalize_Scalars::
759 * Pragma Obsolescent::
761 * Pragma Persistent_BSS::
763 * Pragma Profile (Ravenscar)::
764 * Pragma Profile (Restricted)::
765 * Pragma Psect_Object::
766 * Pragma Pure_Function::
767 * Pragma Restriction_Warnings::
769 * Pragma Source_File_Name::
770 * Pragma Source_File_Name_Project::
771 * Pragma Source_Reference::
772 * Pragma Stream_Convert::
773 * Pragma Style_Checks::
776 * Pragma Suppress_All::
777 * Pragma Suppress_Exception_Locations::
778 * Pragma Suppress_Initialization::
781 * Pragma Task_Storage::
782 * Pragma Time_Slice::
784 * Pragma Unchecked_Union::
785 * Pragma Unimplemented_Unit::
786 * Pragma Universal_Aliasing ::
787 * Pragma Universal_Data::
788 * Pragma Unreferenced::
789 * Pragma Unreferenced_Objects::
790 * Pragma Unreserve_All_Interrupts::
791 * Pragma Unsuppress::
792 * Pragma Use_VADS_Size::
793 * Pragma Validity_Checks::
796 * Pragma Weak_External::
797 * Pragma Wide_Character_Encoding::
800 @node Pragma Abort_Defer
801 @unnumberedsec Pragma Abort_Defer
803 @cindex Deferring aborts
811 This pragma must appear at the start of the statement sequence of a
812 handled sequence of statements (right after the @code{begin}). It has
813 the effect of deferring aborts for the sequence of statements (but not
814 for the declarations or handlers, if any, associated with this statement
818 @unnumberedsec Pragma Ada_83
827 A configuration pragma that establishes Ada 83 mode for the unit to
828 which it applies, regardless of the mode set by the command line
829 switches. In Ada 83 mode, GNAT attempts to be as compatible with
830 the syntax and semantics of Ada 83, as defined in the original Ada
831 83 Reference Manual as possible. In particular, the keywords added by Ada 95
832 and Ada 2005 are not recognized, optional package bodies are allowed,
833 and generics may name types with unknown discriminants without using
834 the @code{(<>)} notation. In addition, some but not all of the additional
835 restrictions of Ada 83 are enforced.
837 Ada 83 mode is intended for two purposes. Firstly, it allows existing
838 Ada 83 code to be compiled and adapted to GNAT with less effort.
839 Secondly, it aids in keeping code backwards compatible with Ada 83.
840 However, there is no guarantee that code that is processed correctly
841 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
842 83 compiler, since GNAT does not enforce all the additional checks
846 @unnumberedsec Pragma Ada_95
855 A configuration pragma that establishes Ada 95 mode for the unit to which
856 it applies, regardless of the mode set by the command line switches.
857 This mode is set automatically for the @code{Ada} and @code{System}
858 packages and their children, so you need not specify it in these
859 contexts. This pragma is useful when writing a reusable component that
860 itself uses Ada 95 features, but which is intended to be usable from
861 either Ada 83 or Ada 95 programs.
864 @unnumberedsec Pragma Ada_05
873 A configuration pragma that establishes Ada 2005 mode for the unit to which
874 it applies, regardless of the mode set by the command line switches.
875 This mode is set automatically for the @code{Ada} and @code{System}
876 packages and their children, so you need not specify it in these
877 contexts. This pragma is useful when writing a reusable component that
878 itself uses Ada 2005 features, but which is intended to be usable from
879 either Ada 83 or Ada 95 programs.
881 @node Pragma Ada_2005
882 @unnumberedsec Pragma Ada_2005
891 This configuration pragma is a synonym for pragma Ada_05 and has the
892 same syntax and effect.
894 @node Pragma Annotate
895 @unnumberedsec Pragma Annotate
900 pragma Annotate (IDENTIFIER @{, ARG@});
902 ARG ::= NAME | EXPRESSION
906 This pragma is used to annotate programs. @var{identifier} identifies
907 the type of annotation. GNAT verifies that it is an identifier, but does
908 not otherwise analyze it. The @var{arg} argument
909 can be either a string literal or an
910 expression. String literals are assumed to be of type
911 @code{Standard.String}. Names of entities are simply analyzed as entity
912 names. All other expressions are analyzed as expressions, and must be
915 The analyzed pragma is retained in the tree, but not otherwise processed
916 by any part of the GNAT compiler. This pragma is intended for use by
917 external tools, including ASIS@.
920 @unnumberedsec Pragma Assert
927 [, static_string_EXPRESSION]);
931 The effect of this pragma depends on whether the corresponding command
932 line switch is set to activate assertions. The pragma expands into code
933 equivalent to the following:
936 if assertions-enabled then
937 if not boolean_EXPRESSION then
938 System.Assertions.Raise_Assert_Failure
945 The string argument, if given, is the message that will be associated
946 with the exception occurrence if the exception is raised. If no second
947 argument is given, the default message is @samp{@var{file}:@var{nnn}},
948 where @var{file} is the name of the source file containing the assert,
949 and @var{nnn} is the line number of the assert. A pragma is not a
950 statement, so if a statement sequence contains nothing but a pragma
951 assert, then a null statement is required in addition, as in:
956 pragma Assert (K > 3, "Bad value for K");
962 Note that, as with the @code{if} statement to which it is equivalent, the
963 type of the expression is either @code{Standard.Boolean}, or any type derived
964 from this standard type.
966 If assertions are disabled (switch @option{-gnata} not used), then there
967 is no run-time effect (and in particular, any side effects from the
968 expression will not occur at run time). (The expression is still
969 analyzed at compile time, and may cause types to be frozen if they are
970 mentioned here for the first time).
972 If assertions are enabled, then the given expression is tested, and if
973 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
974 which results in the raising of @code{Assert_Failure} with the given message.
976 You should generally avoid side effects in the expression arguments of
977 this pragma, because these side effects will turn on and off with the
978 setting of the assertions mode, resulting in assertions that have an
979 effect on the program. However, the expressions are analyzed for
980 semantic correctness whether or not assertions are enabled, so turning
981 assertions on and off cannot affect the legality of a program.
983 @node Pragma Ast_Entry
984 @unnumberedsec Pragma Ast_Entry
990 pragma AST_Entry (entry_IDENTIFIER);
994 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
995 argument is the simple name of a single entry; at most one @code{AST_Entry}
996 pragma is allowed for any given entry. This pragma must be used in
997 conjunction with the @code{AST_Entry} attribute, and is only allowed after
998 the entry declaration and in the same task type specification or single task
999 as the entry to which it applies. This pragma specifies that the given entry
1000 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1001 resulting from an OpenVMS system service call. The pragma does not affect
1002 normal use of the entry. For further details on this pragma, see the
1003 DEC Ada Language Reference Manual, section 9.12a.
1005 @node Pragma C_Pass_By_Copy
1006 @unnumberedsec Pragma C_Pass_By_Copy
1007 @cindex Passing by copy
1008 @findex C_Pass_By_Copy
1011 @smallexample @c ada
1012 pragma C_Pass_By_Copy
1013 ([Max_Size =>] static_integer_EXPRESSION);
1017 Normally the default mechanism for passing C convention records to C
1018 convention subprograms is to pass them by reference, as suggested by RM
1019 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1020 this default, by requiring that record formal parameters be passed by
1021 copy if all of the following conditions are met:
1025 The size of the record type does not exceed the value specified for
1028 The record type has @code{Convention C}.
1030 The formal parameter has this record type, and the subprogram has a
1031 foreign (non-Ada) convention.
1035 If these conditions are met the argument is passed by copy, i.e.@: in a
1036 manner consistent with what C expects if the corresponding formal in the
1037 C prototype is a struct (rather than a pointer to a struct).
1039 You can also pass records by copy by specifying the convention
1040 @code{C_Pass_By_Copy} for the record type, or by using the extended
1041 @code{Import} and @code{Export} pragmas, which allow specification of
1042 passing mechanisms on a parameter by parameter basis.
1044 @node Pragma Check_Name
1045 @unnumberedsec Pragma Check_Name
1046 @cindex Defining check names
1047 @cindex Check names, defining
1051 @smallexample @c ada
1052 pragma Check_Name (check_name_IDENTIFIER);
1056 This is a configuration pragma that defines a new implementation
1057 defined check name (unless IDENTIFIER matches one of the predefined
1058 check names, in which case the pragma has no effect). Check names
1059 are global to a partition, so if two more more configuration pragmas
1060 are present in a partition mentioning the same name, only one new
1061 check name is introduced.
1063 An implementation defined check name introduced with this pragma may
1064 be used in only three contexts: @code{pragma Suppress},
1065 @code{pragma Unsuppress},
1066 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1067 any of these three cases, the check name must be visible. A check
1068 name is visible if it is in the configuration pragmas applying to
1069 the current unit, or if it appears at the start of any unit that
1070 is part of the dependency set of the current unit (e.g., units that
1071 are mentioned in @code{with} clauses).
1073 @node Pragma Comment
1074 @unnumberedsec Pragma Comment
1079 @smallexample @c ada
1080 pragma Comment (static_string_EXPRESSION);
1084 This is almost identical in effect to pragma @code{Ident}. It allows the
1085 placement of a comment into the object file and hence into the
1086 executable file if the operating system permits such usage. The
1087 difference is that @code{Comment}, unlike @code{Ident}, has
1088 no limitations on placement of the pragma (it can be placed
1089 anywhere in the main source unit), and if more than one pragma
1090 is used, all comments are retained.
1092 @node Pragma Common_Object
1093 @unnumberedsec Pragma Common_Object
1094 @findex Common_Object
1098 @smallexample @c ada
1099 pragma Common_Object (
1100 [Internal =>] LOCAL_NAME
1101 [, [External =>] EXTERNAL_SYMBOL]
1102 [, [Size =>] EXTERNAL_SYMBOL] );
1106 | static_string_EXPRESSION
1110 This pragma enables the shared use of variables stored in overlaid
1111 linker areas corresponding to the use of @code{COMMON}
1112 in Fortran. The single
1113 object @var{LOCAL_NAME} is assigned to the area designated by
1114 the @var{External} argument.
1115 You may define a record to correspond to a series
1116 of fields. The @var{Size} argument
1117 is syntax checked in GNAT, but otherwise ignored.
1119 @code{Common_Object} is not supported on all platforms. If no
1120 support is available, then the code generator will issue a message
1121 indicating that the necessary attribute for implementation of this
1122 pragma is not available.
1124 @node Pragma Compile_Time_Error
1125 @unnumberedsec Pragma Compile_Time_Error
1126 @findex Compile_Time_Error
1130 @smallexample @c ada
1131 pragma Compile_Time_Error
1132 (boolean_EXPRESSION, static_string_EXPRESSION);
1136 This pragma can be used to generate additional compile time
1138 is particularly useful in generics, where errors can be issued for
1139 specific problematic instantiations. The first parameter is a boolean
1140 expression. The pragma is effective only if the value of this expression
1141 is known at compile time, and has the value True. The set of expressions
1142 whose values are known at compile time includes all static boolean
1143 expressions, and also other values which the compiler can determine
1144 at compile time (e.g., the size of a record type set by an explicit
1145 size representation clause, or the value of a variable which was
1146 initialized to a constant and is known not to have been modified).
1147 If these conditions are met, an error message is generated using
1148 the value given as the second argument. This string value may contain
1149 embedded ASCII.LF characters to break the message into multiple lines.
1151 @node Pragma Compile_Time_Warning
1152 @unnumberedsec Pragma Compile_Time_Warning
1153 @findex Compile_Time_Warning
1157 @smallexample @c ada
1158 pragma Compile_Time_Warning
1159 (boolean_EXPRESSION, static_string_EXPRESSION);
1163 Same as pragma Compile_Time_Error, except a warning is issued instead
1164 of an error message.
1166 @node Pragma Complete_Representation
1167 @unnumberedsec Pragma Complete_Representation
1168 @findex Complete_Representation
1172 @smallexample @c ada
1173 pragma Complete_Representation;
1177 This pragma must appear immediately within a record representation
1178 clause. Typical placements are before the first component clause
1179 or after the last component clause. The effect is to give an error
1180 message if any component is missing a component clause. This pragma
1181 may be used to ensure that a record representation clause is
1182 complete, and that this invariant is maintained if fields are
1183 added to the record in the future.
1185 @node Pragma Complex_Representation
1186 @unnumberedsec Pragma Complex_Representation
1187 @findex Complex_Representation
1191 @smallexample @c ada
1192 pragma Complex_Representation
1193 ([Entity =>] LOCAL_NAME);
1197 The @var{Entity} argument must be the name of a record type which has
1198 two fields of the same floating-point type. The effect of this pragma is
1199 to force gcc to use the special internal complex representation form for
1200 this record, which may be more efficient. Note that this may result in
1201 the code for this type not conforming to standard ABI (application
1202 binary interface) requirements for the handling of record types. For
1203 example, in some environments, there is a requirement for passing
1204 records by pointer, and the use of this pragma may result in passing
1205 this type in floating-point registers.
1207 @node Pragma Component_Alignment
1208 @unnumberedsec Pragma Component_Alignment
1209 @cindex Alignments of components
1210 @findex Component_Alignment
1214 @smallexample @c ada
1215 pragma Component_Alignment (
1216 [Form =>] ALIGNMENT_CHOICE
1217 [, [Name =>] type_LOCAL_NAME]);
1219 ALIGNMENT_CHOICE ::=
1227 Specifies the alignment of components in array or record types.
1228 The meaning of the @var{Form} argument is as follows:
1231 @findex Component_Size
1232 @item Component_Size
1233 Aligns scalar components and subcomponents of the array or record type
1234 on boundaries appropriate to their inherent size (naturally
1235 aligned). For example, 1-byte components are aligned on byte boundaries,
1236 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1237 integer components are aligned on 4-byte boundaries and so on. These
1238 alignment rules correspond to the normal rules for C compilers on all
1239 machines except the VAX@.
1241 @findex Component_Size_4
1242 @item Component_Size_4
1243 Naturally aligns components with a size of four or fewer
1244 bytes. Components that are larger than 4 bytes are placed on the next
1247 @findex Storage_Unit
1249 Specifies that array or record components are byte aligned, i.e.@:
1250 aligned on boundaries determined by the value of the constant
1251 @code{System.Storage_Unit}.
1255 Specifies that array or record components are aligned on default
1256 boundaries, appropriate to the underlying hardware or operating system or
1257 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1258 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1259 the @code{Default} choice is the same as @code{Component_Size} (natural
1264 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1265 refer to a local record or array type, and the specified alignment
1266 choice applies to the specified type. The use of
1267 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1268 @code{Component_Alignment} pragma to be ignored. The use of
1269 @code{Component_Alignment} together with a record representation clause
1270 is only effective for fields not specified by the representation clause.
1272 If the @code{Name} parameter is absent, the pragma can be used as either
1273 a configuration pragma, in which case it applies to one or more units in
1274 accordance with the normal rules for configuration pragmas, or it can be
1275 used within a declarative part, in which case it applies to types that
1276 are declared within this declarative part, or within any nested scope
1277 within this declarative part. In either case it specifies the alignment
1278 to be applied to any record or array type which has otherwise standard
1281 If the alignment for a record or array type is not specified (using
1282 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1283 clause), the GNAT uses the default alignment as described previously.
1285 @node Pragma Convention_Identifier
1286 @unnumberedsec Pragma Convention_Identifier
1287 @findex Convention_Identifier
1288 @cindex Conventions, synonyms
1292 @smallexample @c ada
1293 pragma Convention_Identifier (
1294 [Name =>] IDENTIFIER,
1295 [Convention =>] convention_IDENTIFIER);
1299 This pragma provides a mechanism for supplying synonyms for existing
1300 convention identifiers. The @code{Name} identifier can subsequently
1301 be used as a synonym for the given convention in other pragmas (including
1302 for example pragma @code{Import} or another @code{Convention_Identifier}
1303 pragma). As an example of the use of this, suppose you had legacy code
1304 which used Fortran77 as the identifier for Fortran. Then the pragma:
1306 @smallexample @c ada
1307 pragma Convention_Identifier (Fortran77, Fortran);
1311 would allow the use of the convention identifier @code{Fortran77} in
1312 subsequent code, avoiding the need to modify the sources. As another
1313 example, you could use this to parametrize convention requirements
1314 according to systems. Suppose you needed to use @code{Stdcall} on
1315 windows systems, and @code{C} on some other system, then you could
1316 define a convention identifier @code{Library} and use a single
1317 @code{Convention_Identifier} pragma to specify which convention
1318 would be used system-wide.
1320 @node Pragma CPP_Class
1321 @unnumberedsec Pragma CPP_Class
1323 @cindex Interfacing with C++
1327 @smallexample @c ada
1328 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1332 The argument denotes an entity in the current declarative region that is
1333 declared as a tagged record type. It indicates that the type corresponds
1334 to an externally declared C++ class type, and is to be laid out the same
1335 way that C++ would lay out the type.
1337 Types for which @code{CPP_Class} is specified do not have assignment or
1338 equality operators defined (such operations can be imported or declared
1339 as subprograms as required). Initialization is allowed only by constructor
1340 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1341 limited if not explicitly declared as limited or derived from a limited
1342 type, and a warning is issued in that case.
1344 Pragma @code{CPP_Class} is intended primarily for automatic generation
1345 using an automatic binding generator tool.
1346 See @ref{Interfacing to C++} for related information.
1348 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1349 for backward compatibility but its functionality is available
1350 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1352 @node Pragma CPP_Constructor
1353 @unnumberedsec Pragma CPP_Constructor
1354 @cindex Interfacing with C++
1355 @findex CPP_Constructor
1359 @smallexample @c ada
1360 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1361 [, [External_Name =>] static_string_EXPRESSION ]
1362 [, [Link_Name =>] static_string_EXPRESSION ]);
1366 This pragma identifies an imported function (imported in the usual way
1367 with pragma @code{Import}) as corresponding to a C++ constructor. If
1368 @code{External_Name} and @code{Link_Name} are not specified then the
1369 @code{Entity} argument is a name that must have been previously mentioned
1370 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1371 must be of one of the following forms:
1375 @code{function @var{Fname} return @var{T}'Class}
1378 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1382 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1384 The first form is the default constructor, used when an object of type
1385 @var{T} is created on the Ada side with no explicit constructor. Other
1386 constructors (including the copy constructor, which is simply a special
1387 case of the second form in which the one and only argument is of type
1388 @var{T}), can only appear in two contexts:
1392 On the right side of an initialization of an object of type @var{T}.
1394 In an extension aggregate for an object of a type derived from @var{T}.
1398 Although the constructor is described as a function that returns a value
1399 on the Ada side, it is typically a procedure with an extra implicit
1400 argument (the object being initialized) at the implementation
1401 level. GNAT issues the appropriate call, whatever it is, to get the
1402 object properly initialized.
1404 In the case of derived objects, you may use one of two possible forms
1405 for declaring and creating an object:
1408 @item @code{New_Object : Derived_T}
1409 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1413 In the first case the default constructor is called and extension fields
1414 if any are initialized according to the default initialization
1415 expressions in the Ada declaration. In the second case, the given
1416 constructor is called and the extension aggregate indicates the explicit
1417 values of the extension fields.
1419 If no constructors are imported, it is impossible to create any objects
1420 on the Ada side. If no default constructor is imported, only the
1421 initialization forms using an explicit call to a constructor are
1424 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1425 using an automatic binding generator tool.
1426 See @ref{Interfacing to C++} for more related information.
1428 @node Pragma CPP_Virtual
1429 @unnumberedsec Pragma CPP_Virtual
1430 @cindex Interfacing to C++
1433 This pragma is now obsolete has has no effect because GNAT generates
1434 the same object layout than the G++ compiler.
1436 See @ref{Interfacing to C++} for related information.
1438 @node Pragma CPP_Vtable
1439 @unnumberedsec Pragma CPP_Vtable
1440 @cindex Interfacing with C++
1443 This pragma is now obsolete has has no effect because GNAT generates
1444 the same object layout than the G++ compiler.
1446 See @ref{Interfacing to C++} for related information.
1449 @unnumberedsec Pragma Debug
1454 @smallexample @c ada
1455 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1457 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1459 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1463 The procedure call argument has the syntactic form of an expression, meeting
1464 the syntactic requirements for pragmas.
1466 If debug pragmas are not enabled or if the condition is present and evaluates
1467 to False, this pragma has no effect. If debug pragmas are enabled, the
1468 semantics of the pragma is exactly equivalent to the procedure call statement
1469 corresponding to the argument with a terminating semicolon. Pragmas are
1470 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1471 intersperse calls to debug procedures in the middle of declarations. Debug
1472 pragmas can be enabled either by use of the command line switch @option{-gnata}
1473 or by use of the configuration pragma @code{Debug_Policy}.
1475 @node Pragma Debug_Policy
1476 @unnumberedsec Pragma Debug_Policy
1477 @findex Debug_Policy
1481 @smallexample @c ada
1482 pragma Debug_Policy (CHECK | IGNORE);
1486 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1487 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1488 This pragma overrides the effect of the @option{-gnata} switch on the
1491 @node Pragma Detect_Blocking
1492 @unnumberedsec Pragma Detect_Blocking
1493 @findex Detect_Blocking
1497 @smallexample @c ada
1498 pragma Detect_Blocking;
1502 This is a configuration pragma that forces the detection of potentially
1503 blocking operations within a protected operation, and to raise Program_Error
1506 @node Pragma Elaboration_Checks
1507 @unnumberedsec Pragma Elaboration_Checks
1508 @cindex Elaboration control
1509 @findex Elaboration_Checks
1513 @smallexample @c ada
1514 pragma Elaboration_Checks (Dynamic | Static);
1518 This is a configuration pragma that provides control over the
1519 elaboration model used by the compilation affected by the
1520 pragma. If the parameter is @code{Dynamic},
1521 then the dynamic elaboration
1522 model described in the Ada Reference Manual is used, as though
1523 the @option{-gnatE} switch had been specified on the command
1524 line. If the parameter is @code{Static}, then the default GNAT static
1525 model is used. This configuration pragma overrides the setting
1526 of the command line. For full details on the elaboration models
1527 used by the GNAT compiler, see section ``Elaboration Order
1528 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1530 @node Pragma Eliminate
1531 @unnumberedsec Pragma Eliminate
1532 @cindex Elimination of unused subprograms
1537 @smallexample @c ada
1539 [Unit_Name =>] IDENTIFIER |
1540 SELECTED_COMPONENT);
1543 [Unit_Name =>] IDENTIFIER |
1545 [Entity =>] IDENTIFIER |
1546 SELECTED_COMPONENT |
1548 [,OVERLOADING_RESOLUTION]);
1550 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1553 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1556 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1558 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1559 Result_Type => result_SUBTYPE_NAME]
1561 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1562 SUBTYPE_NAME ::= STRING_VALUE
1564 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1565 SOURCE_TRACE ::= STRING_VALUE
1567 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1571 This pragma indicates that the given entity is not used outside the
1572 compilation unit it is defined in. The entity must be an explicitly declared
1573 subprogram; this includes generic subprogram instances and
1574 subprograms declared in generic package instances.
1576 If the entity to be eliminated is a library level subprogram, then
1577 the first form of pragma @code{Eliminate} is used with only a single argument.
1578 In this form, the @code{Unit_Name} argument specifies the name of the
1579 library level unit to be eliminated.
1581 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1582 are required. If item is an entity of a library package, then the first
1583 argument specifies the unit name, and the second argument specifies
1584 the particular entity. If the second argument is in string form, it must
1585 correspond to the internal manner in which GNAT stores entity names (see
1586 compilation unit Namet in the compiler sources for details).
1588 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1589 to distinguish between overloaded subprograms. If a pragma does not contain
1590 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1591 subprograms denoted by the first two parameters.
1593 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1594 to be eliminated in a manner similar to that used for the extended
1595 @code{Import} and @code{Export} pragmas, except that the subtype names are
1596 always given as strings. At the moment, this form of distinguishing
1597 overloaded subprograms is implemented only partially, so we do not recommend
1598 using it for practical subprogram elimination.
1600 Note that in case of a parameterless procedure its profile is represented
1601 as @code{Parameter_Types => ("")}
1603 Alternatively, the @code{Source_Location} parameter is used to specify
1604 which overloaded alternative is to be eliminated by pointing to the
1605 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1606 source text. The string literal (or concatenation of string literals)
1607 given as SOURCE_TRACE must have the following format:
1609 @smallexample @c ada
1610 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1615 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1616 FILE_NAME ::= STRING_LITERAL
1617 LINE_NUMBER ::= DIGIT @{DIGIT@}
1620 SOURCE_TRACE should be the short name of the source file (with no directory
1621 information), and LINE_NUMBER is supposed to point to the line where the
1622 defining name of the subprogram is located.
1624 For the subprograms that are not a part of generic instantiations, only one
1625 SOURCE_LOCATION is used. If a subprogram is declared in a package
1626 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1627 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1628 second one denotes the declaration of the corresponding subprogram in the
1629 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1630 in case of nested instantiations.
1632 The effect of the pragma is to allow the compiler to eliminate
1633 the code or data associated with the named entity. Any reference to
1634 an eliminated entity outside the compilation unit it is defined in,
1635 causes a compile time or link time error.
1637 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1638 in a system independent manner, with unused entities eliminated, without
1639 the requirement of modifying the source text. Normally the required set
1640 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1641 tool. Elimination of unused entities local to a compilation unit is
1642 automatic, without requiring the use of pragma @code{Eliminate}.
1644 Note that the reason this pragma takes string literals where names might
1645 be expected is that a pragma @code{Eliminate} can appear in a context where the
1646 relevant names are not visible.
1648 Note that any change in the source files that includes removing, splitting of
1649 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1652 It is legal to use pragma Eliminate where the referenced entity is a
1653 dispatching operation, but it is not clear what this would mean, since
1654 in general the call does not know which entity is actually being called.
1655 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1657 @node Pragma Export_Exception
1658 @unnumberedsec Pragma Export_Exception
1660 @findex Export_Exception
1664 @smallexample @c ada
1665 pragma Export_Exception (
1666 [Internal =>] LOCAL_NAME
1667 [, [External =>] EXTERNAL_SYMBOL]
1668 [, [Form =>] Ada | VMS]
1669 [, [Code =>] static_integer_EXPRESSION]);
1673 | static_string_EXPRESSION
1677 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1678 causes the specified exception to be propagated outside of the Ada program,
1679 so that it can be handled by programs written in other OpenVMS languages.
1680 This pragma establishes an external name for an Ada exception and makes the
1681 name available to the OpenVMS Linker as a global symbol. For further details
1682 on this pragma, see the
1683 DEC Ada Language Reference Manual, section 13.9a3.2.
1685 @node Pragma Export_Function
1686 @unnumberedsec Pragma Export_Function
1687 @cindex Argument passing mechanisms
1688 @findex Export_Function
1693 @smallexample @c ada
1694 pragma Export_Function (
1695 [Internal =>] LOCAL_NAME
1696 [, [External =>] EXTERNAL_SYMBOL]
1697 [, [Parameter_Types =>] PARAMETER_TYPES]
1698 [, [Result_Type =>] result_SUBTYPE_MARK]
1699 [, [Mechanism =>] MECHANISM]
1700 [, [Result_Mechanism =>] MECHANISM_NAME]);
1704 | static_string_EXPRESSION
1709 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1713 | subtype_Name ' Access
1717 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1719 MECHANISM_ASSOCIATION ::=
1720 [formal_parameter_NAME =>] MECHANISM_NAME
1725 | Descriptor [([Class =>] CLASS_NAME)]
1727 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1731 Use this pragma to make a function externally callable and optionally
1732 provide information on mechanisms to be used for passing parameter and
1733 result values. We recommend, for the purposes of improving portability,
1734 this pragma always be used in conjunction with a separate pragma
1735 @code{Export}, which must precede the pragma @code{Export_Function}.
1736 GNAT does not require a separate pragma @code{Export}, but if none is
1737 present, @code{Convention Ada} is assumed, which is usually
1738 not what is wanted, so it is usually appropriate to use this
1739 pragma in conjunction with a @code{Export} or @code{Convention}
1740 pragma that specifies the desired foreign convention.
1741 Pragma @code{Export_Function}
1742 (and @code{Export}, if present) must appear in the same declarative
1743 region as the function to which they apply.
1745 @var{internal_name} must uniquely designate the function to which the
1746 pragma applies. If more than one function name exists of this name in
1747 the declarative part you must use the @code{Parameter_Types} and
1748 @code{Result_Type} parameters is mandatory to achieve the required
1749 unique designation. @var{subtype_mark}s in these parameters must
1750 exactly match the subtypes in the corresponding function specification,
1751 using positional notation to match parameters with subtype marks.
1752 The form with an @code{'Access} attribute can be used to match an
1753 anonymous access parameter.
1756 @cindex Passing by descriptor
1757 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1759 @cindex Suppressing external name
1760 Special treatment is given if the EXTERNAL is an explicit null
1761 string or a static string expressions that evaluates to the null
1762 string. In this case, no external name is generated. This form
1763 still allows the specification of parameter mechanisms.
1765 @node Pragma Export_Object
1766 @unnumberedsec Pragma Export_Object
1767 @findex Export_Object
1771 @smallexample @c ada
1772 pragma Export_Object
1773 [Internal =>] LOCAL_NAME
1774 [, [External =>] EXTERNAL_SYMBOL]
1775 [, [Size =>] EXTERNAL_SYMBOL]
1779 | static_string_EXPRESSION
1783 This pragma designates an object as exported, and apart from the
1784 extended rules for external symbols, is identical in effect to the use of
1785 the normal @code{Export} pragma applied to an object. You may use a
1786 separate Export pragma (and you probably should from the point of view
1787 of portability), but it is not required. @var{Size} is syntax checked,
1788 but otherwise ignored by GNAT@.
1790 @node Pragma Export_Procedure
1791 @unnumberedsec Pragma Export_Procedure
1792 @findex Export_Procedure
1796 @smallexample @c ada
1797 pragma Export_Procedure (
1798 [Internal =>] LOCAL_NAME
1799 [, [External =>] EXTERNAL_SYMBOL]
1800 [, [Parameter_Types =>] PARAMETER_TYPES]
1801 [, [Mechanism =>] MECHANISM]);
1805 | static_string_EXPRESSION
1810 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1814 | subtype_Name ' Access
1818 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1820 MECHANISM_ASSOCIATION ::=
1821 [formal_parameter_NAME =>] MECHANISM_NAME
1826 | Descriptor [([Class =>] CLASS_NAME)]
1828 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1832 This pragma is identical to @code{Export_Function} except that it
1833 applies to a procedure rather than a function and the parameters
1834 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1835 GNAT does not require a separate pragma @code{Export}, but if none is
1836 present, @code{Convention Ada} is assumed, which is usually
1837 not what is wanted, so it is usually appropriate to use this
1838 pragma in conjunction with a @code{Export} or @code{Convention}
1839 pragma that specifies the desired foreign convention.
1842 @cindex Passing by descriptor
1843 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1845 @cindex Suppressing external name
1846 Special treatment is given if the EXTERNAL is an explicit null
1847 string or a static string expressions that evaluates to the null
1848 string. In this case, no external name is generated. This form
1849 still allows the specification of parameter mechanisms.
1851 @node Pragma Export_Value
1852 @unnumberedsec Pragma Export_Value
1853 @findex Export_Value
1857 @smallexample @c ada
1858 pragma Export_Value (
1859 [Value =>] static_integer_EXPRESSION,
1860 [Link_Name =>] static_string_EXPRESSION);
1864 This pragma serves to export a static integer value for external use.
1865 The first argument specifies the value to be exported. The Link_Name
1866 argument specifies the symbolic name to be associated with the integer
1867 value. This pragma is useful for defining a named static value in Ada
1868 that can be referenced in assembly language units to be linked with
1869 the application. This pragma is currently supported only for the
1870 AAMP target and is ignored for other targets.
1872 @node Pragma Export_Valued_Procedure
1873 @unnumberedsec Pragma Export_Valued_Procedure
1874 @findex Export_Valued_Procedure
1878 @smallexample @c ada
1879 pragma Export_Valued_Procedure (
1880 [Internal =>] LOCAL_NAME
1881 [, [External =>] EXTERNAL_SYMBOL]
1882 [, [Parameter_Types =>] PARAMETER_TYPES]
1883 [, [Mechanism =>] MECHANISM]);
1887 | static_string_EXPRESSION
1892 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1896 | subtype_Name ' Access
1900 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1902 MECHANISM_ASSOCIATION ::=
1903 [formal_parameter_NAME =>] MECHANISM_NAME
1908 | Descriptor [([Class =>] CLASS_NAME)]
1910 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1914 This pragma is identical to @code{Export_Procedure} except that the
1915 first parameter of @var{LOCAL_NAME}, which must be present, must be of
1916 mode @code{OUT}, and externally the subprogram is treated as a function
1917 with this parameter as the result of the function. GNAT provides for
1918 this capability to allow the use of @code{OUT} and @code{IN OUT}
1919 parameters in interfacing to external functions (which are not permitted
1921 GNAT does not require a separate pragma @code{Export}, but if none is
1922 present, @code{Convention Ada} is assumed, which is almost certainly
1923 not what is wanted since the whole point of this pragma is to interface
1924 with foreign language functions, so it is usually appropriate to use this
1925 pragma in conjunction with a @code{Export} or @code{Convention}
1926 pragma that specifies the desired foreign convention.
1929 @cindex Passing by descriptor
1930 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1932 @cindex Suppressing external name
1933 Special treatment is given if the EXTERNAL is an explicit null
1934 string or a static string expressions that evaluates to the null
1935 string. In this case, no external name is generated. This form
1936 still allows the specification of parameter mechanisms.
1938 @node Pragma Extend_System
1939 @unnumberedsec Pragma Extend_System
1940 @cindex @code{system}, extending
1942 @findex Extend_System
1946 @smallexample @c ada
1947 pragma Extend_System ([Name =>] IDENTIFIER);
1951 This pragma is used to provide backwards compatibility with other
1952 implementations that extend the facilities of package @code{System}. In
1953 GNAT, @code{System} contains only the definitions that are present in
1954 the Ada RM@. However, other implementations, notably the DEC Ada 83
1955 implementation, provide many extensions to package @code{System}.
1957 For each such implementation accommodated by this pragma, GNAT provides a
1958 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1959 implementation, which provides the required additional definitions. You
1960 can use this package in two ways. You can @code{with} it in the normal
1961 way and access entities either by selection or using a @code{use}
1962 clause. In this case no special processing is required.
1964 However, if existing code contains references such as
1965 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1966 definitions provided in package @code{System}, you may use this pragma
1967 to extend visibility in @code{System} in a non-standard way that
1968 provides greater compatibility with the existing code. Pragma
1969 @code{Extend_System} is a configuration pragma whose single argument is
1970 the name of the package containing the extended definition
1971 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
1972 control of this pragma will be processed using special visibility
1973 processing that looks in package @code{System.Aux_@var{xxx}} where
1974 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1975 package @code{System}, but not found in package @code{System}.
1977 You can use this pragma either to access a predefined @code{System}
1978 extension supplied with the compiler, for example @code{Aux_DEC} or
1979 you can construct your own extension unit following the above
1980 definition. Note that such a package is a child of @code{System}
1981 and thus is considered part of the implementation. To compile
1982 it you will have to use the appropriate switch for compiling
1983 system units. See the GNAT User's Guide for details.
1985 @node Pragma External
1986 @unnumberedsec Pragma External
1991 @smallexample @c ada
1993 [ Convention =>] convention_IDENTIFIER,
1994 [ Entity =>] LOCAL_NAME
1995 [, [External_Name =>] static_string_EXPRESSION ]
1996 [, [Link_Name =>] static_string_EXPRESSION ]);
2000 This pragma is identical in syntax and semantics to pragma
2001 @code{Export} as defined in the Ada Reference Manual. It is
2002 provided for compatibility with some Ada 83 compilers that
2003 used this pragma for exactly the same purposes as pragma
2004 @code{Export} before the latter was standardized.
2006 @node Pragma External_Name_Casing
2007 @unnumberedsec Pragma External_Name_Casing
2008 @cindex Dec Ada 83 casing compatibility
2009 @cindex External Names, casing
2010 @cindex Casing of External names
2011 @findex External_Name_Casing
2015 @smallexample @c ada
2016 pragma External_Name_Casing (
2017 Uppercase | Lowercase
2018 [, Uppercase | Lowercase | As_Is]);
2022 This pragma provides control over the casing of external names associated
2023 with Import and Export pragmas. There are two cases to consider:
2026 @item Implicit external names
2027 Implicit external names are derived from identifiers. The most common case
2028 arises when a standard Ada Import or Export pragma is used with only two
2031 @smallexample @c ada
2032 pragma Import (C, C_Routine);
2036 Since Ada is a case-insensitive language, the spelling of the identifier in
2037 the Ada source program does not provide any information on the desired
2038 casing of the external name, and so a convention is needed. In GNAT the
2039 default treatment is that such names are converted to all lower case
2040 letters. This corresponds to the normal C style in many environments.
2041 The first argument of pragma @code{External_Name_Casing} can be used to
2042 control this treatment. If @code{Uppercase} is specified, then the name
2043 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2044 then the normal default of all lower case letters will be used.
2046 This same implicit treatment is also used in the case of extended DEC Ada 83
2047 compatible Import and Export pragmas where an external name is explicitly
2048 specified using an identifier rather than a string.
2050 @item Explicit external names
2051 Explicit external names are given as string literals. The most common case
2052 arises when a standard Ada Import or Export pragma is used with three
2055 @smallexample @c ada
2056 pragma Import (C, C_Routine, "C_routine");
2060 In this case, the string literal normally provides the exact casing required
2061 for the external name. The second argument of pragma
2062 @code{External_Name_Casing} may be used to modify this behavior.
2063 If @code{Uppercase} is specified, then the name
2064 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2065 then the name will be forced to all lowercase letters. A specification of
2066 @code{As_Is} provides the normal default behavior in which the casing is
2067 taken from the string provided.
2071 This pragma may appear anywhere that a pragma is valid. In particular, it
2072 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2073 case it applies to all subsequent compilations, or it can be used as a program
2074 unit pragma, in which case it only applies to the current unit, or it can
2075 be used more locally to control individual Import/Export pragmas.
2077 It is primarily intended for use with OpenVMS systems, where many
2078 compilers convert all symbols to upper case by default. For interfacing to
2079 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2082 @smallexample @c ada
2083 pragma External_Name_Casing (Uppercase, Uppercase);
2087 to enforce the upper casing of all external symbols.
2089 @node Pragma Fast_Math
2090 @unnumberedsec Pragma Fast_Math
2095 @smallexample @c ada
2100 This is a configuration pragma which activates a mode in which speed is
2101 considered more important for floating-point operations than absolutely
2102 accurate adherence to the requirements of the standard. Currently the
2103 following operations are affected:
2106 @item Complex Multiplication
2107 The normal simple formula for complex multiplication can result in intermediate
2108 overflows for numbers near the end of the range. The Ada standard requires that
2109 this situation be detected and corrected by scaling, but in Fast_Math mode such
2110 cases will simply result in overflow. Note that to take advantage of this you
2111 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2112 under control of the pragma, rather than use the preinstantiated versions.
2115 @node Pragma Favor_Top_Level
2116 @unnumberedsec Pragma Favor_Top_Level
2117 @findex Favor_Top_Level
2121 @smallexample @c ada
2122 pragma Favor_Top_Level (type_NAME);
2126 The named type must be an access-to-subprogram type. This pragma is an
2127 efficiency hint to the compiler, regarding the use of 'Access or
2128 'Unrestricted_Access on nested (non-library-level) subprograms. The
2129 pragma means that nested subprograms are not used with this type, or
2130 are rare, so that the generated code should be efficient in the
2131 top-level case. When this pragma is used, dynamically generated
2132 trampolines may be used on some targets for nested subprograms.
2133 See also the No_Implicit_Dynamic_Code restriction.
2135 @node Pragma Finalize_Storage_Only
2136 @unnumberedsec Pragma Finalize_Storage_Only
2137 @findex Finalize_Storage_Only
2141 @smallexample @c ada
2142 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2146 This pragma allows the compiler not to emit a Finalize call for objects
2147 defined at the library level. This is mostly useful for types where
2148 finalization is only used to deal with storage reclamation since in most
2149 environments it is not necessary to reclaim memory just before terminating
2150 execution, hence the name.
2152 @node Pragma Float_Representation
2153 @unnumberedsec Pragma Float_Representation
2155 @findex Float_Representation
2159 @smallexample @c ada
2160 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2162 FLOAT_REP ::= VAX_Float | IEEE_Float
2166 In the one argument form, this pragma is a configuration pragma which
2167 allows control over the internal representation chosen for the predefined
2168 floating point types declared in the packages @code{Standard} and
2169 @code{System}. On all systems other than OpenVMS, the argument must
2170 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2171 argument may be @code{VAX_Float} to specify the use of the VAX float
2172 format for the floating-point types in Standard. This requires that
2173 the standard runtime libraries be recompiled. See the
2174 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2175 of the GNAT Users Guide for details on the use of this command.
2177 The two argument form specifies the representation to be used for
2178 the specified floating-point type. On all systems other than OpenVMS,
2180 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2181 argument may be @code{VAX_Float} to specify the use of the VAX float
2186 For digits values up to 6, F float format will be used.
2188 For digits values from 7 to 9, G float format will be used.
2190 For digits values from 10 to 15, F float format will be used.
2192 Digits values above 15 are not allowed.
2196 @unnumberedsec Pragma Ident
2201 @smallexample @c ada
2202 pragma Ident (static_string_EXPRESSION);
2206 This pragma provides a string identification in the generated object file,
2207 if the system supports the concept of this kind of identification string.
2208 This pragma is allowed only in the outermost declarative part or
2209 declarative items of a compilation unit. If more than one @code{Ident}
2210 pragma is given, only the last one processed is effective.
2212 On OpenVMS systems, the effect of the pragma is identical to the effect of
2213 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2214 maximum allowed length is 31 characters, so if it is important to
2215 maintain compatibility with this compiler, you should obey this length
2218 @node Pragma Implemented_By_Entry
2219 @unnumberedsec Pragma Implemented_By_Entry
2220 @findex Implemented_By_Entry
2224 @smallexample @c ada
2225 pragma Implemented_By_Entry (LOCAL_NAME);
2229 This is a representation pragma which applies to protected, synchronized and
2230 task interface primitives. If the pragma is applied to primitive operation Op
2231 of interface Iface, it is illegal to override Op in a type that implements
2232 Iface, with anything other than an entry.
2234 @smallexample @c ada
2235 type Iface is protected interface;
2236 procedure Do_Something (Object : in out Iface) is abstract;
2237 pragma Implemented_By_Entry (Do_Something);
2239 protected type P is new Iface with
2240 procedure Do_Something; -- Illegal
2243 task type T is new Iface with
2244 entry Do_Something; -- Legal
2249 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2250 is intended to be used in conjunction with dispatching requeue statements as
2251 described in AI05-0030. Should the ARG decide on an official name and syntax,
2252 this pragma will become language-defined rather than GNAT-specific.
2254 @node Pragma Implicit_Packing
2255 @unnumberedsec Pragma Implicit_Packing
2256 @findex Implicit_Packing
2260 @smallexample @c ada
2261 pragma Implicit_Packing;
2265 This is a configuration pragma that requests implicit packing for packed
2266 arrays for which a size clause is given but no explicit pragma Pack or
2267 specification of Component_Size is present. Consider this example:
2269 @smallexample @c ada
2270 type R is array (0 .. 7) of Boolean;
2275 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2276 does not change the layout of a composite object. So the Size clause in the
2277 above example is normally rejected, since the default layout of the array uses
2278 8-bit components, and thus the array requires a minimum of 64 bits.
2280 If this declaration is compiled in a region of code covered by an occurrence
2281 of the configuration pragma Implicit_Packing, then the Size clause in this
2282 and similar examples will cause implicit packing and thus be accepted. For
2283 this implicit packing to occur, the type in question must be an array of small
2284 components whose size is known at compile time, and the Size clause must
2285 specify the exact size that corresponds to the length of the array multiplied
2286 by the size in bits of the component type.
2287 @cindex Array packing
2289 @node Pragma Import_Exception
2290 @unnumberedsec Pragma Import_Exception
2292 @findex Import_Exception
2296 @smallexample @c ada
2297 pragma Import_Exception (
2298 [Internal =>] LOCAL_NAME
2299 [, [External =>] EXTERNAL_SYMBOL]
2300 [, [Form =>] Ada | VMS]
2301 [, [Code =>] static_integer_EXPRESSION]);
2305 | static_string_EXPRESSION
2309 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2310 It allows OpenVMS conditions (for example, from OpenVMS system services or
2311 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2312 The pragma specifies that the exception associated with an exception
2313 declaration in an Ada program be defined externally (in non-Ada code).
2314 For further details on this pragma, see the
2315 DEC Ada Language Reference Manual, section 13.9a.3.1.
2317 @node Pragma Import_Function
2318 @unnumberedsec Pragma Import_Function
2319 @findex Import_Function
2323 @smallexample @c ada
2324 pragma Import_Function (
2325 [Internal =>] LOCAL_NAME,
2326 [, [External =>] EXTERNAL_SYMBOL]
2327 [, [Parameter_Types =>] PARAMETER_TYPES]
2328 [, [Result_Type =>] SUBTYPE_MARK]
2329 [, [Mechanism =>] MECHANISM]
2330 [, [Result_Mechanism =>] MECHANISM_NAME]
2331 [, [First_Optional_Parameter =>] IDENTIFIER]);
2335 | static_string_EXPRESSION
2339 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2343 | subtype_Name ' Access
2347 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2349 MECHANISM_ASSOCIATION ::=
2350 [formal_parameter_NAME =>] MECHANISM_NAME
2355 | Descriptor [([Class =>] CLASS_NAME)]
2357 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2361 This pragma is used in conjunction with a pragma @code{Import} to
2362 specify additional information for an imported function. The pragma
2363 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2364 @code{Import_Function} pragma and both must appear in the same
2365 declarative part as the function specification.
2367 The @var{Internal} argument must uniquely designate
2368 the function to which the
2369 pragma applies. If more than one function name exists of this name in
2370 the declarative part you must use the @code{Parameter_Types} and
2371 @var{Result_Type} parameters to achieve the required unique
2372 designation. Subtype marks in these parameters must exactly match the
2373 subtypes in the corresponding function specification, using positional
2374 notation to match parameters with subtype marks.
2375 The form with an @code{'Access} attribute can be used to match an
2376 anonymous access parameter.
2378 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2379 parameters to specify passing mechanisms for the
2380 parameters and result. If you specify a single mechanism name, it
2381 applies to all parameters. Otherwise you may specify a mechanism on a
2382 parameter by parameter basis using either positional or named
2383 notation. If the mechanism is not specified, the default mechanism
2387 @cindex Passing by descriptor
2388 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2390 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2391 It specifies that the designated parameter and all following parameters
2392 are optional, meaning that they are not passed at the generated code
2393 level (this is distinct from the notion of optional parameters in Ada
2394 where the parameters are passed anyway with the designated optional
2395 parameters). All optional parameters must be of mode @code{IN} and have
2396 default parameter values that are either known at compile time
2397 expressions, or uses of the @code{'Null_Parameter} attribute.
2399 @node Pragma Import_Object
2400 @unnumberedsec Pragma Import_Object
2401 @findex Import_Object
2405 @smallexample @c ada
2406 pragma Import_Object
2407 [Internal =>] LOCAL_NAME
2408 [, [External =>] EXTERNAL_SYMBOL]
2409 [, [Size =>] EXTERNAL_SYMBOL]);
2413 | static_string_EXPRESSION
2417 This pragma designates an object as imported, and apart from the
2418 extended rules for external symbols, is identical in effect to the use of
2419 the normal @code{Import} pragma applied to an object. Unlike the
2420 subprogram case, you need not use a separate @code{Import} pragma,
2421 although you may do so (and probably should do so from a portability
2422 point of view). @var{size} is syntax checked, but otherwise ignored by
2425 @node Pragma Import_Procedure
2426 @unnumberedsec Pragma Import_Procedure
2427 @findex Import_Procedure
2431 @smallexample @c ada
2432 pragma Import_Procedure (
2433 [Internal =>] LOCAL_NAME
2434 [, [External =>] EXTERNAL_SYMBOL]
2435 [, [Parameter_Types =>] PARAMETER_TYPES]
2436 [, [Mechanism =>] MECHANISM]
2437 [, [First_Optional_Parameter =>] IDENTIFIER]);
2441 | static_string_EXPRESSION
2445 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2449 | subtype_Name ' Access
2453 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2455 MECHANISM_ASSOCIATION ::=
2456 [formal_parameter_NAME =>] MECHANISM_NAME
2461 | Descriptor [([Class =>] CLASS_NAME)]
2463 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2467 This pragma is identical to @code{Import_Function} except that it
2468 applies to a procedure rather than a function and the parameters
2469 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2471 @node Pragma Import_Valued_Procedure
2472 @unnumberedsec Pragma Import_Valued_Procedure
2473 @findex Import_Valued_Procedure
2477 @smallexample @c ada
2478 pragma Import_Valued_Procedure (
2479 [Internal =>] LOCAL_NAME
2480 [, [External =>] EXTERNAL_SYMBOL]
2481 [, [Parameter_Types =>] PARAMETER_TYPES]
2482 [, [Mechanism =>] MECHANISM]
2483 [, [First_Optional_Parameter =>] IDENTIFIER]);
2487 | static_string_EXPRESSION
2491 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2495 | subtype_Name ' Access
2499 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2501 MECHANISM_ASSOCIATION ::=
2502 [formal_parameter_NAME =>] MECHANISM_NAME
2507 | Descriptor [([Class =>] CLASS_NAME)]
2509 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2513 This pragma is identical to @code{Import_Procedure} except that the
2514 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2515 mode @code{OUT}, and externally the subprogram is treated as a function
2516 with this parameter as the result of the function. The purpose of this
2517 capability is to allow the use of @code{OUT} and @code{IN OUT}
2518 parameters in interfacing to external functions (which are not permitted
2519 in Ada functions). You may optionally use the @code{Mechanism}
2520 parameters to specify passing mechanisms for the parameters.
2521 If you specify a single mechanism name, it applies to all parameters.
2522 Otherwise you may specify a mechanism on a parameter by parameter
2523 basis using either positional or named notation. If the mechanism is not
2524 specified, the default mechanism is used.
2526 Note that it is important to use this pragma in conjunction with a separate
2527 pragma Import that specifies the desired convention, since otherwise the
2528 default convention is Ada, which is almost certainly not what is required.
2530 @node Pragma Initialize_Scalars
2531 @unnumberedsec Pragma Initialize_Scalars
2532 @findex Initialize_Scalars
2533 @cindex debugging with Initialize_Scalars
2537 @smallexample @c ada
2538 pragma Initialize_Scalars;
2542 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2543 two important differences. First, there is no requirement for the pragma
2544 to be used uniformly in all units of a partition, in particular, it is fine
2545 to use this just for some or all of the application units of a partition,
2546 without needing to recompile the run-time library.
2548 In the case where some units are compiled with the pragma, and some without,
2549 then a declaration of a variable where the type is defined in package
2550 Standard or is locally declared will always be subject to initialization,
2551 as will any declaration of a scalar variable. For composite variables,
2552 whether the variable is initialized may also depend on whether the package
2553 in which the type of the variable is declared is compiled with the pragma.
2555 The other important difference is that you can control the value used
2556 for initializing scalar objects. At bind time, you can select several
2557 options for initialization. You can
2558 initialize with invalid values (similar to Normalize_Scalars, though for
2559 Initialize_Scalars it is not always possible to determine the invalid
2560 values in complex cases like signed component fields with non-standard
2561 sizes). You can also initialize with high or
2562 low values, or with a specified bit pattern. See the users guide for binder
2563 options for specifying these cases.
2565 This means that you can compile a program, and then without having to
2566 recompile the program, you can run it with different values being used
2567 for initializing otherwise uninitialized values, to test if your program
2568 behavior depends on the choice. Of course the behavior should not change,
2569 and if it does, then most likely you have an erroneous reference to an
2570 uninitialized value.
2572 It is even possible to change the value at execution time eliminating even
2573 the need to rebind with a different switch using an environment variable.
2574 See the GNAT users guide for details.
2576 Note that pragma @code{Initialize_Scalars} is particularly useful in
2577 conjunction with the enhanced validity checking that is now provided
2578 in GNAT, which checks for invalid values under more conditions.
2579 Using this feature (see description of the @option{-gnatV} flag in the
2580 users guide) in conjunction with pragma @code{Initialize_Scalars}
2581 provides a powerful new tool to assist in the detection of problems
2582 caused by uninitialized variables.
2584 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2585 effect on the generated code. This may cause your code to be
2586 substantially larger. It may also cause an increase in the amount
2587 of stack required, so it is probably a good idea to turn on stack
2588 checking (see description of stack checking in the GNAT users guide)
2589 when using this pragma.
2591 @node Pragma Inline_Always
2592 @unnumberedsec Pragma Inline_Always
2593 @findex Inline_Always
2597 @smallexample @c ada
2598 pragma Inline_Always (NAME [, NAME]);
2602 Similar to pragma @code{Inline} except that inlining is not subject to
2603 the use of option @option{-gnatn} and the inlining happens regardless of
2604 whether this option is used.
2606 @node Pragma Inline_Generic
2607 @unnumberedsec Pragma Inline_Generic
2608 @findex Inline_Generic
2612 @smallexample @c ada
2613 pragma Inline_Generic (generic_package_NAME);
2617 This is implemented for compatibility with DEC Ada 83 and is recognized,
2618 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2619 by default when using GNAT@.
2621 @node Pragma Interface
2622 @unnumberedsec Pragma Interface
2627 @smallexample @c ada
2629 [Convention =>] convention_identifier,
2630 [Entity =>] local_NAME
2631 [, [External_Name =>] static_string_expression]
2632 [, [Link_Name =>] static_string_expression]);
2636 This pragma is identical in syntax and semantics to
2637 the standard Ada pragma @code{Import}. It is provided for compatibility
2638 with Ada 83. The definition is upwards compatible both with pragma
2639 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2640 with some extended implementations of this pragma in certain Ada 83
2643 @node Pragma Interface_Name
2644 @unnumberedsec Pragma Interface_Name
2645 @findex Interface_Name
2649 @smallexample @c ada
2650 pragma Interface_Name (
2651 [Entity =>] LOCAL_NAME
2652 [, [External_Name =>] static_string_EXPRESSION]
2653 [, [Link_Name =>] static_string_EXPRESSION]);
2657 This pragma provides an alternative way of specifying the interface name
2658 for an interfaced subprogram, and is provided for compatibility with Ada
2659 83 compilers that use the pragma for this purpose. You must provide at
2660 least one of @var{External_Name} or @var{Link_Name}.
2662 @node Pragma Interrupt_Handler
2663 @unnumberedsec Pragma Interrupt_Handler
2664 @findex Interrupt_Handler
2668 @smallexample @c ada
2669 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2673 This program unit pragma is supported for parameterless protected procedures
2674 as described in Annex C of the Ada Reference Manual. On the AAMP target
2675 the pragma can also be specified for nonprotected parameterless procedures
2676 that are declared at the library level (which includes procedures
2677 declared at the top level of a library package). In the case of AAMP,
2678 when this pragma is applied to a nonprotected procedure, the instruction
2679 @code{IERET} is generated for returns from the procedure, enabling
2680 maskable interrupts, in place of the normal return instruction.
2682 @node Pragma Interrupt_State
2683 @unnumberedsec Pragma Interrupt_State
2684 @findex Interrupt_State
2688 @smallexample @c ada
2689 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2693 Normally certain interrupts are reserved to the implementation. Any attempt
2694 to attach an interrupt causes Program_Error to be raised, as described in
2695 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
2696 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
2697 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2698 interrupt execution. Additionally, signals such as @code{SIGSEGV},
2699 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2700 Ada exceptions, or used to implement run-time functions such as the
2701 @code{abort} statement and stack overflow checking.
2703 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2704 such uses of interrupts. It subsumes the functionality of pragma
2705 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
2706 available on OS/2, Windows or VMS. On all other platforms than VxWorks,
2707 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2708 and may be used to mark interrupts required by the board support package
2711 Interrupts can be in one of three states:
2715 The interrupt is reserved (no Ada handler can be installed), and the
2716 Ada run-time may not install a handler. As a result you are guaranteed
2717 standard system default action if this interrupt is raised.
2721 The interrupt is reserved (no Ada handler can be installed). The run time
2722 is allowed to install a handler for internal control purposes, but is
2723 not required to do so.
2727 The interrupt is unreserved. The user may install a handler to provide
2732 These states are the allowed values of the @code{State} parameter of the
2733 pragma. The @code{Name} parameter is a value of the type
2734 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
2735 @code{Ada.Interrupts.Names}.
2737 This is a configuration pragma, and the binder will check that there
2738 are no inconsistencies between different units in a partition in how a
2739 given interrupt is specified. It may appear anywhere a pragma is legal.
2741 The effect is to move the interrupt to the specified state.
2743 By declaring interrupts to be SYSTEM, you guarantee the standard system
2744 action, such as a core dump.
2746 By declaring interrupts to be USER, you guarantee that you can install
2749 Note that certain signals on many operating systems cannot be caught and
2750 handled by applications. In such cases, the pragma is ignored. See the
2751 operating system documentation, or the value of the array @code{Reserved}
2752 declared in the specification of package @code{System.OS_Interface}.
2754 Overriding the default state of signals used by the Ada runtime may interfere
2755 with an application's runtime behavior in the cases of the synchronous signals,
2756 and in the case of the signal used to implement the @code{abort} statement.
2758 @node Pragma Keep_Names
2759 @unnumberedsec Pragma Keep_Names
2764 @smallexample @c ada
2765 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2769 The @var{LOCAL_NAME} argument
2770 must refer to an enumeration first subtype
2771 in the current declarative part. The effect is to retain the enumeration
2772 literal names for use by @code{Image} and @code{Value} even if a global
2773 @code{Discard_Names} pragma applies. This is useful when you want to
2774 generally suppress enumeration literal names and for example you therefore
2775 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2776 want to retain the names for specific enumeration types.
2778 @node Pragma License
2779 @unnumberedsec Pragma License
2781 @cindex License checking
2785 @smallexample @c ada
2786 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2790 This pragma is provided to allow automated checking for appropriate license
2791 conditions with respect to the standard and modified GPL@. A pragma
2792 @code{License}, which is a configuration pragma that typically appears at
2793 the start of a source file or in a separate @file{gnat.adc} file, specifies
2794 the licensing conditions of a unit as follows:
2798 This is used for a unit that can be freely used with no license restrictions.
2799 Examples of such units are public domain units, and units from the Ada
2803 This is used for a unit that is licensed under the unmodified GPL, and which
2804 therefore cannot be @code{with}'ed by a restricted unit.
2807 This is used for a unit licensed under the GNAT modified GPL that includes
2808 a special exception paragraph that specifically permits the inclusion of
2809 the unit in programs without requiring the entire program to be released
2813 This is used for a unit that is restricted in that it is not permitted to
2814 depend on units that are licensed under the GPL@. Typical examples are
2815 proprietary code that is to be released under more restrictive license
2816 conditions. Note that restricted units are permitted to @code{with} units
2817 which are licensed under the modified GPL (this is the whole point of the
2823 Normally a unit with no @code{License} pragma is considered to have an
2824 unknown license, and no checking is done. However, standard GNAT headers
2825 are recognized, and license information is derived from them as follows.
2829 A GNAT license header starts with a line containing 78 hyphens. The following
2830 comment text is searched for the appearance of any of the following strings.
2832 If the string ``GNU General Public License'' is found, then the unit is assumed
2833 to have GPL license, unless the string ``As a special exception'' follows, in
2834 which case the license is assumed to be modified GPL@.
2836 If one of the strings
2837 ``This specification is adapted from the Ada Semantic Interface'' or
2838 ``This specification is derived from the Ada Reference Manual'' is found
2839 then the unit is assumed to be unrestricted.
2843 These default actions means that a program with a restricted license pragma
2844 will automatically get warnings if a GPL unit is inappropriately
2845 @code{with}'ed. For example, the program:
2847 @smallexample @c ada
2850 procedure Secret_Stuff is
2856 if compiled with pragma @code{License} (@code{Restricted}) in a
2857 @file{gnat.adc} file will generate the warning:
2862 >>> license of withed unit "Sem_Ch3" is incompatible
2864 2. with GNAT.Sockets;
2865 3. procedure Secret_Stuff is
2869 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2870 compiler and is licensed under the
2871 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2872 run time, and is therefore licensed under the modified GPL@.
2874 @node Pragma Link_With
2875 @unnumberedsec Pragma Link_With
2880 @smallexample @c ada
2881 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2885 This pragma is provided for compatibility with certain Ada 83 compilers.
2886 It has exactly the same effect as pragma @code{Linker_Options} except
2887 that spaces occurring within one of the string expressions are treated
2888 as separators. For example, in the following case:
2890 @smallexample @c ada
2891 pragma Link_With ("-labc -ldef");
2895 results in passing the strings @code{-labc} and @code{-ldef} as two
2896 separate arguments to the linker. In addition pragma Link_With allows
2897 multiple arguments, with the same effect as successive pragmas.
2899 @node Pragma Linker_Alias
2900 @unnumberedsec Pragma Linker_Alias
2901 @findex Linker_Alias
2905 @smallexample @c ada
2906 pragma Linker_Alias (
2907 [Entity =>] LOCAL_NAME,
2908 [Target =>] static_string_EXPRESSION);
2912 @var{LOCAL_NAME} must refer to an object that is declared at the library
2913 level. This pragma establishes the given entity as a linker alias for the
2914 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
2915 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
2916 @var{static_string_EXPRESSION} in the object file, that is to say no space
2917 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
2918 to the same address as @var{static_string_EXPRESSION} by the linker.
2920 The actual linker name for the target must be used (e.g.@: the fully
2921 encoded name with qualification in Ada, or the mangled name in C++),
2922 or it must be declared using the C convention with @code{pragma Import}
2923 or @code{pragma Export}.
2925 Not all target machines support this pragma. On some of them it is accepted
2926 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
2928 @smallexample @c ada
2929 -- Example of the use of pragma Linker_Alias
2933 pragma Export (C, i);
2935 new_name_for_i : Integer;
2936 pragma Linker_Alias (new_name_for_i, "i");
2940 @node Pragma Linker_Constructor
2941 @unnumberedsec Pragma Linker_Constructor
2942 @findex Linker_Constructor
2946 @smallexample @c ada
2947 pragma Linker_Constructor (procedure_LOCAL_NAME);
2951 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
2952 is declared at the library level. A procedure to which this pragma is
2953 applied will be treated as an initialization routine by the linker.
2954 It is equivalent to @code{__attribute__((constructor))} in GNU C and
2955 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
2956 of the executable is called (or immediately after the shared library is
2957 loaded if the procedure is linked in a shared library), in particular
2958 before the Ada run-time environment is set up.
2960 Because of these specific contexts, the set of operations such a procedure
2961 can perform is very limited and the type of objects it can manipulate is
2962 essentially restricted to the elementary types. In particular, it must only
2963 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
2965 This pragma is used by GNAT to implement auto-initialization of shared Stand
2966 Alone Libraries, which provides a related capability without the restrictions
2967 listed above. Where possible, the use of Stand Alone Libraries is preferable
2968 to the use of this pragma.
2970 @node Pragma Linker_Destructor
2971 @unnumberedsec Pragma Linker_Destructor
2972 @findex Linker_Destructor
2976 @smallexample @c ada
2977 pragma Linker_Destructor (procedure_LOCAL_NAME);
2981 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
2982 is declared at the library level. A procedure to which this pragma is
2983 applied will be treated as a finalization routine by the linker.
2984 It is equivalent to @code{__attribute__((destructor))} in GNU C and
2985 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
2986 of the executable has exited (or immediately before the shared library
2987 is unloaded if the procedure is linked in a shared library), in particular
2988 after the Ada run-time environment is shut down.
2990 See @code{pragma Linker_Constructor} for the set of restrictions that apply
2991 because of these specific contexts.
2993 @node Pragma Linker_Section
2994 @unnumberedsec Pragma Linker_Section
2995 @findex Linker_Section
2999 @smallexample @c ada
3000 pragma Linker_Section (
3001 [Entity =>] LOCAL_NAME,
3002 [Section =>] static_string_EXPRESSION);
3006 @var{LOCAL_NAME} must refer to an object that is declared at the library
3007 level. This pragma specifies the name of the linker section for the given
3008 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3009 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3010 section of the executable (assuming the linker doesn't rename the section).
3012 The compiler normally places library-level objects in standard sections
3013 depending on their type: procedures and functions generally go in the
3014 @code{.text} section, initialized variables in the @code{.data} section
3015 and uninitialized variables in the @code{.bss} section.
3017 Other, special sections may exist on given target machines to map special
3018 hardware, for example I/O ports or flash memory. This pragma is a means to
3019 defer the final layout of the executable to the linker, thus fully working
3020 at the symbolic level with the compiler.
3022 Some file formats do not support arbitrary sections so not all target
3023 machines support this pragma. The use of this pragma may cause a program
3024 execution to be erroneous if it is used to place an entity into an
3025 inappropriate section (e.g.@: a modified variable into the @code{.text}
3026 section). See also @code{pragma Persistent_BSS}.
3028 @smallexample @c ada
3029 -- Example of the use of pragma Linker_Section
3033 pragma Volatile (Port_A);
3034 pragma Linker_Section (Port_A, ".bss.port_a");
3037 pragma Volatile (Port_B);
3038 pragma Linker_Section (Port_B, ".bss.port_b");
3042 @node Pragma Long_Float
3043 @unnumberedsec Pragma Long_Float
3049 @smallexample @c ada
3050 pragma Long_Float (FLOAT_FORMAT);
3052 FLOAT_FORMAT ::= D_Float | G_Float
3056 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3057 It allows control over the internal representation chosen for the predefined
3058 type @code{Long_Float} and for floating point type representations with
3059 @code{digits} specified in the range 7 through 15.
3060 For further details on this pragma, see the
3061 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3062 this pragma, the standard runtime libraries must be recompiled. See the
3063 description of the @code{GNAT LIBRARY} command in the OpenVMS version
3064 of the GNAT User's Guide for details on the use of this command.
3066 @node Pragma Machine_Attribute
3067 @unnumberedsec Pragma Machine_Attribute
3068 @findex Machine_Attribute
3072 @smallexample @c ada
3073 pragma Machine_Attribute (
3074 [Entity =>] LOCAL_NAME,
3075 [Attribute_Name =>] static_string_EXPRESSION
3076 [, [Info =>] static_string_EXPRESSION] );
3080 Machine-dependent attributes can be specified for types and/or
3081 declarations. This pragma is semantically equivalent to
3082 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3083 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3084 in GNU C, where @code{@var{attribute_name}} is recognized by the
3085 target macro @code{TARGET_ATTRIBUTE_TABLE} which is defined for each
3086 machine. The optional parameter @var{info} is transformed into an
3087 identifier, which may make this pragma unusable for some attributes
3088 (parameter of some attributes must be a number or a string). See the
3089 GCC manual for further information. It is not possible to specify
3090 attributes defined by other languages, only attributes defined by the
3091 machine the code is intended to run on.
3094 @unnumberedsec Pragma Main
3100 @smallexample @c ada
3102 (MAIN_OPTION [, MAIN_OPTION]);
3105 [STACK_SIZE =>] static_integer_EXPRESSION
3106 | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
3107 | [TIME_SLICING_ENABLED =>] static_boolean_EXPRESSION
3111 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3112 no effect in GNAT, other than being syntax checked.
3114 @node Pragma Main_Storage
3115 @unnumberedsec Pragma Main_Storage
3117 @findex Main_Storage
3121 @smallexample @c ada
3123 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3125 MAIN_STORAGE_OPTION ::=
3126 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3127 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3131 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3132 no effect in GNAT, other than being syntax checked. Note that the pragma
3133 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3135 @node Pragma No_Body
3136 @unnumberedsec Pragma No_Body
3141 @smallexample @c ada
3146 There are a number of cases in which a package spec does not require a body,
3147 and in fact a body is not permitted. GNAT will not permit the spec to be
3148 compiled if there is a body around. The pragma No_Body allows you to provide
3149 a body file, even in a case where no body is allowed. The body file must
3150 contain only comments and a single No_Body pragma. This is recognized by
3151 the compiler as indicating that no body is logically present.
3153 This is particularly useful during maintenance when a package is modified in
3154 such a way that a body needed before is no longer needed. The provision of a
3155 dummy body with a No_Body pragma ensures that there is no interference from
3156 earlier versions of the package body.
3158 @node Pragma No_Return
3159 @unnumberedsec Pragma No_Return
3164 @smallexample @c ada
3165 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3169 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3170 declarations in the current declarative part. A procedure to which this
3171 pragma is applied may not contain any explicit @code{return} statements.
3172 In addition, if the procedure contains any implicit returns from falling
3173 off the end of a statement sequence, then execution of that implicit
3174 return will cause Program_Error to be raised.
3176 One use of this pragma is to identify procedures whose only purpose is to raise
3177 an exception. Another use of this pragma is to suppress incorrect warnings
3178 about missing returns in functions, where the last statement of a function
3179 statement sequence is a call to such a procedure.
3181 Note that in Ada 2005 mode, this pragma is part of the language, and is
3182 identical in effect to the pragma as implemented in Ada 95 mode.
3184 @node Pragma No_Strict_Aliasing
3185 @unnumberedsec Pragma No_Strict_Aliasing
3186 @findex No_Strict_Aliasing
3190 @smallexample @c ada
3191 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3195 @var{type_LOCAL_NAME} must refer to an access type
3196 declaration in the current declarative part. The effect is to inhibit
3197 strict aliasing optimization for the given type. The form with no
3198 arguments is a configuration pragma which applies to all access types
3199 declared in units to which the pragma applies. For a detailed
3200 description of the strict aliasing optimization, and the situations
3201 in which it must be suppressed, see section
3202 ``Optimization and Strict Aliasing'' in the @value{EDITION} User's Guide.
3204 @node Pragma Normalize_Scalars
3205 @unnumberedsec Pragma Normalize_Scalars
3206 @findex Normalize_Scalars
3210 @smallexample @c ada
3211 pragma Normalize_Scalars;
3215 This is a language defined pragma which is fully implemented in GNAT@. The
3216 effect is to cause all scalar objects that are not otherwise initialized
3217 to be initialized. The initial values are implementation dependent and
3221 @item Standard.Character
3223 Objects whose root type is Standard.Character are initialized to
3224 Character'Last unless the subtype range excludes NUL (in which case
3225 NUL is used). This choice will always generate an invalid value if
3228 @item Standard.Wide_Character
3230 Objects whose root type is Standard.Wide_Character are initialized to
3231 Wide_Character'Last unless the subtype range excludes NUL (in which case
3232 NUL is used). This choice will always generate an invalid value if
3235 @item Standard.Wide_Wide_Character
3237 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3238 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3239 which case NUL is used). This choice will always generate an invalid value if
3244 Objects of an integer type are treated differently depending on whether
3245 negative values are present in the subtype. If no negative values are
3246 present, then all one bits is used as the initial value except in the
3247 special case where zero is excluded from the subtype, in which case
3248 all zero bits are used. This choice will always generate an invalid
3249 value if one exists.
3251 For subtypes with negative values present, the largest negative number
3252 is used, except in the unusual case where this largest negative number
3253 is in the subtype, and the largest positive number is not, in which case
3254 the largest positive value is used. This choice will always generate
3255 an invalid value if one exists.
3257 @item Floating-Point Types
3258 Objects of all floating-point types are initialized to all 1-bits. For
3259 standard IEEE format, this corresponds to a NaN (not a number) which is
3260 indeed an invalid value.
3262 @item Fixed-Point Types
3263 Objects of all fixed-point types are treated as described above for integers,
3264 with the rules applying to the underlying integer value used to represent
3265 the fixed-point value.
3268 Objects of a modular type are initialized to all one bits, except in
3269 the special case where zero is excluded from the subtype, in which
3270 case all zero bits are used. This choice will always generate an
3271 invalid value if one exists.
3273 @item Enumeration types
3274 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3275 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3276 whose Pos value is zero, in which case a code of zero is used. This choice
3277 will always generate an invalid value if one exists.
3281 @node Pragma Obsolescent
3282 @unnumberedsec Pragma Obsolescent
3287 @smallexample @c ada
3289 (Entity => NAME [, static_string_EXPRESSION [,Ada_05]]);
3293 This pragma can occur immediately following a declaration of an entity,
3294 including the case of a record component, and usually the Entity name
3295 must match the name of the entity declared by this declaration.
3296 Alternatively, the pragma can immediately follow an
3297 enumeration type declaration, where the entity argument names one of the
3298 enumeration literals.
3300 This pragma is used to indicate that the named entity
3301 is considered obsolescent and should not be used. Typically this is
3302 used when an API must be modified by eventually removing or modifying
3303 existing subprograms or other entities. The pragma can be used at an
3304 intermediate stage when the entity is still present, but will be
3307 The effect of this pragma is to output a warning message on
3308 a call to a program thus marked that the
3309 subprogram is obsolescent if the appropriate warning option in the
3310 compiler is activated. If the string parameter is present, then a second
3311 warning message is given containing this text.
3312 In addition, a call to such a program is considered a violation of
3313 pragma Restrictions (No_Obsolescent_Features).
3315 This pragma can also be used as a program unit pragma for a package,
3316 in which case the entity name is the name of the package, and the
3317 pragma indicates that the entire package is considered
3318 obsolescent. In this case a client @code{with}'ing such a package
3319 violates the restriction, and the @code{with} statement is
3320 flagged with warnings if the warning option is set.
3322 If the optional third parameter is present (which must be exactly
3323 the identifier Ada_05, no other argument is allowed), then the
3324 indication of obsolescence applies only when compiling in Ada 2005
3325 mode. This is primarily intended for dealing with the situations
3326 in the predefined library where subprograms or packages
3327 have become defined as obsolescent in Ada 2005
3328 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3330 The following examples show typical uses of this pragma:
3332 @smallexample @c ada
3335 (Entity => p, "use pp instead of p");
3341 (Entity => q2, "use q2new instead");
3343 type R is new integer;
3345 (Entity => R, "use RR in Ada 2005", Ada_05);
3350 pragma Obsolescent (Entity => F2);
3354 type E is (a, bc, 'd', quack);
3355 pragma Obsolescent (Entity => bc)
3356 pragma Obsolescent (Entity => 'd')
3359 (a, b : character) return character;
3360 pragma Obsolescent (Entity => "+");
3365 In an earlier version of GNAT, the Entity parameter was not required,
3366 and this form is still accepted for compatibility purposes. If the
3367 Entity parameter is omitted, then the pragma applies to the declaration
3368 immediately preceding the pragma (this form cannot be used for the
3369 enumeration literal case).
3371 @node Pragma Passive
3372 @unnumberedsec Pragma Passive
3377 @smallexample @c ada
3378 pragma Passive [(Semaphore | No)];
3382 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3383 compatibility with DEC Ada 83 implementations, where it is used within a
3384 task definition to request that a task be made passive. If the argument
3385 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3386 treats the pragma as an assertion that the containing task is passive
3387 and that optimization of context switch with this task is permitted and
3388 desired. If the argument @code{No} is present, the task must not be
3389 optimized. GNAT does not attempt to optimize any tasks in this manner
3390 (since protected objects are available in place of passive tasks).
3392 @node Pragma Persistent_BSS
3393 @unnumberedsec Pragma Persistent_BSS
3394 @findex Persistent_BSS
3398 @smallexample @c ada
3399 pragma Persistent_BSS [(LOCAL_NAME)]
3403 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3404 section. On some targets the linker and loader provide for special
3405 treatment of this section, allowing a program to be reloaded without
3406 affecting the contents of this data (hence the name persistent).
3408 There are two forms of usage. If an argument is given, it must be the
3409 local name of a library level object, with no explicit initialization
3410 and whose type is potentially persistent. If no argument is given, then
3411 the pragma is a configuration pragma, and applies to all library level
3412 objects with no explicit initialization of potentially persistent types.
3414 A potentially persistent type is a scalar type, or a non-tagged,
3415 non-discriminated record, all of whose components have no explicit
3416 initialization and are themselves of a potentially persistent type,
3417 or an array, all of whose constraints are static, and whose component
3418 type is potentially persistent.
3420 If this pragma is used on a target where this feature is not supported,
3421 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3423 @node Pragma Polling
3424 @unnumberedsec Pragma Polling
3429 @smallexample @c ada
3430 pragma Polling (ON | OFF);
3434 This pragma controls the generation of polling code. This is normally off.
3435 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3436 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3437 runtime library, and can be found in file @file{a-excpol.adb}.
3439 Pragma @code{Polling} can appear as a configuration pragma (for example it
3440 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3441 can be used in the statement or declaration sequence to control polling
3444 A call to the polling routine is generated at the start of every loop and
3445 at the start of every subprogram call. This guarantees that the @code{Poll}
3446 routine is called frequently, and places an upper bound (determined by
3447 the complexity of the code) on the period between two @code{Poll} calls.
3449 The primary purpose of the polling interface is to enable asynchronous
3450 aborts on targets that cannot otherwise support it (for example Windows
3451 NT), but it may be used for any other purpose requiring periodic polling.
3452 The standard version is null, and can be replaced by a user program. This
3453 will require re-compilation of the @code{Ada.Exceptions} package that can
3454 be found in files @file{a-except.ads} and @file{a-except.adb}.
3456 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3457 distribution) is used to enable the asynchronous abort capability on
3458 targets that do not normally support the capability. The version of
3459 @code{Poll} in this file makes a call to the appropriate runtime routine
3460 to test for an abort condition.
3462 Note that polling can also be enabled by use of the @option{-gnatP} switch. See
3463 the @cite{GNAT User's Guide} for details.
3465 @node Pragma Profile (Ravenscar)
3466 @unnumberedsec Pragma Profile (Ravenscar)
3471 @smallexample @c ada
3472 pragma Profile (Ravenscar);
3476 A configuration pragma that establishes the following set of configuration
3480 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3481 [RM D.2.2] Tasks are dispatched following a preemptive
3482 priority-ordered scheduling policy.
3484 @item Locking_Policy (Ceiling_Locking)
3485 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3486 the ceiling priority of the corresponding protected object.
3488 @c @item Detect_Blocking
3489 @c This pragma forces the detection of potentially blocking operations within a
3490 @c protected operation, and to raise Program_Error if that happens.
3494 plus the following set of restrictions:
3497 @item Max_Entry_Queue_Length = 1
3498 Defines the maximum number of calls that are queued on a (protected) entry.
3499 Note that this restrictions is checked at run time. Violation of this
3500 restriction results in the raising of Program_Error exception at the point of
3501 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3502 always 1 and hence no task can be queued on a protected entry.
3504 @item Max_Protected_Entries = 1
3505 [RM D.7] Specifies the maximum number of entries per protected type. The
3506 bounds of every entry family of a protected unit shall be static, or shall be
3507 defined by a discriminant of a subtype whose corresponding bound is static.
3508 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3510 @item Max_Task_Entries = 0
3511 [RM D.7] Specifies the maximum number of entries
3512 per task. The bounds of every entry family
3513 of a task unit shall be static, or shall be
3514 defined by a discriminant of a subtype whose
3515 corresponding bound is static. A value of zero
3516 indicates that no rendezvous are possible. For
3517 the Profile (Ravenscar), the value of Max_Task_Entries is always
3520 @item No_Abort_Statements
3521 [RM D.7] There are no abort_statements, and there are
3522 no calls to Task_Identification.Abort_Task.
3524 @item No_Asynchronous_Control
3525 [RM D.7] There are no semantic dependences on the package
3526 Asynchronous_Task_Control.
3529 There are no semantic dependencies on the package Ada.Calendar.
3531 @item No_Dynamic_Attachment
3532 There is no call to any of the operations defined in package Ada.Interrupts
3533 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3534 Detach_Handler, and Reference).
3536 @item No_Dynamic_Priorities
3537 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3539 @item No_Implicit_Heap_Allocations
3540 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3542 @item No_Local_Protected_Objects
3543 Protected objects and access types that designate
3544 such objects shall be declared only at library level.
3546 @item No_Protected_Type_Allocators
3547 There are no allocators for protected types or
3548 types containing protected subcomponents.
3550 @item No_Relative_Delay
3551 There are no delay_relative statements.
3553 @item No_Requeue_Statements
3554 Requeue statements are not allowed.
3556 @item No_Select_Statements
3557 There are no select_statements.
3559 @item No_Task_Allocators
3560 [RM D.7] There are no allocators for task types
3561 or types containing task subcomponents.
3563 @item No_Task_Attributes_Package
3564 There are no semantic dependencies on the Ada.Task_Attributes package.
3566 @item No_Task_Hierarchy
3567 [RM D.7] All (non-environment) tasks depend
3568 directly on the environment task of the partition.
3570 @item No_Task_Termination
3571 Tasks which terminate are erroneous.
3573 @item Simple_Barriers
3574 Entry barrier condition expressions shall be either static
3575 boolean expressions or boolean objects which are declared in
3576 the protected type which contains the entry.
3580 This set of configuration pragmas and restrictions correspond to the
3581 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3582 published by the @cite{International Real-Time Ada Workshop}, 1997,
3583 and whose most recent description is available at
3584 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
3586 The original definition of the profile was revised at subsequent IRTAW
3587 meetings. It has been included in the ISO
3588 @cite{Guide for the Use of the Ada Programming Language in High
3589 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3590 the next revision of the standard. The formal definition given by
3591 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3592 AI-305) available at
3593 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3594 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3597 The above set is a superset of the restrictions provided by pragma
3598 @code{Profile (Restricted)}, it includes six additional restrictions
3599 (@code{Simple_Barriers}, @code{No_Select_Statements},
3600 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3601 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
3602 that pragma @code{Profile (Ravenscar)}, like the pragma
3603 @code{Profile (Restricted)},
3604 automatically causes the use of a simplified,
3605 more efficient version of the tasking run-time system.
3607 @node Pragma Profile (Restricted)
3608 @unnumberedsec Pragma Profile (Restricted)
3609 @findex Restricted Run Time
3613 @smallexample @c ada
3614 pragma Profile (Restricted);
3618 A configuration pragma that establishes the following set of restrictions:
3621 @item No_Abort_Statements
3622 @item No_Entry_Queue
3623 @item No_Task_Hierarchy
3624 @item No_Task_Allocators
3625 @item No_Dynamic_Priorities
3626 @item No_Terminate_Alternatives
3627 @item No_Dynamic_Attachment
3628 @item No_Protected_Type_Allocators
3629 @item No_Local_Protected_Objects
3630 @item No_Requeue_Statements
3631 @item No_Task_Attributes_Package
3632 @item Max_Asynchronous_Select_Nesting = 0
3633 @item Max_Task_Entries = 0
3634 @item Max_Protected_Entries = 1
3635 @item Max_Select_Alternatives = 0
3639 This set of restrictions causes the automatic selection of a simplified
3640 version of the run time that provides improved performance for the
3641 limited set of tasking functionality permitted by this set of restrictions.
3643 @node Pragma Psect_Object
3644 @unnumberedsec Pragma Psect_Object
3645 @findex Psect_Object
3649 @smallexample @c ada
3650 pragma Psect_Object (
3651 [Internal =>] LOCAL_NAME,
3652 [, [External =>] EXTERNAL_SYMBOL]
3653 [, [Size =>] EXTERNAL_SYMBOL]);
3657 | static_string_EXPRESSION
3661 This pragma is identical in effect to pragma @code{Common_Object}.
3663 @node Pragma Pure_Function
3664 @unnumberedsec Pragma Pure_Function
3665 @findex Pure_Function
3669 @smallexample @c ada
3670 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
3674 This pragma appears in the same declarative part as a function
3675 declaration (or a set of function declarations if more than one
3676 overloaded declaration exists, in which case the pragma applies
3677 to all entities). It specifies that the function @code{Entity} is
3678 to be considered pure for the purposes of code generation. This means
3679 that the compiler can assume that there are no side effects, and
3680 in particular that two calls with identical arguments produce the
3681 same result. It also means that the function can be used in an
3684 Note that, quite deliberately, there are no static checks to try
3685 to ensure that this promise is met, so @code{Pure_Function} can be used
3686 with functions that are conceptually pure, even if they do modify
3687 global variables. For example, a square root function that is
3688 instrumented to count the number of times it is called is still
3689 conceptually pure, and can still be optimized, even though it
3690 modifies a global variable (the count). Memo functions are another
3691 example (where a table of previous calls is kept and consulted to
3692 avoid re-computation).
3695 Note: Most functions in a @code{Pure} package are automatically pure, and
3696 there is no need to use pragma @code{Pure_Function} for such functions. One
3697 exception is any function that has at least one formal of type
3698 @code{System.Address} or a type derived from it. Such functions are not
3699 considered pure by default, since the compiler assumes that the
3700 @code{Address} parameter may be functioning as a pointer and that the
3701 referenced data may change even if the address value does not.
3702 Similarly, imported functions are not considered to be pure by default,
3703 since there is no way of checking that they are in fact pure. The use
3704 of pragma @code{Pure_Function} for such a function will override these default
3705 assumption, and cause the compiler to treat a designated subprogram as pure
3708 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3709 applies to the underlying renamed function. This can be used to
3710 disambiguate cases of overloading where some but not all functions
3711 in a set of overloaded functions are to be designated as pure.
3713 If pragma @code{Pure_Function} is applied to a library level function, the
3714 function is also considered pure from an optimization point of view, but the
3715 unit is not a Pure unit in the categorization sense. So for example, a function
3716 thus marked is free to @code{with} non-pure units.
3718 @node Pragma Restriction_Warnings
3719 @unnumberedsec Pragma Restriction_Warnings
3720 @findex Restriction_Warnings
3724 @smallexample @c ada
3725 pragma Restriction_Warnings
3726 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3730 This pragma allows a series of restriction identifiers to be
3731 specified (the list of allowed identifiers is the same as for
3732 pragma @code{Restrictions}). For each of these identifiers
3733 the compiler checks for violations of the restriction, but
3734 generates a warning message rather than an error message
3735 if the restriction is violated.
3738 @unnumberedsec Pragma Shared
3742 This pragma is provided for compatibility with Ada 83. The syntax and
3743 semantics are identical to pragma Atomic.
3745 @node Pragma Source_File_Name
3746 @unnumberedsec Pragma Source_File_Name
3747 @findex Source_File_Name
3751 @smallexample @c ada
3752 pragma Source_File_Name (
3753 [Unit_Name =>] unit_NAME,
3754 Spec_File_Name => STRING_LITERAL);
3756 pragma Source_File_Name (
3757 [Unit_Name =>] unit_NAME,
3758 Body_File_Name => STRING_LITERAL);
3762 Use this to override the normal naming convention. It is a configuration
3763 pragma, and so has the usual applicability of configuration pragmas
3764 (i.e.@: it applies to either an entire partition, or to all units in a
3765 compilation, or to a single unit, depending on how it is used.
3766 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
3767 the second argument is required, and indicates whether this is the file
3768 name for the spec or for the body.
3770 Another form of the @code{Source_File_Name} pragma allows
3771 the specification of patterns defining alternative file naming schemes
3772 to apply to all files.
3774 @smallexample @c ada
3775 pragma Source_File_Name
3776 (Spec_File_Name => STRING_LITERAL
3777 [,Casing => CASING_SPEC]
3778 [,Dot_Replacement => STRING_LITERAL]);
3780 pragma Source_File_Name
3781 (Body_File_Name => STRING_LITERAL
3782 [,Casing => CASING_SPEC]
3783 [,Dot_Replacement => STRING_LITERAL]);
3785 pragma Source_File_Name
3786 (Subunit_File_Name => STRING_LITERAL
3787 [,Casing => CASING_SPEC]
3788 [,Dot_Replacement => STRING_LITERAL]);
3790 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3794 The first argument is a pattern that contains a single asterisk indicating
3795 the point at which the unit name is to be inserted in the pattern string
3796 to form the file name. The second argument is optional. If present it
3797 specifies the casing of the unit name in the resulting file name string.
3798 The default is lower case. Finally the third argument allows for systematic
3799 replacement of any dots in the unit name by the specified string literal.
3801 A pragma Source_File_Name cannot appear after a
3802 @ref{Pragma Source_File_Name_Project}.
3804 For more details on the use of the @code{Source_File_Name} pragma,
3805 see the sections ``Using Other File Names'' and
3806 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3808 @node Pragma Source_File_Name_Project
3809 @unnumberedsec Pragma Source_File_Name_Project
3810 @findex Source_File_Name_Project
3813 This pragma has the same syntax and semantics as pragma Source_File_Name.
3814 It is only allowed as a stand alone configuration pragma.
3815 It cannot appear after a @ref{Pragma Source_File_Name}, and
3816 most importantly, once pragma Source_File_Name_Project appears,
3817 no further Source_File_Name pragmas are allowed.
3819 The intention is that Source_File_Name_Project pragmas are always
3820 generated by the Project Manager in a manner consistent with the naming
3821 specified in a project file, and when naming is controlled in this manner,
3822 it is not permissible to attempt to modify this naming scheme using
3823 Source_File_Name pragmas (which would not be known to the project manager).
3825 @node Pragma Source_Reference
3826 @unnumberedsec Pragma Source_Reference
3827 @findex Source_Reference
3831 @smallexample @c ada
3832 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3836 This pragma must appear as the first line of a source file.
3837 @var{integer_literal} is the logical line number of the line following
3838 the pragma line (for use in error messages and debugging
3839 information). @var{string_literal} is a static string constant that
3840 specifies the file name to be used in error messages and debugging
3841 information. This is most notably used for the output of @code{gnatchop}
3842 with the @option{-r} switch, to make sure that the original unchopped
3843 source file is the one referred to.
3845 The second argument must be a string literal, it cannot be a static
3846 string expression other than a string literal. This is because its value
3847 is needed for error messages issued by all phases of the compiler.
3849 @node Pragma Stream_Convert
3850 @unnumberedsec Pragma Stream_Convert
3851 @findex Stream_Convert
3855 @smallexample @c ada
3856 pragma Stream_Convert (
3857 [Entity =>] type_LOCAL_NAME,
3858 [Read =>] function_NAME,
3859 [Write =>] function_NAME);
3863 This pragma provides an efficient way of providing stream functions for
3864 types defined in packages. Not only is it simpler to use than declaring
3865 the necessary functions with attribute representation clauses, but more
3866 significantly, it allows the declaration to made in such a way that the
3867 stream packages are not loaded unless they are needed. The use of
3868 the Stream_Convert pragma adds no overhead at all, unless the stream
3869 attributes are actually used on the designated type.
3871 The first argument specifies the type for which stream functions are
3872 provided. The second parameter provides a function used to read values
3873 of this type. It must name a function whose argument type may be any
3874 subtype, and whose returned type must be the type given as the first
3875 argument to the pragma.
3877 The meaning of the @var{Read}
3878 parameter is that if a stream attribute directly
3879 or indirectly specifies reading of the type given as the first parameter,
3880 then a value of the type given as the argument to the Read function is
3881 read from the stream, and then the Read function is used to convert this
3882 to the required target type.
3884 Similarly the @var{Write} parameter specifies how to treat write attributes
3885 that directly or indirectly apply to the type given as the first parameter.
3886 It must have an input parameter of the type specified by the first parameter,
3887 and the return type must be the same as the input type of the Read function.
3888 The effect is to first call the Write function to convert to the given stream
3889 type, and then write the result type to the stream.
3891 The Read and Write functions must not be overloaded subprograms. If necessary
3892 renamings can be supplied to meet this requirement.
3893 The usage of this attribute is best illustrated by a simple example, taken
3894 from the GNAT implementation of package Ada.Strings.Unbounded:
3896 @smallexample @c ada
3897 function To_Unbounded (S : String)
3898 return Unbounded_String
3899 renames To_Unbounded_String;
3901 pragma Stream_Convert
3902 (Unbounded_String, To_Unbounded, To_String);
3906 The specifications of the referenced functions, as given in the Ada
3907 Reference Manual are:
3909 @smallexample @c ada
3910 function To_Unbounded_String (Source : String)
3911 return Unbounded_String;
3913 function To_String (Source : Unbounded_String)
3918 The effect is that if the value of an unbounded string is written to a
3919 stream, then the representation of the item in the stream is in the same
3920 format used for @code{Standard.String}, and this same representation is
3921 expected when a value of this type is read from the stream.
3923 @node Pragma Style_Checks
3924 @unnumberedsec Pragma Style_Checks
3925 @findex Style_Checks
3929 @smallexample @c ada
3930 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3931 On | Off [, LOCAL_NAME]);
3935 This pragma is used in conjunction with compiler switches to control the
3936 built in style checking provided by GNAT@. The compiler switches, if set,
3937 provide an initial setting for the switches, and this pragma may be used
3938 to modify these settings, or the settings may be provided entirely by
3939 the use of the pragma. This pragma can be used anywhere that a pragma
3940 is legal, including use as a configuration pragma (including use in
3941 the @file{gnat.adc} file).
3943 The form with a string literal specifies which style options are to be
3944 activated. These are additive, so they apply in addition to any previously
3945 set style check options. The codes for the options are the same as those
3946 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
3947 For example the following two methods can be used to enable
3952 @smallexample @c ada
3953 pragma Style_Checks ("l");
3958 gcc -c -gnatyl @dots{}
3963 The form ALL_CHECKS activates all standard checks (its use is equivalent
3964 to the use of the @code{gnaty} switch with no options. See GNAT User's
3967 The forms with @code{Off} and @code{On}
3968 can be used to temporarily disable style checks
3969 as shown in the following example:
3971 @smallexample @c ada
3975 pragma Style_Checks ("k"); -- requires keywords in lower case
3976 pragma Style_Checks (Off); -- turn off style checks
3977 NULL; -- this will not generate an error message
3978 pragma Style_Checks (On); -- turn style checks back on
3979 NULL; -- this will generate an error message
3983 Finally the two argument form is allowed only if the first argument is
3984 @code{On} or @code{Off}. The effect is to turn of semantic style checks
3985 for the specified entity, as shown in the following example:
3987 @smallexample @c ada
3991 pragma Style_Checks ("r"); -- require consistency of identifier casing
3993 Rf1 : Integer := ARG; -- incorrect, wrong case
3994 pragma Style_Checks (Off, Arg);
3995 Rf2 : Integer := ARG; -- OK, no error
3998 @node Pragma Subtitle
3999 @unnumberedsec Pragma Subtitle
4004 @smallexample @c ada
4005 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4009 This pragma is recognized for compatibility with other Ada compilers
4010 but is ignored by GNAT@.
4012 @node Pragma Suppress
4013 @unnumberedsec Pragma Suppress
4018 @smallexample @c ada
4019 pragma Suppress (Identifier [, [On =>] Name]);
4023 This is a standard pragma, and supports all the check names required in
4024 the RM. It is included here because GNAT recognizes one additional check
4025 name: @code{Alignment_Check} which can be used to suppress alignment checks
4026 on addresses used in address clauses. Such checks can also be suppressed
4027 by suppressing range checks, but the specific use of @code{Alignment_Check}
4028 allows suppression of alignment checks without suppressing other range checks.
4030 @node Pragma Suppress_All
4031 @unnumberedsec Pragma Suppress_All
4032 @findex Suppress_All
4036 @smallexample @c ada
4037 pragma Suppress_All;
4041 This pragma can only appear immediately following a compilation
4042 unit. The effect is to apply @code{Suppress (All_Checks)} to the unit
4043 which it follows. This pragma is implemented for compatibility with DEC
4044 Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal
4045 configuration pragma is the preferred usage in GNAT@.
4047 @node Pragma Suppress_Exception_Locations
4048 @unnumberedsec Pragma Suppress_Exception_Locations
4049 @findex Suppress_Exception_Locations
4053 @smallexample @c ada
4054 pragma Suppress_Exception_Locations;
4058 In normal mode, a raise statement for an exception by default generates
4059 an exception message giving the file name and line number for the location
4060 of the raise. This is useful for debugging and logging purposes, but this
4061 entails extra space for the strings for the messages. The configuration
4062 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4063 generation of these strings, with the result that space is saved, but the
4064 exception message for such raises is null. This configuration pragma may
4065 appear in a global configuration pragma file, or in a specific unit as
4066 usual. It is not required that this pragma be used consistently within
4067 a partition, so it is fine to have some units within a partition compiled
4068 with this pragma and others compiled in normal mode without it.
4070 @node Pragma Suppress_Initialization
4071 @unnumberedsec Pragma Suppress_Initialization
4072 @findex Suppress_Initialization
4073 @cindex Suppressing initialization
4074 @cindex Initialization, suppression of
4078 @smallexample @c ada
4079 pragma Suppress_Initialization ([Entity =>] type_Name);
4083 This pragma suppresses any implicit or explicit initialization
4084 associated with the given type name for all variables of this type.
4086 @node Pragma Task_Info
4087 @unnumberedsec Pragma Task_Info
4092 @smallexample @c ada
4093 pragma Task_Info (EXPRESSION);
4097 This pragma appears within a task definition (like pragma
4098 @code{Priority}) and applies to the task in which it appears. The
4099 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4100 The @code{Task_Info} pragma provides system dependent control over
4101 aspects of tasking implementation, for example, the ability to map
4102 tasks to specific processors. For details on the facilities available
4103 for the version of GNAT that you are using, see the documentation
4104 in the specification of package System.Task_Info in the runtime
4107 @node Pragma Task_Name
4108 @unnumberedsec Pragma Task_Name
4113 @smallexample @c ada
4114 pragma Task_Name (string_EXPRESSION);
4118 This pragma appears within a task definition (like pragma
4119 @code{Priority}) and applies to the task in which it appears. The
4120 argument must be of type String, and provides a name to be used for
4121 the task instance when the task is created. Note that this expression
4122 is not required to be static, and in particular, it can contain
4123 references to task discriminants. This facility can be used to
4124 provide different names for different tasks as they are created,
4125 as illustrated in the example below.
4127 The task name is recorded internally in the run-time structures
4128 and is accessible to tools like the debugger. In addition the
4129 routine @code{Ada.Task_Identification.Image} will return this
4130 string, with a unique task address appended.
4132 @smallexample @c ada
4133 -- Example of the use of pragma Task_Name
4135 with Ada.Task_Identification;
4136 use Ada.Task_Identification;
4137 with Text_IO; use Text_IO;
4140 type Astring is access String;
4142 task type Task_Typ (Name : access String) is
4143 pragma Task_Name (Name.all);
4146 task body Task_Typ is
4147 Nam : constant String := Image (Current_Task);
4149 Put_Line ("-->" & Nam (1 .. 14) & "<--");
4152 type Ptr_Task is access Task_Typ;
4153 Task_Var : Ptr_Task;
4157 new Task_Typ (new String'("This is task 1"));
4159 new Task_Typ (new String'("This is task 2"));
4163 @node Pragma Task_Storage
4164 @unnumberedsec Pragma Task_Storage
4165 @findex Task_Storage
4168 @smallexample @c ada
4169 pragma Task_Storage (
4170 [Task_Type =>] LOCAL_NAME,
4171 [Top_Guard =>] static_integer_EXPRESSION);
4175 This pragma specifies the length of the guard area for tasks. The guard
4176 area is an additional storage area allocated to a task. A value of zero
4177 means that either no guard area is created or a minimal guard area is
4178 created, depending on the target. This pragma can appear anywhere a
4179 @code{Storage_Size} attribute definition clause is allowed for a task
4182 @node Pragma Time_Slice
4183 @unnumberedsec Pragma Time_Slice
4188 @smallexample @c ada
4189 pragma Time_Slice (static_duration_EXPRESSION);
4193 For implementations of GNAT on operating systems where it is possible
4194 to supply a time slice value, this pragma may be used for this purpose.
4195 It is ignored if it is used in a system that does not allow this control,
4196 or if it appears in other than the main program unit.
4198 Note that the effect of this pragma is identical to the effect of the
4199 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4202 @unnumberedsec Pragma Title
4207 @smallexample @c ada
4208 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4211 [Title =>] STRING_LITERAL,
4212 | [Subtitle =>] STRING_LITERAL
4216 Syntax checked but otherwise ignored by GNAT@. This is a listing control
4217 pragma used in DEC Ada 83 implementations to provide a title and/or
4218 subtitle for the program listing. The program listing generated by GNAT
4219 does not have titles or subtitles.
4221 Unlike other pragmas, the full flexibility of named notation is allowed
4222 for this pragma, i.e.@: the parameters may be given in any order if named
4223 notation is used, and named and positional notation can be mixed
4224 following the normal rules for procedure calls in Ada.
4226 @node Pragma Unchecked_Union
4227 @unnumberedsec Pragma Unchecked_Union
4229 @findex Unchecked_Union
4233 @smallexample @c ada
4234 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4238 This pragma is used to specify a representation of a record type that is
4239 equivalent to a C union. It was introduced as a GNAT implementation defined
4240 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4241 pragma, making it language defined, and GNAT fully implements this extended
4242 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4243 details, consult the Ada 2005 Reference Manual, section B.3.3.
4245 @node Pragma Unimplemented_Unit
4246 @unnumberedsec Pragma Unimplemented_Unit
4247 @findex Unimplemented_Unit
4251 @smallexample @c ada
4252 pragma Unimplemented_Unit;
4256 If this pragma occurs in a unit that is processed by the compiler, GNAT
4257 aborts with the message @samp{@var{xxx} not implemented}, where
4258 @var{xxx} is the name of the current compilation unit. This pragma is
4259 intended to allow the compiler to handle unimplemented library units in
4262 The abort only happens if code is being generated. Thus you can use
4263 specs of unimplemented packages in syntax or semantic checking mode.
4265 @node Pragma Universal_Aliasing
4266 @unnumberedsec Pragma Universal_Aliasing
4267 @findex Universal_Aliasing
4271 @smallexample @c ada
4272 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4276 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4277 declarative part. The effect is to inhibit strict type-based aliasing
4278 optimization for the given type. In other words, the effect is as though
4279 access types designating this type were subject to pragma No_Strict_Aliasing.
4280 For a detailed description of the strict aliasing optimization, and the
4281 situations in which it must be suppressed, see section
4282 ``Optimization and Strict Aliasing'' in the @value{EDITION} User's Guide.
4284 @node Pragma Universal_Data
4285 @unnumberedsec Pragma Universal_Data
4286 @findex Universal_Data
4290 @smallexample @c ada
4291 pragma Universal_Data [(library_unit_Name)];
4295 This pragma is supported only for the AAMP target and is ignored for
4296 other targets. The pragma specifies that all library-level objects
4297 (Counter 0 data) associated with the library unit are to be accessed
4298 and updated using universal addressing (24-bit addresses for AAMP5)
4299 rather than the default of 16-bit Data Environment (DENV) addressing.
4300 Use of this pragma will generally result in less efficient code for
4301 references to global data associated with the library unit, but
4302 allows such data to be located anywhere in memory. This pragma is
4303 a library unit pragma, but can also be used as a configuration pragma
4304 (including use in the @file{gnat.adc} file). The functionality
4305 of this pragma is also available by applying the -univ switch on the
4306 compilations of units where universal addressing of the data is desired.
4308 @node Pragma Unreferenced
4309 @unnumberedsec Pragma Unreferenced
4310 @findex Unreferenced
4311 @cindex Warnings, unreferenced
4315 @smallexample @c ada
4316 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4317 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4321 This pragma signals that the entities whose names are listed are
4322 deliberately not referenced in the current source unit. This
4323 suppresses warnings about the
4324 entities being unreferenced, and in addition a warning will be
4325 generated if one of these entities is in fact referenced in the
4326 same unit as the pragma (or in the corresponding body, or one
4329 This is particularly useful for clearly signaling that a particular
4330 parameter is not referenced in some particular subprogram implementation
4331 and that this is deliberate. It can also be useful in the case of
4332 objects declared only for their initialization or finalization side
4335 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4336 current scope, then the entity most recently declared is the one to which
4337 the pragma applies. Note that in the case of accept formals, the pragma
4338 Unreferenced may appear immediately after the keyword @code{do} which
4339 allows the indication of whether or not accept formals are referenced
4340 or not to be given individually for each accept statement.
4342 The left hand side of an assignment does not count as a reference for the
4343 purpose of this pragma. Thus it is fine to assign to an entity for which
4344 pragma Unreferenced is given.
4346 Note that if a warning is desired for all calls to a given subprogram,
4347 regardless of whether they occur in the same unit as the subprogram
4348 declaration, then this pragma should not be used (calls from another
4349 unit would not be flagged); pragma Obsolescent can be used instead
4350 for this purpose, see @xref{Pragma Obsolescent}.
4352 The second form of pragma @code{Unreferenced} is used within a context
4353 clause. In this case the arguments must be unit names of units previously
4354 mentioned in @code{with} clauses (similar to the usage of pragma
4355 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4356 units and unreferenced entities within these units.
4358 @node Pragma Unreferenced_Objects
4359 @unnumberedsec Pragma Unreferenced_Objects
4360 @findex Unreferenced_Objects
4361 @cindex Warnings, unreferenced
4365 @smallexample @c ada
4366 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4370 This pragma signals that for the types or subtypes whose names are
4371 listed, objects which are declared with one of these types or subtypes may
4372 not be referenced, and if no references appear, no warnings are given.
4374 This is particularly useful for objects which are declared solely for their
4375 initialization and finalization effect. Such variables are sometimes referred
4376 to as RAII variables (Resource Acquisition Is Initialization). Using this
4377 pragma on the relevant type (most typically a limited controlled type), the
4378 compiler will automatically suppress unwanted warnings about these variables
4379 not being referenced.
4381 @node Pragma Unreserve_All_Interrupts
4382 @unnumberedsec Pragma Unreserve_All_Interrupts
4383 @findex Unreserve_All_Interrupts
4387 @smallexample @c ada
4388 pragma Unreserve_All_Interrupts;
4392 Normally certain interrupts are reserved to the implementation. Any attempt
4393 to attach an interrupt causes Program_Error to be raised, as described in
4394 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
4395 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
4396 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4397 interrupt execution.
4399 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4400 a program, then all such interrupts are unreserved. This allows the
4401 program to handle these interrupts, but disables their standard
4402 functions. For example, if this pragma is used, then pressing
4403 @kbd{Ctrl-C} will not automatically interrupt execution. However,
4404 a program can then handle the @code{SIGINT} interrupt as it chooses.
4406 For a full list of the interrupts handled in a specific implementation,
4407 see the source code for the specification of @code{Ada.Interrupts.Names} in
4408 file @file{a-intnam.ads}. This is a target dependent file that contains the
4409 list of interrupts recognized for a given target. The documentation in
4410 this file also specifies what interrupts are affected by the use of
4411 the @code{Unreserve_All_Interrupts} pragma.
4413 For a more general facility for controlling what interrupts can be
4414 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4415 of the @code{Unreserve_All_Interrupts} pragma.
4417 @node Pragma Unsuppress
4418 @unnumberedsec Pragma Unsuppress
4423 @smallexample @c ada
4424 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4428 This pragma undoes the effect of a previous pragma @code{Suppress}. If
4429 there is no corresponding pragma @code{Suppress} in effect, it has no
4430 effect. The range of the effect is the same as for pragma
4431 @code{Suppress}. The meaning of the arguments is identical to that used
4432 in pragma @code{Suppress}.
4434 One important application is to ensure that checks are on in cases where
4435 code depends on the checks for its correct functioning, so that the code
4436 will compile correctly even if the compiler switches are set to suppress
4439 @node Pragma Use_VADS_Size
4440 @unnumberedsec Pragma Use_VADS_Size
4441 @cindex @code{Size}, VADS compatibility
4442 @findex Use_VADS_Size
4446 @smallexample @c ada
4447 pragma Use_VADS_Size;
4451 This is a configuration pragma. In a unit to which it applies, any use
4452 of the 'Size attribute is automatically interpreted as a use of the
4453 'VADS_Size attribute. Note that this may result in incorrect semantic
4454 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
4455 the handling of existing code which depends on the interpretation of Size
4456 as implemented in the VADS compiler. See description of the VADS_Size
4457 attribute for further details.
4459 @node Pragma Validity_Checks
4460 @unnumberedsec Pragma Validity_Checks
4461 @findex Validity_Checks
4465 @smallexample @c ada
4466 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4470 This pragma is used in conjunction with compiler switches to control the
4471 built-in validity checking provided by GNAT@. The compiler switches, if set
4472 provide an initial setting for the switches, and this pragma may be used
4473 to modify these settings, or the settings may be provided entirely by
4474 the use of the pragma. This pragma can be used anywhere that a pragma
4475 is legal, including use as a configuration pragma (including use in
4476 the @file{gnat.adc} file).
4478 The form with a string literal specifies which validity options are to be
4479 activated. The validity checks are first set to include only the default
4480 reference manual settings, and then a string of letters in the string
4481 specifies the exact set of options required. The form of this string
4482 is exactly as described for the @option{-gnatVx} compiler switch (see the
4483 GNAT users guide for details). For example the following two methods
4484 can be used to enable validity checking for mode @code{in} and
4485 @code{in out} subprogram parameters:
4489 @smallexample @c ada
4490 pragma Validity_Checks ("im");
4495 gcc -c -gnatVim @dots{}
4500 The form ALL_CHECKS activates all standard checks (its use is equivalent
4501 to the use of the @code{gnatva} switch.
4503 The forms with @code{Off} and @code{On}
4504 can be used to temporarily disable validity checks
4505 as shown in the following example:
4507 @smallexample @c ada
4511 pragma Validity_Checks ("c"); -- validity checks for copies
4512 pragma Validity_Checks (Off); -- turn off validity checks
4513 A := B; -- B will not be validity checked
4514 pragma Validity_Checks (On); -- turn validity checks back on
4515 A := C; -- C will be validity checked
4518 @node Pragma Volatile
4519 @unnumberedsec Pragma Volatile
4524 @smallexample @c ada
4525 pragma Volatile (LOCAL_NAME);
4529 This pragma is defined by the Ada Reference Manual, and the GNAT
4530 implementation is fully conformant with this definition. The reason it
4531 is mentioned in this section is that a pragma of the same name was supplied
4532 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
4533 implementation of pragma Volatile is upwards compatible with the
4534 implementation in DEC Ada 83.
4536 @node Pragma Warnings
4537 @unnumberedsec Pragma Warnings
4542 @smallexample @c ada
4543 pragma Warnings (On | Off);
4544 pragma Warnings (On | Off, LOCAL_NAME);
4545 pragma Warnings (static_string_EXPRESSION);
4546 pragma Warnings (On | Off, static_string_EXPRESSION);
4550 Normally warnings are enabled, with the output being controlled by
4551 the command line switch. Warnings (@code{Off}) turns off generation of
4552 warnings until a Warnings (@code{On}) is encountered or the end of the
4553 current unit. If generation of warnings is turned off using this
4554 pragma, then no warning messages are output, regardless of the
4555 setting of the command line switches.
4557 The form with a single argument may be used as a configuration pragma.
4559 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
4560 the specified entity. This suppression is effective from the point where
4561 it occurs till the end of the extended scope of the variable (similar to
4562 the scope of @code{Suppress}).
4564 The form with a single static_string_EXPRESSION argument provides more precise
4565 control over which warnings are active. The string is a list of letters
4566 specifying which warnings are to be activated and which deactivated. The
4567 code for these letters is the same as the string used in the command
4568 line switch controlling warnings. The following is a brief summary. For
4569 full details see the GNAT Users Guide:
4572 a turn on all optional warnings (except d,h,l)
4573 A turn off all optional warnings
4574 b turn on warnings for bad fixed value (not multiple of small)
4575 B turn off warnings for bad fixed value (not multiple of small)
4576 c turn on warnings for constant conditional
4577 C turn off warnings for constant conditional
4578 d turn on warnings for implicit dereference
4579 D turn off warnings for implicit dereference
4580 e treat all warnings as errors
4581 f turn on warnings for unreferenced formal
4582 F turn off warnings for unreferenced formal
4583 g turn on warnings for unrecognized pragma
4584 G turn off warnings for unrecognized pragma
4585 h turn on warnings for hiding variable
4586 H turn off warnings for hiding variable
4587 i turn on warnings for implementation unit
4588 I turn off warnings for implementation unit
4589 j turn on warnings for obsolescent (annex J) feature
4590 J turn off warnings for obsolescent (annex J) feature
4591 k turn on warnings on constant variable
4592 K turn off warnings on constant variable
4593 l turn on warnings for missing elaboration pragma
4594 L turn off warnings for missing elaboration pragma
4595 m turn on warnings for variable assigned but not read
4596 M turn off warnings for variable assigned but not read
4597 n normal warning mode (cancels -gnatws/-gnatwe)
4598 o turn on warnings for address clause overlay
4599 O turn off warnings for address clause overlay
4600 p turn on warnings for ineffective pragma Inline
4601 P turn off warnings for ineffective pragma Inline
4602 q turn on warnings for questionable missing parentheses
4603 Q turn off warnings for questionable missing parentheses
4604 r turn on warnings for redundant construct
4605 R turn off warnings for redundant construct
4606 s suppress all warnings
4607 t turn on warnings for tracking deleted code
4608 T turn off warnings for tracking deleted code
4609 u turn on warnings for unused entity
4610 U turn off warnings for unused entity
4611 v turn on warnings for unassigned variable
4612 V turn off warnings for unassigned variable
4613 w turn on warnings for wrong low bound assumption
4614 W turn off warnings for wrong low bound assumption
4615 x turn on warnings for export/import
4616 X turn off warnings for export/import
4617 y turn on warnings for Ada 2005 incompatibility
4618 Y turn off warnings for Ada 2005 incompatibility
4619 z turn on size/align warnings for unchecked conversion
4620 Z turn off size/align warnings for unchecked conversion
4624 The specified warnings will be in effect until the end of the program
4625 or another pragma Warnings is encountered. The effect of the pragma is
4626 cumulative. Initially the set of warnings is the standard default set
4627 as possibly modified by compiler switches. Then each pragma Warning
4628 modifies this set of warnings as specified. This form of the pragma may
4629 also be used as a configuration pragma.
4631 The fourth form, with an On|Off parameter and a string, is used to
4632 control individual messages, based on their text. The string argument
4633 is a pattern that is used to match against the text of individual
4634 warning messages (not including the initial "warnings: " tag).
4636 The pattern may start with an asterisk, which matches otherwise unmatched
4637 characters at the start of the message, and it may also end with an asterisk
4638 which matches otherwise unmatched characters at the end of the message. For
4639 example, the string "*alignment*" could be used to match any warnings about
4640 alignment problems. Within the string, the sequence "*" can be used to match
4641 any sequence of characters enclosed in quotation marks. No other regular
4642 expression notations are permitted. All characters other than asterisk in
4643 these three specific cases are treated as literal characters in the match.
4645 There are two ways to use this pragma. The OFF form can be used as a
4646 configuration pragma. The effect is to suppress all warnings (if any)
4647 that match the pattern string throughout the compilation.
4649 The second usage is to suppress a warning locally, and in this case, two
4650 pragmas must appear in sequence:
4652 @smallexample @c ada
4653 pragma Warnings (Off, Pattern);
4654 @dots{} code where given warning is to be suppressed
4655 pragma Warnings (On, Pattern);
4659 In this usage, the pattern string must match in the Off and On pragmas,
4660 and at least one matching warning must be suppressed.
4662 @node Pragma Weak_External
4663 @unnumberedsec Pragma Weak_External
4664 @findex Weak_External
4668 @smallexample @c ada
4669 pragma Weak_External ([Entity =>] LOCAL_NAME);
4673 @var{LOCAL_NAME} must refer to an object that is declared at the library
4674 level. This pragma specifies that the given entity should be marked as a
4675 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
4676 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
4677 of a regular symbol, that is to say a symbol that does not have to be
4678 resolved by the linker if used in conjunction with a pragma Import.
4680 When a weak symbol is not resolved by the linker, its address is set to
4681 zero. This is useful in writing interfaces to external modules that may
4682 or may not be linked in the final executable, for example depending on
4683 configuration settings.
4685 If a program references at run time an entity to which this pragma has been
4686 applied, and the corresponding symbol was not resolved at link time, then
4687 the execution of the program is erroneous. It is not erroneous to take the
4688 Address of such an entity, for example to guard potential references,
4689 as shown in the example below.
4691 Some file formats do not support weak symbols so not all target machines
4692 support this pragma.
4694 @smallexample @c ada
4695 -- Example of the use of pragma Weak_External
4697 package External_Module is
4699 pragma Import (C, key);
4700 pragma Weak_External (key);
4701 function Present return boolean;
4702 end External_Module;
4704 with System; use System;
4705 package body External_Module is
4706 function Present return boolean is
4708 return key'Address /= System.Null_Address;
4710 end External_Module;
4713 @node Pragma Wide_Character_Encoding
4714 @unnumberedsec Pragma Wide_Character_Encoding
4715 @findex Wide_Character_Encoding
4719 @smallexample @c ada
4720 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
4724 This pragma specifies the wide character encoding to be used in program
4725 source text appearing subsequently. It is a configuration pragma, but may
4726 also be used at any point that a pragma is allowed, and it is permissible
4727 to have more than one such pragma in a file, allowing multiple encodings
4728 to appear within the same file.
4730 The argument can be an identifier or a character literal. In the identifier
4731 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
4732 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
4733 case it is correspondingly one of the characters @samp{h}, @samp{u},
4734 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
4736 Note that when the pragma is used within a file, it affects only the
4737 encoding within that file, and does not affect withed units, specs,
4740 @node Implementation Defined Attributes
4741 @chapter Implementation Defined Attributes
4742 Ada defines (throughout the Ada reference manual,
4743 summarized in Annex K),
4744 a set of attributes that provide useful additional functionality in all
4745 areas of the language. These language defined attributes are implemented
4746 in GNAT and work as described in the Ada Reference Manual.
4748 In addition, Ada allows implementations to define additional
4749 attributes whose meaning is defined by the implementation. GNAT provides
4750 a number of these implementation-dependent attributes which can be used
4751 to extend and enhance the functionality of the compiler. This section of
4752 the GNAT reference manual describes these additional attributes.
4754 Note that any program using these attributes may not be portable to
4755 other compilers (although GNAT implements this set of attributes on all
4756 platforms). Therefore if portability to other compilers is an important
4757 consideration, you should minimize the use of these attributes.
4768 * Default_Bit_Order::
4777 * Has_Access_Values::
4778 * Has_Discriminants::
4784 * Max_Interrupt_Priority::
4786 * Maximum_Alignment::
4790 * Passed_By_Reference::
4803 * Unconstrained_Array::
4804 * Universal_Literal_String::
4805 * Unrestricted_Access::
4813 @unnumberedsec Abort_Signal
4814 @findex Abort_Signal
4816 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4817 prefix) provides the entity for the special exception used to signal
4818 task abort or asynchronous transfer of control. Normally this attribute
4819 should only be used in the tasking runtime (it is highly peculiar, and
4820 completely outside the normal semantics of Ada, for a user program to
4821 intercept the abort exception).
4824 @unnumberedsec Address_Size
4825 @cindex Size of @code{Address}
4826 @findex Address_Size
4828 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4829 prefix) is a static constant giving the number of bits in an
4830 @code{Address}. It is the same value as System.Address'Size,
4831 but has the advantage of being static, while a direct
4832 reference to System.Address'Size is non-static because Address
4836 @unnumberedsec Asm_Input
4839 The @code{Asm_Input} attribute denotes a function that takes two
4840 parameters. The first is a string, the second is an expression of the
4841 type designated by the prefix. The first (string) argument is required
4842 to be a static expression, and is the constraint for the parameter,
4843 (e.g.@: what kind of register is required). The second argument is the
4844 value to be used as the input argument. The possible values for the
4845 constant are the same as those used in the RTL, and are dependent on
4846 the configuration file used to built the GCC back end.
4847 @ref{Machine Code Insertions}
4850 @unnumberedsec Asm_Output
4853 The @code{Asm_Output} attribute denotes a function that takes two
4854 parameters. The first is a string, the second is the name of a variable
4855 of the type designated by the attribute prefix. The first (string)
4856 argument is required to be a static expression and designates the
4857 constraint for the parameter (e.g.@: what kind of register is
4858 required). The second argument is the variable to be updated with the
4859 result. The possible values for constraint are the same as those used in
4860 the RTL, and are dependent on the configuration file used to build the
4861 GCC back end. If there are no output operands, then this argument may
4862 either be omitted, or explicitly given as @code{No_Output_Operands}.
4863 @ref{Machine Code Insertions}
4866 @unnumberedsec AST_Entry
4870 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
4871 the name of an entry, it yields a value of the predefined type AST_Handler
4872 (declared in the predefined package System, as extended by the use of
4873 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
4874 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
4875 Language Reference Manual}, section 9.12a.
4880 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4881 offset within the storage unit (byte) that contains the first bit of
4882 storage allocated for the object. The value of this attribute is of the
4883 type @code{Universal_Integer}, and is always a non-negative number not
4884 exceeding the value of @code{System.Storage_Unit}.
4886 For an object that is a variable or a constant allocated in a register,
4887 the value is zero. (The use of this attribute does not force the
4888 allocation of a variable to memory).
4890 For an object that is a formal parameter, this attribute applies
4891 to either the matching actual parameter or to a copy of the
4892 matching actual parameter.
4894 For an access object the value is zero. Note that
4895 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4896 designated object. Similarly for a record component
4897 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4898 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4899 are subject to index checks.
4901 This attribute is designed to be compatible with the DEC Ada 83 definition
4902 and implementation of the @code{Bit} attribute.
4905 @unnumberedsec Bit_Position
4906 @findex Bit_Position
4908 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4909 of the fields of the record type, yields the bit
4910 offset within the record contains the first bit of
4911 storage allocated for the object. The value of this attribute is of the
4912 type @code{Universal_Integer}. The value depends only on the field
4913 @var{C} and is independent of the alignment of
4914 the containing record @var{R}.
4917 @unnumberedsec Code_Address
4918 @findex Code_Address
4919 @cindex Subprogram address
4920 @cindex Address of subprogram code
4923 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
4924 intended effect seems to be to provide
4925 an address value which can be used to call the subprogram by means of
4926 an address clause as in the following example:
4928 @smallexample @c ada
4929 procedure K is @dots{}
4932 for L'Address use K'Address;
4933 pragma Import (Ada, L);
4937 A call to @code{L} is then expected to result in a call to @code{K}@.
4938 In Ada 83, where there were no access-to-subprogram values, this was
4939 a common work-around for getting the effect of an indirect call.
4940 GNAT implements the above use of @code{Address} and the technique
4941 illustrated by the example code works correctly.
4943 However, for some purposes, it is useful to have the address of the start
4944 of the generated code for the subprogram. On some architectures, this is
4945 not necessarily the same as the @code{Address} value described above.
4946 For example, the @code{Address} value may reference a subprogram
4947 descriptor rather than the subprogram itself.
4949 The @code{'Code_Address} attribute, which can only be applied to
4950 subprogram entities, always returns the address of the start of the
4951 generated code of the specified subprogram, which may or may not be
4952 the same value as is returned by the corresponding @code{'Address}
4955 @node Default_Bit_Order
4956 @unnumberedsec Default_Bit_Order
4958 @cindex Little endian
4959 @findex Default_Bit_Order
4961 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4962 permissible prefix), provides the value @code{System.Default_Bit_Order}
4963 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4964 @code{Low_Order_First}). This is used to construct the definition of
4965 @code{Default_Bit_Order} in package @code{System}.
4968 @unnumberedsec Elaborated
4971 The prefix of the @code{'Elaborated} attribute must be a unit name. The
4972 value is a Boolean which indicates whether or not the given unit has been
4973 elaborated. This attribute is primarily intended for internal use by the
4974 generated code for dynamic elaboration checking, but it can also be used
4975 in user programs. The value will always be True once elaboration of all
4976 units has been completed. An exception is for units which need no
4977 elaboration, the value is always False for such units.
4980 @unnumberedsec Elab_Body
4983 This attribute can only be applied to a program unit name. It returns
4984 the entity for the corresponding elaboration procedure for elaborating
4985 the body of the referenced unit. This is used in the main generated
4986 elaboration procedure by the binder and is not normally used in any
4987 other context. However, there may be specialized situations in which it
4988 is useful to be able to call this elaboration procedure from Ada code,
4989 e.g.@: if it is necessary to do selective re-elaboration to fix some
4993 @unnumberedsec Elab_Spec
4996 This attribute can only be applied to a program unit name. It returns
4997 the entity for the corresponding elaboration procedure for elaborating
4998 the specification of the referenced unit. This is used in the main
4999 generated elaboration procedure by the binder and is not normally used
5000 in any other context. However, there may be specialized situations in
5001 which it is useful to be able to call this elaboration procedure from
5002 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5007 @cindex Ada 83 attributes
5010 The @code{Emax} attribute is provided for compatibility with Ada 83. See
5011 the Ada 83 reference manual for an exact description of the semantics of
5015 @unnumberedsec Enabled
5018 The @code{Enabled} attribute allows an application program to check at compile
5019 time to see if the designated check is currently enabled. The prefix is a
5020 simple identifier, referencing any predefined check name (other than
5021 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5022 no argument is given for the attribute, the check is for the general state
5023 of the check, if an argument is given, then it is an entity name, and the
5024 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5025 given naming the entity (if not, then the argument is ignored).
5027 Note that instantiations inherit the check status at the point of the
5028 instantiation, so a useful idiom is to have a library package that
5029 introduces a check name with @code{pragma Check_Name}, and then contains
5030 generic packages or subprograms which use the @code{Enabled} attribute
5031 to see if the check is enabled. A user of this package can then issue
5032 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5033 the package or subprogram, controlling whether the check will be present.
5036 @unnumberedsec Enum_Rep
5037 @cindex Representation of enums
5040 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5041 function with the following spec:
5043 @smallexample @c ada
5044 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5045 return @i{Universal_Integer};
5049 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5050 enumeration type or to a non-overloaded enumeration
5051 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
5052 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5053 enumeration literal or object.
5055 The function returns the representation value for the given enumeration
5056 value. This will be equal to value of the @code{Pos} attribute in the
5057 absence of an enumeration representation clause. This is a static
5058 attribute (i.e.@: the result is static if the argument is static).
5060 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5061 in which case it simply returns the integer value. The reason for this
5062 is to allow it to be used for @code{(<>)} discrete formal arguments in
5063 a generic unit that can be instantiated with either enumeration types
5064 or integer types. Note that if @code{Enum_Rep} is used on a modular
5065 type whose upper bound exceeds the upper bound of the largest signed
5066 integer type, and the argument is a variable, so that the universal
5067 integer calculation is done at run time, then the call to @code{Enum_Rep}
5068 may raise @code{Constraint_Error}.
5071 @unnumberedsec Epsilon
5072 @cindex Ada 83 attributes
5075 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
5076 the Ada 83 reference manual for an exact description of the semantics of
5080 @unnumberedsec Fixed_Value
5083 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5084 function with the following specification:
5086 @smallexample @c ada
5087 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5092 The value returned is the fixed-point value @var{V} such that
5094 @smallexample @c ada
5095 @var{V} = Arg * @var{S}'Small
5099 The effect is thus similar to first converting the argument to the
5100 integer type used to represent @var{S}, and then doing an unchecked
5101 conversion to the fixed-point type. The difference is
5102 that there are full range checks, to ensure that the result is in range.
5103 This attribute is primarily intended for use in implementation of the
5104 input-output functions for fixed-point values.
5106 @node Has_Access_Values
5107 @unnumberedsec Has_Access_Values
5108 @cindex Access values, testing for
5109 @findex Has_Access_Values
5111 The prefix of the @code{Has_Access_Values} attribute is a type. The result
5112 is a Boolean value which is True if the is an access type, or is a composite
5113 type with a component (at any nesting depth) that is an access type, and is
5115 The intended use of this attribute is in conjunction with generic
5116 definitions. If the attribute is applied to a generic private type, it
5117 indicates whether or not the corresponding actual type has access values.
5119 @node Has_Discriminants
5120 @unnumberedsec Has_Discriminants
5121 @cindex Discriminants, testing for
5122 @findex Has_Discriminants
5124 The prefix of the @code{Has_Discriminants} attribute is a type. The result
5125 is a Boolean value which is True if the type has discriminants, and False
5126 otherwise. The intended use of this attribute is in conjunction with generic
5127 definitions. If the attribute is applied to a generic private type, it
5128 indicates whether or not the corresponding actual type has discriminants.
5134 The @code{Img} attribute differs from @code{Image} in that it may be
5135 applied to objects as well as types, in which case it gives the
5136 @code{Image} for the subtype of the object. This is convenient for
5139 @smallexample @c ada
5140 Put_Line ("X = " & X'Img);
5144 has the same meaning as the more verbose:
5146 @smallexample @c ada
5147 Put_Line ("X = " & @var{T}'Image (X));
5151 where @var{T} is the (sub)type of the object @code{X}.
5154 @unnumberedsec Integer_Value
5155 @findex Integer_Value
5157 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5158 function with the following spec:
5160 @smallexample @c ada
5161 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5166 The value returned is the integer value @var{V}, such that
5168 @smallexample @c ada
5169 Arg = @var{V} * @var{T}'Small
5173 where @var{T} is the type of @code{Arg}.
5174 The effect is thus similar to first doing an unchecked conversion from
5175 the fixed-point type to its corresponding implementation type, and then
5176 converting the result to the target integer type. The difference is
5177 that there are full range checks, to ensure that the result is in range.
5178 This attribute is primarily intended for use in implementation of the
5179 standard input-output functions for fixed-point values.
5182 @unnumberedsec Large
5183 @cindex Ada 83 attributes
5186 The @code{Large} attribute is provided for compatibility with Ada 83. See
5187 the Ada 83 reference manual for an exact description of the semantics of
5191 @unnumberedsec Machine_Size
5192 @findex Machine_Size
5194 This attribute is identical to the @code{Object_Size} attribute. It is
5195 provided for compatibility with the DEC Ada 83 attribute of this name.
5198 @unnumberedsec Mantissa
5199 @cindex Ada 83 attributes
5202 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
5203 the Ada 83 reference manual for an exact description of the semantics of
5206 @node Max_Interrupt_Priority
5207 @unnumberedsec Max_Interrupt_Priority
5208 @cindex Interrupt priority, maximum
5209 @findex Max_Interrupt_Priority
5211 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5212 permissible prefix), provides the same value as
5213 @code{System.Max_Interrupt_Priority}.
5216 @unnumberedsec Max_Priority
5217 @cindex Priority, maximum
5218 @findex Max_Priority
5220 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5221 prefix) provides the same value as @code{System.Max_Priority}.
5223 @node Maximum_Alignment
5224 @unnumberedsec Maximum_Alignment
5225 @cindex Alignment, maximum
5226 @findex Maximum_Alignment
5228 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5229 permissible prefix) provides the maximum useful alignment value for the
5230 target. This is a static value that can be used to specify the alignment
5231 for an object, guaranteeing that it is properly aligned in all
5234 @node Mechanism_Code
5235 @unnumberedsec Mechanism_Code
5236 @cindex Return values, passing mechanism
5237 @cindex Parameters, passing mechanism
5238 @findex Mechanism_Code
5240 @code{@var{function}'Mechanism_Code} yields an integer code for the
5241 mechanism used for the result of function, and
5242 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5243 used for formal parameter number @var{n} (a static integer value with 1
5244 meaning the first parameter) of @var{subprogram}. The code returned is:
5252 by descriptor (default descriptor class)
5254 by descriptor (UBS: unaligned bit string)
5256 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5258 by descriptor (UBA: unaligned bit array)
5260 by descriptor (S: string, also scalar access type parameter)
5262 by descriptor (SB: string with arbitrary bounds)
5264 by descriptor (A: contiguous array)
5266 by descriptor (NCA: non-contiguous array)
5270 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5273 @node Null_Parameter
5274 @unnumberedsec Null_Parameter
5275 @cindex Zero address, passing
5276 @findex Null_Parameter
5278 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5279 type or subtype @var{T} allocated at machine address zero. The attribute
5280 is allowed only as the default expression of a formal parameter, or as
5281 an actual expression of a subprogram call. In either case, the
5282 subprogram must be imported.
5284 The identity of the object is represented by the address zero in the
5285 argument list, independent of the passing mechanism (explicit or
5288 This capability is needed to specify that a zero address should be
5289 passed for a record or other composite object passed by reference.
5290 There is no way of indicating this without the @code{Null_Parameter}
5294 @unnumberedsec Object_Size
5295 @cindex Size, used for objects
5298 The size of an object is not necessarily the same as the size of the type
5299 of an object. This is because by default object sizes are increased to be
5300 a multiple of the alignment of the object. For example,
5301 @code{Natural'Size} is
5302 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5303 Similarly, a record containing an integer and a character:
5305 @smallexample @c ada
5313 will have a size of 40 (that is @code{Rec'Size} will be 40. The
5314 alignment will be 4, because of the
5315 integer field, and so the default size of record objects for this type
5316 will be 64 (8 bytes).
5318 The @code{@var{type}'Object_Size} attribute
5319 has been added to GNAT to allow the
5320 default object size of a type to be easily determined. For example,
5321 @code{Natural'Object_Size} is 32, and
5322 @code{Rec'Object_Size} (for the record type in the above example) will be
5323 64. Note also that, unlike the situation with the
5324 @code{Size} attribute as defined in the Ada RM, the
5325 @code{Object_Size} attribute can be specified individually
5326 for different subtypes. For example:
5328 @smallexample @c ada
5329 type R is new Integer;
5330 subtype R1 is R range 1 .. 10;
5331 subtype R2 is R range 1 .. 10;
5332 for R2'Object_Size use 8;
5336 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
5337 32 since the default object size for a subtype is the same as the object size
5338 for the parent subtype. This means that objects of type @code{R}
5340 by default be 32 bits (four bytes). But objects of type
5341 @code{R2} will be only
5342 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
5344 Although @code{Object_Size} does properly reflect the default object size
5345 value, it is not necessarily the case that all objects will be of this size
5346 in a case where it is not specified explicitly. The compiler is free to
5347 increase the size and alignment of stand alone objects to improve efficiency
5348 of the generated code and sometimes does so in the case of large composite
5349 objects. If the size of a stand alone object is critical to the
5350 application, it should be specified explicitly.
5352 @node Passed_By_Reference
5353 @unnumberedsec Passed_By_Reference
5354 @cindex Parameters, when passed by reference
5355 @findex Passed_By_Reference
5357 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5358 a value of type @code{Boolean} value that is @code{True} if the type is
5359 normally passed by reference and @code{False} if the type is normally
5360 passed by copy in calls. For scalar types, the result is always @code{False}
5361 and is static. For non-scalar types, the result is non-static.
5364 @unnumberedsec Pool_Address
5365 @cindex Parameters, when passed by reference
5366 @findex Pool_Address
5368 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
5369 of X within its storage pool. This is the same as
5370 @code{@var{X}'Address}, except that for an unconstrained array whose
5371 bounds are allocated just before the first component,
5372 @code{@var{X}'Pool_Address} returns the address of those bounds,
5373 whereas @code{@var{X}'Address} returns the address of the first
5376 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
5377 the object is allocated'', which could be a user-defined storage pool,
5378 the global heap, on the stack, or in a static memory area. For an
5379 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
5380 what is passed to @code{Allocate} and returned from @code{Deallocate}.
5383 @unnumberedsec Range_Length
5384 @findex Range_Length
5386 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5387 the number of values represented by the subtype (zero for a null
5388 range). The result is static for static subtypes. @code{Range_Length}
5389 applied to the index subtype of a one dimensional array always gives the
5390 same result as @code{Range} applied to the array itself.
5393 @unnumberedsec Safe_Emax
5394 @cindex Ada 83 attributes
5397 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
5398 the Ada 83 reference manual for an exact description of the semantics of
5402 @unnumberedsec Safe_Large
5403 @cindex Ada 83 attributes
5406 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
5407 the Ada 83 reference manual for an exact description of the semantics of
5411 @unnumberedsec Small
5412 @cindex Ada 83 attributes
5415 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
5417 GNAT also allows this attribute to be applied to floating-point types
5418 for compatibility with Ada 83. See
5419 the Ada 83 reference manual for an exact description of the semantics of
5420 this attribute when applied to floating-point types.
5423 @unnumberedsec Storage_Unit
5424 @findex Storage_Unit
5426 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
5427 prefix) provides the same value as @code{System.Storage_Unit}.
5430 @unnumberedsec Stub_Type
5433 The GNAT implementation of remote access-to-classwide types is
5434 organized as described in AARM section E.4 (20.t): a value of an RACW type
5435 (designating a remote object) is represented as a normal access
5436 value, pointing to a "stub" object which in turn contains the
5437 necessary information to contact the designated remote object. A
5438 call on any dispatching operation of such a stub object does the
5439 remote call, if necessary, using the information in the stub object
5440 to locate the target partition, etc.
5442 For a prefix @code{T} that denotes a remote access-to-classwide type,
5443 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
5445 By construction, the layout of @code{T'Stub_Type} is identical to that of
5446 type @code{RACW_Stub_Type} declared in the internal implementation-defined
5447 unit @code{System.Partition_Interface}. Use of this attribute will create
5448 an implicit dependency on this unit.
5451 @unnumberedsec Target_Name
5454 @code{Standard'Target_Name} (@code{Standard} is the only permissible
5455 prefix) provides a static string value that identifies the target
5456 for the current compilation. For GCC implementations, this is the
5457 standard gcc target name without the terminating slash (for
5458 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
5464 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
5465 provides the same value as @code{System.Tick},
5468 @unnumberedsec To_Address
5471 The @code{System'To_Address}
5472 (@code{System} is the only permissible prefix)
5473 denotes a function identical to
5474 @code{System.Storage_Elements.To_Address} except that
5475 it is a static attribute. This means that if its argument is
5476 a static expression, then the result of the attribute is a
5477 static expression. The result is that such an expression can be
5478 used in contexts (e.g.@: preelaborable packages) which require a
5479 static expression and where the function call could not be used
5480 (since the function call is always non-static, even if its
5481 argument is static).
5484 @unnumberedsec Type_Class
5487 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
5488 the value of the type class for the full type of @var{type}. If
5489 @var{type} is a generic formal type, the value is the value for the
5490 corresponding actual subtype. The value of this attribute is of type
5491 @code{System.Aux_DEC.Type_Class}, which has the following definition:
5493 @smallexample @c ada
5495 (Type_Class_Enumeration,
5497 Type_Class_Fixed_Point,
5498 Type_Class_Floating_Point,
5503 Type_Class_Address);
5507 Protected types yield the value @code{Type_Class_Task}, which thus
5508 applies to all concurrent types. This attribute is designed to
5509 be compatible with the DEC Ada 83 attribute of the same name.
5512 @unnumberedsec UET_Address
5515 The @code{UET_Address} attribute can only be used for a prefix which
5516 denotes a library package. It yields the address of the unit exception
5517 table when zero cost exception handling is used. This attribute is
5518 intended only for use within the GNAT implementation. See the unit
5519 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
5520 for details on how this attribute is used in the implementation.
5522 @node Unconstrained_Array
5523 @unnumberedsec Unconstrained_Array
5524 @findex Unconstrained_Array
5526 The @code{Unconstrained_Array} attribute can be used with a prefix that
5527 denotes any type or subtype. It is a static attribute that yields
5528 @code{True} if the prefix designates an unconstrained array,
5529 and @code{False} otherwise. In a generic instance, the result is
5530 still static, and yields the result of applying this test to the
5533 @node Universal_Literal_String
5534 @unnumberedsec Universal_Literal_String
5535 @cindex Named numbers, representation of
5536 @findex Universal_Literal_String
5538 The prefix of @code{Universal_Literal_String} must be a named
5539 number. The static result is the string consisting of the characters of
5540 the number as defined in the original source. This allows the user
5541 program to access the actual text of named numbers without intermediate
5542 conversions and without the need to enclose the strings in quotes (which
5543 would preclude their use as numbers). This is used internally for the
5544 construction of values of the floating-point attributes from the file
5545 @file{ttypef.ads}, but may also be used by user programs.
5547 For example, the following program prints the first 50 digits of pi:
5549 @smallexample @c ada
5550 with Text_IO; use Text_IO;
5554 Put (Ada.Numerics.Pi'Universal_Literal_String);
5558 @node Unrestricted_Access
5559 @unnumberedsec Unrestricted_Access
5560 @cindex @code{Access}, unrestricted
5561 @findex Unrestricted_Access
5563 The @code{Unrestricted_Access} attribute is similar to @code{Access}
5564 except that all accessibility and aliased view checks are omitted. This
5565 is a user-beware attribute. It is similar to
5566 @code{Address}, for which it is a desirable replacement where the value
5567 desired is an access type. In other words, its effect is identical to
5568 first applying the @code{Address} attribute and then doing an unchecked
5569 conversion to a desired access type. In GNAT, but not necessarily in
5570 other implementations, the use of static chains for inner level
5571 subprograms means that @code{Unrestricted_Access} applied to a
5572 subprogram yields a value that can be called as long as the subprogram
5573 is in scope (normal Ada accessibility rules restrict this usage).
5575 It is possible to use @code{Unrestricted_Access} for any type, but care
5576 must be exercised if it is used to create pointers to unconstrained
5577 objects. In this case, the resulting pointer has the same scope as the
5578 context of the attribute, and may not be returned to some enclosing
5579 scope. For instance, a function cannot use @code{Unrestricted_Access}
5580 to create a unconstrained pointer and then return that value to the
5584 @unnumberedsec VADS_Size
5585 @cindex @code{Size}, VADS compatibility
5588 The @code{'VADS_Size} attribute is intended to make it easier to port
5589 legacy code which relies on the semantics of @code{'Size} as implemented
5590 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
5591 same semantic interpretation. In particular, @code{'VADS_Size} applied
5592 to a predefined or other primitive type with no Size clause yields the
5593 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
5594 typical machines). In addition @code{'VADS_Size} applied to an object
5595 gives the result that would be obtained by applying the attribute to
5596 the corresponding type.
5599 @unnumberedsec Value_Size
5600 @cindex @code{Size}, setting for not-first subtype
5602 @code{@var{type}'Value_Size} is the number of bits required to represent
5603 a value of the given subtype. It is the same as @code{@var{type}'Size},
5604 but, unlike @code{Size}, may be set for non-first subtypes.
5607 @unnumberedsec Wchar_T_Size
5608 @findex Wchar_T_Size
5609 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
5610 prefix) provides the size in bits of the C @code{wchar_t} type
5611 primarily for constructing the definition of this type in
5612 package @code{Interfaces.C}.
5615 @unnumberedsec Word_Size
5617 @code{Standard'Word_Size} (@code{Standard} is the only permissible
5618 prefix) provides the value @code{System.Word_Size}.
5620 @c ------------------------
5621 @node Implementation Advice
5622 @chapter Implementation Advice
5624 The main text of the Ada Reference Manual describes the required
5625 behavior of all Ada compilers, and the GNAT compiler conforms to
5628 In addition, there are sections throughout the Ada Reference Manual headed
5629 by the phrase ``Implementation advice''. These sections are not normative,
5630 i.e., they do not specify requirements that all compilers must
5631 follow. Rather they provide advice on generally desirable behavior. You
5632 may wonder why they are not requirements. The most typical answer is
5633 that they describe behavior that seems generally desirable, but cannot
5634 be provided on all systems, or which may be undesirable on some systems.
5636 As far as practical, GNAT follows the implementation advice sections in
5637 the Ada Reference Manual. This chapter contains a table giving the
5638 reference manual section number, paragraph number and several keywords
5639 for each advice. Each entry consists of the text of the advice followed
5640 by the GNAT interpretation of this advice. Most often, this simply says
5641 ``followed'', which means that GNAT follows the advice. However, in a
5642 number of cases, GNAT deliberately deviates from this advice, in which
5643 case the text describes what GNAT does and why.
5645 @cindex Error detection
5646 @unnumberedsec 1.1.3(20): Error Detection
5649 If an implementation detects the use of an unsupported Specialized Needs
5650 Annex feature at run time, it should raise @code{Program_Error} if
5653 Not relevant. All specialized needs annex features are either supported,
5654 or diagnosed at compile time.
5657 @unnumberedsec 1.1.3(31): Child Units
5660 If an implementation wishes to provide implementation-defined
5661 extensions to the functionality of a language-defined library unit, it
5662 should normally do so by adding children to the library unit.
5666 @cindex Bounded errors
5667 @unnumberedsec 1.1.5(12): Bounded Errors
5670 If an implementation detects a bounded error or erroneous
5671 execution, it should raise @code{Program_Error}.
5673 Followed in all cases in which the implementation detects a bounded
5674 error or erroneous execution. Not all such situations are detected at
5678 @unnumberedsec 2.8(16): Pragmas
5681 Normally, implementation-defined pragmas should have no semantic effect
5682 for error-free programs; that is, if the implementation-defined pragmas
5683 are removed from a working program, the program should still be legal,
5684 and should still have the same semantics.
5686 The following implementation defined pragmas are exceptions to this
5698 @item CPP_Constructor
5702 @item Interface_Name
5704 @item Machine_Attribute
5706 @item Unimplemented_Unit
5708 @item Unchecked_Union
5713 In each of the above cases, it is essential to the purpose of the pragma
5714 that this advice not be followed. For details see the separate section
5715 on implementation defined pragmas.
5717 @unnumberedsec 2.8(17-19): Pragmas
5720 Normally, an implementation should not define pragmas that can
5721 make an illegal program legal, except as follows:
5725 A pragma used to complete a declaration, such as a pragma @code{Import};
5729 A pragma used to configure the environment by adding, removing, or
5730 replacing @code{library_items}.
5732 See response to paragraph 16 of this same section.
5734 @cindex Character Sets
5735 @cindex Alternative Character Sets
5736 @unnumberedsec 3.5.2(5): Alternative Character Sets
5739 If an implementation supports a mode with alternative interpretations
5740 for @code{Character} and @code{Wide_Character}, the set of graphic
5741 characters of @code{Character} should nevertheless remain a proper
5742 subset of the set of graphic characters of @code{Wide_Character}. Any
5743 character set ``localizations'' should be reflected in the results of
5744 the subprograms defined in the language-defined package
5745 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
5746 an alternative interpretation of @code{Character}, the implementation should
5747 also support a corresponding change in what is a legal
5748 @code{identifier_letter}.
5750 Not all wide character modes follow this advice, in particular the JIS
5751 and IEC modes reflect standard usage in Japan, and in these encoding,
5752 the upper half of the Latin-1 set is not part of the wide-character
5753 subset, since the most significant bit is used for wide character
5754 encoding. However, this only applies to the external forms. Internally
5755 there is no such restriction.
5757 @cindex Integer types
5758 @unnumberedsec 3.5.4(28): Integer Types
5762 An implementation should support @code{Long_Integer} in addition to
5763 @code{Integer} if the target machine supports 32-bit (or longer)
5764 arithmetic. No other named integer subtypes are recommended for package
5765 @code{Standard}. Instead, appropriate named integer subtypes should be
5766 provided in the library package @code{Interfaces} (see B.2).
5768 @code{Long_Integer} is supported. Other standard integer types are supported
5769 so this advice is not fully followed. These types
5770 are supported for convenient interface to C, and so that all hardware
5771 types of the machine are easily available.
5772 @unnumberedsec 3.5.4(29): Integer Types
5776 An implementation for a two's complement machine should support
5777 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
5778 implementation should support a non-binary modules up to @code{Integer'Last}.
5782 @cindex Enumeration values
5783 @unnumberedsec 3.5.5(8): Enumeration Values
5786 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
5787 subtype, if the value of the operand does not correspond to the internal
5788 code for any enumeration literal of its type (perhaps due to an
5789 un-initialized variable), then the implementation should raise
5790 @code{Program_Error}. This is particularly important for enumeration
5791 types with noncontiguous internal codes specified by an
5792 enumeration_representation_clause.
5797 @unnumberedsec 3.5.7(17): Float Types
5800 An implementation should support @code{Long_Float} in addition to
5801 @code{Float} if the target machine supports 11 or more digits of
5802 precision. No other named floating point subtypes are recommended for
5803 package @code{Standard}. Instead, appropriate named floating point subtypes
5804 should be provided in the library package @code{Interfaces} (see B.2).
5806 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
5807 former provides improved compatibility with other implementations
5808 supporting this type. The latter corresponds to the highest precision
5809 floating-point type supported by the hardware. On most machines, this
5810 will be the same as @code{Long_Float}, but on some machines, it will
5811 correspond to the IEEE extended form. The notable case is all ia32
5812 (x86) implementations, where @code{Long_Long_Float} corresponds to
5813 the 80-bit extended precision format supported in hardware on this
5814 processor. Note that the 128-bit format on SPARC is not supported,
5815 since this is a software rather than a hardware format.
5817 @cindex Multidimensional arrays
5818 @cindex Arrays, multidimensional
5819 @unnumberedsec 3.6.2(11): Multidimensional Arrays
5822 An implementation should normally represent multidimensional arrays in
5823 row-major order, consistent with the notation used for multidimensional
5824 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
5825 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
5826 column-major order should be used instead (see B.5, ``Interfacing with
5831 @findex Duration'Small
5832 @unnumberedsec 9.6(30-31): Duration'Small
5835 Whenever possible in an implementation, the value of @code{Duration'Small}
5836 should be no greater than 100 microseconds.
5838 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
5842 The time base for @code{delay_relative_statements} should be monotonic;
5843 it need not be the same time base as used for @code{Calendar.Clock}.
5847 @unnumberedsec 10.2.1(12): Consistent Representation
5850 In an implementation, a type declared in a pre-elaborated package should
5851 have the same representation in every elaboration of a given version of
5852 the package, whether the elaborations occur in distinct executions of
5853 the same program, or in executions of distinct programs or partitions
5854 that include the given version.
5856 Followed, except in the case of tagged types. Tagged types involve
5857 implicit pointers to a local copy of a dispatch table, and these pointers
5858 have representations which thus depend on a particular elaboration of the
5859 package. It is not easy to see how it would be possible to follow this
5860 advice without severely impacting efficiency of execution.
5862 @cindex Exception information
5863 @unnumberedsec 11.4.1(19): Exception Information
5866 @code{Exception_Message} by default and @code{Exception_Information}
5867 should produce information useful for
5868 debugging. @code{Exception_Message} should be short, about one
5869 line. @code{Exception_Information} can be long. @code{Exception_Message}
5870 should not include the
5871 @code{Exception_Name}. @code{Exception_Information} should include both
5872 the @code{Exception_Name} and the @code{Exception_Message}.
5874 Followed. For each exception that doesn't have a specified
5875 @code{Exception_Message}, the compiler generates one containing the location
5876 of the raise statement. This location has the form ``file:line'', where
5877 file is the short file name (without path information) and line is the line
5878 number in the file. Note that in the case of the Zero Cost Exception
5879 mechanism, these messages become redundant with the Exception_Information that
5880 contains a full backtrace of the calling sequence, so they are disabled.
5881 To disable explicitly the generation of the source location message, use the
5882 Pragma @code{Discard_Names}.
5884 @cindex Suppression of checks
5885 @cindex Checks, suppression of
5886 @unnumberedsec 11.5(28): Suppression of Checks
5889 The implementation should minimize the code executed for checks that
5890 have been suppressed.
5894 @cindex Representation clauses
5895 @unnumberedsec 13.1 (21-24): Representation Clauses
5898 The recommended level of support for all representation items is
5899 qualified as follows:
5903 An implementation need not support representation items containing
5904 non-static expressions, except that an implementation should support a
5905 representation item for a given entity if each non-static expression in
5906 the representation item is a name that statically denotes a constant
5907 declared before the entity.
5909 Followed. In fact, GNAT goes beyond the recommended level of support
5910 by allowing nonstatic expressions in some representation clauses even
5911 without the need to declare constants initialized with the values of
5915 @smallexample @c ada
5918 for Y'Address use X'Address;>>
5924 An implementation need not support a specification for the @code{Size}
5925 for a given composite subtype, nor the size or storage place for an
5926 object (including a component) of a given composite subtype, unless the
5927 constraints on the subtype and its composite subcomponents (if any) are
5928 all static constraints.
5930 Followed. Size Clauses are not permitted on non-static components, as
5935 An aliased component, or a component whose type is by-reference, should
5936 always be allocated at an addressable location.
5940 @cindex Packed types
5941 @unnumberedsec 13.2(6-8): Packed Types
5944 If a type is packed, then the implementation should try to minimize
5945 storage allocated to objects of the type, possibly at the expense of
5946 speed of accessing components, subject to reasonable complexity in
5947 addressing calculations.
5951 The recommended level of support pragma @code{Pack} is:
5953 For a packed record type, the components should be packed as tightly as
5954 possible subject to the Sizes of the component subtypes, and subject to
5955 any @code{record_representation_clause} that applies to the type; the
5956 implementation may, but need not, reorder components or cross aligned
5957 word boundaries to improve the packing. A component whose @code{Size} is
5958 greater than the word size may be allocated an integral number of words.
5960 Followed. Tight packing of arrays is supported for all component sizes
5961 up to 64-bits. If the array component size is 1 (that is to say, if
5962 the component is a boolean type or an enumeration type with two values)
5963 then values of the type are implicitly initialized to zero. This
5964 happens both for objects of the packed type, and for objects that have a
5965 subcomponent of the packed type.
5969 An implementation should support Address clauses for imported
5973 @cindex @code{Address} clauses
5974 @unnumberedsec 13.3(14-19): Address Clauses
5978 For an array @var{X}, @code{@var{X}'Address} should point at the first
5979 component of the array, and not at the array bounds.
5985 The recommended level of support for the @code{Address} attribute is:
5987 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5988 object that is aliased or of a by-reference type, or is an entity whose
5989 @code{Address} has been specified.
5991 Followed. A valid address will be produced even if none of those
5992 conditions have been met. If necessary, the object is forced into
5993 memory to ensure the address is valid.
5997 An implementation should support @code{Address} clauses for imported
6004 Objects (including subcomponents) that are aliased or of a by-reference
6005 type should be allocated on storage element boundaries.
6011 If the @code{Address} of an object is specified, or it is imported or exported,
6012 then the implementation should not perform optimizations based on
6013 assumptions of no aliases.
6017 @cindex @code{Alignment} clauses
6018 @unnumberedsec 13.3(29-35): Alignment Clauses
6021 The recommended level of support for the @code{Alignment} attribute for
6024 An implementation should support specified Alignments that are factors
6025 and multiples of the number of storage elements per word, subject to the
6032 An implementation need not support specified @code{Alignment}s for
6033 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6034 loaded and stored by available machine instructions.
6040 An implementation need not support specified @code{Alignment}s that are
6041 greater than the maximum @code{Alignment} the implementation ever returns by
6048 The recommended level of support for the @code{Alignment} attribute for
6051 Same as above, for subtypes, but in addition:
6057 For stand-alone library-level objects of statically constrained
6058 subtypes, the implementation should support all @code{Alignment}s
6059 supported by the target linker. For example, page alignment is likely to
6060 be supported for such objects, but not for subtypes.
6064 @cindex @code{Size} clauses
6065 @unnumberedsec 13.3(42-43): Size Clauses
6068 The recommended level of support for the @code{Size} attribute of
6071 A @code{Size} clause should be supported for an object if the specified
6072 @code{Size} is at least as large as its subtype's @code{Size}, and
6073 corresponds to a size in storage elements that is a multiple of the
6074 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6078 @unnumberedsec 13.3(50-56): Size Clauses
6081 If the @code{Size} of a subtype is specified, and allows for efficient
6082 independent addressability (see 9.10) on the target architecture, then
6083 the @code{Size} of the following objects of the subtype should equal the
6084 @code{Size} of the subtype:
6086 Aliased objects (including components).
6092 @code{Size} clause on a composite subtype should not affect the
6093 internal layout of components.
6095 Followed. But note that this can be overridden by use of the implementation
6096 pragma Implicit_Packing in the case of packed arrays.
6100 The recommended level of support for the @code{Size} attribute of subtypes is:
6104 The @code{Size} (if not specified) of a static discrete or fixed point
6105 subtype should be the number of bits needed to represent each value
6106 belonging to the subtype using an unbiased representation, leaving space
6107 for a sign bit only if the subtype contains negative values. If such a
6108 subtype is a first subtype, then an implementation should support a
6109 specified @code{Size} for it that reflects this representation.
6115 For a subtype implemented with levels of indirection, the @code{Size}
6116 should include the size of the pointers, but not the size of what they
6121 @cindex @code{Component_Size} clauses
6122 @unnumberedsec 13.3(71-73): Component Size Clauses
6125 The recommended level of support for the @code{Component_Size}
6130 An implementation need not support specified @code{Component_Sizes} that are
6131 less than the @code{Size} of the component subtype.
6137 An implementation should support specified @code{Component_Size}s that
6138 are factors and multiples of the word size. For such
6139 @code{Component_Size}s, the array should contain no gaps between
6140 components. For other @code{Component_Size}s (if supported), the array
6141 should contain no gaps between components when packing is also
6142 specified; the implementation should forbid this combination in cases
6143 where it cannot support a no-gaps representation.
6147 @cindex Enumeration representation clauses
6148 @cindex Representation clauses, enumeration
6149 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6152 The recommended level of support for enumeration representation clauses
6155 An implementation need not support enumeration representation clauses
6156 for boolean types, but should at minimum support the internal codes in
6157 the range @code{System.Min_Int.System.Max_Int}.
6161 @cindex Record representation clauses
6162 @cindex Representation clauses, records
6163 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6166 The recommended level of support for
6167 @*@code{record_representation_clauses} is:
6169 An implementation should support storage places that can be extracted
6170 with a load, mask, shift sequence of machine code, and set with a load,
6171 shift, mask, store sequence, given the available machine instructions
6178 A storage place should be supported if its size is equal to the
6179 @code{Size} of the component subtype, and it starts and ends on a
6180 boundary that obeys the @code{Alignment} of the component subtype.
6186 If the default bit ordering applies to the declaration of a given type,
6187 then for a component whose subtype's @code{Size} is less than the word
6188 size, any storage place that does not cross an aligned word boundary
6189 should be supported.
6195 An implementation may reserve a storage place for the tag field of a
6196 tagged type, and disallow other components from overlapping that place.
6198 Followed. The storage place for the tag field is the beginning of the tagged
6199 record, and its size is Address'Size. GNAT will reject an explicit component
6200 clause for the tag field.
6204 An implementation need not support a @code{component_clause} for a
6205 component of an extension part if the storage place is not after the
6206 storage places of all components of the parent type, whether or not
6207 those storage places had been specified.
6209 Followed. The above advice on record representation clauses is followed,
6210 and all mentioned features are implemented.
6212 @cindex Storage place attributes
6213 @unnumberedsec 13.5.2(5): Storage Place Attributes
6216 If a component is represented using some form of pointer (such as an
6217 offset) to the actual data of the component, and this data is contiguous
6218 with the rest of the object, then the storage place attributes should
6219 reflect the place of the actual data, not the pointer. If a component is
6220 allocated discontinuously from the rest of the object, then a warning
6221 should be generated upon reference to one of its storage place
6224 Followed. There are no such components in GNAT@.
6226 @cindex Bit ordering
6227 @unnumberedsec 13.5.3(7-8): Bit Ordering
6230 The recommended level of support for the non-default bit ordering is:
6234 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6235 should support the non-default bit ordering in addition to the default
6238 Followed. Word size does not equal storage size in this implementation.
6239 Thus non-default bit ordering is not supported.
6241 @cindex @code{Address}, as private type
6242 @unnumberedsec 13.7(37): Address as Private
6245 @code{Address} should be of a private type.
6249 @cindex Operations, on @code{Address}
6250 @cindex @code{Address}, operations of
6251 @unnumberedsec 13.7.1(16): Address Operations
6254 Operations in @code{System} and its children should reflect the target
6255 environment semantics as closely as is reasonable. For example, on most
6256 machines, it makes sense for address arithmetic to ``wrap around''.
6257 Operations that do not make sense should raise @code{Program_Error}.
6259 Followed. Address arithmetic is modular arithmetic that wraps around. No
6260 operation raises @code{Program_Error}, since all operations make sense.
6262 @cindex Unchecked conversion
6263 @unnumberedsec 13.9(14-17): Unchecked Conversion
6266 The @code{Size} of an array object should not include its bounds; hence,
6267 the bounds should not be part of the converted data.
6273 The implementation should not generate unnecessary run-time checks to
6274 ensure that the representation of @var{S} is a representation of the
6275 target type. It should take advantage of the permission to return by
6276 reference when possible. Restrictions on unchecked conversions should be
6277 avoided unless required by the target environment.
6279 Followed. There are no restrictions on unchecked conversion. A warning is
6280 generated if the source and target types do not have the same size since
6281 the semantics in this case may be target dependent.
6285 The recommended level of support for unchecked conversions is:
6289 Unchecked conversions should be supported and should be reversible in
6290 the cases where this clause defines the result. To enable meaningful use
6291 of unchecked conversion, a contiguous representation should be used for
6292 elementary subtypes, for statically constrained array subtypes whose
6293 component subtype is one of the subtypes described in this paragraph,
6294 and for record subtypes without discriminants whose component subtypes
6295 are described in this paragraph.
6299 @cindex Heap usage, implicit
6300 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6303 An implementation should document any cases in which it dynamically
6304 allocates heap storage for a purpose other than the evaluation of an
6307 Followed, the only other points at which heap storage is dynamically
6308 allocated are as follows:
6312 At initial elaboration time, to allocate dynamically sized global
6316 To allocate space for a task when a task is created.
6319 To extend the secondary stack dynamically when needed. The secondary
6320 stack is used for returning variable length results.
6325 A default (implementation-provided) storage pool for an
6326 access-to-constant type should not have overhead to support deallocation of
6333 A storage pool for an anonymous access type should be created at the
6334 point of an allocator for the type, and be reclaimed when the designated
6335 object becomes inaccessible.
6339 @cindex Unchecked deallocation
6340 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6343 For a standard storage pool, @code{Free} should actually reclaim the
6348 @cindex Stream oriented attributes
6349 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6352 If a stream element is the same size as a storage element, then the
6353 normal in-memory representation should be used by @code{Read} and
6354 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
6355 should use the smallest number of stream elements needed to represent
6356 all values in the base range of the scalar type.
6359 Followed. By default, GNAT uses the interpretation suggested by AI-195,
6360 which specifies using the size of the first subtype.
6361 However, such an implementation is based on direct binary
6362 representations and is therefore target- and endianness-dependent.
6363 To address this issue, GNAT also supplies an alternate implementation
6364 of the stream attributes @code{Read} and @code{Write},
6365 which uses the target-independent XDR standard representation
6367 @cindex XDR representation
6368 @cindex @code{Read} attribute
6369 @cindex @code{Write} attribute
6370 @cindex Stream oriented attributes
6371 The XDR implementation is provided as an alternative body of the
6372 @code{System.Stream_Attributes} package, in the file
6373 @file{s-strxdr.adb} in the GNAT library.
6374 There is no @file{s-strxdr.ads} file.
6375 In order to install the XDR implementation, do the following:
6377 @item Replace the default implementation of the
6378 @code{System.Stream_Attributes} package with the XDR implementation.
6379 For example on a Unix platform issue the commands:
6381 $ mv s-stratt.adb s-strold.adb
6382 $ mv s-strxdr.adb s-stratt.adb
6386 Rebuild the GNAT run-time library as documented in the
6387 @cite{GNAT User's Guide}
6390 @unnumberedsec A.1(52): Names of Predefined Numeric Types
6393 If an implementation provides additional named predefined integer types,
6394 then the names should end with @samp{Integer} as in
6395 @samp{Long_Integer}. If an implementation provides additional named
6396 predefined floating point types, then the names should end with
6397 @samp{Float} as in @samp{Long_Float}.
6401 @findex Ada.Characters.Handling
6402 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
6405 If an implementation provides a localized definition of @code{Character}
6406 or @code{Wide_Character}, then the effects of the subprograms in
6407 @code{Characters.Handling} should reflect the localizations. See also
6410 Followed. GNAT provides no such localized definitions.
6412 @cindex Bounded-length strings
6413 @unnumberedsec A.4.4(106): Bounded-Length String Handling
6416 Bounded string objects should not be implemented by implicit pointers
6417 and dynamic allocation.
6419 Followed. No implicit pointers or dynamic allocation are used.
6421 @cindex Random number generation
6422 @unnumberedsec A.5.2(46-47): Random Number Generation
6425 Any storage associated with an object of type @code{Generator} should be
6426 reclaimed on exit from the scope of the object.
6432 If the generator period is sufficiently long in relation to the number
6433 of distinct initiator values, then each possible value of
6434 @code{Initiator} passed to @code{Reset} should initiate a sequence of
6435 random numbers that does not, in a practical sense, overlap the sequence
6436 initiated by any other value. If this is not possible, then the mapping
6437 between initiator values and generator states should be a rapidly
6438 varying function of the initiator value.
6440 Followed. The generator period is sufficiently long for the first
6441 condition here to hold true.
6443 @findex Get_Immediate
6444 @unnumberedsec A.10.7(23): @code{Get_Immediate}
6447 The @code{Get_Immediate} procedures should be implemented with
6448 unbuffered input. For a device such as a keyboard, input should be
6449 @dfn{available} if a key has already been typed, whereas for a disk
6450 file, input should always be available except at end of file. For a file
6451 associated with a keyboard-like device, any line-editing features of the
6452 underlying operating system should be disabled during the execution of
6453 @code{Get_Immediate}.
6455 Followed on all targets except VxWorks. For VxWorks, there is no way to
6456 provide this functionality that does not result in the input buffer being
6457 flushed before the @code{Get_Immediate} call. A special unit
6458 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
6462 @unnumberedsec B.1(39-41): Pragma @code{Export}
6465 If an implementation supports pragma @code{Export} to a given language,
6466 then it should also allow the main subprogram to be written in that
6467 language. It should support some mechanism for invoking the elaboration
6468 of the Ada library units included in the system, and for invoking the
6469 finalization of the environment task. On typical systems, the
6470 recommended mechanism is to provide two subprograms whose link names are
6471 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
6472 elaboration code for library units. @code{adafinal} should contain the
6473 finalization code. These subprograms should have no effect the second
6474 and subsequent time they are called.
6480 Automatic elaboration of pre-elaborated packages should be
6481 provided when pragma @code{Export} is supported.
6483 Followed when the main program is in Ada. If the main program is in a
6484 foreign language, then
6485 @code{adainit} must be called to elaborate pre-elaborated
6490 For each supported convention @var{L} other than @code{Intrinsic}, an
6491 implementation should support @code{Import} and @code{Export} pragmas
6492 for objects of @var{L}-compatible types and for subprograms, and pragma
6493 @code{Convention} for @var{L}-eligible types and for subprograms,
6494 presuming the other language has corresponding features. Pragma
6495 @code{Convention} need not be supported for scalar types.
6499 @cindex Package @code{Interfaces}
6501 @unnumberedsec B.2(12-13): Package @code{Interfaces}
6504 For each implementation-defined convention identifier, there should be a
6505 child package of package Interfaces with the corresponding name. This
6506 package should contain any declarations that would be useful for
6507 interfacing to the language (implementation) represented by the
6508 convention. Any declarations useful for interfacing to any language on
6509 the given hardware architecture should be provided directly in
6512 Followed. An additional package not defined
6513 in the Ada Reference Manual is @code{Interfaces.CPP}, used
6514 for interfacing to C++.
6518 An implementation supporting an interface to C, COBOL, or Fortran should
6519 provide the corresponding package or packages described in the following
6522 Followed. GNAT provides all the packages described in this section.
6524 @cindex C, interfacing with
6525 @unnumberedsec B.3(63-71): Interfacing with C
6528 An implementation should support the following interface correspondences
6535 An Ada procedure corresponds to a void-returning C function.
6541 An Ada function corresponds to a non-void C function.
6547 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
6554 An Ada @code{in} parameter of an access-to-object type with designated
6555 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
6556 where @var{t} is the C type corresponding to the Ada type @var{T}.
6562 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
6563 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
6564 argument to a C function, where @var{t} is the C type corresponding to
6565 the Ada type @var{T}. In the case of an elementary @code{out} or
6566 @code{in out} parameter, a pointer to a temporary copy is used to
6567 preserve by-copy semantics.
6573 An Ada parameter of a record type @var{T}, of any mode, is passed as a
6574 @code{@var{t}*} argument to a C function, where @var{t} is the C
6575 structure corresponding to the Ada type @var{T}.
6577 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
6578 pragma, or Convention, or by explicitly specifying the mechanism for a given
6579 call using an extended import or export pragma.
6583 An Ada parameter of an array type with component type @var{T}, of any
6584 mode, is passed as a @code{@var{t}*} argument to a C function, where
6585 @var{t} is the C type corresponding to the Ada type @var{T}.
6591 An Ada parameter of an access-to-subprogram type is passed as a pointer
6592 to a C function whose prototype corresponds to the designated
6593 subprogram's specification.
6597 @cindex COBOL, interfacing with
6598 @unnumberedsec B.4(95-98): Interfacing with COBOL
6601 An Ada implementation should support the following interface
6602 correspondences between Ada and COBOL@.
6608 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
6609 the COBOL type corresponding to @var{T}.
6615 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
6616 the corresponding COBOL type.
6622 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
6623 COBOL type corresponding to the Ada parameter type; for scalars, a local
6624 copy is used if necessary to ensure by-copy semantics.
6628 @cindex Fortran, interfacing with
6629 @unnumberedsec B.5(22-26): Interfacing with Fortran
6632 An Ada implementation should support the following interface
6633 correspondences between Ada and Fortran:
6639 An Ada procedure corresponds to a Fortran subroutine.
6645 An Ada function corresponds to a Fortran function.
6651 An Ada parameter of an elementary, array, or record type @var{T} is
6652 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
6653 the Fortran type corresponding to the Ada type @var{T}, and where the
6654 INTENT attribute of the corresponding dummy argument matches the Ada
6655 formal parameter mode; the Fortran implementation's parameter passing
6656 conventions are used. For elementary types, a local copy is used if
6657 necessary to ensure by-copy semantics.
6663 An Ada parameter of an access-to-subprogram type is passed as a
6664 reference to a Fortran procedure whose interface corresponds to the
6665 designated subprogram's specification.
6669 @cindex Machine operations
6670 @unnumberedsec C.1(3-5): Access to Machine Operations
6673 The machine code or intrinsic support should allow access to all
6674 operations normally available to assembly language programmers for the
6675 target environment, including privileged instructions, if any.
6681 The interfacing pragmas (see Annex B) should support interface to
6682 assembler; the default assembler should be associated with the
6683 convention identifier @code{Assembler}.
6689 If an entity is exported to assembly language, then the implementation
6690 should allocate it at an addressable location, and should ensure that it
6691 is retained by the linking process, even if not otherwise referenced
6692 from the Ada code. The implementation should assume that any call to a
6693 machine code or assembler subprogram is allowed to read or update every
6694 object that is specified as exported.
6698 @unnumberedsec C.1(10-16): Access to Machine Operations
6701 The implementation should ensure that little or no overhead is
6702 associated with calling intrinsic and machine-code subprograms.
6704 Followed for both intrinsics and machine-code subprograms.
6708 It is recommended that intrinsic subprograms be provided for convenient
6709 access to any machine operations that provide special capabilities or
6710 efficiency and that are not otherwise available through the language
6713 Followed. A full set of machine operation intrinsic subprograms is provided.
6717 Atomic read-modify-write operations---e.g.@:, test and set, compare and
6718 swap, decrement and test, enqueue/dequeue.
6720 Followed on any target supporting such operations.
6724 Standard numeric functions---e.g.@:, sin, log.
6726 Followed on any target supporting such operations.
6730 String manipulation operations---e.g.@:, translate and test.
6732 Followed on any target supporting such operations.
6736 Vector operations---e.g.@:, compare vector against thresholds.
6738 Followed on any target supporting such operations.
6742 Direct operations on I/O ports.
6744 Followed on any target supporting such operations.
6746 @cindex Interrupt support
6747 @unnumberedsec C.3(28): Interrupt Support
6750 If the @code{Ceiling_Locking} policy is not in effect, the
6751 implementation should provide means for the application to specify which
6752 interrupts are to be blocked during protected actions, if the underlying
6753 system allows for a finer-grain control of interrupt blocking.
6755 Followed. The underlying system does not allow for finer-grain control
6756 of interrupt blocking.
6758 @cindex Protected procedure handlers
6759 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
6762 Whenever possible, the implementation should allow interrupt handlers to
6763 be called directly by the hardware.
6767 This is never possible under IRIX, so this is followed by default.
6769 Followed on any target where the underlying operating system permits
6774 Whenever practical, violations of any
6775 implementation-defined restrictions should be detected before run time.
6777 Followed. Compile time warnings are given when possible.
6779 @cindex Package @code{Interrupts}
6781 @unnumberedsec C.3.2(25): Package @code{Interrupts}
6785 If implementation-defined forms of interrupt handler procedures are
6786 supported, such as protected procedures with parameters, then for each
6787 such form of a handler, a type analogous to @code{Parameterless_Handler}
6788 should be specified in a child package of @code{Interrupts}, with the
6789 same operations as in the predefined package Interrupts.
6793 @cindex Pre-elaboration requirements
6794 @unnumberedsec C.4(14): Pre-elaboration Requirements
6797 It is recommended that pre-elaborated packages be implemented in such a
6798 way that there should be little or no code executed at run time for the
6799 elaboration of entities not already covered by the Implementation
6802 Followed. Executable code is generated in some cases, e.g.@: loops
6803 to initialize large arrays.
6805 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
6809 If the pragma applies to an entity, then the implementation should
6810 reduce the amount of storage used for storing names associated with that
6815 @cindex Package @code{Task_Attributes}
6816 @findex Task_Attributes
6817 @unnumberedsec C.7.2(30): The Package Task_Attributes
6820 Some implementations are targeted to domains in which memory use at run
6821 time must be completely deterministic. For such implementations, it is
6822 recommended that the storage for task attributes will be pre-allocated
6823 statically and not from the heap. This can be accomplished by either
6824 placing restrictions on the number and the size of the task's
6825 attributes, or by using the pre-allocated storage for the first @var{N}
6826 attribute objects, and the heap for the others. In the latter case,
6827 @var{N} should be documented.
6829 Not followed. This implementation is not targeted to such a domain.
6831 @cindex Locking Policies
6832 @unnumberedsec D.3(17): Locking Policies
6836 The implementation should use names that end with @samp{_Locking} for
6837 locking policies defined by the implementation.
6839 Followed. A single implementation-defined locking policy is defined,
6840 whose name (@code{Inheritance_Locking}) follows this suggestion.
6842 @cindex Entry queuing policies
6843 @unnumberedsec D.4(16): Entry Queuing Policies
6846 Names that end with @samp{_Queuing} should be used
6847 for all implementation-defined queuing policies.
6849 Followed. No such implementation-defined queuing policies exist.
6851 @cindex Preemptive abort
6852 @unnumberedsec D.6(9-10): Preemptive Abort
6855 Even though the @code{abort_statement} is included in the list of
6856 potentially blocking operations (see 9.5.1), it is recommended that this
6857 statement be implemented in a way that never requires the task executing
6858 the @code{abort_statement} to block.
6864 On a multi-processor, the delay associated with aborting a task on
6865 another processor should be bounded; the implementation should use
6866 periodic polling, if necessary, to achieve this.
6870 @cindex Tasking restrictions
6871 @unnumberedsec D.7(21): Tasking Restrictions
6874 When feasible, the implementation should take advantage of the specified
6875 restrictions to produce a more efficient implementation.
6877 GNAT currently takes advantage of these restrictions by providing an optimized
6878 run time when the Ravenscar profile and the GNAT restricted run time set
6879 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
6880 pragma @code{Profile (Restricted)} for more details.
6882 @cindex Time, monotonic
6883 @unnumberedsec D.8(47-49): Monotonic Time
6886 When appropriate, implementations should provide configuration
6887 mechanisms to change the value of @code{Tick}.
6889 Such configuration mechanisms are not appropriate to this implementation
6890 and are thus not supported.
6894 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6895 be implemented as transformations of the same time base.
6901 It is recommended that the @dfn{best} time base which exists in
6902 the underlying system be available to the application through
6903 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
6907 @cindex Partition communication subsystem
6909 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6912 Whenever possible, the PCS on the called partition should allow for
6913 multiple tasks to call the RPC-receiver with different messages and
6914 should allow them to block until the corresponding subprogram body
6917 Followed by GLADE, a separately supplied PCS that can be used with
6922 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6923 should raise @code{Storage_Error} if it runs out of space trying to
6924 write the @code{Item} into the stream.
6926 Followed by GLADE, a separately supplied PCS that can be used with
6929 @cindex COBOL support
6930 @unnumberedsec F(7): COBOL Support
6933 If COBOL (respectively, C) is widely supported in the target
6934 environment, implementations supporting the Information Systems Annex
6935 should provide the child package @code{Interfaces.COBOL} (respectively,
6936 @code{Interfaces.C}) specified in Annex B and should support a
6937 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6938 pragmas (see Annex B), thus allowing Ada programs to interface with
6939 programs written in that language.
6943 @cindex Decimal radix support
6944 @unnumberedsec F.1(2): Decimal Radix Support
6947 Packed decimal should be used as the internal representation for objects
6948 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6950 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
6954 @unnumberedsec G: Numerics
6957 If Fortran (respectively, C) is widely supported in the target
6958 environment, implementations supporting the Numerics Annex
6959 should provide the child package @code{Interfaces.Fortran} (respectively,
6960 @code{Interfaces.C}) specified in Annex B and should support a
6961 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6962 pragmas (see Annex B), thus allowing Ada programs to interface with
6963 programs written in that language.
6967 @cindex Complex types
6968 @unnumberedsec G.1.1(56-58): Complex Types
6971 Because the usual mathematical meaning of multiplication of a complex
6972 operand and a real operand is that of the scaling of both components of
6973 the former by the latter, an implementation should not perform this
6974 operation by first promoting the real operand to complex type and then
6975 performing a full complex multiplication. In systems that, in the
6976 future, support an Ada binding to IEC 559:1989, the latter technique
6977 will not generate the required result when one of the components of the
6978 complex operand is infinite. (Explicit multiplication of the infinite
6979 component by the zero component obtained during promotion yields a NaN
6980 that propagates into the final result.) Analogous advice applies in the
6981 case of multiplication of a complex operand and a pure-imaginary
6982 operand, and in the case of division of a complex operand by a real or
6983 pure-imaginary operand.
6989 Similarly, because the usual mathematical meaning of addition of a
6990 complex operand and a real operand is that the imaginary operand remains
6991 unchanged, an implementation should not perform this operation by first
6992 promoting the real operand to complex type and then performing a full
6993 complex addition. In implementations in which the @code{Signed_Zeros}
6994 attribute of the component type is @code{True} (and which therefore
6995 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6996 predefined arithmetic operations), the latter technique will not
6997 generate the required result when the imaginary component of the complex
6998 operand is a negatively signed zero. (Explicit addition of the negative
6999 zero to the zero obtained during promotion yields a positive zero.)
7000 Analogous advice applies in the case of addition of a complex operand
7001 and a pure-imaginary operand, and in the case of subtraction of a
7002 complex operand and a real or pure-imaginary operand.
7008 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7009 attempt to provide a rational treatment of the signs of zero results and
7010 result components. As one example, the result of the @code{Argument}
7011 function should have the sign of the imaginary component of the
7012 parameter @code{X} when the point represented by that parameter lies on
7013 the positive real axis; as another, the sign of the imaginary component
7014 of the @code{Compose_From_Polar} function should be the same as
7015 (respectively, the opposite of) that of the @code{Argument} parameter when that
7016 parameter has a value of zero and the @code{Modulus} parameter has a
7017 nonnegative (respectively, negative) value.
7021 @cindex Complex elementary functions
7022 @unnumberedsec G.1.2(49): Complex Elementary Functions
7025 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7026 @code{True} should attempt to provide a rational treatment of the signs
7027 of zero results and result components. For example, many of the complex
7028 elementary functions have components that are odd functions of one of
7029 the parameter components; in these cases, the result component should
7030 have the sign of the parameter component at the origin. Other complex
7031 elementary functions have zero components whose sign is opposite that of
7032 a parameter component at the origin, or is always positive or always
7037 @cindex Accuracy requirements
7038 @unnumberedsec G.2.4(19): Accuracy Requirements
7041 The versions of the forward trigonometric functions without a
7042 @code{Cycle} parameter should not be implemented by calling the
7043 corresponding version with a @code{Cycle} parameter of
7044 @code{2.0*Numerics.Pi}, since this will not provide the required
7045 accuracy in some portions of the domain. For the same reason, the
7046 version of @code{Log} without a @code{Base} parameter should not be
7047 implemented by calling the corresponding version with a @code{Base}
7048 parameter of @code{Numerics.e}.
7052 @cindex Complex arithmetic accuracy
7053 @cindex Accuracy, complex arithmetic
7054 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7058 The version of the @code{Compose_From_Polar} function without a
7059 @code{Cycle} parameter should not be implemented by calling the
7060 corresponding version with a @code{Cycle} parameter of
7061 @code{2.0*Numerics.Pi}, since this will not provide the required
7062 accuracy in some portions of the domain.
7066 @c -----------------------------------------
7067 @node Implementation Defined Characteristics
7068 @chapter Implementation Defined Characteristics
7071 In addition to the implementation dependent pragmas and attributes, and
7072 the implementation advice, there are a number of other Ada features
7073 that are potentially implementation dependent. These are mentioned
7074 throughout the Ada Reference Manual, and are summarized in annex M@.
7076 A requirement for conforming Ada compilers is that they provide
7077 documentation describing how the implementation deals with each of these
7078 issues. In this chapter, you will find each point in annex M listed
7079 followed by a description in italic font of how GNAT
7083 implementation on IRIX 5.3 operating system or greater
7085 handles the implementation dependence.
7087 You can use this chapter as a guide to minimizing implementation
7088 dependent features in your programs if portability to other compilers
7089 and other operating systems is an important consideration. The numbers
7090 in each section below correspond to the paragraph number in the Ada
7096 @strong{2}. Whether or not each recommendation given in Implementation
7097 Advice is followed. See 1.1.2(37).
7100 @xref{Implementation Advice}.
7105 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
7108 The complexity of programs that can be processed is limited only by the
7109 total amount of available virtual memory, and disk space for the
7110 generated object files.
7115 @strong{4}. Variations from the standard that are impractical to avoid
7116 given the implementation's execution environment. See 1.1.3(6).
7119 There are no variations from the standard.
7124 @strong{5}. Which @code{code_statement}s cause external
7125 interactions. See 1.1.3(10).
7128 Any @code{code_statement} can potentially cause external interactions.
7133 @strong{6}. The coded representation for the text of an Ada
7134 program. See 2.1(4).
7137 See separate section on source representation.
7142 @strong{7}. The control functions allowed in comments. See 2.1(14).
7145 See separate section on source representation.
7150 @strong{8}. The representation for an end of line. See 2.2(2).
7153 See separate section on source representation.
7158 @strong{9}. Maximum supported line length and lexical element
7159 length. See 2.2(15).
7162 The maximum line length is 255 characters and the maximum length of a
7163 lexical element is also 255 characters.
7168 @strong{10}. Implementation defined pragmas. See 2.8(14).
7172 @xref{Implementation Defined Pragmas}.
7177 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
7180 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7181 parameter, checks that the optimization flag is set, and aborts if it is
7187 @strong{12}. The sequence of characters of the value returned by
7188 @code{@var{S}'Image} when some of the graphic characters of
7189 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
7193 The sequence of characters is as defined by the wide character encoding
7194 method used for the source. See section on source representation for
7200 @strong{13}. The predefined integer types declared in
7201 @code{Standard}. See 3.5.4(25).
7205 @item Short_Short_Integer
7208 (Short) 16 bit signed
7212 64 bit signed (Alpha OpenVMS only)
7213 32 bit signed (all other targets)
7214 @item Long_Long_Integer
7221 @strong{14}. Any nonstandard integer types and the operators defined
7222 for them. See 3.5.4(26).
7225 There are no nonstandard integer types.
7230 @strong{15}. Any nonstandard real types and the operators defined for
7234 There are no nonstandard real types.
7239 @strong{16}. What combinations of requested decimal precision and range
7240 are supported for floating point types. See 3.5.7(7).
7243 The precision and range is as defined by the IEEE standard.
7248 @strong{17}. The predefined floating point types declared in
7249 @code{Standard}. See 3.5.7(16).
7256 (Short) 32 bit IEEE short
7259 @item Long_Long_Float
7260 64 bit IEEE long (80 bit IEEE long on x86 processors)
7266 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
7269 @code{Fine_Delta} is 2**(@minus{}63)
7274 @strong{19}. What combinations of small, range, and digits are
7275 supported for fixed point types. See 3.5.9(10).
7278 Any combinations are permitted that do not result in a small less than
7279 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7280 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7281 is 64 bits (true of all architectures except ia32), then the output from
7282 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
7283 is because floating-point conversions are used to convert fixed point.
7288 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
7289 within an unnamed @code{block_statement}. See 3.9(10).
7292 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7293 decimal integer are allocated.
7298 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
7301 @xref{Implementation Defined Attributes}.
7306 @strong{22}. Any implementation-defined time types. See 9.6(6).
7309 There are no implementation-defined time types.
7314 @strong{23}. The time base associated with relative delays.
7317 See 9.6(20). The time base used is that provided by the C library
7318 function @code{gettimeofday}.
7323 @strong{24}. The time base of the type @code{Calendar.Time}. See
7327 The time base used is that provided by the C library function
7328 @code{gettimeofday}.
7333 @strong{25}. The time zone used for package @code{Calendar}
7334 operations. See 9.6(24).
7337 The time zone used by package @code{Calendar} is the current system time zone
7338 setting for local time, as accessed by the C library function
7344 @strong{26}. Any limit on @code{delay_until_statements} of
7345 @code{select_statements}. See 9.6(29).
7348 There are no such limits.
7353 @strong{27}. Whether or not two non-overlapping parts of a composite
7354 object are independently addressable, in the case where packing, record
7355 layout, or @code{Component_Size} is specified for the object. See
7359 Separate components are independently addressable if they do not share
7360 overlapping storage units.
7365 @strong{28}. The representation for a compilation. See 10.1(2).
7368 A compilation is represented by a sequence of files presented to the
7369 compiler in a single invocation of the @command{gcc} command.
7374 @strong{29}. Any restrictions on compilations that contain multiple
7375 compilation_units. See 10.1(4).
7378 No single file can contain more than one compilation unit, but any
7379 sequence of files can be presented to the compiler as a single
7385 @strong{30}. The mechanisms for creating an environment and for adding
7386 and replacing compilation units. See 10.1.4(3).
7389 See separate section on compilation model.
7394 @strong{31}. The manner of explicitly assigning library units to a
7395 partition. See 10.2(2).
7398 If a unit contains an Ada main program, then the Ada units for the partition
7399 are determined by recursive application of the rules in the Ada Reference
7400 Manual section 10.2(2-6). In other words, the Ada units will be those that
7401 are needed by the main program, and then this definition of need is applied
7402 recursively to those units, and the partition contains the transitive
7403 closure determined by this relationship. In short, all the necessary units
7404 are included, with no need to explicitly specify the list. If additional
7405 units are required, e.g.@: by foreign language units, then all units must be
7406 mentioned in the context clause of one of the needed Ada units.
7408 If the partition contains no main program, or if the main program is in
7409 a language other than Ada, then GNAT
7410 provides the binder options @option{-z} and @option{-n} respectively, and in
7411 this case a list of units can be explicitly supplied to the binder for
7412 inclusion in the partition (all units needed by these units will also
7413 be included automatically). For full details on the use of these
7414 options, refer to the @cite{GNAT User's Guide} sections on Binding
7420 @strong{32}. The implementation-defined means, if any, of specifying
7421 which compilation units are needed by a given compilation unit. See
7425 The units needed by a given compilation unit are as defined in
7426 the Ada Reference Manual section 10.2(2-6). There are no
7427 implementation-defined pragmas or other implementation-defined
7428 means for specifying needed units.
7433 @strong{33}. The manner of designating the main subprogram of a
7434 partition. See 10.2(7).
7437 The main program is designated by providing the name of the
7438 corresponding @file{ALI} file as the input parameter to the binder.
7443 @strong{34}. The order of elaboration of @code{library_items}. See
7447 The first constraint on ordering is that it meets the requirements of
7448 Chapter 10 of the Ada Reference Manual. This still leaves some
7449 implementation dependent choices, which are resolved by first
7450 elaborating bodies as early as possible (i.e., in preference to specs
7451 where there is a choice), and second by evaluating the immediate with
7452 clauses of a unit to determine the probably best choice, and
7453 third by elaborating in alphabetical order of unit names
7454 where a choice still remains.
7459 @strong{35}. Parameter passing and function return for the main
7460 subprogram. See 10.2(21).
7463 The main program has no parameters. It may be a procedure, or a function
7464 returning an integer type. In the latter case, the returned integer
7465 value is the return code of the program (overriding any value that
7466 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
7471 @strong{36}. The mechanisms for building and running partitions. See
7475 GNAT itself supports programs with only a single partition. The GNATDIST
7476 tool provided with the GLADE package (which also includes an implementation
7477 of the PCS) provides a completely flexible method for building and running
7478 programs consisting of multiple partitions. See the separate GLADE manual
7484 @strong{37}. The details of program execution, including program
7485 termination. See 10.2(25).
7488 See separate section on compilation model.
7493 @strong{38}. The semantics of any non-active partitions supported by the
7494 implementation. See 10.2(28).
7497 Passive partitions are supported on targets where shared memory is
7498 provided by the operating system. See the GLADE reference manual for
7504 @strong{39}. The information returned by @code{Exception_Message}. See
7508 Exception message returns the null string unless a specific message has
7509 been passed by the program.
7514 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
7515 declared within an unnamed @code{block_statement}. See 11.4.1(12).
7518 Blocks have implementation defined names of the form @code{B@var{nnn}}
7519 where @var{nnn} is an integer.
7524 @strong{41}. The information returned by
7525 @code{Exception_Information}. See 11.4.1(13).
7528 @code{Exception_Information} returns a string in the following format:
7531 @emph{Exception_Name:} nnnnn
7532 @emph{Message:} mmmmm
7534 @emph{Call stack traceback locations:}
7535 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
7543 @code{nnnn} is the fully qualified name of the exception in all upper
7544 case letters. This line is always present.
7547 @code{mmmm} is the message (this line present only if message is non-null)
7550 @code{ppp} is the Process Id value as a decimal integer (this line is
7551 present only if the Process Id is nonzero). Currently we are
7552 not making use of this field.
7555 The Call stack traceback locations line and the following values
7556 are present only if at least one traceback location was recorded.
7557 The values are given in C style format, with lower case letters
7558 for a-f, and only as many digits present as are necessary.
7562 The line terminator sequence at the end of each line, including
7563 the last line is a single @code{LF} character (@code{16#0A#}).
7568 @strong{42}. Implementation-defined check names. See 11.5(27).
7571 The implementation defined check name Alignment_Check controls checking of
7572 address clause values for proper alignment (that is, the address supplied
7573 must be consistent with the alignment of the type).
7575 In addition, a user program can add implementation-defined check names
7576 by means of the pragma Check_Name.
7581 @strong{43}. The interpretation of each aspect of representation. See
7585 See separate section on data representations.
7590 @strong{44}. Any restrictions placed upon representation items. See
7594 See separate section on data representations.
7599 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
7603 Size for an indefinite subtype is the maximum possible size, except that
7604 for the case of a subprogram parameter, the size of the parameter object
7610 @strong{46}. The default external representation for a type tag. See
7614 The default external representation for a type tag is the fully expanded
7615 name of the type in upper case letters.
7620 @strong{47}. What determines whether a compilation unit is the same in
7621 two different partitions. See 13.3(76).
7624 A compilation unit is the same in two different partitions if and only
7625 if it derives from the same source file.
7630 @strong{48}. Implementation-defined components. See 13.5.1(15).
7633 The only implementation defined component is the tag for a tagged type,
7634 which contains a pointer to the dispatching table.
7639 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
7640 ordering. See 13.5.3(5).
7643 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
7644 implementation, so no non-default bit ordering is supported. The default
7645 bit ordering corresponds to the natural endianness of the target architecture.
7650 @strong{50}. The contents of the visible part of package @code{System}
7651 and its language-defined children. See 13.7(2).
7654 See the definition of these packages in files @file{system.ads} and
7655 @file{s-stoele.ads}.
7660 @strong{51}. The contents of the visible part of package
7661 @code{System.Machine_Code}, and the meaning of
7662 @code{code_statements}. See 13.8(7).
7665 See the definition and documentation in file @file{s-maccod.ads}.
7670 @strong{52}. The effect of unchecked conversion. See 13.9(11).
7673 Unchecked conversion between types of the same size
7674 results in an uninterpreted transmission of the bits from one type
7675 to the other. If the types are of unequal sizes, then in the case of
7676 discrete types, a shorter source is first zero or sign extended as
7677 necessary, and a shorter target is simply truncated on the left.
7678 For all non-discrete types, the source is first copied if necessary
7679 to ensure that the alignment requirements of the target are met, then
7680 a pointer is constructed to the source value, and the result is obtained
7681 by dereferencing this pointer after converting it to be a pointer to the
7682 target type. Unchecked conversions where the target subtype is an
7683 unconstrained array are not permitted. If the target alignment is
7684 greater than the source alignment, then a copy of the result is
7685 made with appropriate alignment
7690 @strong{53}. The manner of choosing a storage pool for an access type
7691 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
7694 There are 3 different standard pools used by the compiler when
7695 @code{Storage_Pool} is not specified depending whether the type is local
7696 to a subprogram or defined at the library level and whether
7697 @code{Storage_Size}is specified or not. See documentation in the runtime
7698 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
7699 @code{System.Pool_Local} in files @file{s-poosiz.ads},
7700 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
7706 @strong{54}. Whether or not the implementation provides user-accessible
7707 names for the standard pool type(s). See 13.11(17).
7711 See documentation in the sources of the run time mentioned in paragraph
7712 @strong{53} . All these pools are accessible by means of @code{with}'ing
7718 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
7721 @code{Storage_Size} is measured in storage units, and refers to the
7722 total space available for an access type collection, or to the primary
7723 stack space for a task.
7728 @strong{56}. Implementation-defined aspects of storage pools. See
7732 See documentation in the sources of the run time mentioned in paragraph
7733 @strong{53} for details on GNAT-defined aspects of storage pools.
7738 @strong{57}. The set of restrictions allowed in a pragma
7739 @code{Restrictions}. See 13.12(7).
7742 All RM defined Restriction identifiers are implemented. The following
7743 additional restriction identifiers are provided. There are two separate
7744 lists of implementation dependent restriction identifiers. The first
7745 set requires consistency throughout a partition (in other words, if the
7746 restriction identifier is used for any compilation unit in the partition,
7747 then all compilation units in the partition must obey the restriction.
7751 @item Simple_Barriers
7752 @findex Simple_Barriers
7753 This restriction ensures at compile time that barriers in entry declarations
7754 for protected types are restricted to either static boolean expressions or
7755 references to simple boolean variables defined in the private part of the
7756 protected type. No other form of entry barriers is permitted. This is one
7757 of the restrictions of the Ravenscar profile for limited tasking (see also
7758 pragma @code{Profile (Ravenscar)}).
7760 @item Max_Entry_Queue_Length => Expr
7761 @findex Max_Entry_Queue_Length
7762 This restriction is a declaration that any protected entry compiled in
7763 the scope of the restriction has at most the specified number of
7764 tasks waiting on the entry
7765 at any one time, and so no queue is required. This restriction is not
7766 checked at compile time. A program execution is erroneous if an attempt
7767 is made to queue more than the specified number of tasks on such an entry.
7771 This restriction ensures at compile time that there is no implicit or
7772 explicit dependence on the package @code{Ada.Calendar}.
7774 @item No_Direct_Boolean_Operators
7775 @findex No_Direct_Boolean_Operators
7776 This restriction ensures that no logical (and/or/xor) or comparison
7777 operators are used on operands of type Boolean (or any type derived
7778 from Boolean). This is intended for use in safety critical programs
7779 where the certification protocol requires the use of short-circuit
7780 (and then, or else) forms for all composite boolean operations.
7782 @item No_Dispatching_Calls
7783 @findex No_Dispatching_Calls
7784 This restriction ensures at compile time that the code generated by the
7785 compiler involves no dispatching calls. The use of this restriction allows the
7786 safe use of record extensions, classwide membership tests and other classwide
7787 features not involving implicit dispatching. This restriction ensures that
7788 the code contains no indirect calls through a dispatching mechanism. Note that
7789 this includes internally-generated calls created by the compiler, for example
7790 in the implementation of class-wide objects assignments. The
7791 membership test is allowed in the presence of this restriction, because its
7792 implementation requires no dispatching.
7793 This restriction is comparable to the official Ada restriction
7794 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7795 all classwide constructs that do not imply dispatching.
7796 The following example indicates constructs that violate this restriction.
7800 type T is tagged record
7803 procedure P (X : T);
7805 type DT is new T with record
7806 More_Data : Natural;
7808 procedure Q (X : DT);
7812 procedure Example is
7813 procedure Test (O : T'Class) is
7814 N : Natural := O'Size;-- Error: Dispatching call
7815 C : T'Class := O; -- Error: implicit Dispatching Call
7817 if O in DT'Class then -- OK : Membership test
7818 Q (DT (O)); -- OK : Type conversion plus direct call
7820 P (O); -- Error: Dispatching call
7826 P (Obj); -- OK : Direct call
7827 P (T (Obj)); -- OK : Type conversion plus direct call
7828 P (T'Class (Obj)); -- Error: Dispatching call
7830 Test (Obj); -- OK : Type conversion
7832 if Obj in T'Class then -- OK : Membership test
7838 @item No_Dynamic_Attachment
7839 @findex No_Dynamic_Attachment
7840 This restriction ensures that there is no call to any of the operations
7841 defined in package Ada.Interrupts.
7843 @item No_Enumeration_Maps
7844 @findex No_Enumeration_Maps
7845 This restriction ensures at compile time that no operations requiring
7846 enumeration maps are used (that is Image and Value attributes applied
7847 to enumeration types).
7849 @item No_Entry_Calls_In_Elaboration_Code
7850 @findex No_Entry_Calls_In_Elaboration_Code
7851 This restriction ensures at compile time that no task or protected entry
7852 calls are made during elaboration code. As a result of the use of this
7853 restriction, the compiler can assume that no code past an accept statement
7854 in a task can be executed at elaboration time.
7856 @item No_Exception_Handlers
7857 @findex No_Exception_Handlers
7858 This restriction ensures at compile time that there are no explicit
7859 exception handlers. It also indicates that no exception propagation will
7860 be provided. In this mode, exceptions may be raised but will result in
7861 an immediate call to the last chance handler, a routine that the user
7862 must define with the following profile:
7864 procedure Last_Chance_Handler
7865 (Source_Location : System.Address; Line : Integer);
7866 pragma Export (C, Last_Chance_Handler,
7867 "__gnat_last_chance_handler");
7869 The parameter is a C null-terminated string representing a message to be
7870 associated with the exception (typically the source location of the raise
7871 statement generated by the compiler). The Line parameter when nonzero
7872 represents the line number in the source program where the raise occurs.
7874 @item No_Exception_Propagation
7875 @findex No_Exception_Propagation
7876 This restriction guarantees that exceptions are never propagated to an outer
7877 subprogram scope). The only case in which an exception may be raised is when
7878 the handler is statically in the same subprogram, so that the effect of a raise
7879 is essentially like a goto statement. Any other raise statement (implicit or
7880 explicit) will be considered unhandled. Exception handlers are allowed, but may
7881 not contain an exception occurrence identifier (exception choice). In addition
7882 use of the package GNAT.Current_Exception is not permitted, and reraise
7883 statements (raise with no operand) are not permitted.
7885 @item No_Exception_Registration
7886 @findex No_Exception_Registration
7887 This restriction ensures at compile time that no stream operations for
7888 types Exception_Id or Exception_Occurrence are used. This also makes it
7889 impossible to pass exceptions to or from a partition with this restriction
7890 in a distributed environment. If this exception is active, then the generated
7891 code is simplified by omitting the otherwise-required global registration
7892 of exceptions when they are declared.
7894 @item No_Implicit_Conditionals
7895 @findex No_Implicit_Conditionals
7896 This restriction ensures that the generated code does not contain any
7897 implicit conditionals, either by modifying the generated code where possible,
7898 or by rejecting any construct that would otherwise generate an implicit
7899 conditional. Note that this check does not include run time constraint
7900 checks, which on some targets may generate implicit conditionals as
7901 well. To control the latter, constraint checks can be suppressed in the
7902 normal manner. Constructs generating implicit conditionals include comparisons
7903 of composite objects and the Max/Min attributes.
7905 @item No_Implicit_Dynamic_Code
7906 @findex No_Implicit_Dynamic_Code
7907 This restriction prevents the compiler from building ``trampolines''.
7908 This is a structure that is built on the stack and contains dynamic
7909 code to be executed at run time. On some targets, a trampoline is
7910 built for the following features: @code{Access},
7911 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
7912 nested task bodies; primitive operations of nested tagged types.
7913 Trampolines do not work on machines that prevent execution of stack
7914 data. For example, on windows systems, enabling DEP (data execution
7915 protection) will cause trampolines to raise an exception.
7917 @item No_Implicit_Loops
7918 @findex No_Implicit_Loops
7919 This restriction ensures that the generated code does not contain any
7920 implicit @code{for} loops, either by modifying
7921 the generated code where possible,
7922 or by rejecting any construct that would otherwise generate an implicit
7923 @code{for} loop. If this restriction is active, it is possible to build
7924 large array aggregates with all static components without generating an
7925 intermediate temporary, and without generating a loop to initialize individual
7926 components. Otherwise, a loop is created for arrays larger than about 5000
7929 @item No_Initialize_Scalars
7930 @findex No_Initialize_Scalars
7931 This restriction ensures that no unit in the partition is compiled with
7932 pragma Initialize_Scalars. This allows the generation of more efficient
7933 code, and in particular eliminates dummy null initialization routines that
7934 are otherwise generated for some record and array types.
7936 @item No_Local_Protected_Objects
7937 @findex No_Local_Protected_Objects
7938 This restriction ensures at compile time that protected objects are
7939 only declared at the library level.
7941 @item No_Protected_Type_Allocators
7942 @findex No_Protected_Type_Allocators
7943 This restriction ensures at compile time that there are no allocator
7944 expressions that attempt to allocate protected objects.
7946 @item No_Secondary_Stack
7947 @findex No_Secondary_Stack
7948 This restriction ensures at compile time that the generated code does not
7949 contain any reference to the secondary stack. The secondary stack is used
7950 to implement functions returning unconstrained objects (arrays or records)
7953 @item No_Select_Statements
7954 @findex No_Select_Statements
7955 This restriction ensures at compile time no select statements of any kind
7956 are permitted, that is the keyword @code{select} may not appear.
7957 This is one of the restrictions of the Ravenscar
7958 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7960 @item No_Standard_Storage_Pools
7961 @findex No_Standard_Storage_Pools
7962 This restriction ensures at compile time that no access types
7963 use the standard default storage pool. Any access type declared must
7964 have an explicit Storage_Pool attribute defined specifying a
7965 user-defined storage pool.
7969 This restriction ensures at compile/bind time that there are no
7970 stream objects created (and therefore no actual stream operations).
7971 This restriction does not forbid dependences on the package
7972 @code{Ada.Streams}. So it is permissible to with
7973 @code{Ada.Streams} (or another package that does so itself)
7974 as long as no actual stream objects are created.
7976 @item No_Task_Attributes_Package
7977 @findex No_Task_Attributes_Package
7978 This restriction ensures at compile time that there are no implicit or
7979 explicit dependencies on the package @code{Ada.Task_Attributes}.
7981 @item No_Task_Termination
7982 @findex No_Task_Termination
7983 This restriction ensures at compile time that no terminate alternatives
7984 appear in any task body.
7988 This restriction prevents the declaration of tasks or task types throughout
7989 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
7990 except that violations are caught at compile time and cause an error message
7991 to be output either by the compiler or binder.
7993 @item Static_Priorities
7994 @findex Static_Priorities
7995 This restriction ensures at compile time that all priority expressions
7996 are static, and that there are no dependencies on the package
7997 @code{Ada.Dynamic_Priorities}.
7999 @item Static_Storage_Size
8000 @findex Static_Storage_Size
8001 This restriction ensures at compile time that any expression appearing
8002 in a Storage_Size pragma or attribute definition clause is static.
8007 The second set of implementation dependent restriction identifiers
8008 does not require partition-wide consistency.
8009 The restriction may be enforced for a single
8010 compilation unit without any effect on any of the
8011 other compilation units in the partition.
8015 @item No_Elaboration_Code
8016 @findex No_Elaboration_Code
8017 This restriction ensures at compile time that no elaboration code is
8018 generated. Note that this is not the same condition as is enforced
8019 by pragma @code{Preelaborate}. There are cases in which pragma
8020 @code{Preelaborate} still permits code to be generated (e.g.@: code
8021 to initialize a large array to all zeroes), and there are cases of units
8022 which do not meet the requirements for pragma @code{Preelaborate},
8023 but for which no elaboration code is generated. Generally, it is
8024 the case that preelaborable units will meet the restrictions, with
8025 the exception of large aggregates initialized with an others_clause,
8026 and exception declarations (which generate calls to a run-time
8027 registry procedure). This restriction is enforced on
8028 a unit by unit basis, it need not be obeyed consistently
8029 throughout a partition.
8031 In the case of aggregates with others, if the aggregate has a dynamic
8032 size, there is no way to eliminate the elaboration code (such dynamic
8033 bounds would be incompatible with @code{Preelaborate} in any case). If
8034 the bounds are static, then use of this restriction actually modifies
8035 the code choice of the compiler to avoid generating a loop, and instead
8036 generate the aggregate statically if possible, no matter how many times
8037 the data for the others clause must be repeatedly generated.
8039 It is not possible to precisely document
8040 the constructs which are compatible with this restriction, since,
8041 unlike most other restrictions, this is not a restriction on the
8042 source code, but a restriction on the generated object code. For
8043 example, if the source contains a declaration:
8046 Val : constant Integer := X;
8050 where X is not a static constant, it may be possible, depending
8051 on complex optimization circuitry, for the compiler to figure
8052 out the value of X at compile time, in which case this initialization
8053 can be done by the loader, and requires no initialization code. It
8054 is not possible to document the precise conditions under which the
8055 optimizer can figure this out.
8057 Note that this the implementation of this restriction requires full
8058 code generation. If it is used in conjunction with "semantics only"
8059 checking, then some cases of violations may be missed.
8061 @item No_Entry_Queue
8062 @findex No_Entry_Queue
8063 This restriction is a declaration that any protected entry compiled in
8064 the scope of the restriction has at most one task waiting on the entry
8065 at any one time, and so no queue is required. This restriction is not
8066 checked at compile time. A program execution is erroneous if an attempt
8067 is made to queue a second task on such an entry.
8069 @item No_Implementation_Attributes
8070 @findex No_Implementation_Attributes
8071 This restriction checks at compile time that no GNAT-defined attributes
8072 are present. With this restriction, the only attributes that can be used
8073 are those defined in the Ada Reference Manual.
8075 @item No_Implementation_Pragmas
8076 @findex No_Implementation_Pragmas
8077 This restriction checks at compile time that no GNAT-defined pragmas
8078 are present. With this restriction, the only pragmas that can be used
8079 are those defined in the Ada Reference Manual.
8081 @item No_Implementation_Restrictions
8082 @findex No_Implementation_Restrictions
8083 This restriction checks at compile time that no GNAT-defined restriction
8084 identifiers (other than @code{No_Implementation_Restrictions} itself)
8085 are present. With this restriction, the only other restriction identifiers
8086 that can be used are those defined in the Ada Reference Manual.
8088 @item No_Wide_Characters
8089 @findex No_Wide_Characters
8090 This restriction ensures at compile time that no uses of the types
8091 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8093 appear, and that no wide or wide wide string or character literals
8094 appear in the program (that is literals representing characters not in
8095 type @code{Character}.
8102 @strong{58}. The consequences of violating limitations on
8103 @code{Restrictions} pragmas. See 13.12(9).
8106 Restrictions that can be checked at compile time result in illegalities
8107 if violated. Currently there are no other consequences of violating
8113 @strong{59}. The representation used by the @code{Read} and
8114 @code{Write} attributes of elementary types in terms of stream
8115 elements. See 13.13.2(9).
8118 The representation is the in-memory representation of the base type of
8119 the type, using the number of bits corresponding to the
8120 @code{@var{type}'Size} value, and the natural ordering of the machine.
8125 @strong{60}. The names and characteristics of the numeric subtypes
8126 declared in the visible part of package @code{Standard}. See A.1(3).
8129 See items describing the integer and floating-point types supported.
8134 @strong{61}. The accuracy actually achieved by the elementary
8135 functions. See A.5.1(1).
8138 The elementary functions correspond to the functions available in the C
8139 library. Only fast math mode is implemented.
8144 @strong{62}. The sign of a zero result from some of the operators or
8145 functions in @code{Numerics.Generic_Elementary_Functions}, when
8146 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
8149 The sign of zeroes follows the requirements of the IEEE 754 standard on
8155 @strong{63}. The value of
8156 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
8159 Maximum image width is 649, see library file @file{a-numran.ads}.
8164 @strong{64}. The value of
8165 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
8168 Maximum image width is 80, see library file @file{a-nudira.ads}.
8173 @strong{65}. The algorithms for random number generation. See
8177 The algorithm is documented in the source files @file{a-numran.ads} and
8178 @file{a-numran.adb}.
8183 @strong{66}. The string representation of a random number generator's
8184 state. See A.5.2(38).
8187 See the documentation contained in the file @file{a-numran.adb}.
8192 @strong{67}. The minimum time interval between calls to the
8193 time-dependent Reset procedure that are guaranteed to initiate different
8194 random number sequences. See A.5.2(45).
8197 The minimum period between reset calls to guarantee distinct series of
8198 random numbers is one microsecond.
8203 @strong{68}. The values of the @code{Model_Mantissa},
8204 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8205 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8206 Annex is not supported. See A.5.3(72).
8209 See the source file @file{ttypef.ads} for the values of all numeric
8215 @strong{69}. Any implementation-defined characteristics of the
8216 input-output packages. See A.7(14).
8219 There are no special implementation defined characteristics for these
8225 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
8229 All type representations are contiguous, and the @code{Buffer_Size} is
8230 the value of @code{@var{type}'Size} rounded up to the next storage unit
8236 @strong{71}. External files for standard input, standard output, and
8237 standard error See A.10(5).
8240 These files are mapped onto the files provided by the C streams
8241 libraries. See source file @file{i-cstrea.ads} for further details.
8246 @strong{72}. The accuracy of the value produced by @code{Put}. See
8250 If more digits are requested in the output than are represented by the
8251 precision of the value, zeroes are output in the corresponding least
8252 significant digit positions.
8257 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
8258 @code{Command_Name}. See A.15(1).
8261 These are mapped onto the @code{argv} and @code{argc} parameters of the
8262 main program in the natural manner.
8267 @strong{74}. Implementation-defined convention names. See B.1(11).
8270 The following convention names are supported
8278 Synonym for Assembler
8280 Synonym for Assembler
8283 @item C_Pass_By_Copy
8284 Allowed only for record types, like C, but also notes that record
8285 is to be passed by copy rather than reference.
8288 @item C_Plus_Plus (or CPP)
8291 Treated the same as C
8293 Treated the same as C
8297 For support of pragma @code{Import} with convention Intrinsic, see
8298 separate section on Intrinsic Subprograms.
8300 Stdcall (used for Windows implementations only). This convention correspond
8301 to the WINAPI (previously called Pascal convention) C/C++ convention under
8302 Windows. A function with this convention cleans the stack before exit.
8308 Stubbed is a special convention used to indicate that the body of the
8309 subprogram will be entirely ignored. Any call to the subprogram
8310 is converted into a raise of the @code{Program_Error} exception. If a
8311 pragma @code{Import} specifies convention @code{stubbed} then no body need
8312 be present at all. This convention is useful during development for the
8313 inclusion of subprograms whose body has not yet been written.
8317 In addition, all otherwise unrecognized convention names are also
8318 treated as being synonymous with convention C@. In all implementations
8319 except for VMS, use of such other names results in a warning. In VMS
8320 implementations, these names are accepted silently.
8325 @strong{75}. The meaning of link names. See B.1(36).
8328 Link names are the actual names used by the linker.
8333 @strong{76}. The manner of choosing link names when neither the link
8334 name nor the address of an imported or exported entity is specified. See
8338 The default linker name is that which would be assigned by the relevant
8339 external language, interpreting the Ada name as being in all lower case
8345 @strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37).
8348 The string passed to @code{Linker_Options} is presented uninterpreted as
8349 an argument to the link command, unless it contains Ascii.NUL characters.
8350 NUL characters if they appear act as argument separators, so for example
8352 @smallexample @c ada
8353 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
8357 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8358 linker. The order of linker options is preserved for a given unit. The final
8359 list of options passed to the linker is in reverse order of the elaboration
8360 order. For example, linker options for a body always appear before the options
8361 from the corresponding package spec.
8366 @strong{78}. The contents of the visible part of package
8367 @code{Interfaces} and its language-defined descendants. See B.2(1).
8370 See files with prefix @file{i-} in the distributed library.
8375 @strong{79}. Implementation-defined children of package
8376 @code{Interfaces}. The contents of the visible part of package
8377 @code{Interfaces}. See B.2(11).
8380 See files with prefix @file{i-} in the distributed library.
8385 @strong{80}. The types @code{Floating}, @code{Long_Floating},
8386 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
8387 @code{COBOL_Character}; and the initialization of the variables
8388 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
8389 @code{Interfaces.COBOL}. See B.4(50).
8396 (Floating) Long_Float
8401 @item Decimal_Element
8403 @item COBOL_Character
8408 For initialization, see the file @file{i-cobol.ads} in the distributed library.
8413 @strong{81}. Support for access to machine instructions. See C.1(1).
8416 See documentation in file @file{s-maccod.ads} in the distributed library.
8421 @strong{82}. Implementation-defined aspects of access to machine
8422 operations. See C.1(9).
8425 See documentation in file @file{s-maccod.ads} in the distributed library.
8430 @strong{83}. Implementation-defined aspects of interrupts. See C.3(2).
8433 Interrupts are mapped to signals or conditions as appropriate. See
8435 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
8436 on the interrupts supported on a particular target.
8441 @strong{84}. Implementation-defined aspects of pre-elaboration. See
8445 GNAT does not permit a partition to be restarted without reloading,
8446 except under control of the debugger.
8451 @strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7).
8454 Pragma @code{Discard_Names} causes names of enumeration literals to
8455 be suppressed. In the presence of this pragma, the Image attribute
8456 provides the image of the Pos of the literal, and Value accepts
8462 @strong{86}. The result of the @code{Task_Identification.Image}
8463 attribute. See C.7.1(7).
8466 The result of this attribute is a string that identifies
8467 the object or component that denotes a given task. If a variable @code{Var}
8468 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
8470 is the hexadecimal representation of the virtual address of the corresponding
8471 task control block. If the variable is an array of tasks, the image of each
8472 task will have the form of an indexed component indicating the position of a
8473 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
8474 component of a record, the image of the task will have the form of a selected
8475 component. These rules are fully recursive, so that the image of a task that
8476 is a subcomponent of a composite object corresponds to the expression that
8477 designates this task.
8479 If a task is created by an allocator, its image depends on the context. If the
8480 allocator is part of an object declaration, the rules described above are used
8481 to construct its image, and this image is not affected by subsequent
8482 assignments. If the allocator appears within an expression, the image
8483 includes only the name of the task type.
8485 If the configuration pragma Discard_Names is present, or if the restriction
8486 No_Implicit_Heap_Allocation is in effect, the image reduces to
8487 the numeric suffix, that is to say the hexadecimal representation of the
8488 virtual address of the control block of the task.
8492 @strong{87}. The value of @code{Current_Task} when in a protected entry
8493 or interrupt handler. See C.7.1(17).
8496 Protected entries or interrupt handlers can be executed by any
8497 convenient thread, so the value of @code{Current_Task} is undefined.
8502 @strong{88}. The effect of calling @code{Current_Task} from an entry
8503 body or interrupt handler. See C.7.1(19).
8506 The effect of calling @code{Current_Task} from an entry body or
8507 interrupt handler is to return the identification of the task currently
8513 @strong{89}. Implementation-defined aspects of
8514 @code{Task_Attributes}. See C.7.2(19).
8517 There are no implementation-defined aspects of @code{Task_Attributes}.
8522 @strong{90}. Values of all @code{Metrics}. See D(2).
8525 The metrics information for GNAT depends on the performance of the
8526 underlying operating system. The sources of the run-time for tasking
8527 implementation, together with the output from @option{-gnatG} can be
8528 used to determine the exact sequence of operating systems calls made
8529 to implement various tasking constructs. Together with appropriate
8530 information on the performance of the underlying operating system,
8531 on the exact target in use, this information can be used to determine
8532 the required metrics.
8537 @strong{91}. The declarations of @code{Any_Priority} and
8538 @code{Priority}. See D.1(11).
8541 See declarations in file @file{system.ads}.
8546 @strong{92}. Implementation-defined execution resources. See D.1(15).
8549 There are no implementation-defined execution resources.
8554 @strong{93}. Whether, on a multiprocessor, a task that is waiting for
8555 access to a protected object keeps its processor busy. See D.2.1(3).
8558 On a multi-processor, a task that is waiting for access to a protected
8559 object does not keep its processor busy.
8564 @strong{94}. The affect of implementation defined execution resources
8565 on task dispatching. See D.2.1(9).
8570 Tasks map to IRIX threads, and the dispatching policy is as defined by
8571 the IRIX implementation of threads.
8573 Tasks map to threads in the threads package used by GNAT@. Where possible
8574 and appropriate, these threads correspond to native threads of the
8575 underlying operating system.
8580 @strong{95}. Implementation-defined @code{policy_identifiers} allowed
8581 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
8584 There are no implementation-defined policy-identifiers allowed in this
8590 @strong{96}. Implementation-defined aspects of priority inversion. See
8594 Execution of a task cannot be preempted by the implementation processing
8595 of delay expirations for lower priority tasks.
8600 @strong{97}. Implementation defined task dispatching. See D.2.2(18).
8605 Tasks map to IRIX threads, and the dispatching policy is as defined by
8606 the IRIX implementation of threads.
8608 The policy is the same as that of the underlying threads implementation.
8613 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
8614 in a pragma @code{Locking_Policy}. See D.3(4).
8617 The only implementation defined policy permitted in GNAT is
8618 @code{Inheritance_Locking}. On targets that support this policy, locking
8619 is implemented by inheritance, i.e.@: the task owning the lock operates
8620 at a priority equal to the highest priority of any task currently
8621 requesting the lock.
8626 @strong{99}. Default ceiling priorities. See D.3(10).
8629 The ceiling priority of protected objects of the type
8630 @code{System.Interrupt_Priority'Last} as described in the Ada
8631 Reference Manual D.3(10),
8636 @strong{100}. The ceiling of any protected object used internally by
8637 the implementation. See D.3(16).
8640 The ceiling priority of internal protected objects is
8641 @code{System.Priority'Last}.
8646 @strong{101}. Implementation-defined queuing policies. See D.4(1).
8649 There are no implementation-defined queuing policies.
8654 @strong{102}. On a multiprocessor, any conditions that cause the
8655 completion of an aborted construct to be delayed later than what is
8656 specified for a single processor. See D.6(3).
8659 The semantics for abort on a multi-processor is the same as on a single
8660 processor, there are no further delays.
8665 @strong{103}. Any operations that implicitly require heap storage
8666 allocation. See D.7(8).
8669 The only operation that implicitly requires heap storage allocation is
8675 @strong{104}. Implementation-defined aspects of pragma
8676 @code{Restrictions}. See D.7(20).
8679 There are no such implementation-defined aspects.
8684 @strong{105}. Implementation-defined aspects of package
8685 @code{Real_Time}. See D.8(17).
8688 There are no implementation defined aspects of package @code{Real_Time}.
8693 @strong{106}. Implementation-defined aspects of
8694 @code{delay_statements}. See D.9(8).
8697 Any difference greater than one microsecond will cause the task to be
8698 delayed (see D.9(7)).
8703 @strong{107}. The upper bound on the duration of interrupt blocking
8704 caused by the implementation. See D.12(5).
8707 The upper bound is determined by the underlying operating system. In
8708 no cases is it more than 10 milliseconds.
8713 @strong{108}. The means for creating and executing distributed
8717 The GLADE package provides a utility GNATDIST for creating and executing
8718 distributed programs. See the GLADE reference manual for further details.
8723 @strong{109}. Any events that can result in a partition becoming
8724 inaccessible. See E.1(7).
8727 See the GLADE reference manual for full details on such events.
8732 @strong{110}. The scheduling policies, treatment of priorities, and
8733 management of shared resources between partitions in certain cases. See
8737 See the GLADE reference manual for full details on these aspects of
8738 multi-partition execution.
8743 @strong{111}. Events that cause the version of a compilation unit to
8747 Editing the source file of a compilation unit, or the source files of
8748 any units on which it is dependent in a significant way cause the version
8749 to change. No other actions cause the version number to change. All changes
8750 are significant except those which affect only layout, capitalization or
8756 @strong{112}. Whether the execution of the remote subprogram is
8757 immediately aborted as a result of cancellation. See E.4(13).
8760 See the GLADE reference manual for details on the effect of abort in
8761 a distributed application.
8766 @strong{113}. Implementation-defined aspects of the PCS@. See E.5(25).
8769 See the GLADE reference manual for a full description of all implementation
8770 defined aspects of the PCS@.
8775 @strong{114}. Implementation-defined interfaces in the PCS@. See
8779 See the GLADE reference manual for a full description of all
8780 implementation defined interfaces.
8785 @strong{115}. The values of named numbers in the package
8786 @code{Decimal}. See F.2(7).
8798 @item Max_Decimal_Digits
8805 @strong{116}. The value of @code{Max_Picture_Length} in the package
8806 @code{Text_IO.Editing}. See F.3.3(16).
8814 @strong{117}. The value of @code{Max_Picture_Length} in the package
8815 @code{Wide_Text_IO.Editing}. See F.3.4(5).
8823 @strong{118}. The accuracy actually achieved by the complex elementary
8824 functions and by other complex arithmetic operations. See G.1(1).
8827 Standard library functions are used for the complex arithmetic
8828 operations. Only fast math mode is currently supported.
8833 @strong{119}. The sign of a zero result (or a component thereof) from
8834 any operator or function in @code{Numerics.Generic_Complex_Types}, when
8835 @code{Real'Signed_Zeros} is True. See G.1.1(53).
8838 The signs of zero values are as recommended by the relevant
8839 implementation advice.
8844 @strong{120}. The sign of a zero result (or a component thereof) from
8845 any operator or function in
8846 @code{Numerics.Generic_Complex_Elementary_Functions}, when
8847 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
8850 The signs of zero values are as recommended by the relevant
8851 implementation advice.
8856 @strong{121}. Whether the strict mode or the relaxed mode is the
8857 default. See G.2(2).
8860 The strict mode is the default. There is no separate relaxed mode. GNAT
8861 provides a highly efficient implementation of strict mode.
8866 @strong{122}. The result interval in certain cases of fixed-to-float
8867 conversion. See G.2.1(10).
8870 For cases where the result interval is implementation dependent, the
8871 accuracy is that provided by performing all operations in 64-bit IEEE
8872 floating-point format.
8877 @strong{123}. The result of a floating point arithmetic operation in
8878 overflow situations, when the @code{Machine_Overflows} attribute of the
8879 result type is @code{False}. See G.2.1(13).
8882 Infinite and NaN values are produced as dictated by the IEEE
8883 floating-point standard.
8885 Note that on machines that are not fully compliant with the IEEE
8886 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
8887 must be used for achieving IEEE confirming behavior (although at the cost
8888 of a significant performance penalty), so infinite and NaN values are
8894 @strong{124}. The result interval for division (or exponentiation by a
8895 negative exponent), when the floating point hardware implements division
8896 as multiplication by a reciprocal. See G.2.1(16).
8899 Not relevant, division is IEEE exact.
8904 @strong{125}. The definition of close result set, which determines the
8905 accuracy of certain fixed point multiplications and divisions. See
8909 Operations in the close result set are performed using IEEE long format
8910 floating-point arithmetic. The input operands are converted to
8911 floating-point, the operation is done in floating-point, and the result
8912 is converted to the target type.
8917 @strong{126}. Conditions on a @code{universal_real} operand of a fixed
8918 point multiplication or division for which the result shall be in the
8919 perfect result set. See G.2.3(22).
8922 The result is only defined to be in the perfect result set if the result
8923 can be computed by a single scaling operation involving a scale factor
8924 representable in 64-bits.
8929 @strong{127}. The result of a fixed point arithmetic operation in
8930 overflow situations, when the @code{Machine_Overflows} attribute of the
8931 result type is @code{False}. See G.2.3(27).
8934 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
8940 @strong{128}. The result of an elementary function reference in
8941 overflow situations, when the @code{Machine_Overflows} attribute of the
8942 result type is @code{False}. See G.2.4(4).
8945 IEEE infinite and Nan values are produced as appropriate.
8950 @strong{129}. The value of the angle threshold, within which certain
8951 elementary functions, complex arithmetic operations, and complex
8952 elementary functions yield results conforming to a maximum relative
8953 error bound. See G.2.4(10).
8956 Information on this subject is not yet available.
8961 @strong{130}. The accuracy of certain elementary functions for
8962 parameters beyond the angle threshold. See G.2.4(10).
8965 Information on this subject is not yet available.
8970 @strong{131}. The result of a complex arithmetic operation or complex
8971 elementary function reference in overflow situations, when the
8972 @code{Machine_Overflows} attribute of the corresponding real type is
8973 @code{False}. See G.2.6(5).
8976 IEEE infinite and Nan values are produced as appropriate.
8981 @strong{132}. The accuracy of certain complex arithmetic operations and
8982 certain complex elementary functions for parameters (or components
8983 thereof) beyond the angle threshold. See G.2.6(8).
8986 Information on those subjects is not yet available.
8991 @strong{133}. Information regarding bounded errors and erroneous
8992 execution. See H.2(1).
8995 Information on this subject is not yet available.
9000 @strong{134}. Implementation-defined aspects of pragma
9001 @code{Inspection_Point}. See H.3.2(8).
9004 Pragma @code{Inspection_Point} ensures that the variable is live and can
9005 be examined by the debugger at the inspection point.
9010 @strong{135}. Implementation-defined aspects of pragma
9011 @code{Restrictions}. See H.4(25).
9014 There are no implementation-defined aspects of pragma @code{Restrictions}. The
9015 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9016 generated code. Checks must suppressed by use of pragma @code{Suppress}.
9021 @strong{136}. Any restrictions on pragma @code{Restrictions}. See
9025 There are no restrictions on pragma @code{Restrictions}.
9027 @node Intrinsic Subprograms
9028 @chapter Intrinsic Subprograms
9029 @cindex Intrinsic Subprograms
9032 * Intrinsic Operators::
9033 * Enclosing_Entity::
9034 * Exception_Information::
9035 * Exception_Message::
9043 * Shift_Right_Arithmetic::
9048 GNAT allows a user application program to write the declaration:
9050 @smallexample @c ada
9051 pragma Import (Intrinsic, name);
9055 providing that the name corresponds to one of the implemented intrinsic
9056 subprograms in GNAT, and that the parameter profile of the referenced
9057 subprogram meets the requirements. This chapter describes the set of
9058 implemented intrinsic subprograms, and the requirements on parameter profiles.
9059 Note that no body is supplied; as with other uses of pragma Import, the
9060 body is supplied elsewhere (in this case by the compiler itself). Note
9061 that any use of this feature is potentially non-portable, since the
9062 Ada standard does not require Ada compilers to implement this feature.
9064 @node Intrinsic Operators
9065 @section Intrinsic Operators
9066 @cindex Intrinsic operator
9069 All the predefined numeric operators in package Standard
9070 in @code{pragma Import (Intrinsic,..)}
9071 declarations. In the binary operator case, the operands must have the same
9072 size. The operand or operands must also be appropriate for
9073 the operator. For example, for addition, the operands must
9074 both be floating-point or both be fixed-point, and the
9075 right operand for @code{"**"} must have a root type of
9076 @code{Standard.Integer'Base}.
9077 You can use an intrinsic operator declaration as in the following example:
9079 @smallexample @c ada
9080 type Int1 is new Integer;
9081 type Int2 is new Integer;
9083 function "+" (X1 : Int1; X2 : Int2) return Int1;
9084 function "+" (X1 : Int1; X2 : Int2) return Int2;
9085 pragma Import (Intrinsic, "+");
9089 This declaration would permit ``mixed mode'' arithmetic on items
9090 of the differing types @code{Int1} and @code{Int2}.
9091 It is also possible to specify such operators for private types, if the
9092 full views are appropriate arithmetic types.
9094 @node Enclosing_Entity
9095 @section Enclosing_Entity
9096 @cindex Enclosing_Entity
9098 This intrinsic subprogram is used in the implementation of the
9099 library routine @code{GNAT.Source_Info}. The only useful use of the
9100 intrinsic import in this case is the one in this unit, so an
9101 application program should simply call the function
9102 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9103 the current subprogram, package, task, entry, or protected subprogram.
9105 @node Exception_Information
9106 @section Exception_Information
9107 @cindex Exception_Information'
9109 This intrinsic subprogram is used in the implementation of the
9110 library routine @code{GNAT.Current_Exception}. The only useful
9111 use of the intrinsic import in this case is the one in this unit,
9112 so an application program should simply call the function
9113 @code{GNAT.Current_Exception.Exception_Information} to obtain
9114 the exception information associated with the current exception.
9116 @node Exception_Message
9117 @section Exception_Message
9118 @cindex Exception_Message
9120 This intrinsic subprogram is used in the implementation of the
9121 library routine @code{GNAT.Current_Exception}. The only useful
9122 use of the intrinsic import in this case is the one in this unit,
9123 so an application program should simply call the function
9124 @code{GNAT.Current_Exception.Exception_Message} to obtain
9125 the message associated with the current exception.
9127 @node Exception_Name
9128 @section Exception_Name
9129 @cindex Exception_Name
9131 This intrinsic subprogram is used in the implementation of the
9132 library routine @code{GNAT.Current_Exception}. The only useful
9133 use of the intrinsic import in this case is the one in this unit,
9134 so an application program should simply call the function
9135 @code{GNAT.Current_Exception.Exception_Name} to obtain
9136 the name of the current exception.
9142 This intrinsic subprogram is used in the implementation of the
9143 library routine @code{GNAT.Source_Info}. The only useful use of the
9144 intrinsic import in this case is the one in this unit, so an
9145 application program should simply call the function
9146 @code{GNAT.Source_Info.File} to obtain the name of the current
9153 This intrinsic subprogram is used in the implementation of the
9154 library routine @code{GNAT.Source_Info}. The only useful use of the
9155 intrinsic import in this case is the one in this unit, so an
9156 application program should simply call the function
9157 @code{GNAT.Source_Info.Line} to obtain the number of the current
9161 @section Rotate_Left
9164 In standard Ada, the @code{Rotate_Left} function is available only
9165 for the predefined modular types in package @code{Interfaces}. However, in
9166 GNAT it is possible to define a Rotate_Left function for a user
9167 defined modular type or any signed integer type as in this example:
9169 @smallexample @c ada
9171 (Value : My_Modular_Type;
9173 return My_Modular_Type;
9177 The requirements are that the profile be exactly as in the example
9178 above. The only modifications allowed are in the formal parameter
9179 names, and in the type of @code{Value} and the return type, which
9180 must be the same, and must be either a signed integer type, or
9181 a modular integer type with a binary modulus, and the size must
9182 be 8. 16, 32 or 64 bits.
9185 @section Rotate_Right
9186 @cindex Rotate_Right
9188 A @code{Rotate_Right} function can be defined for any user defined
9189 binary modular integer type, or signed integer type, as described
9190 above for @code{Rotate_Left}.
9196 A @code{Shift_Left} function can be defined for any user defined
9197 binary modular integer type, or signed integer type, as described
9198 above for @code{Rotate_Left}.
9201 @section Shift_Right
9204 A @code{Shift_Right} function can be defined for any user defined
9205 binary modular integer type, or signed integer type, as described
9206 above for @code{Rotate_Left}.
9208 @node Shift_Right_Arithmetic
9209 @section Shift_Right_Arithmetic
9210 @cindex Shift_Right_Arithmetic
9212 A @code{Shift_Right_Arithmetic} function can be defined for any user
9213 defined binary modular integer type, or signed integer type, as described
9214 above for @code{Rotate_Left}.
9216 @node Source_Location
9217 @section Source_Location
9218 @cindex Source_Location
9220 This intrinsic subprogram is used in the implementation of the
9221 library routine @code{GNAT.Source_Info}. The only useful use of the
9222 intrinsic import in this case is the one in this unit, so an
9223 application program should simply call the function
9224 @code{GNAT.Source_Info.Source_Location} to obtain the current
9225 source file location.
9227 @node Representation Clauses and Pragmas
9228 @chapter Representation Clauses and Pragmas
9229 @cindex Representation Clauses
9232 * Alignment Clauses::
9234 * Storage_Size Clauses::
9235 * Size of Variant Record Objects::
9236 * Biased Representation ::
9237 * Value_Size and Object_Size Clauses::
9238 * Component_Size Clauses::
9239 * Bit_Order Clauses::
9240 * Effect of Bit_Order on Byte Ordering::
9241 * Pragma Pack for Arrays::
9242 * Pragma Pack for Records::
9243 * Record Representation Clauses::
9244 * Enumeration Clauses::
9246 * Effect of Convention on Representation::
9247 * Determining the Representations chosen by GNAT::
9251 @cindex Representation Clause
9252 @cindex Representation Pragma
9253 @cindex Pragma, representation
9254 This section describes the representation clauses accepted by GNAT, and
9255 their effect on the representation of corresponding data objects.
9257 GNAT fully implements Annex C (Systems Programming). This means that all
9258 the implementation advice sections in chapter 13 are fully implemented.
9259 However, these sections only require a minimal level of support for
9260 representation clauses. GNAT provides much more extensive capabilities,
9261 and this section describes the additional capabilities provided.
9263 @node Alignment Clauses
9264 @section Alignment Clauses
9265 @cindex Alignment Clause
9268 GNAT requires that all alignment clauses specify a power of 2, and all
9269 default alignments are always a power of 2. The default alignment
9270 values are as follows:
9273 @item @emph{Primitive Types}.
9274 For primitive types, the alignment is the minimum of the actual size of
9275 objects of the type divided by @code{Storage_Unit},
9276 and the maximum alignment supported by the target.
9277 (This maximum alignment is given by the GNAT-specific attribute
9278 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9279 @cindex @code{Maximum_Alignment} attribute
9280 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9281 default alignment will be 8 on any target that supports alignments
9282 this large, but on some targets, the maximum alignment may be smaller
9283 than 8, in which case objects of type @code{Long_Float} will be maximally
9286 @item @emph{Arrays}.
9287 For arrays, the alignment is equal to the alignment of the component type
9288 for the normal case where no packing or component size is given. If the
9289 array is packed, and the packing is effective (see separate section on
9290 packed arrays), then the alignment will be one for long packed arrays,
9291 or arrays whose length is not known at compile time. For short packed
9292 arrays, which are handled internally as modular types, the alignment
9293 will be as described for primitive types, e.g.@: a packed array of length
9294 31 bits will have an object size of four bytes, and an alignment of 4.
9296 @item @emph{Records}.
9297 For the normal non-packed case, the alignment of a record is equal to
9298 the maximum alignment of any of its components. For tagged records, this
9299 includes the implicit access type used for the tag. If a pragma @code{Pack} is
9300 used and all fields are packable (see separate section on pragma @code{Pack}),
9301 then the resulting alignment is 1.
9303 A special case is when:
9306 the size of the record is given explicitly, or a
9307 full record representation clause is given, and
9309 the size of the record is 2, 4, or 8 bytes.
9312 In this case, an alignment is chosen to match the
9313 size of the record. For example, if we have:
9315 @smallexample @c ada
9316 type Small is record
9319 for Small'Size use 16;
9323 then the default alignment of the record type @code{Small} is 2, not 1. This
9324 leads to more efficient code when the record is treated as a unit, and also
9325 allows the type to specified as @code{Atomic} on architectures requiring
9331 An alignment clause may specify a larger alignment than the default value
9332 up to some maximum value dependent on the target (obtainable by using the
9333 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
9334 a smaller alignment than the default value, for example
9336 @smallexample @c ada
9341 for V'alignment use 1;
9345 @cindex Alignment, default
9346 The default alignment for the type @code{V} is 4, as a result of the
9347 Integer field in the record, but it is permissible, as shown, to
9348 override the default alignment of the record with a smaller value.
9351 @section Size Clauses
9355 The default size for a type @code{T} is obtainable through the
9356 language-defined attribute @code{T'Size} and also through the
9357 equivalent GNAT-defined attribute @code{T'Value_Size}.
9358 For objects of type @code{T}, GNAT will generally increase the type size
9359 so that the object size (obtainable through the GNAT-defined attribute
9360 @code{T'Object_Size})
9361 is a multiple of @code{T'Alignment * Storage_Unit}.
9364 @smallexample @c ada
9365 type Smallint is range 1 .. 6;
9374 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
9375 as specified by the RM rules,
9376 but objects of this type will have a size of 8
9377 (@code{Smallint'Object_Size} = 8),
9378 since objects by default occupy an integral number
9379 of storage units. On some targets, notably older
9380 versions of the Digital Alpha, the size of stand
9381 alone objects of this type may be 32, reflecting
9382 the inability of the hardware to do byte load/stores.
9384 Similarly, the size of type @code{Rec} is 40 bits
9385 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
9386 the alignment is 4, so objects of this type will have
9387 their size increased to 64 bits so that it is a multiple
9388 of the alignment (in bits). This decision is
9389 in accordance with the specific Implementation Advice in RM 13.3(43):
9392 A @code{Size} clause should be supported for an object if the specified
9393 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
9394 to a size in storage elements that is a multiple of the object's
9395 @code{Alignment} (if the @code{Alignment} is nonzero).
9399 An explicit size clause may be used to override the default size by
9400 increasing it. For example, if we have:
9402 @smallexample @c ada
9403 type My_Boolean is new Boolean;
9404 for My_Boolean'Size use 32;
9408 then values of this type will always be 32 bits long. In the case of
9409 discrete types, the size can be increased up to 64 bits, with the effect
9410 that the entire specified field is used to hold the value, sign- or
9411 zero-extended as appropriate. If more than 64 bits is specified, then
9412 padding space is allocated after the value, and a warning is issued that
9413 there are unused bits.
9415 Similarly the size of records and arrays may be increased, and the effect
9416 is to add padding bits after the value. This also causes a warning message
9419 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
9420 Size in bits, this corresponds to an object of size 256 megabytes (minus
9421 one). This limitation is true on all targets. The reason for this
9422 limitation is that it improves the quality of the code in many cases
9423 if it is known that a Size value can be accommodated in an object of
9426 @node Storage_Size Clauses
9427 @section Storage_Size Clauses
9428 @cindex Storage_Size Clause
9431 For tasks, the @code{Storage_Size} clause specifies the amount of space
9432 to be allocated for the task stack. This cannot be extended, and if the
9433 stack is exhausted, then @code{Storage_Error} will be raised (if stack
9434 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
9435 or a @code{Storage_Size} pragma in the task definition to set the
9436 appropriate required size. A useful technique is to include in every
9437 task definition a pragma of the form:
9439 @smallexample @c ada
9440 pragma Storage_Size (Default_Stack_Size);
9444 Then @code{Default_Stack_Size} can be defined in a global package, and
9445 modified as required. Any tasks requiring stack sizes different from the
9446 default can have an appropriate alternative reference in the pragma.
9448 You can also use the @option{-d} binder switch to modify the default stack
9451 For access types, the @code{Storage_Size} clause specifies the maximum
9452 space available for allocation of objects of the type. If this space is
9453 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9454 In the case where the access type is declared local to a subprogram, the
9455 use of a @code{Storage_Size} clause triggers automatic use of a special
9456 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9457 space for the pool is automatically reclaimed on exit from the scope in
9458 which the type is declared.
9460 A special case recognized by the compiler is the specification of a
9461 @code{Storage_Size} of zero for an access type. This means that no
9462 items can be allocated from the pool, and this is recognized at compile
9463 time, and all the overhead normally associated with maintaining a fixed
9464 size storage pool is eliminated. Consider the following example:
9466 @smallexample @c ada
9468 type R is array (Natural) of Character;
9469 type P is access all R;
9470 for P'Storage_Size use 0;
9471 -- Above access type intended only for interfacing purposes
9475 procedure g (m : P);
9476 pragma Import (C, g);
9487 As indicated in this example, these dummy storage pools are often useful in
9488 connection with interfacing where no object will ever be allocated. If you
9489 compile the above example, you get the warning:
9492 p.adb:16:09: warning: allocation from empty storage pool
9493 p.adb:16:09: warning: Storage_Error will be raised at run time
9497 Of course in practice, there will not be any explicit allocators in the
9498 case of such an access declaration.
9500 @node Size of Variant Record Objects
9501 @section Size of Variant Record Objects
9502 @cindex Size, variant record objects
9503 @cindex Variant record objects, size
9506 In the case of variant record objects, there is a question whether Size gives
9507 information about a particular variant, or the maximum size required
9508 for any variant. Consider the following program
9510 @smallexample @c ada
9511 with Text_IO; use Text_IO;
9513 type R1 (A : Boolean := False) is record
9515 when True => X : Character;
9524 Put_Line (Integer'Image (V1'Size));
9525 Put_Line (Integer'Image (V2'Size));
9530 Here we are dealing with a variant record, where the True variant
9531 requires 16 bits, and the False variant requires 8 bits.
9532 In the above example, both V1 and V2 contain the False variant,
9533 which is only 8 bits long. However, the result of running the
9542 The reason for the difference here is that the discriminant value of
9543 V1 is fixed, and will always be False. It is not possible to assign
9544 a True variant value to V1, therefore 8 bits is sufficient. On the
9545 other hand, in the case of V2, the initial discriminant value is
9546 False (from the default), but it is possible to assign a True
9547 variant value to V2, therefore 16 bits must be allocated for V2
9548 in the general case, even fewer bits may be needed at any particular
9549 point during the program execution.
9551 As can be seen from the output of this program, the @code{'Size}
9552 attribute applied to such an object in GNAT gives the actual allocated
9553 size of the variable, which is the largest size of any of the variants.
9554 The Ada Reference Manual is not completely clear on what choice should
9555 be made here, but the GNAT behavior seems most consistent with the
9556 language in the RM@.
9558 In some cases, it may be desirable to obtain the size of the current
9559 variant, rather than the size of the largest variant. This can be
9560 achieved in GNAT by making use of the fact that in the case of a
9561 subprogram parameter, GNAT does indeed return the size of the current
9562 variant (because a subprogram has no way of knowing how much space
9563 is actually allocated for the actual).
9565 Consider the following modified version of the above program:
9567 @smallexample @c ada
9568 with Text_IO; use Text_IO;
9570 type R1 (A : Boolean := False) is record
9572 when True => X : Character;
9579 function Size (V : R1) return Integer is
9585 Put_Line (Integer'Image (V2'Size));
9586 Put_Line (Integer'IMage (Size (V2)));
9588 Put_Line (Integer'Image (V2'Size));
9589 Put_Line (Integer'IMage (Size (V2)));
9594 The output from this program is
9604 Here we see that while the @code{'Size} attribute always returns
9605 the maximum size, regardless of the current variant value, the
9606 @code{Size} function does indeed return the size of the current
9609 @node Biased Representation
9610 @section Biased Representation
9611 @cindex Size for biased representation
9612 @cindex Biased representation
9615 In the case of scalars with a range starting at other than zero, it is
9616 possible in some cases to specify a size smaller than the default minimum
9617 value, and in such cases, GNAT uses an unsigned biased representation,
9618 in which zero is used to represent the lower bound, and successive values
9619 represent successive values of the type.
9621 For example, suppose we have the declaration:
9623 @smallexample @c ada
9624 type Small is range -7 .. -4;
9625 for Small'Size use 2;
9629 Although the default size of type @code{Small} is 4, the @code{Size}
9630 clause is accepted by GNAT and results in the following representation
9634 -7 is represented as 2#00#
9635 -6 is represented as 2#01#
9636 -5 is represented as 2#10#
9637 -4 is represented as 2#11#
9641 Biased representation is only used if the specified @code{Size} clause
9642 cannot be accepted in any other manner. These reduced sizes that force
9643 biased representation can be used for all discrete types except for
9644 enumeration types for which a representation clause is given.
9646 @node Value_Size and Object_Size Clauses
9647 @section Value_Size and Object_Size Clauses
9650 @cindex Size, of objects
9653 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
9654 number of bits required to hold values of type @code{T}.
9655 Although this interpretation was allowed in Ada 83, it was not required,
9656 and this requirement in practice can cause some significant difficulties.
9657 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
9658 However, in Ada 95 and Ada 2005,
9659 @code{Natural'Size} is
9660 typically 31. This means that code may change in behavior when moving
9661 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
9663 @smallexample @c ada
9670 at 0 range 0 .. Natural'Size - 1;
9671 at 0 range Natural'Size .. 2 * Natural'Size - 1;
9676 In the above code, since the typical size of @code{Natural} objects
9677 is 32 bits and @code{Natural'Size} is 31, the above code can cause
9678 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
9679 there are cases where the fact that the object size can exceed the
9680 size of the type causes surprises.
9682 To help get around this problem GNAT provides two implementation
9683 defined attributes, @code{Value_Size} and @code{Object_Size}. When
9684 applied to a type, these attributes yield the size of the type
9685 (corresponding to the RM defined size attribute), and the size of
9686 objects of the type respectively.
9688 The @code{Object_Size} is used for determining the default size of
9689 objects and components. This size value can be referred to using the
9690 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
9691 the basis of the determination of the size. The backend is free to
9692 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
9693 character might be stored in 32 bits on a machine with no efficient
9694 byte access instructions such as the Alpha.
9696 The default rules for the value of @code{Object_Size} for
9697 discrete types are as follows:
9701 The @code{Object_Size} for base subtypes reflect the natural hardware
9702 size in bits (run the compiler with @option{-gnatS} to find those values
9703 for numeric types). Enumeration types and fixed-point base subtypes have
9704 8, 16, 32 or 64 bits for this size, depending on the range of values
9708 The @code{Object_Size} of a subtype is the same as the
9709 @code{Object_Size} of
9710 the type from which it is obtained.
9713 The @code{Object_Size} of a derived base type is copied from the parent
9714 base type, and the @code{Object_Size} of a derived first subtype is copied
9715 from the parent first subtype.
9719 The @code{Value_Size} attribute
9720 is the (minimum) number of bits required to store a value
9722 This value is used to determine how tightly to pack
9723 records or arrays with components of this type, and also affects
9724 the semantics of unchecked conversion (unchecked conversions where
9725 the @code{Value_Size} values differ generate a warning, and are potentially
9728 The default rules for the value of @code{Value_Size} are as follows:
9732 The @code{Value_Size} for a base subtype is the minimum number of bits
9733 required to store all values of the type (including the sign bit
9734 only if negative values are possible).
9737 If a subtype statically matches the first subtype of a given type, then it has
9738 by default the same @code{Value_Size} as the first subtype. This is a
9739 consequence of RM 13.1(14) (``if two subtypes statically match,
9740 then their subtype-specific aspects are the same''.)
9743 All other subtypes have a @code{Value_Size} corresponding to the minimum
9744 number of bits required to store all values of the subtype. For
9745 dynamic bounds, it is assumed that the value can range down or up
9746 to the corresponding bound of the ancestor
9750 The RM defined attribute @code{Size} corresponds to the
9751 @code{Value_Size} attribute.
9753 The @code{Size} attribute may be defined for a first-named subtype. This sets
9754 the @code{Value_Size} of
9755 the first-named subtype to the given value, and the
9756 @code{Object_Size} of this first-named subtype to the given value padded up
9757 to an appropriate boundary. It is a consequence of the default rules
9758 above that this @code{Object_Size} will apply to all further subtypes. On the
9759 other hand, @code{Value_Size} is affected only for the first subtype, any
9760 dynamic subtypes obtained from it directly, and any statically matching
9761 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
9763 @code{Value_Size} and
9764 @code{Object_Size} may be explicitly set for any subtype using
9765 an attribute definition clause. Note that the use of these attributes
9766 can cause the RM 13.1(14) rule to be violated. If two access types
9767 reference aliased objects whose subtypes have differing @code{Object_Size}
9768 values as a result of explicit attribute definition clauses, then it
9769 is erroneous to convert from one access subtype to the other.
9771 At the implementation level, Esize stores the Object_Size and the
9772 RM_Size field stores the @code{Value_Size} (and hence the value of the
9773 @code{Size} attribute,
9774 which, as noted above, is equivalent to @code{Value_Size}).
9776 To get a feel for the difference, consider the following examples (note
9777 that in each case the base is @code{Short_Short_Integer} with a size of 8):
9780 Object_Size Value_Size
9782 type x1 is range 0 .. 5; 8 3
9784 type x2 is range 0 .. 5;
9785 for x2'size use 12; 16 12
9787 subtype x3 is x2 range 0 .. 3; 16 2
9789 subtype x4 is x2'base range 0 .. 10; 8 4
9791 subtype x5 is x2 range 0 .. dynamic; 16 3*
9793 subtype x6 is x2'base range 0 .. dynamic; 8 3*
9798 Note: the entries marked ``3*'' are not actually specified by the Ada
9799 Reference Manual, but it seems in the spirit of the RM rules to allocate
9800 the minimum number of bits (here 3, given the range for @code{x2})
9801 known to be large enough to hold the given range of values.
9803 So far, so good, but GNAT has to obey the RM rules, so the question is
9804 under what conditions must the RM @code{Size} be used.
9805 The following is a list
9806 of the occasions on which the RM @code{Size} must be used:
9810 Component size for packed arrays or records
9813 Value of the attribute @code{Size} for a type
9816 Warning about sizes not matching for unchecked conversion
9820 For record types, the @code{Object_Size} is always a multiple of the
9821 alignment of the type (this is true for all types). In some cases the
9822 @code{Value_Size} can be smaller. Consider:
9832 On a typical 32-bit architecture, the X component will be four bytes, and
9833 require four-byte alignment, and the Y component will be one byte. In this
9834 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
9835 required to store a value of this type, and for example, it is permissible
9836 to have a component of type R in an outer record whose component size is
9837 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
9838 since it must be rounded up so that this value is a multiple of the
9839 alignment (4 bytes = 32 bits).
9842 For all other types, the @code{Object_Size}
9843 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
9844 Only @code{Size} may be specified for such types.
9846 @node Component_Size Clauses
9847 @section Component_Size Clauses
9848 @cindex Component_Size Clause
9851 Normally, the value specified in a component size clause must be consistent
9852 with the subtype of the array component with regard to size and alignment.
9853 In other words, the value specified must be at least equal to the size
9854 of this subtype, and must be a multiple of the alignment value.
9856 In addition, component size clauses are allowed which cause the array
9857 to be packed, by specifying a smaller value. The cases in which this
9858 is allowed are for component size values in the range 1 through 63. The value
9859 specified must not be smaller than the Size of the subtype. GNAT will
9860 accurately honor all packing requests in this range. For example, if
9863 @smallexample @c ada
9864 type r is array (1 .. 8) of Natural;
9865 for r'Component_Size use 31;
9869 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
9870 Of course access to the components of such an array is considerably
9871 less efficient than if the natural component size of 32 is used.
9873 Note that there is no point in giving both a component size clause
9874 and a pragma Pack for the same array type. if such duplicate
9875 clauses are given, the pragma Pack will be ignored.
9877 @node Bit_Order Clauses
9878 @section Bit_Order Clauses
9879 @cindex Bit_Order Clause
9880 @cindex bit ordering
9881 @cindex ordering, of bits
9884 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
9885 attribute. The specification may either correspond to the default bit
9886 order for the target, in which case the specification has no effect and
9887 places no additional restrictions, or it may be for the non-standard
9888 setting (that is the opposite of the default).
9890 In the case where the non-standard value is specified, the effect is
9891 to renumber bits within each byte, but the ordering of bytes is not
9892 affected. There are certain
9893 restrictions placed on component clauses as follows:
9897 @item Components fitting within a single storage unit.
9899 These are unrestricted, and the effect is merely to renumber bits. For
9900 example if we are on a little-endian machine with @code{Low_Order_First}
9901 being the default, then the following two declarations have exactly
9904 @smallexample @c ada
9907 B : Integer range 1 .. 120;
9911 A at 0 range 0 .. 0;
9912 B at 0 range 1 .. 7;
9917 B : Integer range 1 .. 120;
9920 for R2'Bit_Order use High_Order_First;
9923 A at 0 range 7 .. 7;
9924 B at 0 range 0 .. 6;
9929 The useful application here is to write the second declaration with the
9930 @code{Bit_Order} attribute definition clause, and know that it will be treated
9931 the same, regardless of whether the target is little-endian or big-endian.
9933 @item Components occupying an integral number of bytes.
9935 These are components that exactly fit in two or more bytes. Such component
9936 declarations are allowed, but have no effect, since it is important to realize
9937 that the @code{Bit_Order} specification does not affect the ordering of bytes.
9938 In particular, the following attempt at getting an endian-independent integer
9941 @smallexample @c ada
9946 for R2'Bit_Order use High_Order_First;
9949 A at 0 range 0 .. 31;
9954 This declaration will result in a little-endian integer on a
9955 little-endian machine, and a big-endian integer on a big-endian machine.
9956 If byte flipping is required for interoperability between big- and
9957 little-endian machines, this must be explicitly programmed. This capability
9958 is not provided by @code{Bit_Order}.
9960 @item Components that are positioned across byte boundaries
9962 but do not occupy an integral number of bytes. Given that bytes are not
9963 reordered, such fields would occupy a non-contiguous sequence of bits
9964 in memory, requiring non-trivial code to reassemble. They are for this
9965 reason not permitted, and any component clause specifying such a layout
9966 will be flagged as illegal by GNAT@.
9971 Since the misconception that Bit_Order automatically deals with all
9972 endian-related incompatibilities is a common one, the specification of
9973 a component field that is an integral number of bytes will always
9974 generate a warning. This warning may be suppressed using @code{pragma
9975 Warnings (Off)} if desired. The following section contains additional
9976 details regarding the issue of byte ordering.
9978 @node Effect of Bit_Order on Byte Ordering
9979 @section Effect of Bit_Order on Byte Ordering
9980 @cindex byte ordering
9981 @cindex ordering, of bytes
9984 In this section we will review the effect of the @code{Bit_Order} attribute
9985 definition clause on byte ordering. Briefly, it has no effect at all, but
9986 a detailed example will be helpful. Before giving this
9987 example, let us review the precise
9988 definition of the effect of defining @code{Bit_Order}. The effect of a
9989 non-standard bit order is described in section 15.5.3 of the Ada
9993 2 A bit ordering is a method of interpreting the meaning of
9994 the storage place attributes.
9998 To understand the precise definition of storage place attributes in
9999 this context, we visit section 13.5.1 of the manual:
10002 13 A record_representation_clause (without the mod_clause)
10003 specifies the layout. The storage place attributes (see 13.5.2)
10004 are taken from the values of the position, first_bit, and last_bit
10005 expressions after normalizing those values so that first_bit is
10006 less than Storage_Unit.
10010 The critical point here is that storage places are taken from
10011 the values after normalization, not before. So the @code{Bit_Order}
10012 interpretation applies to normalized values. The interpretation
10013 is described in the later part of the 15.5.3 paragraph:
10016 2 A bit ordering is a method of interpreting the meaning of
10017 the storage place attributes. High_Order_First (known in the
10018 vernacular as ``big endian'') means that the first bit of a
10019 storage element (bit 0) is the most significant bit (interpreting
10020 the sequence of bits that represent a component as an unsigned
10021 integer value). Low_Order_First (known in the vernacular as
10022 ``little endian'') means the opposite: the first bit is the
10027 Note that the numbering is with respect to the bits of a storage
10028 unit. In other words, the specification affects only the numbering
10029 of bits within a single storage unit.
10031 We can make the effect clearer by giving an example.
10033 Suppose that we have an external device which presents two bytes, the first
10034 byte presented, which is the first (low addressed byte) of the two byte
10035 record is called Master, and the second byte is called Slave.
10037 The left most (most significant bit is called Control for each byte, and
10038 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10039 (least significant) bit.
10041 On a big-endian machine, we can write the following representation clause
10043 @smallexample @c ada
10044 type Data is record
10045 Master_Control : Bit;
10053 Slave_Control : Bit;
10063 for Data use record
10064 Master_Control at 0 range 0 .. 0;
10065 Master_V1 at 0 range 1 .. 1;
10066 Master_V2 at 0 range 2 .. 2;
10067 Master_V3 at 0 range 3 .. 3;
10068 Master_V4 at 0 range 4 .. 4;
10069 Master_V5 at 0 range 5 .. 5;
10070 Master_V6 at 0 range 6 .. 6;
10071 Master_V7 at 0 range 7 .. 7;
10072 Slave_Control at 1 range 0 .. 0;
10073 Slave_V1 at 1 range 1 .. 1;
10074 Slave_V2 at 1 range 2 .. 2;
10075 Slave_V3 at 1 range 3 .. 3;
10076 Slave_V4 at 1 range 4 .. 4;
10077 Slave_V5 at 1 range 5 .. 5;
10078 Slave_V6 at 1 range 6 .. 6;
10079 Slave_V7 at 1 range 7 .. 7;
10084 Now if we move this to a little endian machine, then the bit ordering within
10085 the byte is backwards, so we have to rewrite the record rep clause as:
10087 @smallexample @c ada
10088 for Data use record
10089 Master_Control at 0 range 7 .. 7;
10090 Master_V1 at 0 range 6 .. 6;
10091 Master_V2 at 0 range 5 .. 5;
10092 Master_V3 at 0 range 4 .. 4;
10093 Master_V4 at 0 range 3 .. 3;
10094 Master_V5 at 0 range 2 .. 2;
10095 Master_V6 at 0 range 1 .. 1;
10096 Master_V7 at 0 range 0 .. 0;
10097 Slave_Control at 1 range 7 .. 7;
10098 Slave_V1 at 1 range 6 .. 6;
10099 Slave_V2 at 1 range 5 .. 5;
10100 Slave_V3 at 1 range 4 .. 4;
10101 Slave_V4 at 1 range 3 .. 3;
10102 Slave_V5 at 1 range 2 .. 2;
10103 Slave_V6 at 1 range 1 .. 1;
10104 Slave_V7 at 1 range 0 .. 0;
10109 It is a nuisance to have to rewrite the clause, especially if
10110 the code has to be maintained on both machines. However,
10111 this is a case that we can handle with the
10112 @code{Bit_Order} attribute if it is implemented.
10113 Note that the implementation is not required on byte addressed
10114 machines, but it is indeed implemented in GNAT.
10115 This means that we can simply use the
10116 first record clause, together with the declaration
10118 @smallexample @c ada
10119 for Data'Bit_Order use High_Order_First;
10123 and the effect is what is desired, namely the layout is exactly the same,
10124 independent of whether the code is compiled on a big-endian or little-endian
10127 The important point to understand is that byte ordering is not affected.
10128 A @code{Bit_Order} attribute definition never affects which byte a field
10129 ends up in, only where it ends up in that byte.
10130 To make this clear, let us rewrite the record rep clause of the previous
10133 @smallexample @c ada
10134 for Data'Bit_Order use High_Order_First;
10135 for Data use record
10136 Master_Control at 0 range 0 .. 0;
10137 Master_V1 at 0 range 1 .. 1;
10138 Master_V2 at 0 range 2 .. 2;
10139 Master_V3 at 0 range 3 .. 3;
10140 Master_V4 at 0 range 4 .. 4;
10141 Master_V5 at 0 range 5 .. 5;
10142 Master_V6 at 0 range 6 .. 6;
10143 Master_V7 at 0 range 7 .. 7;
10144 Slave_Control at 0 range 8 .. 8;
10145 Slave_V1 at 0 range 9 .. 9;
10146 Slave_V2 at 0 range 10 .. 10;
10147 Slave_V3 at 0 range 11 .. 11;
10148 Slave_V4 at 0 range 12 .. 12;
10149 Slave_V5 at 0 range 13 .. 13;
10150 Slave_V6 at 0 range 14 .. 14;
10151 Slave_V7 at 0 range 15 .. 15;
10156 This is exactly equivalent to saying (a repeat of the first example):
10158 @smallexample @c ada
10159 for Data'Bit_Order use High_Order_First;
10160 for Data use record
10161 Master_Control at 0 range 0 .. 0;
10162 Master_V1 at 0 range 1 .. 1;
10163 Master_V2 at 0 range 2 .. 2;
10164 Master_V3 at 0 range 3 .. 3;
10165 Master_V4 at 0 range 4 .. 4;
10166 Master_V5 at 0 range 5 .. 5;
10167 Master_V6 at 0 range 6 .. 6;
10168 Master_V7 at 0 range 7 .. 7;
10169 Slave_Control at 1 range 0 .. 0;
10170 Slave_V1 at 1 range 1 .. 1;
10171 Slave_V2 at 1 range 2 .. 2;
10172 Slave_V3 at 1 range 3 .. 3;
10173 Slave_V4 at 1 range 4 .. 4;
10174 Slave_V5 at 1 range 5 .. 5;
10175 Slave_V6 at 1 range 6 .. 6;
10176 Slave_V7 at 1 range 7 .. 7;
10181 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10182 field. The storage place attributes are obtained by normalizing the
10183 values given so that the @code{First_Bit} value is less than 8. After
10184 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10185 we specified in the other case.
10187 Now one might expect that the @code{Bit_Order} attribute might affect
10188 bit numbering within the entire record component (two bytes in this
10189 case, thus affecting which byte fields end up in), but that is not
10190 the way this feature is defined, it only affects numbering of bits,
10191 not which byte they end up in.
10193 Consequently it never makes sense to specify a starting bit number
10194 greater than 7 (for a byte addressable field) if an attribute
10195 definition for @code{Bit_Order} has been given, and indeed it
10196 may be actively confusing to specify such a value, so the compiler
10197 generates a warning for such usage.
10199 If you do need to control byte ordering then appropriate conditional
10200 values must be used. If in our example, the slave byte came first on
10201 some machines we might write:
10203 @smallexample @c ada
10204 Master_Byte_First constant Boolean := @dots{};
10206 Master_Byte : constant Natural :=
10207 1 - Boolean'Pos (Master_Byte_First);
10208 Slave_Byte : constant Natural :=
10209 Boolean'Pos (Master_Byte_First);
10211 for Data'Bit_Order use High_Order_First;
10212 for Data use record
10213 Master_Control at Master_Byte range 0 .. 0;
10214 Master_V1 at Master_Byte range 1 .. 1;
10215 Master_V2 at Master_Byte range 2 .. 2;
10216 Master_V3 at Master_Byte range 3 .. 3;
10217 Master_V4 at Master_Byte range 4 .. 4;
10218 Master_V5 at Master_Byte range 5 .. 5;
10219 Master_V6 at Master_Byte range 6 .. 6;
10220 Master_V7 at Master_Byte range 7 .. 7;
10221 Slave_Control at Slave_Byte range 0 .. 0;
10222 Slave_V1 at Slave_Byte range 1 .. 1;
10223 Slave_V2 at Slave_Byte range 2 .. 2;
10224 Slave_V3 at Slave_Byte range 3 .. 3;
10225 Slave_V4 at Slave_Byte range 4 .. 4;
10226 Slave_V5 at Slave_Byte range 5 .. 5;
10227 Slave_V6 at Slave_Byte range 6 .. 6;
10228 Slave_V7 at Slave_Byte range 7 .. 7;
10233 Now to switch between machines, all that is necessary is
10234 to set the boolean constant @code{Master_Byte_First} in
10235 an appropriate manner.
10237 @node Pragma Pack for Arrays
10238 @section Pragma Pack for Arrays
10239 @cindex Pragma Pack (for arrays)
10242 Pragma @code{Pack} applied to an array has no effect unless the component type
10243 is packable. For a component type to be packable, it must be one of the
10250 Any type whose size is specified with a size clause
10252 Any packed array type with a static size
10256 For all these cases, if the component subtype size is in the range
10257 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10258 component size were specified giving the component subtype size.
10259 For example if we have:
10261 @smallexample @c ada
10262 type r is range 0 .. 17;
10264 type ar is array (1 .. 8) of r;
10269 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10270 and the size of the array @code{ar} will be exactly 40 bits.
10272 Note that in some cases this rather fierce approach to packing can produce
10273 unexpected effects. For example, in Ada 95 and Ada 2005,
10274 subtype @code{Natural} typically has a size of 31, meaning that if you
10275 pack an array of @code{Natural}, you get 31-bit
10276 close packing, which saves a few bits, but results in far less efficient
10277 access. Since many other Ada compilers will ignore such a packing request,
10278 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10279 might not be what is intended. You can easily remove this warning by
10280 using an explicit @code{Component_Size} setting instead, which never generates
10281 a warning, since the intention of the programmer is clear in this case.
10283 GNAT treats packed arrays in one of two ways. If the size of the array is
10284 known at compile time and is less than 64 bits, then internally the array
10285 is represented as a single modular type, of exactly the appropriate number
10286 of bits. If the length is greater than 63 bits, or is not known at compile
10287 time, then the packed array is represented as an array of bytes, and the
10288 length is always a multiple of 8 bits.
10290 Note that to represent a packed array as a modular type, the alignment must
10291 be suitable for the modular type involved. For example, on typical machines
10292 a 32-bit packed array will be represented by a 32-bit modular integer with
10293 an alignment of four bytes. If you explicitly override the default alignment
10294 with an alignment clause that is too small, the modular representation
10295 cannot be used. For example, consider the following set of declarations:
10297 @smallexample @c ada
10298 type R is range 1 .. 3;
10299 type S is array (1 .. 31) of R;
10300 for S'Component_Size use 2;
10302 for S'Alignment use 1;
10306 If the alignment clause were not present, then a 62-bit modular
10307 representation would be chosen (typically with an alignment of 4 or 8
10308 bytes depending on the target). But the default alignment is overridden
10309 with the explicit alignment clause. This means that the modular
10310 representation cannot be used, and instead the array of bytes
10311 representation must be used, meaning that the length must be a multiple
10312 of 8. Thus the above set of declarations will result in a diagnostic
10313 rejecting the size clause and noting that the minimum size allowed is 64.
10315 @cindex Pragma Pack (for type Natural)
10316 @cindex Pragma Pack warning
10318 One special case that is worth noting occurs when the base type of the
10319 component size is 8/16/32 and the subtype is one bit less. Notably this
10320 occurs with subtype @code{Natural}. Consider:
10322 @smallexample @c ada
10323 type Arr is array (1 .. 32) of Natural;
10328 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10329 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10330 Ada 83 compilers did not attempt 31 bit packing.
10332 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
10333 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
10334 substantial unintended performance penalty when porting legacy Ada 83 code.
10335 To help prevent this, GNAT generates a warning in such cases. If you really
10336 want 31 bit packing in a case like this, you can set the component size
10339 @smallexample @c ada
10340 type Arr is array (1 .. 32) of Natural;
10341 for Arr'Component_Size use 31;
10345 Here 31-bit packing is achieved as required, and no warning is generated,
10346 since in this case the programmer intention is clear.
10348 @node Pragma Pack for Records
10349 @section Pragma Pack for Records
10350 @cindex Pragma Pack (for records)
10353 Pragma @code{Pack} applied to a record will pack the components to reduce
10354 wasted space from alignment gaps and by reducing the amount of space
10355 taken by components. We distinguish between @emph{packable} components and
10356 @emph{non-packable} components.
10357 Components of the following types are considered packable:
10360 All primitive types are packable.
10363 Small packed arrays, whose size does not exceed 64 bits, and where the
10364 size is statically known at compile time, are represented internally
10365 as modular integers, and so they are also packable.
10370 All packable components occupy the exact number of bits corresponding to
10371 their @code{Size} value, and are packed with no padding bits, i.e.@: they
10372 can start on an arbitrary bit boundary.
10374 All other types are non-packable, they occupy an integral number of
10376 are placed at a boundary corresponding to their alignment requirements.
10378 For example, consider the record
10380 @smallexample @c ada
10381 type Rb1 is array (1 .. 13) of Boolean;
10384 type Rb2 is array (1 .. 65) of Boolean;
10399 The representation for the record x2 is as follows:
10401 @smallexample @c ada
10402 for x2'Size use 224;
10404 l1 at 0 range 0 .. 0;
10405 l2 at 0 range 1 .. 64;
10406 l3 at 12 range 0 .. 31;
10407 l4 at 16 range 0 .. 0;
10408 l5 at 16 range 1 .. 13;
10409 l6 at 18 range 0 .. 71;
10414 Studying this example, we see that the packable fields @code{l1}
10416 of length equal to their sizes, and placed at specific bit boundaries (and
10417 not byte boundaries) to
10418 eliminate padding. But @code{l3} is of a non-packable float type, so
10419 it is on the next appropriate alignment boundary.
10421 The next two fields are fully packable, so @code{l4} and @code{l5} are
10422 minimally packed with no gaps. However, type @code{Rb2} is a packed
10423 array that is longer than 64 bits, so it is itself non-packable. Thus
10424 the @code{l6} field is aligned to the next byte boundary, and takes an
10425 integral number of bytes, i.e.@: 72 bits.
10427 @node Record Representation Clauses
10428 @section Record Representation Clauses
10429 @cindex Record Representation Clause
10432 Record representation clauses may be given for all record types, including
10433 types obtained by record extension. Component clauses are allowed for any
10434 static component. The restrictions on component clauses depend on the type
10437 @cindex Component Clause
10438 For all components of an elementary type, the only restriction on component
10439 clauses is that the size must be at least the 'Size value of the type
10440 (actually the Value_Size). There are no restrictions due to alignment,
10441 and such components may freely cross storage boundaries.
10443 Packed arrays with a size up to and including 64 bits are represented
10444 internally using a modular type with the appropriate number of bits, and
10445 thus the same lack of restriction applies. For example, if you declare:
10447 @smallexample @c ada
10448 type R is array (1 .. 49) of Boolean;
10454 then a component clause for a component of type R may start on any
10455 specified bit boundary, and may specify a value of 49 bits or greater.
10457 For packed bit arrays that are longer than 64 bits, there are two
10458 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
10459 including the important case of single bits or boolean values, then
10460 there are no limitations on placement of such components, and they
10461 may start and end at arbitrary bit boundaries.
10463 If the component size is not a power of 2 (e.g.@: 3 or 5), then
10464 an array of this type longer than 64 bits must always be placed on
10465 on a storage unit (byte) boundary and occupy an integral number
10466 of storage units (bytes). Any component clause that does not
10467 meet this requirement will be rejected.
10469 Any aliased component, or component of an aliased type, must
10470 have its normal alignment and size. A component clause that
10471 does not meet this requirement will be rejected.
10473 The tag field of a tagged type always occupies an address sized field at
10474 the start of the record. No component clause may attempt to overlay this
10475 tag. When a tagged type appears as a component, the tag field must have
10478 In the case of a record extension T1, of a type T, no component clause applied
10479 to the type T1 can specify a storage location that would overlap the first
10480 T'Size bytes of the record.
10482 For all other component types, including non-bit-packed arrays,
10483 the component can be placed at an arbitrary bit boundary,
10484 so for example, the following is permitted:
10486 @smallexample @c ada
10487 type R is array (1 .. 10) of Boolean;
10496 G at 0 range 0 .. 0;
10497 H at 0 range 1 .. 1;
10498 L at 0 range 2 .. 81;
10499 R at 0 range 82 .. 161;
10504 Note: the above rules apply to recent releases of GNAT 5.
10505 In GNAT 3, there are more severe restrictions on larger components.
10506 For non-primitive types, including packed arrays with a size greater than
10507 64 bits, component clauses must respect the alignment requirement of the
10508 type, in particular, always starting on a byte boundary, and the length
10509 must be a multiple of the storage unit.
10511 @node Enumeration Clauses
10512 @section Enumeration Clauses
10514 The only restriction on enumeration clauses is that the range of values
10515 must be representable. For the signed case, if one or more of the
10516 representation values are negative, all values must be in the range:
10518 @smallexample @c ada
10519 System.Min_Int .. System.Max_Int
10523 For the unsigned case, where all values are nonnegative, the values must
10526 @smallexample @c ada
10527 0 .. System.Max_Binary_Modulus;
10531 A @emph{confirming} representation clause is one in which the values range
10532 from 0 in sequence, i.e.@: a clause that confirms the default representation
10533 for an enumeration type.
10534 Such a confirming representation
10535 is permitted by these rules, and is specially recognized by the compiler so
10536 that no extra overhead results from the use of such a clause.
10538 If an array has an index type which is an enumeration type to which an
10539 enumeration clause has been applied, then the array is stored in a compact
10540 manner. Consider the declarations:
10542 @smallexample @c ada
10543 type r is (A, B, C);
10544 for r use (A => 1, B => 5, C => 10);
10545 type t is array (r) of Character;
10549 The array type t corresponds to a vector with exactly three elements and
10550 has a default size equal to @code{3*Character'Size}. This ensures efficient
10551 use of space, but means that accesses to elements of the array will incur
10552 the overhead of converting representation values to the corresponding
10553 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
10555 @node Address Clauses
10556 @section Address Clauses
10557 @cindex Address Clause
10559 The reference manual allows a general restriction on representation clauses,
10560 as found in RM 13.1(22):
10563 An implementation need not support representation
10564 items containing nonstatic expressions, except that
10565 an implementation should support a representation item
10566 for a given entity if each nonstatic expression in the
10567 representation item is a name that statically denotes
10568 a constant declared before the entity.
10572 In practice this is applicable only to address clauses, since this is the
10573 only case in which a non-static expression is permitted by the syntax. As
10574 the AARM notes in sections 13.1 (22.a-22.h):
10577 22.a Reason: This is to avoid the following sort of thing:
10579 22.b X : Integer := F(@dots{});
10580 Y : Address := G(@dots{});
10581 for X'Address use Y;
10583 22.c In the above, we have to evaluate the
10584 initialization expression for X before we
10585 know where to put the result. This seems
10586 like an unreasonable implementation burden.
10588 22.d The above code should instead be written
10591 22.e Y : constant Address := G(@dots{});
10592 X : Integer := F(@dots{});
10593 for X'Address use Y;
10595 22.f This allows the expression ``Y'' to be safely
10596 evaluated before X is created.
10598 22.g The constant could be a formal parameter of mode in.
10600 22.h An implementation can support other nonstatic
10601 expressions if it wants to. Expressions of type
10602 Address are hardly ever static, but their value
10603 might be known at compile time anyway in many
10608 GNAT does indeed permit many additional cases of non-static expressions. In
10609 particular, if the type involved is elementary there are no restrictions
10610 (since in this case, holding a temporary copy of the initialization value,
10611 if one is present, is inexpensive). In addition, if there is no implicit or
10612 explicit initialization, then there are no restrictions. GNAT will reject
10613 only the case where all three of these conditions hold:
10618 The type of the item is non-elementary (e.g.@: a record or array).
10621 There is explicit or implicit initialization required for the object.
10622 Note that access values are always implicitly initialized, and also
10623 in GNAT, certain bit-packed arrays (those having a dynamic length or
10624 a length greater than 64) will also be implicitly initialized to zero.
10627 The address value is non-static. Here GNAT is more permissive than the
10628 RM, and allows the address value to be the address of a previously declared
10629 stand-alone variable, as long as it does not itself have an address clause.
10631 @smallexample @c ada
10632 Anchor : Some_Initialized_Type;
10633 Overlay : Some_Initialized_Type;
10634 for Overlay'Address use Anchor'Address;
10638 However, the prefix of the address clause cannot be an array component, or
10639 a component of a discriminated record.
10644 As noted above in section 22.h, address values are typically non-static. In
10645 particular the To_Address function, even if applied to a literal value, is
10646 a non-static function call. To avoid this minor annoyance, GNAT provides
10647 the implementation defined attribute 'To_Address. The following two
10648 expressions have identical values:
10652 @smallexample @c ada
10653 To_Address (16#1234_0000#)
10654 System'To_Address (16#1234_0000#);
10658 except that the second form is considered to be a static expression, and
10659 thus when used as an address clause value is always permitted.
10662 Additionally, GNAT treats as static an address clause that is an
10663 unchecked_conversion of a static integer value. This simplifies the porting
10664 of legacy code, and provides a portable equivalent to the GNAT attribute
10667 Another issue with address clauses is the interaction with alignment
10668 requirements. When an address clause is given for an object, the address
10669 value must be consistent with the alignment of the object (which is usually
10670 the same as the alignment of the type of the object). If an address clause
10671 is given that specifies an inappropriately aligned address value, then the
10672 program execution is erroneous.
10674 Since this source of erroneous behavior can have unfortunate effects, GNAT
10675 checks (at compile time if possible, generating a warning, or at execution
10676 time with a run-time check) that the alignment is appropriate. If the
10677 run-time check fails, then @code{Program_Error} is raised. This run-time
10678 check is suppressed if range checks are suppressed, or if the special GNAT
10679 check Alignment_Check is suppressed, or if
10680 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
10682 Finally, GNAT does not permit overlaying of objects of controlled types or
10683 composite types containing a controlled component. In most cases, the compiler
10684 can detect an attempt at such overlays and will generate a warning at compile
10685 time and a Program_Error exception at run time.
10688 An address clause cannot be given for an exported object. More
10689 understandably the real restriction is that objects with an address
10690 clause cannot be exported. This is because such variables are not
10691 defined by the Ada program, so there is no external object to export.
10694 It is permissible to give an address clause and a pragma Import for the
10695 same object. In this case, the variable is not really defined by the
10696 Ada program, so there is no external symbol to be linked. The link name
10697 and the external name are ignored in this case. The reason that we allow this
10698 combination is that it provides a useful idiom to avoid unwanted
10699 initializations on objects with address clauses.
10701 When an address clause is given for an object that has implicit or
10702 explicit initialization, then by default initialization takes place. This
10703 means that the effect of the object declaration is to overwrite the
10704 memory at the specified address. This is almost always not what the
10705 programmer wants, so GNAT will output a warning:
10715 for Ext'Address use System'To_Address (16#1234_1234#);
10717 >>> warning: implicit initialization of "Ext" may
10718 modify overlaid storage
10719 >>> warning: use pragma Import for "Ext" to suppress
10720 initialization (RM B(24))
10726 As indicated by the warning message, the solution is to use a (dummy) pragma
10727 Import to suppress this initialization. The pragma tell the compiler that the
10728 object is declared and initialized elsewhere. The following package compiles
10729 without warnings (and the initialization is suppressed):
10731 @smallexample @c ada
10739 for Ext'Address use System'To_Address (16#1234_1234#);
10740 pragma Import (Ada, Ext);
10745 A final issue with address clauses involves their use for overlaying
10746 variables, as in the following example:
10747 @cindex Overlaying of objects
10749 @smallexample @c ada
10752 for B'Address use A'Address;
10756 or alternatively, using the form recommended by the RM:
10758 @smallexample @c ada
10760 Addr : constant Address := A'Address;
10762 for B'Address use Addr;
10766 In both of these cases, @code{A}
10767 and @code{B} become aliased to one another via the
10768 address clause. This use of address clauses to overlay
10769 variables, achieving an effect similar to unchecked
10770 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
10771 the effect is implementation defined. Furthermore, the
10772 Ada RM specifically recommends that in a situation
10773 like this, @code{B} should be subject to the following
10774 implementation advice (RM 13.3(19)):
10777 19 If the Address of an object is specified, or it is imported
10778 or exported, then the implementation should not perform
10779 optimizations based on assumptions of no aliases.
10783 GNAT follows this recommendation, and goes further by also applying
10784 this recommendation to the overlaid variable (@code{A}
10785 in the above example) in this case. This means that the overlay
10786 works "as expected", in that a modification to one of the variables
10787 will affect the value of the other.
10789 @node Effect of Convention on Representation
10790 @section Effect of Convention on Representation
10791 @cindex Convention, effect on representation
10794 Normally the specification of a foreign language convention for a type or
10795 an object has no effect on the chosen representation. In particular, the
10796 representation chosen for data in GNAT generally meets the standard system
10797 conventions, and for example records are laid out in a manner that is
10798 consistent with C@. This means that specifying convention C (for example)
10801 There are four exceptions to this general rule:
10805 @item Convention Fortran and array subtypes
10806 If pragma Convention Fortran is specified for an array subtype, then in
10807 accordance with the implementation advice in section 3.6.2(11) of the
10808 Ada Reference Manual, the array will be stored in a Fortran-compatible
10809 column-major manner, instead of the normal default row-major order.
10811 @item Convention C and enumeration types
10812 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
10813 to accommodate all values of the type. For example, for the enumeration
10816 @smallexample @c ada
10817 type Color is (Red, Green, Blue);
10821 8 bits is sufficient to store all values of the type, so by default, objects
10822 of type @code{Color} will be represented using 8 bits. However, normal C
10823 convention is to use 32 bits for all enum values in C, since enum values
10824 are essentially of type int. If pragma @code{Convention C} is specified for an
10825 Ada enumeration type, then the size is modified as necessary (usually to
10826 32 bits) to be consistent with the C convention for enum values.
10828 Note that this treatment applies only to types. If Convention C is given for
10829 an enumeration object, where the enumeration type is not Convention C, then
10830 Object_Size bits are allocated. For example, for a normal enumeration type,
10831 with less than 256 elements, only 8 bits will be allocated for the object.
10832 Since this may be a surprise in terms of what C expects, GNAT will issue a
10833 warning in this situation. The warning can be suppressed by giving an explicit
10834 size clause specifying the desired size.
10836 @item Convention C/Fortran and Boolean types
10837 In C, the usual convention for boolean values, that is values used for
10838 conditions, is that zero represents false, and nonzero values represent
10839 true. In Ada, the normal convention is that two specific values, typically
10840 0/1, are used to represent false/true respectively.
10842 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
10843 value represents true).
10845 To accommodate the Fortran and C conventions, if a pragma Convention specifies
10846 C or Fortran convention for a derived Boolean, as in the following example:
10848 @smallexample @c ada
10849 type C_Switch is new Boolean;
10850 pragma Convention (C, C_Switch);
10854 then the GNAT generated code will treat any nonzero value as true. For truth
10855 values generated by GNAT, the conventional value 1 will be used for True, but
10856 when one of these values is read, any nonzero value is treated as True.
10858 @item Access types on OpenVMS
10859 For 64-bit OpenVMS systems, access types (other than those for unconstrained
10860 arrays) are 64-bits long. An exception to this rule is for the case of
10861 C-convention access types where there is no explicit size clause present (or
10862 inherited for derived types). In this case, GNAT chooses to make these
10863 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
10864 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
10868 @node Determining the Representations chosen by GNAT
10869 @section Determining the Representations chosen by GNAT
10870 @cindex Representation, determination of
10871 @cindex @option{-gnatR} switch
10874 Although the descriptions in this section are intended to be complete, it is
10875 often easier to simply experiment to see what GNAT accepts and what the
10876 effect is on the layout of types and objects.
10878 As required by the Ada RM, if a representation clause is not accepted, then
10879 it must be rejected as illegal by the compiler. However, when a
10880 representation clause or pragma is accepted, there can still be questions
10881 of what the compiler actually does. For example, if a partial record
10882 representation clause specifies the location of some components and not
10883 others, then where are the non-specified components placed? Or if pragma
10884 @code{Pack} is used on a record, then exactly where are the resulting
10885 fields placed? The section on pragma @code{Pack} in this chapter can be
10886 used to answer the second question, but it is often easier to just see
10887 what the compiler does.
10889 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
10890 with this option, then the compiler will output information on the actual
10891 representations chosen, in a format similar to source representation
10892 clauses. For example, if we compile the package:
10894 @smallexample @c ada
10896 type r (x : boolean) is tagged record
10898 when True => S : String (1 .. 100);
10899 when False => null;
10903 type r2 is new r (false) with record
10908 y2 at 16 range 0 .. 31;
10915 type x1 is array (1 .. 10) of x;
10916 for x1'component_size use 11;
10918 type ia is access integer;
10920 type Rb1 is array (1 .. 13) of Boolean;
10923 type Rb2 is array (1 .. 65) of Boolean;
10939 using the switch @option{-gnatR} we obtain the following output:
10942 Representation information for unit q
10943 -------------------------------------
10946 for r'Alignment use 4;
10948 x at 4 range 0 .. 7;
10949 _tag at 0 range 0 .. 31;
10950 s at 5 range 0 .. 799;
10953 for r2'Size use 160;
10954 for r2'Alignment use 4;
10956 x at 4 range 0 .. 7;
10957 _tag at 0 range 0 .. 31;
10958 _parent at 0 range 0 .. 63;
10959 y2 at 16 range 0 .. 31;
10963 for x'Alignment use 1;
10965 y at 0 range 0 .. 7;
10968 for x1'Size use 112;
10969 for x1'Alignment use 1;
10970 for x1'Component_Size use 11;
10972 for rb1'Size use 13;
10973 for rb1'Alignment use 2;
10974 for rb1'Component_Size use 1;
10976 for rb2'Size use 72;
10977 for rb2'Alignment use 1;
10978 for rb2'Component_Size use 1;
10980 for x2'Size use 224;
10981 for x2'Alignment use 4;
10983 l1 at 0 range 0 .. 0;
10984 l2 at 0 range 1 .. 64;
10985 l3 at 12 range 0 .. 31;
10986 l4 at 16 range 0 .. 0;
10987 l5 at 16 range 1 .. 13;
10988 l6 at 18 range 0 .. 71;
10993 The Size values are actually the Object_Size, i.e.@: the default size that
10994 will be allocated for objects of the type.
10995 The ?? size for type r indicates that we have a variant record, and the
10996 actual size of objects will depend on the discriminant value.
10998 The Alignment values show the actual alignment chosen by the compiler
10999 for each record or array type.
11001 The record representation clause for type r shows where all fields
11002 are placed, including the compiler generated tag field (whose location
11003 cannot be controlled by the programmer).
11005 The record representation clause for the type extension r2 shows all the
11006 fields present, including the parent field, which is a copy of the fields
11007 of the parent type of r2, i.e.@: r1.
11009 The component size and size clauses for types rb1 and rb2 show
11010 the exact effect of pragma @code{Pack} on these arrays, and the record
11011 representation clause for type x2 shows how pragma @code{Pack} affects
11014 In some cases, it may be useful to cut and paste the representation clauses
11015 generated by the compiler into the original source to fix and guarantee
11016 the actual representation to be used.
11018 @node Standard Library Routines
11019 @chapter Standard Library Routines
11022 The Ada Reference Manual contains in Annex A a full description of an
11023 extensive set of standard library routines that can be used in any Ada
11024 program, and which must be provided by all Ada compilers. They are
11025 analogous to the standard C library used by C programs.
11027 GNAT implements all of the facilities described in annex A, and for most
11028 purposes the description in the Ada Reference Manual, or appropriate Ada
11029 text book, will be sufficient for making use of these facilities.
11031 In the case of the input-output facilities,
11032 @xref{The Implementation of Standard I/O},
11033 gives details on exactly how GNAT interfaces to the
11034 file system. For the remaining packages, the Ada Reference Manual
11035 should be sufficient. The following is a list of the packages included,
11036 together with a brief description of the functionality that is provided.
11038 For completeness, references are included to other predefined library
11039 routines defined in other sections of the Ada Reference Manual (these are
11040 cross-indexed from Annex A).
11044 This is a parent package for all the standard library packages. It is
11045 usually included implicitly in your program, and itself contains no
11046 useful data or routines.
11048 @item Ada.Calendar (9.6)
11049 @code{Calendar} provides time of day access, and routines for
11050 manipulating times and durations.
11052 @item Ada.Characters (A.3.1)
11053 This is a dummy parent package that contains no useful entities
11055 @item Ada.Characters.Handling (A.3.2)
11056 This package provides some basic character handling capabilities,
11057 including classification functions for classes of characters (e.g.@: test
11058 for letters, or digits).
11060 @item Ada.Characters.Latin_1 (A.3.3)
11061 This package includes a complete set of definitions of the characters
11062 that appear in type CHARACTER@. It is useful for writing programs that
11063 will run in international environments. For example, if you want an
11064 upper case E with an acute accent in a string, it is often better to use
11065 the definition of @code{UC_E_Acute} in this package. Then your program
11066 will print in an understandable manner even if your environment does not
11067 support these extended characters.
11069 @item Ada.Command_Line (A.15)
11070 This package provides access to the command line parameters and the name
11071 of the current program (analogous to the use of @code{argc} and @code{argv}
11072 in C), and also allows the exit status for the program to be set in a
11073 system-independent manner.
11075 @item Ada.Decimal (F.2)
11076 This package provides constants describing the range of decimal numbers
11077 implemented, and also a decimal divide routine (analogous to the COBOL
11078 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11080 @item Ada.Direct_IO (A.8.4)
11081 This package provides input-output using a model of a set of records of
11082 fixed-length, containing an arbitrary definite Ada type, indexed by an
11083 integer record number.
11085 @item Ada.Dynamic_Priorities (D.5)
11086 This package allows the priorities of a task to be adjusted dynamically
11087 as the task is running.
11089 @item Ada.Exceptions (11.4.1)
11090 This package provides additional information on exceptions, and also
11091 contains facilities for treating exceptions as data objects, and raising
11092 exceptions with associated messages.
11094 @item Ada.Finalization (7.6)
11095 This package contains the declarations and subprograms to support the
11096 use of controlled types, providing for automatic initialization and
11097 finalization (analogous to the constructors and destructors of C++)
11099 @item Ada.Interrupts (C.3.2)
11100 This package provides facilities for interfacing to interrupts, which
11101 includes the set of signals or conditions that can be raised and
11102 recognized as interrupts.
11104 @item Ada.Interrupts.Names (C.3.2)
11105 This package provides the set of interrupt names (actually signal
11106 or condition names) that can be handled by GNAT@.
11108 @item Ada.IO_Exceptions (A.13)
11109 This package defines the set of exceptions that can be raised by use of
11110 the standard IO packages.
11113 This package contains some standard constants and exceptions used
11114 throughout the numerics packages. Note that the constants pi and e are
11115 defined here, and it is better to use these definitions than rolling
11118 @item Ada.Numerics.Complex_Elementary_Functions
11119 Provides the implementation of standard elementary functions (such as
11120 log and trigonometric functions) operating on complex numbers using the
11121 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11122 created by the package @code{Numerics.Complex_Types}.
11124 @item Ada.Numerics.Complex_Types
11125 This is a predefined instantiation of
11126 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11127 build the type @code{Complex} and @code{Imaginary}.
11129 @item Ada.Numerics.Discrete_Random
11130 This package provides a random number generator suitable for generating
11131 random integer values from a specified range.
11133 @item Ada.Numerics.Float_Random
11134 This package provides a random number generator suitable for generating
11135 uniformly distributed floating point values.
11137 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11138 This is a generic version of the package that provides the
11139 implementation of standard elementary functions (such as log and
11140 trigonometric functions) for an arbitrary complex type.
11142 The following predefined instantiations of this package are provided:
11146 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11148 @code{Ada.Numerics.Complex_Elementary_Functions}
11150 @code{Ada.Numerics.
11151 Long_Complex_Elementary_Functions}
11154 @item Ada.Numerics.Generic_Complex_Types
11155 This is a generic package that allows the creation of complex types,
11156 with associated complex arithmetic operations.
11158 The following predefined instantiations of this package exist
11161 @code{Ada.Numerics.Short_Complex_Complex_Types}
11163 @code{Ada.Numerics.Complex_Complex_Types}
11165 @code{Ada.Numerics.Long_Complex_Complex_Types}
11168 @item Ada.Numerics.Generic_Elementary_Functions
11169 This is a generic package that provides the implementation of standard
11170 elementary functions (such as log an trigonometric functions) for an
11171 arbitrary float type.
11173 The following predefined instantiations of this package exist
11177 @code{Ada.Numerics.Short_Elementary_Functions}
11179 @code{Ada.Numerics.Elementary_Functions}
11181 @code{Ada.Numerics.Long_Elementary_Functions}
11184 @item Ada.Real_Time (D.8)
11185 This package provides facilities similar to those of @code{Calendar}, but
11186 operating with a finer clock suitable for real time control. Note that
11187 annex D requires that there be no backward clock jumps, and GNAT generally
11188 guarantees this behavior, but of course if the external clock on which
11189 the GNAT runtime depends is deliberately reset by some external event,
11190 then such a backward jump may occur.
11192 @item Ada.Sequential_IO (A.8.1)
11193 This package provides input-output facilities for sequential files,
11194 which can contain a sequence of values of a single type, which can be
11195 any Ada type, including indefinite (unconstrained) types.
11197 @item Ada.Storage_IO (A.9)
11198 This package provides a facility for mapping arbitrary Ada types to and
11199 from a storage buffer. It is primarily intended for the creation of new
11202 @item Ada.Streams (13.13.1)
11203 This is a generic package that provides the basic support for the
11204 concept of streams as used by the stream attributes (@code{Input},
11205 @code{Output}, @code{Read} and @code{Write}).
11207 @item Ada.Streams.Stream_IO (A.12.1)
11208 This package is a specialization of the type @code{Streams} defined in
11209 package @code{Streams} together with a set of operations providing
11210 Stream_IO capability. The Stream_IO model permits both random and
11211 sequential access to a file which can contain an arbitrary set of values
11212 of one or more Ada types.
11214 @item Ada.Strings (A.4.1)
11215 This package provides some basic constants used by the string handling
11218 @item Ada.Strings.Bounded (A.4.4)
11219 This package provides facilities for handling variable length
11220 strings. The bounded model requires a maximum length. It is thus
11221 somewhat more limited than the unbounded model, but avoids the use of
11222 dynamic allocation or finalization.
11224 @item Ada.Strings.Fixed (A.4.3)
11225 This package provides facilities for handling fixed length strings.
11227 @item Ada.Strings.Maps (A.4.2)
11228 This package provides facilities for handling character mappings and
11229 arbitrarily defined subsets of characters. For instance it is useful in
11230 defining specialized translation tables.
11232 @item Ada.Strings.Maps.Constants (A.4.6)
11233 This package provides a standard set of predefined mappings and
11234 predefined character sets. For example, the standard upper to lower case
11235 conversion table is found in this package. Note that upper to lower case
11236 conversion is non-trivial if you want to take the entire set of
11237 characters, including extended characters like E with an acute accent,
11238 into account. You should use the mappings in this package (rather than
11239 adding 32 yourself) to do case mappings.
11241 @item Ada.Strings.Unbounded (A.4.5)
11242 This package provides facilities for handling variable length
11243 strings. The unbounded model allows arbitrary length strings, but
11244 requires the use of dynamic allocation and finalization.
11246 @item Ada.Strings.Wide_Bounded (A.4.7)
11247 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11248 @itemx Ada.Strings.Wide_Maps (A.4.7)
11249 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11250 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11251 These packages provide analogous capabilities to the corresponding
11252 packages without @samp{Wide_} in the name, but operate with the types
11253 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11254 and @code{Character}.
11256 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11257 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11258 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11259 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11260 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11261 These packages provide analogous capabilities to the corresponding
11262 packages without @samp{Wide_} in the name, but operate with the types
11263 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11264 of @code{String} and @code{Character}.
11266 @item Ada.Synchronous_Task_Control (D.10)
11267 This package provides some standard facilities for controlling task
11268 communication in a synchronous manner.
11271 This package contains definitions for manipulation of the tags of tagged
11274 @item Ada.Task_Attributes
11275 This package provides the capability of associating arbitrary
11276 task-specific data with separate tasks.
11279 This package provides basic text input-output capabilities for
11280 character, string and numeric data. The subpackages of this
11281 package are listed next.
11283 @item Ada.Text_IO.Decimal_IO
11284 Provides input-output facilities for decimal fixed-point types
11286 @item Ada.Text_IO.Enumeration_IO
11287 Provides input-output facilities for enumeration types.
11289 @item Ada.Text_IO.Fixed_IO
11290 Provides input-output facilities for ordinary fixed-point types.
11292 @item Ada.Text_IO.Float_IO
11293 Provides input-output facilities for float types. The following
11294 predefined instantiations of this generic package are available:
11298 @code{Short_Float_Text_IO}
11300 @code{Float_Text_IO}
11302 @code{Long_Float_Text_IO}
11305 @item Ada.Text_IO.Integer_IO
11306 Provides input-output facilities for integer types. The following
11307 predefined instantiations of this generic package are available:
11310 @item Short_Short_Integer
11311 @code{Ada.Short_Short_Integer_Text_IO}
11312 @item Short_Integer
11313 @code{Ada.Short_Integer_Text_IO}
11315 @code{Ada.Integer_Text_IO}
11317 @code{Ada.Long_Integer_Text_IO}
11318 @item Long_Long_Integer
11319 @code{Ada.Long_Long_Integer_Text_IO}
11322 @item Ada.Text_IO.Modular_IO
11323 Provides input-output facilities for modular (unsigned) types
11325 @item Ada.Text_IO.Complex_IO (G.1.3)
11326 This package provides basic text input-output capabilities for complex
11329 @item Ada.Text_IO.Editing (F.3.3)
11330 This package contains routines for edited output, analogous to the use
11331 of pictures in COBOL@. The picture formats used by this package are a
11332 close copy of the facility in COBOL@.
11334 @item Ada.Text_IO.Text_Streams (A.12.2)
11335 This package provides a facility that allows Text_IO files to be treated
11336 as streams, so that the stream attributes can be used for writing
11337 arbitrary data, including binary data, to Text_IO files.
11339 @item Ada.Unchecked_Conversion (13.9)
11340 This generic package allows arbitrary conversion from one type to
11341 another of the same size, providing for breaking the type safety in
11342 special circumstances.
11344 If the types have the same Size (more accurately the same Value_Size),
11345 then the effect is simply to transfer the bits from the source to the
11346 target type without any modification. This usage is well defined, and
11347 for simple types whose representation is typically the same across
11348 all implementations, gives a portable method of performing such
11351 If the types do not have the same size, then the result is implementation
11352 defined, and thus may be non-portable. The following describes how GNAT
11353 handles such unchecked conversion cases.
11355 If the types are of different sizes, and are both discrete types, then
11356 the effect is of a normal type conversion without any constraint checking.
11357 In particular if the result type has a larger size, the result will be
11358 zero or sign extended. If the result type has a smaller size, the result
11359 will be truncated by ignoring high order bits.
11361 If the types are of different sizes, and are not both discrete types,
11362 then the conversion works as though pointers were created to the source
11363 and target, and the pointer value is converted. The effect is that bits
11364 are copied from successive low order storage units and bits of the source
11365 up to the length of the target type.
11367 A warning is issued if the lengths differ, since the effect in this
11368 case is implementation dependent, and the above behavior may not match
11369 that of some other compiler.
11371 A pointer to one type may be converted to a pointer to another type using
11372 unchecked conversion. The only case in which the effect is undefined is
11373 when one or both pointers are pointers to unconstrained array types. In
11374 this case, the bounds information may get incorrectly transferred, and in
11375 particular, GNAT uses double size pointers for such types, and it is
11376 meaningless to convert between such pointer types. GNAT will issue a
11377 warning if the alignment of the target designated type is more strict
11378 than the alignment of the source designated type (since the result may
11379 be unaligned in this case).
11381 A pointer other than a pointer to an unconstrained array type may be
11382 converted to and from System.Address. Such usage is common in Ada 83
11383 programs, but note that Ada.Address_To_Access_Conversions is the
11384 preferred method of performing such conversions in Ada 95 and Ada 2005.
11386 unchecked conversion nor Ada.Address_To_Access_Conversions should be
11387 used in conjunction with pointers to unconstrained objects, since
11388 the bounds information cannot be handled correctly in this case.
11390 @item Ada.Unchecked_Deallocation (13.11.2)
11391 This generic package allows explicit freeing of storage previously
11392 allocated by use of an allocator.
11394 @item Ada.Wide_Text_IO (A.11)
11395 This package is similar to @code{Ada.Text_IO}, except that the external
11396 file supports wide character representations, and the internal types are
11397 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11398 and @code{String}. It contains generic subpackages listed next.
11400 @item Ada.Wide_Text_IO.Decimal_IO
11401 Provides input-output facilities for decimal fixed-point types
11403 @item Ada.Wide_Text_IO.Enumeration_IO
11404 Provides input-output facilities for enumeration types.
11406 @item Ada.Wide_Text_IO.Fixed_IO
11407 Provides input-output facilities for ordinary fixed-point types.
11409 @item Ada.Wide_Text_IO.Float_IO
11410 Provides input-output facilities for float types. The following
11411 predefined instantiations of this generic package are available:
11415 @code{Short_Float_Wide_Text_IO}
11417 @code{Float_Wide_Text_IO}
11419 @code{Long_Float_Wide_Text_IO}
11422 @item Ada.Wide_Text_IO.Integer_IO
11423 Provides input-output facilities for integer types. The following
11424 predefined instantiations of this generic package are available:
11427 @item Short_Short_Integer
11428 @code{Ada.Short_Short_Integer_Wide_Text_IO}
11429 @item Short_Integer
11430 @code{Ada.Short_Integer_Wide_Text_IO}
11432 @code{Ada.Integer_Wide_Text_IO}
11434 @code{Ada.Long_Integer_Wide_Text_IO}
11435 @item Long_Long_Integer
11436 @code{Ada.Long_Long_Integer_Wide_Text_IO}
11439 @item Ada.Wide_Text_IO.Modular_IO
11440 Provides input-output facilities for modular (unsigned) types
11442 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
11443 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11444 external file supports wide character representations.
11446 @item Ada.Wide_Text_IO.Editing (F.3.4)
11447 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11448 types are @code{Wide_Character} and @code{Wide_String} instead of
11449 @code{Character} and @code{String}.
11451 @item Ada.Wide_Text_IO.Streams (A.12.3)
11452 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11453 types are @code{Wide_Character} and @code{Wide_String} instead of
11454 @code{Character} and @code{String}.
11456 @item Ada.Wide_Wide_Text_IO (A.11)
11457 This package is similar to @code{Ada.Text_IO}, except that the external
11458 file supports wide character representations, and the internal types are
11459 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11460 and @code{String}. It contains generic subpackages listed next.
11462 @item Ada.Wide_Wide_Text_IO.Decimal_IO
11463 Provides input-output facilities for decimal fixed-point types
11465 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
11466 Provides input-output facilities for enumeration types.
11468 @item Ada.Wide_Wide_Text_IO.Fixed_IO
11469 Provides input-output facilities for ordinary fixed-point types.
11471 @item Ada.Wide_Wide_Text_IO.Float_IO
11472 Provides input-output facilities for float types. The following
11473 predefined instantiations of this generic package are available:
11477 @code{Short_Float_Wide_Wide_Text_IO}
11479 @code{Float_Wide_Wide_Text_IO}
11481 @code{Long_Float_Wide_Wide_Text_IO}
11484 @item Ada.Wide_Wide_Text_IO.Integer_IO
11485 Provides input-output facilities for integer types. The following
11486 predefined instantiations of this generic package are available:
11489 @item Short_Short_Integer
11490 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
11491 @item Short_Integer
11492 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
11494 @code{Ada.Integer_Wide_Wide_Text_IO}
11496 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
11497 @item Long_Long_Integer
11498 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
11501 @item Ada.Wide_Wide_Text_IO.Modular_IO
11502 Provides input-output facilities for modular (unsigned) types
11504 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
11505 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11506 external file supports wide character representations.
11508 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
11509 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11510 types are @code{Wide_Character} and @code{Wide_String} instead of
11511 @code{Character} and @code{String}.
11513 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
11514 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11515 types are @code{Wide_Character} and @code{Wide_String} instead of
11516 @code{Character} and @code{String}.
11521 @node The Implementation of Standard I/O
11522 @chapter The Implementation of Standard I/O
11525 GNAT implements all the required input-output facilities described in
11526 A.6 through A.14. These sections of the Ada Reference Manual describe the
11527 required behavior of these packages from the Ada point of view, and if
11528 you are writing a portable Ada program that does not need to know the
11529 exact manner in which Ada maps to the outside world when it comes to
11530 reading or writing external files, then you do not need to read this
11531 chapter. As long as your files are all regular files (not pipes or
11532 devices), and as long as you write and read the files only from Ada, the
11533 description in the Ada Reference Manual is sufficient.
11535 However, if you want to do input-output to pipes or other devices, such
11536 as the keyboard or screen, or if the files you are dealing with are
11537 either generated by some other language, or to be read by some other
11538 language, then you need to know more about the details of how the GNAT
11539 implementation of these input-output facilities behaves.
11541 In this chapter we give a detailed description of exactly how GNAT
11542 interfaces to the file system. As always, the sources of the system are
11543 available to you for answering questions at an even more detailed level,
11544 but for most purposes the information in this chapter will suffice.
11546 Another reason that you may need to know more about how input-output is
11547 implemented arises when you have a program written in mixed languages
11548 where, for example, files are shared between the C and Ada sections of
11549 the same program. GNAT provides some additional facilities, in the form
11550 of additional child library packages, that facilitate this sharing, and
11551 these additional facilities are also described in this chapter.
11554 * Standard I/O Packages::
11560 * Wide_Wide_Text_IO::
11563 * Filenames encoding::
11565 * Operations on C Streams::
11566 * Interfacing to C Streams::
11569 @node Standard I/O Packages
11570 @section Standard I/O Packages
11573 The Standard I/O packages described in Annex A for
11579 Ada.Text_IO.Complex_IO
11581 Ada.Text_IO.Text_Streams
11585 Ada.Wide_Text_IO.Complex_IO
11587 Ada.Wide_Text_IO.Text_Streams
11589 Ada.Wide_Wide_Text_IO
11591 Ada.Wide_Wide_Text_IO.Complex_IO
11593 Ada.Wide_Wide_Text_IO.Text_Streams
11603 are implemented using the C
11604 library streams facility; where
11608 All files are opened using @code{fopen}.
11610 All input/output operations use @code{fread}/@code{fwrite}.
11614 There is no internal buffering of any kind at the Ada library level. The only
11615 buffering is that provided at the system level in the implementation of the
11616 library routines that support streams. This facilitates shared use of these
11617 streams by mixed language programs. Note though that system level buffering is
11618 explicitly enabled at elaboration of the standard I/O packages and that can
11619 have an impact on mixed language programs, in particular those using I/O before
11620 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
11621 the Ada elaboration routine before performing any I/O or when impractical,
11622 flush the common I/O streams and in particular Standard_Output before
11623 elaborating the Ada code.
11626 @section FORM Strings
11629 The format of a FORM string in GNAT is:
11632 "keyword=value,keyword=value,@dots{},keyword=value"
11636 where letters may be in upper or lower case, and there are no spaces
11637 between values. The order of the entries is not important. Currently
11638 there are two keywords defined.
11642 WCEM=[n|h|u|s|e|8|b]
11646 The use of these parameters is described later in this section.
11652 Direct_IO can only be instantiated for definite types. This is a
11653 restriction of the Ada language, which means that the records are fixed
11654 length (the length being determined by @code{@var{type}'Size}, rounded
11655 up to the next storage unit boundary if necessary).
11657 The records of a Direct_IO file are simply written to the file in index
11658 sequence, with the first record starting at offset zero, and subsequent
11659 records following. There is no control information of any kind. For
11660 example, if 32-bit integers are being written, each record takes
11661 4-bytes, so the record at index @var{K} starts at offset
11662 (@var{K}@minus{}1)*4.
11664 There is no limit on the size of Direct_IO files, they are expanded as
11665 necessary to accommodate whatever records are written to the file.
11667 @node Sequential_IO
11668 @section Sequential_IO
11671 Sequential_IO may be instantiated with either a definite (constrained)
11672 or indefinite (unconstrained) type.
11674 For the definite type case, the elements written to the file are simply
11675 the memory images of the data values with no control information of any
11676 kind. The resulting file should be read using the same type, no validity
11677 checking is performed on input.
11679 For the indefinite type case, the elements written consist of two
11680 parts. First is the size of the data item, written as the memory image
11681 of a @code{Interfaces.C.size_t} value, followed by the memory image of
11682 the data value. The resulting file can only be read using the same
11683 (unconstrained) type. Normal assignment checks are performed on these
11684 read operations, and if these checks fail, @code{Data_Error} is
11685 raised. In particular, in the array case, the lengths must match, and in
11686 the variant record case, if the variable for a particular read operation
11687 is constrained, the discriminants must match.
11689 Note that it is not possible to use Sequential_IO to write variable
11690 length array items, and then read the data back into different length
11691 arrays. For example, the following will raise @code{Data_Error}:
11693 @smallexample @c ada
11694 package IO is new Sequential_IO (String);
11699 IO.Write (F, "hello!")
11700 IO.Reset (F, Mode=>In_File);
11707 On some Ada implementations, this will print @code{hell}, but the program is
11708 clearly incorrect, since there is only one element in the file, and that
11709 element is the string @code{hello!}.
11711 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
11712 using Stream_IO, and this is the preferred mechanism. In particular, the
11713 above program fragment rewritten to use Stream_IO will work correctly.
11719 Text_IO files consist of a stream of characters containing the following
11720 special control characters:
11723 LF (line feed, 16#0A#) Line Mark
11724 FF (form feed, 16#0C#) Page Mark
11728 A canonical Text_IO file is defined as one in which the following
11729 conditions are met:
11733 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
11737 The character @code{FF} is used only as a page mark, i.e.@: to mark the
11738 end of a page and consequently can appear only immediately following a
11739 @code{LF} (line mark) character.
11742 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
11743 (line mark, page mark). In the former case, the page mark is implicitly
11744 assumed to be present.
11748 A file written using Text_IO will be in canonical form provided that no
11749 explicit @code{LF} or @code{FF} characters are written using @code{Put}
11750 or @code{Put_Line}. There will be no @code{FF} character at the end of
11751 the file unless an explicit @code{New_Page} operation was performed
11752 before closing the file.
11754 A canonical Text_IO file that is a regular file (i.e., not a device or a
11755 pipe) can be read using any of the routines in Text_IO@. The
11756 semantics in this case will be exactly as defined in the Ada Reference
11757 Manual, and all the routines in Text_IO are fully implemented.
11759 A text file that does not meet the requirements for a canonical Text_IO
11760 file has one of the following:
11764 The file contains @code{FF} characters not immediately following a
11765 @code{LF} character.
11768 The file contains @code{LF} or @code{FF} characters written by
11769 @code{Put} or @code{Put_Line}, which are not logically considered to be
11770 line marks or page marks.
11773 The file ends in a character other than @code{LF} or @code{FF},
11774 i.e.@: there is no explicit line mark or page mark at the end of the file.
11778 Text_IO can be used to read such non-standard text files but subprograms
11779 to do with line or page numbers do not have defined meanings. In
11780 particular, a @code{FF} character that does not follow a @code{LF}
11781 character may or may not be treated as a page mark from the point of
11782 view of page and line numbering. Every @code{LF} character is considered
11783 to end a line, and there is an implied @code{LF} character at the end of
11787 * Text_IO Stream Pointer Positioning::
11788 * Text_IO Reading and Writing Non-Regular Files::
11790 * Treating Text_IO Files as Streams::
11791 * Text_IO Extensions::
11792 * Text_IO Facilities for Unbounded Strings::
11795 @node Text_IO Stream Pointer Positioning
11796 @subsection Stream Pointer Positioning
11799 @code{Ada.Text_IO} has a definition of current position for a file that
11800 is being read. No internal buffering occurs in Text_IO, and usually the
11801 physical position in the stream used to implement the file corresponds
11802 to this logical position defined by Text_IO@. There are two exceptions:
11806 After a call to @code{End_Of_Page} that returns @code{True}, the stream
11807 is positioned past the @code{LF} (line mark) that precedes the page
11808 mark. Text_IO maintains an internal flag so that subsequent read
11809 operations properly handle the logical position which is unchanged by
11810 the @code{End_Of_Page} call.
11813 After a call to @code{End_Of_File} that returns @code{True}, if the
11814 Text_IO file was positioned before the line mark at the end of file
11815 before the call, then the logical position is unchanged, but the stream
11816 is physically positioned right at the end of file (past the line mark,
11817 and past a possible page mark following the line mark. Again Text_IO
11818 maintains internal flags so that subsequent read operations properly
11819 handle the logical position.
11823 These discrepancies have no effect on the observable behavior of
11824 Text_IO, but if a single Ada stream is shared between a C program and
11825 Ada program, or shared (using @samp{shared=yes} in the form string)
11826 between two Ada files, then the difference may be observable in some
11829 @node Text_IO Reading and Writing Non-Regular Files
11830 @subsection Reading and Writing Non-Regular Files
11833 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
11834 can be used for reading and writing. Writing is not affected and the
11835 sequence of characters output is identical to the normal file case, but
11836 for reading, the behavior of Text_IO is modified to avoid undesirable
11837 look-ahead as follows:
11839 An input file that is not a regular file is considered to have no page
11840 marks. Any @code{Ascii.FF} characters (the character normally used for a
11841 page mark) appearing in the file are considered to be data
11842 characters. In particular:
11846 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
11847 following a line mark. If a page mark appears, it will be treated as a
11851 This avoids the need to wait for an extra character to be typed or
11852 entered from the pipe to complete one of these operations.
11855 @code{End_Of_Page} always returns @code{False}
11858 @code{End_Of_File} will return @code{False} if there is a page mark at
11859 the end of the file.
11863 Output to non-regular files is the same as for regular files. Page marks
11864 may be written to non-regular files using @code{New_Page}, but as noted
11865 above they will not be treated as page marks on input if the output is
11866 piped to another Ada program.
11868 Another important discrepancy when reading non-regular files is that the end
11869 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
11870 pressing the @key{EOT} key,
11872 is signaled once (i.e.@: the test @code{End_Of_File}
11873 will yield @code{True}, or a read will
11874 raise @code{End_Error}), but then reading can resume
11875 to read data past that end of
11876 file indication, until another end of file indication is entered.
11878 @node Get_Immediate
11879 @subsection Get_Immediate
11880 @cindex Get_Immediate
11883 Get_Immediate returns the next character (including control characters)
11884 from the input file. In particular, Get_Immediate will return LF or FF
11885 characters used as line marks or page marks. Such operations leave the
11886 file positioned past the control character, and it is thus not treated
11887 as having its normal function. This means that page, line and column
11888 counts after this kind of Get_Immediate call are set as though the mark
11889 did not occur. In the case where a Get_Immediate leaves the file
11890 positioned between the line mark and page mark (which is not normally
11891 possible), it is undefined whether the FF character will be treated as a
11894 @node Treating Text_IO Files as Streams
11895 @subsection Treating Text_IO Files as Streams
11896 @cindex Stream files
11899 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
11900 as a stream. Data written to a Text_IO file in this stream mode is
11901 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
11902 16#0C# (@code{FF}), the resulting file may have non-standard
11903 format. Similarly if read operations are used to read from a Text_IO
11904 file treated as a stream, then @code{LF} and @code{FF} characters may be
11905 skipped and the effect is similar to that described above for
11906 @code{Get_Immediate}.
11908 @node Text_IO Extensions
11909 @subsection Text_IO Extensions
11910 @cindex Text_IO extensions
11913 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
11914 to the standard @code{Text_IO} package:
11917 @item function File_Exists (Name : String) return Boolean;
11918 Determines if a file of the given name exists.
11920 @item function Get_Line return String;
11921 Reads a string from the standard input file. The value returned is exactly
11922 the length of the line that was read.
11924 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
11925 Similar, except that the parameter File specifies the file from which
11926 the string is to be read.
11930 @node Text_IO Facilities for Unbounded Strings
11931 @subsection Text_IO Facilities for Unbounded Strings
11932 @cindex Text_IO for unbounded strings
11933 @cindex Unbounded_String, Text_IO operations
11936 The package @code{Ada.Strings.Unbounded.Text_IO}
11937 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
11938 subprograms useful for Text_IO operations on unbounded strings:
11942 @item function Get_Line (File : File_Type) return Unbounded_String;
11943 Reads a line from the specified file
11944 and returns the result as an unbounded string.
11946 @item procedure Put (File : File_Type; U : Unbounded_String);
11947 Writes the value of the given unbounded string to the specified file
11948 Similar to the effect of
11949 @code{Put (To_String (U))} except that an extra copy is avoided.
11951 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
11952 Writes the value of the given unbounded string to the specified file,
11953 followed by a @code{New_Line}.
11954 Similar to the effect of @code{Put_Line (To_String (U))} except
11955 that an extra copy is avoided.
11959 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
11960 and is optional. If the parameter is omitted, then the standard input or
11961 output file is referenced as appropriate.
11963 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
11964 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
11965 @code{Wide_Text_IO} functionality for unbounded wide strings.
11967 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
11968 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
11969 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
11972 @section Wide_Text_IO
11975 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
11976 both input and output files may contain special sequences that represent
11977 wide character values. The encoding scheme for a given file may be
11978 specified using a FORM parameter:
11985 as part of the FORM string (WCEM = wide character encoding method),
11986 where @var{x} is one of the following characters
11992 Upper half encoding
12004 The encoding methods match those that
12005 can be used in a source
12006 program, but there is no requirement that the encoding method used for
12007 the source program be the same as the encoding method used for files,
12008 and different files may use different encoding methods.
12010 The default encoding method for the standard files, and for opened files
12011 for which no WCEM parameter is given in the FORM string matches the
12012 wide character encoding specified for the main program (the default
12013 being brackets encoding if no coding method was specified with -gnatW).
12017 In this encoding, a wide character is represented by a five character
12025 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12026 characters (using upper case letters) of the wide character code. For
12027 example, ESC A345 is used to represent the wide character with code
12028 16#A345#. This scheme is compatible with use of the full
12029 @code{Wide_Character} set.
12031 @item Upper Half Coding
12032 The wide character with encoding 16#abcd#, where the upper bit is on
12033 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12034 16#cd#. The second byte may never be a format control character, but is
12035 not required to be in the upper half. This method can be also used for
12036 shift-JIS or EUC where the internal coding matches the external coding.
12038 @item Shift JIS Coding
12039 A wide character is represented by a two character sequence 16#ab# and
12040 16#cd#, with the restrictions described for upper half encoding as
12041 described above. The internal character code is the corresponding JIS
12042 character according to the standard algorithm for Shift-JIS
12043 conversion. Only characters defined in the JIS code set table can be
12044 used with this encoding method.
12047 A wide character is represented by a two character sequence 16#ab# and
12048 16#cd#, with both characters being in the upper half. The internal
12049 character code is the corresponding JIS character according to the EUC
12050 encoding algorithm. Only characters defined in the JIS code set table
12051 can be used with this encoding method.
12054 A wide character is represented using
12055 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12056 10646-1/Am.2. Depending on the character value, the representation
12057 is a one, two, or three byte sequence:
12060 16#0000#-16#007f#: 2#0xxxxxxx#
12061 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12062 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12066 where the @var{xxx} bits correspond to the left-padded bits of the
12067 16-bit character value. Note that all lower half ASCII characters
12068 are represented as ASCII bytes and all upper half characters and
12069 other wide characters are represented as sequences of upper-half
12070 (The full UTF-8 scheme allows for encoding 31-bit characters as
12071 6-byte sequences, but in this implementation, all UTF-8 sequences
12072 of four or more bytes length will raise a Constraint_Error, as
12073 will all invalid UTF-8 sequences.)
12075 @item Brackets Coding
12076 In this encoding, a wide character is represented by the following eight
12077 character sequence:
12084 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12085 characters (using uppercase letters) of the wide character code. For
12086 example, @code{["A345"]} is used to represent the wide character with code
12088 This scheme is compatible with use of the full Wide_Character set.
12089 On input, brackets coding can also be used for upper half characters,
12090 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12091 is only used for wide characters with a code greater than @code{16#FF#}.
12093 Note that brackets coding is not normally used in the context of
12094 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12095 a portable way of encoding source files. In the context of Wide_Text_IO
12096 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12097 any instance of the left bracket character other than to encode wide
12098 character values using the brackets encoding method. In practice it is
12099 expected that some standard wide character encoding method such
12100 as UTF-8 will be used for text input output.
12102 If brackets notation is used, then any occurrence of a left bracket
12103 in the input file which is not the start of a valid wide character
12104 sequence will cause Constraint_Error to be raised. It is possible to
12105 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12106 input will interpret this as a left bracket.
12108 However, when a left bracket is output, it will be output as a left bracket
12109 and not as ["5B"]. We make this decision because for normal use of
12110 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12111 brackets. For example, if we write:
12114 Put_Line ("Start of output [first run]");
12118 we really do not want to have the left bracket in this message clobbered so
12119 that the output reads:
12122 Start of output ["5B"]first run]
12126 In practice brackets encoding is reasonably useful for normal Put_Line use
12127 since we won't get confused between left brackets and wide character
12128 sequences in the output. But for input, or when files are written out
12129 and read back in, it really makes better sense to use one of the standard
12130 encoding methods such as UTF-8.
12135 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12136 not all wide character
12137 values can be represented. An attempt to output a character that cannot
12138 be represented using the encoding scheme for the file causes
12139 Constraint_Error to be raised. An invalid wide character sequence on
12140 input also causes Constraint_Error to be raised.
12143 * Wide_Text_IO Stream Pointer Positioning::
12144 * Wide_Text_IO Reading and Writing Non-Regular Files::
12147 @node Wide_Text_IO Stream Pointer Positioning
12148 @subsection Stream Pointer Positioning
12151 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12152 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12155 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12156 normal lower ASCII set (i.e.@: a character in the range:
12158 @smallexample @c ada
12159 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12163 then although the logical position of the file pointer is unchanged by
12164 the @code{Look_Ahead} call, the stream is physically positioned past the
12165 wide character sequence. Again this is to avoid the need for buffering
12166 or backup, and all @code{Wide_Text_IO} routines check the internal
12167 indication that this situation has occurred so that this is not visible
12168 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
12169 can be observed if the wide text file shares a stream with another file.
12171 @node Wide_Text_IO Reading and Writing Non-Regular Files
12172 @subsection Reading and Writing Non-Regular Files
12175 As in the case of Text_IO, when a non-regular file is read, it is
12176 assumed that the file contains no page marks (any form characters are
12177 treated as data characters), and @code{End_Of_Page} always returns
12178 @code{False}. Similarly, the end of file indication is not sticky, so
12179 it is possible to read beyond an end of file.
12181 @node Wide_Wide_Text_IO
12182 @section Wide_Wide_Text_IO
12185 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12186 both input and output files may contain special sequences that represent
12187 wide wide character values. The encoding scheme for a given file may be
12188 specified using a FORM parameter:
12195 as part of the FORM string (WCEM = wide character encoding method),
12196 where @var{x} is one of the following characters
12202 Upper half encoding
12214 The encoding methods match those that
12215 can be used in a source
12216 program, but there is no requirement that the encoding method used for
12217 the source program be the same as the encoding method used for files,
12218 and different files may use different encoding methods.
12220 The default encoding method for the standard files, and for opened files
12221 for which no WCEM parameter is given in the FORM string matches the
12222 wide character encoding specified for the main program (the default
12223 being brackets encoding if no coding method was specified with -gnatW).
12228 A wide character is represented using
12229 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12230 10646-1/Am.2. Depending on the character value, the representation
12231 is a one, two, three, or four byte sequence:
12234 16#000000#-16#00007f#: 2#0xxxxxxx#
12235 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12236 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12237 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12241 where the @var{xxx} bits correspond to the left-padded bits of the
12242 21-bit character value. Note that all lower half ASCII characters
12243 are represented as ASCII bytes and all upper half characters and
12244 other wide characters are represented as sequences of upper-half
12247 @item Brackets Coding
12248 In this encoding, a wide wide character is represented by the following eight
12249 character sequence if is in wide character range
12255 and by the following ten character sequence if not
12258 [ " a b c d e f " ]
12262 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12263 are the four or six hexadecimal
12264 characters (using uppercase letters) of the wide wide character code. For
12265 example, @code{["01A345"]} is used to represent the wide wide character
12266 with code @code{16#01A345#}.
12268 This scheme is compatible with use of the full Wide_Wide_Character set.
12269 On input, brackets coding can also be used for upper half characters,
12270 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12271 is only used for wide characters with a code greater than @code{16#FF#}.
12276 If is also possible to use the other Wide_Character encoding methods,
12277 such as Shift-JIS, but the other schemes cannot support the full range
12278 of wide wide characters.
12279 An attempt to output a character that cannot
12280 be represented using the encoding scheme for the file causes
12281 Constraint_Error to be raised. An invalid wide character sequence on
12282 input also causes Constraint_Error to be raised.
12285 * Wide_Wide_Text_IO Stream Pointer Positioning::
12286 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12289 @node Wide_Wide_Text_IO Stream Pointer Positioning
12290 @subsection Stream Pointer Positioning
12293 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12294 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12297 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12298 normal lower ASCII set (i.e.@: a character in the range:
12300 @smallexample @c ada
12301 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12305 then although the logical position of the file pointer is unchanged by
12306 the @code{Look_Ahead} call, the stream is physically positioned past the
12307 wide character sequence. Again this is to avoid the need for buffering
12308 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
12309 indication that this situation has occurred so that this is not visible
12310 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
12311 can be observed if the wide text file shares a stream with another file.
12313 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
12314 @subsection Reading and Writing Non-Regular Files
12317 As in the case of Text_IO, when a non-regular file is read, it is
12318 assumed that the file contains no page marks (any form characters are
12319 treated as data characters), and @code{End_Of_Page} always returns
12320 @code{False}. Similarly, the end of file indication is not sticky, so
12321 it is possible to read beyond an end of file.
12327 A stream file is a sequence of bytes, where individual elements are
12328 written to the file as described in the Ada Reference Manual. The type
12329 @code{Stream_Element} is simply a byte. There are two ways to read or
12330 write a stream file.
12334 The operations @code{Read} and @code{Write} directly read or write a
12335 sequence of stream elements with no control information.
12338 The stream attributes applied to a stream file transfer data in the
12339 manner described for stream attributes.
12343 @section Shared Files
12346 Section A.14 of the Ada Reference Manual allows implementations to
12347 provide a wide variety of behavior if an attempt is made to access the
12348 same external file with two or more internal files.
12350 To provide a full range of functionality, while at the same time
12351 minimizing the problems of portability caused by this implementation
12352 dependence, GNAT handles file sharing as follows:
12356 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
12357 to open two or more files with the same full name is considered an error
12358 and is not supported. The exception @code{Use_Error} will be
12359 raised. Note that a file that is not explicitly closed by the program
12360 remains open until the program terminates.
12363 If the form parameter @samp{shared=no} appears in the form string, the
12364 file can be opened or created with its own separate stream identifier,
12365 regardless of whether other files sharing the same external file are
12366 opened. The exact effect depends on how the C stream routines handle
12367 multiple accesses to the same external files using separate streams.
12370 If the form parameter @samp{shared=yes} appears in the form string for
12371 each of two or more files opened using the same full name, the same
12372 stream is shared between these files, and the semantics are as described
12373 in Ada Reference Manual, Section A.14.
12377 When a program that opens multiple files with the same name is ported
12378 from another Ada compiler to GNAT, the effect will be that
12379 @code{Use_Error} is raised.
12381 The documentation of the original compiler and the documentation of the
12382 program should then be examined to determine if file sharing was
12383 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
12384 and @code{Create} calls as required.
12386 When a program is ported from GNAT to some other Ada compiler, no
12387 special attention is required unless the @samp{shared=@var{xxx}} form
12388 parameter is used in the program. In this case, you must examine the
12389 documentation of the new compiler to see if it supports the required
12390 file sharing semantics, and form strings modified appropriately. Of
12391 course it may be the case that the program cannot be ported if the
12392 target compiler does not support the required functionality. The best
12393 approach in writing portable code is to avoid file sharing (and hence
12394 the use of the @samp{shared=@var{xxx}} parameter in the form string)
12397 One common use of file sharing in Ada 83 is the use of instantiations of
12398 Sequential_IO on the same file with different types, to achieve
12399 heterogeneous input-output. Although this approach will work in GNAT if
12400 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
12401 for this purpose (using the stream attributes)
12403 @node Filenames encoding
12404 @section Filenames encoding
12407 An encoding form parameter can be used to specify the filename
12408 encoding @samp{encoding=@var{xxx}}.
12412 If the form parameter @samp{encoding=utf8} appears in the form string, the
12413 filename must be encoded in UTF-8.
12416 If the form parameter @samp{encoding=8bits} appears in the form
12417 string, the filename must be a standard 8bits string.
12420 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
12421 value UTF-8 is used. This encoding form parameter is only supported on
12422 the Windows platform. On the other Operating Systems the runtime is
12423 supporting UTF-8 natively.
12426 @section Open Modes
12429 @code{Open} and @code{Create} calls result in a call to @code{fopen}
12430 using the mode shown in the following table:
12433 @center @code{Open} and @code{Create} Call Modes
12435 @b{OPEN } @b{CREATE}
12436 Append_File "r+" "w+"
12438 Out_File (Direct_IO) "r+" "w"
12439 Out_File (all other cases) "w" "w"
12440 Inout_File "r+" "w+"
12444 If text file translation is required, then either @samp{b} or @samp{t}
12445 is added to the mode, depending on the setting of Text. Text file
12446 translation refers to the mapping of CR/LF sequences in an external file
12447 to LF characters internally. This mapping only occurs in DOS and
12448 DOS-like systems, and is not relevant to other systems.
12450 A special case occurs with Stream_IO@. As shown in the above table, the
12451 file is initially opened in @samp{r} or @samp{w} mode for the
12452 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
12453 subsequently requires switching from reading to writing or vice-versa,
12454 then the file is reopened in @samp{r+} mode to permit the required operation.
12456 @node Operations on C Streams
12457 @section Operations on C Streams
12458 The package @code{Interfaces.C_Streams} provides an Ada program with direct
12459 access to the C library functions for operations on C streams:
12461 @smallexample @c adanocomment
12462 package Interfaces.C_Streams is
12463 -- Note: the reason we do not use the types that are in
12464 -- Interfaces.C is that we want to avoid dragging in the
12465 -- code in this unit if possible.
12466 subtype chars is System.Address;
12467 -- Pointer to null-terminated array of characters
12468 subtype FILEs is System.Address;
12469 -- Corresponds to the C type FILE*
12470 subtype voids is System.Address;
12471 -- Corresponds to the C type void*
12472 subtype int is Integer;
12473 subtype long is Long_Integer;
12474 -- Note: the above types are subtypes deliberately, and it
12475 -- is part of this spec that the above correspondences are
12476 -- guaranteed. This means that it is legitimate to, for
12477 -- example, use Integer instead of int. We provide these
12478 -- synonyms for clarity, but in some cases it may be
12479 -- convenient to use the underlying types (for example to
12480 -- avoid an unnecessary dependency of a spec on the spec
12482 type size_t is mod 2 ** Standard'Address_Size;
12483 NULL_Stream : constant FILEs;
12484 -- Value returned (NULL in C) to indicate an
12485 -- fdopen/fopen/tmpfile error
12486 ----------------------------------
12487 -- Constants Defined in stdio.h --
12488 ----------------------------------
12489 EOF : constant int;
12490 -- Used by a number of routines to indicate error or
12492 IOFBF : constant int;
12493 IOLBF : constant int;
12494 IONBF : constant int;
12495 -- Used to indicate buffering mode for setvbuf call
12496 SEEK_CUR : constant int;
12497 SEEK_END : constant int;
12498 SEEK_SET : constant int;
12499 -- Used to indicate origin for fseek call
12500 function stdin return FILEs;
12501 function stdout return FILEs;
12502 function stderr return FILEs;
12503 -- Streams associated with standard files
12504 --------------------------
12505 -- Standard C functions --
12506 --------------------------
12507 -- The functions selected below are ones that are
12508 -- available in DOS, OS/2, UNIX and Xenix (but not
12509 -- necessarily in ANSI C). These are very thin interfaces
12510 -- which copy exactly the C headers. For more
12511 -- documentation on these functions, see the Microsoft C
12512 -- "Run-Time Library Reference" (Microsoft Press, 1990,
12513 -- ISBN 1-55615-225-6), which includes useful information
12514 -- on system compatibility.
12515 procedure clearerr (stream : FILEs);
12516 function fclose (stream : FILEs) return int;
12517 function fdopen (handle : int; mode : chars) return FILEs;
12518 function feof (stream : FILEs) return int;
12519 function ferror (stream : FILEs) return int;
12520 function fflush (stream : FILEs) return int;
12521 function fgetc (stream : FILEs) return int;
12522 function fgets (strng : chars; n : int; stream : FILEs)
12524 function fileno (stream : FILEs) return int;
12525 function fopen (filename : chars; Mode : chars)
12527 -- Note: to maintain target independence, use
12528 -- text_translation_required, a boolean variable defined in
12529 -- a-sysdep.c to deal with the target dependent text
12530 -- translation requirement. If this variable is set,
12531 -- then b/t should be appended to the standard mode
12532 -- argument to set the text translation mode off or on
12534 function fputc (C : int; stream : FILEs) return int;
12535 function fputs (Strng : chars; Stream : FILEs) return int;
12552 function ftell (stream : FILEs) return long;
12559 function isatty (handle : int) return int;
12560 procedure mktemp (template : chars);
12561 -- The return value (which is just a pointer to template)
12563 procedure rewind (stream : FILEs);
12564 function rmtmp return int;
12572 function tmpfile return FILEs;
12573 function ungetc (c : int; stream : FILEs) return int;
12574 function unlink (filename : chars) return int;
12575 ---------------------
12576 -- Extra functions --
12577 ---------------------
12578 -- These functions supply slightly thicker bindings than
12579 -- those above. They are derived from functions in the
12580 -- C Run-Time Library, but may do a bit more work than
12581 -- just directly calling one of the Library functions.
12582 function is_regular_file (handle : int) return int;
12583 -- Tests if given handle is for a regular file (result 1)
12584 -- or for a non-regular file (pipe or device, result 0).
12585 ---------------------------------
12586 -- Control of Text/Binary Mode --
12587 ---------------------------------
12588 -- If text_translation_required is true, then the following
12589 -- functions may be used to dynamically switch a file from
12590 -- binary to text mode or vice versa. These functions have
12591 -- no effect if text_translation_required is false (i.e.@: in
12592 -- normal UNIX mode). Use fileno to get a stream handle.
12593 procedure set_binary_mode (handle : int);
12594 procedure set_text_mode (handle : int);
12595 ----------------------------
12596 -- Full Path Name support --
12597 ----------------------------
12598 procedure full_name (nam : chars; buffer : chars);
12599 -- Given a NUL terminated string representing a file
12600 -- name, returns in buffer a NUL terminated string
12601 -- representing the full path name for the file name.
12602 -- On systems where it is relevant the drive is also
12603 -- part of the full path name. It is the responsibility
12604 -- of the caller to pass an actual parameter for buffer
12605 -- that is big enough for any full path name. Use
12606 -- max_path_len given below as the size of buffer.
12607 max_path_len : integer;
12608 -- Maximum length of an allowable full path name on the
12609 -- system, including a terminating NUL character.
12610 end Interfaces.C_Streams;
12613 @node Interfacing to C Streams
12614 @section Interfacing to C Streams
12617 The packages in this section permit interfacing Ada files to C Stream
12620 @smallexample @c ada
12621 with Interfaces.C_Streams;
12622 package Ada.Sequential_IO.C_Streams is
12623 function C_Stream (F : File_Type)
12624 return Interfaces.C_Streams.FILEs;
12626 (File : in out File_Type;
12627 Mode : in File_Mode;
12628 C_Stream : in Interfaces.C_Streams.FILEs;
12629 Form : in String := "");
12630 end Ada.Sequential_IO.C_Streams;
12632 with Interfaces.C_Streams;
12633 package Ada.Direct_IO.C_Streams is
12634 function C_Stream (F : File_Type)
12635 return Interfaces.C_Streams.FILEs;
12637 (File : in out File_Type;
12638 Mode : in File_Mode;
12639 C_Stream : in Interfaces.C_Streams.FILEs;
12640 Form : in String := "");
12641 end Ada.Direct_IO.C_Streams;
12643 with Interfaces.C_Streams;
12644 package Ada.Text_IO.C_Streams is
12645 function C_Stream (F : File_Type)
12646 return Interfaces.C_Streams.FILEs;
12648 (File : in out File_Type;
12649 Mode : in File_Mode;
12650 C_Stream : in Interfaces.C_Streams.FILEs;
12651 Form : in String := "");
12652 end Ada.Text_IO.C_Streams;
12654 with Interfaces.C_Streams;
12655 package Ada.Wide_Text_IO.C_Streams is
12656 function C_Stream (F : File_Type)
12657 return Interfaces.C_Streams.FILEs;
12659 (File : in out File_Type;
12660 Mode : in File_Mode;
12661 C_Stream : in Interfaces.C_Streams.FILEs;
12662 Form : in String := "");
12663 end Ada.Wide_Text_IO.C_Streams;
12665 with Interfaces.C_Streams;
12666 package Ada.Wide_Wide_Text_IO.C_Streams is
12667 function C_Stream (F : File_Type)
12668 return Interfaces.C_Streams.FILEs;
12670 (File : in out File_Type;
12671 Mode : in File_Mode;
12672 C_Stream : in Interfaces.C_Streams.FILEs;
12673 Form : in String := "");
12674 end Ada.Wide_Wide_Text_IO.C_Streams;
12676 with Interfaces.C_Streams;
12677 package Ada.Stream_IO.C_Streams is
12678 function C_Stream (F : File_Type)
12679 return Interfaces.C_Streams.FILEs;
12681 (File : in out File_Type;
12682 Mode : in File_Mode;
12683 C_Stream : in Interfaces.C_Streams.FILEs;
12684 Form : in String := "");
12685 end Ada.Stream_IO.C_Streams;
12689 In each of these six packages, the @code{C_Stream} function obtains the
12690 @code{FILE} pointer from a currently opened Ada file. It is then
12691 possible to use the @code{Interfaces.C_Streams} package to operate on
12692 this stream, or the stream can be passed to a C program which can
12693 operate on it directly. Of course the program is responsible for
12694 ensuring that only appropriate sequences of operations are executed.
12696 One particular use of relevance to an Ada program is that the
12697 @code{setvbuf} function can be used to control the buffering of the
12698 stream used by an Ada file. In the absence of such a call the standard
12699 default buffering is used.
12701 The @code{Open} procedures in these packages open a file giving an
12702 existing C Stream instead of a file name. Typically this stream is
12703 imported from a C program, allowing an Ada file to operate on an
12706 @node The GNAT Library
12707 @chapter The GNAT Library
12710 The GNAT library contains a number of general and special purpose packages.
12711 It represents functionality that the GNAT developers have found useful, and
12712 which is made available to GNAT users. The packages described here are fully
12713 supported, and upwards compatibility will be maintained in future releases,
12714 so you can use these facilities with the confidence that the same functionality
12715 will be available in future releases.
12717 The chapter here simply gives a brief summary of the facilities available.
12718 The full documentation is found in the spec file for the package. The full
12719 sources of these library packages, including both spec and body, are provided
12720 with all GNAT releases. For example, to find out the full specifications of
12721 the SPITBOL pattern matching capability, including a full tutorial and
12722 extensive examples, look in the @file{g-spipat.ads} file in the library.
12724 For each entry here, the package name (as it would appear in a @code{with}
12725 clause) is given, followed by the name of the corresponding spec file in
12726 parentheses. The packages are children in four hierarchies, @code{Ada},
12727 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
12728 GNAT-specific hierarchy.
12730 Note that an application program should only use packages in one of these
12731 four hierarchies if the package is defined in the Ada Reference Manual,
12732 or is listed in this section of the GNAT Programmers Reference Manual.
12733 All other units should be considered internal implementation units and
12734 should not be directly @code{with}'ed by application code. The use of
12735 a @code{with} statement that references one of these internal implementation
12736 units makes an application potentially dependent on changes in versions
12737 of GNAT, and will generate a warning message.
12740 * Ada.Characters.Latin_9 (a-chlat9.ads)::
12741 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
12742 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
12743 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
12744 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
12745 * Ada.Command_Line.Remove (a-colire.ads)::
12746 * Ada.Command_Line.Environment (a-colien.ads)::
12747 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
12748 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
12749 * Ada.Exceptions.Traceback (a-exctra.ads)::
12750 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
12751 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
12752 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
12753 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
12754 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
12755 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
12756 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
12757 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
12758 * GNAT.Altivec (g-altive.ads)::
12759 * GNAT.Altivec.Conversions (g-altcon.ads)::
12760 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
12761 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
12762 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
12763 * GNAT.Array_Split (g-arrspl.ads)::
12764 * GNAT.AWK (g-awk.ads)::
12765 * GNAT.Bounded_Buffers (g-boubuf.ads)::
12766 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
12767 * GNAT.Bubble_Sort (g-bubsor.ads)::
12768 * GNAT.Bubble_Sort_A (g-busora.ads)::
12769 * GNAT.Bubble_Sort_G (g-busorg.ads)::
12770 * GNAT.Byte_Order_Mark (g-byorma.ads)::
12771 * GNAT.Byte_Swapping (g-bytswa.ads)::
12772 * GNAT.Calendar (g-calend.ads)::
12773 * GNAT.Calendar.Time_IO (g-catiio.ads)::
12774 * GNAT.CRC32 (g-crc32.ads)::
12775 * GNAT.Case_Util (g-casuti.ads)::
12776 * GNAT.CGI (g-cgi.ads)::
12777 * GNAT.CGI.Cookie (g-cgicoo.ads)::
12778 * GNAT.CGI.Debug (g-cgideb.ads)::
12779 * GNAT.Command_Line (g-comlin.ads)::
12780 * GNAT.Compiler_Version (g-comver.ads)::
12781 * GNAT.Ctrl_C (g-ctrl_c.ads)::
12782 * GNAT.Current_Exception (g-curexc.ads)::
12783 * GNAT.Debug_Pools (g-debpoo.ads)::
12784 * GNAT.Debug_Utilities (g-debuti.ads)::
12785 * GNAT.Decode_String (g-decstr.ads)::
12786 * GNAT.Decode_UTF8_String (g-deutst.ads)::
12787 * GNAT.Directory_Operations (g-dirope.ads)::
12788 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
12789 * GNAT.Dynamic_HTables (g-dynhta.ads)::
12790 * GNAT.Dynamic_Tables (g-dyntab.ads)::
12791 * GNAT.Encode_String (g-encstr.ads)::
12792 * GNAT.Encode_UTF8_String (g-enutst.ads)::
12793 * GNAT.Exception_Actions (g-excact.ads)::
12794 * GNAT.Exception_Traces (g-exctra.ads)::
12795 * GNAT.Exceptions (g-except.ads)::
12796 * GNAT.Expect (g-expect.ads)::
12797 * GNAT.Float_Control (g-flocon.ads)::
12798 * GNAT.Heap_Sort (g-heasor.ads)::
12799 * GNAT.Heap_Sort_A (g-hesora.ads)::
12800 * GNAT.Heap_Sort_G (g-hesorg.ads)::
12801 * GNAT.HTable (g-htable.ads)::
12802 * GNAT.IO (g-io.ads)::
12803 * GNAT.IO_Aux (g-io_aux.ads)::
12804 * GNAT.Lock_Files (g-locfil.ads)::
12805 * GNAT.MD5 (g-md5.ads)::
12806 * GNAT.Memory_Dump (g-memdum.ads)::
12807 * GNAT.Most_Recent_Exception (g-moreex.ads)::
12808 * GNAT.OS_Lib (g-os_lib.ads)::
12809 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
12810 * GNAT.Random_Numbers (g-rannum.ads)::
12811 * GNAT.Regexp (g-regexp.ads)::
12812 * GNAT.Registry (g-regist.ads)::
12813 * GNAT.Regpat (g-regpat.ads)::
12814 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
12815 * GNAT.Semaphores (g-semaph.ads)::
12816 * GNAT.SHA1 (g-sha1.ads)::
12817 * GNAT.Signals (g-signal.ads)::
12818 * GNAT.Sockets (g-socket.ads)::
12819 * GNAT.Source_Info (g-souinf.ads)::
12820 * GNAT.Spelling_Checker (g-speche.ads)::
12821 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
12822 * GNAT.Spitbol.Patterns (g-spipat.ads)::
12823 * GNAT.Spitbol (g-spitbo.ads)::
12824 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
12825 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
12826 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
12827 * GNAT.Strings (g-string.ads)::
12828 * GNAT.String_Split (g-strspl.ads)::
12829 * GNAT.Table (g-table.ads)::
12830 * GNAT.Task_Lock (g-tasloc.ads)::
12831 * GNAT.Threads (g-thread.ads)::
12832 * GNAT.Traceback (g-traceb.ads)::
12833 * GNAT.Traceback.Symbolic (g-trasym.ads)::
12834 * GNAT.UTF_32 (g-utf_32.ads)::
12835 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
12836 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
12837 * GNAT.Wide_String_Split (g-wistsp.ads)::
12838 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
12839 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
12840 * Interfaces.C.Extensions (i-cexten.ads)::
12841 * Interfaces.C.Streams (i-cstrea.ads)::
12842 * Interfaces.CPP (i-cpp.ads)::
12843 * Interfaces.Os2lib (i-os2lib.ads)::
12844 * Interfaces.Os2lib.Errors (i-os2err.ads)::
12845 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
12846 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
12847 * Interfaces.Packed_Decimal (i-pacdec.ads)::
12848 * Interfaces.VxWorks (i-vxwork.ads)::
12849 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
12850 * System.Address_Image (s-addima.ads)::
12851 * System.Assertions (s-assert.ads)::
12852 * System.Memory (s-memory.ads)::
12853 * System.Partition_Interface (s-parint.ads)::
12854 * System.Restrictions (s-restri.ads)::
12855 * System.Rident (s-rident.ads)::
12856 * System.Task_Info (s-tasinf.ads)::
12857 * System.Wch_Cnv (s-wchcnv.ads)::
12858 * System.Wch_Con (s-wchcon.ads)::
12861 @node Ada.Characters.Latin_9 (a-chlat9.ads)
12862 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12863 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12864 @cindex Latin_9 constants for Character
12867 This child of @code{Ada.Characters}
12868 provides a set of definitions corresponding to those in the
12869 RM-defined package @code{Ada.Characters.Latin_1} but with the
12870 few modifications required for @code{Latin-9}
12871 The provision of such a package
12872 is specifically authorized by the Ada Reference Manual
12875 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
12876 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12877 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12878 @cindex Latin_1 constants for Wide_Character
12881 This child of @code{Ada.Characters}
12882 provides a set of definitions corresponding to those in the
12883 RM-defined package @code{Ada.Characters.Latin_1} but with the
12884 types of the constants being @code{Wide_Character}
12885 instead of @code{Character}. The provision of such a package
12886 is specifically authorized by the Ada Reference Manual
12889 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
12890 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12891 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12892 @cindex Latin_9 constants for Wide_Character
12895 This child of @code{Ada.Characters}
12896 provides a set of definitions corresponding to those in the
12897 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12898 types of the constants being @code{Wide_Character}
12899 instead of @code{Character}. The provision of such a package
12900 is specifically authorized by the Ada Reference Manual
12903 @node Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)
12904 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12905 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12906 @cindex Latin_1 constants for Wide_Wide_Character
12909 This child of @code{Ada.Characters}
12910 provides a set of definitions corresponding to those in the
12911 RM-defined package @code{Ada.Characters.Latin_1} but with the
12912 types of the constants being @code{Wide_Wide_Character}
12913 instead of @code{Character}. The provision of such a package
12914 is specifically authorized by the Ada Reference Manual
12917 @node Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)
12918 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12919 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12920 @cindex Latin_9 constants for Wide_Wide_Character
12923 This child of @code{Ada.Characters}
12924 provides a set of definitions corresponding to those in the
12925 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12926 types of the constants being @code{Wide_Wide_Character}
12927 instead of @code{Character}. The provision of such a package
12928 is specifically authorized by the Ada Reference Manual
12931 @node Ada.Command_Line.Remove (a-colire.ads)
12932 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12933 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12934 @cindex Removing command line arguments
12935 @cindex Command line, argument removal
12938 This child of @code{Ada.Command_Line}
12939 provides a mechanism for logically removing
12940 arguments from the argument list. Once removed, an argument is not visible
12941 to further calls on the subprograms in @code{Ada.Command_Line} will not
12942 see the removed argument.
12944 @node Ada.Command_Line.Environment (a-colien.ads)
12945 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12946 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12947 @cindex Environment entries
12950 This child of @code{Ada.Command_Line}
12951 provides a mechanism for obtaining environment values on systems
12952 where this concept makes sense.
12954 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
12955 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12956 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12957 @cindex C Streams, Interfacing with Direct_IO
12960 This package provides subprograms that allow interfacing between
12961 C streams and @code{Direct_IO}. The stream identifier can be
12962 extracted from a file opened on the Ada side, and an Ada file
12963 can be constructed from a stream opened on the C side.
12965 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
12966 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12967 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12968 @cindex Null_Occurrence, testing for
12971 This child subprogram provides a way of testing for the null
12972 exception occurrence (@code{Null_Occurrence}) without raising
12975 @node Ada.Exceptions.Traceback (a-exctra.ads)
12976 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12977 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12978 @cindex Traceback for Exception Occurrence
12981 This child package provides the subprogram (@code{Tracebacks}) to
12982 give a traceback array of addresses based on an exception
12985 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
12986 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12987 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12988 @cindex C Streams, Interfacing with Sequential_IO
12991 This package provides subprograms that allow interfacing between
12992 C streams and @code{Sequential_IO}. The stream identifier can be
12993 extracted from a file opened on the Ada side, and an Ada file
12994 can be constructed from a stream opened on the C side.
12996 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
12997 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12998 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12999 @cindex C Streams, Interfacing with Stream_IO
13002 This package provides subprograms that allow interfacing between
13003 C streams and @code{Stream_IO}. The stream identifier can be
13004 extracted from a file opened on the Ada side, and an Ada file
13005 can be constructed from a stream opened on the C side.
13007 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13008 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13009 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13010 @cindex @code{Unbounded_String}, IO support
13011 @cindex @code{Text_IO}, extensions for unbounded strings
13014 This package provides subprograms for Text_IO for unbounded
13015 strings, avoiding the necessity for an intermediate operation
13016 with ordinary strings.
13018 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13019 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13020 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13021 @cindex @code{Unbounded_Wide_String}, IO support
13022 @cindex @code{Text_IO}, extensions for unbounded wide strings
13025 This package provides subprograms for Text_IO for unbounded
13026 wide strings, avoiding the necessity for an intermediate operation
13027 with ordinary wide strings.
13029 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13030 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13031 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13032 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13033 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13036 This package provides subprograms for Text_IO for unbounded
13037 wide wide strings, avoiding the necessity for an intermediate operation
13038 with ordinary wide wide strings.
13040 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13041 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13042 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13043 @cindex C Streams, Interfacing with @code{Text_IO}
13046 This package provides subprograms that allow interfacing between
13047 C streams and @code{Text_IO}. The stream identifier can be
13048 extracted from a file opened on the Ada side, and an Ada file
13049 can be constructed from a stream opened on the C side.
13051 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13052 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13053 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13054 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13057 This package provides subprograms that allow interfacing between
13058 C streams and @code{Wide_Text_IO}. The stream identifier can be
13059 extracted from a file opened on the Ada side, and an Ada file
13060 can be constructed from a stream opened on the C side.
13062 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13063 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13064 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13065 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13068 This package provides subprograms that allow interfacing between
13069 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
13070 extracted from a file opened on the Ada side, and an Ada file
13071 can be constructed from a stream opened on the C side.
13073 @node GNAT.Altivec (g-altive.ads)
13074 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13075 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13079 This is the root package of the GNAT AltiVec binding. It provides
13080 definitions of constants and types common to all the versions of the
13083 @node GNAT.Altivec.Conversions (g-altcon.ads)
13084 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13085 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13089 This package provides the Vector/View conversion routines.
13091 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13092 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13093 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13097 This package exposes the Ada interface to the AltiVec operations on
13098 vector objects. A soft emulation is included by default in the GNAT
13099 library. The hard binding is provided as a separate package. This unit
13100 is common to both bindings.
13102 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13103 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13104 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13108 This package exposes the various vector types part of the Ada binding
13109 to AltiVec facilities.
13111 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13112 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13113 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13117 This package provides public 'View' data types from/to which private
13118 vector representations can be converted via
13119 GNAT.Altivec.Conversions. This allows convenient access to individual
13120 vector elements and provides a simple way to initialize vector
13123 @node GNAT.Array_Split (g-arrspl.ads)
13124 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13125 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13126 @cindex Array splitter
13129 Useful array-manipulation routines: given a set of separators, split
13130 an array wherever the separators appear, and provide direct access
13131 to the resulting slices.
13133 @node GNAT.AWK (g-awk.ads)
13134 @section @code{GNAT.AWK} (@file{g-awk.ads})
13135 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13140 Provides AWK-like parsing functions, with an easy interface for parsing one
13141 or more files containing formatted data. The file is viewed as a database
13142 where each record is a line and a field is a data element in this line.
13144 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13145 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13146 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13148 @cindex Bounded Buffers
13151 Provides a concurrent generic bounded buffer abstraction. Instances are
13152 useful directly or as parts of the implementations of other abstractions,
13155 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13156 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13157 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13162 Provides a thread-safe asynchronous intertask mailbox communication facility.
13164 @node GNAT.Bubble_Sort (g-bubsor.ads)
13165 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13166 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13168 @cindex Bubble sort
13171 Provides a general implementation of bubble sort usable for sorting arbitrary
13172 data items. Exchange and comparison procedures are provided by passing
13173 access-to-procedure values.
13175 @node GNAT.Bubble_Sort_A (g-busora.ads)
13176 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13177 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13179 @cindex Bubble sort
13182 Provides a general implementation of bubble sort usable for sorting arbitrary
13183 data items. Move and comparison procedures are provided by passing
13184 access-to-procedure values. This is an older version, retained for
13185 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13187 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13188 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13189 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13191 @cindex Bubble sort
13194 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13195 are provided as generic parameters, this improves efficiency, especially
13196 if the procedures can be inlined, at the expense of duplicating code for
13197 multiple instantiations.
13199 @node GNAT.Byte_Order_Mark (g-byorma.ads)
13200 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13201 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13202 @cindex UTF-8 representation
13203 @cindex Wide characte representations
13206 Provides a routine which given a string, reads the start of the string to
13207 see whether it is one of the standard byte order marks (BOM's) which signal
13208 the encoding of the string. The routine includes detection of special XML
13209 sequences for various UCS input formats.
13211 @node GNAT.Byte_Swapping (g-bytswa.ads)
13212 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13213 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13214 @cindex Byte swapping
13218 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13219 Machine-specific implementations are available in some cases.
13221 @node GNAT.Calendar (g-calend.ads)
13222 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13223 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13224 @cindex @code{Calendar}
13227 Extends the facilities provided by @code{Ada.Calendar} to include handling
13228 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13229 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
13230 C @code{timeval} format.
13232 @node GNAT.Calendar.Time_IO (g-catiio.ads)
13233 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13234 @cindex @code{Calendar}
13236 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13238 @node GNAT.CRC32 (g-crc32.ads)
13239 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
13240 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
13242 @cindex Cyclic Redundancy Check
13245 This package implements the CRC-32 algorithm. For a full description
13246 of this algorithm see
13247 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
13248 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
13249 Aug.@: 1988. Sarwate, D.V@.
13251 @node GNAT.Case_Util (g-casuti.ads)
13252 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
13253 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
13254 @cindex Casing utilities
13255 @cindex Character handling (@code{GNAT.Case_Util})
13258 A set of simple routines for handling upper and lower casing of strings
13259 without the overhead of the full casing tables
13260 in @code{Ada.Characters.Handling}.
13262 @node GNAT.CGI (g-cgi.ads)
13263 @section @code{GNAT.CGI} (@file{g-cgi.ads})
13264 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
13265 @cindex CGI (Common Gateway Interface)
13268 This is a package for interfacing a GNAT program with a Web server via the
13269 Common Gateway Interface (CGI)@. Basically this package parses the CGI
13270 parameters, which are a set of key/value pairs sent by the Web server. It
13271 builds a table whose index is the key and provides some services to deal
13274 @node GNAT.CGI.Cookie (g-cgicoo.ads)
13275 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13276 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13277 @cindex CGI (Common Gateway Interface) cookie support
13278 @cindex Cookie support in CGI
13281 This is a package to interface a GNAT program with a Web server via the
13282 Common Gateway Interface (CGI). It exports services to deal with Web
13283 cookies (piece of information kept in the Web client software).
13285 @node GNAT.CGI.Debug (g-cgideb.ads)
13286 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13287 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13288 @cindex CGI (Common Gateway Interface) debugging
13291 This is a package to help debugging CGI (Common Gateway Interface)
13292 programs written in Ada.
13294 @node GNAT.Command_Line (g-comlin.ads)
13295 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
13296 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
13297 @cindex Command line
13300 Provides a high level interface to @code{Ada.Command_Line} facilities,
13301 including the ability to scan for named switches with optional parameters
13302 and expand file names using wild card notations.
13304 @node GNAT.Compiler_Version (g-comver.ads)
13305 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13306 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13307 @cindex Compiler Version
13308 @cindex Version, of compiler
13311 Provides a routine for obtaining the version of the compiler used to
13312 compile the program. More accurately this is the version of the binder
13313 used to bind the program (this will normally be the same as the version
13314 of the compiler if a consistent tool set is used to compile all units
13317 @node GNAT.Ctrl_C (g-ctrl_c.ads)
13318 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13319 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13323 Provides a simple interface to handle Ctrl-C keyboard events.
13325 @node GNAT.Current_Exception (g-curexc.ads)
13326 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13327 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13328 @cindex Current exception
13329 @cindex Exception retrieval
13332 Provides access to information on the current exception that has been raised
13333 without the need for using the Ada 95 / Ada 2005 exception choice parameter
13334 specification syntax.
13335 This is particularly useful in simulating typical facilities for
13336 obtaining information about exceptions provided by Ada 83 compilers.
13338 @node GNAT.Debug_Pools (g-debpoo.ads)
13339 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13340 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13342 @cindex Debug pools
13343 @cindex Memory corruption debugging
13346 Provide a debugging storage pools that helps tracking memory corruption
13347 problems. See section ``Finding memory problems with GNAT Debug Pool'' in
13348 the @cite{GNAT User's Guide}.
13350 @node GNAT.Debug_Utilities (g-debuti.ads)
13351 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13352 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13356 Provides a few useful utilities for debugging purposes, including conversion
13357 to and from string images of address values. Supports both C and Ada formats
13358 for hexadecimal literals.
13360 @node GNAT.Decode_String (g-decstr.ads)
13361 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
13362 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
13363 @cindex Decoding strings
13364 @cindex String decoding
13365 @cindex Wide character encoding
13370 A generic package providing routines for decoding wide character and wide wide
13371 character strings encoded as sequences of 8-bit characters using a specified
13372 encoding method. Includes validation routines, and also routines for stepping
13373 to next or previous encoded character in an encoded string.
13374 Useful in conjunction with Unicode character coding. Note there is a
13375 preinstantiation for UTF-8. See next entry.
13377 @node GNAT.Decode_UTF8_String (g-deutst.ads)
13378 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13379 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13380 @cindex Decoding strings
13381 @cindex Decoding UTF-8 strings
13382 @cindex UTF-8 string decoding
13383 @cindex Wide character decoding
13388 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
13390 @node GNAT.Directory_Operations (g-dirope.ads)
13391 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13392 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13393 @cindex Directory operations
13396 Provides a set of routines for manipulating directories, including changing
13397 the current directory, making new directories, and scanning the files in a
13400 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
13401 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
13402 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
13403 @cindex Directory operations iteration
13406 A child unit of GNAT.Directory_Operations providing additional operations
13407 for iterating through directories.
13409 @node GNAT.Dynamic_HTables (g-dynhta.ads)
13410 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13411 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13412 @cindex Hash tables
13415 A generic implementation of hash tables that can be used to hash arbitrary
13416 data. Provided in two forms, a simple form with built in hash functions,
13417 and a more complex form in which the hash function is supplied.
13420 This package provides a facility similar to that of @code{GNAT.HTable},
13421 except that this package declares a type that can be used to define
13422 dynamic instances of the hash table, while an instantiation of
13423 @code{GNAT.HTable} creates a single instance of the hash table.
13425 @node GNAT.Dynamic_Tables (g-dyntab.ads)
13426 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13427 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13428 @cindex Table implementation
13429 @cindex Arrays, extendable
13432 A generic package providing a single dimension array abstraction where the
13433 length of the array can be dynamically modified.
13436 This package provides a facility similar to that of @code{GNAT.Table},
13437 except that this package declares a type that can be used to define
13438 dynamic instances of the table, while an instantiation of
13439 @code{GNAT.Table} creates a single instance of the table type.
13441 @node GNAT.Encode_String (g-encstr.ads)
13442 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
13443 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
13444 @cindex Encoding strings
13445 @cindex String encoding
13446 @cindex Wide character encoding
13451 A generic package providing routines for encoding wide character and wide
13452 wide character strings as sequences of 8-bit characters using a specified
13453 encoding method. Useful in conjunction with Unicode character coding.
13454 Note there is a preinstantiation for UTF-8. See next entry.
13456 @node GNAT.Encode_UTF8_String (g-enutst.ads)
13457 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
13458 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
13459 @cindex Encoding strings
13460 @cindex Encoding UTF-8 strings
13461 @cindex UTF-8 string encoding
13462 @cindex Wide character encoding
13467 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
13469 @node GNAT.Exception_Actions (g-excact.ads)
13470 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13471 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13472 @cindex Exception actions
13475 Provides callbacks when an exception is raised. Callbacks can be registered
13476 for specific exceptions, or when any exception is raised. This
13477 can be used for instance to force a core dump to ease debugging.
13479 @node GNAT.Exception_Traces (g-exctra.ads)
13480 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13481 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13482 @cindex Exception traces
13486 Provides an interface allowing to control automatic output upon exception
13489 @node GNAT.Exceptions (g-except.ads)
13490 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
13491 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
13492 @cindex Exceptions, Pure
13493 @cindex Pure packages, exceptions
13496 Normally it is not possible to raise an exception with
13497 a message from a subprogram in a pure package, since the
13498 necessary types and subprograms are in @code{Ada.Exceptions}
13499 which is not a pure unit. @code{GNAT.Exceptions} provides a
13500 facility for getting around this limitation for a few
13501 predefined exceptions, and for example allow raising
13502 @code{Constraint_Error} with a message from a pure subprogram.
13504 @node GNAT.Expect (g-expect.ads)
13505 @section @code{GNAT.Expect} (@file{g-expect.ads})
13506 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
13509 Provides a set of subprograms similar to what is available
13510 with the standard Tcl Expect tool.
13511 It allows you to easily spawn and communicate with an external process.
13512 You can send commands or inputs to the process, and compare the output
13513 with some expected regular expression. Currently @code{GNAT.Expect}
13514 is implemented on all native GNAT ports except for OpenVMS@.
13515 It is not implemented for cross ports, and in particular is not
13516 implemented for VxWorks or LynxOS@.
13518 @node GNAT.Float_Control (g-flocon.ads)
13519 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
13520 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
13521 @cindex Floating-Point Processor
13524 Provides an interface for resetting the floating-point processor into the
13525 mode required for correct semantic operation in Ada. Some third party
13526 library calls may cause this mode to be modified, and the Reset procedure
13527 in this package can be used to reestablish the required mode.
13529 @node GNAT.Heap_Sort (g-heasor.ads)
13530 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13531 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13535 Provides a general implementation of heap sort usable for sorting arbitrary
13536 data items. Exchange and comparison procedures are provided by passing
13537 access-to-procedure values. The algorithm used is a modified heap sort
13538 that performs approximately N*log(N) comparisons in the worst case.
13540 @node GNAT.Heap_Sort_A (g-hesora.ads)
13541 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13542 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13546 Provides a general implementation of heap sort usable for sorting arbitrary
13547 data items. Move and comparison procedures are provided by passing
13548 access-to-procedure values. The algorithm used is a modified heap sort
13549 that performs approximately N*log(N) comparisons in the worst case.
13550 This differs from @code{GNAT.Heap_Sort} in having a less convenient
13551 interface, but may be slightly more efficient.
13553 @node GNAT.Heap_Sort_G (g-hesorg.ads)
13554 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13555 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13559 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
13560 are provided as generic parameters, this improves efficiency, especially
13561 if the procedures can be inlined, at the expense of duplicating code for
13562 multiple instantiations.
13564 @node GNAT.HTable (g-htable.ads)
13565 @section @code{GNAT.HTable} (@file{g-htable.ads})
13566 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
13567 @cindex Hash tables
13570 A generic implementation of hash tables that can be used to hash arbitrary
13571 data. Provides two approaches, one a simple static approach, and the other
13572 allowing arbitrary dynamic hash tables.
13574 @node GNAT.IO (g-io.ads)
13575 @section @code{GNAT.IO} (@file{g-io.ads})
13576 @cindex @code{GNAT.IO} (@file{g-io.ads})
13578 @cindex Input/Output facilities
13581 A simple preelaborable input-output package that provides a subset of
13582 simple Text_IO functions for reading characters and strings from
13583 Standard_Input, and writing characters, strings and integers to either
13584 Standard_Output or Standard_Error.
13586 @node GNAT.IO_Aux (g-io_aux.ads)
13587 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13588 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13590 @cindex Input/Output facilities
13592 Provides some auxiliary functions for use with Text_IO, including a test
13593 for whether a file exists, and functions for reading a line of text.
13595 @node GNAT.Lock_Files (g-locfil.ads)
13596 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13597 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13598 @cindex File locking
13599 @cindex Locking using files
13602 Provides a general interface for using files as locks. Can be used for
13603 providing program level synchronization.
13605 @node GNAT.MD5 (g-md5.ads)
13606 @section @code{GNAT.MD5} (@file{g-md5.ads})
13607 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
13608 @cindex Message Digest MD5
13611 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
13613 @node GNAT.Memory_Dump (g-memdum.ads)
13614 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13615 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13616 @cindex Dump Memory
13619 Provides a convenient routine for dumping raw memory to either the
13620 standard output or standard error files. Uses GNAT.IO for actual
13623 @node GNAT.Most_Recent_Exception (g-moreex.ads)
13624 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13625 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13626 @cindex Exception, obtaining most recent
13629 Provides access to the most recently raised exception. Can be used for
13630 various logging purposes, including duplicating functionality of some
13631 Ada 83 implementation dependent extensions.
13633 @node GNAT.OS_Lib (g-os_lib.ads)
13634 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13635 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13636 @cindex Operating System interface
13637 @cindex Spawn capability
13640 Provides a range of target independent operating system interface functions,
13641 including time/date management, file operations, subprocess management,
13642 including a portable spawn procedure, and access to environment variables
13643 and error return codes.
13645 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
13646 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13647 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13648 @cindex Hash functions
13651 Provides a generator of static minimal perfect hash functions. No
13652 collisions occur and each item can be retrieved from the table in one
13653 probe (perfect property). The hash table size corresponds to the exact
13654 size of the key set and no larger (minimal property). The key set has to
13655 be know in advance (static property). The hash functions are also order
13656 preserving. If w2 is inserted after w1 in the generator, their
13657 hashcode are in the same order. These hashing functions are very
13658 convenient for use with realtime applications.
13660 @node GNAT.Random_Numbers (g-rannum.ads)
13661 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
13662 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
13663 @cindex Random number generation
13666 Provides random number capabilities which extend those available in the
13667 standard Ada library and are more convenient to use.
13669 @node GNAT.Regexp (g-regexp.ads)
13670 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
13671 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
13672 @cindex Regular expressions
13673 @cindex Pattern matching
13676 A simple implementation of regular expressions, using a subset of regular
13677 expression syntax copied from familiar Unix style utilities. This is the
13678 simples of the three pattern matching packages provided, and is particularly
13679 suitable for ``file globbing'' applications.
13681 @node GNAT.Registry (g-regist.ads)
13682 @section @code{GNAT.Registry} (@file{g-regist.ads})
13683 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
13684 @cindex Windows Registry
13687 This is a high level binding to the Windows registry. It is possible to
13688 do simple things like reading a key value, creating a new key. For full
13689 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
13690 package provided with the Win32Ada binding
13692 @node GNAT.Regpat (g-regpat.ads)
13693 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
13694 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
13695 @cindex Regular expressions
13696 @cindex Pattern matching
13699 A complete implementation of Unix-style regular expression matching, copied
13700 from the original V7 style regular expression library written in C by
13701 Henry Spencer (and binary compatible with this C library).
13703 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
13704 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13705 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13706 @cindex Secondary Stack Info
13709 Provide the capability to query the high water mark of the current task's
13712 @node GNAT.Semaphores (g-semaph.ads)
13713 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
13714 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
13718 Provides classic counting and binary semaphores using protected types.
13720 @node GNAT.SHA1 (g-sha1.ads)
13721 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
13722 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
13723 @cindex Secure Hash Algorithm SHA-1
13726 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
13728 @node GNAT.Signals (g-signal.ads)
13729 @section @code{GNAT.Signals} (@file{g-signal.ads})
13730 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
13734 Provides the ability to manipulate the blocked status of signals on supported
13737 @node GNAT.Sockets (g-socket.ads)
13738 @section @code{GNAT.Sockets} (@file{g-socket.ads})
13739 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
13743 A high level and portable interface to develop sockets based applications.
13744 This package is based on the sockets thin binding found in
13745 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
13746 on all native GNAT ports except for OpenVMS@. It is not implemented
13747 for the LynxOS@ cross port.
13749 @node GNAT.Source_Info (g-souinf.ads)
13750 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
13751 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
13752 @cindex Source Information
13755 Provides subprograms that give access to source code information known at
13756 compile time, such as the current file name and line number.
13758 @node GNAT.Spelling_Checker (g-speche.ads)
13759 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
13760 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
13761 @cindex Spell checking
13764 Provides a function for determining whether one string is a plausible
13765 near misspelling of another string.
13767 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
13768 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
13769 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
13770 @cindex Spell checking
13773 Provides a generic function that can be instantiated with a string type for
13774 determining whether one string is a plausible near misspelling of another
13777 @node GNAT.Spitbol.Patterns (g-spipat.ads)
13778 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13779 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13780 @cindex SPITBOL pattern matching
13781 @cindex Pattern matching
13784 A complete implementation of SNOBOL4 style pattern matching. This is the
13785 most elaborate of the pattern matching packages provided. It fully duplicates
13786 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
13787 efficient algorithm developed by Robert Dewar for the SPITBOL system.
13789 @node GNAT.Spitbol (g-spitbo.ads)
13790 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13791 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13792 @cindex SPITBOL interface
13795 The top level package of the collection of SPITBOL-style functionality, this
13796 package provides basic SNOBOL4 string manipulation functions, such as
13797 Pad, Reverse, Trim, Substr capability, as well as a generic table function
13798 useful for constructing arbitrary mappings from strings in the style of
13799 the SNOBOL4 TABLE function.
13801 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
13802 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13803 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13804 @cindex Sets of strings
13805 @cindex SPITBOL Tables
13808 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13809 for type @code{Standard.Boolean}, giving an implementation of sets of
13812 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
13813 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13814 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13815 @cindex Integer maps
13817 @cindex SPITBOL Tables
13820 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13821 for type @code{Standard.Integer}, giving an implementation of maps
13822 from string to integer values.
13824 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
13825 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13826 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13827 @cindex String maps
13829 @cindex SPITBOL Tables
13832 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
13833 a variable length string type, giving an implementation of general
13834 maps from strings to strings.
13836 @node GNAT.Strings (g-string.ads)
13837 @section @code{GNAT.Strings} (@file{g-string.ads})
13838 @cindex @code{GNAT.Strings} (@file{g-string.ads})
13841 Common String access types and related subprograms. Basically it
13842 defines a string access and an array of string access types.
13844 @node GNAT.String_Split (g-strspl.ads)
13845 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
13846 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
13847 @cindex String splitter
13850 Useful string manipulation routines: given a set of separators, split
13851 a string wherever the separators appear, and provide direct access
13852 to the resulting slices. This package is instantiated from
13853 @code{GNAT.Array_Split}.
13855 @node GNAT.Table (g-table.ads)
13856 @section @code{GNAT.Table} (@file{g-table.ads})
13857 @cindex @code{GNAT.Table} (@file{g-table.ads})
13858 @cindex Table implementation
13859 @cindex Arrays, extendable
13862 A generic package providing a single dimension array abstraction where the
13863 length of the array can be dynamically modified.
13866 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
13867 except that this package declares a single instance of the table type,
13868 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
13869 used to define dynamic instances of the table.
13871 @node GNAT.Task_Lock (g-tasloc.ads)
13872 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13873 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13874 @cindex Task synchronization
13875 @cindex Task locking
13879 A very simple facility for locking and unlocking sections of code using a
13880 single global task lock. Appropriate for use in situations where contention
13881 between tasks is very rarely expected.
13883 @node GNAT.Threads (g-thread.ads)
13884 @section @code{GNAT.Threads} (@file{g-thread.ads})
13885 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
13886 @cindex Foreign threads
13887 @cindex Threads, foreign
13890 Provides facilities for dealing with foreign threads which need to be known
13891 by the GNAT run-time system. Consult the documentation of this package for
13892 further details if your program has threads that are created by a non-Ada
13893 environment which then accesses Ada code.
13895 @node GNAT.Traceback (g-traceb.ads)
13896 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
13897 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
13898 @cindex Trace back facilities
13901 Provides a facility for obtaining non-symbolic traceback information, useful
13902 in various debugging situations.
13904 @node GNAT.Traceback.Symbolic (g-trasym.ads)
13905 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13906 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13907 @cindex Trace back facilities
13909 @node GNAT.UTF_32 (g-utf_32.ads)
13910 @section @code{GNAT.UTF_32} (@file{g-table.ads})
13911 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
13912 @cindex Wide character codes
13915 This is a package intended to be used in conjunction with the
13916 @code{Wide_Character} type in Ada 95 and the
13917 @code{Wide_Wide_Character} type in Ada 2005 (available
13918 in @code{GNAT} in Ada 2005 mode). This package contains
13919 Unicode categorization routines, as well as lexical
13920 categorization routines corresponding to the Ada 2005
13921 lexical rules for identifiers and strings, and also a
13922 lower case to upper case fold routine corresponding to
13923 the Ada 2005 rules for identifier equivalence.
13925 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
13926 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
13927 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
13928 @cindex Spell checking
13931 Provides a function for determining whether one wide wide string is a plausible
13932 near misspelling of another wide wide string, where the strings are represented
13933 using the UTF_32_String type defined in System.Wch_Cnv.
13935 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
13936 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
13937 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
13938 @cindex Spell checking
13941 Provides a function for determining whether one wide string is a plausible
13942 near misspelling of another wide string.
13944 @node GNAT.Wide_String_Split (g-wistsp.ads)
13945 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13946 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13947 @cindex Wide_String splitter
13950 Useful wide string manipulation routines: given a set of separators, split
13951 a wide string wherever the separators appear, and provide direct access
13952 to the resulting slices. This package is instantiated from
13953 @code{GNAT.Array_Split}.
13955 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
13956 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
13957 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
13958 @cindex Spell checking
13961 Provides a function for determining whether one wide wide string is a plausible
13962 near misspelling of another wide wide string.
13964 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
13965 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13966 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13967 @cindex Wide_Wide_String splitter
13970 Useful wide wide string manipulation routines: given a set of separators, split
13971 a wide wide string wherever the separators appear, and provide direct access
13972 to the resulting slices. This package is instantiated from
13973 @code{GNAT.Array_Split}.
13975 @node Interfaces.C.Extensions (i-cexten.ads)
13976 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13977 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13980 This package contains additional C-related definitions, intended
13981 for use with either manually or automatically generated bindings
13984 @node Interfaces.C.Streams (i-cstrea.ads)
13985 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13986 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13987 @cindex C streams, interfacing
13990 This package is a binding for the most commonly used operations
13993 @node Interfaces.CPP (i-cpp.ads)
13994 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
13995 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
13996 @cindex C++ interfacing
13997 @cindex Interfacing, to C++
14000 This package provides facilities for use in interfacing to C++. It
14001 is primarily intended to be used in connection with automated tools
14002 for the generation of C++ interfaces.
14004 @node Interfaces.Os2lib (i-os2lib.ads)
14005 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
14006 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
14007 @cindex Interfacing, to OS/2
14008 @cindex OS/2 interfacing
14011 This package provides interface definitions to the OS/2 library.
14012 It is a thin binding which is a direct translation of the
14013 various @file{<bse@.h>} files.
14015 @node Interfaces.Os2lib.Errors (i-os2err.ads)
14016 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
14017 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
14018 @cindex OS/2 Error codes
14019 @cindex Interfacing, to OS/2
14020 @cindex OS/2 interfacing
14023 This package provides definitions of the OS/2 error codes.
14025 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
14026 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
14027 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
14028 @cindex Interfacing, to OS/2
14029 @cindex Synchronization, OS/2
14030 @cindex OS/2 synchronization primitives
14033 This is a child package that provides definitions for interfacing
14034 to the @code{OS/2} synchronization primitives.
14036 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
14037 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
14038 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
14039 @cindex Interfacing, to OS/2
14040 @cindex Thread control, OS/2
14041 @cindex OS/2 thread interfacing
14044 This is a child package that provides definitions for interfacing
14045 to the @code{OS/2} thread primitives.
14047 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14048 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14049 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14050 @cindex IBM Packed Format
14051 @cindex Packed Decimal
14054 This package provides a set of routines for conversions to and
14055 from a packed decimal format compatible with that used on IBM
14058 @node Interfaces.VxWorks (i-vxwork.ads)
14059 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14060 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14061 @cindex Interfacing to VxWorks
14062 @cindex VxWorks, interfacing
14065 This package provides a limited binding to the VxWorks API.
14066 In particular, it interfaces with the
14067 VxWorks hardware interrupt facilities.
14069 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14070 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14071 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14072 @cindex Interfacing to VxWorks' I/O
14073 @cindex VxWorks, I/O interfacing
14074 @cindex VxWorks, Get_Immediate
14075 @cindex Get_Immediate, VxWorks
14078 This package provides a binding to the ioctl (IO/Control)
14079 function of VxWorks, defining a set of option values and
14080 function codes. A particular use of this package is
14081 to enable the use of Get_Immediate under VxWorks.
14083 @node System.Address_Image (s-addima.ads)
14084 @section @code{System.Address_Image} (@file{s-addima.ads})
14085 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14086 @cindex Address image
14087 @cindex Image, of an address
14090 This function provides a useful debugging
14091 function that gives an (implementation dependent)
14092 string which identifies an address.
14094 @node System.Assertions (s-assert.ads)
14095 @section @code{System.Assertions} (@file{s-assert.ads})
14096 @cindex @code{System.Assertions} (@file{s-assert.ads})
14098 @cindex Assert_Failure, exception
14101 This package provides the declaration of the exception raised
14102 by an run-time assertion failure, as well as the routine that
14103 is used internally to raise this assertion.
14105 @node System.Memory (s-memory.ads)
14106 @section @code{System.Memory} (@file{s-memory.ads})
14107 @cindex @code{System.Memory} (@file{s-memory.ads})
14108 @cindex Memory allocation
14111 This package provides the interface to the low level routines used
14112 by the generated code for allocation and freeing storage for the
14113 default storage pool (analogous to the C routines malloc and free.
14114 It also provides a reallocation interface analogous to the C routine
14115 realloc. The body of this unit may be modified to provide alternative
14116 allocation mechanisms for the default pool, and in addition, direct
14117 calls to this unit may be made for low level allocation uses (for
14118 example see the body of @code{GNAT.Tables}).
14120 @node System.Partition_Interface (s-parint.ads)
14121 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14122 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14123 @cindex Partition interfacing functions
14126 This package provides facilities for partition interfacing. It
14127 is used primarily in a distribution context when using Annex E
14130 @node System.Restrictions (s-restri.ads)
14131 @section @code{System.Restrictions} (@file{s-restri.ads})
14132 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14133 @cindex Run-time restrictions access
14136 This package provides facilities for accessing at run time
14137 the status of restrictions specified at compile time for
14138 the partition. Information is available both with regard
14139 to actual restrictions specified, and with regard to
14140 compiler determined information on which restrictions
14141 are violated by one or more packages in the partition.
14143 @node System.Rident (s-rident.ads)
14144 @section @code{System.Rident} (@file{s-rident.ads})
14145 @cindex @code{System.Rident} (@file{s-rident.ads})
14146 @cindex Restrictions definitions
14149 This package provides definitions of the restrictions
14150 identifiers supported by GNAT, and also the format of
14151 the restrictions provided in package System.Restrictions.
14152 It is not normally necessary to @code{with} this generic package
14153 since the necessary instantiation is included in
14154 package System.Restrictions.
14156 @node System.Task_Info (s-tasinf.ads)
14157 @section @code{System.Task_Info} (@file{s-tasinf.ads})
14158 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
14159 @cindex Task_Info pragma
14162 This package provides target dependent functionality that is used
14163 to support the @code{Task_Info} pragma
14165 @node System.Wch_Cnv (s-wchcnv.ads)
14166 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14167 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14168 @cindex Wide Character, Representation
14169 @cindex Wide String, Conversion
14170 @cindex Representation of wide characters
14173 This package provides routines for converting between
14174 wide and wide wide characters and a representation as a value of type
14175 @code{Standard.String}, using a specified wide character
14176 encoding method. It uses definitions in
14177 package @code{System.Wch_Con}.
14179 @node System.Wch_Con (s-wchcon.ads)
14180 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
14181 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
14184 This package provides definitions and descriptions of
14185 the various methods used for encoding wide characters
14186 in ordinary strings. These definitions are used by
14187 the package @code{System.Wch_Cnv}.
14189 @node Interfacing to Other Languages
14190 @chapter Interfacing to Other Languages
14192 The facilities in annex B of the Ada Reference Manual are fully
14193 implemented in GNAT, and in addition, a full interface to C++ is
14197 * Interfacing to C::
14198 * Interfacing to C++::
14199 * Interfacing to COBOL::
14200 * Interfacing to Fortran::
14201 * Interfacing to non-GNAT Ada code::
14204 @node Interfacing to C
14205 @section Interfacing to C
14208 Interfacing to C with GNAT can use one of two approaches:
14212 The types in the package @code{Interfaces.C} may be used.
14214 Standard Ada types may be used directly. This may be less portable to
14215 other compilers, but will work on all GNAT compilers, which guarantee
14216 correspondence between the C and Ada types.
14220 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
14221 effect, since this is the default. The following table shows the
14222 correspondence between Ada scalar types and the corresponding C types.
14227 @item Short_Integer
14229 @item Short_Short_Integer
14233 @item Long_Long_Integer
14241 @item Long_Long_Float
14242 This is the longest floating-point type supported by the hardware.
14246 Additionally, there are the following general correspondences between Ada
14250 Ada enumeration types map to C enumeration types directly if pragma
14251 @code{Convention C} is specified, which causes them to have int
14252 length. Without pragma @code{Convention C}, Ada enumeration types map to
14253 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
14254 @code{int}, respectively) depending on the number of values passed.
14255 This is the only case in which pragma @code{Convention C} affects the
14256 representation of an Ada type.
14259 Ada access types map to C pointers, except for the case of pointers to
14260 unconstrained types in Ada, which have no direct C equivalent.
14263 Ada arrays map directly to C arrays.
14266 Ada records map directly to C structures.
14269 Packed Ada records map to C structures where all members are bit fields
14270 of the length corresponding to the @code{@var{type}'Size} value in Ada.
14273 @node Interfacing to C++
14274 @section Interfacing to C++
14277 The interface to C++ makes use of the following pragmas, which are
14278 primarily intended to be constructed automatically using a binding generator
14279 tool, although it is possible to construct them by hand. No suitable binding
14280 generator tool is supplied with GNAT though.
14282 Using these pragmas it is possible to achieve complete
14283 inter-operability between Ada tagged types and C++ class definitions.
14284 See @ref{Implementation Defined Pragmas}, for more details.
14287 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
14288 The argument denotes an entity in the current declarative region that is
14289 declared as a tagged or untagged record type. It indicates that the type
14290 corresponds to an externally declared C++ class type, and is to be laid
14291 out the same way that C++ would lay out the type.
14293 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
14294 for backward compatibility but its functionality is available
14295 using pragma @code{Import} with @code{Convention} = @code{CPP}.
14297 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
14298 This pragma identifies an imported function (imported in the usual way
14299 with pragma @code{Import}) as corresponding to a C++ constructor.
14302 @node Interfacing to COBOL
14303 @section Interfacing to COBOL
14306 Interfacing to COBOL is achieved as described in section B.4 of
14307 the Ada Reference Manual.
14309 @node Interfacing to Fortran
14310 @section Interfacing to Fortran
14313 Interfacing to Fortran is achieved as described in section B.5 of the
14314 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
14315 multi-dimensional array causes the array to be stored in column-major
14316 order as required for convenient interface to Fortran.
14318 @node Interfacing to non-GNAT Ada code
14319 @section Interfacing to non-GNAT Ada code
14321 It is possible to specify the convention @code{Ada} in a pragma
14322 @code{Import} or pragma @code{Export}. However this refers to
14323 the calling conventions used by GNAT, which may or may not be
14324 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
14325 compiler to allow interoperation.
14327 If arguments types are kept simple, and if the foreign compiler generally
14328 follows system calling conventions, then it may be possible to integrate
14329 files compiled by other Ada compilers, provided that the elaboration
14330 issues are adequately addressed (for example by eliminating the
14331 need for any load time elaboration).
14333 In particular, GNAT running on VMS is designed to
14334 be highly compatible with the DEC Ada 83 compiler, so this is one
14335 case in which it is possible to import foreign units of this type,
14336 provided that the data items passed are restricted to simple scalar
14337 values or simple record types without variants, or simple array
14338 types with fixed bounds.
14340 @node Specialized Needs Annexes
14341 @chapter Specialized Needs Annexes
14344 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
14345 required in all implementations. However, as described in this chapter,
14346 GNAT implements all of these annexes:
14349 @item Systems Programming (Annex C)
14350 The Systems Programming Annex is fully implemented.
14352 @item Real-Time Systems (Annex D)
14353 The Real-Time Systems Annex is fully implemented.
14355 @item Distributed Systems (Annex E)
14356 Stub generation is fully implemented in the GNAT compiler. In addition,
14357 a complete compatible PCS is available as part of the GLADE system,
14358 a separate product. When the two
14359 products are used in conjunction, this annex is fully implemented.
14361 @item Information Systems (Annex F)
14362 The Information Systems annex is fully implemented.
14364 @item Numerics (Annex G)
14365 The Numerics Annex is fully implemented.
14367 @item Safety and Security / High-Integrity Systems (Annex H)
14368 The Safety and Security Annex (termed the High-Integrity Systems Annex
14369 in Ada 2005) is fully implemented.
14372 @node Implementation of Specific Ada Features
14373 @chapter Implementation of Specific Ada Features
14376 This chapter describes the GNAT implementation of several Ada language
14380 * Machine Code Insertions::
14381 * GNAT Implementation of Tasking::
14382 * GNAT Implementation of Shared Passive Packages::
14383 * Code Generation for Array Aggregates::
14384 * The Size of Discriminated Records with Default Discriminants::
14385 * Strict Conformance to the Ada Reference Manual::
14388 @node Machine Code Insertions
14389 @section Machine Code Insertions
14390 @cindex Machine Code insertions
14393 Package @code{Machine_Code} provides machine code support as described
14394 in the Ada Reference Manual in two separate forms:
14397 Machine code statements, consisting of qualified expressions that
14398 fit the requirements of RM section 13.8.
14400 An intrinsic callable procedure, providing an alternative mechanism of
14401 including machine instructions in a subprogram.
14405 The two features are similar, and both are closely related to the mechanism
14406 provided by the asm instruction in the GNU C compiler. Full understanding
14407 and use of the facilities in this package requires understanding the asm
14408 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
14409 by Richard Stallman. The relevant section is titled ``Extensions to the C
14410 Language Family'' @result{} ``Assembler Instructions with C Expression
14413 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
14414 semantic restrictions and effects as described below. Both are provided so
14415 that the procedure call can be used as a statement, and the function call
14416 can be used to form a code_statement.
14418 The first example given in the GCC documentation is the C @code{asm}
14421 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
14425 The equivalent can be written for GNAT as:
14427 @smallexample @c ada
14428 Asm ("fsinx %1 %0",
14429 My_Float'Asm_Output ("=f", result),
14430 My_Float'Asm_Input ("f", angle));
14434 The first argument to @code{Asm} is the assembler template, and is
14435 identical to what is used in GNU C@. This string must be a static
14436 expression. The second argument is the output operand list. It is
14437 either a single @code{Asm_Output} attribute reference, or a list of such
14438 references enclosed in parentheses (technically an array aggregate of
14441 The @code{Asm_Output} attribute denotes a function that takes two
14442 parameters. The first is a string, the second is the name of a variable
14443 of the type designated by the attribute prefix. The first (string)
14444 argument is required to be a static expression and designates the
14445 constraint for the parameter (e.g.@: what kind of register is
14446 required). The second argument is the variable to be updated with the
14447 result. The possible values for constraint are the same as those used in
14448 the RTL, and are dependent on the configuration file used to build the
14449 GCC back end. If there are no output operands, then this argument may
14450 either be omitted, or explicitly given as @code{No_Output_Operands}.
14452 The second argument of @code{@var{my_float}'Asm_Output} functions as
14453 though it were an @code{out} parameter, which is a little curious, but
14454 all names have the form of expressions, so there is no syntactic
14455 irregularity, even though normally functions would not be permitted
14456 @code{out} parameters. The third argument is the list of input
14457 operands. It is either a single @code{Asm_Input} attribute reference, or
14458 a list of such references enclosed in parentheses (technically an array
14459 aggregate of such references).
14461 The @code{Asm_Input} attribute denotes a function that takes two
14462 parameters. The first is a string, the second is an expression of the
14463 type designated by the prefix. The first (string) argument is required
14464 to be a static expression, and is the constraint for the parameter,
14465 (e.g.@: what kind of register is required). The second argument is the
14466 value to be used as the input argument. The possible values for the
14467 constant are the same as those used in the RTL, and are dependent on
14468 the configuration file used to built the GCC back end.
14470 If there are no input operands, this argument may either be omitted, or
14471 explicitly given as @code{No_Input_Operands}. The fourth argument, not
14472 present in the above example, is a list of register names, called the
14473 @dfn{clobber} argument. This argument, if given, must be a static string
14474 expression, and is a space or comma separated list of names of registers
14475 that must be considered destroyed as a result of the @code{Asm} call. If
14476 this argument is the null string (the default value), then the code
14477 generator assumes that no additional registers are destroyed.
14479 The fifth argument, not present in the above example, called the
14480 @dfn{volatile} argument, is by default @code{False}. It can be set to
14481 the literal value @code{True} to indicate to the code generator that all
14482 optimizations with respect to the instruction specified should be
14483 suppressed, and that in particular, for an instruction that has outputs,
14484 the instruction will still be generated, even if none of the outputs are
14485 used. See the full description in the GCC manual for further details.
14486 Generally it is strongly advisable to use Volatile for any ASM statement
14487 that is missing either input or output operands, or when two or more ASM
14488 statements appear in sequence, to avoid unwanted optimizations. A warning
14489 is generated if this advice is not followed.
14491 The @code{Asm} subprograms may be used in two ways. First the procedure
14492 forms can be used anywhere a procedure call would be valid, and
14493 correspond to what the RM calls ``intrinsic'' routines. Such calls can
14494 be used to intersperse machine instructions with other Ada statements.
14495 Second, the function forms, which return a dummy value of the limited
14496 private type @code{Asm_Insn}, can be used in code statements, and indeed
14497 this is the only context where such calls are allowed. Code statements
14498 appear as aggregates of the form:
14500 @smallexample @c ada
14501 Asm_Insn'(Asm (@dots{}));
14502 Asm_Insn'(Asm_Volatile (@dots{}));
14506 In accordance with RM rules, such code statements are allowed only
14507 within subprograms whose entire body consists of such statements. It is
14508 not permissible to intermix such statements with other Ada statements.
14510 Typically the form using intrinsic procedure calls is more convenient
14511 and more flexible. The code statement form is provided to meet the RM
14512 suggestion that such a facility should be made available. The following
14513 is the exact syntax of the call to @code{Asm}. As usual, if named notation
14514 is used, the arguments may be given in arbitrary order, following the
14515 normal rules for use of positional and named arguments)
14519 [Template =>] static_string_EXPRESSION
14520 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
14521 [,[Inputs =>] INPUT_OPERAND_LIST ]
14522 [,[Clobber =>] static_string_EXPRESSION ]
14523 [,[Volatile =>] static_boolean_EXPRESSION] )
14525 OUTPUT_OPERAND_LIST ::=
14526 [PREFIX.]No_Output_Operands
14527 | OUTPUT_OPERAND_ATTRIBUTE
14528 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
14530 OUTPUT_OPERAND_ATTRIBUTE ::=
14531 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
14533 INPUT_OPERAND_LIST ::=
14534 [PREFIX.]No_Input_Operands
14535 | INPUT_OPERAND_ATTRIBUTE
14536 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
14538 INPUT_OPERAND_ATTRIBUTE ::=
14539 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
14543 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
14544 are declared in the package @code{Machine_Code} and must be referenced
14545 according to normal visibility rules. In particular if there is no
14546 @code{use} clause for this package, then appropriate package name
14547 qualification is required.
14549 @node GNAT Implementation of Tasking
14550 @section GNAT Implementation of Tasking
14553 This chapter outlines the basic GNAT approach to tasking (in particular,
14554 a multi-layered library for portability) and discusses issues related
14555 to compliance with the Real-Time Systems Annex.
14558 * Mapping Ada Tasks onto the Underlying Kernel Threads::
14559 * Ensuring Compliance with the Real-Time Annex::
14562 @node Mapping Ada Tasks onto the Underlying Kernel Threads
14563 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
14566 GNAT's run-time support comprises two layers:
14569 @item GNARL (GNAT Run-time Layer)
14570 @item GNULL (GNAT Low-level Library)
14574 In GNAT, Ada's tasking services rely on a platform and OS independent
14575 layer known as GNARL@. This code is responsible for implementing the
14576 correct semantics of Ada's task creation, rendezvous, protected
14579 GNARL decomposes Ada's tasking semantics into simpler lower level
14580 operations such as create a thread, set the priority of a thread,
14581 yield, create a lock, lock/unlock, etc. The spec for these low-level
14582 operations constitutes GNULLI, the GNULL Interface. This interface is
14583 directly inspired from the POSIX real-time API@.
14585 If the underlying executive or OS implements the POSIX standard
14586 faithfully, the GNULL Interface maps as is to the services offered by
14587 the underlying kernel. Otherwise, some target dependent glue code maps
14588 the services offered by the underlying kernel to the semantics expected
14591 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
14592 key point is that each Ada task is mapped on a thread in the underlying
14593 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
14595 In addition Ada task priorities map onto the underlying thread priorities.
14596 Mapping Ada tasks onto the underlying kernel threads has several advantages:
14600 The underlying scheduler is used to schedule the Ada tasks. This
14601 makes Ada tasks as efficient as kernel threads from a scheduling
14605 Interaction with code written in C containing threads is eased
14606 since at the lowest level Ada tasks and C threads map onto the same
14607 underlying kernel concept.
14610 When an Ada task is blocked during I/O the remaining Ada tasks are
14614 On multiprocessor systems Ada tasks can execute in parallel.
14618 Some threads libraries offer a mechanism to fork a new process, with the
14619 child process duplicating the threads from the parent.
14621 support this functionality when the parent contains more than one task.
14622 @cindex Forking a new process
14624 @node Ensuring Compliance with the Real-Time Annex
14625 @subsection Ensuring Compliance with the Real-Time Annex
14626 @cindex Real-Time Systems Annex compliance
14629 Although mapping Ada tasks onto
14630 the underlying threads has significant advantages, it does create some
14631 complications when it comes to respecting the scheduling semantics
14632 specified in the real-time annex (Annex D).
14634 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
14635 scheduling policy states:
14638 @emph{When the active priority of a ready task that is not running
14639 changes, or the setting of its base priority takes effect, the
14640 task is removed from the ready queue for its old active priority
14641 and is added at the tail of the ready queue for its new active
14642 priority, except in the case where the active priority is lowered
14643 due to the loss of inherited priority, in which case the task is
14644 added at the head of the ready queue for its new active priority.}
14648 While most kernels do put tasks at the end of the priority queue when
14649 a task changes its priority, (which respects the main
14650 FIFO_Within_Priorities requirement), almost none keep a thread at the
14651 beginning of its priority queue when its priority drops from the loss
14652 of inherited priority.
14654 As a result most vendors have provided incomplete Annex D implementations.
14656 The GNAT run-time, has a nice cooperative solution to this problem
14657 which ensures that accurate FIFO_Within_Priorities semantics are
14660 The principle is as follows. When an Ada task T is about to start
14661 running, it checks whether some other Ada task R with the same
14662 priority as T has been suspended due to the loss of priority
14663 inheritance. If this is the case, T yields and is placed at the end of
14664 its priority queue. When R arrives at the front of the queue it
14667 Note that this simple scheme preserves the relative order of the tasks
14668 that were ready to execute in the priority queue where R has been
14671 @node GNAT Implementation of Shared Passive Packages
14672 @section GNAT Implementation of Shared Passive Packages
14673 @cindex Shared passive packages
14676 GNAT fully implements the pragma @code{Shared_Passive} for
14677 @cindex pragma @code{Shared_Passive}
14678 the purpose of designating shared passive packages.
14679 This allows the use of passive partitions in the
14680 context described in the Ada Reference Manual; i.e., for communication
14681 between separate partitions of a distributed application using the
14682 features in Annex E.
14684 @cindex Distribution Systems Annex
14686 However, the implementation approach used by GNAT provides for more
14687 extensive usage as follows:
14690 @item Communication between separate programs
14692 This allows separate programs to access the data in passive
14693 partitions, using protected objects for synchronization where
14694 needed. The only requirement is that the two programs have a
14695 common shared file system. It is even possible for programs
14696 running on different machines with different architectures
14697 (e.g.@: different endianness) to communicate via the data in
14698 a passive partition.
14700 @item Persistence between program runs
14702 The data in a passive package can persist from one run of a
14703 program to another, so that a later program sees the final
14704 values stored by a previous run of the same program.
14709 The implementation approach used is to store the data in files. A
14710 separate stream file is created for each object in the package, and
14711 an access to an object causes the corresponding file to be read or
14714 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
14715 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
14716 set to the directory to be used for these files.
14717 The files in this directory
14718 have names that correspond to their fully qualified names. For
14719 example, if we have the package
14721 @smallexample @c ada
14723 pragma Shared_Passive (X);
14730 and the environment variable is set to @code{/stemp/}, then the files created
14731 will have the names:
14739 These files are created when a value is initially written to the object, and
14740 the files are retained until manually deleted. This provides the persistence
14741 semantics. If no file exists, it means that no partition has assigned a value
14742 to the variable; in this case the initial value declared in the package
14743 will be used. This model ensures that there are no issues in synchronizing
14744 the elaboration process, since elaboration of passive packages elaborates the
14745 initial values, but does not create the files.
14747 The files are written using normal @code{Stream_IO} access.
14748 If you want to be able
14749 to communicate between programs or partitions running on different
14750 architectures, then you should use the XDR versions of the stream attribute
14751 routines, since these are architecture independent.
14753 If active synchronization is required for access to the variables in the
14754 shared passive package, then as described in the Ada Reference Manual, the
14755 package may contain protected objects used for this purpose. In this case
14756 a lock file (whose name is @file{___lock} (three underscores)
14757 is created in the shared memory directory.
14758 @cindex @file{___lock} file (for shared passive packages)
14759 This is used to provide the required locking
14760 semantics for proper protected object synchronization.
14762 As of January 2003, GNAT supports shared passive packages on all platforms
14763 except for OpenVMS.
14765 @node Code Generation for Array Aggregates
14766 @section Code Generation for Array Aggregates
14769 * Static constant aggregates with static bounds::
14770 * Constant aggregates with unconstrained nominal types::
14771 * Aggregates with static bounds::
14772 * Aggregates with non-static bounds::
14773 * Aggregates in assignment statements::
14777 Aggregates have a rich syntax and allow the user to specify the values of
14778 complex data structures by means of a single construct. As a result, the
14779 code generated for aggregates can be quite complex and involve loops, case
14780 statements and multiple assignments. In the simplest cases, however, the
14781 compiler will recognize aggregates whose components and constraints are
14782 fully static, and in those cases the compiler will generate little or no
14783 executable code. The following is an outline of the code that GNAT generates
14784 for various aggregate constructs. For further details, you will find it
14785 useful to examine the output produced by the -gnatG flag to see the expanded
14786 source that is input to the code generator. You may also want to examine
14787 the assembly code generated at various levels of optimization.
14789 The code generated for aggregates depends on the context, the component values,
14790 and the type. In the context of an object declaration the code generated is
14791 generally simpler than in the case of an assignment. As a general rule, static
14792 component values and static subtypes also lead to simpler code.
14794 @node Static constant aggregates with static bounds
14795 @subsection Static constant aggregates with static bounds
14798 For the declarations:
14799 @smallexample @c ada
14800 type One_Dim is array (1..10) of integer;
14801 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
14805 GNAT generates no executable code: the constant ar0 is placed in static memory.
14806 The same is true for constant aggregates with named associations:
14808 @smallexample @c ada
14809 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
14810 Cr3 : constant One_Dim := (others => 7777);
14814 The same is true for multidimensional constant arrays such as:
14816 @smallexample @c ada
14817 type two_dim is array (1..3, 1..3) of integer;
14818 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
14822 The same is true for arrays of one-dimensional arrays: the following are
14825 @smallexample @c ada
14826 type ar1b is array (1..3) of boolean;
14827 type ar_ar is array (1..3) of ar1b;
14828 None : constant ar1b := (others => false); -- fully static
14829 None2 : constant ar_ar := (1..3 => None); -- fully static
14833 However, for multidimensional aggregates with named associations, GNAT will
14834 generate assignments and loops, even if all associations are static. The
14835 following two declarations generate a loop for the first dimension, and
14836 individual component assignments for the second dimension:
14838 @smallexample @c ada
14839 Zero1: constant two_dim := (1..3 => (1..3 => 0));
14840 Zero2: constant two_dim := (others => (others => 0));
14843 @node Constant aggregates with unconstrained nominal types
14844 @subsection Constant aggregates with unconstrained nominal types
14847 In such cases the aggregate itself establishes the subtype, so that
14848 associations with @code{others} cannot be used. GNAT determines the
14849 bounds for the actual subtype of the aggregate, and allocates the
14850 aggregate statically as well. No code is generated for the following:
14852 @smallexample @c ada
14853 type One_Unc is array (natural range <>) of integer;
14854 Cr_Unc : constant One_Unc := (12,24,36);
14857 @node Aggregates with static bounds
14858 @subsection Aggregates with static bounds
14861 In all previous examples the aggregate was the initial (and immutable) value
14862 of a constant. If the aggregate initializes a variable, then code is generated
14863 for it as a combination of individual assignments and loops over the target
14864 object. The declarations
14866 @smallexample @c ada
14867 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
14868 Cr_Var2 : One_Dim := (others > -1);
14872 generate the equivalent of
14874 @smallexample @c ada
14880 for I in Cr_Var2'range loop
14885 @node Aggregates with non-static bounds
14886 @subsection Aggregates with non-static bounds
14889 If the bounds of the aggregate are not statically compatible with the bounds
14890 of the nominal subtype of the target, then constraint checks have to be
14891 generated on the bounds. For a multidimensional array, constraint checks may
14892 have to be applied to sub-arrays individually, if they do not have statically
14893 compatible subtypes.
14895 @node Aggregates in assignment statements
14896 @subsection Aggregates in assignment statements
14899 In general, aggregate assignment requires the construction of a temporary,
14900 and a copy from the temporary to the target of the assignment. This is because
14901 it is not always possible to convert the assignment into a series of individual
14902 component assignments. For example, consider the simple case:
14904 @smallexample @c ada
14909 This cannot be converted into:
14911 @smallexample @c ada
14917 So the aggregate has to be built first in a separate location, and then
14918 copied into the target. GNAT recognizes simple cases where this intermediate
14919 step is not required, and the assignments can be performed in place, directly
14920 into the target. The following sufficient criteria are applied:
14924 The bounds of the aggregate are static, and the associations are static.
14926 The components of the aggregate are static constants, names of
14927 simple variables that are not renamings, or expressions not involving
14928 indexed components whose operands obey these rules.
14932 If any of these conditions are violated, the aggregate will be built in
14933 a temporary (created either by the front-end or the code generator) and then
14934 that temporary will be copied onto the target.
14937 @node The Size of Discriminated Records with Default Discriminants
14938 @section The Size of Discriminated Records with Default Discriminants
14941 If a discriminated type @code{T} has discriminants with default values, it is
14942 possible to declare an object of this type without providing an explicit
14945 @smallexample @c ada
14947 type Size is range 1..100;
14949 type Rec (D : Size := 15) is record
14950 Name : String (1..D);
14958 Such an object is said to be @emph{unconstrained}.
14959 The discriminant of the object
14960 can be modified by a full assignment to the object, as long as it preserves the
14961 relation between the value of the discriminant, and the value of the components
14964 @smallexample @c ada
14966 Word := (3, "yes");
14968 Word := (5, "maybe");
14970 Word := (5, "no"); -- raises Constraint_Error
14975 In order to support this behavior efficiently, an unconstrained object is
14976 given the maximum size that any value of the type requires. In the case
14977 above, @code{Word} has storage for the discriminant and for
14978 a @code{String} of length 100.
14979 It is important to note that unconstrained objects do not require dynamic
14980 allocation. It would be an improper implementation to place on the heap those
14981 components whose size depends on discriminants. (This improper implementation
14982 was used by some Ada83 compilers, where the @code{Name} component above
14984 been stored as a pointer to a dynamic string). Following the principle that
14985 dynamic storage management should never be introduced implicitly,
14986 an Ada compiler should reserve the full size for an unconstrained declared
14987 object, and place it on the stack.
14989 This maximum size approach
14990 has been a source of surprise to some users, who expect the default
14991 values of the discriminants to determine the size reserved for an
14992 unconstrained object: ``If the default is 15, why should the object occupy
14994 The answer, of course, is that the discriminant may be later modified,
14995 and its full range of values must be taken into account. This is why the
15000 type Rec (D : Positive := 15) is record
15001 Name : String (1..D);
15009 is flagged by the compiler with a warning:
15010 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15011 because the required size includes @code{Positive'Last}
15012 bytes. As the first example indicates, the proper approach is to declare an
15013 index type of ``reasonable'' range so that unconstrained objects are not too
15016 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15017 created in the heap by means of an allocator, then it is @emph{not}
15019 it is constrained by the default values of the discriminants, and those values
15020 cannot be modified by full assignment. This is because in the presence of
15021 aliasing all views of the object (which may be manipulated by different tasks,
15022 say) must be consistent, so it is imperative that the object, once created,
15025 @node Strict Conformance to the Ada Reference Manual
15026 @section Strict Conformance to the Ada Reference Manual
15029 The dynamic semantics defined by the Ada Reference Manual impose a set of
15030 run-time checks to be generated. By default, the GNAT compiler will insert many
15031 run-time checks into the compiled code, including most of those required by the
15032 Ada Reference Manual. However, there are three checks that are not enabled
15033 in the default mode for efficiency reasons: arithmetic overflow checking for
15034 integer operations (including division by zero), checks for access before
15035 elaboration on subprogram calls, and stack overflow checking (most operating
15036 systems do not perform this check by default).
15038 Strict conformance to the Ada Reference Manual can be achieved by adding
15039 three compiler options for overflow checking for integer operations
15040 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15041 calls and generic instantiations (@option{-gnatE}), and stack overflow
15042 checking (@option{-fstack-check}).
15044 Note that the result of a floating point arithmetic operation in overflow and
15045 invalid situations, when the @code{Machine_Overflows} attribute of the result
15046 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15047 case for machines compliant with the IEEE floating-point standard, but on
15048 machines that are not fully compliant with this standard, such as Alpha, the
15049 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15050 behavior (although at the cost of a significant performance penalty), so
15051 infinite and and NaN values are properly generated.
15054 @node Project File Reference
15055 @chapter Project File Reference
15058 This chapter describes the syntax and semantics of project files.
15059 Project files specify the options to be used when building a system.
15060 Project files can specify global settings for all tools,
15061 as well as tool-specific settings.
15062 See the chapter on project files in the GNAT Users guide for examples of use.
15066 * Lexical Elements::
15068 * Empty declarations::
15069 * Typed string declarations::
15073 * Project Attributes::
15074 * Attribute References::
15075 * External Values::
15076 * Case Construction::
15078 * Package Renamings::
15080 * Project Extensions::
15081 * Project File Elaboration::
15084 @node Reserved Words
15085 @section Reserved Words
15088 All Ada reserved words are reserved in project files, and cannot be used
15089 as variable names or project names. In addition, the following are
15090 also reserved in project files:
15093 @item @code{extends}
15095 @item @code{external}
15097 @item @code{project}
15101 @node Lexical Elements
15102 @section Lexical Elements
15105 Rules for identifiers are the same as in Ada. Identifiers
15106 are case-insensitive. Strings are case sensitive, except where noted.
15107 Comments have the same form as in Ada.
15117 simple_name @{. simple_name@}
15121 @section Declarations
15124 Declarations introduce new entities that denote types, variables, attributes,
15125 and packages. Some declarations can only appear immediately within a project
15126 declaration. Others can appear within a project or within a package.
15130 declarative_item ::=
15131 simple_declarative_item |
15132 typed_string_declaration |
15133 package_declaration
15135 simple_declarative_item ::=
15136 variable_declaration |
15137 typed_variable_declaration |
15138 attribute_declaration |
15139 case_construction |
15143 @node Empty declarations
15144 @section Empty declarations
15147 empty_declaration ::=
15151 An empty declaration is allowed anywhere a declaration is allowed.
15154 @node Typed string declarations
15155 @section Typed string declarations
15158 Typed strings are sequences of string literals. Typed strings are the only
15159 named types in project files. They are used in case constructions, where they
15160 provide support for conditional attribute definitions.
15164 typed_string_declaration ::=
15165 @b{type} <typed_string_>_simple_name @b{is}
15166 ( string_literal @{, string_literal@} );
15170 A typed string declaration can only appear immediately within a project
15173 All the string literals in a typed string declaration must be distinct.
15179 Variables denote values, and appear as constituents of expressions.
15182 typed_variable_declaration ::=
15183 <typed_variable_>simple_name : <typed_string_>name := string_expression ;
15185 variable_declaration ::=
15186 <variable_>simple_name := expression;
15190 The elaboration of a variable declaration introduces the variable and
15191 assigns to it the value of the expression. The name of the variable is
15192 available after the assignment symbol.
15195 A typed_variable can only be declare once.
15198 a non-typed variable can be declared multiple times.
15201 Before the completion of its first declaration, the value of variable
15202 is the null string.
15205 @section Expressions
15208 An expression is a formula that defines a computation or retrieval of a value.
15209 In a project file the value of an expression is either a string or a list
15210 of strings. A string value in an expression is either a literal, the current
15211 value of a variable, an external value, an attribute reference, or a
15212 concatenation operation.
15225 attribute_reference
15231 ( <string_>expression @{ , <string_>expression @} )
15234 @subsection Concatenation
15236 The following concatenation functions are defined:
15238 @smallexample @c ada
15239 function "&" (X : String; Y : String) return String;
15240 function "&" (X : String_List; Y : String) return String_List;
15241 function "&" (X : String_List; Y : String_List) return String_List;
15245 @section Attributes
15248 An attribute declaration defines a property of a project or package. This
15249 property can later be queried by means of an attribute reference.
15250 Attribute values are strings or string lists.
15252 Some attributes are associative arrays. These attributes are mappings whose
15253 domain is a set of strings. These attributes are declared one association
15254 at a time, by specifying a point in the domain and the corresponding image
15255 of the attribute. They may also be declared as a full associative array,
15256 getting the same associations as the corresponding attribute in an imported
15257 or extended project.
15259 Attributes that are not associative arrays are called simple attributes.
15263 attribute_declaration ::=
15264 full_associative_array_declaration |
15265 @b{for} attribute_designator @b{use} expression ;
15267 full_associative_array_declaration ::=
15268 @b{for} <associative_array_attribute_>simple_name @b{use}
15269 <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
15271 attribute_designator ::=
15272 <simple_attribute_>simple_name |
15273 <associative_array_attribute_>simple_name ( string_literal )
15277 Some attributes are project-specific, and can only appear immediately within
15278 a project declaration. Others are package-specific, and can only appear within
15279 the proper package.
15281 The expression in an attribute definition must be a string or a string_list.
15282 The string literal appearing in the attribute_designator of an associative
15283 array attribute is case-insensitive.
15285 @node Project Attributes
15286 @section Project Attributes
15289 The following attributes apply to a project. All of them are simple
15294 Expression must be a path name. The attribute defines the
15295 directory in which the object files created by the build are to be placed. If
15296 not specified, object files are placed in the project directory.
15299 Expression must be a path name. The attribute defines the
15300 directory in which the executables created by the build are to be placed.
15301 If not specified, executables are placed in the object directory.
15304 Expression must be a list of path names. The attribute
15305 defines the directories in which the source files for the project are to be
15306 found. If not specified, source files are found in the project directory.
15307 If a string in the list ends with "/**", then the directory that precedes
15308 "/**" and all of its subdirectories (recursively) are included in the list
15309 of source directories.
15311 @item Excluded_Source_Dirs
15312 Expression must be a list of strings. Each entry designates a directory that
15313 is not to be included in the list of source directories of the project.
15314 This is normally used when there are strings ending with "/**" in the value
15315 of attribute Source_Dirs.
15318 Expression must be a list of file names. The attribute
15319 defines the individual files, in the project directory, which are to be used
15320 as sources for the project. File names are path_names that contain no directory
15321 information. If the project has no sources the attribute must be declared
15322 explicitly with an empty list.
15324 @item Excluded_Source_Files (Locally_Removed_Files)
15325 Expression must be a list of strings that are legal file names.
15326 Each file name must designate a source that would normally be a source file
15327 in the source directories of the project or, if the project file is an
15328 extending project file, inherited by the current project file. It cannot
15329 designate an immediate source that is not inherited. Each of the source files
15330 in the list are not considered to be sources of the project file: they are not
15331 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
15332 Excluded_Source_Files is preferred.
15334 @item Source_List_File
15335 Expression must a single path name. The attribute
15336 defines a text file that contains a list of source file names to be used
15337 as sources for the project
15340 Expression must be a path name. The attribute defines the
15341 directory in which a library is to be built. The directory must exist, must
15342 be distinct from the project's object directory, and must be writable.
15345 Expression must be a string that is a legal file name,
15346 without extension. The attribute defines a string that is used to generate
15347 the name of the library to be built by the project.
15350 Argument must be a string value that must be one of the
15351 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
15352 string is case-insensitive. If this attribute is not specified, the library is
15353 a static library. Otherwise, the library may be dynamic or relocatable. This
15354 distinction is operating-system dependent.
15356 @item Library_Version
15357 Expression must be a string value whose interpretation
15358 is platform dependent. On UNIX, it is used only for dynamic/relocatable
15359 libraries as the internal name of the library (the @code{"soname"}). If the
15360 library file name (built from the @code{Library_Name}) is different from the
15361 @code{Library_Version}, then the library file will be a symbolic link to the
15362 actual file whose name will be @code{Library_Version}.
15364 @item Library_Interface
15365 Expression must be a string list. Each element of the string list
15366 must designate a unit of the project.
15367 If this attribute is present in a Library Project File, then the project
15368 file is a Stand-alone Library_Project_File.
15370 @item Library_Auto_Init
15371 Expression must be a single string "true" or "false", case-insensitive.
15372 If this attribute is present in a Stand-alone Library Project File,
15373 it indicates if initialization is automatic when the dynamic library
15376 @item Library_Options
15377 Expression must be a string list. Indicates additional switches that
15378 are to be used when building a shared library.
15381 Expression must be a single string. Designates an alternative to "gcc"
15382 for building shared libraries.
15384 @item Library_Src_Dir
15385 Expression must be a path name. The attribute defines the
15386 directory in which the sources of the interfaces of a Stand-alone Library will
15387 be copied. The directory must exist, must be distinct from the project's
15388 object directory and source directories of all projects in the project tree,
15389 and must be writable.
15391 @item Library_Src_Dir
15392 Expression must be a path name. The attribute defines the
15393 directory in which the ALI files of a Library will
15394 be copied. The directory must exist, must be distinct from the project's
15395 object directory and source directories of all projects in the project tree,
15396 and must be writable.
15398 @item Library_Symbol_File
15399 Expression must be a single string. Its value is the single file name of a
15400 symbol file to be created when building a stand-alone library when the
15401 symbol policy is either "compliant", "controlled" or "restricted",
15402 on platforms that support symbol control, such as VMS. When symbol policy
15403 is "direct", then a file with this name must exist in the object directory.
15405 @item Library_Reference_Symbol_File
15406 Expression must be a single string. Its value is the path name of a
15407 reference symbol file that is read when the symbol policy is either
15408 "compliant" or "controlled", on platforms that support symbol control,
15409 such as VMS, when building a stand-alone library. The path may be an absolute
15410 path or a path relative to the project directory.
15412 @item Library_Symbol_Policy
15413 Expression must be a single string. Its case-insensitive value can only be
15414 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
15416 This attribute is not taken into account on all platforms. It controls the
15417 policy for exported symbols and, on some platforms (like VMS) that have the
15418 notions of major and minor IDs built in the library files, it controls
15419 the setting of these IDs.
15421 "autonomous" or "default": exported symbols are not controlled.
15423 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
15424 it is equivalent to policy "autonomous". If there are exported symbols in
15425 the reference symbol file that are not in the object files of the interfaces,
15426 the major ID of the library is increased. If there are symbols in the
15427 object files of the interfaces that are not in the reference symbol file,
15428 these symbols are put at the end of the list in the newly created symbol file
15429 and the minor ID is increased.
15431 "controlled": the attribute Library_Reference_Symbol_File must be defined.
15432 The library will fail to build if the exported symbols in the object files of
15433 the interfaces do not match exactly the symbol in the symbol file.
15435 "restricted": The attribute Library_Symbol_File must be defined. The library
15436 will fail to build if there are symbols in the symbol file that are not in
15437 the exported symbols of the object files of the interfaces. Additional symbols
15438 in the object files are not added to the symbol file.
15440 "direct": The attribute Library_Symbol_File must be defined and must designate
15441 an existing file in the object directory. This symbol file is passed directly
15442 to the underlying linker without any symbol processing.
15445 Expression must be a list of strings that are legal file names.
15446 These file names designate existing compilation units in the source directory
15447 that are legal main subprograms.
15449 When a project file is elaborated, as part of the execution of a gnatmake
15450 command, one or several executables are built and placed in the Exec_Dir.
15451 If the gnatmake command does not include explicit file names, the executables
15452 that are built correspond to the files specified by this attribute.
15454 @item Externally_Built
15455 Expression must be a single string. Its value must be either "true" of "false",
15456 case-insensitive. The default is "false". When the value of this attribute is
15457 "true", no attempt is made to compile the sources or to build the library,
15458 when the project is a library project.
15460 @item Main_Language
15461 This is a simple attribute. Its value is a string that specifies the
15462 language of the main program.
15465 Expression must be a string list. Each string designates
15466 a programming language that is known to GNAT. The strings are case-insensitive.
15470 @node Attribute References
15471 @section Attribute References
15474 Attribute references are used to retrieve the value of previously defined
15475 attribute for a package or project.
15478 attribute_reference ::=
15479 attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
15481 attribute_prefix ::=
15483 <project_simple_name | package_identifier |
15484 <project_>simple_name . package_identifier
15488 If an attribute has not been specified for a given package or project, its
15489 value is the null string or the empty list.
15491 @node External Values
15492 @section External Values
15495 An external value is an expression whose value is obtained from the command
15496 that invoked the processing of the current project file (typically a
15502 @b{external} ( string_literal [, string_literal] )
15506 The first string_literal is the string to be used on the command line or
15507 in the environment to specify the external value. The second string_literal,
15508 if present, is the default to use if there is no specification for this
15509 external value either on the command line or in the environment.
15511 @node Case Construction
15512 @section Case Construction
15515 A case construction supports attribute and variable declarations that depend
15516 on the value of a previously declared variable.
15520 case_construction ::=
15521 @b{case} <typed_variable_>name @b{is}
15526 @b{when} discrete_choice_list =>
15527 @{case_construction |
15528 attribute_declaration |
15529 variable_declaration |
15530 empty_declaration@}
15532 discrete_choice_list ::=
15533 string_literal @{| string_literal@} |
15538 Inside a case construction, variable declarations must be for variables that
15539 have already been declared before the case construction.
15541 All choices in a choice list must be distinct. The choice lists of two
15542 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
15543 alternatives do not need to include all values of the type. An @code{others}
15544 choice must appear last in the list of alternatives.
15550 A package provides a grouping of variable declarations and attribute
15551 declarations to be used when invoking various GNAT tools. The name of
15552 the package indicates the tool(s) to which it applies.
15556 package_declaration ::=
15557 package_specification | package_renaming
15559 package_specification ::=
15560 @b{package} package_identifier @b{is}
15561 @{simple_declarative_item@}
15562 @b{end} package_identifier ;
15564 package_identifier ::=
15565 @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
15566 @code{Linker} | @code{Finder} | @code{Cross_Reference} |
15567 @code{gnatls} | @code{IDE} | @code{Pretty_Printer}
15570 @subsection Package Naming
15573 The attributes of a @code{Naming} package specifies the naming conventions
15574 that apply to the source files in a project. When invoking other GNAT tools,
15575 they will use the sources in the source directories that satisfy these
15576 naming conventions.
15578 The following attributes apply to a @code{Naming} package:
15582 This is a simple attribute whose value is a string. Legal values of this
15583 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
15584 These strings are themselves case insensitive.
15587 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
15589 @item Dot_Replacement
15590 This is a simple attribute whose string value satisfies the following
15594 @item It must not be empty
15595 @item It cannot start or end with an alphanumeric character
15596 @item It cannot be a single underscore
15597 @item It cannot start with an underscore followed by an alphanumeric
15598 @item It cannot contain a dot @code{'.'} if longer than one character
15602 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
15605 This is an associative array attribute, defined on language names,
15606 whose image is a string that must satisfy the following
15610 @item It must not be empty
15611 @item It cannot start with an alphanumeric character
15612 @item It cannot start with an underscore followed by an alphanumeric character
15616 For Ada, the attribute denotes the suffix used in file names that contain
15617 library unit declarations, that is to say units that are package and
15618 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
15619 specified, then the default is @code{".ads"}.
15621 For C and C++, the attribute denotes the suffix used in file names that
15622 contain prototypes.
15625 This is an associative array attribute defined on language names,
15626 whose image is a string that must satisfy the following
15630 @item It must not be empty
15631 @item It cannot start with an alphanumeric character
15632 @item It cannot start with an underscore followed by an alphanumeric character
15633 @item It cannot be a suffix of @code{Spec_Suffix}
15637 For Ada, the attribute denotes the suffix used in file names that contain
15638 library bodies, that is to say units that are package and subprogram bodies.
15639 If @code{Body_Suffix ("Ada")} is not specified, then the default is
15642 For C and C++, the attribute denotes the suffix used in file names that contain
15645 @item Separate_Suffix
15646 This is a simple attribute whose value satisfies the same conditions as
15647 @code{Body_Suffix}.
15649 This attribute is specific to Ada. It denotes the suffix used in file names
15650 that contain separate bodies. If it is not specified, then it defaults to same
15651 value as @code{Body_Suffix ("Ada")}.
15654 This is an associative array attribute, specific to Ada, defined over
15655 compilation unit names. The image is a string that is the name of the file
15656 that contains that library unit. The file name is case sensitive if the
15657 conventions of the host operating system require it.
15660 This is an associative array attribute, specific to Ada, defined over
15661 compilation unit names. The image is a string that is the name of the file
15662 that contains the library unit body for the named unit. The file name is case
15663 sensitive if the conventions of the host operating system require it.
15665 @item Specification_Exceptions
15666 This is an associative array attribute defined on language names,
15667 whose value is a list of strings.
15669 This attribute is not significant for Ada.
15671 For C and C++, each string in the list denotes the name of a file that
15672 contains prototypes, but whose suffix is not necessarily the
15673 @code{Spec_Suffix} for the language.
15675 @item Implementation_Exceptions
15676 This is an associative array attribute defined on language names,
15677 whose value is a list of strings.
15679 This attribute is not significant for Ada.
15681 For C and C++, each string in the list denotes the name of a file that
15682 contains source code, but whose suffix is not necessarily the
15683 @code{Body_Suffix} for the language.
15686 The following attributes of package @code{Naming} are obsolescent. They are
15687 kept as synonyms of other attributes for compatibility with previous versions
15688 of the Project Manager.
15691 @item Specification_Suffix
15692 This is a synonym of @code{Spec_Suffix}.
15694 @item Implementation_Suffix
15695 This is a synonym of @code{Body_Suffix}.
15697 @item Specification
15698 This is a synonym of @code{Spec}.
15700 @item Implementation
15701 This is a synonym of @code{Body}.
15704 @subsection package Compiler
15707 The attributes of the @code{Compiler} package specify the compilation options
15708 to be used by the underlying compiler.
15711 @item Default_Switches
15712 This is an associative array attribute. Its
15713 domain is a set of language names. Its range is a string list that
15714 specifies the compilation options to be used when compiling a component
15715 written in that language, for which no file-specific switches have been
15719 This is an associative array attribute. Its domain is
15720 a set of file names. Its range is a string list that specifies the
15721 compilation options to be used when compiling the named file. If a file
15722 is not specified in the Switches attribute, it is compiled with the
15723 options specified by Default_Switches of its language, if defined.
15725 @item Local_Configuration_Pragmas.
15726 This is a simple attribute, whose
15727 value is a path name that designates a file containing configuration pragmas
15728 to be used for all invocations of the compiler for immediate sources of the
15732 @subsection package Builder
15735 The attributes of package @code{Builder} specify the compilation, binding, and
15736 linking options to be used when building an executable for a project. The
15737 following attributes apply to package @code{Builder}:
15740 @item Default_Switches
15741 This is an associative array attribute. Its
15742 domain is a set of language names. Its range is a string list that
15743 specifies options to be used when building a main
15744 written in that language, for which no file-specific switches have been
15748 This is an associative array attribute. Its domain is
15749 a set of file names. Its range is a string list that specifies
15750 options to be used when building the named main file. If a main file
15751 is not specified in the Switches attribute, it is built with the
15752 options specified by Default_Switches of its language, if defined.
15754 @item Global_Configuration_Pragmas
15755 This is a simple attribute, whose
15756 value is a path name that designates a file that contains configuration pragmas
15757 to be used in every build of an executable. If both local and global
15758 configuration pragmas are specified, a compilation makes use of both sets.
15762 This is an associative array attribute. Its domain is
15763 a set of main source file names. Its range is a simple string that specifies
15764 the executable file name to be used when linking the specified main source.
15765 If a main source is not specified in the Executable attribute, the executable
15766 file name is deducted from the main source file name.
15767 This attribute has no effect if its value is the empty string.
15769 @item Executable_Suffix
15770 This is a simple attribute whose value is the suffix to be added to
15771 the executables that don't have an attribute Executable specified.
15774 @subsection package Gnatls
15777 The attributes of package @code{Gnatls} specify the tool options to be used
15778 when invoking the library browser @command{gnatls}.
15779 The following attributes apply to package @code{Gnatls}:
15783 This is a single attribute with a string list value. Each nonempty string
15784 in the list is an option when invoking @code{gnatls}.
15787 @subsection package Binder
15790 The attributes of package @code{Binder} specify the options to be used
15791 when invoking the binder in the construction of an executable.
15792 The following attributes apply to package @code{Binder}:
15795 @item Default_Switches
15796 This is an associative array attribute. Its
15797 domain is a set of language names. Its range is a string list that
15798 specifies options to be used when binding a main
15799 written in that language, for which no file-specific switches have been
15803 This is an associative array attribute. Its domain is
15804 a set of file names. Its range is a string list that specifies
15805 options to be used when binding the named main file. If a main file
15806 is not specified in the Switches attribute, it is bound with the
15807 options specified by Default_Switches of its language, if defined.
15810 @subsection package Linker
15813 The attributes of package @code{Linker} specify the options to be used when
15814 invoking the linker in the construction of an executable.
15815 The following attributes apply to package @code{Linker}:
15818 @item Default_Switches
15819 This is an associative array attribute. Its
15820 domain is a set of language names. Its range is a string list that
15821 specifies options to be used when linking a main
15822 written in that language, for which no file-specific switches have been
15826 This is an associative array attribute. Its domain is
15827 a set of file names. Its range is a string list that specifies
15828 options to be used when linking the named main file. If a main file
15829 is not specified in the Switches attribute, it is linked with the
15830 options specified by Default_Switches of its language, if defined.
15832 @item Linker_Options
15833 This is a string list attribute. Its value specifies additional options that
15834 be given to the linker when linking an executable. This attribute is not
15835 used in the main project, only in projects imported directly or indirectly.
15839 @subsection package Cross_Reference
15842 The attributes of package @code{Cross_Reference} specify the tool options
15844 when invoking the library tool @command{gnatxref}.
15845 The following attributes apply to package @code{Cross_Reference}:
15848 @item Default_Switches
15849 This is an associative array attribute. Its
15850 domain is a set of language names. Its range is a string list that
15851 specifies options to be used when calling @command{gnatxref} on a source
15852 written in that language, for which no file-specific switches have been
15856 This is an associative array attribute. Its domain is
15857 a set of file names. Its range is a string list that specifies
15858 options to be used when calling @command{gnatxref} on the named main source.
15859 If a source is not specified in the Switches attribute, @command{gnatxref} will
15860 be called with the options specified by Default_Switches of its language,
15864 @subsection package Finder
15867 The attributes of package @code{Finder} specify the tool options to be used
15868 when invoking the search tool @command{gnatfind}.
15869 The following attributes apply to package @code{Finder}:
15872 @item Default_Switches
15873 This is an associative array attribute. Its
15874 domain is a set of language names. Its range is a string list that
15875 specifies options to be used when calling @command{gnatfind} on a source
15876 written in that language, for which no file-specific switches have been
15880 This is an associative array attribute. Its domain is
15881 a set of file names. Its range is a string list that specifies
15882 options to be used when calling @command{gnatfind} on the named main source.
15883 If a source is not specified in the Switches attribute, @command{gnatfind} will
15884 be called with the options specified by Default_Switches of its language,
15888 @subsection package Pretty_Printer
15891 The attributes of package @code{Pretty_Printer}
15892 specify the tool options to be used
15893 when invoking the formatting tool @command{gnatpp}.
15894 The following attributes apply to package @code{Pretty_Printer}:
15897 @item Default_switches
15898 This is an associative array attribute. Its
15899 domain is a set of language names. Its range is a string list that
15900 specifies options to be used when calling @command{gnatpp} on a source
15901 written in that language, for which no file-specific switches have been
15905 This is an associative array attribute. Its domain is
15906 a set of file names. Its range is a string list that specifies
15907 options to be used when calling @command{gnatpp} on the named main source.
15908 If a source is not specified in the Switches attribute, @command{gnatpp} will
15909 be called with the options specified by Default_Switches of its language,
15913 @subsection package gnatstub
15916 The attributes of package @code{gnatstub}
15917 specify the tool options to be used
15918 when invoking the tool @command{gnatstub}.
15919 The following attributes apply to package @code{gnatstub}:
15922 @item Default_switches
15923 This is an associative array attribute. Its
15924 domain is a set of language names. Its range is a string list that
15925 specifies options to be used when calling @command{gnatstub} on a source
15926 written in that language, for which no file-specific switches have been
15930 This is an associative array attribute. Its domain is
15931 a set of file names. Its range is a string list that specifies
15932 options to be used when calling @command{gnatstub} on the named main source.
15933 If a source is not specified in the Switches attribute, @command{gnatpp} will
15934 be called with the options specified by Default_Switches of its language,
15938 @subsection package Eliminate
15941 The attributes of package @code{Eliminate}
15942 specify the tool options to be used
15943 when invoking the tool @command{gnatelim}.
15944 The following attributes apply to package @code{Eliminate}:
15947 @item Default_switches
15948 This is an associative array attribute. Its
15949 domain is a set of language names. Its range is a string list that
15950 specifies options to be used when calling @command{gnatelim} on a source
15951 written in that language, for which no file-specific switches have been
15955 This is an associative array attribute. Its domain is
15956 a set of file names. Its range is a string list that specifies
15957 options to be used when calling @command{gnatelim} on the named main source.
15958 If a source is not specified in the Switches attribute, @command{gnatelim} will
15959 be called with the options specified by Default_Switches of its language,
15963 @subsection package Metrics
15966 The attributes of package @code{Metrics}
15967 specify the tool options to be used
15968 when invoking the tool @command{gnatmetric}.
15969 The following attributes apply to package @code{Metrics}:
15972 @item Default_switches
15973 This is an associative array attribute. Its
15974 domain is a set of language names. Its range is a string list that
15975 specifies options to be used when calling @command{gnatmetric} on a source
15976 written in that language, for which no file-specific switches have been
15980 This is an associative array attribute. Its domain is
15981 a set of file names. Its range is a string list that specifies
15982 options to be used when calling @command{gnatmetric} on the named main source.
15983 If a source is not specified in the Switches attribute, @command{gnatmetric}
15984 will be called with the options specified by Default_Switches of its language,
15988 @subsection package IDE
15991 The attributes of package @code{IDE} specify the options to be used when using
15992 an Integrated Development Environment such as @command{GPS}.
15996 This is a simple attribute. Its value is a string that designates the remote
15997 host in a cross-compilation environment, to be used for remote compilation and
15998 debugging. This field should not be specified when running on the local
16002 This is a simple attribute. Its value is a string that specifies the
16003 name of IP address of the embedded target in a cross-compilation environment,
16004 on which the program should execute.
16006 @item Communication_Protocol
16007 This is a simple string attribute. Its value is the name of the protocol
16008 to use to communicate with the target in a cross-compilation environment,
16009 e.g.@: @code{"wtx"} or @code{"vxworks"}.
16011 @item Compiler_Command
16012 This is an associative array attribute, whose domain is a language name. Its
16013 value is string that denotes the command to be used to invoke the compiler.
16014 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16015 gnatmake, in particular in the handling of switches.
16017 @item Debugger_Command
16018 This is simple attribute, Its value is a string that specifies the name of
16019 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16021 @item Default_Switches
16022 This is an associative array attribute. Its indexes are the name of the
16023 external tools that the GNAT Programming System (GPS) is supporting. Its
16024 value is a list of switches to use when invoking that tool.
16027 This is a simple attribute. Its value is a string that specifies the name
16028 of the @command{gnatls} utility to be used to retrieve information about the
16029 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16032 This is a simple attribute. Its value is a string used to specify the
16033 Version Control System (VCS) to be used for this project, e.g.@: CVS, RCS
16034 ClearCase or Perforce.
16036 @item VCS_File_Check
16037 This is a simple attribute. Its value is a string that specifies the
16038 command used by the VCS to check the validity of a file, either
16039 when the user explicitly asks for a check, or as a sanity check before
16040 doing the check-in.
16042 @item VCS_Log_Check
16043 This is a simple attribute. Its value is a string that specifies
16044 the command used by the VCS to check the validity of a log file.
16046 @item VCS_Repository_Root
16047 The VCS repository root path. This is used to create tags or branches
16048 of the repository. For subversion the value should be the @code{URL}
16049 as specified to check-out the working copy of the repository.
16051 @item VCS_Patch_Root
16052 The local root directory to use for building patch file. All patch chunks
16053 will be relative to this path. The root project directory is used if
16054 this value is not defined.
16058 @node Package Renamings
16059 @section Package Renamings
16062 A package can be defined by a renaming declaration. The new package renames
16063 a package declared in a different project file, and has the same attributes
16064 as the package it renames.
16067 package_renaming ::==
16068 @b{package} package_identifier @b{renames}
16069 <project_>simple_name.package_identifier ;
16073 The package_identifier of the renamed package must be the same as the
16074 package_identifier. The project whose name is the prefix of the renamed
16075 package must contain a package declaration with this name. This project
16076 must appear in the context_clause of the enclosing project declaration,
16077 or be the parent project of the enclosing child project.
16083 A project file specifies a set of rules for constructing a software system.
16084 A project file can be self-contained, or depend on other project files.
16085 Dependencies are expressed through a context clause that names other projects.
16091 context_clause project_declaration
16093 project_declaration ::=
16094 simple_project_declaration | project_extension
16096 simple_project_declaration ::=
16097 @b{project} <project_>simple_name @b{is}
16098 @{declarative_item@}
16099 @b{end} <project_>simple_name;
16105 [@b{limited}] @b{with} path_name @{ , path_name @} ;
16112 A path name denotes a project file. A path name can be absolute or relative.
16113 An absolute path name includes a sequence of directories, in the syntax of
16114 the host operating system, that identifies uniquely the project file in the
16115 file system. A relative path name identifies the project file, relative
16116 to the directory that contains the current project, or relative to a
16117 directory listed in the environment variable ADA_PROJECT_PATH.
16118 Path names are case sensitive if file names in the host operating system
16119 are case sensitive.
16121 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16122 directory names separated by colons (semicolons on Windows).
16124 A given project name can appear only once in a context_clause.
16126 It is illegal for a project imported by a context clause to refer, directly
16127 or indirectly, to the project in which this context clause appears (the
16128 dependency graph cannot contain cycles), except when one of the with_clause
16129 in the cycle is a @code{limited with}.
16131 @node Project Extensions
16132 @section Project Extensions
16135 A project extension introduces a new project, which inherits the declarations
16136 of another project.
16140 project_extension ::=
16141 @b{project} <project_>simple_name @b{extends} path_name @b{is}
16142 @{declarative_item@}
16143 @b{end} <project_>simple_name;
16147 The project extension declares a child project. The child project inherits
16148 all the declarations and all the files of the parent project, These inherited
16149 declaration can be overridden in the child project, by means of suitable
16152 @node Project File Elaboration
16153 @section Project File Elaboration
16156 A project file is processed as part of the invocation of a gnat tool that
16157 uses the project option. Elaboration of the process file consists in the
16158 sequential elaboration of all its declarations. The computed values of
16159 attributes and variables in the project are then used to establish the
16160 environment in which the gnat tool will execute.
16162 @node Obsolescent Features
16163 @chapter Obsolescent Features
16166 This chapter describes features that are provided by GNAT, but are
16167 considered obsolescent since there are preferred ways of achieving
16168 the same effect. These features are provided solely for historical
16169 compatibility purposes.
16172 * pragma No_Run_Time::
16173 * pragma Ravenscar::
16174 * pragma Restricted_Run_Time::
16177 @node pragma No_Run_Time
16178 @section pragma No_Run_Time
16180 The pragma @code{No_Run_Time} is used to achieve an affect similar
16181 to the use of the "Zero Foot Print" configurable run time, but without
16182 requiring a specially configured run time. The result of using this
16183 pragma, which must be used for all units in a partition, is to restrict
16184 the use of any language features requiring run-time support code. The
16185 preferred usage is to use an appropriately configured run-time that
16186 includes just those features that are to be made accessible.
16188 @node pragma Ravenscar
16189 @section pragma Ravenscar
16191 The pragma @code{Ravenscar} has exactly the same effect as pragma
16192 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16193 is part of the new Ada 2005 standard.
16195 @node pragma Restricted_Run_Time
16196 @section pragma Restricted_Run_Time
16198 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16199 pragma @code{Profile (Restricted)}. The latter usage is
16200 preferred since the Ada 2005 pragma @code{Profile} is intended for
16201 this kind of implementation dependent addition.
16204 @c GNU Free Documentation License
16206 @node Index,,GNU Free Documentation License, Top