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, Free Software Foundation
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}.
609 [optional information or parameters]
612 Examples are described by text
614 and then shown this way.
619 Commands that are entered by the user are preceded in this manual by the
620 characters @samp{$ } (dollar sign followed by space). If your system uses this
621 sequence as a prompt, then the commands will appear exactly as you see them
622 in the manual. If your system uses some other prompt, then the command will
623 appear with the @samp{$} replaced by whatever prompt character you are using.
625 @node Related Information
626 @unnumberedsec Related Information
628 See the following documents for further information on GNAT:
632 @cite{GNAT User's Guide}, which provides information on how to use
633 the GNAT compiler system.
636 @cite{Ada 95 Reference Manual}, which contains all reference
637 material for the Ada 95 programming language.
640 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
641 of the Ada 95 standard. The annotations describe
642 detailed aspects of the design decision, and in particular contain useful
643 sections on Ada 83 compatibility.
646 @cite{Ada 2005 Reference Manual}, which contains all reference
647 material for the Ada 2005 programming language.
650 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
651 of the Ada 2005 standard. The annotations describe
652 detailed aspects of the design decision, and in particular contain useful
653 sections on Ada 83 and Ada 95 compatibility.
656 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
657 which contains specific information on compatibility between GNAT and
661 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
662 describes in detail the pragmas and attributes provided by the DEC Ada 83
667 @node Implementation Defined Pragmas
668 @chapter Implementation Defined Pragmas
671 Ada defines a set of pragmas that can be used to supply additional
672 information to the compiler. These language defined pragmas are
673 implemented in GNAT and work as described in the Ada Reference
676 In addition, Ada allows implementations to define additional pragmas
677 whose meaning is defined by the implementation. GNAT provides a number
678 of these implementation-defined pragmas, which can be used to extend
679 and enhance the functionality of the compiler. This section of the GNAT
680 Reference Manual describes these additional pragmas.
682 Note that any program using these pragmas might not be portable to other
683 compilers (although GNAT implements this set of pragmas on all
684 platforms). Therefore if portability to other compilers is an important
685 consideration, the use of these pragmas should be minimized.
688 * Pragma Abort_Defer::
696 * Pragma C_Pass_By_Copy::
697 * Pragma Check_Name::
699 * Pragma Common_Object::
700 * Pragma Compile_Time_Error::
701 * Pragma Compile_Time_Warning::
702 * Pragma Complete_Representation::
703 * Pragma Complex_Representation::
704 * Pragma Component_Alignment::
705 * Pragma Convention_Identifier::
707 * Pragma CPP_Constructor::
708 * Pragma CPP_Virtual::
709 * Pragma CPP_Vtable::
711 * Pragma Debug_Policy::
712 * Pragma Detect_Blocking::
713 * Pragma Elaboration_Checks::
715 * Pragma Export_Exception::
716 * Pragma Export_Function::
717 * Pragma Export_Object::
718 * Pragma Export_Procedure::
719 * Pragma Export_Value::
720 * Pragma Export_Valued_Procedure::
721 * Pragma Extend_System::
723 * Pragma External_Name_Casing::
725 * Pragma Favor_Top_Level::
726 * Pragma Finalize_Storage_Only::
727 * Pragma Float_Representation::
729 * Pragma Implemented_By_Entry::
730 * Pragma Implicit_Packing::
731 * Pragma Import_Exception::
732 * Pragma Import_Function::
733 * Pragma Import_Object::
734 * Pragma Import_Procedure::
735 * Pragma Import_Valued_Procedure::
736 * Pragma Initialize_Scalars::
737 * Pragma Inline_Always::
738 * Pragma Inline_Generic::
740 * Pragma Interface_Name::
741 * Pragma Interrupt_Handler::
742 * Pragma Interrupt_State::
743 * Pragma Keep_Names::
746 * Pragma Linker_Alias::
747 * Pragma Linker_Constructor::
748 * Pragma Linker_Destructor::
749 * Pragma Linker_Section::
750 * Pragma Long_Float::
751 * Pragma Machine_Attribute::
753 * Pragma Main_Storage::
756 * Pragma No_Strict_Aliasing::
757 * Pragma Normalize_Scalars::
758 * Pragma Obsolescent::
760 * Pragma Persistent_BSS::
762 * Pragma Profile (Ravenscar)::
763 * Pragma Profile (Restricted)::
764 * Pragma Psect_Object::
765 * Pragma Pure_Function::
766 * Pragma Restriction_Warnings::
768 * Pragma Source_File_Name::
769 * Pragma Source_File_Name_Project::
770 * Pragma Source_Reference::
771 * Pragma Stream_Convert::
772 * Pragma Style_Checks::
775 * Pragma Suppress_All::
776 * Pragma Suppress_Exception_Locations::
777 * Pragma Suppress_Initialization::
780 * Pragma Task_Storage::
781 * Pragma Time_Slice::
783 * Pragma Unchecked_Union::
784 * Pragma Unimplemented_Unit::
785 * Pragma Universal_Aliasing ::
786 * Pragma Universal_Data::
787 * Pragma Unreferenced::
788 * Pragma Unreferenced_Objects::
789 * Pragma Unreserve_All_Interrupts::
790 * Pragma Unsuppress::
791 * Pragma Use_VADS_Size::
792 * Pragma Validity_Checks::
795 * Pragma Weak_External::
796 * Pragma Wide_Character_Encoding::
799 @node Pragma Abort_Defer
800 @unnumberedsec Pragma Abort_Defer
802 @cindex Deferring aborts
810 This pragma must appear at the start of the statement sequence of a
811 handled sequence of statements (right after the @code{begin}). It has
812 the effect of deferring aborts for the sequence of statements (but not
813 for the declarations or handlers, if any, associated with this statement
817 @unnumberedsec Pragma Ada_83
826 A configuration pragma that establishes Ada 83 mode for the unit to
827 which it applies, regardless of the mode set by the command line
828 switches. In Ada 83 mode, GNAT attempts to be as compatible with
829 the syntax and semantics of Ada 83, as defined in the original Ada
830 83 Reference Manual as possible. In particular, the keywords added by Ada 95
831 and Ada 2005 are not recognized, optional package bodies are allowed,
832 and generics may name types with unknown discriminants without using
833 the @code{(<>)} notation. In addition, some but not all of the additional
834 restrictions of Ada 83 are enforced.
836 Ada 83 mode is intended for two purposes. Firstly, it allows existing
837 Ada 83 code to be compiled and adapted to GNAT with less effort.
838 Secondly, it aids in keeping code backwards compatible with Ada 83.
839 However, there is no guarantee that code that is processed correctly
840 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
841 83 compiler, since GNAT does not enforce all the additional checks
845 @unnumberedsec Pragma Ada_95
854 A configuration pragma that establishes Ada 95 mode for the unit to which
855 it applies, regardless of the mode set by the command line switches.
856 This mode is set automatically for the @code{Ada} and @code{System}
857 packages and their children, so you need not specify it in these
858 contexts. This pragma is useful when writing a reusable component that
859 itself uses Ada 95 features, but which is intended to be usable from
860 either Ada 83 or Ada 95 programs.
863 @unnumberedsec Pragma Ada_05
872 A configuration pragma that establishes Ada 2005 mode for the unit to which
873 it applies, regardless of the mode set by the command line switches.
874 This mode is set automatically for the @code{Ada} and @code{System}
875 packages and their children, so you need not specify it in these
876 contexts. This pragma is useful when writing a reusable component that
877 itself uses Ada 2005 features, but which is intended to be usable from
878 either Ada 83 or Ada 95 programs.
880 @node Pragma Ada_2005
881 @unnumberedsec Pragma Ada_2005
890 This configuration pragma is a synonym for pragma Ada_05 and has the
891 same syntax and effect.
893 @node Pragma Annotate
894 @unnumberedsec Pragma Annotate
899 pragma Annotate (IDENTIFIER @{, ARG@});
901 ARG ::= NAME | EXPRESSION
905 This pragma is used to annotate programs. @var{identifier} identifies
906 the type of annotation. GNAT verifies that it is an identifier, but does
907 not otherwise analyze it. The @var{arg} argument
908 can be either a string literal or an
909 expression. String literals are assumed to be of type
910 @code{Standard.String}. Names of entities are simply analyzed as entity
911 names. All other expressions are analyzed as expressions, and must be
914 The analyzed pragma is retained in the tree, but not otherwise processed
915 by any part of the GNAT compiler. This pragma is intended for use by
916 external tools, including ASIS@.
919 @unnumberedsec Pragma Assert
926 [, static_string_EXPRESSION]);
930 The effect of this pragma depends on whether the corresponding command
931 line switch is set to activate assertions. The pragma expands into code
932 equivalent to the following:
935 if assertions-enabled then
936 if not boolean_EXPRESSION then
937 System.Assertions.Raise_Assert_Failure
944 The string argument, if given, is the message that will be associated
945 with the exception occurrence if the exception is raised. If no second
946 argument is given, the default message is @samp{@var{file}:@var{nnn}},
947 where @var{file} is the name of the source file containing the assert,
948 and @var{nnn} is the line number of the assert. A pragma is not a
949 statement, so if a statement sequence contains nothing but a pragma
950 assert, then a null statement is required in addition, as in:
955 pragma Assert (K > 3, "Bad value for K");
961 Note that, as with the @code{if} statement to which it is equivalent, the
962 type of the expression is either @code{Standard.Boolean}, or any type derived
963 from this standard type.
965 If assertions are disabled (switch @code{-gnata} not used), then there
966 is no run-time effect (and in particular, any side effects from the
967 expression will not occur at run time). (The expression is still
968 analyzed at compile time, and may cause types to be frozen if they are
969 mentioned here for the first time).
971 If assertions are enabled, then the given expression is tested, and if
972 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
973 which results in the raising of @code{Assert_Failure} with the given message.
975 You should generally avoid side effects in the expression arguments of
976 this pragma, because these side effects will turn on and off with the
977 setting of the assertions mode, resulting in assertions that have an
978 effect on the program. However, the expressions are analyzed for
979 semantic correctness whether or not assertions are enabled, so turning
980 assertions on and off cannot affect the legality of a program.
982 @node Pragma Ast_Entry
983 @unnumberedsec Pragma Ast_Entry
989 pragma AST_Entry (entry_IDENTIFIER);
993 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
994 argument is the simple name of a single entry; at most one @code{AST_Entry}
995 pragma is allowed for any given entry. This pragma must be used in
996 conjunction with the @code{AST_Entry} attribute, and is only allowed after
997 the entry declaration and in the same task type specification or single task
998 as the entry to which it applies. This pragma specifies that the given entry
999 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1000 resulting from an OpenVMS system service call. The pragma does not affect
1001 normal use of the entry. For further details on this pragma, see the
1002 DEC Ada Language Reference Manual, section 9.12a.
1004 @node Pragma C_Pass_By_Copy
1005 @unnumberedsec Pragma C_Pass_By_Copy
1006 @cindex Passing by copy
1007 @findex C_Pass_By_Copy
1010 @smallexample @c ada
1011 pragma C_Pass_By_Copy
1012 ([Max_Size =>] static_integer_EXPRESSION);
1016 Normally the default mechanism for passing C convention records to C
1017 convention subprograms is to pass them by reference, as suggested by RM
1018 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1019 this default, by requiring that record formal parameters be passed by
1020 copy if all of the following conditions are met:
1024 The size of the record type does not exceed the value specified for
1027 The record type has @code{Convention C}.
1029 The formal parameter has this record type, and the subprogram has a
1030 foreign (non-Ada) convention.
1034 If these conditions are met the argument is passed by copy, i.e.@: in a
1035 manner consistent with what C expects if the corresponding formal in the
1036 C prototype is a struct (rather than a pointer to a struct).
1038 You can also pass records by copy by specifying the convention
1039 @code{C_Pass_By_Copy} for the record type, or by using the extended
1040 @code{Import} and @code{Export} pragmas, which allow specification of
1041 passing mechanisms on a parameter by parameter basis.
1043 @node Pragma Check_Name
1044 @unnumberedsec Pragma Check_Name
1045 @cindex Defining check names
1046 @cindex Check names, defining
1050 @smallexample @c ada
1051 pragma Check_Name (check_name_IDENTIFIER);
1055 This is a configuration pragma that defines a new implementation
1056 defined check name (unless IDENTIFIER matches one of the predefined
1057 check names, in which case the pragma has no effect). Check names
1058 are global to a partition, so if two more more configuration pragmas
1059 are present in a partition mentioning the same name, only one new
1060 check name is introduced.
1062 An implementation defined check name introduced with this pragma may
1063 be used in only three contexts: @code{pragma Suppress},
1064 @code{pragma Unsuppress},
1065 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1066 any of these three cases, the check name must be visible. A check
1067 name is visible if it is in the configuration pragmas applying to
1068 the current unit, or if it appears at the start of any unit that
1069 is part of the dependency set of the current unit (e.g. units that
1070 are mentioned in @code{with} clauses.
1072 @node Pragma Comment
1073 @unnumberedsec Pragma Comment
1078 @smallexample @c ada
1079 pragma Comment (static_string_EXPRESSION);
1083 This is almost identical in effect to pragma @code{Ident}. It allows the
1084 placement of a comment into the object file and hence into the
1085 executable file if the operating system permits such usage. The
1086 difference is that @code{Comment}, unlike @code{Ident}, has
1087 no limitations on placement of the pragma (it can be placed
1088 anywhere in the main source unit), and if more than one pragma
1089 is used, all comments are retained.
1091 @node Pragma Common_Object
1092 @unnumberedsec Pragma Common_Object
1093 @findex Common_Object
1097 @smallexample @c ada
1098 pragma Common_Object (
1099 [Internal =>] LOCAL_NAME
1100 [, [External =>] EXTERNAL_SYMBOL]
1101 [, [Size =>] EXTERNAL_SYMBOL] );
1105 | static_string_EXPRESSION
1109 This pragma enables the shared use of variables stored in overlaid
1110 linker areas corresponding to the use of @code{COMMON}
1111 in Fortran. The single
1112 object @var{LOCAL_NAME} is assigned to the area designated by
1113 the @var{External} argument.
1114 You may define a record to correspond to a series
1115 of fields. The @var{Size} argument
1116 is syntax checked in GNAT, but otherwise ignored.
1118 @code{Common_Object} is not supported on all platforms. If no
1119 support is available, then the code generator will issue a message
1120 indicating that the necessary attribute for implementation of this
1121 pragma is not available.
1123 @node Pragma Compile_Time_Error
1124 @unnumberedsec Pragma Compile_Time_Error
1125 @findex Compile_Time_Error
1129 @smallexample @c ada
1130 pragma Compile_Time_Error
1131 (boolean_EXPRESSION, static_string_EXPRESSION);
1135 This pragma can be used to generate additional compile time
1137 is particularly useful in generics, where errors can be issued for
1138 specific problematic instantiations. The first parameter is a boolean
1139 expression. The pragma is effective only if the value of this expression
1140 is known at compile time, and has the value True. The set of expressions
1141 whose values are known at compile time includes all static boolean
1142 expressions, and also other values which the compiler can determine
1143 at compile time (e.g. the size of a record type set by an explicit
1144 size representation clause, or the value of a variable which was
1145 initialized to a constant and is known not to have been modified).
1146 If these conditions are met, an error message is generated using
1147 the value given as the second argument. This string value may contain
1148 embedded ASCII.LF characters to break the message into multiple lines.
1150 @node Pragma Compile_Time_Warning
1151 @unnumberedsec Pragma Compile_Time_Warning
1152 @findex Compile_Time_Warning
1156 @smallexample @c ada
1157 pragma Compile_Time_Warning
1158 (boolean_EXPRESSION, static_string_EXPRESSION);
1162 Same as pragma Compile_Time_Error, except a warning is issued instead
1163 of an error message.
1165 @node Pragma Complete_Representation
1166 @unnumberedsec Pragma Complete_Representation
1167 @findex Complete_Representation
1171 @smallexample @c ada
1172 pragma Complete_Representation;
1176 This pragma must appear immediately within a record representation
1177 clause. Typical placements are before the first component clause
1178 or after the last component clause. The effect is to give an error
1179 message if any component is missing a component clause. This pragma
1180 may be used to ensure that a record representation clause is
1181 complete, and that this invariant is maintained if fields are
1182 added to the record in the future.
1184 @node Pragma Complex_Representation
1185 @unnumberedsec Pragma Complex_Representation
1186 @findex Complex_Representation
1190 @smallexample @c ada
1191 pragma Complex_Representation
1192 ([Entity =>] LOCAL_NAME);
1196 The @var{Entity} argument must be the name of a record type which has
1197 two fields of the same floating-point type. The effect of this pragma is
1198 to force gcc to use the special internal complex representation form for
1199 this record, which may be more efficient. Note that this may result in
1200 the code for this type not conforming to standard ABI (application
1201 binary interface) requirements for the handling of record types. For
1202 example, in some environments, there is a requirement for passing
1203 records by pointer, and the use of this pragma may result in passing
1204 this type in floating-point registers.
1206 @node Pragma Component_Alignment
1207 @unnumberedsec Pragma Component_Alignment
1208 @cindex Alignments of components
1209 @findex Component_Alignment
1213 @smallexample @c ada
1214 pragma Component_Alignment (
1215 [Form =>] ALIGNMENT_CHOICE
1216 [, [Name =>] type_LOCAL_NAME]);
1218 ALIGNMENT_CHOICE ::=
1226 Specifies the alignment of components in array or record types.
1227 The meaning of the @var{Form} argument is as follows:
1230 @findex Component_Size
1231 @item Component_Size
1232 Aligns scalar components and subcomponents of the array or record type
1233 on boundaries appropriate to their inherent size (naturally
1234 aligned). For example, 1-byte components are aligned on byte boundaries,
1235 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1236 integer components are aligned on 4-byte boundaries and so on. These
1237 alignment rules correspond to the normal rules for C compilers on all
1238 machines except the VAX@.
1240 @findex Component_Size_4
1241 @item Component_Size_4
1242 Naturally aligns components with a size of four or fewer
1243 bytes. Components that are larger than 4 bytes are placed on the next
1246 @findex Storage_Unit
1248 Specifies that array or record components are byte aligned, i.e.@:
1249 aligned on boundaries determined by the value of the constant
1250 @code{System.Storage_Unit}.
1254 Specifies that array or record components are aligned on default
1255 boundaries, appropriate to the underlying hardware or operating system or
1256 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1257 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1258 the @code{Default} choice is the same as @code{Component_Size} (natural
1263 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1264 refer to a local record or array type, and the specified alignment
1265 choice applies to the specified type. The use of
1266 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1267 @code{Component_Alignment} pragma to be ignored. The use of
1268 @code{Component_Alignment} together with a record representation clause
1269 is only effective for fields not specified by the representation clause.
1271 If the @code{Name} parameter is absent, the pragma can be used as either
1272 a configuration pragma, in which case it applies to one or more units in
1273 accordance with the normal rules for configuration pragmas, or it can be
1274 used within a declarative part, in which case it applies to types that
1275 are declared within this declarative part, or within any nested scope
1276 within this declarative part. In either case it specifies the alignment
1277 to be applied to any record or array type which has otherwise standard
1280 If the alignment for a record or array type is not specified (using
1281 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1282 clause), the GNAT uses the default alignment as described previously.
1284 @node Pragma Convention_Identifier
1285 @unnumberedsec Pragma Convention_Identifier
1286 @findex Convention_Identifier
1287 @cindex Conventions, synonyms
1291 @smallexample @c ada
1292 pragma Convention_Identifier (
1293 [Name =>] IDENTIFIER,
1294 [Convention =>] convention_IDENTIFIER);
1298 This pragma provides a mechanism for supplying synonyms for existing
1299 convention identifiers. The @code{Name} identifier can subsequently
1300 be used as a synonym for the given convention in other pragmas (including
1301 for example pragma @code{Import} or another @code{Convention_Identifier}
1302 pragma). As an example of the use of this, suppose you had legacy code
1303 which used Fortran77 as the identifier for Fortran. Then the pragma:
1305 @smallexample @c ada
1306 pragma Convention_Identifier (Fortran77, Fortran);
1310 would allow the use of the convention identifier @code{Fortran77} in
1311 subsequent code, avoiding the need to modify the sources. As another
1312 example, you could use this to parametrize convention requirements
1313 according to systems. Suppose you needed to use @code{Stdcall} on
1314 windows systems, and @code{C} on some other system, then you could
1315 define a convention identifier @code{Library} and use a single
1316 @code{Convention_Identifier} pragma to specify which convention
1317 would be used system-wide.
1319 @node Pragma CPP_Class
1320 @unnumberedsec Pragma CPP_Class
1322 @cindex Interfacing with C++
1326 @smallexample @c ada
1327 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1331 The argument denotes an entity in the current declarative region that is
1332 declared as a tagged record type. It indicates that the type corresponds
1333 to an externally declared C++ class type, and is to be laid out the same
1334 way that C++ would lay out the type.
1336 Types for which @code{CPP_Class} is specified do not have assignment or
1337 equality operators defined (such operations can be imported or declared
1338 as subprograms as required). Initialization is allowed only by constructor
1339 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1340 limited if not explicitly declared as limited or derived from a limited
1341 type, and a warning is issued in that case.
1343 Pragma @code{CPP_Class} is intended primarily for automatic generation
1344 using an automatic binding generator tool.
1345 See @ref{Interfacing to C++} for related information.
1347 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1348 for backward compatibility but its functionality is available
1349 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1351 @node Pragma CPP_Constructor
1352 @unnumberedsec Pragma CPP_Constructor
1353 @cindex Interfacing with C++
1354 @findex CPP_Constructor
1358 @smallexample @c ada
1359 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1360 [, [External_Name =>] static_string_EXPRESSION ]
1361 [, [Link_Name =>] static_string_EXPRESSION ]);
1365 This pragma identifies an imported function (imported in the usual way
1366 with pragma @code{Import}) as corresponding to a C++ constructor. If
1367 @code{External_Name} and @code{Link_Name} are not specified then the
1368 @code{Entity} argument is a name that must have been previously mentioned
1369 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1370 must be of one of the following forms:
1374 @code{function @var{Fname} return @var{T}'Class}
1377 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1381 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1383 The first form is the default constructor, used when an object of type
1384 @var{T} is created on the Ada side with no explicit constructor. Other
1385 constructors (including the copy constructor, which is simply a special
1386 case of the second form in which the one and only argument is of type
1387 @var{T}), can only appear in two contexts:
1391 On the right side of an initialization of an object of type @var{T}.
1393 In an extension aggregate for an object of a type derived from @var{T}.
1397 Although the constructor is described as a function that returns a value
1398 on the Ada side, it is typically a procedure with an extra implicit
1399 argument (the object being initialized) at the implementation
1400 level. GNAT issues the appropriate call, whatever it is, to get the
1401 object properly initialized.
1403 In the case of derived objects, you may use one of two possible forms
1404 for declaring and creating an object:
1407 @item @code{New_Object : Derived_T}
1408 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1412 In the first case the default constructor is called and extension fields
1413 if any are initialized according to the default initialization
1414 expressions in the Ada declaration. In the second case, the given
1415 constructor is called and the extension aggregate indicates the explicit
1416 values of the extension fields.
1418 If no constructors are imported, it is impossible to create any objects
1419 on the Ada side. If no default constructor is imported, only the
1420 initialization forms using an explicit call to a constructor are
1423 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1424 using an automatic binding generator tool.
1425 See @ref{Interfacing to C++} for more related information.
1427 @node Pragma CPP_Virtual
1428 @unnumberedsec Pragma CPP_Virtual
1429 @cindex Interfacing to C++
1432 This pragma is now obsolete has has no effect because GNAT generates
1433 the same object layout than the G++ compiler.
1435 See @ref{Interfacing to C++} for related information.
1437 @node Pragma CPP_Vtable
1438 @unnumberedsec Pragma CPP_Vtable
1439 @cindex Interfacing with C++
1442 This pragma is now obsolete has has no effect because GNAT generates
1443 the same object layout than the G++ compiler.
1445 See @ref{Interfacing to C++} for related information.
1448 @unnumberedsec Pragma Debug
1453 @smallexample @c ada
1454 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1456 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1458 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1462 The procedure call argument has the syntactic form of an expression, meeting
1463 the syntactic requirements for pragmas.
1465 If debug pragmas are not enabled or if the condition is present and evaluates
1466 to False, this pragma has no effect. If debug pragmas are enabled, the
1467 semantics of the pragma is exactly equivalent to the procedure call statement
1468 corresponding to the argument with a terminating semicolon. Pragmas are
1469 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1470 intersperse calls to debug procedures in the middle of declarations. Debug
1471 pragmas can be enabled either by use of the command line switch @code{-gnata}
1472 or by use of the configuration pragma @code{Debug_Policy}.
1474 @node Pragma Debug_Policy
1475 @unnumberedsec Pragma Debug_Policy
1476 @findex Debug_Policy
1480 @smallexample @c ada
1481 pragma Debug_Policy (CHECK | IGNORE);
1485 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1486 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1487 This pragma overrides the effect of the @code{-gnata} switch on the
1490 @node Pragma Detect_Blocking
1491 @unnumberedsec Pragma Detect_Blocking
1492 @findex Detect_Blocking
1496 @smallexample @c ada
1497 pragma Detect_Blocking;
1501 This is a configuration pragma that forces the detection of potentially
1502 blocking operations within a protected operation, and to raise Program_Error
1505 @node Pragma Elaboration_Checks
1506 @unnumberedsec Pragma Elaboration_Checks
1507 @cindex Elaboration control
1508 @findex Elaboration_Checks
1512 @smallexample @c ada
1513 pragma Elaboration_Checks (Dynamic | Static);
1517 This is a configuration pragma that provides control over the
1518 elaboration model used by the compilation affected by the
1519 pragma. If the parameter is @code{Dynamic},
1520 then the dynamic elaboration
1521 model described in the Ada Reference Manual is used, as though
1522 the @code{-gnatE} switch had been specified on the command
1523 line. If the parameter is @code{Static}, then the default GNAT static
1524 model is used. This configuration pragma overrides the setting
1525 of the command line. For full details on the elaboration models
1526 used by the GNAT compiler, see section ``Elaboration Order
1527 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1529 @node Pragma Eliminate
1530 @unnumberedsec Pragma Eliminate
1531 @cindex Elimination of unused subprograms
1536 @smallexample @c ada
1538 [Unit_Name =>] IDENTIFIER |
1539 SELECTED_COMPONENT);
1542 [Unit_Name =>] IDENTIFIER |
1544 [Entity =>] IDENTIFIER |
1545 SELECTED_COMPONENT |
1547 [,OVERLOADING_RESOLUTION]);
1549 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1552 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1555 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1557 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1558 Result_Type => result_SUBTYPE_NAME]
1560 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1561 SUBTYPE_NAME ::= STRING_VALUE
1563 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1564 SOURCE_TRACE ::= STRING_VALUE
1566 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1570 This pragma indicates that the given entity is not used outside the
1571 compilation unit it is defined in. The entity must be an explicitly declared
1572 subprogram; this includes generic subprogram instances and
1573 subprograms declared in generic package instances.
1575 If the entity to be eliminated is a library level subprogram, then
1576 the first form of pragma @code{Eliminate} is used with only a single argument.
1577 In this form, the @code{Unit_Name} argument specifies the name of the
1578 library level unit to be eliminated.
1580 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1581 are required. If item is an entity of a library package, then the first
1582 argument specifies the unit name, and the second argument specifies
1583 the particular entity. If the second argument is in string form, it must
1584 correspond to the internal manner in which GNAT stores entity names (see
1585 compilation unit Namet in the compiler sources for details).
1587 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1588 to distinguish between overloaded subprograms. If a pragma does not contain
1589 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1590 subprograms denoted by the first two parameters.
1592 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1593 to be eliminated in a manner similar to that used for the extended
1594 @code{Import} and @code{Export} pragmas, except that the subtype names are
1595 always given as strings. At the moment, this form of distinguishing
1596 overloaded subprograms is implemented only partially, so we do not recommend
1597 using it for practical subprogram elimination.
1599 Note that in case of a parameterless procedure its profile is represented
1600 as @code{Parameter_Types => ("")}
1602 Alternatively, the @code{Source_Location} parameter is used to specify
1603 which overloaded alternative is to be eliminated by pointing to the
1604 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1605 source text. The string literal (or concatenation of string literals)
1606 given as SOURCE_TRACE must have the following format:
1608 @smallexample @c ada
1609 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1614 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1615 FILE_NAME ::= STRING_LITERAL
1616 LINE_NUMBER ::= DIGIT @{DIGIT@}
1619 SOURCE_TRACE should be the short name of the source file (with no directory
1620 information), and LINE_NUMBER is supposed to point to the line where the
1621 defining name of the subprogram is located.
1623 For the subprograms that are not a part of generic instantiations, only one
1624 SOURCE_LOCATION is used. If a subprogram is declared in a package
1625 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1626 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1627 second one denotes the declaration of the corresponding subprogram in the
1628 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1629 in case of nested instantiations.
1631 The effect of the pragma is to allow the compiler to eliminate
1632 the code or data associated with the named entity. Any reference to
1633 an eliminated entity outside the compilation unit it is defined in,
1634 causes a compile time or link time error.
1636 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1637 in a system independent manner, with unused entities eliminated, without
1638 the requirement of modifying the source text. Normally the required set
1639 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1640 tool. Elimination of unused entities local to a compilation unit is
1641 automatic, without requiring the use of pragma @code{Eliminate}.
1643 Note that the reason this pragma takes string literals where names might
1644 be expected is that a pragma @code{Eliminate} can appear in a context where the
1645 relevant names are not visible.
1647 Note that any change in the source files that includes removing, splitting of
1648 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1651 It is legal to use pragma Eliminate where the referenced entity is a
1652 dispatching operation, but it is not clear what this would mean, since
1653 in general the call does not know which entity is actually being called.
1654 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1656 @node Pragma Export_Exception
1657 @unnumberedsec Pragma Export_Exception
1659 @findex Export_Exception
1663 @smallexample @c ada
1664 pragma Export_Exception (
1665 [Internal =>] LOCAL_NAME
1666 [, [External =>] EXTERNAL_SYMBOL]
1667 [, [Form =>] Ada | VMS]
1668 [, [Code =>] static_integer_EXPRESSION]);
1672 | static_string_EXPRESSION
1676 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1677 causes the specified exception to be propagated outside of the Ada program,
1678 so that it can be handled by programs written in other OpenVMS languages.
1679 This pragma establishes an external name for an Ada exception and makes the
1680 name available to the OpenVMS Linker as a global symbol. For further details
1681 on this pragma, see the
1682 DEC Ada Language Reference Manual, section 13.9a3.2.
1684 @node Pragma Export_Function
1685 @unnumberedsec Pragma Export_Function
1686 @cindex Argument passing mechanisms
1687 @findex Export_Function
1692 @smallexample @c ada
1693 pragma Export_Function (
1694 [Internal =>] LOCAL_NAME
1695 [, [External =>] EXTERNAL_SYMBOL]
1696 [, [Parameter_Types =>] PARAMETER_TYPES]
1697 [, [Result_Type =>] result_SUBTYPE_MARK]
1698 [, [Mechanism =>] MECHANISM]
1699 [, [Result_Mechanism =>] MECHANISM_NAME]);
1703 | static_string_EXPRESSION
1708 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1712 | subtype_Name ' Access
1716 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1718 MECHANISM_ASSOCIATION ::=
1719 [formal_parameter_NAME =>] MECHANISM_NAME
1724 | Descriptor [([Class =>] CLASS_NAME)]
1726 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1730 Use this pragma to make a function externally callable and optionally
1731 provide information on mechanisms to be used for passing parameter and
1732 result values. We recommend, for the purposes of improving portability,
1733 this pragma always be used in conjunction with a separate pragma
1734 @code{Export}, which must precede the pragma @code{Export_Function}.
1735 GNAT does not require a separate pragma @code{Export}, but if none is
1736 present, @code{Convention Ada} is assumed, which is usually
1737 not what is wanted, so it is usually appropriate to use this
1738 pragma in conjunction with a @code{Export} or @code{Convention}
1739 pragma that specifies the desired foreign convention.
1740 Pragma @code{Export_Function}
1741 (and @code{Export}, if present) must appear in the same declarative
1742 region as the function to which they apply.
1744 @var{internal_name} must uniquely designate the function to which the
1745 pragma applies. If more than one function name exists of this name in
1746 the declarative part you must use the @code{Parameter_Types} and
1747 @code{Result_Type} parameters is mandatory to achieve the required
1748 unique designation. @var{subtype_ mark}s in these parameters must
1749 exactly match the subtypes in the corresponding function specification,
1750 using positional notation to match parameters with subtype marks.
1751 The form with an @code{'Access} attribute can be used to match an
1752 anonymous access parameter.
1755 @cindex Passing by descriptor
1756 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1758 @cindex Suppressing external name
1759 Special treatment is given if the EXTERNAL is an explicit null
1760 string or a static string expressions that evaluates to the null
1761 string. In this case, no external name is generated. This form
1762 still allows the specification of parameter mechanisms.
1764 @node Pragma Export_Object
1765 @unnumberedsec Pragma Export_Object
1766 @findex Export_Object
1770 @smallexample @c ada
1771 pragma Export_Object
1772 [Internal =>] LOCAL_NAME
1773 [, [External =>] EXTERNAL_SYMBOL]
1774 [, [Size =>] EXTERNAL_SYMBOL]
1778 | static_string_EXPRESSION
1782 This pragma designates an object as exported, and apart from the
1783 extended rules for external symbols, is identical in effect to the use of
1784 the normal @code{Export} pragma applied to an object. You may use a
1785 separate Export pragma (and you probably should from the point of view
1786 of portability), but it is not required. @var{Size} is syntax checked,
1787 but otherwise ignored by GNAT@.
1789 @node Pragma Export_Procedure
1790 @unnumberedsec Pragma Export_Procedure
1791 @findex Export_Procedure
1795 @smallexample @c ada
1796 pragma Export_Procedure (
1797 [Internal =>] LOCAL_NAME
1798 [, [External =>] EXTERNAL_SYMBOL]
1799 [, [Parameter_Types =>] PARAMETER_TYPES]
1800 [, [Mechanism =>] MECHANISM]);
1804 | static_string_EXPRESSION
1809 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1813 | subtype_Name ' Access
1817 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1819 MECHANISM_ASSOCIATION ::=
1820 [formal_parameter_NAME =>] MECHANISM_NAME
1825 | Descriptor [([Class =>] CLASS_NAME)]
1827 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1831 This pragma is identical to @code{Export_Function} except that it
1832 applies to a procedure rather than a function and the parameters
1833 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1834 GNAT does not require a separate pragma @code{Export}, but if none is
1835 present, @code{Convention Ada} is assumed, which is usually
1836 not what is wanted, so it is usually appropriate to use this
1837 pragma in conjunction with a @code{Export} or @code{Convention}
1838 pragma that specifies the desired foreign convention.
1841 @cindex Passing by descriptor
1842 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1844 @cindex Suppressing external name
1845 Special treatment is given if the EXTERNAL is an explicit null
1846 string or a static string expressions that evaluates to the null
1847 string. In this case, no external name is generated. This form
1848 still allows the specification of parameter mechanisms.
1850 @node Pragma Export_Value
1851 @unnumberedsec Pragma Export_Value
1852 @findex Export_Value
1856 @smallexample @c ada
1857 pragma Export_Value (
1858 [Value =>] static_integer_EXPRESSION,
1859 [Link_Name =>] static_string_EXPRESSION);
1863 This pragma serves to export a static integer value for external use.
1864 The first argument specifies the value to be exported. The Link_Name
1865 argument specifies the symbolic name to be associated with the integer
1866 value. This pragma is useful for defining a named static value in Ada
1867 that can be referenced in assembly language units to be linked with
1868 the application. This pragma is currently supported only for the
1869 AAMP target and is ignored for other targets.
1871 @node Pragma Export_Valued_Procedure
1872 @unnumberedsec Pragma Export_Valued_Procedure
1873 @findex Export_Valued_Procedure
1877 @smallexample @c ada
1878 pragma Export_Valued_Procedure (
1879 [Internal =>] LOCAL_NAME
1880 [, [External =>] EXTERNAL_SYMBOL]
1881 [, [Parameter_Types =>] PARAMETER_TYPES]
1882 [, [Mechanism =>] MECHANISM]);
1886 | static_string_EXPRESSION
1891 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1895 | subtype_Name ' Access
1899 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1901 MECHANISM_ASSOCIATION ::=
1902 [formal_parameter_NAME =>] MECHANISM_NAME
1907 | Descriptor [([Class =>] CLASS_NAME)]
1909 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1913 This pragma is identical to @code{Export_Procedure} except that the
1914 first parameter of @var{LOCAL_NAME}, which must be present, must be of
1915 mode @code{OUT}, and externally the subprogram is treated as a function
1916 with this parameter as the result of the function. GNAT provides for
1917 this capability to allow the use of @code{OUT} and @code{IN OUT}
1918 parameters in interfacing to external functions (which are not permitted
1920 GNAT does not require a separate pragma @code{Export}, but if none is
1921 present, @code{Convention Ada} is assumed, which is almost certainly
1922 not what is wanted since the whole point of this pragma is to interface
1923 with foreign language functions, so it is usually appropriate to use this
1924 pragma in conjunction with a @code{Export} or @code{Convention}
1925 pragma that specifies the desired foreign convention.
1928 @cindex Passing by descriptor
1929 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1931 @cindex Suppressing external name
1932 Special treatment is given if the EXTERNAL is an explicit null
1933 string or a static string expressions that evaluates to the null
1934 string. In this case, no external name is generated. This form
1935 still allows the specification of parameter mechanisms.
1937 @node Pragma Extend_System
1938 @unnumberedsec Pragma Extend_System
1939 @cindex @code{system}, extending
1941 @findex Extend_System
1945 @smallexample @c ada
1946 pragma Extend_System ([Name =>] IDENTIFIER);
1950 This pragma is used to provide backwards compatibility with other
1951 implementations that extend the facilities of package @code{System}. In
1952 GNAT, @code{System} contains only the definitions that are present in
1953 the Ada RM@. However, other implementations, notably the DEC Ada 83
1954 implementation, provide many extensions to package @code{System}.
1956 For each such implementation accommodated by this pragma, GNAT provides a
1957 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1958 implementation, which provides the required additional definitions. You
1959 can use this package in two ways. You can @code{with} it in the normal
1960 way and access entities either by selection or using a @code{use}
1961 clause. In this case no special processing is required.
1963 However, if existing code contains references such as
1964 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1965 definitions provided in package @code{System}, you may use this pragma
1966 to extend visibility in @code{System} in a non-standard way that
1967 provides greater compatibility with the existing code. Pragma
1968 @code{Extend_System} is a configuration pragma whose single argument is
1969 the name of the package containing the extended definition
1970 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
1971 control of this pragma will be processed using special visibility
1972 processing that looks in package @code{System.Aux_@var{xxx}} where
1973 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1974 package @code{System}, but not found in package @code{System}.
1976 You can use this pragma either to access a predefined @code{System}
1977 extension supplied with the compiler, for example @code{Aux_DEC} or
1978 you can construct your own extension unit following the above
1979 definition. Note that such a package is a child of @code{System}
1980 and thus is considered part of the implementation. To compile
1981 it you will have to use the appropriate switch for compiling
1982 system units. See the GNAT User's Guide for details.
1984 @node Pragma External
1985 @unnumberedsec Pragma External
1990 @smallexample @c ada
1992 [ Convention =>] convention_IDENTIFIER,
1993 [ Entity =>] LOCAL_NAME
1994 [, [External_Name =>] static_string_EXPRESSION ]
1995 [, [Link_Name =>] static_string_EXPRESSION ]);
1999 This pragma is identical in syntax and semantics to pragma
2000 @code{Export} as defined in the Ada Reference Manual. It is
2001 provided for compatibility with some Ada 83 compilers that
2002 used this pragma for exactly the same purposes as pragma
2003 @code{Export} before the latter was standardized.
2005 @node Pragma External_Name_Casing
2006 @unnumberedsec Pragma External_Name_Casing
2007 @cindex Dec Ada 83 casing compatibility
2008 @cindex External Names, casing
2009 @cindex Casing of External names
2010 @findex External_Name_Casing
2014 @smallexample @c ada
2015 pragma External_Name_Casing (
2016 Uppercase | Lowercase
2017 [, Uppercase | Lowercase | As_Is]);
2021 This pragma provides control over the casing of external names associated
2022 with Import and Export pragmas. There are two cases to consider:
2025 @item Implicit external names
2026 Implicit external names are derived from identifiers. The most common case
2027 arises when a standard Ada Import or Export pragma is used with only two
2030 @smallexample @c ada
2031 pragma Import (C, C_Routine);
2035 Since Ada is a case-insensitive language, the spelling of the identifier in
2036 the Ada source program does not provide any information on the desired
2037 casing of the external name, and so a convention is needed. In GNAT the
2038 default treatment is that such names are converted to all lower case
2039 letters. This corresponds to the normal C style in many environments.
2040 The first argument of pragma @code{External_Name_Casing} can be used to
2041 control this treatment. If @code{Uppercase} is specified, then the name
2042 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2043 then the normal default of all lower case letters will be used.
2045 This same implicit treatment is also used in the case of extended DEC Ada 83
2046 compatible Import and Export pragmas where an external name is explicitly
2047 specified using an identifier rather than a string.
2049 @item Explicit external names
2050 Explicit external names are given as string literals. The most common case
2051 arises when a standard Ada Import or Export pragma is used with three
2054 @smallexample @c ada
2055 pragma Import (C, C_Routine, "C_routine");
2059 In this case, the string literal normally provides the exact casing required
2060 for the external name. The second argument of pragma
2061 @code{External_Name_Casing} may be used to modify this behavior.
2062 If @code{Uppercase} is specified, then the name
2063 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2064 then the name will be forced to all lowercase letters. A specification of
2065 @code{As_Is} provides the normal default behavior in which the casing is
2066 taken from the string provided.
2070 This pragma may appear anywhere that a pragma is valid. In particular, it
2071 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2072 case it applies to all subsequent compilations, or it can be used as a program
2073 unit pragma, in which case it only applies to the current unit, or it can
2074 be used more locally to control individual Import/Export pragmas.
2076 It is primarily intended for use with OpenVMS systems, where many
2077 compilers convert all symbols to upper case by default. For interfacing to
2078 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2081 @smallexample @c ada
2082 pragma External_Name_Casing (Uppercase, Uppercase);
2086 to enforce the upper casing of all external symbols.
2088 @node Pragma Fast_Math
2089 @unnumberedsec Pragma Fast_Math
2094 @smallexample @c ada
2099 This is a configuration pragma which activates a mode in which speed is
2100 considered more important for floating-point operations than absolutely
2101 accurate adherence to the requirements of the standard. Currently the
2102 following operations are affected:
2105 @item Complex Multiplication
2106 The normal simple formula for complex multiplication can result in intermediate
2107 overflows for numbers near the end of the range. The Ada standard requires that
2108 this situation be detected and corrected by scaling, but in Fast_Math mode such
2109 cases will simply result in overflow. Note that to take advantage of this you
2110 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2111 under control of the pragma, rather than use the preinstantiated versions.
2114 @node Pragma Favor_Top_Level
2115 @unnumberedsec Pragma Favor_Top_Level
2116 @findex Favor_Top_Level
2120 @smallexample @c ada
2121 pragma Favor_Top_Level (type_NAME);
2125 The named type must be an access-to-subprogram type. This pragma is an
2126 efficiency hint to the compiler, regarding the use of 'Access or
2127 'Unrestricted_Access on nested (non-library-level) subprograms. The
2128 pragma means that nested subprograms are not used with this type, or
2129 are rare, so that the generated code should be efficient in the
2130 top-level case. When this pragma is used, dynamically generated
2131 trampolines may be used on some targets for nested subprograms.
2132 See also the No_Implicit_Dynamic_Code restriction.
2134 @node Pragma Finalize_Storage_Only
2135 @unnumberedsec Pragma Finalize_Storage_Only
2136 @findex Finalize_Storage_Only
2140 @smallexample @c ada
2141 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2145 This pragma allows the compiler not to emit a Finalize call for objects
2146 defined at the library level. This is mostly useful for types where
2147 finalization is only used to deal with storage reclamation since in most
2148 environments it is not necessary to reclaim memory just before terminating
2149 execution, hence the name.
2151 @node Pragma Float_Representation
2152 @unnumberedsec Pragma Float_Representation
2154 @findex Float_Representation
2158 @smallexample @c ada
2159 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2161 FLOAT_REP ::= VAX_Float | IEEE_Float
2165 In the one argument form, this pragma is a configuration pragma which
2166 allows control over the internal representation chosen for the predefined
2167 floating point types declared in the packages @code{Standard} and
2168 @code{System}. On all systems other than OpenVMS, the argument must
2169 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2170 argument may be @code{VAX_Float} to specify the use of the VAX float
2171 format for the floating-point types in Standard. This requires that
2172 the standard runtime libraries be recompiled. See the
2173 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2174 of the GNAT Users Guide for details on the use of this command.
2176 The two argument form specifies the representation to be used for
2177 the specified floating-point type. On all systems other than OpenVMS,
2179 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2180 argument may be @code{VAX_Float} to specify the use of the VAX float
2185 For digits values up to 6, F float format will be used.
2187 For digits values from 7 to 9, G float format will be used.
2189 For digits values from 10 to 15, F float format will be used.
2191 Digits values above 15 are not allowed.
2195 @unnumberedsec Pragma Ident
2200 @smallexample @c ada
2201 pragma Ident (static_string_EXPRESSION);
2205 This pragma provides a string identification in the generated object file,
2206 if the system supports the concept of this kind of identification string.
2207 This pragma is allowed only in the outermost declarative part or
2208 declarative items of a compilation unit. If more than one @code{Ident}
2209 pragma is given, only the last one processed is effective.
2211 On OpenVMS systems, the effect of the pragma is identical to the effect of
2212 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2213 maximum allowed length is 31 characters, so if it is important to
2214 maintain compatibility with this compiler, you should obey this length
2217 @node Pragma Implemented_By_Entry
2218 @unnumberedsec Pragma Implemented_By_Entry
2219 @findex Implemented_By_Entry
2223 @smallexample @c ada
2224 pragma Implemented_By_Entry (LOCAL_NAME);
2228 This is a representation pragma which applies to protected, synchronized and
2229 task interface primitives. If the pragma is applied to primitive operation Op
2230 of interface Iface, it is illegal to override Op in a type that implements
2231 Iface, with anything other than an entry.
2233 @smallexample @c ada
2234 type Iface is protected interface;
2235 procedure Do_Something (Object : in out Iface) is abstract;
2236 pragma Implemented_By_Entry (Do_Something);
2238 protected type P is new Iface with
2239 procedure Do_Something; -- Illegal
2242 task type T is new Iface with
2243 entry Do_Something; -- Legal
2248 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2249 is intended to be used in conjunction with dispatching requeue statements as
2250 described in AI05-0030. Should the ARG decide on an official name and syntax,
2251 this pragma will become language-defined rather than GNAT-specific.
2253 @node Pragma Implicit_Packing
2254 @unnumberedsec Pragma Implicit_Packing
2255 @findex Implicit_Packing
2259 @smallexample @c ada
2260 pragma Implicit_Packing;
2264 This is a configuration pragma that requests implicit packing for packed
2265 arrays for which a size clause is given but no explicit pragma Pack or
2266 specification of Component_Size is present. Consider this example:
2268 @smallexample @c ada
2269 type R is array (0 .. 7) of Boolean;
2274 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2275 does not change the layout of a composite object. So the Size clause in the
2276 above example is normally rejected, since the default layout of the array uses
2277 8-bit components, and thus the array requires a minimum of 64 bits.
2279 If this declaration is compiled in a region of code covered by an occurrence
2280 of the configuration pragma Implicit_Packing, then the Size clause in this
2281 and similar examples will cause implicit packing and thus be accepted. For
2282 this implicit packing to occur, the type in question must be an array of small
2283 components whose size is known at compile time, and the Size clause must
2284 specify the exact size that corresponds to the length of the array multiplied
2285 by the size in bits of the component type.
2286 @cindex Array packing
2288 @node Pragma Import_Exception
2289 @unnumberedsec Pragma Import_Exception
2291 @findex Import_Exception
2295 @smallexample @c ada
2296 pragma Import_Exception (
2297 [Internal =>] LOCAL_NAME
2298 [, [External =>] EXTERNAL_SYMBOL]
2299 [, [Form =>] Ada | VMS]
2300 [, [Code =>] static_integer_EXPRESSION]);
2304 | static_string_EXPRESSION
2308 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2309 It allows OpenVMS conditions (for example, from OpenVMS system services or
2310 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2311 The pragma specifies that the exception associated with an exception
2312 declaration in an Ada program be defined externally (in non-Ada code).
2313 For further details on this pragma, see the
2314 DEC Ada Language Reference Manual, section 13.9a.3.1.
2316 @node Pragma Import_Function
2317 @unnumberedsec Pragma Import_Function
2318 @findex Import_Function
2322 @smallexample @c ada
2323 pragma Import_Function (
2324 [Internal =>] LOCAL_NAME,
2325 [, [External =>] EXTERNAL_SYMBOL]
2326 [, [Parameter_Types =>] PARAMETER_TYPES]
2327 [, [Result_Type =>] SUBTYPE_MARK]
2328 [, [Mechanism =>] MECHANISM]
2329 [, [Result_Mechanism =>] MECHANISM_NAME]
2330 [, [First_Optional_Parameter =>] IDENTIFIER]);
2334 | static_string_EXPRESSION
2338 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2342 | subtype_Name ' Access
2346 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2348 MECHANISM_ASSOCIATION ::=
2349 [formal_parameter_NAME =>] MECHANISM_NAME
2354 | Descriptor [([Class =>] CLASS_NAME)]
2356 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2360 This pragma is used in conjunction with a pragma @code{Import} to
2361 specify additional information for an imported function. The pragma
2362 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2363 @code{Import_Function} pragma and both must appear in the same
2364 declarative part as the function specification.
2366 The @var{Internal} argument must uniquely designate
2367 the function to which the
2368 pragma applies. If more than one function name exists of this name in
2369 the declarative part you must use the @code{Parameter_Types} and
2370 @var{Result_Type} parameters to achieve the required unique
2371 designation. Subtype marks in these parameters must exactly match the
2372 subtypes in the corresponding function specification, using positional
2373 notation to match parameters with subtype marks.
2374 The form with an @code{'Access} attribute can be used to match an
2375 anonymous access parameter.
2377 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2378 parameters to specify passing mechanisms for the
2379 parameters and result. If you specify a single mechanism name, it
2380 applies to all parameters. Otherwise you may specify a mechanism on a
2381 parameter by parameter basis using either positional or named
2382 notation. If the mechanism is not specified, the default mechanism
2386 @cindex Passing by descriptor
2387 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2389 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2390 It specifies that the designated parameter and all following parameters
2391 are optional, meaning that they are not passed at the generated code
2392 level (this is distinct from the notion of optional parameters in Ada
2393 where the parameters are passed anyway with the designated optional
2394 parameters). All optional parameters must be of mode @code{IN} and have
2395 default parameter values that are either known at compile time
2396 expressions, or uses of the @code{'Null_Parameter} attribute.
2398 @node Pragma Import_Object
2399 @unnumberedsec Pragma Import_Object
2400 @findex Import_Object
2404 @smallexample @c ada
2405 pragma Import_Object
2406 [Internal =>] LOCAL_NAME
2407 [, [External =>] EXTERNAL_SYMBOL]
2408 [, [Size =>] EXTERNAL_SYMBOL]);
2412 | static_string_EXPRESSION
2416 This pragma designates an object as imported, and apart from the
2417 extended rules for external symbols, is identical in effect to the use of
2418 the normal @code{Import} pragma applied to an object. Unlike the
2419 subprogram case, you need not use a separate @code{Import} pragma,
2420 although you may do so (and probably should do so from a portability
2421 point of view). @var{size} is syntax checked, but otherwise ignored by
2424 @node Pragma Import_Procedure
2425 @unnumberedsec Pragma Import_Procedure
2426 @findex Import_Procedure
2430 @smallexample @c ada
2431 pragma Import_Procedure (
2432 [Internal =>] LOCAL_NAME
2433 [, [External =>] EXTERNAL_SYMBOL]
2434 [, [Parameter_Types =>] PARAMETER_TYPES]
2435 [, [Mechanism =>] MECHANISM]
2436 [, [First_Optional_Parameter =>] IDENTIFIER]);
2440 | static_string_EXPRESSION
2444 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2448 | subtype_Name ' Access
2452 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2454 MECHANISM_ASSOCIATION ::=
2455 [formal_parameter_NAME =>] MECHANISM_NAME
2460 | Descriptor [([Class =>] CLASS_NAME)]
2462 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2466 This pragma is identical to @code{Import_Function} except that it
2467 applies to a procedure rather than a function and the parameters
2468 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2470 @node Pragma Import_Valued_Procedure
2471 @unnumberedsec Pragma Import_Valued_Procedure
2472 @findex Import_Valued_Procedure
2476 @smallexample @c ada
2477 pragma Import_Valued_Procedure (
2478 [Internal =>] LOCAL_NAME
2479 [, [External =>] EXTERNAL_SYMBOL]
2480 [, [Parameter_Types =>] PARAMETER_TYPES]
2481 [, [Mechanism =>] MECHANISM]
2482 [, [First_Optional_Parameter =>] IDENTIFIER]);
2486 | static_string_EXPRESSION
2490 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2494 | subtype_Name ' Access
2498 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2500 MECHANISM_ASSOCIATION ::=
2501 [formal_parameter_NAME =>] MECHANISM_NAME
2506 | Descriptor [([Class =>] CLASS_NAME)]
2508 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2512 This pragma is identical to @code{Import_Procedure} except that the
2513 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2514 mode @code{OUT}, and externally the subprogram is treated as a function
2515 with this parameter as the result of the function. The purpose of this
2516 capability is to allow the use of @code{OUT} and @code{IN OUT}
2517 parameters in interfacing to external functions (which are not permitted
2518 in Ada functions). You may optionally use the @code{Mechanism}
2519 parameters to specify passing mechanisms for the parameters.
2520 If you specify a single mechanism name, it applies to all parameters.
2521 Otherwise you may specify a mechanism on a parameter by parameter
2522 basis using either positional or named notation. If the mechanism is not
2523 specified, the default mechanism is used.
2525 Note that it is important to use this pragma in conjunction with a separate
2526 pragma Import that specifies the desired convention, since otherwise the
2527 default convention is Ada, which is almost certainly not what is required.
2529 @node Pragma Initialize_Scalars
2530 @unnumberedsec Pragma Initialize_Scalars
2531 @findex Initialize_Scalars
2532 @cindex debugging with Initialize_Scalars
2536 @smallexample @c ada
2537 pragma Initialize_Scalars;
2541 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2542 two important differences. First, there is no requirement for the pragma
2543 to be used uniformly in all units of a partition, in particular, it is fine
2544 to use this just for some or all of the application units of a partition,
2545 without needing to recompile the run-time library.
2547 In the case where some units are compiled with the pragma, and some without,
2548 then a declaration of a variable where the type is defined in package
2549 Standard or is locally declared will always be subject to initialization,
2550 as will any declaration of a scalar variable. For composite variables,
2551 whether the variable is initialized may also depend on whether the package
2552 in which the type of the variable is declared is compiled with the pragma.
2554 The other important difference is that you can control the value used
2555 for initializing scalar objects. At bind time, you can select several
2556 options for initialization. You can
2557 initialize with invalid values (similar to Normalize_Scalars, though for
2558 Initialize_Scalars it is not always possible to determine the invalid
2559 values in complex cases like signed component fields with non-standard
2560 sizes). You can also initialize with high or
2561 low values, or with a specified bit pattern. See the users guide for binder
2562 options for specifying these cases.
2564 This means that you can compile a program, and then without having to
2565 recompile the program, you can run it with different values being used
2566 for initializing otherwise uninitialized values, to test if your program
2567 behavior depends on the choice. Of course the behavior should not change,
2568 and if it does, then most likely you have an erroneous reference to an
2569 uninitialized value.
2571 It is even possible to change the value at execution time eliminating even
2572 the need to rebind with a different switch using an environment variable.
2573 See the GNAT users guide for details.
2575 Note that pragma @code{Initialize_Scalars} is particularly useful in
2576 conjunction with the enhanced validity checking that is now provided
2577 in GNAT, which checks for invalid values under more conditions.
2578 Using this feature (see description of the @code{-gnatV} flag in the
2579 users guide) in conjunction with pragma @code{Initialize_Scalars}
2580 provides a powerful new tool to assist in the detection of problems
2581 caused by uninitialized variables.
2583 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2584 effect on the generated code. This may cause your code to be
2585 substantially larger. It may also cause an increase in the amount
2586 of stack required, so it is probably a good idea to turn on stack
2587 checking (see description of stack checking in the GNAT users guide)
2588 when using this pragma.
2590 @node Pragma Inline_Always
2591 @unnumberedsec Pragma Inline_Always
2592 @findex Inline_Always
2596 @smallexample @c ada
2597 pragma Inline_Always (NAME [, NAME]);
2601 Similar to pragma @code{Inline} except that inlining is not subject to
2602 the use of option @code{-gnatn} and the inlining happens regardless of
2603 whether this option is used.
2605 @node Pragma Inline_Generic
2606 @unnumberedsec Pragma Inline_Generic
2607 @findex Inline_Generic
2611 @smallexample @c ada
2612 pragma Inline_Generic (generic_package_NAME);
2616 This is implemented for compatibility with DEC Ada 83 and is recognized,
2617 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2618 by default when using GNAT@.
2620 @node Pragma Interface
2621 @unnumberedsec Pragma Interface
2626 @smallexample @c ada
2628 [Convention =>] convention_identifier,
2629 [Entity =>] local_NAME
2630 [, [External_Name =>] static_string_expression]
2631 [, [Link_Name =>] static_string_expression]);
2635 This pragma is identical in syntax and semantics to
2636 the standard Ada pragma @code{Import}. It is provided for compatibility
2637 with Ada 83. The definition is upwards compatible both with pragma
2638 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2639 with some extended implementations of this pragma in certain Ada 83
2642 @node Pragma Interface_Name
2643 @unnumberedsec Pragma Interface_Name
2644 @findex Interface_Name
2648 @smallexample @c ada
2649 pragma Interface_Name (
2650 [Entity =>] LOCAL_NAME
2651 [, [External_Name =>] static_string_EXPRESSION]
2652 [, [Link_Name =>] static_string_EXPRESSION]);
2656 This pragma provides an alternative way of specifying the interface name
2657 for an interfaced subprogram, and is provided for compatibility with Ada
2658 83 compilers that use the pragma for this purpose. You must provide at
2659 least one of @var{External_Name} or @var{Link_Name}.
2661 @node Pragma Interrupt_Handler
2662 @unnumberedsec Pragma Interrupt_Handler
2663 @findex Interrupt_Handler
2667 @smallexample @c ada
2668 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2672 This program unit pragma is supported for parameterless protected procedures
2673 as described in Annex C of the Ada Reference Manual. On the AAMP target
2674 the pragma can also be specified for nonprotected parameterless procedures
2675 that are declared at the library level (which includes procedures
2676 declared at the top level of a library package). In the case of AAMP,
2677 when this pragma is applied to a nonprotected procedure, the instruction
2678 @code{IERET} is generated for returns from the procedure, enabling
2679 maskable interrupts, in place of the normal return instruction.
2681 @node Pragma Interrupt_State
2682 @unnumberedsec Pragma Interrupt_State
2683 @findex Interrupt_State
2687 @smallexample @c ada
2688 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2692 Normally certain interrupts are reserved to the implementation. Any attempt
2693 to attach an interrupt causes Program_Error to be raised, as described in
2694 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
2695 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
2696 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2697 interrupt execution. Additionally, signals such as @code{SIGSEGV},
2698 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2699 Ada exceptions, or used to implement run-time functions such as the
2700 @code{abort} statement and stack overflow checking.
2702 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2703 such uses of interrupts. It subsumes the functionality of pragma
2704 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
2705 available on OS/2, Windows or VMS. On all other platforms than VxWorks,
2706 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2707 and may be used to mark interrupts required by the board support package
2710 Interrupts can be in one of three states:
2714 The interrupt is reserved (no Ada handler can be installed), and the
2715 Ada run-time may not install a handler. As a result you are guaranteed
2716 standard system default action if this interrupt is raised.
2720 The interrupt is reserved (no Ada handler can be installed). The run time
2721 is allowed to install a handler for internal control purposes, but is
2722 not required to do so.
2726 The interrupt is unreserved. The user may install a handler to provide
2731 These states are the allowed values of the @code{State} parameter of the
2732 pragma. The @code{Name} parameter is a value of the type
2733 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
2734 @code{Ada.Interrupts.Names}.
2736 This is a configuration pragma, and the binder will check that there
2737 are no inconsistencies between different units in a partition in how a
2738 given interrupt is specified. It may appear anywhere a pragma is legal.
2740 The effect is to move the interrupt to the specified state.
2742 By declaring interrupts to be SYSTEM, you guarantee the standard system
2743 action, such as a core dump.
2745 By declaring interrupts to be USER, you guarantee that you can install
2748 Note that certain signals on many operating systems cannot be caught and
2749 handled by applications. In such cases, the pragma is ignored. See the
2750 operating system documentation, or the value of the array @code{Reserved}
2751 declared in the specification of package @code{System.OS_Interface}.
2753 Overriding the default state of signals used by the Ada runtime may interfere
2754 with an application's runtime behavior in the cases of the synchronous signals,
2755 and in the case of the signal used to implement the @code{abort} statement.
2757 @node Pragma Keep_Names
2758 @unnumberedsec Pragma Keep_Names
2763 @smallexample @c ada
2764 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2768 The @var{LOCAL_NAME} argument
2769 must refer to an enumeration first subtype
2770 in the current declarative part. The effect is to retain the enumeration
2771 literal names for use by @code{Image} and @code{Value} even if a global
2772 @code{Discard_Names} pragma applies. This is useful when you want to
2773 generally suppress enumeration literal names and for example you therefore
2774 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2775 want to retain the names for specific enumeration types.
2777 @node Pragma License
2778 @unnumberedsec Pragma License
2780 @cindex License checking
2784 @smallexample @c ada
2785 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2789 This pragma is provided to allow automated checking for appropriate license
2790 conditions with respect to the standard and modified GPL@. A pragma
2791 @code{License}, which is a configuration pragma that typically appears at
2792 the start of a source file or in a separate @file{gnat.adc} file, specifies
2793 the licensing conditions of a unit as follows:
2797 This is used for a unit that can be freely used with no license restrictions.
2798 Examples of such units are public domain units, and units from the Ada
2802 This is used for a unit that is licensed under the unmodified GPL, and which
2803 therefore cannot be @code{with}'ed by a restricted unit.
2806 This is used for a unit licensed under the GNAT modified GPL that includes
2807 a special exception paragraph that specifically permits the inclusion of
2808 the unit in programs without requiring the entire program to be released
2812 This is used for a unit that is restricted in that it is not permitted to
2813 depend on units that are licensed under the GPL@. Typical examples are
2814 proprietary code that is to be released under more restrictive license
2815 conditions. Note that restricted units are permitted to @code{with} units
2816 which are licensed under the modified GPL (this is the whole point of the
2822 Normally a unit with no @code{License} pragma is considered to have an
2823 unknown license, and no checking is done. However, standard GNAT headers
2824 are recognized, and license information is derived from them as follows.
2828 A GNAT license header starts with a line containing 78 hyphens. The following
2829 comment text is searched for the appearance of any of the following strings.
2831 If the string ``GNU General Public License'' is found, then the unit is assumed
2832 to have GPL license, unless the string ``As a special exception'' follows, in
2833 which case the license is assumed to be modified GPL@.
2835 If one of the strings
2836 ``This specification is adapted from the Ada Semantic Interface'' or
2837 ``This specification is derived from the Ada Reference Manual'' is found
2838 then the unit is assumed to be unrestricted.
2842 These default actions means that a program with a restricted license pragma
2843 will automatically get warnings if a GPL unit is inappropriately
2844 @code{with}'ed. For example, the program:
2846 @smallexample @c ada
2849 procedure Secret_Stuff is
2855 if compiled with pragma @code{License} (@code{Restricted}) in a
2856 @file{gnat.adc} file will generate the warning:
2861 >>> license of withed unit "Sem_Ch3" is incompatible
2863 2. with GNAT.Sockets;
2864 3. procedure Secret_Stuff is
2868 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2869 compiler and is licensed under the
2870 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2871 run time, and is therefore licensed under the modified GPL@.
2873 @node Pragma Link_With
2874 @unnumberedsec Pragma Link_With
2879 @smallexample @c ada
2880 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2884 This pragma is provided for compatibility with certain Ada 83 compilers.
2885 It has exactly the same effect as pragma @code{Linker_Options} except
2886 that spaces occurring within one of the string expressions are treated
2887 as separators. For example, in the following case:
2889 @smallexample @c ada
2890 pragma Link_With ("-labc -ldef");
2894 results in passing the strings @code{-labc} and @code{-ldef} as two
2895 separate arguments to the linker. In addition pragma Link_With allows
2896 multiple arguments, with the same effect as successive pragmas.
2898 @node Pragma Linker_Alias
2899 @unnumberedsec Pragma Linker_Alias
2900 @findex Linker_Alias
2904 @smallexample @c ada
2905 pragma Linker_Alias (
2906 [Entity =>] LOCAL_NAME,
2907 [Target =>] static_string_EXPRESSION);
2911 @var{LOCAL_NAME} must refer to an object that is declared at the library
2912 level. This pragma establishes the given entity as a linker alias for the
2913 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
2914 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
2915 @var{static_string_EXPRESSION} in the object file, that is to say no space
2916 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
2917 to the same address as @var{static_string_EXPRESSION} by the linker.
2919 The actual linker name for the target must be used (e.g. the fully
2920 encoded name with qualification in Ada, or the mangled name in C++),
2921 or it must be declared using the C convention with @code{pragma Import}
2922 or @code{pragma Export}.
2924 Not all target machines support this pragma. On some of them it is accepted
2925 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
2927 @smallexample @c ada
2928 -- Example of the use of pragma Linker_Alias
2932 pragma Export (C, i);
2934 new_name_for_i : Integer;
2935 pragma Linker_Alias (new_name_for_i, "i");
2939 @node Pragma Linker_Constructor
2940 @unnumberedsec Pragma Linker_Constructor
2941 @findex Linker_Constructor
2945 @smallexample @c ada
2946 pragma Linker_Constructor (procedure_LOCAL_NAME);
2950 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
2951 is declared at the library level. A procedure to which this pragma is
2952 applied will be treated as an initialization routine by the linker.
2953 It is equivalent to @code{__attribute__((constructor))} in GNU C and
2954 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
2955 of the executable is called (or immediately after the shared library is
2956 loaded if the procedure is linked in a shared library), in particular
2957 before the Ada run-time environment is set up.
2959 Because of these specific contexts, the set of operations such a procedure
2960 can perform is very limited and the type of objects it can manipulate is
2961 essentially restricted to the elementary types. In particular, it must only
2962 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
2964 This pragma is used by GNAT to implement auto-initialization of shared Stand
2965 Alone Libraries, which provides a related capability without the restrictions
2966 listed above. Where possible, the use of Stand Alone Libraries is preferable
2967 to the use of this pragma.
2969 @node Pragma Linker_Destructor
2970 @unnumberedsec Pragma Linker_Destructor
2971 @findex Linker_Destructor
2975 @smallexample @c ada
2976 pragma Linker_Destructor (procedure_LOCAL_NAME);
2980 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
2981 is declared at the library level. A procedure to which this pragma is
2982 applied will be treated as a finalization routine by the linker.
2983 It is equivalent to @code{__attribute__((destructor))} in GNU C and
2984 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
2985 of the executable has exited (or immediately before the shared library
2986 is unloaded if the procedure is linked in a shared library), in particular
2987 after the Ada run-time environment is shut down.
2989 See @code{pragma Linker_Constructor} for the set of restrictions that apply
2990 because of these specific contexts.
2992 @node Pragma Linker_Section
2993 @unnumberedsec Pragma Linker_Section
2994 @findex Linker_Section
2998 @smallexample @c ada
2999 pragma Linker_Section (
3000 [Entity =>] LOCAL_NAME,
3001 [Section =>] static_string_EXPRESSION);
3005 @var{LOCAL_NAME} must refer to an object that is declared at the library
3006 level. This pragma specifies the name of the linker section for the given
3007 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3008 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3009 section of the executable (assuming the linker doesn't rename the section).
3011 The compiler normally places library-level objects in standard sections
3012 depending on their type: procedures and functions generally go in the
3013 @code{.text} section, initialized variables in the @code{.data} section
3014 and uninitialized variables in the @code{.bss} section.
3016 Other, special sections may exist on given target machines to map special
3017 hardware, for example I/O ports or flash memory. This pragma is a means to
3018 defer the final layout of the executable to the linker, thus fully working
3019 at the symbolic level with the compiler.
3021 Some file formats do not support arbitrary sections so not all target
3022 machines support this pragma. The use of this pragma may cause a program
3023 execution to be erroneous if it is used to place an entity into an
3024 inappropriate section (e.g. a modified variable into the @code{.text}
3025 section). See also @code{pragma Persistent_BSS}.
3027 @smallexample @c ada
3028 -- Example of the use of pragma Linker_Section
3032 pragma Volatile (Port_A);
3033 pragma Linker_Section (Port_A, ".bss.port_a");
3036 pragma Volatile (Port_B);
3037 pragma Linker_Section (Port_B, ".bss.port_b");
3041 @node Pragma Long_Float
3042 @unnumberedsec Pragma Long_Float
3048 @smallexample @c ada
3049 pragma Long_Float (FLOAT_FORMAT);
3051 FLOAT_FORMAT ::= D_Float | G_Float
3055 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3056 It allows control over the internal representation chosen for the predefined
3057 type @code{Long_Float} and for floating point type representations with
3058 @code{digits} specified in the range 7 through 15.
3059 For further details on this pragma, see the
3060 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3061 this pragma, the standard runtime libraries must be recompiled. See the
3062 description of the @code{GNAT LIBRARY} command in the OpenVMS version
3063 of the GNAT User's Guide for details on the use of this command.
3065 @node Pragma Machine_Attribute
3066 @unnumberedsec Pragma Machine_Attribute
3067 @findex Machine_Attribute
3071 @smallexample @c ada
3072 pragma Machine_Attribute (
3073 [Entity =>] LOCAL_NAME,
3074 [Attribute_Name =>] static_string_EXPRESSION
3075 [, [Info =>] static_string_EXPRESSION] );
3079 Machine-dependent attributes can be specified for types and/or
3080 declarations. This pragma is semantically equivalent to
3081 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3082 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3083 in GNU C, where @code{@var{attribute_name}} is recognized by the
3084 target macro @code{TARGET_ATTRIBUTE_TABLE} which is defined for each
3085 machine. The optional parameter @var{info} is transformed into an
3086 identifier, which may make this pragma unusable for some attributes
3087 (parameter of some attributes must be a number or a string). See the
3088 GCC manual for further information. It is not possible to specify
3089 attributes defined by other languages, only attributes defined by the
3090 machine the code is intended to run on.
3093 @unnumberedsec Pragma Main
3099 @smallexample @c ada
3101 (MAIN_OPTION [, MAIN_OPTION]);
3104 [STACK_SIZE =>] static_integer_EXPRESSION
3105 | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
3106 | [TIME_SLICING_ENABLED =>] static_boolean_EXPRESSION
3110 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3111 no effect in GNAT, other than being syntax checked.
3113 @node Pragma Main_Storage
3114 @unnumberedsec Pragma Main_Storage
3116 @findex Main_Storage
3120 @smallexample @c ada
3122 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3124 MAIN_STORAGE_OPTION ::=
3125 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3126 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3130 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3131 no effect in GNAT, other than being syntax checked. Note that the pragma
3132 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3134 @node Pragma No_Body
3135 @unnumberedsec Pragma No_Body
3140 @smallexample @c ada
3145 There are a number of cases in which a package spec does not require a body,
3146 and in fact a body is not permitted. GNAT will not permit the spec to be
3147 compiled if there is a body around. The pragma No_Body allows you to provide
3148 a body file, even in a case where no body is allowed. The body file must
3149 contain only comments and a single No_Body pragma. This is recognized by
3150 the compiler as indicating that no body is logically present.
3152 This is particularly useful during maintenance when a package is modified in
3153 such a way that a body needed before is no longer needed. The provision of a
3154 dummy body with a No_Body pragma ensures that there is no inteference from
3155 earlier versions of the package body.
3157 @node Pragma No_Return
3158 @unnumberedsec Pragma No_Return
3163 @smallexample @c ada
3164 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3168 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3169 declarations in the current declarative part. A procedure to which this
3170 pragma is applied may not contain any explicit @code{return} statements.
3171 In addition, if the procedure contains any implicit returns from falling
3172 off the end of a statement sequence, then execution of that implicit
3173 return will cause Program_Error to be raised.
3175 One use of this pragma is to identify procedures whose only purpose is to raise
3176 an exception. Another use of this pragma is to suppress incorrect warnings
3177 about missing returns in functions, where the last statement of a function
3178 statement sequence is a call to such a procedure.
3180 Note that in Ada 2005 mode, this pragma is part of the language, and is
3181 identical in effect to the pragma as implemented in Ada 95 mode.
3183 @node Pragma No_Strict_Aliasing
3184 @unnumberedsec Pragma No_Strict_Aliasing
3185 @findex No_Strict_Aliasing
3189 @smallexample @c ada
3190 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3194 @var{type_LOCAL_NAME} must refer to an access type
3195 declaration in the current declarative part. The effect is to inhibit
3196 strict aliasing optimization for the given type. The form with no
3197 arguments is a configuration pragma which applies to all access types
3198 declared in units to which the pragma applies. For a detailed
3199 description of the strict aliasing optimization, and the situations
3200 in which it must be suppressed, see section
3201 ``Optimization and Strict Aliasing'' in the @value{EDITION} User's Guide.
3203 @node Pragma Normalize_Scalars
3204 @unnumberedsec Pragma Normalize_Scalars
3205 @findex Normalize_Scalars
3209 @smallexample @c ada
3210 pragma Normalize_Scalars;
3214 This is a language defined pragma which is fully implemented in GNAT@. The
3215 effect is to cause all scalar objects that are not otherwise initialized
3216 to be initialized. The initial values are implementation dependent and
3220 @item Standard.Character
3222 Objects whose root type is Standard.Character are initialized to
3223 Character'Last unless the subtype range excludes NUL (in which case
3224 NUL is used). This choice will always generate an invalid value if
3227 @item Standard.Wide_Character
3229 Objects whose root type is Standard.Wide_Character are initialized to
3230 Wide_Character'Last unless the subtype range excludes NUL (in which case
3231 NUL is used). This choice will always generate an invalid value if
3234 @item Standard.Wide_Wide_Character
3236 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3237 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3238 which case NUL is used). This choice will always generate an invalid value if
3243 Objects of an integer type are treated differently depending on whether
3244 negative values are present in the subtype. If no negative values are
3245 present, then all one bits is used as the initial value except in the
3246 special case where zero is excluded from the subtype, in which case
3247 all zero bits are used. This choice will always generate an invalid
3248 value if one exists.
3250 For subtypes with negative values present, the largest negative number
3251 is used, except in the unusual case where this largest negative number
3252 is in the subtype, and the largest positive number is not, in which case
3253 the largest positive value is used. This choice will always generate
3254 an invalid value if one exists.
3256 @item Floating-Point Types
3257 Objects of all floating-point types are initialized to all 1-bits. For
3258 standard IEEE format, this corresponds to a NaN (not a number) which is
3259 indeed an invalid value.
3261 @item Fixed-Point Types
3262 Objects of all fixed-point types are treated as described above for integers,
3263 with the rules applying to the underlying integer value used to represent
3264 the fixed-point value.
3267 Objects of a modular type are initialized to all one bits, except in
3268 the special case where zero is excluded from the subtype, in which
3269 case all zero bits are used. This choice will always generate an
3270 invalid value if one exists.
3272 @item Enumeration types
3273 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3274 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3275 whose Pos value is zero, in which case a code of zero is used. This choice
3276 will always generate an invalid value if one exists.
3280 @node Pragma Obsolescent
3281 @unnumberedsec Pragma Obsolescent
3286 @smallexample @c ada
3288 (Entity => NAME [, static_string_EXPRESSION [,Ada_05]]);
3292 This pragma can occur immediately following a declaration of an entity,
3293 including the case of a record component, and usually the Entity name
3294 must match the name of the entity declared by this declaration.
3295 Alternatively, the pragma can immediately follow an
3296 enumeration type declaration, where the entity argument names one of the
3297 enumeration literals.
3299 This pragma is used to indicate that the named entity
3300 is considered obsolescent and should not be used. Typically this is
3301 used when an API must be modified by eventually removing or modifying
3302 existing subprograms or other entities. The pragma can be used at an
3303 intermediate stage when the entity is still present, but will be
3306 The effect of this pragma is to output a warning message on
3307 a call to a program thus marked that the
3308 subprogram is obsolescent if the appropriate warning option in the
3309 compiler is activated. If the string parameter is present, then a second
3310 warning message is given containing this text.
3311 In addition, a call to such a program is considered a violation of
3312 pragma Restrictions (No_Obsolescent_Features).
3314 This pragma can also be used as a program unit pragma for a package,
3315 in which case the entity name is the name of the package, and the
3316 pragma indicates that the entire package is considered
3317 obsolescent. In this case a client @code{with}'ing such a package
3318 violates the restriction, and the @code{with} statement is
3319 flagged with warnings if the warning option is set.
3321 If the optional third parameter is present (which must be exactly
3322 the identifier Ada_05, no other argument is allowed), then the
3323 indication of obsolescence applies only when compiling in Ada 2005
3324 mode. This is primarily intended for dealing with the situations
3325 in the predefined library where subprograms or packages
3326 have become defined as obsolescent in Ada 2005
3327 (e.g. in Ada.Characters.Handling), but may be used anywhere.
3329 The following examples show typical uses of this pragma:
3331 @smallexample @c ada
3334 (Entity => p, "use pp instead of p");
3340 (Entity => q2, "use q2new instead");
3342 type R is new integer;
3344 (Entity => R, "use RR in Ada 2005", Ada_05);
3349 pragma Obsolescent (Entity => F2);
3353 type E is (a, bc, 'd', quack);
3354 pragma Obsolescent (Entity => bc)
3355 pragma Obsolescent (Entity => 'd')
3358 (a, b : character) return character;
3359 pragma Obsolescent (Entity => "+");
3364 In an earlier version of GNAT, the Entity parameter was not required,
3365 and this form is still accepted for compatibility purposes. If the
3366 Entity parameter is omitted, then the pragma applies to the declaration
3367 immediately preceding the pragma (this form cannot be used for the
3368 enumeration literal case).
3370 @node Pragma Passive
3371 @unnumberedsec Pragma Passive
3376 @smallexample @c ada
3377 pragma Passive [(Semaphore | No)];
3381 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3382 compatibility with DEC Ada 83 implementations, where it is used within a
3383 task definition to request that a task be made passive. If the argument
3384 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3385 treats the pragma as an assertion that the containing task is passive
3386 and that optimization of context switch with this task is permitted and
3387 desired. If the argument @code{No} is present, the task must not be
3388 optimized. GNAT does not attempt to optimize any tasks in this manner
3389 (since protected objects are available in place of passive tasks).
3391 @node Pragma Persistent_BSS
3392 @unnumberedsec Pragma Persistent_BSS
3393 @findex Persistent_BSS
3397 @smallexample @c ada
3398 pragma Persistent_BSS [(LOCAL_NAME)]
3402 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3403 section. On some targets the linker and loader provide for special
3404 treatment of this section, allowing a program to be reloaded without
3405 affecting the contents of this data (hence the name persistent).
3407 There are two forms of usage. If an argument is given, it must be the
3408 local name of a library level object, with no explicit initialization
3409 and whose type is potentially persistent. If no argument is given, then
3410 the pragma is a configuration pragma, and applies to all library level
3411 objects with no explicit initialization of potentially persistent types.
3413 A potentially persistent type is a scalar type, or a non-tagged,
3414 non-discriminated record, all of whose components have no explicit
3415 initialization and are themselves of a potentially persistent type,
3416 or an array, all of whose constraints are static, and whose component
3417 type is potentially persistent.
3419 If this pragma is used on a target where this feature is not supported,
3420 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3422 @node Pragma Polling
3423 @unnumberedsec Pragma Polling
3428 @smallexample @c ada
3429 pragma Polling (ON | OFF);
3433 This pragma controls the generation of polling code. This is normally off.
3434 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3435 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3436 runtime library, and can be found in file @file{a-excpol.adb}.
3438 Pragma @code{Polling} can appear as a configuration pragma (for example it
3439 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3440 can be used in the statement or declaration sequence to control polling
3443 A call to the polling routine is generated at the start of every loop and
3444 at the start of every subprogram call. This guarantees that the @code{Poll}
3445 routine is called frequently, and places an upper bound (determined by
3446 the complexity of the code) on the period between two @code{Poll} calls.
3448 The primary purpose of the polling interface is to enable asynchronous
3449 aborts on targets that cannot otherwise support it (for example Windows
3450 NT), but it may be used for any other purpose requiring periodic polling.
3451 The standard version is null, and can be replaced by a user program. This
3452 will require re-compilation of the @code{Ada.Exceptions} package that can
3453 be found in files @file{a-except.ads} and @file{a-except.adb}.
3455 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3456 distribution) is used to enable the asynchronous abort capability on
3457 targets that do not normally support the capability. The version of
3458 @code{Poll} in this file makes a call to the appropriate runtime routine
3459 to test for an abort condition.
3461 Note that polling can also be enabled by use of the @code{-gnatP} switch. See
3462 the @cite{GNAT User's Guide} for details.
3464 @node Pragma Profile (Ravenscar)
3465 @unnumberedsec Pragma Profile (Ravenscar)
3470 @smallexample @c ada
3471 pragma Profile (Ravenscar);
3475 A configuration pragma that establishes the following set of configuration
3479 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3480 [RM D.2.2] Tasks are dispatched following a preemptive
3481 priority-ordered scheduling policy.
3483 @item Locking_Policy (Ceiling_Locking)
3484 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3485 the ceiling priority of the corresponding protected object.
3487 @c @item Detect_Blocking
3488 @c This pragma forces the detection of potentially blocking operations within a
3489 @c protected operation, and to raise Program_Error if that happens.
3493 plus the following set of restrictions:
3496 @item Max_Entry_Queue_Length = 1
3497 Defines the maximum number of calls that are queued on a (protected) entry.
3498 Note that this restrictions is checked at run time. Violation of this
3499 restriction results in the raising of Program_Error exception at the point of
3500 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3501 always 1 and hence no task can be queued on a protected entry.
3503 @item Max_Protected_Entries = 1
3504 [RM D.7] Specifies the maximum number of entries per protected type. The
3505 bounds of every entry family of a protected unit shall be static, or shall be
3506 defined by a discriminant of a subtype whose corresponding bound is static.
3507 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3509 @item Max_Task_Entries = 0
3510 [RM D.7] Specifies the maximum number of entries
3511 per task. The bounds of every entry family
3512 of a task unit shall be static, or shall be
3513 defined by a discriminant of a subtype whose
3514 corresponding bound is static. A value of zero
3515 indicates that no rendezvous are possible. For
3516 the Profile (Ravenscar), the value of Max_Task_Entries is always
3519 @item No_Abort_Statements
3520 [RM D.7] There are no abort_statements, and there are
3521 no calls to Task_Identification.Abort_Task.
3523 @item No_Asynchronous_Control
3524 [RM D.7] There are no semantic dependences on the package
3525 Asynchronous_Task_Control.
3528 There are no semantic dependencies on the package Ada.Calendar.
3530 @item No_Dynamic_Attachment
3531 There is no call to any of the operations defined in package Ada.Interrupts
3532 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3533 Detach_Handler, and Reference).
3535 @item No_Dynamic_Priorities
3536 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3538 @item No_Implicit_Heap_Allocations
3539 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3541 @item No_Local_Protected_Objects
3542 Protected objects and access types that designate
3543 such objects shall be declared only at library level.
3545 @item No_Protected_Type_Allocators
3546 There are no allocators for protected types or
3547 types containing protected subcomponents.
3549 @item No_Relative_Delay
3550 There are no delay_relative statements.
3552 @item No_Requeue_Statements
3553 Requeue statements are not allowed.
3555 @item No_Select_Statements
3556 There are no select_statements.
3558 @item No_Task_Allocators
3559 [RM D.7] There are no allocators for task types
3560 or types containing task subcomponents.
3562 @item No_Task_Attributes_Package
3563 There are no semantic dependencies on the Ada.Task_Attributes package.
3565 @item No_Task_Hierarchy
3566 [RM D.7] All (non-environment) tasks depend
3567 directly on the environment task of the partition.
3569 @item No_Task_Termination
3570 Tasks which terminate are erroneous.
3572 @item Simple_Barriers
3573 Entry barrier condition expressions shall be either static
3574 boolean expressions or boolean objects which are declared in
3575 the protected type which contains the entry.
3579 This set of configuration pragmas and restrictions correspond to the
3580 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3581 published by the @cite{International Real-Time Ada Workshop}, 1997,
3582 and whose most recent description is available at
3583 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
3585 The original definition of the profile was revised at subsequent IRTAW
3586 meetings. It has been included in the ISO
3587 @cite{Guide for the Use of the Ada Programming Language in High
3588 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3589 the next revision of the standard. The formal definition given by
3590 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3591 AI-305) available at
3592 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3593 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3596 The above set is a superset of the restrictions provided by pragma
3597 @code{Profile (Restricted)}, it includes six additional restrictions
3598 (@code{Simple_Barriers}, @code{No_Select_Statements},
3599 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3600 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
3601 that pragma @code{Profile (Ravenscar)}, like the pragma
3602 @code{Profile (Restricted)},
3603 automatically causes the use of a simplified,
3604 more efficient version of the tasking run-time system.
3606 @node Pragma Profile (Restricted)
3607 @unnumberedsec Pragma Profile (Restricted)
3608 @findex Restricted Run Time
3612 @smallexample @c ada
3613 pragma Profile (Restricted);
3617 A configuration pragma that establishes the following set of restrictions:
3620 @item No_Abort_Statements
3621 @item No_Entry_Queue
3622 @item No_Task_Hierarchy
3623 @item No_Task_Allocators
3624 @item No_Dynamic_Priorities
3625 @item No_Terminate_Alternatives
3626 @item No_Dynamic_Attachment
3627 @item No_Protected_Type_Allocators
3628 @item No_Local_Protected_Objects
3629 @item No_Requeue_Statements
3630 @item No_Task_Attributes_Package
3631 @item Max_Asynchronous_Select_Nesting = 0
3632 @item Max_Task_Entries = 0
3633 @item Max_Protected_Entries = 1
3634 @item Max_Select_Alternatives = 0
3638 This set of restrictions causes the automatic selection of a simplified
3639 version of the run time that provides improved performance for the
3640 limited set of tasking functionality permitted by this set of restrictions.
3642 @node Pragma Psect_Object
3643 @unnumberedsec Pragma Psect_Object
3644 @findex Psect_Object
3648 @smallexample @c ada
3649 pragma Psect_Object (
3650 [Internal =>] LOCAL_NAME,
3651 [, [External =>] EXTERNAL_SYMBOL]
3652 [, [Size =>] EXTERNAL_SYMBOL]);
3656 | static_string_EXPRESSION
3660 This pragma is identical in effect to pragma @code{Common_Object}.
3662 @node Pragma Pure_Function
3663 @unnumberedsec Pragma Pure_Function
3664 @findex Pure_Function
3668 @smallexample @c ada
3669 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
3673 This pragma appears in the same declarative part as a function
3674 declaration (or a set of function declarations if more than one
3675 overloaded declaration exists, in which case the pragma applies
3676 to all entities). It specifies that the function @code{Entity} is
3677 to be considered pure for the purposes of code generation. This means
3678 that the compiler can assume that there are no side effects, and
3679 in particular that two calls with identical arguments produce the
3680 same result. It also means that the function can be used in an
3683 Note that, quite deliberately, there are no static checks to try
3684 to ensure that this promise is met, so @code{Pure_Function} can be used
3685 with functions that are conceptually pure, even if they do modify
3686 global variables. For example, a square root function that is
3687 instrumented to count the number of times it is called is still
3688 conceptually pure, and can still be optimized, even though it
3689 modifies a global variable (the count). Memo functions are another
3690 example (where a table of previous calls is kept and consulted to
3691 avoid re-computation).
3694 Note: Most functions in a @code{Pure} package are automatically pure, and
3695 there is no need to use pragma @code{Pure_Function} for such functions. One
3696 exception is any function that has at least one formal of type
3697 @code{System.Address} or a type derived from it. Such functions are not
3698 considered pure by default, since the compiler assumes that the
3699 @code{Address} parameter may be functioning as a pointer and that the
3700 referenced data may change even if the address value does not.
3701 Similarly, imported functions are not considered to be pure by default,
3702 since there is no way of checking that they are in fact pure. The use
3703 of pragma @code{Pure_Function} for such a function will override these default
3704 assumption, and cause the compiler to treat a designated subprogram as pure
3707 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3708 applies to the underlying renamed function. This can be used to
3709 disambiguate cases of overloading where some but not all functions
3710 in a set of overloaded functions are to be designated as pure.
3712 If pragma @code{Pure_Function} is applied to a library level function, the
3713 function is also considered pure from an optimization point of view, but the
3714 unit is not a Pure unit in the categorization sense. So for example, a function
3715 thus marked is free to @code{with} non-pure units.
3717 @node Pragma Restriction_Warnings
3718 @unnumberedsec Pragma Restriction_Warnings
3719 @findex Restriction_Warnings
3723 @smallexample @c ada
3724 pragma Restriction_Warnings
3725 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3729 This pragma allows a series of restriction identifiers to be
3730 specified (the list of allowed identifiers is the same as for
3731 pragma @code{Restrictions}). For each of these identifiers
3732 the compiler checks for violations of the restriction, but
3733 generates a warning message rather than an error message
3734 if the restriction is violated.
3737 @unnumberedsec Pragma Shared
3741 This pragma is provided for compatibility with Ada 83. The syntax and
3742 semantics are identical to pragma Atomic.
3744 @node Pragma Source_File_Name
3745 @unnumberedsec Pragma Source_File_Name
3746 @findex Source_File_Name
3750 @smallexample @c ada
3751 pragma Source_File_Name (
3752 [Unit_Name =>] unit_NAME,
3753 Spec_File_Name => STRING_LITERAL);
3755 pragma Source_File_Name (
3756 [Unit_Name =>] unit_NAME,
3757 Body_File_Name => STRING_LITERAL);
3761 Use this to override the normal naming convention. It is a configuration
3762 pragma, and so has the usual applicability of configuration pragmas
3763 (i.e.@: it applies to either an entire partition, or to all units in a
3764 compilation, or to a single unit, depending on how it is used.
3765 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
3766 the second argument is required, and indicates whether this is the file
3767 name for the spec or for the body.
3769 Another form of the @code{Source_File_Name} pragma allows
3770 the specification of patterns defining alternative file naming schemes
3771 to apply to all files.
3773 @smallexample @c ada
3774 pragma Source_File_Name
3775 (Spec_File_Name => STRING_LITERAL
3776 [,Casing => CASING_SPEC]
3777 [,Dot_Replacement => STRING_LITERAL]);
3779 pragma Source_File_Name
3780 (Body_File_Name => STRING_LITERAL
3781 [,Casing => CASING_SPEC]
3782 [,Dot_Replacement => STRING_LITERAL]);
3784 pragma Source_File_Name
3785 (Subunit_File_Name => STRING_LITERAL
3786 [,Casing => CASING_SPEC]
3787 [,Dot_Replacement => STRING_LITERAL]);
3789 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3793 The first argument is a pattern that contains a single asterisk indicating
3794 the point at which the unit name is to be inserted in the pattern string
3795 to form the file name. The second argument is optional. If present it
3796 specifies the casing of the unit name in the resulting file name string.
3797 The default is lower case. Finally the third argument allows for systematic
3798 replacement of any dots in the unit name by the specified string literal.
3800 A pragma Source_File_Name cannot appear after a
3801 @ref{Pragma Source_File_Name_Project}.
3803 For more details on the use of the @code{Source_File_Name} pragma,
3804 see the sections ``Using Other File Names'' and
3805 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3807 @node Pragma Source_File_Name_Project
3808 @unnumberedsec Pragma Source_File_Name_Project
3809 @findex Source_File_Name_Project
3812 This pragma has the same syntax and semantics as pragma Source_File_Name.
3813 It is only allowed as a stand alone configuration pragma.
3814 It cannot appear after a @ref{Pragma Source_File_Name}, and
3815 most importantly, once pragma Source_File_Name_Project appears,
3816 no further Source_File_Name pragmas are allowed.
3818 The intention is that Source_File_Name_Project pragmas are always
3819 generated by the Project Manager in a manner consistent with the naming
3820 specified in a project file, and when naming is controlled in this manner,
3821 it is not permissible to attempt to modify this naming scheme using
3822 Source_File_Name pragmas (which would not be known to the project manager).
3824 @node Pragma Source_Reference
3825 @unnumberedsec Pragma Source_Reference
3826 @findex Source_Reference
3830 @smallexample @c ada
3831 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3835 This pragma must appear as the first line of a source file.
3836 @var{integer_literal} is the logical line number of the line following
3837 the pragma line (for use in error messages and debugging
3838 information). @var{string_literal} is a static string constant that
3839 specifies the file name to be used in error messages and debugging
3840 information. This is most notably used for the output of @code{gnatchop}
3841 with the @code{-r} switch, to make sure that the original unchopped
3842 source file is the one referred to.
3844 The second argument must be a string literal, it cannot be a static
3845 string expression other than a string literal. This is because its value
3846 is needed for error messages issued by all phases of the compiler.
3848 @node Pragma Stream_Convert
3849 @unnumberedsec Pragma Stream_Convert
3850 @findex Stream_Convert
3854 @smallexample @c ada
3855 pragma Stream_Convert (
3856 [Entity =>] type_LOCAL_NAME,
3857 [Read =>] function_NAME,
3858 [Write =>] function_NAME);
3862 This pragma provides an efficient way of providing stream functions for
3863 types defined in packages. Not only is it simpler to use than declaring
3864 the necessary functions with attribute representation clauses, but more
3865 significantly, it allows the declaration to made in such a way that the
3866 stream packages are not loaded unless they are needed. The use of
3867 the Stream_Convert pragma adds no overhead at all, unless the stream
3868 attributes are actually used on the designated type.
3870 The first argument specifies the type for which stream functions are
3871 provided. The second parameter provides a function used to read values
3872 of this type. It must name a function whose argument type may be any
3873 subtype, and whose returned type must be the type given as the first
3874 argument to the pragma.
3876 The meaning of the @var{Read}
3877 parameter is that if a stream attribute directly
3878 or indirectly specifies reading of the type given as the first parameter,
3879 then a value of the type given as the argument to the Read function is
3880 read from the stream, and then the Read function is used to convert this
3881 to the required target type.
3883 Similarly the @var{Write} parameter specifies how to treat write attributes
3884 that directly or indirectly apply to the type given as the first parameter.
3885 It must have an input parameter of the type specified by the first parameter,
3886 and the return type must be the same as the input type of the Read function.
3887 The effect is to first call the Write function to convert to the given stream
3888 type, and then write the result type to the stream.
3890 The Read and Write functions must not be overloaded subprograms. If necessary
3891 renamings can be supplied to meet this requirement.
3892 The usage of this attribute is best illustrated by a simple example, taken
3893 from the GNAT implementation of package Ada.Strings.Unbounded:
3895 @smallexample @c ada
3896 function To_Unbounded (S : String)
3897 return Unbounded_String
3898 renames To_Unbounded_String;
3900 pragma Stream_Convert
3901 (Unbounded_String, To_Unbounded, To_String);
3905 The specifications of the referenced functions, as given in the Ada
3906 Reference Manual are:
3908 @smallexample @c ada
3909 function To_Unbounded_String (Source : String)
3910 return Unbounded_String;
3912 function To_String (Source : Unbounded_String)
3917 The effect is that if the value of an unbounded string is written to a
3918 stream, then the representation of the item in the stream is in the same
3919 format used for @code{Standard.String}, and this same representation is
3920 expected when a value of this type is read from the stream.
3922 @node Pragma Style_Checks
3923 @unnumberedsec Pragma Style_Checks
3924 @findex Style_Checks
3928 @smallexample @c ada
3929 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3930 On | Off [, LOCAL_NAME]);
3934 This pragma is used in conjunction with compiler switches to control the
3935 built in style checking provided by GNAT@. The compiler switches, if set,
3936 provide an initial setting for the switches, and this pragma may be used
3937 to modify these settings, or the settings may be provided entirely by
3938 the use of the pragma. This pragma can be used anywhere that a pragma
3939 is legal, including use as a configuration pragma (including use in
3940 the @file{gnat.adc} file).
3942 The form with a string literal specifies which style options are to be
3943 activated. These are additive, so they apply in addition to any previously
3944 set style check options. The codes for the options are the same as those
3945 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3946 For example the following two methods can be used to enable
3951 @smallexample @c ada
3952 pragma Style_Checks ("l");
3957 gcc -c -gnatyl @dots{}
3962 The form ALL_CHECKS activates all standard checks (its use is equivalent
3963 to the use of the @code{gnaty} switch with no options. See GNAT User's
3966 The forms with @code{Off} and @code{On}
3967 can be used to temporarily disable style checks
3968 as shown in the following example:
3970 @smallexample @c ada
3974 pragma Style_Checks ("k"); -- requires keywords in lower case
3975 pragma Style_Checks (Off); -- turn off style checks
3976 NULL; -- this will not generate an error message
3977 pragma Style_Checks (On); -- turn style checks back on
3978 NULL; -- this will generate an error message
3982 Finally the two argument form is allowed only if the first argument is
3983 @code{On} or @code{Off}. The effect is to turn of semantic style checks
3984 for the specified entity, as shown in the following example:
3986 @smallexample @c ada
3990 pragma Style_Checks ("r"); -- require consistency of identifier casing
3992 Rf1 : Integer := ARG; -- incorrect, wrong case
3993 pragma Style_Checks (Off, Arg);
3994 Rf2 : Integer := ARG; -- OK, no error
3997 @node Pragma Subtitle
3998 @unnumberedsec Pragma Subtitle
4003 @smallexample @c ada
4004 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4008 This pragma is recognized for compatibility with other Ada compilers
4009 but is ignored by GNAT@.
4011 @node Pragma Suppress
4012 @unnumberedsec Pragma Suppress
4017 @smallexample @c ada
4018 pragma Suppress (Identifier [, [On =>] Name]);
4022 This is a standard pragma, and supports all the check names required in
4023 the RM. It is included here because GNAT recognizes one additional check
4024 name: @code{Alignment_Check} which can be used to suppress alignment checks
4025 on addresses used in address clauses. Such checks can also be suppressed
4026 by suppressing range checks, but the specific use of @code{Alignment_Check}
4027 allows suppression of alignment checks without suppressing other range checks.
4029 @node Pragma Suppress_All
4030 @unnumberedsec Pragma Suppress_All
4031 @findex Suppress_All
4035 @smallexample @c ada
4036 pragma Suppress_All;
4040 This pragma can only appear immediately following a compilation
4041 unit. The effect is to apply @code{Suppress (All_Checks)} to the unit
4042 which it follows. This pragma is implemented for compatibility with DEC
4043 Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal
4044 configuration pragma is the preferred usage in GNAT@.
4046 @node Pragma Suppress_Exception_Locations
4047 @unnumberedsec Pragma Suppress_Exception_Locations
4048 @findex Suppress_Exception_Locations
4052 @smallexample @c ada
4053 pragma Suppress_Exception_Locations;
4057 In normal mode, a raise statement for an exception by default generates
4058 an exception message giving the file name and line number for the location
4059 of the raise. This is useful for debugging and logging purposes, but this
4060 entails extra space for the strings for the messages. The configuration
4061 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4062 generation of these strings, with the result that space is saved, but the
4063 exception message for such raises is null. This configuration pragma may
4064 appear in a global configuration pragma file, or in a specific unit as
4065 usual. It is not required that this pragma be used consistently within
4066 a partition, so it is fine to have some units within a partition compiled
4067 with this pragma and others compiled in normal mode without it.
4069 @node Pragma Suppress_Initialization
4070 @unnumberedsec Pragma Suppress_Initialization
4071 @findex Suppress_Initialization
4072 @cindex Suppressing initialization
4073 @cindex Initialization, suppression of
4077 @smallexample @c ada
4078 pragma Suppress_Initialization ([Entity =>] type_Name);
4082 This pragma suppresses any implicit or explicit initialization
4083 associated with the given type name for all variables of this type.
4085 @node Pragma Task_Info
4086 @unnumberedsec Pragma Task_Info
4091 @smallexample @c ada
4092 pragma Task_Info (EXPRESSION);
4096 This pragma appears within a task definition (like pragma
4097 @code{Priority}) and applies to the task in which it appears. The
4098 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4099 The @code{Task_Info} pragma provides system dependent control over
4100 aspects of tasking implementation, for example, the ability to map
4101 tasks to specific processors. For details on the facilities available
4102 for the version of GNAT that you are using, see the documentation
4103 in the specification of package System.Task_Info in the runtime
4106 @node Pragma Task_Name
4107 @unnumberedsec Pragma Task_Name
4112 @smallexample @c ada
4113 pragma Task_Name (string_EXPRESSION);
4117 This pragma appears within a task definition (like pragma
4118 @code{Priority}) and applies to the task in which it appears. The
4119 argument must be of type String, and provides a name to be used for
4120 the task instance when the task is created. Note that this expression
4121 is not required to be static, and in particular, it can contain
4122 references to task discriminants. This facility can be used to
4123 provide different names for different tasks as they are created,
4124 as illustrated in the example below.
4126 The task name is recorded internally in the run-time structures
4127 and is accessible to tools like the debugger. In addition the
4128 routine @code{Ada.Task_Identification.Image} will return this
4129 string, with a unique task address appended.
4131 @smallexample @c ada
4132 -- Example of the use of pragma Task_Name
4134 with Ada.Task_Identification;
4135 use Ada.Task_Identification;
4136 with Text_IO; use Text_IO;
4139 type Astring is access String;
4141 task type Task_Typ (Name : access String) is
4142 pragma Task_Name (Name.all);
4145 task body Task_Typ is
4146 Nam : constant String := Image (Current_Task);
4148 Put_Line ("-->" & Nam (1 .. 14) & "<--");
4151 type Ptr_Task is access Task_Typ;
4152 Task_Var : Ptr_Task;
4156 new Task_Typ (new String'("This is task 1"));
4158 new Task_Typ (new String'("This is task 2"));
4162 @node Pragma Task_Storage
4163 @unnumberedsec Pragma Task_Storage
4164 @findex Task_Storage
4167 @smallexample @c ada
4168 pragma Task_Storage (
4169 [Task_Type =>] LOCAL_NAME,
4170 [Top_Guard =>] static_integer_EXPRESSION);
4174 This pragma specifies the length of the guard area for tasks. The guard
4175 area is an additional storage area allocated to a task. A value of zero
4176 means that either no guard area is created or a minimal guard area is
4177 created, depending on the target. This pragma can appear anywhere a
4178 @code{Storage_Size} attribute definition clause is allowed for a task
4181 @node Pragma Time_Slice
4182 @unnumberedsec Pragma Time_Slice
4187 @smallexample @c ada
4188 pragma Time_Slice (static_duration_EXPRESSION);
4192 For implementations of GNAT on operating systems where it is possible
4193 to supply a time slice value, this pragma may be used for this purpose.
4194 It is ignored if it is used in a system that does not allow this control,
4195 or if it appears in other than the main program unit.
4197 Note that the effect of this pragma is identical to the effect of the
4198 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4201 @unnumberedsec Pragma Title
4206 @smallexample @c ada
4207 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4210 [Title =>] STRING_LITERAL,
4211 | [Subtitle =>] STRING_LITERAL
4215 Syntax checked but otherwise ignored by GNAT@. This is a listing control
4216 pragma used in DEC Ada 83 implementations to provide a title and/or
4217 subtitle for the program listing. The program listing generated by GNAT
4218 does not have titles or subtitles.
4220 Unlike other pragmas, the full flexibility of named notation is allowed
4221 for this pragma, i.e.@: the parameters may be given in any order if named
4222 notation is used, and named and positional notation can be mixed
4223 following the normal rules for procedure calls in Ada.
4225 @node Pragma Unchecked_Union
4226 @unnumberedsec Pragma Unchecked_Union
4228 @findex Unchecked_Union
4232 @smallexample @c ada
4233 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4237 This pragma is used to specify a representation of a record type that is
4238 equivalent to a C union. It was introduced as a GNAT implementation defined
4239 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4240 pragma, making it language defined, and GNAT fully implements this extended
4241 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4242 details, consult the Ada 2005 Reference Manual, section B.3.3.
4244 @node Pragma Unimplemented_Unit
4245 @unnumberedsec Pragma Unimplemented_Unit
4246 @findex Unimplemented_Unit
4250 @smallexample @c ada
4251 pragma Unimplemented_Unit;
4255 If this pragma occurs in a unit that is processed by the compiler, GNAT
4256 aborts with the message @samp{@var{xxx} not implemented}, where
4257 @var{xxx} is the name of the current compilation unit. This pragma is
4258 intended to allow the compiler to handle unimplemented library units in
4261 The abort only happens if code is being generated. Thus you can use
4262 specs of unimplemented packages in syntax or semantic checking mode.
4264 @node Pragma Universal_Aliasing
4265 @unnumberedsec Pragma Universal_Aliasing
4266 @findex Universal_Aliasing
4270 @smallexample @c ada
4271 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4275 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4276 declarative part. The effect is to inhibit strict type-based aliasing
4277 optimization for the given type. In other words, the effect is as though
4278 access types designating this type were subject to pragma No_Strict_Aliasing.
4279 For a detailed description of the strict aliasing optimization, and the
4280 situations in which it must be suppressed, see section
4281 ``Optimization and Strict Aliasing'' in the @value{EDITION} User's Guide.
4283 @node Pragma Universal_Data
4284 @unnumberedsec Pragma Universal_Data
4285 @findex Universal_Data
4289 @smallexample @c ada
4290 pragma Universal_Data [(library_unit_Name)];
4294 This pragma is supported only for the AAMP target and is ignored for
4295 other targets. The pragma specifies that all library-level objects
4296 (Counter 0 data) associated with the library unit are to be accessed
4297 and updated using universal addressing (24-bit addresses for AAMP5)
4298 rather than the default of 16-bit Data Environment (DENV) addressing.
4299 Use of this pragma will generally result in less efficient code for
4300 references to global data associated with the library unit, but
4301 allows such data to be located anywhere in memory. This pragma is
4302 a library unit pragma, but can also be used as a configuration pragma
4303 (including use in the @file{gnat.adc} file). The functionality
4304 of this pragma is also available by applying the -univ switch on the
4305 compilations of units where universal addressing of the data is desired.
4307 @node Pragma Unreferenced
4308 @unnumberedsec Pragma Unreferenced
4309 @findex Unreferenced
4310 @cindex Warnings, unreferenced
4314 @smallexample @c ada
4315 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4316 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4320 This pragma signals that the entities whose names are listed are
4321 deliberately not referenced in the current source unit. This
4322 suppresses warnings about the
4323 entities being unreferenced, and in addition a warning will be
4324 generated if one of these entities is in fact referenced in the
4325 same unit as the pragma (or in the corresponding body, or one
4328 This is particularly useful for clearly signaling that a particular
4329 parameter is not referenced in some particular subprogram implementation
4330 and that this is deliberate. It can also be useful in the case of
4331 objects declared only for their initialization or finalization side
4334 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4335 current scope, then the entity most recently declared is the one to which
4336 the pragma applies. Note that in the case of accept formals, the pragma
4337 Unreferenced may appear immediately after the keyword @code{do} which
4338 allows the indication of whether or not accept formals are referenced
4339 or not to be given individually for each accept statement.
4341 The left hand side of an assignment does not count as a reference for the
4342 purpose of this pragma. Thus it is fine to assign to an entity for which
4343 pragma Unreferenced is given.
4345 Note that if a warning is desired for all calls to a given subprogram,
4346 regardless of whether they occur in the same unit as the subprogram
4347 declaration, then this pragma should not be used (calls from another
4348 unit would not be flagged); pragma Obsolescent can be used instead
4349 for this purpose, see @xref{Pragma Obsolescent}.
4351 The second form of pragma @code{Unreferenced} is used within a context
4352 clause. In this case the arguments must be unit names of units previously
4353 mentioned in @code{with} clauses (similar to the usage of pragma
4354 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4355 units and unreferenced entities within these units.
4357 @node Pragma Unreferenced_Objects
4358 @unnumberedsec Pragma Unreferenced_Objects
4359 @findex Unreferenced_Objects
4360 @cindex Warnings, unreferenced
4364 @smallexample @c ada
4365 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4369 This pragma signals that for the types or subtypes whose names are
4370 listed, objects which are declared with one of these types or subtypes may
4371 not be referenced, and if no references appear, no warnings are given.
4373 This is particularly useful for objects which are declared solely for their
4374 initialization and finalization effect. Such variables are sometimes referred
4375 to as RAII variables (Resource Acquisition Is Initialization). Using this
4376 pragma on the relevant type (most typically a limited controlled type), the
4377 compiler will automatically suppress unwanted warnings about these variables
4378 not being referenced.
4380 @node Pragma Unreserve_All_Interrupts
4381 @unnumberedsec Pragma Unreserve_All_Interrupts
4382 @findex Unreserve_All_Interrupts
4386 @smallexample @c ada
4387 pragma Unreserve_All_Interrupts;
4391 Normally certain interrupts are reserved to the implementation. Any attempt
4392 to attach an interrupt causes Program_Error to be raised, as described in
4393 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
4394 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
4395 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4396 interrupt execution.
4398 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4399 a program, then all such interrupts are unreserved. This allows the
4400 program to handle these interrupts, but disables their standard
4401 functions. For example, if this pragma is used, then pressing
4402 @kbd{Ctrl-C} will not automatically interrupt execution. However,
4403 a program can then handle the @code{SIGINT} interrupt as it chooses.
4405 For a full list of the interrupts handled in a specific implementation,
4406 see the source code for the specification of @code{Ada.Interrupts.Names} in
4407 file @file{a-intnam.ads}. This is a target dependent file that contains the
4408 list of interrupts recognized for a given target. The documentation in
4409 this file also specifies what interrupts are affected by the use of
4410 the @code{Unreserve_All_Interrupts} pragma.
4412 For a more general facility for controlling what interrupts can be
4413 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4414 of the @code{Unreserve_All_Interrupts} pragma.
4416 @node Pragma Unsuppress
4417 @unnumberedsec Pragma Unsuppress
4422 @smallexample @c ada
4423 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4427 This pragma undoes the effect of a previous pragma @code{Suppress}. If
4428 there is no corresponding pragma @code{Suppress} in effect, it has no
4429 effect. The range of the effect is the same as for pragma
4430 @code{Suppress}. The meaning of the arguments is identical to that used
4431 in pragma @code{Suppress}.
4433 One important application is to ensure that checks are on in cases where
4434 code depends on the checks for its correct functioning, so that the code
4435 will compile correctly even if the compiler switches are set to suppress
4438 @node Pragma Use_VADS_Size
4439 @unnumberedsec Pragma Use_VADS_Size
4440 @cindex @code{Size}, VADS compatibility
4441 @findex Use_VADS_Size
4445 @smallexample @c ada
4446 pragma Use_VADS_Size;
4450 This is a configuration pragma. In a unit to which it applies, any use
4451 of the 'Size attribute is automatically interpreted as a use of the
4452 'VADS_Size attribute. Note that this may result in incorrect semantic
4453 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
4454 the handling of existing code which depends on the interpretation of Size
4455 as implemented in the VADS compiler. See description of the VADS_Size
4456 attribute for further details.
4458 @node Pragma Validity_Checks
4459 @unnumberedsec Pragma Validity_Checks
4460 @findex Validity_Checks
4464 @smallexample @c ada
4465 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4469 This pragma is used in conjunction with compiler switches to control the
4470 built-in validity checking provided by GNAT@. The compiler switches, if set
4471 provide an initial setting for the switches, and this pragma may be used
4472 to modify these settings, or the settings may be provided entirely by
4473 the use of the pragma. This pragma can be used anywhere that a pragma
4474 is legal, including use as a configuration pragma (including use in
4475 the @file{gnat.adc} file).
4477 The form with a string literal specifies which validity options are to be
4478 activated. The validity checks are first set to include only the default
4479 reference manual settings, and then a string of letters in the string
4480 specifies the exact set of options required. The form of this string
4481 is exactly as described for the @code{-gnatVx} compiler switch (see the
4482 GNAT users guide for details). For example the following two methods
4483 can be used to enable validity checking for mode @code{in} and
4484 @code{in out} subprogram parameters:
4488 @smallexample @c ada
4489 pragma Validity_Checks ("im");
4494 gcc -c -gnatVim @dots{}
4499 The form ALL_CHECKS activates all standard checks (its use is equivalent
4500 to the use of the @code{gnatva} switch.
4502 The forms with @code{Off} and @code{On}
4503 can be used to temporarily disable validity checks
4504 as shown in the following example:
4506 @smallexample @c ada
4510 pragma Validity_Checks ("c"); -- validity checks for copies
4511 pragma Validity_Checks (Off); -- turn off validity checks
4512 A := B; -- B will not be validity checked
4513 pragma Validity_Checks (On); -- turn validity checks back on
4514 A := C; -- C will be validity checked
4517 @node Pragma Volatile
4518 @unnumberedsec Pragma Volatile
4523 @smallexample @c ada
4524 pragma Volatile (LOCAL_NAME);
4528 This pragma is defined by the Ada Reference Manual, and the GNAT
4529 implementation is fully conformant with this definition. The reason it
4530 is mentioned in this section is that a pragma of the same name was supplied
4531 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
4532 implementation of pragma Volatile is upwards compatible with the
4533 implementation in DEC Ada 83.
4535 @node Pragma Warnings
4536 @unnumberedsec Pragma Warnings
4541 @smallexample @c ada
4542 pragma Warnings (On | Off);
4543 pragma Warnings (On | Off, LOCAL_NAME);
4544 pragma Warnings (static_string_EXPRESSION);
4545 pragma Warnings (On | Off, static_string_EXPRESSION);
4549 Normally warnings are enabled, with the output being controlled by
4550 the command line switch. Warnings (@code{Off}) turns off generation of
4551 warnings until a Warnings (@code{On}) is encountered or the end of the
4552 current unit. If generation of warnings is turned off using this
4553 pragma, then no warning messages are output, regardless of the
4554 setting of the command line switches.
4556 The form with a single argument may be used as a configuration pragma.
4558 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
4559 the specified entity. This suppression is effective from the point where
4560 it occurs till the end of the extended scope of the variable (similar to
4561 the scope of @code{Suppress}).
4563 The form with a single static_string_EXPRESSION argument provides more precise
4564 control over which warnings are active. The string is a list of letters
4565 specifying which warnings are to be activated and which deactivated. The
4566 code for these letters is the same as the string used in the command
4567 line switch controlling warnings. The following is a brief summary. For
4568 full details see the GNAT Users Guide:
4571 a turn on all optional warnings (except d,h,l)
4572 A turn off all optional warnings
4573 b turn on warnings for bad fixed value (not multiple of small)
4574 B turn off warnings for bad fixed value (not multiple of small)
4575 c turn on warnings for constant conditional
4576 C turn off warnings for constant conditional
4577 d turn on warnings for implicit dereference
4578 D turn off warnings for implicit dereference
4579 e treat all warnings as errors
4580 f turn on warnings for unreferenced formal
4581 F turn off warnings for unreferenced formal
4582 g turn on warnings for unrecognized pragma
4583 G turn off warnings for unrecognized pragma
4584 h turn on warnings for hiding variable
4585 H turn off warnings for hiding variable
4586 i turn on warnings for implementation unit
4587 I turn off warnings for implementation unit
4588 j turn on warnings for obsolescent (annex J) feature
4589 J turn off warnings for obsolescent (annex J) feature
4590 k turn on warnings on constant variable
4591 K turn off warnings on constant variable
4592 l turn on warnings for missing elaboration pragma
4593 L turn off warnings for missing elaboration pragma
4594 m turn on warnings for variable assigned but not read
4595 M turn off warnings for variable assigned but not read
4596 n normal warning mode (cancels -gnatws/-gnatwe)
4597 o turn on warnings for address clause overlay
4598 O turn off warnings for address clause overlay
4599 p turn on warnings for ineffective pragma Inline
4600 P turn off warnings for ineffective pragma Inline
4601 q turn on warnings for questionable missing parentheses
4602 Q turn off warnings for questionable missing parentheses
4603 r turn on warnings for redundant construct
4604 R turn off warnings for redundant construct
4605 s suppress all warnings
4606 t turn on warnings for tracking deleted code
4607 T turn off warnings for tracking deleted code
4608 u turn on warnings for unused entity
4609 U turn off warnings for unused entity
4610 v turn on warnings for unassigned variable
4611 V turn off warnings for unassigned variable
4612 w turn on warnings for wrong low bound assumption
4613 W turn off warnings for wrong low bound assumption
4614 x turn on warnings for export/import
4615 X turn off warnings for export/import
4616 y turn on warnings for Ada 2005 incompatibility
4617 Y turn off warnings for Ada 2005 incompatibility
4618 z turn on size/align warnings for unchecked conversion
4619 Z turn off size/align warnings for unchecked conversion
4623 The specified warnings will be in effect until the end of the program
4624 or another pragma Warnings is encountered. The effect of the pragma is
4625 cumulative. Initially the set of warnings is the standard default set
4626 as possibly modified by compiler switches. Then each pragma Warning
4627 modifies this set of warnings as specified. This form of the pragma may
4628 also be used as a configuration pragma.
4630 The fourth form, with an On|Off parameter and a string, is used to
4631 control individual messages, based on their text. The string argument
4632 is a pattern that is used to match against the text of individual
4633 warning messages (not including the initial "warnings: " tag).
4635 The pattern may start with an asterisk, which matches otherwise unmatched
4636 characters at the start of the message, and it may also end with an asterisk
4637 which matches otherwise unmatched characters at the end of the message. For
4638 example, the string "*alignment*" could be used to match any warnings about
4639 alignment problems. Within the string, the sequence "*" can be used to match
4640 any sequence of characters enclosed in quotation marks. No other regular
4641 expression notations are permitted. All characters other than asterisk in
4642 these three specific cases are treated as literal characters in the match.
4644 There are two ways to use this pragma. The OFF form can be used as a
4645 configuration pragma. The effect is to suppress all warnings (if any)
4646 that match the pattern string throughout the compilation.
4648 The second usage is to suppress a warning locally, and in this case, two
4649 pragmas must appear in sequence:
4651 @smallexample @c ada
4652 pragma Warnings (Off, Pattern);
4653 .. code where given warning is to be suppressed
4654 pragma Warnings (On, Pattern);
4658 In this usage, the pattern string must match in the Off and On pragmas,
4659 and at least one matching warning must be suppressed.
4661 @node Pragma Weak_External
4662 @unnumberedsec Pragma Weak_External
4663 @findex Weak_External
4667 @smallexample @c ada
4668 pragma Weak_External ([Entity =>] LOCAL_NAME);
4672 @var{LOCAL_NAME} must refer to an object that is declared at the library
4673 level. This pragma specifies that the given entity should be marked as a
4674 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
4675 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
4676 of a regular symbol, that is to say a symbol that does not have to be
4677 resolved by the linker if used in conjunction with a pragma Import.
4679 When a weak symbol is not resolved by the linker, its address is set to
4680 zero. This is useful in writing interfaces to external modules that may
4681 or may not be linked in the final executable, for example depending on
4682 configuration settings.
4684 If a program references at run time an entity to which this pragma has been
4685 applied, and the corresponding symbol was not resolved at link time, then
4686 the execution of the program is erroneous. It is not erroneous to take the
4687 Address of such an entity, for example to guard potential references,
4688 as shown in the example below.
4690 Some file formats do not support weak symbols so not all target machines
4691 support this pragma.
4693 @smallexample @c ada
4694 -- Example of the use of pragma Weak_External
4696 package External_Module is
4698 pragma Import (C, key);
4699 pragma Weak_External (key);
4700 function Present return boolean;
4701 end External_Module;
4703 with System; use System;
4704 package body External_Module is
4705 function Present return boolean is
4707 return key'Address /= System.Null_Address;
4709 end External_Module;
4712 @node Pragma Wide_Character_Encoding
4713 @unnumberedsec Pragma Wide_Character_Encoding
4714 @findex Wide_Character_Encoding
4718 @smallexample @c ada
4719 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
4723 This pragma specifies the wide character encoding to be used in program
4724 source text appearing subsequently. It is a configuration pragma, but may
4725 also be used at any point that a pragma is allowed, and it is permissible
4726 to have more than one such pragma in a file, allowing multiple encodings
4727 to appear within the same file.
4729 The argument can be an identifier or a character literal. In the identifier
4730 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
4731 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
4732 case it is correspondingly one of the characters h,u,s,e,8,b.
4734 Note that when the pragma is used within a file, it affects only the
4735 encoding within that file, and does not affect withed units, specs,
4738 @node Implementation Defined Attributes
4739 @chapter Implementation Defined Attributes
4740 Ada defines (throughout the Ada reference manual,
4741 summarized in Annex K),
4742 a set of attributes that provide useful additional functionality in all
4743 areas of the language. These language defined attributes are implemented
4744 in GNAT and work as described in the Ada Reference Manual.
4746 In addition, Ada allows implementations to define additional
4747 attributes whose meaning is defined by the implementation. GNAT provides
4748 a number of these implementation-dependent attributes which can be used
4749 to extend and enhance the functionality of the compiler. This section of
4750 the GNAT reference manual describes these additional attributes.
4752 Note that any program using these attributes may not be portable to
4753 other compilers (although GNAT implements this set of attributes on all
4754 platforms). Therefore if portability to other compilers is an important
4755 consideration, you should minimize the use of these attributes.
4766 * Default_Bit_Order::
4775 * Has_Access_Values::
4776 * Has_Discriminants::
4782 * Max_Interrupt_Priority::
4784 * Maximum_Alignment::
4788 * Passed_By_Reference::
4801 * Unconstrained_Array::
4802 * Universal_Literal_String::
4803 * Unrestricted_Access::
4811 @unnumberedsec Abort_Signal
4812 @findex Abort_Signal
4814 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4815 prefix) provides the entity for the special exception used to signal
4816 task abort or asynchronous transfer of control. Normally this attribute
4817 should only be used in the tasking runtime (it is highly peculiar, and
4818 completely outside the normal semantics of Ada, for a user program to
4819 intercept the abort exception).
4822 @unnumberedsec Address_Size
4823 @cindex Size of @code{Address}
4824 @findex Address_Size
4826 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4827 prefix) is a static constant giving the number of bits in an
4828 @code{Address}. It is the same value as System.Address'Size,
4829 but has the advantage of being static, while a direct
4830 reference to System.Address'Size is non-static because Address
4834 @unnumberedsec Asm_Input
4837 The @code{Asm_Input} attribute denotes a function that takes two
4838 parameters. The first is a string, the second is an expression of the
4839 type designated by the prefix. The first (string) argument is required
4840 to be a static expression, and is the constraint for the parameter,
4841 (e.g.@: what kind of register is required). The second argument is the
4842 value to be used as the input argument. The possible values for the
4843 constant are the same as those used in the RTL, and are dependent on
4844 the configuration file used to built the GCC back end.
4845 @ref{Machine Code Insertions}
4848 @unnumberedsec Asm_Output
4851 The @code{Asm_Output} attribute denotes a function that takes two
4852 parameters. The first is a string, the second is the name of a variable
4853 of the type designated by the attribute prefix. The first (string)
4854 argument is required to be a static expression and designates the
4855 constraint for the parameter (e.g.@: what kind of register is
4856 required). The second argument is the variable to be updated with the
4857 result. The possible values for constraint are the same as those used in
4858 the RTL, and are dependent on the configuration file used to build the
4859 GCC back end. If there are no output operands, then this argument may
4860 either be omitted, or explicitly given as @code{No_Output_Operands}.
4861 @ref{Machine Code Insertions}
4864 @unnumberedsec AST_Entry
4868 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
4869 the name of an entry, it yields a value of the predefined type AST_Handler
4870 (declared in the predefined package System, as extended by the use of
4871 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
4872 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
4873 Language Reference Manual}, section 9.12a.
4878 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4879 offset within the storage unit (byte) that contains the first bit of
4880 storage allocated for the object. The value of this attribute is of the
4881 type @code{Universal_Integer}, and is always a non-negative number not
4882 exceeding the value of @code{System.Storage_Unit}.
4884 For an object that is a variable or a constant allocated in a register,
4885 the value is zero. (The use of this attribute does not force the
4886 allocation of a variable to memory).
4888 For an object that is a formal parameter, this attribute applies
4889 to either the matching actual parameter or to a copy of the
4890 matching actual parameter.
4892 For an access object the value is zero. Note that
4893 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4894 designated object. Similarly for a record component
4895 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4896 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4897 are subject to index checks.
4899 This attribute is designed to be compatible with the DEC Ada 83 definition
4900 and implementation of the @code{Bit} attribute.
4903 @unnumberedsec Bit_Position
4904 @findex Bit_Position
4906 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4907 of the fields of the record type, yields the bit
4908 offset within the record contains the first bit of
4909 storage allocated for the object. The value of this attribute is of the
4910 type @code{Universal_Integer}. The value depends only on the field
4911 @var{C} and is independent of the alignment of
4912 the containing record @var{R}.
4915 @unnumberedsec Code_Address
4916 @findex Code_Address
4917 @cindex Subprogram address
4918 @cindex Address of subprogram code
4921 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
4922 intended effect seems to be to provide
4923 an address value which can be used to call the subprogram by means of
4924 an address clause as in the following example:
4926 @smallexample @c ada
4927 procedure K is @dots{}
4930 for L'Address use K'Address;
4931 pragma Import (Ada, L);
4935 A call to @code{L} is then expected to result in a call to @code{K}@.
4936 In Ada 83, where there were no access-to-subprogram values, this was
4937 a common work-around for getting the effect of an indirect call.
4938 GNAT implements the above use of @code{Address} and the technique
4939 illustrated by the example code works correctly.
4941 However, for some purposes, it is useful to have the address of the start
4942 of the generated code for the subprogram. On some architectures, this is
4943 not necessarily the same as the @code{Address} value described above.
4944 For example, the @code{Address} value may reference a subprogram
4945 descriptor rather than the subprogram itself.
4947 The @code{'Code_Address} attribute, which can only be applied to
4948 subprogram entities, always returns the address of the start of the
4949 generated code of the specified subprogram, which may or may not be
4950 the same value as is returned by the corresponding @code{'Address}
4953 @node Default_Bit_Order
4954 @unnumberedsec Default_Bit_Order
4956 @cindex Little endian
4957 @findex Default_Bit_Order
4959 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4960 permissible prefix), provides the value @code{System.Default_Bit_Order}
4961 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4962 @code{Low_Order_First}). This is used to construct the definition of
4963 @code{Default_Bit_Order} in package @code{System}.
4966 @unnumberedsec Elaborated
4969 The prefix of the @code{'Elaborated} attribute must be a unit name. The
4970 value is a Boolean which indicates whether or not the given unit has been
4971 elaborated. This attribute is primarily intended for internal use by the
4972 generated code for dynamic elaboration checking, but it can also be used
4973 in user programs. The value will always be True once elaboration of all
4974 units has been completed. An exception is for units which need no
4975 elaboration, the value is always False for such units.
4978 @unnumberedsec Elab_Body
4981 This attribute can only be applied to a program unit name. It returns
4982 the entity for the corresponding elaboration procedure for elaborating
4983 the body of the referenced unit. This is used in the main generated
4984 elaboration procedure by the binder and is not normally used in any
4985 other context. However, there may be specialized situations in which it
4986 is useful to be able to call this elaboration procedure from Ada code,
4987 e.g.@: if it is necessary to do selective re-elaboration to fix some
4991 @unnumberedsec Elab_Spec
4994 This attribute can only be applied to a program unit name. It returns
4995 the entity for the corresponding elaboration procedure for elaborating
4996 the specification of the referenced unit. This is used in the main
4997 generated elaboration procedure by the binder and is not normally used
4998 in any other context. However, there may be specialized situations in
4999 which it is useful to be able to call this elaboration procedure from
5000 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5005 @cindex Ada 83 attributes
5008 The @code{Emax} attribute is provided for compatibility with Ada 83. See
5009 the Ada 83 reference manual for an exact description of the semantics of
5013 @unnumberedsec Enabled
5016 The @code{Enabled} attribute allows an application program to check at compile
5017 time to see if the designated check is currently enabled. The prefix is a
5018 simple identifier, referencing any predefined check name (other than
5019 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5020 no argument is given for the attribute, the check is for the general state
5021 of the check, if an argument is given, then it is an entity name, and the
5022 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5023 given naming the entity (if not, then the argument is ignored).
5025 Note that instantiations inherit the check status at the point of the
5026 instantiation, so a useful idiom is to have a library package that
5027 introduces a check name with @code{pragma Check_Name}, and then contains
5028 generic packages or subprograms which use the @code{Enabled} attribute
5029 to see if the check is enabled. A user of this package can then issue
5030 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5031 the package or subprogram, controlling whether the check will be present.
5034 @unnumberedsec Enum_Rep
5035 @cindex Representation of enums
5038 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5039 function with the following spec:
5041 @smallexample @c ada
5042 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5043 return @i{Universal_Integer};
5047 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5048 enumeration type or to a non-overloaded enumeration
5049 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
5050 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5051 enumeration literal or object.
5053 The function returns the representation value for the given enumeration
5054 value. This will be equal to value of the @code{Pos} attribute in the
5055 absence of an enumeration representation clause. This is a static
5056 attribute (i.e.@: the result is static if the argument is static).
5058 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5059 in which case it simply returns the integer value. The reason for this
5060 is to allow it to be used for @code{(<>)} discrete formal arguments in
5061 a generic unit that can be instantiated with either enumeration types
5062 or integer types. Note that if @code{Enum_Rep} is used on a modular
5063 type whose upper bound exceeds the upper bound of the largest signed
5064 integer type, and the argument is a variable, so that the universal
5065 integer calculation is done at run time, then the call to @code{Enum_Rep}
5066 may raise @code{Constraint_Error}.
5069 @unnumberedsec Epsilon
5070 @cindex Ada 83 attributes
5073 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
5074 the Ada 83 reference manual for an exact description of the semantics of
5078 @unnumberedsec Fixed_Value
5081 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5082 function with the following specification:
5084 @smallexample @c ada
5085 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5090 The value returned is the fixed-point value @var{V} such that
5092 @smallexample @c ada
5093 @var{V} = Arg * @var{S}'Small
5097 The effect is thus similar to first converting the argument to the
5098 integer type used to represent @var{S}, and then doing an unchecked
5099 conversion to the fixed-point type. The difference is
5100 that there are full range checks, to ensure that the result is in range.
5101 This attribute is primarily intended for use in implementation of the
5102 input-output functions for fixed-point values.
5104 @node Has_Access_Values
5105 @unnumberedsec Has_Access_Values
5106 @cindex Access values, testing for
5107 @findex Has_Access_Values
5109 The prefix of the @code{Has_Access_Values} attribute is a type. The result
5110 is a Boolean value which is True if the is an access type, or is a composite
5111 type with a component (at any nesting depth) that is an access type, and is
5113 The intended use of this attribute is in conjunction with generic
5114 definitions. If the attribute is applied to a generic private type, it
5115 indicates whether or not the corresponding actual type has access values.
5117 @node Has_Discriminants
5118 @unnumberedsec Has_Discriminants
5119 @cindex Discriminants, testing for
5120 @findex Has_Discriminants
5122 The prefix of the @code{Has_Discriminants} attribute is a type. The result
5123 is a Boolean value which is True if the type has discriminants, and False
5124 otherwise. The intended use of this attribute is in conjunction with generic
5125 definitions. If the attribute is applied to a generic private type, it
5126 indicates whether or not the corresponding actual type has discriminants.
5132 The @code{Img} attribute differs from @code{Image} in that it may be
5133 applied to objects as well as types, in which case it gives the
5134 @code{Image} for the subtype of the object. This is convenient for
5137 @smallexample @c ada
5138 Put_Line ("X = " & X'Img);
5142 has the same meaning as the more verbose:
5144 @smallexample @c ada
5145 Put_Line ("X = " & @var{T}'Image (X));
5149 where @var{T} is the (sub)type of the object @code{X}.
5152 @unnumberedsec Integer_Value
5153 @findex Integer_Value
5155 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5156 function with the following spec:
5158 @smallexample @c ada
5159 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5164 The value returned is the integer value @var{V}, such that
5166 @smallexample @c ada
5167 Arg = @var{V} * @var{T}'Small
5171 where @var{T} is the type of @code{Arg}.
5172 The effect is thus similar to first doing an unchecked conversion from
5173 the fixed-point type to its corresponding implementation type, and then
5174 converting the result to the target integer type. The difference is
5175 that there are full range checks, to ensure that the result is in range.
5176 This attribute is primarily intended for use in implementation of the
5177 standard input-output functions for fixed-point values.
5180 @unnumberedsec Large
5181 @cindex Ada 83 attributes
5184 The @code{Large} attribute is provided for compatibility with Ada 83. See
5185 the Ada 83 reference manual for an exact description of the semantics of
5189 @unnumberedsec Machine_Size
5190 @findex Machine_Size
5192 This attribute is identical to the @code{Object_Size} attribute. It is
5193 provided for compatibility with the DEC Ada 83 attribute of this name.
5196 @unnumberedsec Mantissa
5197 @cindex Ada 83 attributes
5200 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
5201 the Ada 83 reference manual for an exact description of the semantics of
5204 @node Max_Interrupt_Priority
5205 @unnumberedsec Max_Interrupt_Priority
5206 @cindex Interrupt priority, maximum
5207 @findex Max_Interrupt_Priority
5209 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5210 permissible prefix), provides the same value as
5211 @code{System.Max_Interrupt_Priority}.
5214 @unnumberedsec Max_Priority
5215 @cindex Priority, maximum
5216 @findex Max_Priority
5218 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5219 prefix) provides the same value as @code{System.Max_Priority}.
5221 @node Maximum_Alignment
5222 @unnumberedsec Maximum_Alignment
5223 @cindex Alignment, maximum
5224 @findex Maximum_Alignment
5226 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5227 permissible prefix) provides the maximum useful alignment value for the
5228 target. This is a static value that can be used to specify the alignment
5229 for an object, guaranteeing that it is properly aligned in all
5232 @node Mechanism_Code
5233 @unnumberedsec Mechanism_Code
5234 @cindex Return values, passing mechanism
5235 @cindex Parameters, passing mechanism
5236 @findex Mechanism_Code
5238 @code{@var{function}'Mechanism_Code} yields an integer code for the
5239 mechanism used for the result of function, and
5240 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5241 used for formal parameter number @var{n} (a static integer value with 1
5242 meaning the first parameter) of @var{subprogram}. The code returned is:
5250 by descriptor (default descriptor class)
5252 by descriptor (UBS: unaligned bit string)
5254 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5256 by descriptor (UBA: unaligned bit array)
5258 by descriptor (S: string, also scalar access type parameter)
5260 by descriptor (SB: string with arbitrary bounds)
5262 by descriptor (A: contiguous array)
5264 by descriptor (NCA: non-contiguous array)
5268 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5271 @node Null_Parameter
5272 @unnumberedsec Null_Parameter
5273 @cindex Zero address, passing
5274 @findex Null_Parameter
5276 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5277 type or subtype @var{T} allocated at machine address zero. The attribute
5278 is allowed only as the default expression of a formal parameter, or as
5279 an actual expression of a subprogram call. In either case, the
5280 subprogram must be imported.
5282 The identity of the object is represented by the address zero in the
5283 argument list, independent of the passing mechanism (explicit or
5286 This capability is needed to specify that a zero address should be
5287 passed for a record or other composite object passed by reference.
5288 There is no way of indicating this without the @code{Null_Parameter}
5292 @unnumberedsec Object_Size
5293 @cindex Size, used for objects
5296 The size of an object is not necessarily the same as the size of the type
5297 of an object. This is because by default object sizes are increased to be
5298 a multiple of the alignment of the object. For example,
5299 @code{Natural'Size} is
5300 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5301 Similarly, a record containing an integer and a character:
5303 @smallexample @c ada
5311 will have a size of 40 (that is @code{Rec'Size} will be 40. The
5312 alignment will be 4, because of the
5313 integer field, and so the default size of record objects for this type
5314 will be 64 (8 bytes).
5316 The @code{@var{type}'Object_Size} attribute
5317 has been added to GNAT to allow the
5318 default object size of a type to be easily determined. For example,
5319 @code{Natural'Object_Size} is 32, and
5320 @code{Rec'Object_Size} (for the record type in the above example) will be
5321 64. Note also that, unlike the situation with the
5322 @code{Size} attribute as defined in the Ada RM, the
5323 @code{Object_Size} attribute can be specified individually
5324 for different subtypes. For example:
5326 @smallexample @c ada
5327 type R is new Integer;
5328 subtype R1 is R range 1 .. 10;
5329 subtype R2 is R range 1 .. 10;
5330 for R2'Object_Size use 8;
5334 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
5335 32 since the default object size for a subtype is the same as the object size
5336 for the parent subtype. This means that objects of type @code{R}
5338 by default be 32 bits (four bytes). But objects of type
5339 @code{R2} will be only
5340 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
5342 Although @code{Object_Size} does properly reflect the default object size
5343 value, it is not necessarily the case that all objects will be of this size
5344 in a case where it is not specified explicitly. The compiler is free to
5345 increase the size and alignment of stand alone objects to improve efficiency
5346 of the generated code and sometimes does so in the case of large composite
5347 objects. If the size of a stand alone object is critical to the
5348 application, it should be specified explicitly.
5350 @node Passed_By_Reference
5351 @unnumberedsec Passed_By_Reference
5352 @cindex Parameters, when passed by reference
5353 @findex Passed_By_Reference
5355 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5356 a value of type @code{Boolean} value that is @code{True} if the type is
5357 normally passed by reference and @code{False} if the type is normally
5358 passed by copy in calls. For scalar types, the result is always @code{False}
5359 and is static. For non-scalar types, the result is non-static.
5362 @unnumberedsec Pool_Address
5363 @cindex Parameters, when passed by reference
5364 @findex Pool_Address
5366 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
5367 of X within its storage pool. This is the same as
5368 @code{@var{X}'Address}, except that for an unconstrained array whose
5369 bounds are allocated just before the first component,
5370 @code{@var{X}'Pool_Address} returns the address of those bounds,
5371 whereas @code{@var{X}'Address} returns the address of the first
5374 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
5375 the object is allocated'', which could be a user-defined storage pool,
5376 the global heap, on the stack, or in a static memory area. For an
5377 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
5378 what is passed to @code{Allocate} and returned from @code{Deallocate}.
5381 @unnumberedsec Range_Length
5382 @findex Range_Length
5384 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5385 the number of values represented by the subtype (zero for a null
5386 range). The result is static for static subtypes. @code{Range_Length}
5387 applied to the index subtype of a one dimensional array always gives the
5388 same result as @code{Range} applied to the array itself.
5391 @unnumberedsec Safe_Emax
5392 @cindex Ada 83 attributes
5395 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
5396 the Ada 83 reference manual for an exact description of the semantics of
5400 @unnumberedsec Safe_Large
5401 @cindex Ada 83 attributes
5404 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
5405 the Ada 83 reference manual for an exact description of the semantics of
5409 @unnumberedsec Small
5410 @cindex Ada 83 attributes
5413 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
5415 GNAT also allows this attribute to be applied to floating-point types
5416 for compatibility with Ada 83. See
5417 the Ada 83 reference manual for an exact description of the semantics of
5418 this attribute when applied to floating-point types.
5421 @unnumberedsec Storage_Unit
5422 @findex Storage_Unit
5424 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
5425 prefix) provides the same value as @code{System.Storage_Unit}.
5428 @unnumberedsec Stub_Type
5431 The GNAT implementation of remote access-to-classwide types is
5432 organized as described in AARM section E.4 (20.t): a value of an RACW type
5433 (designating a remote object) is represented as a normal access
5434 value, pointing to a "stub" object which in turn contains the
5435 necessary information to contact the designated remote object. A
5436 call on any dispatching operation of such a stub object does the
5437 remote call, if necessary, using the information in the stub object
5438 to locate the target partition, etc.
5440 For a prefix @code{T} that denotes a remote access-to-classwide type,
5441 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
5443 By construction, the layout of @code{T'Stub_Type} is identical to that of
5444 type @code{RACW_Stub_Type} declared in the internal implementation-defined
5445 unit @code{System.Partition_Interface}. Use of this attribute will create
5446 an implicit dependency on this unit.
5449 @unnumberedsec Target_Name
5452 @code{Standard'Target_Name} (@code{Standard} is the only permissible
5453 prefix) provides a static string value that identifies the target
5454 for the current compilation. For GCC implementations, this is the
5455 standard gcc target name without the terminating slash (for
5456 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
5462 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
5463 provides the same value as @code{System.Tick},
5466 @unnumberedsec To_Address
5469 The @code{System'To_Address}
5470 (@code{System} is the only permissible prefix)
5471 denotes a function identical to
5472 @code{System.Storage_Elements.To_Address} except that
5473 it is a static attribute. This means that if its argument is
5474 a static expression, then the result of the attribute is a
5475 static expression. The result is that such an expression can be
5476 used in contexts (e.g.@: preelaborable packages) which require a
5477 static expression and where the function call could not be used
5478 (since the function call is always non-static, even if its
5479 argument is static).
5482 @unnumberedsec Type_Class
5485 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
5486 the value of the type class for the full type of @var{type}. If
5487 @var{type} is a generic formal type, the value is the value for the
5488 corresponding actual subtype. The value of this attribute is of type
5489 @code{System.Aux_DEC.Type_Class}, which has the following definition:
5491 @smallexample @c ada
5493 (Type_Class_Enumeration,
5495 Type_Class_Fixed_Point,
5496 Type_Class_Floating_Point,
5501 Type_Class_Address);
5505 Protected types yield the value @code{Type_Class_Task}, which thus
5506 applies to all concurrent types. This attribute is designed to
5507 be compatible with the DEC Ada 83 attribute of the same name.
5510 @unnumberedsec UET_Address
5513 The @code{UET_Address} attribute can only be used for a prefix which
5514 denotes a library package. It yields the address of the unit exception
5515 table when zero cost exception handling is used. This attribute is
5516 intended only for use within the GNAT implementation. See the unit
5517 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
5518 for details on how this attribute is used in the implementation.
5520 @node Unconstrained_Array
5521 @unnumberedsec Unconstrained_Array
5522 @findex Unconstrained_Array
5524 The @code{Unconstrained_Array} attribute can be used with a prefix that
5525 denotes any type or subtype. It is a static attribute that yields
5526 @code{True} if the prefix designates an unconstrained array,
5527 and @code{False} otherwise. In a generic instance, the result is
5528 still static, and yields the result of applying this test to the
5531 @node Universal_Literal_String
5532 @unnumberedsec Universal_Literal_String
5533 @cindex Named numbers, representation of
5534 @findex Universal_Literal_String
5536 The prefix of @code{Universal_Literal_String} must be a named
5537 number. The static result is the string consisting of the characters of
5538 the number as defined in the original source. This allows the user
5539 program to access the actual text of named numbers without intermediate
5540 conversions and without the need to enclose the strings in quotes (which
5541 would preclude their use as numbers). This is used internally for the
5542 construction of values of the floating-point attributes from the file
5543 @file{ttypef.ads}, but may also be used by user programs.
5545 For example, the following program prints the first 50 digits of pi:
5547 @smallexample @c ada
5548 with Text_IO; use Text_IO;
5552 Put (Ada.Numerics.Pi'Universal_Literal_String);
5556 @node Unrestricted_Access
5557 @unnumberedsec Unrestricted_Access
5558 @cindex @code{Access}, unrestricted
5559 @findex Unrestricted_Access
5561 The @code{Unrestricted_Access} attribute is similar to @code{Access}
5562 except that all accessibility and aliased view checks are omitted. This
5563 is a user-beware attribute. It is similar to
5564 @code{Address}, for which it is a desirable replacement where the value
5565 desired is an access type. In other words, its effect is identical to
5566 first applying the @code{Address} attribute and then doing an unchecked
5567 conversion to a desired access type. In GNAT, but not necessarily in
5568 other implementations, the use of static chains for inner level
5569 subprograms means that @code{Unrestricted_Access} applied to a
5570 subprogram yields a value that can be called as long as the subprogram
5571 is in scope (normal Ada accessibility rules restrict this usage).
5573 It is possible to use @code{Unrestricted_Access} for any type, but care
5574 must be exercised if it is used to create pointers to unconstrained
5575 objects. In this case, the resulting pointer has the same scope as the
5576 context of the attribute, and may not be returned to some enclosing
5577 scope. For instance, a function cannot use @code{Unrestricted_Access}
5578 to create a unconstrained pointer and then return that value to the
5582 @unnumberedsec VADS_Size
5583 @cindex @code{Size}, VADS compatibility
5586 The @code{'VADS_Size} attribute is intended to make it easier to port
5587 legacy code which relies on the semantics of @code{'Size} as implemented
5588 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
5589 same semantic interpretation. In particular, @code{'VADS_Size} applied
5590 to a predefined or other primitive type with no Size clause yields the
5591 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
5592 typical machines). In addition @code{'VADS_Size} applied to an object
5593 gives the result that would be obtained by applying the attribute to
5594 the corresponding type.
5597 @unnumberedsec Value_Size
5598 @cindex @code{Size}, setting for not-first subtype
5600 @code{@var{type}'Value_Size} is the number of bits required to represent
5601 a value of the given subtype. It is the same as @code{@var{type}'Size},
5602 but, unlike @code{Size}, may be set for non-first subtypes.
5605 @unnumberedsec Wchar_T_Size
5606 @findex Wchar_T_Size
5607 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
5608 prefix) provides the size in bits of the C @code{wchar_t} type
5609 primarily for constructing the definition of this type in
5610 package @code{Interfaces.C}.
5613 @unnumberedsec Word_Size
5615 @code{Standard'Word_Size} (@code{Standard} is the only permissible
5616 prefix) provides the value @code{System.Word_Size}.
5618 @c ------------------------
5619 @node Implementation Advice
5620 @chapter Implementation Advice
5622 The main text of the Ada Reference Manual describes the required
5623 behavior of all Ada compilers, and the GNAT compiler conforms to
5626 In addition, there are sections throughout the Ada Reference Manual headed
5627 by the phrase ``Implementation advice''. These sections are not normative,
5628 i.e., they do not specify requirements that all compilers must
5629 follow. Rather they provide advice on generally desirable behavior. You
5630 may wonder why they are not requirements. The most typical answer is
5631 that they describe behavior that seems generally desirable, but cannot
5632 be provided on all systems, or which may be undesirable on some systems.
5634 As far as practical, GNAT follows the implementation advice sections in
5635 the Ada Reference Manual. This chapter contains a table giving the
5636 reference manual section number, paragraph number and several keywords
5637 for each advice. Each entry consists of the text of the advice followed
5638 by the GNAT interpretation of this advice. Most often, this simply says
5639 ``followed'', which means that GNAT follows the advice. However, in a
5640 number of cases, GNAT deliberately deviates from this advice, in which
5641 case the text describes what GNAT does and why.
5643 @cindex Error detection
5644 @unnumberedsec 1.1.3(20): Error Detection
5647 If an implementation detects the use of an unsupported Specialized Needs
5648 Annex feature at run time, it should raise @code{Program_Error} if
5651 Not relevant. All specialized needs annex features are either supported,
5652 or diagnosed at compile time.
5655 @unnumberedsec 1.1.3(31): Child Units
5658 If an implementation wishes to provide implementation-defined
5659 extensions to the functionality of a language-defined library unit, it
5660 should normally do so by adding children to the library unit.
5664 @cindex Bounded errors
5665 @unnumberedsec 1.1.5(12): Bounded Errors
5668 If an implementation detects a bounded error or erroneous
5669 execution, it should raise @code{Program_Error}.
5671 Followed in all cases in which the implementation detects a bounded
5672 error or erroneous execution. Not all such situations are detected at
5676 @unnumberedsec 2.8(16): Pragmas
5679 Normally, implementation-defined pragmas should have no semantic effect
5680 for error-free programs; that is, if the implementation-defined pragmas
5681 are removed from a working program, the program should still be legal,
5682 and should still have the same semantics.
5684 The following implementation defined pragmas are exceptions to this
5696 @item CPP_Constructor
5700 @item Interface_Name
5702 @item Machine_Attribute
5704 @item Unimplemented_Unit
5706 @item Unchecked_Union
5711 In each of the above cases, it is essential to the purpose of the pragma
5712 that this advice not be followed. For details see the separate section
5713 on implementation defined pragmas.
5715 @unnumberedsec 2.8(17-19): Pragmas
5718 Normally, an implementation should not define pragmas that can
5719 make an illegal program legal, except as follows:
5723 A pragma used to complete a declaration, such as a pragma @code{Import};
5727 A pragma used to configure the environment by adding, removing, or
5728 replacing @code{library_items}.
5730 See response to paragraph 16 of this same section.
5732 @cindex Character Sets
5733 @cindex Alternative Character Sets
5734 @unnumberedsec 3.5.2(5): Alternative Character Sets
5737 If an implementation supports a mode with alternative interpretations
5738 for @code{Character} and @code{Wide_Character}, the set of graphic
5739 characters of @code{Character} should nevertheless remain a proper
5740 subset of the set of graphic characters of @code{Wide_Character}. Any
5741 character set ``localizations'' should be reflected in the results of
5742 the subprograms defined in the language-defined package
5743 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
5744 an alternative interpretation of @code{Character}, the implementation should
5745 also support a corresponding change in what is a legal
5746 @code{identifier_letter}.
5748 Not all wide character modes follow this advice, in particular the JIS
5749 and IEC modes reflect standard usage in Japan, and in these encoding,
5750 the upper half of the Latin-1 set is not part of the wide-character
5751 subset, since the most significant bit is used for wide character
5752 encoding. However, this only applies to the external forms. Internally
5753 there is no such restriction.
5755 @cindex Integer types
5756 @unnumberedsec 3.5.4(28): Integer Types
5760 An implementation should support @code{Long_Integer} in addition to
5761 @code{Integer} if the target machine supports 32-bit (or longer)
5762 arithmetic. No other named integer subtypes are recommended for package
5763 @code{Standard}. Instead, appropriate named integer subtypes should be
5764 provided in the library package @code{Interfaces} (see B.2).
5766 @code{Long_Integer} is supported. Other standard integer types are supported
5767 so this advice is not fully followed. These types
5768 are supported for convenient interface to C, and so that all hardware
5769 types of the machine are easily available.
5770 @unnumberedsec 3.5.4(29): Integer Types
5774 An implementation for a two's complement machine should support
5775 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
5776 implementation should support a non-binary modules up to @code{Integer'Last}.
5780 @cindex Enumeration values
5781 @unnumberedsec 3.5.5(8): Enumeration Values
5784 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
5785 subtype, if the value of the operand does not correspond to the internal
5786 code for any enumeration literal of its type (perhaps due to an
5787 un-initialized variable), then the implementation should raise
5788 @code{Program_Error}. This is particularly important for enumeration
5789 types with noncontiguous internal codes specified by an
5790 enumeration_representation_clause.
5795 @unnumberedsec 3.5.7(17): Float Types
5798 An implementation should support @code{Long_Float} in addition to
5799 @code{Float} if the target machine supports 11 or more digits of
5800 precision. No other named floating point subtypes are recommended for
5801 package @code{Standard}. Instead, appropriate named floating point subtypes
5802 should be provided in the library package @code{Interfaces} (see B.2).
5804 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
5805 former provides improved compatibility with other implementations
5806 supporting this type. The latter corresponds to the highest precision
5807 floating-point type supported by the hardware. On most machines, this
5808 will be the same as @code{Long_Float}, but on some machines, it will
5809 correspond to the IEEE extended form. The notable case is all ia32
5810 (x86) implementations, where @code{Long_Long_Float} corresponds to
5811 the 80-bit extended precision format supported in hardware on this
5812 processor. Note that the 128-bit format on SPARC is not supported,
5813 since this is a software rather than a hardware format.
5815 @cindex Multidimensional arrays
5816 @cindex Arrays, multidimensional
5817 @unnumberedsec 3.6.2(11): Multidimensional Arrays
5820 An implementation should normally represent multidimensional arrays in
5821 row-major order, consistent with the notation used for multidimensional
5822 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
5823 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
5824 column-major order should be used instead (see B.5, ``Interfacing with
5829 @findex Duration'Small
5830 @unnumberedsec 9.6(30-31): Duration'Small
5833 Whenever possible in an implementation, the value of @code{Duration'Small}
5834 should be no greater than 100 microseconds.
5836 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
5840 The time base for @code{delay_relative_statements} should be monotonic;
5841 it need not be the same time base as used for @code{Calendar.Clock}.
5845 @unnumberedsec 10.2.1(12): Consistent Representation
5848 In an implementation, a type declared in a pre-elaborated package should
5849 have the same representation in every elaboration of a given version of
5850 the package, whether the elaborations occur in distinct executions of
5851 the same program, or in executions of distinct programs or partitions
5852 that include the given version.
5854 Followed, except in the case of tagged types. Tagged types involve
5855 implicit pointers to a local copy of a dispatch table, and these pointers
5856 have representations which thus depend on a particular elaboration of the
5857 package. It is not easy to see how it would be possible to follow this
5858 advice without severely impacting efficiency of execution.
5860 @cindex Exception information
5861 @unnumberedsec 11.4.1(19): Exception Information
5864 @code{Exception_Message} by default and @code{Exception_Information}
5865 should produce information useful for
5866 debugging. @code{Exception_Message} should be short, about one
5867 line. @code{Exception_Information} can be long. @code{Exception_Message}
5868 should not include the
5869 @code{Exception_Name}. @code{Exception_Information} should include both
5870 the @code{Exception_Name} and the @code{Exception_Message}.
5872 Followed. For each exception that doesn't have a specified
5873 @code{Exception_Message}, the compiler generates one containing the location
5874 of the raise statement. This location has the form ``file:line'', where
5875 file is the short file name (without path information) and line is the line
5876 number in the file. Note that in the case of the Zero Cost Exception
5877 mechanism, these messages become redundant with the Exception_Information that
5878 contains a full backtrace of the calling sequence, so they are disabled.
5879 To disable explicitly the generation of the source location message, use the
5880 Pragma @code{Discard_Names}.
5882 @cindex Suppression of checks
5883 @cindex Checks, suppression of
5884 @unnumberedsec 11.5(28): Suppression of Checks
5887 The implementation should minimize the code executed for checks that
5888 have been suppressed.
5892 @cindex Representation clauses
5893 @unnumberedsec 13.1 (21-24): Representation Clauses
5896 The recommended level of support for all representation items is
5897 qualified as follows:
5901 An implementation need not support representation items containing
5902 non-static expressions, except that an implementation should support a
5903 representation item for a given entity if each non-static expression in
5904 the representation item is a name that statically denotes a constant
5905 declared before the entity.
5907 Followed. In fact, GNAT goes beyond the recommended level of support
5908 by allowing nonstatic expressions in some representation clauses even
5909 without the need to declare constants initialized with the values of
5913 @smallexample @c ada
5916 for Y'Address use X'Address;>>
5922 An implementation need not support a specification for the @code{Size}
5923 for a given composite subtype, nor the size or storage place for an
5924 object (including a component) of a given composite subtype, unless the
5925 constraints on the subtype and its composite subcomponents (if any) are
5926 all static constraints.
5928 Followed. Size Clauses are not permitted on non-static components, as
5933 An aliased component, or a component whose type is by-reference, should
5934 always be allocated at an addressable location.
5938 @cindex Packed types
5939 @unnumberedsec 13.2(6-8): Packed Types
5942 If a type is packed, then the implementation should try to minimize
5943 storage allocated to objects of the type, possibly at the expense of
5944 speed of accessing components, subject to reasonable complexity in
5945 addressing calculations.
5949 The recommended level of support pragma @code{Pack} is:
5951 For a packed record type, the components should be packed as tightly as
5952 possible subject to the Sizes of the component subtypes, and subject to
5953 any @code{record_representation_clause} that applies to the type; the
5954 implementation may, but need not, reorder components or cross aligned
5955 word boundaries to improve the packing. A component whose @code{Size} is
5956 greater than the word size may be allocated an integral number of words.
5958 Followed. Tight packing of arrays is supported for all component sizes
5959 up to 64-bits. If the array component size is 1 (that is to say, if
5960 the component is a boolean type or an enumeration type with two values)
5961 then values of the type are implicitly initialized to zero. This
5962 happens both for objects of the packed type, and for objects that have a
5963 subcomponent of the packed type.
5967 An implementation should support Address clauses for imported
5971 @cindex @code{Address} clauses
5972 @unnumberedsec 13.3(14-19): Address Clauses
5976 For an array @var{X}, @code{@var{X}'Address} should point at the first
5977 component of the array, and not at the array bounds.
5983 The recommended level of support for the @code{Address} attribute is:
5985 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5986 object that is aliased or of a by-reference type, or is an entity whose
5987 @code{Address} has been specified.
5989 Followed. A valid address will be produced even if none of those
5990 conditions have been met. If necessary, the object is forced into
5991 memory to ensure the address is valid.
5995 An implementation should support @code{Address} clauses for imported
6002 Objects (including subcomponents) that are aliased or of a by-reference
6003 type should be allocated on storage element boundaries.
6009 If the @code{Address} of an object is specified, or it is imported or exported,
6010 then the implementation should not perform optimizations based on
6011 assumptions of no aliases.
6015 @cindex @code{Alignment} clauses
6016 @unnumberedsec 13.3(29-35): Alignment Clauses
6019 The recommended level of support for the @code{Alignment} attribute for
6022 An implementation should support specified Alignments that are factors
6023 and multiples of the number of storage elements per word, subject to the
6030 An implementation need not support specified @code{Alignment}s for
6031 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6032 loaded and stored by available machine instructions.
6038 An implementation need not support specified @code{Alignment}s that are
6039 greater than the maximum @code{Alignment} the implementation ever returns by
6046 The recommended level of support for the @code{Alignment} attribute for
6049 Same as above, for subtypes, but in addition:
6055 For stand-alone library-level objects of statically constrained
6056 subtypes, the implementation should support all @code{Alignment}s
6057 supported by the target linker. For example, page alignment is likely to
6058 be supported for such objects, but not for subtypes.
6062 @cindex @code{Size} clauses
6063 @unnumberedsec 13.3(42-43): Size Clauses
6066 The recommended level of support for the @code{Size} attribute of
6069 A @code{Size} clause should be supported for an object if the specified
6070 @code{Size} is at least as large as its subtype's @code{Size}, and
6071 corresponds to a size in storage elements that is a multiple of the
6072 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6076 @unnumberedsec 13.3(50-56): Size Clauses
6079 If the @code{Size} of a subtype is specified, and allows for efficient
6080 independent addressability (see 9.10) on the target architecture, then
6081 the @code{Size} of the following objects of the subtype should equal the
6082 @code{Size} of the subtype:
6084 Aliased objects (including components).
6090 @code{Size} clause on a composite subtype should not affect the
6091 internal layout of components.
6093 Followed. But note that this can be overridden by use of the implementation
6094 pragma Implicit_Packing in the case of packed arrays.
6098 The recommended level of support for the @code{Size} attribute of subtypes is:
6102 The @code{Size} (if not specified) of a static discrete or fixed point
6103 subtype should be the number of bits needed to represent each value
6104 belonging to the subtype using an unbiased representation, leaving space
6105 for a sign bit only if the subtype contains negative values. If such a
6106 subtype is a first subtype, then an implementation should support a
6107 specified @code{Size} for it that reflects this representation.
6113 For a subtype implemented with levels of indirection, the @code{Size}
6114 should include the size of the pointers, but not the size of what they
6119 @cindex @code{Component_Size} clauses
6120 @unnumberedsec 13.3(71-73): Component Size Clauses
6123 The recommended level of support for the @code{Component_Size}
6128 An implementation need not support specified @code{Component_Sizes} that are
6129 less than the @code{Size} of the component subtype.
6135 An implementation should support specified @code{Component_Size}s that
6136 are factors and multiples of the word size. For such
6137 @code{Component_Size}s, the array should contain no gaps between
6138 components. For other @code{Component_Size}s (if supported), the array
6139 should contain no gaps between components when packing is also
6140 specified; the implementation should forbid this combination in cases
6141 where it cannot support a no-gaps representation.
6145 @cindex Enumeration representation clauses
6146 @cindex Representation clauses, enumeration
6147 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6150 The recommended level of support for enumeration representation clauses
6153 An implementation need not support enumeration representation clauses
6154 for boolean types, but should at minimum support the internal codes in
6155 the range @code{System.Min_Int.System.Max_Int}.
6159 @cindex Record representation clauses
6160 @cindex Representation clauses, records
6161 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6164 The recommended level of support for
6165 @*@code{record_representation_clauses} is:
6167 An implementation should support storage places that can be extracted
6168 with a load, mask, shift sequence of machine code, and set with a load,
6169 shift, mask, store sequence, given the available machine instructions
6176 A storage place should be supported if its size is equal to the
6177 @code{Size} of the component subtype, and it starts and ends on a
6178 boundary that obeys the @code{Alignment} of the component subtype.
6184 If the default bit ordering applies to the declaration of a given type,
6185 then for a component whose subtype's @code{Size} is less than the word
6186 size, any storage place that does not cross an aligned word boundary
6187 should be supported.
6193 An implementation may reserve a storage place for the tag field of a
6194 tagged type, and disallow other components from overlapping that place.
6196 Followed. The storage place for the tag field is the beginning of the tagged
6197 record, and its size is Address'Size. GNAT will reject an explicit component
6198 clause for the tag field.
6202 An implementation need not support a @code{component_clause} for a
6203 component of an extension part if the storage place is not after the
6204 storage places of all components of the parent type, whether or not
6205 those storage places had been specified.
6207 Followed. The above advice on record representation clauses is followed,
6208 and all mentioned features are implemented.
6210 @cindex Storage place attributes
6211 @unnumberedsec 13.5.2(5): Storage Place Attributes
6214 If a component is represented using some form of pointer (such as an
6215 offset) to the actual data of the component, and this data is contiguous
6216 with the rest of the object, then the storage place attributes should
6217 reflect the place of the actual data, not the pointer. If a component is
6218 allocated discontinuously from the rest of the object, then a warning
6219 should be generated upon reference to one of its storage place
6222 Followed. There are no such components in GNAT@.
6224 @cindex Bit ordering
6225 @unnumberedsec 13.5.3(7-8): Bit Ordering
6228 The recommended level of support for the non-default bit ordering is:
6232 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6233 should support the non-default bit ordering in addition to the default
6236 Followed. Word size does not equal storage size in this implementation.
6237 Thus non-default bit ordering is not supported.
6239 @cindex @code{Address}, as private type
6240 @unnumberedsec 13.7(37): Address as Private
6243 @code{Address} should be of a private type.
6247 @cindex Operations, on @code{Address}
6248 @cindex @code{Address}, operations of
6249 @unnumberedsec 13.7.1(16): Address Operations
6252 Operations in @code{System} and its children should reflect the target
6253 environment semantics as closely as is reasonable. For example, on most
6254 machines, it makes sense for address arithmetic to ``wrap around''.
6255 Operations that do not make sense should raise @code{Program_Error}.
6257 Followed. Address arithmetic is modular arithmetic that wraps around. No
6258 operation raises @code{Program_Error}, since all operations make sense.
6260 @cindex Unchecked conversion
6261 @unnumberedsec 13.9(14-17): Unchecked Conversion
6264 The @code{Size} of an array object should not include its bounds; hence,
6265 the bounds should not be part of the converted data.
6271 The implementation should not generate unnecessary run-time checks to
6272 ensure that the representation of @var{S} is a representation of the
6273 target type. It should take advantage of the permission to return by
6274 reference when possible. Restrictions on unchecked conversions should be
6275 avoided unless required by the target environment.
6277 Followed. There are no restrictions on unchecked conversion. A warning is
6278 generated if the source and target types do not have the same size since
6279 the semantics in this case may be target dependent.
6283 The recommended level of support for unchecked conversions is:
6287 Unchecked conversions should be supported and should be reversible in
6288 the cases where this clause defines the result. To enable meaningful use
6289 of unchecked conversion, a contiguous representation should be used for
6290 elementary subtypes, for statically constrained array subtypes whose
6291 component subtype is one of the subtypes described in this paragraph,
6292 and for record subtypes without discriminants whose component subtypes
6293 are described in this paragraph.
6297 @cindex Heap usage, implicit
6298 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6301 An implementation should document any cases in which it dynamically
6302 allocates heap storage for a purpose other than the evaluation of an
6305 Followed, the only other points at which heap storage is dynamically
6306 allocated are as follows:
6310 At initial elaboration time, to allocate dynamically sized global
6314 To allocate space for a task when a task is created.
6317 To extend the secondary stack dynamically when needed. The secondary
6318 stack is used for returning variable length results.
6323 A default (implementation-provided) storage pool for an
6324 access-to-constant type should not have overhead to support deallocation of
6331 A storage pool for an anonymous access type should be created at the
6332 point of an allocator for the type, and be reclaimed when the designated
6333 object becomes inaccessible.
6337 @cindex Unchecked deallocation
6338 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6341 For a standard storage pool, @code{Free} should actually reclaim the
6346 @cindex Stream oriented attributes
6347 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6350 If a stream element is the same size as a storage element, then the
6351 normal in-memory representation should be used by @code{Read} and
6352 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
6353 should use the smallest number of stream elements needed to represent
6354 all values in the base range of the scalar type.
6357 Followed. By default, GNAT uses the interpretation suggested by AI-195,
6358 which specifies using the size of the first subtype.
6359 However, such an implementation is based on direct binary
6360 representations and is therefore target- and endianness-dependent.
6361 To address this issue, GNAT also supplies an alternate implementation
6362 of the stream attributes @code{Read} and @code{Write},
6363 which uses the target-independent XDR standard representation
6365 @cindex XDR representation
6366 @cindex @code{Read} attribute
6367 @cindex @code{Write} attribute
6368 @cindex Stream oriented attributes
6369 The XDR implementation is provided as an alternative body of the
6370 @code{System.Stream_Attributes} package, in the file
6371 @file{s-strxdr.adb} in the GNAT library.
6372 There is no @file{s-strxdr.ads} file.
6373 In order to install the XDR implementation, do the following:
6375 @item Replace the default implementation of the
6376 @code{System.Stream_Attributes} package with the XDR implementation.
6377 For example on a Unix platform issue the commands:
6379 $ mv s-stratt.adb s-strold.adb
6380 $ mv s-strxdr.adb s-stratt.adb
6384 Rebuild the GNAT run-time library as documented in the
6385 @cite{GNAT User's Guide}
6388 @unnumberedsec A.1(52): Names of Predefined Numeric Types
6391 If an implementation provides additional named predefined integer types,
6392 then the names should end with @samp{Integer} as in
6393 @samp{Long_Integer}. If an implementation provides additional named
6394 predefined floating point types, then the names should end with
6395 @samp{Float} as in @samp{Long_Float}.
6399 @findex Ada.Characters.Handling
6400 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
6403 If an implementation provides a localized definition of @code{Character}
6404 or @code{Wide_Character}, then the effects of the subprograms in
6405 @code{Characters.Handling} should reflect the localizations. See also
6408 Followed. GNAT provides no such localized definitions.
6410 @cindex Bounded-length strings
6411 @unnumberedsec A.4.4(106): Bounded-Length String Handling
6414 Bounded string objects should not be implemented by implicit pointers
6415 and dynamic allocation.
6417 Followed. No implicit pointers or dynamic allocation are used.
6419 @cindex Random number generation
6420 @unnumberedsec A.5.2(46-47): Random Number Generation
6423 Any storage associated with an object of type @code{Generator} should be
6424 reclaimed on exit from the scope of the object.
6430 If the generator period is sufficiently long in relation to the number
6431 of distinct initiator values, then each possible value of
6432 @code{Initiator} passed to @code{Reset} should initiate a sequence of
6433 random numbers that does not, in a practical sense, overlap the sequence
6434 initiated by any other value. If this is not possible, then the mapping
6435 between initiator values and generator states should be a rapidly
6436 varying function of the initiator value.
6438 Followed. The generator period is sufficiently long for the first
6439 condition here to hold true.
6441 @findex Get_Immediate
6442 @unnumberedsec A.10.7(23): @code{Get_Immediate}
6445 The @code{Get_Immediate} procedures should be implemented with
6446 unbuffered input. For a device such as a keyboard, input should be
6447 @dfn{available} if a key has already been typed, whereas for a disk
6448 file, input should always be available except at end of file. For a file
6449 associated with a keyboard-like device, any line-editing features of the
6450 underlying operating system should be disabled during the execution of
6451 @code{Get_Immediate}.
6453 Followed on all targets except VxWorks. For VxWorks, there is no way to
6454 provide this functionality that does not result in the input buffer being
6455 flushed before the @code{Get_Immediate} call. A special unit
6456 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
6460 @unnumberedsec B.1(39-41): Pragma @code{Export}
6463 If an implementation supports pragma @code{Export} to a given language,
6464 then it should also allow the main subprogram to be written in that
6465 language. It should support some mechanism for invoking the elaboration
6466 of the Ada library units included in the system, and for invoking the
6467 finalization of the environment task. On typical systems, the
6468 recommended mechanism is to provide two subprograms whose link names are
6469 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
6470 elaboration code for library units. @code{adafinal} should contain the
6471 finalization code. These subprograms should have no effect the second
6472 and subsequent time they are called.
6478 Automatic elaboration of pre-elaborated packages should be
6479 provided when pragma @code{Export} is supported.
6481 Followed when the main program is in Ada. If the main program is in a
6482 foreign language, then
6483 @code{adainit} must be called to elaborate pre-elaborated
6488 For each supported convention @var{L} other than @code{Intrinsic}, an
6489 implementation should support @code{Import} and @code{Export} pragmas
6490 for objects of @var{L}-compatible types and for subprograms, and pragma
6491 @code{Convention} for @var{L}-eligible types and for subprograms,
6492 presuming the other language has corresponding features. Pragma
6493 @code{Convention} need not be supported for scalar types.
6497 @cindex Package @code{Interfaces}
6499 @unnumberedsec B.2(12-13): Package @code{Interfaces}
6502 For each implementation-defined convention identifier, there should be a
6503 child package of package Interfaces with the corresponding name. This
6504 package should contain any declarations that would be useful for
6505 interfacing to the language (implementation) represented by the
6506 convention. Any declarations useful for interfacing to any language on
6507 the given hardware architecture should be provided directly in
6510 Followed. An additional package not defined
6511 in the Ada Reference Manual is @code{Interfaces.CPP}, used
6512 for interfacing to C++.
6516 An implementation supporting an interface to C, COBOL, or Fortran should
6517 provide the corresponding package or packages described in the following
6520 Followed. GNAT provides all the packages described in this section.
6522 @cindex C, interfacing with
6523 @unnumberedsec B.3(63-71): Interfacing with C
6526 An implementation should support the following interface correspondences
6533 An Ada procedure corresponds to a void-returning C function.
6539 An Ada function corresponds to a non-void C function.
6545 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
6552 An Ada @code{in} parameter of an access-to-object type with designated
6553 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
6554 where @var{t} is the C type corresponding to the Ada type @var{T}.
6560 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
6561 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
6562 argument to a C function, where @var{t} is the C type corresponding to
6563 the Ada type @var{T}. In the case of an elementary @code{out} or
6564 @code{in out} parameter, a pointer to a temporary copy is used to
6565 preserve by-copy semantics.
6571 An Ada parameter of a record type @var{T}, of any mode, is passed as a
6572 @code{@var{t}*} argument to a C function, where @var{t} is the C
6573 structure corresponding to the Ada type @var{T}.
6575 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
6576 pragma, or Convention, or by explicitly specifying the mechanism for a given
6577 call using an extended import or export pragma.
6581 An Ada parameter of an array type with component type @var{T}, of any
6582 mode, is passed as a @code{@var{t}*} argument to a C function, where
6583 @var{t} is the C type corresponding to the Ada type @var{T}.
6589 An Ada parameter of an access-to-subprogram type is passed as a pointer
6590 to a C function whose prototype corresponds to the designated
6591 subprogram's specification.
6595 @cindex COBOL, interfacing with
6596 @unnumberedsec B.4(95-98): Interfacing with COBOL
6599 An Ada implementation should support the following interface
6600 correspondences between Ada and COBOL@.
6606 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
6607 the COBOL type corresponding to @var{T}.
6613 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
6614 the corresponding COBOL type.
6620 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
6621 COBOL type corresponding to the Ada parameter type; for scalars, a local
6622 copy is used if necessary to ensure by-copy semantics.
6626 @cindex Fortran, interfacing with
6627 @unnumberedsec B.5(22-26): Interfacing with Fortran
6630 An Ada implementation should support the following interface
6631 correspondences between Ada and Fortran:
6637 An Ada procedure corresponds to a Fortran subroutine.
6643 An Ada function corresponds to a Fortran function.
6649 An Ada parameter of an elementary, array, or record type @var{T} is
6650 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
6651 the Fortran type corresponding to the Ada type @var{T}, and where the
6652 INTENT attribute of the corresponding dummy argument matches the Ada
6653 formal parameter mode; the Fortran implementation's parameter passing
6654 conventions are used. For elementary types, a local copy is used if
6655 necessary to ensure by-copy semantics.
6661 An Ada parameter of an access-to-subprogram type is passed as a
6662 reference to a Fortran procedure whose interface corresponds to the
6663 designated subprogram's specification.
6667 @cindex Machine operations
6668 @unnumberedsec C.1(3-5): Access to Machine Operations
6671 The machine code or intrinsic support should allow access to all
6672 operations normally available to assembly language programmers for the
6673 target environment, including privileged instructions, if any.
6679 The interfacing pragmas (see Annex B) should support interface to
6680 assembler; the default assembler should be associated with the
6681 convention identifier @code{Assembler}.
6687 If an entity is exported to assembly language, then the implementation
6688 should allocate it at an addressable location, and should ensure that it
6689 is retained by the linking process, even if not otherwise referenced
6690 from the Ada code. The implementation should assume that any call to a
6691 machine code or assembler subprogram is allowed to read or update every
6692 object that is specified as exported.
6696 @unnumberedsec C.1(10-16): Access to Machine Operations
6699 The implementation should ensure that little or no overhead is
6700 associated with calling intrinsic and machine-code subprograms.
6702 Followed for both intrinsics and machine-code subprograms.
6706 It is recommended that intrinsic subprograms be provided for convenient
6707 access to any machine operations that provide special capabilities or
6708 efficiency and that are not otherwise available through the language
6711 Followed. A full set of machine operation intrinsic subprograms is provided.
6715 Atomic read-modify-write operations---e.g.@:, test and set, compare and
6716 swap, decrement and test, enqueue/dequeue.
6718 Followed on any target supporting such operations.
6722 Standard numeric functions---e.g.@:, sin, log.
6724 Followed on any target supporting such operations.
6728 String manipulation operations---e.g.@:, translate and test.
6730 Followed on any target supporting such operations.
6734 Vector operations---e.g.@:, compare vector against thresholds.
6736 Followed on any target supporting such operations.
6740 Direct operations on I/O ports.
6742 Followed on any target supporting such operations.
6744 @cindex Interrupt support
6745 @unnumberedsec C.3(28): Interrupt Support
6748 If the @code{Ceiling_Locking} policy is not in effect, the
6749 implementation should provide means for the application to specify which
6750 interrupts are to be blocked during protected actions, if the underlying
6751 system allows for a finer-grain control of interrupt blocking.
6753 Followed. The underlying system does not allow for finer-grain control
6754 of interrupt blocking.
6756 @cindex Protected procedure handlers
6757 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
6760 Whenever possible, the implementation should allow interrupt handlers to
6761 be called directly by the hardware.
6765 This is never possible under IRIX, so this is followed by default.
6767 Followed on any target where the underlying operating system permits
6772 Whenever practical, violations of any
6773 implementation-defined restrictions should be detected before run time.
6775 Followed. Compile time warnings are given when possible.
6777 @cindex Package @code{Interrupts}
6779 @unnumberedsec C.3.2(25): Package @code{Interrupts}
6783 If implementation-defined forms of interrupt handler procedures are
6784 supported, such as protected procedures with parameters, then for each
6785 such form of a handler, a type analogous to @code{Parameterless_Handler}
6786 should be specified in a child package of @code{Interrupts}, with the
6787 same operations as in the predefined package Interrupts.
6791 @cindex Pre-elaboration requirements
6792 @unnumberedsec C.4(14): Pre-elaboration Requirements
6795 It is recommended that pre-elaborated packages be implemented in such a
6796 way that there should be little or no code executed at run time for the
6797 elaboration of entities not already covered by the Implementation
6800 Followed. Executable code is generated in some cases, e.g.@: loops
6801 to initialize large arrays.
6803 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
6807 If the pragma applies to an entity, then the implementation should
6808 reduce the amount of storage used for storing names associated with that
6813 @cindex Package @code{Task_Attributes}
6814 @findex Task_Attributes
6815 @unnumberedsec C.7.2(30): The Package Task_Attributes
6818 Some implementations are targeted to domains in which memory use at run
6819 time must be completely deterministic. For such implementations, it is
6820 recommended that the storage for task attributes will be pre-allocated
6821 statically and not from the heap. This can be accomplished by either
6822 placing restrictions on the number and the size of the task's
6823 attributes, or by using the pre-allocated storage for the first @var{N}
6824 attribute objects, and the heap for the others. In the latter case,
6825 @var{N} should be documented.
6827 Not followed. This implementation is not targeted to such a domain.
6829 @cindex Locking Policies
6830 @unnumberedsec D.3(17): Locking Policies
6834 The implementation should use names that end with @samp{_Locking} for
6835 locking policies defined by the implementation.
6837 Followed. A single implementation-defined locking policy is defined,
6838 whose name (@code{Inheritance_Locking}) follows this suggestion.
6840 @cindex Entry queuing policies
6841 @unnumberedsec D.4(16): Entry Queuing Policies
6844 Names that end with @samp{_Queuing} should be used
6845 for all implementation-defined queuing policies.
6847 Followed. No such implementation-defined queuing policies exist.
6849 @cindex Preemptive abort
6850 @unnumberedsec D.6(9-10): Preemptive Abort
6853 Even though the @code{abort_statement} is included in the list of
6854 potentially blocking operations (see 9.5.1), it is recommended that this
6855 statement be implemented in a way that never requires the task executing
6856 the @code{abort_statement} to block.
6862 On a multi-processor, the delay associated with aborting a task on
6863 another processor should be bounded; the implementation should use
6864 periodic polling, if necessary, to achieve this.
6868 @cindex Tasking restrictions
6869 @unnumberedsec D.7(21): Tasking Restrictions
6872 When feasible, the implementation should take advantage of the specified
6873 restrictions to produce a more efficient implementation.
6875 GNAT currently takes advantage of these restrictions by providing an optimized
6876 run time when the Ravenscar profile and the GNAT restricted run time set
6877 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
6878 pragma @code{Profile (Restricted)} for more details.
6880 @cindex Time, monotonic
6881 @unnumberedsec D.8(47-49): Monotonic Time
6884 When appropriate, implementations should provide configuration
6885 mechanisms to change the value of @code{Tick}.
6887 Such configuration mechanisms are not appropriate to this implementation
6888 and are thus not supported.
6892 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6893 be implemented as transformations of the same time base.
6899 It is recommended that the @dfn{best} time base which exists in
6900 the underlying system be available to the application through
6901 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
6905 @cindex Partition communication subsystem
6907 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6910 Whenever possible, the PCS on the called partition should allow for
6911 multiple tasks to call the RPC-receiver with different messages and
6912 should allow them to block until the corresponding subprogram body
6915 Followed by GLADE, a separately supplied PCS that can be used with
6920 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6921 should raise @code{Storage_Error} if it runs out of space trying to
6922 write the @code{Item} into the stream.
6924 Followed by GLADE, a separately supplied PCS that can be used with
6927 @cindex COBOL support
6928 @unnumberedsec F(7): COBOL Support
6931 If COBOL (respectively, C) is widely supported in the target
6932 environment, implementations supporting the Information Systems Annex
6933 should provide the child package @code{Interfaces.COBOL} (respectively,
6934 @code{Interfaces.C}) specified in Annex B and should support a
6935 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6936 pragmas (see Annex B), thus allowing Ada programs to interface with
6937 programs written in that language.
6941 @cindex Decimal radix support
6942 @unnumberedsec F.1(2): Decimal Radix Support
6945 Packed decimal should be used as the internal representation for objects
6946 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6948 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
6952 @unnumberedsec G: Numerics
6955 If Fortran (respectively, C) is widely supported in the target
6956 environment, implementations supporting the Numerics Annex
6957 should provide the child package @code{Interfaces.Fortran} (respectively,
6958 @code{Interfaces.C}) specified in Annex B and should support a
6959 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6960 pragmas (see Annex B), thus allowing Ada programs to interface with
6961 programs written in that language.
6965 @cindex Complex types
6966 @unnumberedsec G.1.1(56-58): Complex Types
6969 Because the usual mathematical meaning of multiplication of a complex
6970 operand and a real operand is that of the scaling of both components of
6971 the former by the latter, an implementation should not perform this
6972 operation by first promoting the real operand to complex type and then
6973 performing a full complex multiplication. In systems that, in the
6974 future, support an Ada binding to IEC 559:1989, the latter technique
6975 will not generate the required result when one of the components of the
6976 complex operand is infinite. (Explicit multiplication of the infinite
6977 component by the zero component obtained during promotion yields a NaN
6978 that propagates into the final result.) Analogous advice applies in the
6979 case of multiplication of a complex operand and a pure-imaginary
6980 operand, and in the case of division of a complex operand by a real or
6981 pure-imaginary operand.
6987 Similarly, because the usual mathematical meaning of addition of a
6988 complex operand and a real operand is that the imaginary operand remains
6989 unchanged, an implementation should not perform this operation by first
6990 promoting the real operand to complex type and then performing a full
6991 complex addition. In implementations in which the @code{Signed_Zeros}
6992 attribute of the component type is @code{True} (and which therefore
6993 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6994 predefined arithmetic operations), the latter technique will not
6995 generate the required result when the imaginary component of the complex
6996 operand is a negatively signed zero. (Explicit addition of the negative
6997 zero to the zero obtained during promotion yields a positive zero.)
6998 Analogous advice applies in the case of addition of a complex operand
6999 and a pure-imaginary operand, and in the case of subtraction of a
7000 complex operand and a real or pure-imaginary operand.
7006 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7007 attempt to provide a rational treatment of the signs of zero results and
7008 result components. As one example, the result of the @code{Argument}
7009 function should have the sign of the imaginary component of the
7010 parameter @code{X} when the point represented by that parameter lies on
7011 the positive real axis; as another, the sign of the imaginary component
7012 of the @code{Compose_From_Polar} function should be the same as
7013 (respectively, the opposite of) that of the @code{Argument} parameter when that
7014 parameter has a value of zero and the @code{Modulus} parameter has a
7015 nonnegative (respectively, negative) value.
7019 @cindex Complex elementary functions
7020 @unnumberedsec G.1.2(49): Complex Elementary Functions
7023 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7024 @code{True} should attempt to provide a rational treatment of the signs
7025 of zero results and result components. For example, many of the complex
7026 elementary functions have components that are odd functions of one of
7027 the parameter components; in these cases, the result component should
7028 have the sign of the parameter component at the origin. Other complex
7029 elementary functions have zero components whose sign is opposite that of
7030 a parameter component at the origin, or is always positive or always
7035 @cindex Accuracy requirements
7036 @unnumberedsec G.2.4(19): Accuracy Requirements
7039 The versions of the forward trigonometric functions without a
7040 @code{Cycle} parameter should not be implemented by calling the
7041 corresponding version with a @code{Cycle} parameter of
7042 @code{2.0*Numerics.Pi}, since this will not provide the required
7043 accuracy in some portions of the domain. For the same reason, the
7044 version of @code{Log} without a @code{Base} parameter should not be
7045 implemented by calling the corresponding version with a @code{Base}
7046 parameter of @code{Numerics.e}.
7050 @cindex Complex arithmetic accuracy
7051 @cindex Accuracy, complex arithmetic
7052 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7056 The version of the @code{Compose_From_Polar} function without a
7057 @code{Cycle} parameter should not be implemented by calling the
7058 corresponding version with a @code{Cycle} parameter of
7059 @code{2.0*Numerics.Pi}, since this will not provide the required
7060 accuracy in some portions of the domain.
7064 @c -----------------------------------------
7065 @node Implementation Defined Characteristics
7066 @chapter Implementation Defined Characteristics
7069 In addition to the implementation dependent pragmas and attributes, and
7070 the implementation advice, there are a number of other Ada features
7071 that are potentially implementation dependent. These are mentioned
7072 throughout the Ada Reference Manual, and are summarized in annex M@.
7074 A requirement for conforming Ada compilers is that they provide
7075 documentation describing how the implementation deals with each of these
7076 issues. In this chapter, you will find each point in annex M listed
7077 followed by a description in italic font of how GNAT
7081 implementation on IRIX 5.3 operating system or greater
7083 handles the implementation dependence.
7085 You can use this chapter as a guide to minimizing implementation
7086 dependent features in your programs if portability to other compilers
7087 and other operating systems is an important consideration. The numbers
7088 in each section below correspond to the paragraph number in the Ada
7094 @strong{2}. Whether or not each recommendation given in Implementation
7095 Advice is followed. See 1.1.2(37).
7098 @xref{Implementation Advice}.
7103 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
7106 The complexity of programs that can be processed is limited only by the
7107 total amount of available virtual memory, and disk space for the
7108 generated object files.
7113 @strong{4}. Variations from the standard that are impractical to avoid
7114 given the implementation's execution environment. See 1.1.3(6).
7117 There are no variations from the standard.
7122 @strong{5}. Which @code{code_statement}s cause external
7123 interactions. See 1.1.3(10).
7126 Any @code{code_statement} can potentially cause external interactions.
7131 @strong{6}. The coded representation for the text of an Ada
7132 program. See 2.1(4).
7135 See separate section on source representation.
7140 @strong{7}. The control functions allowed in comments. See 2.1(14).
7143 See separate section on source representation.
7148 @strong{8}. The representation for an end of line. See 2.2(2).
7151 See separate section on source representation.
7156 @strong{9}. Maximum supported line length and lexical element
7157 length. See 2.2(15).
7160 The maximum line length is 255 characters an the maximum length of a
7161 lexical element is also 255 characters.
7166 @strong{10}. Implementation defined pragmas. See 2.8(14).
7170 @xref{Implementation Defined Pragmas}.
7175 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
7178 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7179 parameter, checks that the optimization flag is set, and aborts if it is
7185 @strong{12}. The sequence of characters of the value returned by
7186 @code{@var{S}'Image} when some of the graphic characters of
7187 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
7191 The sequence of characters is as defined by the wide character encoding
7192 method used for the source. See section on source representation for
7198 @strong{13}. The predefined integer types declared in
7199 @code{Standard}. See 3.5.4(25).
7203 @item Short_Short_Integer
7206 (Short) 16 bit signed
7210 64 bit signed (Alpha OpenVMS only)
7211 32 bit signed (all other targets)
7212 @item Long_Long_Integer
7219 @strong{14}. Any nonstandard integer types and the operators defined
7220 for them. See 3.5.4(26).
7223 There are no nonstandard integer types.
7228 @strong{15}. Any nonstandard real types and the operators defined for
7232 There are no nonstandard real types.
7237 @strong{16}. What combinations of requested decimal precision and range
7238 are supported for floating point types. See 3.5.7(7).
7241 The precision and range is as defined by the IEEE standard.
7246 @strong{17}. The predefined floating point types declared in
7247 @code{Standard}. See 3.5.7(16).
7254 (Short) 32 bit IEEE short
7257 @item Long_Long_Float
7258 64 bit IEEE long (80 bit IEEE long on x86 processors)
7264 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
7267 @code{Fine_Delta} is 2**(@minus{}63)
7272 @strong{19}. What combinations of small, range, and digits are
7273 supported for fixed point types. See 3.5.9(10).
7276 Any combinations are permitted that do not result in a small less than
7277 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7278 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7279 is 64 bits (true of all architectures except ia32), then the output from
7280 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
7281 is because floating-point conversions are used to convert fixed point.
7286 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
7287 within an unnamed @code{block_statement}. See 3.9(10).
7290 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7291 decimal integer are allocated.
7296 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
7299 @xref{Implementation Defined Attributes}.
7304 @strong{22}. Any implementation-defined time types. See 9.6(6).
7307 There are no implementation-defined time types.
7312 @strong{23}. The time base associated with relative delays.
7315 See 9.6(20). The time base used is that provided by the C library
7316 function @code{gettimeofday}.
7321 @strong{24}. The time base of the type @code{Calendar.Time}. See
7325 The time base used is that provided by the C library function
7326 @code{gettimeofday}.
7331 @strong{25}. The time zone used for package @code{Calendar}
7332 operations. See 9.6(24).
7335 The time zone used by package @code{Calendar} is the current system time zone
7336 setting for local time, as accessed by the C library function
7342 @strong{26}. Any limit on @code{delay_until_statements} of
7343 @code{select_statements}. See 9.6(29).
7346 There are no such limits.
7351 @strong{27}. Whether or not two non overlapping parts of a composite
7352 object are independently addressable, in the case where packing, record
7353 layout, or @code{Component_Size} is specified for the object. See
7357 Separate components are independently addressable if they do not share
7358 overlapping storage units.
7363 @strong{28}. The representation for a compilation. See 10.1(2).
7366 A compilation is represented by a sequence of files presented to the
7367 compiler in a single invocation of the @code{gcc} command.
7372 @strong{29}. Any restrictions on compilations that contain multiple
7373 compilation_units. See 10.1(4).
7376 No single file can contain more than one compilation unit, but any
7377 sequence of files can be presented to the compiler as a single
7383 @strong{30}. The mechanisms for creating an environment and for adding
7384 and replacing compilation units. See 10.1.4(3).
7387 See separate section on compilation model.
7392 @strong{31}. The manner of explicitly assigning library units to a
7393 partition. See 10.2(2).
7396 If a unit contains an Ada main program, then the Ada units for the partition
7397 are determined by recursive application of the rules in the Ada Reference
7398 Manual section 10.2(2-6). In other words, the Ada units will be those that
7399 are needed by the main program, and then this definition of need is applied
7400 recursively to those units, and the partition contains the transitive
7401 closure determined by this relationship. In short, all the necessary units
7402 are included, with no need to explicitly specify the list. If additional
7403 units are required, e.g.@: by foreign language units, then all units must be
7404 mentioned in the context clause of one of the needed Ada units.
7406 If the partition contains no main program, or if the main program is in
7407 a language other than Ada, then GNAT
7408 provides the binder options @code{-z} and @code{-n} respectively, and in
7409 this case a list of units can be explicitly supplied to the binder for
7410 inclusion in the partition (all units needed by these units will also
7411 be included automatically). For full details on the use of these
7412 options, refer to the @cite{GNAT User's Guide} sections on Binding
7418 @strong{32}. The implementation-defined means, if any, of specifying
7419 which compilation units are needed by a given compilation unit. See
7423 The units needed by a given compilation unit are as defined in
7424 the Ada Reference Manual section 10.2(2-6). There are no
7425 implementation-defined pragmas or other implementation-defined
7426 means for specifying needed units.
7431 @strong{33}. The manner of designating the main subprogram of a
7432 partition. See 10.2(7).
7435 The main program is designated by providing the name of the
7436 corresponding @file{ALI} file as the input parameter to the binder.
7441 @strong{34}. The order of elaboration of @code{library_items}. See
7445 The first constraint on ordering is that it meets the requirements of
7446 Chapter 10 of the Ada Reference Manual. This still leaves some
7447 implementation dependent choices, which are resolved by first
7448 elaborating bodies as early as possible (i.e., in preference to specs
7449 where there is a choice), and second by evaluating the immediate with
7450 clauses of a unit to determine the probably best choice, and
7451 third by elaborating in alphabetical order of unit names
7452 where a choice still remains.
7457 @strong{35}. Parameter passing and function return for the main
7458 subprogram. See 10.2(21).
7461 The main program has no parameters. It may be a procedure, or a function
7462 returning an integer type. In the latter case, the returned integer
7463 value is the return code of the program (overriding any value that
7464 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
7469 @strong{36}. The mechanisms for building and running partitions. See
7473 GNAT itself supports programs with only a single partition. The GNATDIST
7474 tool provided with the GLADE package (which also includes an implementation
7475 of the PCS) provides a completely flexible method for building and running
7476 programs consisting of multiple partitions. See the separate GLADE manual
7482 @strong{37}. The details of program execution, including program
7483 termination. See 10.2(25).
7486 See separate section on compilation model.
7491 @strong{38}. The semantics of any non-active partitions supported by the
7492 implementation. See 10.2(28).
7495 Passive partitions are supported on targets where shared memory is
7496 provided by the operating system. See the GLADE reference manual for
7502 @strong{39}. The information returned by @code{Exception_Message}. See
7506 Exception message returns the null string unless a specific message has
7507 been passed by the program.
7512 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
7513 declared within an unnamed @code{block_statement}. See 11.4.1(12).
7516 Blocks have implementation defined names of the form @code{B@var{nnn}}
7517 where @var{nnn} is an integer.
7522 @strong{41}. The information returned by
7523 @code{Exception_Information}. See 11.4.1(13).
7526 @code{Exception_Information} returns a string in the following format:
7529 @emph{Exception_Name:} nnnnn
7530 @emph{Message:} mmmmm
7532 @emph{Call stack traceback locations:}
7533 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
7541 @code{nnnn} is the fully qualified name of the exception in all upper
7542 case letters. This line is always present.
7545 @code{mmmm} is the message (this line present only if message is non-null)
7548 @code{ppp} is the Process Id value as a decimal integer (this line is
7549 present only if the Process Id is nonzero). Currently we are
7550 not making use of this field.
7553 The Call stack traceback locations line and the following values
7554 are present only if at least one traceback location was recorded.
7555 The values are given in C style format, with lower case letters
7556 for a-f, and only as many digits present as are necessary.
7560 The line terminator sequence at the end of each line, including
7561 the last line is a single @code{LF} character (@code{16#0A#}).
7566 @strong{42}. Implementation-defined check names. See 11.5(27).
7569 The implementation defined check name Alignment_Check controls checking of
7570 address clause values for proper alignment (that is, the address supplied
7571 must be consistent with the alignment of the type).
7573 In addition, a user program can add implementation-defined check names
7574 by means of the pragma Check_Name.
7579 @strong{43}. The interpretation of each aspect of representation. See
7583 See separate section on data representations.
7588 @strong{44}. Any restrictions placed upon representation items. See
7592 See separate section on data representations.
7597 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
7601 Size for an indefinite subtype is the maximum possible size, except that
7602 for the case of a subprogram parameter, the size of the parameter object
7608 @strong{46}. The default external representation for a type tag. See
7612 The default external representation for a type tag is the fully expanded
7613 name of the type in upper case letters.
7618 @strong{47}. What determines whether a compilation unit is the same in
7619 two different partitions. See 13.3(76).
7622 A compilation unit is the same in two different partitions if and only
7623 if it derives from the same source file.
7628 @strong{48}. Implementation-defined components. See 13.5.1(15).
7631 The only implementation defined component is the tag for a tagged type,
7632 which contains a pointer to the dispatching table.
7637 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
7638 ordering. See 13.5.3(5).
7641 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
7642 implementation, so no non-default bit ordering is supported. The default
7643 bit ordering corresponds to the natural endianness of the target architecture.
7648 @strong{50}. The contents of the visible part of package @code{System}
7649 and its language-defined children. See 13.7(2).
7652 See the definition of these packages in files @file{system.ads} and
7653 @file{s-stoele.ads}.
7658 @strong{51}. The contents of the visible part of package
7659 @code{System.Machine_Code}, and the meaning of
7660 @code{code_statements}. See 13.8(7).
7663 See the definition and documentation in file @file{s-maccod.ads}.
7668 @strong{52}. The effect of unchecked conversion. See 13.9(11).
7671 Unchecked conversion between types of the same size
7672 results in an uninterpreted transmission of the bits from one type
7673 to the other. If the types are of unequal sizes, then in the case of
7674 discrete types, a shorter source is first zero or sign extended as
7675 necessary, and a shorter target is simply truncated on the left.
7676 For all non-discrete types, the source is first copied if necessary
7677 to ensure that the alignment requirements of the target are met, then
7678 a pointer is constructed to the source value, and the result is obtained
7679 by dereferencing this pointer after converting it to be a pointer to the
7680 target type. Unchecked conversions where the target subtype is an
7681 unconstrained array are not permitted. If the target alignment is
7682 greater than the source alignment, then a copy of the result is
7683 made with appropriate alignment
7688 @strong{53}. The manner of choosing a storage pool for an access type
7689 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
7692 There are 3 different standard pools used by the compiler when
7693 @code{Storage_Pool} is not specified depending whether the type is local
7694 to a subprogram or defined at the library level and whether
7695 @code{Storage_Size}is specified or not. See documentation in the runtime
7696 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
7697 @code{System.Pool_Local} in files @file{s-poosiz.ads},
7698 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
7704 @strong{54}. Whether or not the implementation provides user-accessible
7705 names for the standard pool type(s). See 13.11(17).
7709 See documentation in the sources of the run time mentioned in paragraph
7710 @strong{53} . All these pools are accessible by means of @code{with}'ing
7716 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
7719 @code{Storage_Size} is measured in storage units, and refers to the
7720 total space available for an access type collection, or to the primary
7721 stack space for a task.
7726 @strong{56}. Implementation-defined aspects of storage pools. See
7730 See documentation in the sources of the run time mentioned in paragraph
7731 @strong{53} for details on GNAT-defined aspects of storage pools.
7736 @strong{57}. The set of restrictions allowed in a pragma
7737 @code{Restrictions}. See 13.12(7).
7740 All RM defined Restriction identifiers are implemented. The following
7741 additional restriction identifiers are provided. There are two separate
7742 lists of implementation dependent restriction identifiers. The first
7743 set requires consistency throughout a partition (in other words, if the
7744 restriction identifier is used for any compilation unit in the partition,
7745 then all compilation units in the partition must obey the restriction.
7749 @item Simple_Barriers
7750 @findex Simple_Barriers
7751 This restriction ensures at compile time that barriers in entry declarations
7752 for protected types are restricted to either static boolean expressions or
7753 references to simple boolean variables defined in the private part of the
7754 protected type. No other form of entry barriers is permitted. This is one
7755 of the restrictions of the Ravenscar profile for limited tasking (see also
7756 pragma @code{Profile (Ravenscar)}).
7758 @item Max_Entry_Queue_Length => Expr
7759 @findex Max_Entry_Queue_Length
7760 This restriction is a declaration that any protected entry compiled in
7761 the scope of the restriction has at most the specified number of
7762 tasks waiting on the entry
7763 at any one time, and so no queue is required. This restriction is not
7764 checked at compile time. A program execution is erroneous if an attempt
7765 is made to queue more than the specified number of tasks on such an entry.
7769 This restriction ensures at compile time that there is no implicit or
7770 explicit dependence on the package @code{Ada.Calendar}.
7772 @item No_Direct_Boolean_Operators
7773 @findex No_Direct_Boolean_Operators
7774 This restriction ensures that no logical (and/or/xor) or comparison
7775 operators are used on operands of type Boolean (or any type derived
7776 from Boolean). This is intended for use in safety critical programs
7777 where the certification protocol requires the use of short-circuit
7778 (and then, or else) forms for all composite boolean operations.
7780 @item No_Dispatching_Calls
7781 @findex No_Dispatching_Calls
7782 This restriction ensures at compile time that the code generated by the
7783 compiler involves no dispatching calls. The use of this restriction allows the
7784 safe use of record extensions, classwide membership tests and other classwide
7785 features not involving implicit dispatching. This restriction ensures that
7786 the code contains no indirect calls through a dispatching mechanism. Note that
7787 this includes internally-generated calls created by the compiler, for example
7788 in the implementation of class-wide objects assignments. The
7789 membership test is allowed in the presence of this restriction, because its
7790 implementation requires no dispatching.
7791 This restriction is comparable to the official Ada restriction
7792 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7793 all classwide constructs that do not imply dispatching.
7794 The following example indicates constructs that violate this restriction.
7798 type T is tagged record
7801 procedure P (X : T);
7803 type DT is new T with record
7804 More_Data : Natural;
7806 procedure Q (X : DT);
7810 procedure Example is
7811 procedure Test (O : T'Class) is
7812 N : Natural := O'Size;-- Error: Dispatching call
7813 C : T'Class := O; -- Error: implicit Dispatching Call
7815 if O in DT'Class then -- OK : Membership test
7816 Q (DT (O)); -- OK : Type conversion plus direct call
7818 P (O); -- Error: Dispatching call
7824 P (Obj); -- OK : Direct call
7825 P (T (Obj)); -- OK : Type conversion plus direct call
7826 P (T'Class (Obj)); -- Error: Dispatching call
7828 Test (Obj); -- OK : Type conversion
7830 if Obj in T'Class then -- OK : Membership test
7836 @item No_Dynamic_Attachment
7837 @findex No_Dynamic_Attachment
7838 This restriction ensures that there is no call to any of the operations
7839 defined in package Ada.Interrupts.
7841 @item No_Enumeration_Maps
7842 @findex No_Enumeration_Maps
7843 This restriction ensures at compile time that no operations requiring
7844 enumeration maps are used (that is Image and Value attributes applied
7845 to enumeration types).
7847 @item No_Entry_Calls_In_Elaboration_Code
7848 @findex No_Entry_Calls_In_Elaboration_Code
7849 This restriction ensures at compile time that no task or protected entry
7850 calls are made during elaboration code. As a result of the use of this
7851 restriction, the compiler can assume that no code past an accept statement
7852 in a task can be executed at elaboration time.
7854 @item No_Exception_Handlers
7855 @findex No_Exception_Handlers
7856 This restriction ensures at compile time that there are no explicit
7857 exception handlers. It also indicates that no exception propagation will
7858 be provided. In this mode, exceptions may be raised but will result in
7859 an immediate call to the last chance handler, a routine that the user
7860 must define with the following profile:
7862 procedure Last_Chance_Handler
7863 (Source_Location : System.Address; Line : Integer);
7864 pragma Export (C, Last_Chance_Handler,
7865 "__gnat_last_chance_handler");
7867 The parameter is a C null-terminated string representing a message to be
7868 associated with the exception (typically the source location of the raise
7869 statement generated by the compiler). The Line parameter when nonzero
7870 represents the line number in the source program where the raise occurs.
7872 @item No_Exception_Propagation
7873 @findex No_Exception_Propagation
7874 This restriction guarantees that exceptions are never propagated to an outer
7875 subprogram scope). The only case in which an exception may be raised is when
7876 the handler is statically in the same subprogram, so that the effect of a raise
7877 is essentially like a goto statement. Any other raise statement (implicit or
7878 explicit) will be considered unhandled. Exception handlers are allowed, but may
7879 not contain an exception occurrence identifier (exception choice). In addition
7880 use of the package GNAT.Current_Exception is not permitted, and reraise
7881 statements (raise with no operand) are not permitted.
7883 @item No_Exception_Registration
7884 @findex No_Exception_Registration
7885 This restriction ensures at compile time that no stream operations for
7886 types Exception_Id or Exception_Occurrence are used. This also makes it
7887 impossible to pass exceptions to or from a partition with this restriction
7888 in a distributed environment. If this exception is active, then the generated
7889 code is simplified by omitting the otherwise-required global registration
7890 of exceptions when they are declared.
7892 @item No_Implicit_Conditionals
7893 @findex No_Implicit_Conditionals
7894 This restriction ensures that the generated code does not contain any
7895 implicit conditionals, either by modifying the generated code where possible,
7896 or by rejecting any construct that would otherwise generate an implicit
7897 conditional. Note that this check does not include run time constraint
7898 checks, which on some targets may generate implicit conditionals as
7899 well. To control the latter, constraint checks can be suppressed in the
7900 normal manner. Constructs generating implicit conditionals include comparisons
7901 of composite objects and the Max/Min attributes.
7903 @item No_Implicit_Dynamic_Code
7904 @findex No_Implicit_Dynamic_Code
7905 This restriction prevents the compiler from building ``trampolines''.
7906 This is a structure that is built on the stack and contains dynamic
7907 code to be executed at run time. On some targets, a trampoline is
7908 built for the following features: @code{Access},
7909 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
7910 nested task bodies; primitive operations of nested tagged types.
7911 Trampolines do not work on machines that prevent execution of stack
7912 data. For example, on windows systems, enabling DEP (data execution
7913 protection) will cause trampolines to raise an exception.
7915 @item No_Implicit_Loops
7916 @findex No_Implicit_Loops
7917 This restriction ensures that the generated code does not contain any
7918 implicit @code{for} loops, either by modifying
7919 the generated code where possible,
7920 or by rejecting any construct that would otherwise generate an implicit
7921 @code{for} loop. If this restriction is active, it is possible to build
7922 large array aggregates with all static components without generating an
7923 intermediate temporary, and without generating a loop to initialize individual
7924 components..Otherwise, a loop is created for arrays larger than about 5000
7927 @item No_Initialize_Scalars
7928 @findex No_Initialize_Scalars
7929 This restriction ensures that no unit in the partition is compiled with
7930 pragma Initialize_Scalars. This allows the generation of more efficient
7931 code, and in particular eliminates dummy null initialization routines that
7932 are otherwise generated for some record and array types.
7934 @item No_Local_Protected_Objects
7935 @findex No_Local_Protected_Objects
7936 This restriction ensures at compile time that protected objects are
7937 only declared at the library level.
7939 @item No_Protected_Type_Allocators
7940 @findex No_Protected_Type_Allocators
7941 This restriction ensures at compile time that there are no allocator
7942 expressions that attempt to allocate protected objects.
7944 @item No_Secondary_Stack
7945 @findex No_Secondary_Stack
7946 This restriction ensures at compile time that the generated code does not
7947 contain any reference to the secondary stack. The secondary stack is used
7948 to implement functions returning unconstrained objects (arrays or records)
7951 @item No_Select_Statements
7952 @findex No_Select_Statements
7953 This restriction ensures at compile time no select statements of any kind
7954 are permitted, that is the keyword @code{select} may not appear.
7955 This is one of the restrictions of the Ravenscar
7956 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7958 @item No_Standard_Storage_Pools
7959 @findex No_Standard_Storage_Pools
7960 This restriction ensures at compile time that no access types
7961 use the standard default storage pool. Any access type declared must
7962 have an explicit Storage_Pool attribute defined specifying a
7963 user-defined storage pool.
7967 This restriction ensures at compile/bind time that there are no
7968 stream objects created (and therefore no actual stream operations).
7969 This restriction does not forbid dependences on the package
7970 @code{Ada.Streams}. So it is permissible to with
7971 @code{Ada.Streams} (or another package that does so itself)
7972 as long as no actual stream objects are created.
7974 @item No_Task_Attributes_Package
7975 @findex No_Task_Attributes_Package
7976 This restriction ensures at compile time that there are no implicit or
7977 explicit dependencies on the package @code{Ada.Task_Attributes}.
7979 @item No_Task_Termination
7980 @findex No_Task_Termination
7981 This restriction ensures at compile time that no terminate alternatives
7982 appear in any task body.
7986 This restriction prevents the declaration of tasks or task types throughout
7987 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
7988 except that violations are caught at compile time and cause an error message
7989 to be output either by the compiler or binder.
7991 @item Static_Priorities
7992 @findex Static_Priorities
7993 This restriction ensures at compile time that all priority expressions
7994 are static, and that there are no dependencies on the package
7995 @code{Ada.Dynamic_Priorities}.
7997 @item Static_Storage_Size
7998 @findex Static_Storage_Size
7999 This restriction ensures at compile time that any expression appearing
8000 in a Storage_Size pragma or attribute definition clause is static.
8005 The second set of implementation dependent restriction identifiers
8006 does not require partition-wide consistency.
8007 The restriction may be enforced for a single
8008 compilation unit without any effect on any of the
8009 other compilation units in the partition.
8013 @item No_Elaboration_Code
8014 @findex No_Elaboration_Code
8015 This restriction ensures at compile time that no elaboration code is
8016 generated. Note that this is not the same condition as is enforced
8017 by pragma @code{Preelaborate}. There are cases in which pragma
8018 @code{Preelaborate} still permits code to be generated (e.g.@: code
8019 to initialize a large array to all zeroes), and there are cases of units
8020 which do not meet the requirements for pragma @code{Preelaborate},
8021 but for which no elaboration code is generated. Generally, it is
8022 the case that preelaborable units will meet the restrictions, with
8023 the exception of large aggregates initialized with an others_clause,
8024 and exception declarations (which generate calls to a run-time
8025 registry procedure). This restriction is enforced on
8026 a unit by unit basis, it need not be obeyed consistently
8027 throughout a partition.
8029 In the case of aggregates with others, if the aggregate has a dynamic
8030 size, there is no way to eliminate the elaboration code (such dynamic
8031 bounds would be incompatible with @code{Preelaborate} in any case). If
8032 the bounds are static, then use of this restriction actually modifies
8033 the code choice of the compiler to avoid generating a loop, and instead
8034 generate the aggregate statically if possible, no matter how many times
8035 the data for the others clause must be repeatedly generated.
8037 It is not possible to precisely document
8038 the constructs which are compatible with this restriction, since,
8039 unlike most other restrictions, this is not a restriction on the
8040 source code, but a restriction on the generated object code. For
8041 example, if the source contains a declaration:
8044 Val : constant Integer := X;
8048 where X is not a static constant, it may be possible, depending
8049 on complex optimization circuitry, for the compiler to figure
8050 out the value of X at compile time, in which case this initialization
8051 can be done by the loader, and requires no initialization code. It
8052 is not possible to document the precise conditions under which the
8053 optimizer can figure this out.
8055 Note that this the implementation of this restriction requires full
8056 code generation. If it is used in conjunction with "semantics only"
8057 checking, then some cases of violations may be missed.
8059 @item No_Entry_Queue
8060 @findex No_Entry_Queue
8061 This restriction is a declaration that any protected entry compiled in
8062 the scope of the restriction has at most one task waiting on the entry
8063 at any one time, and so no queue is required. This restriction is not
8064 checked at compile time. A program execution is erroneous if an attempt
8065 is made to queue a second task on such an entry.
8067 @item No_Implementation_Attributes
8068 @findex No_Implementation_Attributes
8069 This restriction checks at compile time that no GNAT-defined attributes
8070 are present. With this restriction, the only attributes that can be used
8071 are those defined in the Ada Reference Manual.
8073 @item No_Implementation_Pragmas
8074 @findex No_Implementation_Pragmas
8075 This restriction checks at compile time that no GNAT-defined pragmas
8076 are present. With this restriction, the only pragmas that can be used
8077 are those defined in the Ada Reference Manual.
8079 @item No_Implementation_Restrictions
8080 @findex No_Implementation_Restrictions
8081 This restriction checks at compile time that no GNAT-defined restriction
8082 identifiers (other than @code{No_Implementation_Restrictions} itself)
8083 are present. With this restriction, the only other restriction identifiers
8084 that can be used are those defined in the Ada Reference Manual.
8086 @item No_Wide_Characters
8087 @findex No_Wide_Characters
8088 This restriction ensures at compile time that no uses of the types
8089 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8091 appear, and that no wide or wide wide string or character literals
8092 appear in the program (that is literals representing characters not in
8093 type @code{Character}.
8100 @strong{58}. The consequences of violating limitations on
8101 @code{Restrictions} pragmas. See 13.12(9).
8104 Restrictions that can be checked at compile time result in illegalities
8105 if violated. Currently there are no other consequences of violating
8111 @strong{59}. The representation used by the @code{Read} and
8112 @code{Write} attributes of elementary types in terms of stream
8113 elements. See 13.13.2(9).
8116 The representation is the in-memory representation of the base type of
8117 the type, using the number of bits corresponding to the
8118 @code{@var{type}'Size} value, and the natural ordering of the machine.
8123 @strong{60}. The names and characteristics of the numeric subtypes
8124 declared in the visible part of package @code{Standard}. See A.1(3).
8127 See items describing the integer and floating-point types supported.
8132 @strong{61}. The accuracy actually achieved by the elementary
8133 functions. See A.5.1(1).
8136 The elementary functions correspond to the functions available in the C
8137 library. Only fast math mode is implemented.
8142 @strong{62}. The sign of a zero result from some of the operators or
8143 functions in @code{Numerics.Generic_Elementary_Functions}, when
8144 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
8147 The sign of zeroes follows the requirements of the IEEE 754 standard on
8153 @strong{63}. The value of
8154 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
8157 Maximum image width is 649, see library file @file{a-numran.ads}.
8162 @strong{64}. The value of
8163 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
8166 Maximum image width is 80, see library file @file{a-nudira.ads}.
8171 @strong{65}. The algorithms for random number generation. See
8175 The algorithm is documented in the source files @file{a-numran.ads} and
8176 @file{a-numran.adb}.
8181 @strong{66}. The string representation of a random number generator's
8182 state. See A.5.2(38).
8185 See the documentation contained in the file @file{a-numran.adb}.
8190 @strong{67}. The minimum time interval between calls to the
8191 time-dependent Reset procedure that are guaranteed to initiate different
8192 random number sequences. See A.5.2(45).
8195 The minimum period between reset calls to guarantee distinct series of
8196 random numbers is one microsecond.
8201 @strong{68}. The values of the @code{Model_Mantissa},
8202 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8203 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8204 Annex is not supported. See A.5.3(72).
8207 See the source file @file{ttypef.ads} for the values of all numeric
8213 @strong{69}. Any implementation-defined characteristics of the
8214 input-output packages. See A.7(14).
8217 There are no special implementation defined characteristics for these
8223 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
8227 All type representations are contiguous, and the @code{Buffer_Size} is
8228 the value of @code{@var{type}'Size} rounded up to the next storage unit
8234 @strong{71}. External files for standard input, standard output, and
8235 standard error See A.10(5).
8238 These files are mapped onto the files provided by the C streams
8239 libraries. See source file @file{i-cstrea.ads} for further details.
8244 @strong{72}. The accuracy of the value produced by @code{Put}. See
8248 If more digits are requested in the output than are represented by the
8249 precision of the value, zeroes are output in the corresponding least
8250 significant digit positions.
8255 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
8256 @code{Command_Name}. See A.15(1).
8259 These are mapped onto the @code{argv} and @code{argc} parameters of the
8260 main program in the natural manner.
8265 @strong{74}. Implementation-defined convention names. See B.1(11).
8268 The following convention names are supported
8276 Synonym for Assembler
8278 Synonym for Assembler
8281 @item C_Pass_By_Copy
8282 Allowed only for record types, like C, but also notes that record
8283 is to be passed by copy rather than reference.
8286 @item C_Plus_Plus (or CPP)
8289 Treated the same as C
8291 Treated the same as C
8295 For support of pragma @code{Import} with convention Intrinsic, see
8296 separate section on Intrinsic Subprograms.
8298 Stdcall (used for Windows implementations only). This convention correspond
8299 to the WINAPI (previously called Pascal convention) C/C++ convention under
8300 Windows. A function with this convention cleans the stack before exit.
8306 Stubbed is a special convention used to indicate that the body of the
8307 subprogram will be entirely ignored. Any call to the subprogram
8308 is converted into a raise of the @code{Program_Error} exception. If a
8309 pragma @code{Import} specifies convention @code{stubbed} then no body need
8310 be present at all. This convention is useful during development for the
8311 inclusion of subprograms whose body has not yet been written.
8315 In addition, all otherwise unrecognized convention names are also
8316 treated as being synonymous with convention C@. In all implementations
8317 except for VMS, use of such other names results in a warning. In VMS
8318 implementations, these names are accepted silently.
8323 @strong{75}. The meaning of link names. See B.1(36).
8326 Link names are the actual names used by the linker.
8331 @strong{76}. The manner of choosing link names when neither the link
8332 name nor the address of an imported or exported entity is specified. See
8336 The default linker name is that which would be assigned by the relevant
8337 external language, interpreting the Ada name as being in all lower case
8343 @strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37).
8346 The string passed to @code{Linker_Options} is presented uninterpreted as
8347 an argument to the link command, unless it contains Ascii.NUL characters.
8348 NUL characters if they appear act as argument separators, so for example
8350 @smallexample @c ada
8351 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
8355 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8356 linker. The order of linker options is preserved for a given unit. The final
8357 list of options passed to the linker is in reverse order of the elaboration
8358 order. For example, linker options fo a body always appear before the options
8359 from the corresponding package spec.
8364 @strong{78}. The contents of the visible part of package
8365 @code{Interfaces} and its language-defined descendants. See B.2(1).
8368 See files with prefix @file{i-} in the distributed library.
8373 @strong{79}. Implementation-defined children of package
8374 @code{Interfaces}. The contents of the visible part of package
8375 @code{Interfaces}. See B.2(11).
8378 See files with prefix @file{i-} in the distributed library.
8383 @strong{80}. The types @code{Floating}, @code{Long_Floating},
8384 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
8385 @code{COBOL_Character}; and the initialization of the variables
8386 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
8387 @code{Interfaces.COBOL}. See B.4(50).
8394 (Floating) Long_Float
8399 @item Decimal_Element
8401 @item COBOL_Character
8406 For initialization, see the file @file{i-cobol.ads} in the distributed library.
8411 @strong{81}. Support for access to machine instructions. See C.1(1).
8414 See documentation in file @file{s-maccod.ads} in the distributed library.
8419 @strong{82}. Implementation-defined aspects of access to machine
8420 operations. See C.1(9).
8423 See documentation in file @file{s-maccod.ads} in the distributed library.
8428 @strong{83}. Implementation-defined aspects of interrupts. See C.3(2).
8431 Interrupts are mapped to signals or conditions as appropriate. See
8433 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
8434 on the interrupts supported on a particular target.
8439 @strong{84}. Implementation-defined aspects of pre-elaboration. See
8443 GNAT does not permit a partition to be restarted without reloading,
8444 except under control of the debugger.
8449 @strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7).
8452 Pragma @code{Discard_Names} causes names of enumeration literals to
8453 be suppressed. In the presence of this pragma, the Image attribute
8454 provides the image of the Pos of the literal, and Value accepts
8460 @strong{86}. The result of the @code{Task_Identification.Image}
8461 attribute. See C.7.1(7).
8464 The result of this attribute is a string that identifies
8465 the object or component that denotes a given task. If a variable Var has a task
8466 type, the image for this task will have the form Var_XXXXXXXX, where the
8468 is the hexadecimal representation of the virtual address of the corresponding
8469 task control block. If the variable is an array of tasks, the image of each
8470 task will have the form of an indexed component indicating the position of a
8471 given task in the array, eg. Group(5)_XXXXXXX. If the task is a
8472 component of a record, the image of the task will have the form of a selected
8473 component. These rules are fully recursive, so that the image of a task that
8474 is a subcomponent of a composite object corresponds to the expression that
8475 designates this task.
8477 If a task is created by an allocator, its image depends on the context. If the
8478 allocator is part of an object declaration, the rules described above are used
8479 to construct its image, and this image is not affected by subsequent
8480 assignments. If the allocator appears within an expression, the image
8481 includes only the name of the task type.
8483 If the configuration pragma Discard_Names is present, or if the restriction
8484 No_Implicit_Heap_Allocation is in effect, the image reduces to
8485 the numeric suffix, that is to say the hexadecimal representation of the
8486 virtual address of the control block of the task.
8490 @strong{87}. The value of @code{Current_Task} when in a protected entry
8491 or interrupt handler. See C.7.1(17).
8494 Protected entries or interrupt handlers can be executed by any
8495 convenient thread, so the value of @code{Current_Task} is undefined.
8500 @strong{88}. The effect of calling @code{Current_Task} from an entry
8501 body or interrupt handler. See C.7.1(19).
8504 The effect of calling @code{Current_Task} from an entry body or
8505 interrupt handler is to return the identification of the task currently
8511 @strong{89}. Implementation-defined aspects of
8512 @code{Task_Attributes}. See C.7.2(19).
8515 There are no implementation-defined aspects of @code{Task_Attributes}.
8520 @strong{90}. Values of all @code{Metrics}. See D(2).
8523 The metrics information for GNAT depends on the performance of the
8524 underlying operating system. The sources of the run-time for tasking
8525 implementation, together with the output from @code{-gnatG} can be
8526 used to determine the exact sequence of operating systems calls made
8527 to implement various tasking constructs. Together with appropriate
8528 information on the performance of the underlying operating system,
8529 on the exact target in use, this information can be used to determine
8530 the required metrics.
8535 @strong{91}. The declarations of @code{Any_Priority} and
8536 @code{Priority}. See D.1(11).
8539 See declarations in file @file{system.ads}.
8544 @strong{92}. Implementation-defined execution resources. See D.1(15).
8547 There are no implementation-defined execution resources.
8552 @strong{93}. Whether, on a multiprocessor, a task that is waiting for
8553 access to a protected object keeps its processor busy. See D.2.1(3).
8556 On a multi-processor, a task that is waiting for access to a protected
8557 object does not keep its processor busy.
8562 @strong{94}. The affect of implementation defined execution resources
8563 on task dispatching. See D.2.1(9).
8568 Tasks map to IRIX threads, and the dispatching policy is as defined by
8569 the IRIX implementation of threads.
8571 Tasks map to threads in the threads package used by GNAT@. Where possible
8572 and appropriate, these threads correspond to native threads of the
8573 underlying operating system.
8578 @strong{95}. Implementation-defined @code{policy_identifiers} allowed
8579 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
8582 There are no implementation-defined policy-identifiers allowed in this
8588 @strong{96}. Implementation-defined aspects of priority inversion. See
8592 Execution of a task cannot be preempted by the implementation processing
8593 of delay expirations for lower priority tasks.
8598 @strong{97}. Implementation defined task dispatching. See D.2.2(18).
8603 Tasks map to IRIX threads, and the dispatching policy is as defined by
8604 the IRIX implementation of threads.
8606 The policy is the same as that of the underlying threads implementation.
8611 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
8612 in a pragma @code{Locking_Policy}. See D.3(4).
8615 The only implementation defined policy permitted in GNAT is
8616 @code{Inheritance_Locking}. On targets that support this policy, locking
8617 is implemented by inheritance, i.e.@: the task owning the lock operates
8618 at a priority equal to the highest priority of any task currently
8619 requesting the lock.
8624 @strong{99}. Default ceiling priorities. See D.3(10).
8627 The ceiling priority of protected objects of the type
8628 @code{System.Interrupt_Priority'Last} as described in the Ada
8629 Reference Manual D.3(10),
8634 @strong{100}. The ceiling of any protected object used internally by
8635 the implementation. See D.3(16).
8638 The ceiling priority of internal protected objects is
8639 @code{System.Priority'Last}.
8644 @strong{101}. Implementation-defined queuing policies. See D.4(1).
8647 There are no implementation-defined queuing policies.
8652 @strong{102}. On a multiprocessor, any conditions that cause the
8653 completion of an aborted construct to be delayed later than what is
8654 specified for a single processor. See D.6(3).
8657 The semantics for abort on a multi-processor is the same as on a single
8658 processor, there are no further delays.
8663 @strong{103}. Any operations that implicitly require heap storage
8664 allocation. See D.7(8).
8667 The only operation that implicitly requires heap storage allocation is
8673 @strong{104}. Implementation-defined aspects of pragma
8674 @code{Restrictions}. See D.7(20).
8677 There are no such implementation-defined aspects.
8682 @strong{105}. Implementation-defined aspects of package
8683 @code{Real_Time}. See D.8(17).
8686 There are no implementation defined aspects of package @code{Real_Time}.
8691 @strong{106}. Implementation-defined aspects of
8692 @code{delay_statements}. See D.9(8).
8695 Any difference greater than one microsecond will cause the task to be
8696 delayed (see D.9(7)).
8701 @strong{107}. The upper bound on the duration of interrupt blocking
8702 caused by the implementation. See D.12(5).
8705 The upper bound is determined by the underlying operating system. In
8706 no cases is it more than 10 milliseconds.
8711 @strong{108}. The means for creating and executing distributed
8715 The GLADE package provides a utility GNATDIST for creating and executing
8716 distributed programs. See the GLADE reference manual for further details.
8721 @strong{109}. Any events that can result in a partition becoming
8722 inaccessible. See E.1(7).
8725 See the GLADE reference manual for full details on such events.
8730 @strong{110}. The scheduling policies, treatment of priorities, and
8731 management of shared resources between partitions in certain cases. See
8735 See the GLADE reference manual for full details on these aspects of
8736 multi-partition execution.
8741 @strong{111}. Events that cause the version of a compilation unit to
8745 Editing the source file of a compilation unit, or the source files of
8746 any units on which it is dependent in a significant way cause the version
8747 to change. No other actions cause the version number to change. All changes
8748 are significant except those which affect only layout, capitalization or
8754 @strong{112}. Whether the execution of the remote subprogram is
8755 immediately aborted as a result of cancellation. See E.4(13).
8758 See the GLADE reference manual for details on the effect of abort in
8759 a distributed application.
8764 @strong{113}. Implementation-defined aspects of the PCS@. See E.5(25).
8767 See the GLADE reference manual for a full description of all implementation
8768 defined aspects of the PCS@.
8773 @strong{114}. Implementation-defined interfaces in the PCS@. See
8777 See the GLADE reference manual for a full description of all
8778 implementation defined interfaces.
8783 @strong{115}. The values of named numbers in the package
8784 @code{Decimal}. See F.2(7).
8796 @item Max_Decimal_Digits
8803 @strong{116}. The value of @code{Max_Picture_Length} in the package
8804 @code{Text_IO.Editing}. See F.3.3(16).
8812 @strong{117}. The value of @code{Max_Picture_Length} in the package
8813 @code{Wide_Text_IO.Editing}. See F.3.4(5).
8821 @strong{118}. The accuracy actually achieved by the complex elementary
8822 functions and by other complex arithmetic operations. See G.1(1).
8825 Standard library functions are used for the complex arithmetic
8826 operations. Only fast math mode is currently supported.
8831 @strong{119}. The sign of a zero result (or a component thereof) from
8832 any operator or function in @code{Numerics.Generic_Complex_Types}, when
8833 @code{Real'Signed_Zeros} is True. See G.1.1(53).
8836 The signs of zero values are as recommended by the relevant
8837 implementation advice.
8842 @strong{120}. The sign of a zero result (or a component thereof) from
8843 any operator or function in
8844 @code{Numerics.Generic_Complex_Elementary_Functions}, when
8845 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
8848 The signs of zero values are as recommended by the relevant
8849 implementation advice.
8854 @strong{121}. Whether the strict mode or the relaxed mode is the
8855 default. See G.2(2).
8858 The strict mode is the default. There is no separate relaxed mode. GNAT
8859 provides a highly efficient implementation of strict mode.
8864 @strong{122}. The result interval in certain cases of fixed-to-float
8865 conversion. See G.2.1(10).
8868 For cases where the result interval is implementation dependent, the
8869 accuracy is that provided by performing all operations in 64-bit IEEE
8870 floating-point format.
8875 @strong{123}. The result of a floating point arithmetic operation in
8876 overflow situations, when the @code{Machine_Overflows} attribute of the
8877 result type is @code{False}. See G.2.1(13).
8880 Infinite and NaN values are produced as dictated by the IEEE
8881 floating-point standard.
8883 Note that on machines that are not fully compliant with the IEEE
8884 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
8885 must be used for achieving IEEE confirming behavior (although at the cost
8886 of a significant performance penalty), so infinite and NaN values are
8892 @strong{124}. The result interval for division (or exponentiation by a
8893 negative exponent), when the floating point hardware implements division
8894 as multiplication by a reciprocal. See G.2.1(16).
8897 Not relevant, division is IEEE exact.
8902 @strong{125}. The definition of close result set, which determines the
8903 accuracy of certain fixed point multiplications and divisions. See
8907 Operations in the close result set are performed using IEEE long format
8908 floating-point arithmetic. The input operands are converted to
8909 floating-point, the operation is done in floating-point, and the result
8910 is converted to the target type.
8915 @strong{126}. Conditions on a @code{universal_real} operand of a fixed
8916 point multiplication or division for which the result shall be in the
8917 perfect result set. See G.2.3(22).
8920 The result is only defined to be in the perfect result set if the result
8921 can be computed by a single scaling operation involving a scale factor
8922 representable in 64-bits.
8927 @strong{127}. The result of a fixed point arithmetic operation in
8928 overflow situations, when the @code{Machine_Overflows} attribute of the
8929 result type is @code{False}. See G.2.3(27).
8932 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
8938 @strong{128}. The result of an elementary function reference in
8939 overflow situations, when the @code{Machine_Overflows} attribute of the
8940 result type is @code{False}. See G.2.4(4).
8943 IEEE infinite and Nan values are produced as appropriate.
8948 @strong{129}. The value of the angle threshold, within which certain
8949 elementary functions, complex arithmetic operations, and complex
8950 elementary functions yield results conforming to a maximum relative
8951 error bound. See G.2.4(10).
8954 Information on this subject is not yet available.
8959 @strong{130}. The accuracy of certain elementary functions for
8960 parameters beyond the angle threshold. See G.2.4(10).
8963 Information on this subject is not yet available.
8968 @strong{131}. The result of a complex arithmetic operation or complex
8969 elementary function reference in overflow situations, when the
8970 @code{Machine_Overflows} attribute of the corresponding real type is
8971 @code{False}. See G.2.6(5).
8974 IEEE infinite and Nan values are produced as appropriate.
8979 @strong{132}. The accuracy of certain complex arithmetic operations and
8980 certain complex elementary functions for parameters (or components
8981 thereof) beyond the angle threshold. See G.2.6(8).
8984 Information on those subjects is not yet available.
8989 @strong{133}. Information regarding bounded errors and erroneous
8990 execution. See H.2(1).
8993 Information on this subject is not yet available.
8998 @strong{134}. Implementation-defined aspects of pragma
8999 @code{Inspection_Point}. See H.3.2(8).
9002 Pragma @code{Inspection_Point} ensures that the variable is live and can
9003 be examined by the debugger at the inspection point.
9008 @strong{135}. Implementation-defined aspects of pragma
9009 @code{Restrictions}. See H.4(25).
9012 There are no implementation-defined aspects of pragma @code{Restrictions}. The
9013 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9014 generated code. Checks must suppressed by use of pragma @code{Suppress}.
9019 @strong{136}. Any restrictions on pragma @code{Restrictions}. See
9023 There are no restrictions on pragma @code{Restrictions}.
9025 @node Intrinsic Subprograms
9026 @chapter Intrinsic Subprograms
9027 @cindex Intrinsic Subprograms
9030 * Intrinsic Operators::
9031 * Enclosing_Entity::
9032 * Exception_Information::
9033 * Exception_Message::
9041 * Shift_Right_Arithmetic::
9046 GNAT allows a user application program to write the declaration:
9048 @smallexample @c ada
9049 pragma Import (Intrinsic, name);
9053 providing that the name corresponds to one of the implemented intrinsic
9054 subprograms in GNAT, and that the parameter profile of the referenced
9055 subprogram meets the requirements. This chapter describes the set of
9056 implemented intrinsic subprograms, and the requirements on parameter profiles.
9057 Note that no body is supplied; as with other uses of pragma Import, the
9058 body is supplied elsewhere (in this case by the compiler itself). Note
9059 that any use of this feature is potentially non-portable, since the
9060 Ada standard does not require Ada compilers to implement this feature.
9062 @node Intrinsic Operators
9063 @section Intrinsic Operators
9064 @cindex Intrinsic operator
9067 All the predefined numeric operators in package Standard
9068 in @code{pragma Import (Intrinsic,..)}
9069 declarations. In the binary operator case, the operands must have the same
9070 size. The operand or operands must also be appropriate for
9071 the operator. For example, for addition, the operands must
9072 both be floating-point or both be fixed-point, and the
9073 right operand for @code{"**"} must have a root type of
9074 @code{Standard.Integer'Base}.
9075 You can use an intrinsic operator declaration as in the following example:
9077 @smallexample @c ada
9078 type Int1 is new Integer;
9079 type Int2 is new Integer;
9081 function "+" (X1 : Int1; X2 : Int2) return Int1;
9082 function "+" (X1 : Int1; X2 : Int2) return Int2;
9083 pragma Import (Intrinsic, "+");
9087 This declaration would permit ``mixed mode'' arithmetic on items
9088 of the differing types @code{Int1} and @code{Int2}.
9089 It is also possible to specify such operators for private types, if the
9090 full views are appropriate arithmetic types.
9092 @node Enclosing_Entity
9093 @section Enclosing_Entity
9094 @cindex Enclosing_Entity
9096 This intrinsic subprogram is used in the implementation of the
9097 library routine @code{GNAT.Source_Info}. The only useful use of the
9098 intrinsic import in this case is the one in this unit, so an
9099 application program should simply call the function
9100 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9101 the current subprogram, package, task, entry, or protected subprogram.
9103 @node Exception_Information
9104 @section Exception_Information
9105 @cindex Exception_Information'
9107 This intrinsic subprogram is used in the implementation of the
9108 library routine @code{GNAT.Current_Exception}. The only useful
9109 use of the intrinsic import in this case is the one in this unit,
9110 so an application program should simply call the function
9111 @code{GNAT.Current_Exception.Exception_Information} to obtain
9112 the exception information associated with the current exception.
9114 @node Exception_Message
9115 @section Exception_Message
9116 @cindex Exception_Message
9118 This intrinsic subprogram is used in the implementation of the
9119 library routine @code{GNAT.Current_Exception}. The only useful
9120 use of the intrinsic import in this case is the one in this unit,
9121 so an application program should simply call the function
9122 @code{GNAT.Current_Exception.Exception_Message} to obtain
9123 the message associated with the current exception.
9125 @node Exception_Name
9126 @section Exception_Name
9127 @cindex Exception_Name
9129 This intrinsic subprogram is used in the implementation of the
9130 library routine @code{GNAT.Current_Exception}. The only useful
9131 use of the intrinsic import in this case is the one in this unit,
9132 so an application program should simply call the function
9133 @code{GNAT.Current_Exception.Exception_Name} to obtain
9134 the name of the current exception.
9140 This intrinsic subprogram is used in the implementation of the
9141 library routine @code{GNAT.Source_Info}. The only useful use of the
9142 intrinsic import in this case is the one in this unit, so an
9143 application program should simply call the function
9144 @code{GNAT.Source_Info.File} to obtain the name of the current
9151 This intrinsic subprogram is used in the implementation of the
9152 library routine @code{GNAT.Source_Info}. The only useful use of the
9153 intrinsic import in this case is the one in this unit, so an
9154 application program should simply call the function
9155 @code{GNAT.Source_Info.Line} to obtain the number of the current
9159 @section Rotate_Left
9162 In standard Ada, the @code{Rotate_Left} function is available only
9163 for the predefined modular types in package @code{Interfaces}. However, in
9164 GNAT it is possible to define a Rotate_Left function for a user
9165 defined modular type or any signed integer type as in this example:
9167 @smallexample @c ada
9169 (Value : My_Modular_Type;
9171 return My_Modular_Type;
9175 The requirements are that the profile be exactly as in the example
9176 above. The only modifications allowed are in the formal parameter
9177 names, and in the type of @code{Value} and the return type, which
9178 must be the same, and must be either a signed integer type, or
9179 a modular integer type with a binary modulus, and the size must
9180 be 8. 16, 32 or 64 bits.
9183 @section Rotate_Right
9184 @cindex Rotate_Right
9186 A @code{Rotate_Right} function can be defined for any user defined
9187 binary modular integer type, or signed integer type, as described
9188 above for @code{Rotate_Left}.
9194 A @code{Shift_Left} function can be defined for any user defined
9195 binary modular integer type, or signed integer type, as described
9196 above for @code{Rotate_Left}.
9199 @section Shift_Right
9202 A @code{Shift_Right} function can be defined for any user defined
9203 binary modular integer type, or signed integer type, as described
9204 above for @code{Rotate_Left}.
9206 @node Shift_Right_Arithmetic
9207 @section Shift_Right_Arithmetic
9208 @cindex Shift_Right_Arithmetic
9210 A @code{Shift_Right_Arithmetic} function can be defined for any user
9211 defined binary modular integer type, or signed integer type, as described
9212 above for @code{Rotate_Left}.
9214 @node Source_Location
9215 @section Source_Location
9216 @cindex Source_Location
9218 This intrinsic subprogram is used in the implementation of the
9219 library routine @code{GNAT.Source_Info}. The only useful use of the
9220 intrinsic import in this case is the one in this unit, so an
9221 application program should simply call the function
9222 @code{GNAT.Source_Info.Source_Location} to obtain the current
9223 source file location.
9225 @node Representation Clauses and Pragmas
9226 @chapter Representation Clauses and Pragmas
9227 @cindex Representation Clauses
9230 * Alignment Clauses::
9232 * Storage_Size Clauses::
9233 * Size of Variant Record Objects::
9234 * Biased Representation ::
9235 * Value_Size and Object_Size Clauses::
9236 * Component_Size Clauses::
9237 * Bit_Order Clauses::
9238 * Effect of Bit_Order on Byte Ordering::
9239 * Pragma Pack for Arrays::
9240 * Pragma Pack for Records::
9241 * Record Representation Clauses::
9242 * Enumeration Clauses::
9244 * Effect of Convention on Representation::
9245 * Determining the Representations chosen by GNAT::
9249 @cindex Representation Clause
9250 @cindex Representation Pragma
9251 @cindex Pragma, representation
9252 This section describes the representation clauses accepted by GNAT, and
9253 their effect on the representation of corresponding data objects.
9255 GNAT fully implements Annex C (Systems Programming). This means that all
9256 the implementation advice sections in chapter 13 are fully implemented.
9257 However, these sections only require a minimal level of support for
9258 representation clauses. GNAT provides much more extensive capabilities,
9259 and this section describes the additional capabilities provided.
9261 @node Alignment Clauses
9262 @section Alignment Clauses
9263 @cindex Alignment Clause
9266 GNAT requires that all alignment clauses specify a power of 2, and all
9267 default alignments are always a power of 2. The default alignment
9268 values are as follows:
9271 @item @emph{Primitive Types}.
9272 For primitive types, the alignment is the minimum of the actual size of
9273 objects of the type divided by @code{Storage_Unit},
9274 and the maximum alignment supported by the target.
9275 (This maximum alignment is given by the GNAT-specific attribute
9276 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9277 @cindex @code{Maximum_Alignment} attribute
9278 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9279 default alignment will be 8 on any target that supports alignments
9280 this large, but on some targets, the maximum alignment may be smaller
9281 than 8, in which case objects of type @code{Long_Float} will be maximally
9284 @item @emph{Arrays}.
9285 For arrays, the alignment is equal to the alignment of the component type
9286 for the normal case where no packing or component size is given. If the
9287 array is packed, and the packing is effective (see separate section on
9288 packed arrays), then the alignment will be one for long packed arrays,
9289 or arrays whose length is not known at compile time. For short packed
9290 arrays, which are handled internally as modular types, the alignment
9291 will be as described for primitive types, e.g.@: a packed array of length
9292 31 bits will have an object size of four bytes, and an alignment of 4.
9294 @item @emph{Records}.
9295 For the normal non-packed case, the alignment of a record is equal to
9296 the maximum alignment of any of its components. For tagged records, this
9297 includes the implicit access type used for the tag. If a pragma @code{Pack} is
9298 used and all fields are packable (see separate section on pragma @code{Pack}),
9299 then the resulting alignment is 1.
9301 A special case is when:
9304 the size of the record is given explicitly, or a
9305 full record representation clause is given, and
9307 the size of the record is 2, 4, or 8 bytes.
9310 In this case, an alignment is chosen to match the
9311 size of the record. For example, if we have:
9313 @smallexample @c ada
9314 type Small is record
9317 for Small'Size use 16;
9321 then the default alignment of the record type @code{Small} is 2, not 1. This
9322 leads to more efficient code when the record is treated as a unit, and also
9323 allows the type to specified as @code{Atomic} on architectures requiring
9329 An alignment clause may specify a larger alignment than the default value
9330 up to some maximum value dependent on the target (obtainable by using the
9331 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
9332 a smaller alignment than the default value, for example
9334 @smallexample @c ada
9339 for V'alignment use 1;
9343 @cindex Alignment, default
9344 The default alignment for the type @code{V} is 4, as a result of the
9345 Integer field in the record, but it is permissible, as shown, to
9346 override the default alignment of the record with a smaller value.
9349 @section Size Clauses
9353 The default size for a type @code{T} is obtainable through the
9354 language-defined attribute @code{T'Size} and also through the
9355 equivalent GNAT-defined attribute @code{T'Value_Size}.
9356 For objects of type @code{T}, GNAT will generally increase the type size
9357 so that the object size (obtainable through the GNAT-defined attribute
9358 @code{T'Object_Size})
9359 is a multiple of @code{T'Alignment * Storage_Unit}.
9362 @smallexample @c ada
9363 type Smallint is range 1 .. 6;
9372 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
9373 as specified by the RM rules,
9374 but objects of this type will have a size of 8
9375 (@code{Smallint'Object_Size} = 8),
9376 since objects by default occupy an integral number
9377 of storage units. On some targets, notably older
9378 versions of the Digital Alpha, the size of stand
9379 alone objects of this type may be 32, reflecting
9380 the inability of the hardware to do byte load/stores.
9382 Similarly, the size of type @code{Rec} is 40 bits
9383 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
9384 the alignment is 4, so objects of this type will have
9385 their size increased to 64 bits so that it is a multiple
9386 of the alignment (in bits). This decision is
9387 in accordance with the specific Implementation Advice in RM 13.3(43):
9390 A @code{Size} clause should be supported for an object if the specified
9391 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
9392 to a size in storage elements that is a multiple of the object's
9393 @code{Alignment} (if the @code{Alignment} is nonzero).
9397 An explicit size clause may be used to override the default size by
9398 increasing it. For example, if we have:
9400 @smallexample @c ada
9401 type My_Boolean is new Boolean;
9402 for My_Boolean'Size use 32;
9406 then values of this type will always be 32 bits long. In the case of
9407 discrete types, the size can be increased up to 64 bits, with the effect
9408 that the entire specified field is used to hold the value, sign- or
9409 zero-extended as appropriate. If more than 64 bits is specified, then
9410 padding space is allocated after the value, and a warning is issued that
9411 there are unused bits.
9413 Similarly the size of records and arrays may be increased, and the effect
9414 is to add padding bits after the value. This also causes a warning message
9417 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
9418 Size in bits, this corresponds to an object of size 256 megabytes (minus
9419 one). This limitation is true on all targets. The reason for this
9420 limitation is that it improves the quality of the code in many cases
9421 if it is known that a Size value can be accommodated in an object of
9424 @node Storage_Size Clauses
9425 @section Storage_Size Clauses
9426 @cindex Storage_Size Clause
9429 For tasks, the @code{Storage_Size} clause specifies the amount of space
9430 to be allocated for the task stack. This cannot be extended, and if the
9431 stack is exhausted, then @code{Storage_Error} will be raised (if stack
9432 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
9433 or a @code{Storage_Size} pragma in the task definition to set the
9434 appropriate required size. A useful technique is to include in every
9435 task definition a pragma of the form:
9437 @smallexample @c ada
9438 pragma Storage_Size (Default_Stack_Size);
9442 Then @code{Default_Stack_Size} can be defined in a global package, and
9443 modified as required. Any tasks requiring stack sizes different from the
9444 default can have an appropriate alternative reference in the pragma.
9446 You can also use the @code{-d} binder switch to modify the default stack
9449 For access types, the @code{Storage_Size} clause specifies the maximum
9450 space available for allocation of objects of the type. If this space is
9451 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9452 In the case where the access type is declared local to a subprogram, the
9453 use of a @code{Storage_Size} clause triggers automatic use of a special
9454 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9455 space for the pool is automatically reclaimed on exit from the scope in
9456 which the type is declared.
9458 A special case recognized by the compiler is the specification of a
9459 @code{Storage_Size} of zero for an access type. This means that no
9460 items can be allocated from the pool, and this is recognized at compile
9461 time, and all the overhead normally associated with maintaining a fixed
9462 size storage pool is eliminated. Consider the following example:
9464 @smallexample @c ada
9466 type R is array (Natural) of Character;
9467 type P is access all R;
9468 for P'Storage_Size use 0;
9469 -- Above access type intended only for interfacing purposes
9473 procedure g (m : P);
9474 pragma Import (C, g);
9485 As indicated in this example, these dummy storage pools are often useful in
9486 connection with interfacing where no object will ever be allocated. If you
9487 compile the above example, you get the warning:
9490 p.adb:16:09: warning: allocation from empty storage pool
9491 p.adb:16:09: warning: Storage_Error will be raised at run time
9495 Of course in practice, there will not be any explicit allocators in the
9496 case of such an access declaration.
9498 @node Size of Variant Record Objects
9499 @section Size of Variant Record Objects
9500 @cindex Size, variant record objects
9501 @cindex Variant record objects, size
9504 In the case of variant record objects, there is a question whether Size gives
9505 information about a particular variant, or the maximum size required
9506 for any variant. Consider the following program
9508 @smallexample @c ada
9509 with Text_IO; use Text_IO;
9511 type R1 (A : Boolean := False) is record
9513 when True => X : Character;
9522 Put_Line (Integer'Image (V1'Size));
9523 Put_Line (Integer'Image (V2'Size));
9528 Here we are dealing with a variant record, where the True variant
9529 requires 16 bits, and the False variant requires 8 bits.
9530 In the above example, both V1 and V2 contain the False variant,
9531 which is only 8 bits long. However, the result of running the
9540 The reason for the difference here is that the discriminant value of
9541 V1 is fixed, and will always be False. It is not possible to assign
9542 a True variant value to V1, therefore 8 bits is sufficient. On the
9543 other hand, in the case of V2, the initial discriminant value is
9544 False (from the default), but it is possible to assign a True
9545 variant value to V2, therefore 16 bits must be allocated for V2
9546 in the general case, even fewer bits may be needed at any particular
9547 point during the program execution.
9549 As can be seen from the output of this program, the @code{'Size}
9550 attribute applied to such an object in GNAT gives the actual allocated
9551 size of the variable, which is the largest size of any of the variants.
9552 The Ada Reference Manual is not completely clear on what choice should
9553 be made here, but the GNAT behavior seems most consistent with the
9554 language in the RM@.
9556 In some cases, it may be desirable to obtain the size of the current
9557 variant, rather than the size of the largest variant. This can be
9558 achieved in GNAT by making use of the fact that in the case of a
9559 subprogram parameter, GNAT does indeed return the size of the current
9560 variant (because a subprogram has no way of knowing how much space
9561 is actually allocated for the actual).
9563 Consider the following modified version of the above program:
9565 @smallexample @c ada
9566 with Text_IO; use Text_IO;
9568 type R1 (A : Boolean := False) is record
9570 when True => X : Character;
9577 function Size (V : R1) return Integer is
9583 Put_Line (Integer'Image (V2'Size));
9584 Put_Line (Integer'IMage (Size (V2)));
9586 Put_Line (Integer'Image (V2'Size));
9587 Put_Line (Integer'IMage (Size (V2)));
9592 The output from this program is
9602 Here we see that while the @code{'Size} attribute always returns
9603 the maximum size, regardless of the current variant value, the
9604 @code{Size} function does indeed return the size of the current
9607 @node Biased Representation
9608 @section Biased Representation
9609 @cindex Size for biased representation
9610 @cindex Biased representation
9613 In the case of scalars with a range starting at other than zero, it is
9614 possible in some cases to specify a size smaller than the default minimum
9615 value, and in such cases, GNAT uses an unsigned biased representation,
9616 in which zero is used to represent the lower bound, and successive values
9617 represent successive values of the type.
9619 For example, suppose we have the declaration:
9621 @smallexample @c ada
9622 type Small is range -7 .. -4;
9623 for Small'Size use 2;
9627 Although the default size of type @code{Small} is 4, the @code{Size}
9628 clause is accepted by GNAT and results in the following representation
9632 -7 is represented as 2#00#
9633 -6 is represented as 2#01#
9634 -5 is represented as 2#10#
9635 -4 is represented as 2#11#
9639 Biased representation is only used if the specified @code{Size} clause
9640 cannot be accepted in any other manner. These reduced sizes that force
9641 biased representation can be used for all discrete types except for
9642 enumeration types for which a representation clause is given.
9644 @node Value_Size and Object_Size Clauses
9645 @section Value_Size and Object_Size Clauses
9648 @cindex Size, of objects
9651 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
9652 number of bits required to hold values of type @code{T}.
9653 Although this interpretation was allowed in Ada 83, it was not required,
9654 and this requirement in practice can cause some significant difficulties.
9655 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
9656 However, in Ada 95 and Ada 2005,
9657 @code{Natural'Size} is
9658 typically 31. This means that code may change in behavior when moving
9659 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
9661 @smallexample @c ada
9668 at 0 range 0 .. Natural'Size - 1;
9669 at 0 range Natural'Size .. 2 * Natural'Size - 1;
9674 In the above code, since the typical size of @code{Natural} objects
9675 is 32 bits and @code{Natural'Size} is 31, the above code can cause
9676 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
9677 there are cases where the fact that the object size can exceed the
9678 size of the type causes surprises.
9680 To help get around this problem GNAT provides two implementation
9681 defined attributes, @code{Value_Size} and @code{Object_Size}. When
9682 applied to a type, these attributes yield the size of the type
9683 (corresponding to the RM defined size attribute), and the size of
9684 objects of the type respectively.
9686 The @code{Object_Size} is used for determining the default size of
9687 objects and components. This size value can be referred to using the
9688 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
9689 the basis of the determination of the size. The backend is free to
9690 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
9691 character might be stored in 32 bits on a machine with no efficient
9692 byte access instructions such as the Alpha.
9694 The default rules for the value of @code{Object_Size} for
9695 discrete types are as follows:
9699 The @code{Object_Size} for base subtypes reflect the natural hardware
9700 size in bits (run the compiler with @option{-gnatS} to find those values
9701 for numeric types). Enumeration types and fixed-point base subtypes have
9702 8, 16, 32 or 64 bits for this size, depending on the range of values
9706 The @code{Object_Size} of a subtype is the same as the
9707 @code{Object_Size} of
9708 the type from which it is obtained.
9711 The @code{Object_Size} of a derived base type is copied from the parent
9712 base type, and the @code{Object_Size} of a derived first subtype is copied
9713 from the parent first subtype.
9717 The @code{Value_Size} attribute
9718 is the (minimum) number of bits required to store a value
9720 This value is used to determine how tightly to pack
9721 records or arrays with components of this type, and also affects
9722 the semantics of unchecked conversion (unchecked conversions where
9723 the @code{Value_Size} values differ generate a warning, and are potentially
9726 The default rules for the value of @code{Value_Size} are as follows:
9730 The @code{Value_Size} for a base subtype is the minimum number of bits
9731 required to store all values of the type (including the sign bit
9732 only if negative values are possible).
9735 If a subtype statically matches the first subtype of a given type, then it has
9736 by default the same @code{Value_Size} as the first subtype. This is a
9737 consequence of RM 13.1(14) (``if two subtypes statically match,
9738 then their subtype-specific aspects are the same''.)
9741 All other subtypes have a @code{Value_Size} corresponding to the minimum
9742 number of bits required to store all values of the subtype. For
9743 dynamic bounds, it is assumed that the value can range down or up
9744 to the corresponding bound of the ancestor
9748 The RM defined attribute @code{Size} corresponds to the
9749 @code{Value_Size} attribute.
9751 The @code{Size} attribute may be defined for a first-named subtype. This sets
9752 the @code{Value_Size} of
9753 the first-named subtype to the given value, and the
9754 @code{Object_Size} of this first-named subtype to the given value padded up
9755 to an appropriate boundary. It is a consequence of the default rules
9756 above that this @code{Object_Size} will apply to all further subtypes. On the
9757 other hand, @code{Value_Size} is affected only for the first subtype, any
9758 dynamic subtypes obtained from it directly, and any statically matching
9759 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
9761 @code{Value_Size} and
9762 @code{Object_Size} may be explicitly set for any subtype using
9763 an attribute definition clause. Note that the use of these attributes
9764 can cause the RM 13.1(14) rule to be violated. If two access types
9765 reference aliased objects whose subtypes have differing @code{Object_Size}
9766 values as a result of explicit attribute definition clauses, then it
9767 is erroneous to convert from one access subtype to the other.
9769 At the implementation level, Esize stores the Object_Size and the
9770 RM_Size field stores the @code{Value_Size} (and hence the value of the
9771 @code{Size} attribute,
9772 which, as noted above, is equivalent to @code{Value_Size}).
9774 To get a feel for the difference, consider the following examples (note
9775 that in each case the base is @code{Short_Short_Integer} with a size of 8):
9778 Object_Size Value_Size
9780 type x1 is range 0 .. 5; 8 3
9782 type x2 is range 0 .. 5;
9783 for x2'size use 12; 16 12
9785 subtype x3 is x2 range 0 .. 3; 16 2
9787 subtype x4 is x2'base range 0 .. 10; 8 4
9789 subtype x5 is x2 range 0 .. dynamic; 16 3*
9791 subtype x6 is x2'base range 0 .. dynamic; 8 3*
9796 Note: the entries marked ``3*'' are not actually specified by the Ada
9797 Reference Manual, but it seems in the spirit of the RM rules to allocate
9798 the minimum number of bits (here 3, given the range for @code{x2})
9799 known to be large enough to hold the given range of values.
9801 So far, so good, but GNAT has to obey the RM rules, so the question is
9802 under what conditions must the RM @code{Size} be used.
9803 The following is a list
9804 of the occasions on which the RM @code{Size} must be used:
9808 Component size for packed arrays or records
9811 Value of the attribute @code{Size} for a type
9814 Warning about sizes not matching for unchecked conversion
9818 For record types, the @code{Object_Size} is always a multiple of the
9819 alignment of the type (this is true for all types). In some cases the
9820 @code{Value_Size} can be smaller. Consider:
9830 On a typical 32-bit architecture, the X component will be four bytes, and
9831 require four-byte alignment, and the Y component will be one byte. In this
9832 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
9833 required to store a value of this type, and for example, it is permissible
9834 to have a component of type R in an outer record whose component size is
9835 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
9836 since it must be rounded up so that this value is a multiple of the
9837 alignment (4 bytes = 32 bits).
9840 For all other types, the @code{Object_Size}
9841 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
9842 Only @code{Size} may be specified for such types.
9844 @node Component_Size Clauses
9845 @section Component_Size Clauses
9846 @cindex Component_Size Clause
9849 Normally, the value specified in a component size clause must be consistent
9850 with the subtype of the array component with regard to size and alignment.
9851 In other words, the value specified must be at least equal to the size
9852 of this subtype, and must be a multiple of the alignment value.
9854 In addition, component size clauses are allowed which cause the array
9855 to be packed, by specifying a smaller value. The cases in which this
9856 is allowed are for component size values in the range 1 through 63. The value
9857 specified must not be smaller than the Size of the subtype. GNAT will
9858 accurately honor all packing requests in this range. For example, if
9861 @smallexample @c ada
9862 type r is array (1 .. 8) of Natural;
9863 for r'Component_Size use 31;
9867 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
9868 Of course access to the components of such an array is considerably
9869 less efficient than if the natural component size of 32 is used.
9871 Note that there is no point in giving both a component size clause
9872 and a pragma Pack for the same array type. if such duplicate
9873 clauses are given, the pragma Pack will be ignored.
9875 @node Bit_Order Clauses
9876 @section Bit_Order Clauses
9877 @cindex Bit_Order Clause
9878 @cindex bit ordering
9879 @cindex ordering, of bits
9882 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
9883 attribute. The specification may either correspond to the default bit
9884 order for the target, in which case the specification has no effect and
9885 places no additional restrictions, or it may be for the non-standard
9886 setting (that is the opposite of the default).
9888 In the case where the non-standard value is specified, the effect is
9889 to renumber bits within each byte, but the ordering of bytes is not
9890 affected. There are certain
9891 restrictions placed on component clauses as follows:
9895 @item Components fitting within a single storage unit.
9897 These are unrestricted, and the effect is merely to renumber bits. For
9898 example if we are on a little-endian machine with @code{Low_Order_First}
9899 being the default, then the following two declarations have exactly
9902 @smallexample @c ada
9905 B : Integer range 1 .. 120;
9909 A at 0 range 0 .. 0;
9910 B at 0 range 1 .. 7;
9915 B : Integer range 1 .. 120;
9918 for R2'Bit_Order use High_Order_First;
9921 A at 0 range 7 .. 7;
9922 B at 0 range 0 .. 6;
9927 The useful application here is to write the second declaration with the
9928 @code{Bit_Order} attribute definition clause, and know that it will be treated
9929 the same, regardless of whether the target is little-endian or big-endian.
9931 @item Components occupying an integral number of bytes.
9933 These are components that exactly fit in two or more bytes. Such component
9934 declarations are allowed, but have no effect, since it is important to realize
9935 that the @code{Bit_Order} specification does not affect the ordering of bytes.
9936 In particular, the following attempt at getting an endian-independent integer
9939 @smallexample @c ada
9944 for R2'Bit_Order use High_Order_First;
9947 A at 0 range 0 .. 31;
9952 This declaration will result in a little-endian integer on a
9953 little-endian machine, and a big-endian integer on a big-endian machine.
9954 If byte flipping is required for interoperability between big- and
9955 little-endian machines, this must be explicitly programmed. This capability
9956 is not provided by @code{Bit_Order}.
9958 @item Components that are positioned across byte boundaries
9960 but do not occupy an integral number of bytes. Given that bytes are not
9961 reordered, such fields would occupy a non-contiguous sequence of bits
9962 in memory, requiring non-trivial code to reassemble. They are for this
9963 reason not permitted, and any component clause specifying such a layout
9964 will be flagged as illegal by GNAT@.
9969 Since the misconception that Bit_Order automatically deals with all
9970 endian-related incompatibilities is a common one, the specification of
9971 a component field that is an integral number of bytes will always
9972 generate a warning. This warning may be suppressed using @code{pragma
9973 Warnings (Off)} if desired. The following section contains additional
9974 details regarding the issue of byte ordering.
9976 @node Effect of Bit_Order on Byte Ordering
9977 @section Effect of Bit_Order on Byte Ordering
9978 @cindex byte ordering
9979 @cindex ordering, of bytes
9982 In this section we will review the effect of the @code{Bit_Order} attribute
9983 definition clause on byte ordering. Briefly, it has no effect at all, but
9984 a detailed example will be helpful. Before giving this
9985 example, let us review the precise
9986 definition of the effect of defining @code{Bit_Order}. The effect of a
9987 non-standard bit order is described in section 15.5.3 of the Ada
9991 2 A bit ordering is a method of interpreting the meaning of
9992 the storage place attributes.
9996 To understand the precise definition of storage place attributes in
9997 this context, we visit section 13.5.1 of the manual:
10000 13 A record_representation_clause (without the mod_clause)
10001 specifies the layout. The storage place attributes (see 13.5.2)
10002 are taken from the values of the position, first_bit, and last_bit
10003 expressions after normalizing those values so that first_bit is
10004 less than Storage_Unit.
10008 The critical point here is that storage places are taken from
10009 the values after normalization, not before. So the @code{Bit_Order}
10010 interpretation applies to normalized values. The interpretation
10011 is described in the later part of the 15.5.3 paragraph:
10014 2 A bit ordering is a method of interpreting the meaning of
10015 the storage place attributes. High_Order_First (known in the
10016 vernacular as ``big endian'') means that the first bit of a
10017 storage element (bit 0) is the most significant bit (interpreting
10018 the sequence of bits that represent a component as an unsigned
10019 integer value). Low_Order_First (known in the vernacular as
10020 ``little endian'') means the opposite: the first bit is the
10025 Note that the numbering is with respect to the bits of a storage
10026 unit. In other words, the specification affects only the numbering
10027 of bits within a single storage unit.
10029 We can make the effect clearer by giving an example.
10031 Suppose that we have an external device which presents two bytes, the first
10032 byte presented, which is the first (low addressed byte) of the two byte
10033 record is called Master, and the second byte is called Slave.
10035 The left most (most significant bit is called Control for each byte, and
10036 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10037 (least significant) bit.
10039 On a big-endian machine, we can write the following representation clause
10041 @smallexample @c ada
10042 type Data is record
10043 Master_Control : Bit;
10051 Slave_Control : Bit;
10061 for Data use record
10062 Master_Control at 0 range 0 .. 0;
10063 Master_V1 at 0 range 1 .. 1;
10064 Master_V2 at 0 range 2 .. 2;
10065 Master_V3 at 0 range 3 .. 3;
10066 Master_V4 at 0 range 4 .. 4;
10067 Master_V5 at 0 range 5 .. 5;
10068 Master_V6 at 0 range 6 .. 6;
10069 Master_V7 at 0 range 7 .. 7;
10070 Slave_Control at 1 range 0 .. 0;
10071 Slave_V1 at 1 range 1 .. 1;
10072 Slave_V2 at 1 range 2 .. 2;
10073 Slave_V3 at 1 range 3 .. 3;
10074 Slave_V4 at 1 range 4 .. 4;
10075 Slave_V5 at 1 range 5 .. 5;
10076 Slave_V6 at 1 range 6 .. 6;
10077 Slave_V7 at 1 range 7 .. 7;
10082 Now if we move this to a little endian machine, then the bit ordering within
10083 the byte is backwards, so we have to rewrite the record rep clause as:
10085 @smallexample @c ada
10086 for Data use record
10087 Master_Control at 0 range 7 .. 7;
10088 Master_V1 at 0 range 6 .. 6;
10089 Master_V2 at 0 range 5 .. 5;
10090 Master_V3 at 0 range 4 .. 4;
10091 Master_V4 at 0 range 3 .. 3;
10092 Master_V5 at 0 range 2 .. 2;
10093 Master_V6 at 0 range 1 .. 1;
10094 Master_V7 at 0 range 0 .. 0;
10095 Slave_Control at 1 range 7 .. 7;
10096 Slave_V1 at 1 range 6 .. 6;
10097 Slave_V2 at 1 range 5 .. 5;
10098 Slave_V3 at 1 range 4 .. 4;
10099 Slave_V4 at 1 range 3 .. 3;
10100 Slave_V5 at 1 range 2 .. 2;
10101 Slave_V6 at 1 range 1 .. 1;
10102 Slave_V7 at 1 range 0 .. 0;
10107 It is a nuisance to have to rewrite the clause, especially if
10108 the code has to be maintained on both machines. However,
10109 this is a case that we can handle with the
10110 @code{Bit_Order} attribute if it is implemented.
10111 Note that the implementation is not required on byte addressed
10112 machines, but it is indeed implemented in GNAT.
10113 This means that we can simply use the
10114 first record clause, together with the declaration
10116 @smallexample @c ada
10117 for Data'Bit_Order use High_Order_First;
10121 and the effect is what is desired, namely the layout is exactly the same,
10122 independent of whether the code is compiled on a big-endian or little-endian
10125 The important point to understand is that byte ordering is not affected.
10126 A @code{Bit_Order} attribute definition never affects which byte a field
10127 ends up in, only where it ends up in that byte.
10128 To make this clear, let us rewrite the record rep clause of the previous
10131 @smallexample @c ada
10132 for Data'Bit_Order use High_Order_First;
10133 for Data use record
10134 Master_Control at 0 range 0 .. 0;
10135 Master_V1 at 0 range 1 .. 1;
10136 Master_V2 at 0 range 2 .. 2;
10137 Master_V3 at 0 range 3 .. 3;
10138 Master_V4 at 0 range 4 .. 4;
10139 Master_V5 at 0 range 5 .. 5;
10140 Master_V6 at 0 range 6 .. 6;
10141 Master_V7 at 0 range 7 .. 7;
10142 Slave_Control at 0 range 8 .. 8;
10143 Slave_V1 at 0 range 9 .. 9;
10144 Slave_V2 at 0 range 10 .. 10;
10145 Slave_V3 at 0 range 11 .. 11;
10146 Slave_V4 at 0 range 12 .. 12;
10147 Slave_V5 at 0 range 13 .. 13;
10148 Slave_V6 at 0 range 14 .. 14;
10149 Slave_V7 at 0 range 15 .. 15;
10154 This is exactly equivalent to saying (a repeat of the first example):
10156 @smallexample @c ada
10157 for Data'Bit_Order use High_Order_First;
10158 for Data use record
10159 Master_Control at 0 range 0 .. 0;
10160 Master_V1 at 0 range 1 .. 1;
10161 Master_V2 at 0 range 2 .. 2;
10162 Master_V3 at 0 range 3 .. 3;
10163 Master_V4 at 0 range 4 .. 4;
10164 Master_V5 at 0 range 5 .. 5;
10165 Master_V6 at 0 range 6 .. 6;
10166 Master_V7 at 0 range 7 .. 7;
10167 Slave_Control at 1 range 0 .. 0;
10168 Slave_V1 at 1 range 1 .. 1;
10169 Slave_V2 at 1 range 2 .. 2;
10170 Slave_V3 at 1 range 3 .. 3;
10171 Slave_V4 at 1 range 4 .. 4;
10172 Slave_V5 at 1 range 5 .. 5;
10173 Slave_V6 at 1 range 6 .. 6;
10174 Slave_V7 at 1 range 7 .. 7;
10179 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10180 field. The storage place attributes are obtained by normalizing the
10181 values given so that the @code{First_Bit} value is less than 8. After
10182 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10183 we specified in the other case.
10185 Now one might expect that the @code{Bit_Order} attribute might affect
10186 bit numbering within the entire record component (two bytes in this
10187 case, thus affecting which byte fields end up in), but that is not
10188 the way this feature is defined, it only affects numbering of bits,
10189 not which byte they end up in.
10191 Consequently it never makes sense to specify a starting bit number
10192 greater than 7 (for a byte addressable field) if an attribute
10193 definition for @code{Bit_Order} has been given, and indeed it
10194 may be actively confusing to specify such a value, so the compiler
10195 generates a warning for such usage.
10197 If you do need to control byte ordering then appropriate conditional
10198 values must be used. If in our example, the slave byte came first on
10199 some machines we might write:
10201 @smallexample @c ada
10202 Master_Byte_First constant Boolean := @dots{};
10204 Master_Byte : constant Natural :=
10205 1 - Boolean'Pos (Master_Byte_First);
10206 Slave_Byte : constant Natural :=
10207 Boolean'Pos (Master_Byte_First);
10209 for Data'Bit_Order use High_Order_First;
10210 for Data use record
10211 Master_Control at Master_Byte range 0 .. 0;
10212 Master_V1 at Master_Byte range 1 .. 1;
10213 Master_V2 at Master_Byte range 2 .. 2;
10214 Master_V3 at Master_Byte range 3 .. 3;
10215 Master_V4 at Master_Byte range 4 .. 4;
10216 Master_V5 at Master_Byte range 5 .. 5;
10217 Master_V6 at Master_Byte range 6 .. 6;
10218 Master_V7 at Master_Byte range 7 .. 7;
10219 Slave_Control at Slave_Byte range 0 .. 0;
10220 Slave_V1 at Slave_Byte range 1 .. 1;
10221 Slave_V2 at Slave_Byte range 2 .. 2;
10222 Slave_V3 at Slave_Byte range 3 .. 3;
10223 Slave_V4 at Slave_Byte range 4 .. 4;
10224 Slave_V5 at Slave_Byte range 5 .. 5;
10225 Slave_V6 at Slave_Byte range 6 .. 6;
10226 Slave_V7 at Slave_Byte range 7 .. 7;
10231 Now to switch between machines, all that is necessary is
10232 to set the boolean constant @code{Master_Byte_First} in
10233 an appropriate manner.
10235 @node Pragma Pack for Arrays
10236 @section Pragma Pack for Arrays
10237 @cindex Pragma Pack (for arrays)
10240 Pragma @code{Pack} applied to an array has no effect unless the component type
10241 is packable. For a component type to be packable, it must be one of the
10248 Any type whose size is specified with a size clause
10250 Any packed array type with a static size
10254 For all these cases, if the component subtype size is in the range
10255 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10256 component size were specified giving the component subtype size.
10257 For example if we have:
10259 @smallexample @c ada
10260 type r is range 0 .. 17;
10262 type ar is array (1 .. 8) of r;
10267 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10268 and the size of the array @code{ar} will be exactly 40 bits.
10270 Note that in some cases this rather fierce approach to packing can produce
10271 unexpected effects. For example, in Ada 95 and Ada 2005,
10272 subtype @code{Natural} typically has a size of 31, meaning that if you
10273 pack an array of @code{Natural}, you get 31-bit
10274 close packing, which saves a few bits, but results in far less efficient
10275 access. Since many other Ada compilers will ignore such a packing request,
10276 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10277 might not be what is intended. You can easily remove this warning by
10278 using an explicit @code{Component_Size} setting instead, which never generates
10279 a warning, since the intention of the programmer is clear in this case.
10281 GNAT treats packed arrays in one of two ways. If the size of the array is
10282 known at compile time and is less than 64 bits, then internally the array
10283 is represented as a single modular type, of exactly the appropriate number
10284 of bits. If the length is greater than 63 bits, or is not known at compile
10285 time, then the packed array is represented as an array of bytes, and the
10286 length is always a multiple of 8 bits.
10288 Note that to represent a packed array as a modular type, the alignment must
10289 be suitable for the modular type involved. For example, on typical machines
10290 a 32-bit packed array will be represented by a 32-bit modular integer with
10291 an alignment of four bytes. If you explicitly override the default alignment
10292 with an alignment clause that is too small, the modular representation
10293 cannot be used. For example, consider the following set of declarations:
10295 @smallexample @c ada
10296 type R is range 1 .. 3;
10297 type S is array (1 .. 31) of R;
10298 for S'Component_Size use 2;
10300 for S'Alignment use 1;
10304 If the alignment clause were not present, then a 62-bit modular
10305 representation would be chosen (typically with an alignment of 4 or 8
10306 bytes depending on the target). But the default alignment is overridden
10307 with the explicit alignment clause. This means that the modular
10308 representation cannot be used, and instead the array of bytes
10309 representation must be used, meaning that the length must be a multiple
10310 of 8. Thus the above set of declarations will result in a diagnostic
10311 rejecting the size clause and noting that the minimum size allowed is 64.
10313 @cindex Pragma Pack (for type Natural)
10314 @cindex Pragma Pack warning
10316 One special case that is worth noting occurs when the base type of the
10317 component size is 8/16/32 and the subtype is one bit less. Notably this
10318 occurs with subtype @code{Natural}. Consider:
10320 @smallexample @c ada
10321 type Arr is array (1 .. 32) of Natural;
10326 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10327 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10328 Ada 83 compilers did not attempt 31 bit packing.
10330 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
10331 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
10332 substantial unintended performance penalty when porting legacy Ada 83 code.
10333 To help prevent this, GNAT generates a warning in such cases. If you really
10334 want 31 bit packing in a case like this, you can set the component size
10337 @smallexample @c ada
10338 type Arr is array (1 .. 32) of Natural;
10339 for Arr'Component_Size use 31;
10343 Here 31-bit packing is achieved as required, and no warning is generated,
10344 since in this case the programmer intention is clear.
10346 @node Pragma Pack for Records
10347 @section Pragma Pack for Records
10348 @cindex Pragma Pack (for records)
10351 Pragma @code{Pack} applied to a record will pack the components to reduce
10352 wasted space from alignment gaps and by reducing the amount of space
10353 taken by components. We distinguish between @emph{packable} components and
10354 @emph{non-packable} components.
10355 Components of the following types are considered packable:
10358 All primitive types are packable.
10361 Small packed arrays, whose size does not exceed 64 bits, and where the
10362 size is statically known at compile time, are represented internally
10363 as modular integers, and so they are also packable.
10368 All packable components occupy the exact number of bits corresponding to
10369 their @code{Size} value, and are packed with no padding bits, i.e.@: they
10370 can start on an arbitrary bit boundary.
10372 All other types are non-packable, they occupy an integral number of
10374 are placed at a boundary corresponding to their alignment requirements.
10376 For example, consider the record
10378 @smallexample @c ada
10379 type Rb1 is array (1 .. 13) of Boolean;
10382 type Rb2 is array (1 .. 65) of Boolean;
10397 The representation for the record x2 is as follows:
10399 @smallexample @c ada
10400 for x2'Size use 224;
10402 l1 at 0 range 0 .. 0;
10403 l2 at 0 range 1 .. 64;
10404 l3 at 12 range 0 .. 31;
10405 l4 at 16 range 0 .. 0;
10406 l5 at 16 range 1 .. 13;
10407 l6 at 18 range 0 .. 71;
10412 Studying this example, we see that the packable fields @code{l1}
10414 of length equal to their sizes, and placed at specific bit boundaries (and
10415 not byte boundaries) to
10416 eliminate padding. But @code{l3} is of a non-packable float type, so
10417 it is on the next appropriate alignment boundary.
10419 The next two fields are fully packable, so @code{l4} and @code{l5} are
10420 minimally packed with no gaps. However, type @code{Rb2} is a packed
10421 array that is longer than 64 bits, so it is itself non-packable. Thus
10422 the @code{l6} field is aligned to the next byte boundary, and takes an
10423 integral number of bytes, i.e.@: 72 bits.
10425 @node Record Representation Clauses
10426 @section Record Representation Clauses
10427 @cindex Record Representation Clause
10430 Record representation clauses may be given for all record types, including
10431 types obtained by record extension. Component clauses are allowed for any
10432 static component. The restrictions on component clauses depend on the type
10435 @cindex Component Clause
10436 For all components of an elementary type, the only restriction on component
10437 clauses is that the size must be at least the 'Size value of the type
10438 (actually the Value_Size). There are no restrictions due to alignment,
10439 and such components may freely cross storage boundaries.
10441 Packed arrays with a size up to and including 64 bits are represented
10442 internally using a modular type with the appropriate number of bits, and
10443 thus the same lack of restriction applies. For example, if you declare:
10445 @smallexample @c ada
10446 type R is array (1 .. 49) of Boolean;
10452 then a component clause for a component of type R may start on any
10453 specified bit boundary, and may specify a value of 49 bits or greater.
10455 For packed bit arrays that are longer than 64 bits, there are two
10456 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
10457 including the important case of single bits or boolean values, then
10458 there are no limitations on placement of such components, and they
10459 may start and end at arbitrary bit boundaries.
10461 If the component size is not a power of 2 (e.g. 3 or 5), then
10462 an array of this type longer than 64 bits must always be placed on
10463 on a storage unit (byte) boundary and occupy an integral number
10464 of storage units (bytes). Any component clause that does not
10465 meet this requirement will be rejected.
10467 Any aliased component, or component of an aliased type, must
10468 have its normal alignment and size. A component clause that
10469 does not meet this requirement will be rejected.
10471 The tag field of a tagged type always occupies an address sized field at
10472 the start of the record. No component clause may attempt to overlay this
10473 tag. When a tagged type appears as a component, the tag field must have
10476 In the case of a record extension T1, of a type T, no component clause applied
10477 to the type T1 can specify a storage location that would overlap the first
10478 T'Size bytes of the record.
10480 For all other component types, including non-bit-packed arrays,
10481 the component can be placed at an arbitrary bit boundary,
10482 so for example, the following is permitted:
10484 @smallexample @c ada
10485 type R is array (1 .. 10) of Boolean;
10494 G at 0 range 0 .. 0;
10495 H at 0 range 1 .. 1;
10496 L at 0 range 2 .. 81;
10497 R at 0 range 82 .. 161;
10502 Note: the above rules apply to recent releases of GNAT 5.
10503 In GNAT 3, there are more severe restrictions on larger components.
10504 For non-primitive types, including packed arrays with a size greater than
10505 64 bits, component clauses must respect the alignment requirement of the
10506 type, in particular, always starting on a byte boundary, and the length
10507 must be a multiple of the storage unit.
10509 @node Enumeration Clauses
10510 @section Enumeration Clauses
10512 The only restriction on enumeration clauses is that the range of values
10513 must be representable. For the signed case, if one or more of the
10514 representation values are negative, all values must be in the range:
10516 @smallexample @c ada
10517 System.Min_Int .. System.Max_Int
10521 For the unsigned case, where all values are non negative, the values must
10524 @smallexample @c ada
10525 0 .. System.Max_Binary_Modulus;
10529 A @emph{confirming} representation clause is one in which the values range
10530 from 0 in sequence, i.e.@: a clause that confirms the default representation
10531 for an enumeration type.
10532 Such a confirming representation
10533 is permitted by these rules, and is specially recognized by the compiler so
10534 that no extra overhead results from the use of such a clause.
10536 If an array has an index type which is an enumeration type to which an
10537 enumeration clause has been applied, then the array is stored in a compact
10538 manner. Consider the declarations:
10540 @smallexample @c ada
10541 type r is (A, B, C);
10542 for r use (A => 1, B => 5, C => 10);
10543 type t is array (r) of Character;
10547 The array type t corresponds to a vector with exactly three elements and
10548 has a default size equal to @code{3*Character'Size}. This ensures efficient
10549 use of space, but means that accesses to elements of the array will incur
10550 the overhead of converting representation values to the corresponding
10551 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
10553 @node Address Clauses
10554 @section Address Clauses
10555 @cindex Address Clause
10557 The reference manual allows a general restriction on representation clauses,
10558 as found in RM 13.1(22):
10561 An implementation need not support representation
10562 items containing nonstatic expressions, except that
10563 an implementation should support a representation item
10564 for a given entity if each nonstatic expression in the
10565 representation item is a name that statically denotes
10566 a constant declared before the entity.
10570 In practice this is applicable only to address clauses, since this is the
10571 only case in which a non-static expression is permitted by the syntax. As
10572 the AARM notes in sections 13.1 (22.a-22.h):
10575 22.a Reason: This is to avoid the following sort of thing:
10577 22.b X : Integer := F(@dots{});
10578 Y : Address := G(@dots{});
10579 for X'Address use Y;
10581 22.c In the above, we have to evaluate the
10582 initialization expression for X before we
10583 know where to put the result. This seems
10584 like an unreasonable implementation burden.
10586 22.d The above code should instead be written
10589 22.e Y : constant Address := G(@dots{});
10590 X : Integer := F(@dots{});
10591 for X'Address use Y;
10593 22.f This allows the expression ``Y'' to be safely
10594 evaluated before X is created.
10596 22.g The constant could be a formal parameter of mode in.
10598 22.h An implementation can support other nonstatic
10599 expressions if it wants to. Expressions of type
10600 Address are hardly ever static, but their value
10601 might be known at compile time anyway in many
10606 GNAT does indeed permit many additional cases of non-static expressions. In
10607 particular, if the type involved is elementary there are no restrictions
10608 (since in this case, holding a temporary copy of the initialization value,
10609 if one is present, is inexpensive). In addition, if there is no implicit or
10610 explicit initialization, then there are no restrictions. GNAT will reject
10611 only the case where all three of these conditions hold:
10616 The type of the item is non-elementary (e.g.@: a record or array).
10619 There is explicit or implicit initialization required for the object.
10620 Note that access values are always implicitly initialized, and also
10621 in GNAT, certain bit-packed arrays (those having a dynamic length or
10622 a length greater than 64) will also be implicitly initialized to zero.
10625 The address value is non-static. Here GNAT is more permissive than the
10626 RM, and allows the address value to be the address of a previously declared
10627 stand-alone variable, as long as it does not itself have an address clause.
10629 @smallexample @c ada
10630 Anchor : Some_Initialized_Type;
10631 Overlay : Some_Initialized_Type;
10632 for Overlay'Address use Anchor'Address;
10636 However, the prefix of the address clause cannot be an array component, or
10637 a component of a discriminated record.
10642 As noted above in section 22.h, address values are typically non-static. In
10643 particular the To_Address function, even if applied to a literal value, is
10644 a non-static function call. To avoid this minor annoyance, GNAT provides
10645 the implementation defined attribute 'To_Address. The following two
10646 expressions have identical values:
10650 @smallexample @c ada
10651 To_Address (16#1234_0000#)
10652 System'To_Address (16#1234_0000#);
10656 except that the second form is considered to be a static expression, and
10657 thus when used as an address clause value is always permitted.
10660 Additionally, GNAT treats as static an address clause that is an
10661 unchecked_conversion of a static integer value. This simplifies the porting
10662 of legacy code, and provides a portable equivalent to the GNAT attribute
10665 Another issue with address clauses is the interaction with alignment
10666 requirements. When an address clause is given for an object, the address
10667 value must be consistent with the alignment of the object (which is usually
10668 the same as the alignment of the type of the object). If an address clause
10669 is given that specifies an inappropriately aligned address value, then the
10670 program execution is erroneous.
10672 Since this source of erroneous behavior can have unfortunate effects, GNAT
10673 checks (at compile time if possible, generating a warning, or at execution
10674 time with a run-time check) that the alignment is appropriate. If the
10675 run-time check fails, then @code{Program_Error} is raised. This run-time
10676 check is suppressed if range checks are suppressed, or if the special GNAT
10677 check Alignment_Check is suppressed, or if
10678 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
10680 Finally, GNAT does not permit overlaying of objects of controlled types or
10681 composite types containing a controlled component. In most cases, the compiler
10682 can detect an attempt at such overlays and will generate a warning at compile
10683 time and a Program_Error exception at run time.
10686 An address clause cannot be given for an exported object. More
10687 understandably the real restriction is that objects with an address
10688 clause cannot be exported. This is because such variables are not
10689 defined by the Ada program, so there is no external object to export.
10692 It is permissible to give an address clause and a pragma Import for the
10693 same object. In this case, the variable is not really defined by the
10694 Ada program, so there is no external symbol to be linked. The link name
10695 and the external name are ignored in this case. The reason that we allow this
10696 combination is that it provides a useful idiom to avoid unwanted
10697 initializations on objects with address clauses.
10699 When an address clause is given for an object that has implicit or
10700 explicit initialization, then by default initialization takes place. This
10701 means that the effect of the object declaration is to overwrite the
10702 memory at the specified address. This is almost always not what the
10703 programmer wants, so GNAT will output a warning:
10713 for Ext'Address use System'To_Address (16#1234_1234#);
10715 >>> warning: implicit initialization of "Ext" may
10716 modify overlaid storage
10717 >>> warning: use pragma Import for "Ext" to suppress
10718 initialization (RM B(24))
10724 As indicated by the warning message, the solution is to use a (dummy) pragma
10725 Import to suppress this initialization. The pragma tell the compiler that the
10726 object is declared and initialized elsewhere. The following package compiles
10727 without warnings (and the initialization is suppressed):
10729 @smallexample @c ada
10737 for Ext'Address use System'To_Address (16#1234_1234#);
10738 pragma Import (Ada, Ext);
10743 A final issue with address clauses involves their use for overlaying
10744 variables, as in the following example:
10745 @cindex Overlaying of objects
10747 @smallexample @c ada
10750 for B'Address use A'Address;
10754 or alternatively, using the form recommended by the RM:
10756 @smallexample @c ada
10758 Addr : constant Address := A'Address;
10760 for B'Address use Addr;
10764 In both of these cases, @code{A}
10765 and @code{B} become aliased to one another via the
10766 address clause. This use of address clauses to overlay
10767 variables, achieving an effect similar to unchecked
10768 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
10769 the effect is implementation defined. Furthermore, the
10770 Ada RM specifically recommends that in a situation
10771 like this, @code{B} should be subject to the following
10772 implementation advice (RM 13.3(19)):
10775 19 If the Address of an object is specified, or it is imported
10776 or exported, then the implementation should not perform
10777 optimizations based on assumptions of no aliases.
10781 GNAT follows this recommendation, and goes further by also applying
10782 this recommendation to the overlaid variable (@code{A}
10783 in the above example) in this case. This means that the overlay
10784 works "as expected", in that a modification to one of the variables
10785 will affect the value of the other.
10787 @node Effect of Convention on Representation
10788 @section Effect of Convention on Representation
10789 @cindex Convention, effect on representation
10792 Normally the specification of a foreign language convention for a type or
10793 an object has no effect on the chosen representation. In particular, the
10794 representation chosen for data in GNAT generally meets the standard system
10795 conventions, and for example records are laid out in a manner that is
10796 consistent with C@. This means that specifying convention C (for example)
10799 There are four exceptions to this general rule:
10803 @item Convention Fortran and array subtypes
10804 If pragma Convention Fortran is specified for an array subtype, then in
10805 accordance with the implementation advice in section 3.6.2(11) of the
10806 Ada Reference Manual, the array will be stored in a Fortran-compatible
10807 column-major manner, instead of the normal default row-major order.
10809 @item Convention C and enumeration types
10810 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
10811 to accommodate all values of the type. For example, for the enumeration
10814 @smallexample @c ada
10815 type Color is (Red, Green, Blue);
10819 8 bits is sufficient to store all values of the type, so by default, objects
10820 of type @code{Color} will be represented using 8 bits. However, normal C
10821 convention is to use 32 bits for all enum values in C, since enum values
10822 are essentially of type int. If pragma @code{Convention C} is specified for an
10823 Ada enumeration type, then the size is modified as necessary (usually to
10824 32 bits) to be consistent with the C convention for enum values.
10826 Note that this treatment applies only to types. If Convention C is given for
10827 an enumeration object, where the enumeration type is not Convention C, then
10828 Object_Size bits are allocated. For example, for a normal enumeration type,
10829 with less than 256 elements, only 8 bits will be allocated for the object.
10830 Since this may be a surprise in terms of what C expects, GNAT will issue a
10831 warning in this situation. The warning can be suppressed by giving an explicit
10832 size clause specifying the desired size.
10834 @item Convention C/Fortran and Boolean types
10835 In C, the usual convention for boolean values, that is values used for
10836 conditions, is that zero represents false, and nonzero values represent
10837 true. In Ada, the normal convention is that two specific values, typically
10838 0/1, are used to represent false/true respectively.
10840 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
10841 value represents true).
10843 To accommodate the Fortran and C conventions, if a pragma Convention specifies
10844 C or Fortran convention for a derived Boolean, as in the following example:
10846 @smallexample @c ada
10847 type C_Switch is new Boolean;
10848 pragma Convention (C, C_Switch);
10852 then the GNAT generated code will treat any nonzero value as true. For truth
10853 values generated by GNAT, the conventional value 1 will be used for True, but
10854 when one of these values is read, any nonzero value is treated as True.
10856 @item Access types on OpenVMS
10857 For 64-bit OpenVMS systems, access types (other than those for unconstrained
10858 arrays) are 64-bits long. An exception to this rule is for the case of
10859 C-convention access types where there is no explicit size clause present (or
10860 inherited for derived types). In this case, GNAT chooses to make these
10861 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
10862 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
10866 @node Determining the Representations chosen by GNAT
10867 @section Determining the Representations chosen by GNAT
10868 @cindex Representation, determination of
10869 @cindex @code{-gnatR} switch
10872 Although the descriptions in this section are intended to be complete, it is
10873 often easier to simply experiment to see what GNAT accepts and what the
10874 effect is on the layout of types and objects.
10876 As required by the Ada RM, if a representation clause is not accepted, then
10877 it must be rejected as illegal by the compiler. However, when a
10878 representation clause or pragma is accepted, there can still be questions
10879 of what the compiler actually does. For example, if a partial record
10880 representation clause specifies the location of some components and not
10881 others, then where are the non-specified components placed? Or if pragma
10882 @code{Pack} is used on a record, then exactly where are the resulting
10883 fields placed? The section on pragma @code{Pack} in this chapter can be
10884 used to answer the second question, but it is often easier to just see
10885 what the compiler does.
10887 For this purpose, GNAT provides the option @code{-gnatR}. If you compile
10888 with this option, then the compiler will output information on the actual
10889 representations chosen, in a format similar to source representation
10890 clauses. For example, if we compile the package:
10892 @smallexample @c ada
10894 type r (x : boolean) is tagged record
10896 when True => S : String (1 .. 100);
10897 when False => null;
10901 type r2 is new r (false) with record
10906 y2 at 16 range 0 .. 31;
10913 type x1 is array (1 .. 10) of x;
10914 for x1'component_size use 11;
10916 type ia is access integer;
10918 type Rb1 is array (1 .. 13) of Boolean;
10921 type Rb2 is array (1 .. 65) of Boolean;
10937 using the switch @code{-gnatR} we obtain the following output:
10940 Representation information for unit q
10941 -------------------------------------
10944 for r'Alignment use 4;
10946 x at 4 range 0 .. 7;
10947 _tag at 0 range 0 .. 31;
10948 s at 5 range 0 .. 799;
10951 for r2'Size use 160;
10952 for r2'Alignment use 4;
10954 x at 4 range 0 .. 7;
10955 _tag at 0 range 0 .. 31;
10956 _parent at 0 range 0 .. 63;
10957 y2 at 16 range 0 .. 31;
10961 for x'Alignment use 1;
10963 y at 0 range 0 .. 7;
10966 for x1'Size use 112;
10967 for x1'Alignment use 1;
10968 for x1'Component_Size use 11;
10970 for rb1'Size use 13;
10971 for rb1'Alignment use 2;
10972 for rb1'Component_Size use 1;
10974 for rb2'Size use 72;
10975 for rb2'Alignment use 1;
10976 for rb2'Component_Size use 1;
10978 for x2'Size use 224;
10979 for x2'Alignment use 4;
10981 l1 at 0 range 0 .. 0;
10982 l2 at 0 range 1 .. 64;
10983 l3 at 12 range 0 .. 31;
10984 l4 at 16 range 0 .. 0;
10985 l5 at 16 range 1 .. 13;
10986 l6 at 18 range 0 .. 71;
10991 The Size values are actually the Object_Size, i.e.@: the default size that
10992 will be allocated for objects of the type.
10993 The ?? size for type r indicates that we have a variant record, and the
10994 actual size of objects will depend on the discriminant value.
10996 The Alignment values show the actual alignment chosen by the compiler
10997 for each record or array type.
10999 The record representation clause for type r shows where all fields
11000 are placed, including the compiler generated tag field (whose location
11001 cannot be controlled by the programmer).
11003 The record representation clause for the type extension r2 shows all the
11004 fields present, including the parent field, which is a copy of the fields
11005 of the parent type of r2, i.e.@: r1.
11007 The component size and size clauses for types rb1 and rb2 show
11008 the exact effect of pragma @code{Pack} on these arrays, and the record
11009 representation clause for type x2 shows how pragma @code{Pack} affects
11012 In some cases, it may be useful to cut and paste the representation clauses
11013 generated by the compiler into the original source to fix and guarantee
11014 the actual representation to be used.
11016 @node Standard Library Routines
11017 @chapter Standard Library Routines
11020 The Ada Reference Manual contains in Annex A a full description of an
11021 extensive set of standard library routines that can be used in any Ada
11022 program, and which must be provided by all Ada compilers. They are
11023 analogous to the standard C library used by C programs.
11025 GNAT implements all of the facilities described in annex A, and for most
11026 purposes the description in the Ada Reference Manual, or appropriate Ada
11027 text book, will be sufficient for making use of these facilities.
11029 In the case of the input-output facilities,
11030 @xref{The Implementation of Standard I/O},
11031 gives details on exactly how GNAT interfaces to the
11032 file system. For the remaining packages, the Ada Reference Manual
11033 should be sufficient. The following is a list of the packages included,
11034 together with a brief description of the functionality that is provided.
11036 For completeness, references are included to other predefined library
11037 routines defined in other sections of the Ada Reference Manual (these are
11038 cross-indexed from Annex A).
11042 This is a parent package for all the standard library packages. It is
11043 usually included implicitly in your program, and itself contains no
11044 useful data or routines.
11046 @item Ada.Calendar (9.6)
11047 @code{Calendar} provides time of day access, and routines for
11048 manipulating times and durations.
11050 @item Ada.Characters (A.3.1)
11051 This is a dummy parent package that contains no useful entities
11053 @item Ada.Characters.Handling (A.3.2)
11054 This package provides some basic character handling capabilities,
11055 including classification functions for classes of characters (e.g.@: test
11056 for letters, or digits).
11058 @item Ada.Characters.Latin_1 (A.3.3)
11059 This package includes a complete set of definitions of the characters
11060 that appear in type CHARACTER@. It is useful for writing programs that
11061 will run in international environments. For example, if you want an
11062 upper case E with an acute accent in a string, it is often better to use
11063 the definition of @code{UC_E_Acute} in this package. Then your program
11064 will print in an understandable manner even if your environment does not
11065 support these extended characters.
11067 @item Ada.Command_Line (A.15)
11068 This package provides access to the command line parameters and the name
11069 of the current program (analogous to the use of @code{argc} and @code{argv}
11070 in C), and also allows the exit status for the program to be set in a
11071 system-independent manner.
11073 @item Ada.Decimal (F.2)
11074 This package provides constants describing the range of decimal numbers
11075 implemented, and also a decimal divide routine (analogous to the COBOL
11076 verb DIVIDE .. GIVING .. REMAINDER ..)
11078 @item Ada.Direct_IO (A.8.4)
11079 This package provides input-output using a model of a set of records of
11080 fixed-length, containing an arbitrary definite Ada type, indexed by an
11081 integer record number.
11083 @item Ada.Dynamic_Priorities (D.5)
11084 This package allows the priorities of a task to be adjusted dynamically
11085 as the task is running.
11087 @item Ada.Exceptions (11.4.1)
11088 This package provides additional information on exceptions, and also
11089 contains facilities for treating exceptions as data objects, and raising
11090 exceptions with associated messages.
11092 @item Ada.Finalization (7.6)
11093 This package contains the declarations and subprograms to support the
11094 use of controlled types, providing for automatic initialization and
11095 finalization (analogous to the constructors and destructors of C++)
11097 @item Ada.Interrupts (C.3.2)
11098 This package provides facilities for interfacing to interrupts, which
11099 includes the set of signals or conditions that can be raised and
11100 recognized as interrupts.
11102 @item Ada.Interrupts.Names (C.3.2)
11103 This package provides the set of interrupt names (actually signal
11104 or condition names) that can be handled by GNAT@.
11106 @item Ada.IO_Exceptions (A.13)
11107 This package defines the set of exceptions that can be raised by use of
11108 the standard IO packages.
11111 This package contains some standard constants and exceptions used
11112 throughout the numerics packages. Note that the constants pi and e are
11113 defined here, and it is better to use these definitions than rolling
11116 @item Ada.Numerics.Complex_Elementary_Functions
11117 Provides the implementation of standard elementary functions (such as
11118 log and trigonometric functions) operating on complex numbers using the
11119 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11120 created by the package @code{Numerics.Complex_Types}.
11122 @item Ada.Numerics.Complex_Types
11123 This is a predefined instantiation of
11124 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11125 build the type @code{Complex} and @code{Imaginary}.
11127 @item Ada.Numerics.Discrete_Random
11128 This package provides a random number generator suitable for generating
11129 random integer values from a specified range.
11131 @item Ada.Numerics.Float_Random
11132 This package provides a random number generator suitable for generating
11133 uniformly distributed floating point values.
11135 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11136 This is a generic version of the package that provides the
11137 implementation of standard elementary functions (such as log and
11138 trigonometric functions) for an arbitrary complex type.
11140 The following predefined instantiations of this package are provided:
11144 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11146 @code{Ada.Numerics.Complex_Elementary_Functions}
11148 @code{Ada.Numerics.
11149 Long_Complex_Elementary_Functions}
11152 @item Ada.Numerics.Generic_Complex_Types
11153 This is a generic package that allows the creation of complex types,
11154 with associated complex arithmetic operations.
11156 The following predefined instantiations of this package exist
11159 @code{Ada.Numerics.Short_Complex_Complex_Types}
11161 @code{Ada.Numerics.Complex_Complex_Types}
11163 @code{Ada.Numerics.Long_Complex_Complex_Types}
11166 @item Ada.Numerics.Generic_Elementary_Functions
11167 This is a generic package that provides the implementation of standard
11168 elementary functions (such as log an trigonometric functions) for an
11169 arbitrary float type.
11171 The following predefined instantiations of this package exist
11175 @code{Ada.Numerics.Short_Elementary_Functions}
11177 @code{Ada.Numerics.Elementary_Functions}
11179 @code{Ada.Numerics.Long_Elementary_Functions}
11182 @item Ada.Real_Time (D.8)
11183 This package provides facilities similar to those of @code{Calendar}, but
11184 operating with a finer clock suitable for real time control. Note that
11185 annex D requires that there be no backward clock jumps, and GNAT generally
11186 guarantees this behavior, but of course if the external clock on which
11187 the GNAT runtime depends is deliberately reset by some external event,
11188 then such a backward jump may occur.
11190 @item Ada.Sequential_IO (A.8.1)
11191 This package provides input-output facilities for sequential files,
11192 which can contain a sequence of values of a single type, which can be
11193 any Ada type, including indefinite (unconstrained) types.
11195 @item Ada.Storage_IO (A.9)
11196 This package provides a facility for mapping arbitrary Ada types to and
11197 from a storage buffer. It is primarily intended for the creation of new
11200 @item Ada.Streams (13.13.1)
11201 This is a generic package that provides the basic support for the
11202 concept of streams as used by the stream attributes (@code{Input},
11203 @code{Output}, @code{Read} and @code{Write}).
11205 @item Ada.Streams.Stream_IO (A.12.1)
11206 This package is a specialization of the type @code{Streams} defined in
11207 package @code{Streams} together with a set of operations providing
11208 Stream_IO capability. The Stream_IO model permits both random and
11209 sequential access to a file which can contain an arbitrary set of values
11210 of one or more Ada types.
11212 @item Ada.Strings (A.4.1)
11213 This package provides some basic constants used by the string handling
11216 @item Ada.Strings.Bounded (A.4.4)
11217 This package provides facilities for handling variable length
11218 strings. The bounded model requires a maximum length. It is thus
11219 somewhat more limited than the unbounded model, but avoids the use of
11220 dynamic allocation or finalization.
11222 @item Ada.Strings.Fixed (A.4.3)
11223 This package provides facilities for handling fixed length strings.
11225 @item Ada.Strings.Maps (A.4.2)
11226 This package provides facilities for handling character mappings and
11227 arbitrarily defined subsets of characters. For instance it is useful in
11228 defining specialized translation tables.
11230 @item Ada.Strings.Maps.Constants (A.4.6)
11231 This package provides a standard set of predefined mappings and
11232 predefined character sets. For example, the standard upper to lower case
11233 conversion table is found in this package. Note that upper to lower case
11234 conversion is non-trivial if you want to take the entire set of
11235 characters, including extended characters like E with an acute accent,
11236 into account. You should use the mappings in this package (rather than
11237 adding 32 yourself) to do case mappings.
11239 @item Ada.Strings.Unbounded (A.4.5)
11240 This package provides facilities for handling variable length
11241 strings. The unbounded model allows arbitrary length strings, but
11242 requires the use of dynamic allocation and finalization.
11244 @item Ada.Strings.Wide_Bounded (A.4.7)
11245 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11246 @itemx Ada.Strings.Wide_Maps (A.4.7)
11247 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11248 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11249 These packages provide analogous capabilities to the corresponding
11250 packages without @samp{Wide_} in the name, but operate with the types
11251 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11252 and @code{Character}.
11254 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11255 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11256 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11257 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11258 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11259 These packages provide analogous capabilities to the corresponding
11260 packages without @samp{Wide_} in the name, but operate with the types
11261 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11262 of @code{String} and @code{Character}.
11264 @item Ada.Synchronous_Task_Control (D.10)
11265 This package provides some standard facilities for controlling task
11266 communication in a synchronous manner.
11269 This package contains definitions for manipulation of the tags of tagged
11272 @item Ada.Task_Attributes
11273 This package provides the capability of associating arbitrary
11274 task-specific data with separate tasks.
11277 This package provides basic text input-output capabilities for
11278 character, string and numeric data. The subpackages of this
11279 package are listed next.
11281 @item Ada.Text_IO.Decimal_IO
11282 Provides input-output facilities for decimal fixed-point types
11284 @item Ada.Text_IO.Enumeration_IO
11285 Provides input-output facilities for enumeration types.
11287 @item Ada.Text_IO.Fixed_IO
11288 Provides input-output facilities for ordinary fixed-point types.
11290 @item Ada.Text_IO.Float_IO
11291 Provides input-output facilities for float types. The following
11292 predefined instantiations of this generic package are available:
11296 @code{Short_Float_Text_IO}
11298 @code{Float_Text_IO}
11300 @code{Long_Float_Text_IO}
11303 @item Ada.Text_IO.Integer_IO
11304 Provides input-output facilities for integer types. The following
11305 predefined instantiations of this generic package are available:
11308 @item Short_Short_Integer
11309 @code{Ada.Short_Short_Integer_Text_IO}
11310 @item Short_Integer
11311 @code{Ada.Short_Integer_Text_IO}
11313 @code{Ada.Integer_Text_IO}
11315 @code{Ada.Long_Integer_Text_IO}
11316 @item Long_Long_Integer
11317 @code{Ada.Long_Long_Integer_Text_IO}
11320 @item Ada.Text_IO.Modular_IO
11321 Provides input-output facilities for modular (unsigned) types
11323 @item Ada.Text_IO.Complex_IO (G.1.3)
11324 This package provides basic text input-output capabilities for complex
11327 @item Ada.Text_IO.Editing (F.3.3)
11328 This package contains routines for edited output, analogous to the use
11329 of pictures in COBOL@. The picture formats used by this package are a
11330 close copy of the facility in COBOL@.
11332 @item Ada.Text_IO.Text_Streams (A.12.2)
11333 This package provides a facility that allows Text_IO files to be treated
11334 as streams, so that the stream attributes can be used for writing
11335 arbitrary data, including binary data, to Text_IO files.
11337 @item Ada.Unchecked_Conversion (13.9)
11338 This generic package allows arbitrary conversion from one type to
11339 another of the same size, providing for breaking the type safety in
11340 special circumstances.
11342 If the types have the same Size (more accurately the same Value_Size),
11343 then the effect is simply to transfer the bits from the source to the
11344 target type without any modification. This usage is well defined, and
11345 for simple types whose representation is typically the same across
11346 all implementations, gives a portable method of performing such
11349 If the types do not have the same size, then the result is implementation
11350 defined, and thus may be non-portable. The following describes how GNAT
11351 handles such unchecked conversion cases.
11353 If the types are of different sizes, and are both discrete types, then
11354 the effect is of a normal type conversion without any constraint checking.
11355 In particular if the result type has a larger size, the result will be
11356 zero or sign extended. If the result type has a smaller size, the result
11357 will be truncated by ignoring high order bits.
11359 If the types are of different sizes, and are not both discrete types,
11360 then the conversion works as though pointers were created to the source
11361 and target, and the pointer value is converted. The effect is that bits
11362 are copied from successive low order storage units and bits of the source
11363 up to the length of the target type.
11365 A warning is issued if the lengths differ, since the effect in this
11366 case is implementation dependent, and the above behavior may not match
11367 that of some other compiler.
11369 A pointer to one type may be converted to a pointer to another type using
11370 unchecked conversion. The only case in which the effect is undefined is
11371 when one or both pointers are pointers to unconstrained array types. In
11372 this case, the bounds information may get incorrectly transferred, and in
11373 particular, GNAT uses double size pointers for such types, and it is
11374 meaningless to convert between such pointer types. GNAT will issue a
11375 warning if the alignment of the target designated type is more strict
11376 than the alignment of the source designated type (since the result may
11377 be unaligned in this case).
11379 A pointer other than a pointer to an unconstrained array type may be
11380 converted to and from System.Address. Such usage is common in Ada 83
11381 programs, but note that Ada.Address_To_Access_Conversions is the
11382 preferred method of performing such conversions in Ada 95 and Ada 2005.
11384 unchecked conversion nor Ada.Address_To_Access_Conversions should be
11385 used in conjunction with pointers to unconstrained objects, since
11386 the bounds information cannot be handled correctly in this case.
11388 @item Ada.Unchecked_Deallocation (13.11.2)
11389 This generic package allows explicit freeing of storage previously
11390 allocated by use of an allocator.
11392 @item Ada.Wide_Text_IO (A.11)
11393 This package is similar to @code{Ada.Text_IO}, except that the external
11394 file supports wide character representations, and the internal types are
11395 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11396 and @code{String}. It contains generic subpackages listed next.
11398 @item Ada.Wide_Text_IO.Decimal_IO
11399 Provides input-output facilities for decimal fixed-point types
11401 @item Ada.Wide_Text_IO.Enumeration_IO
11402 Provides input-output facilities for enumeration types.
11404 @item Ada.Wide_Text_IO.Fixed_IO
11405 Provides input-output facilities for ordinary fixed-point types.
11407 @item Ada.Wide_Text_IO.Float_IO
11408 Provides input-output facilities for float types. The following
11409 predefined instantiations of this generic package are available:
11413 @code{Short_Float_Wide_Text_IO}
11415 @code{Float_Wide_Text_IO}
11417 @code{Long_Float_Wide_Text_IO}
11420 @item Ada.Wide_Text_IO.Integer_IO
11421 Provides input-output facilities for integer types. The following
11422 predefined instantiations of this generic package are available:
11425 @item Short_Short_Integer
11426 @code{Ada.Short_Short_Integer_Wide_Text_IO}
11427 @item Short_Integer
11428 @code{Ada.Short_Integer_Wide_Text_IO}
11430 @code{Ada.Integer_Wide_Text_IO}
11432 @code{Ada.Long_Integer_Wide_Text_IO}
11433 @item Long_Long_Integer
11434 @code{Ada.Long_Long_Integer_Wide_Text_IO}
11437 @item Ada.Wide_Text_IO.Modular_IO
11438 Provides input-output facilities for modular (unsigned) types
11440 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
11441 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11442 external file supports wide character representations.
11444 @item Ada.Wide_Text_IO.Editing (F.3.4)
11445 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11446 types are @code{Wide_Character} and @code{Wide_String} instead of
11447 @code{Character} and @code{String}.
11449 @item Ada.Wide_Text_IO.Streams (A.12.3)
11450 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11451 types are @code{Wide_Character} and @code{Wide_String} instead of
11452 @code{Character} and @code{String}.
11454 @item Ada.Wide_Wide_Text_IO (A.11)
11455 This package is similar to @code{Ada.Text_IO}, except that the external
11456 file supports wide character representations, and the internal types are
11457 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11458 and @code{String}. It contains generic subpackages listed next.
11460 @item Ada.Wide_Wide_Text_IO.Decimal_IO
11461 Provides input-output facilities for decimal fixed-point types
11463 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
11464 Provides input-output facilities for enumeration types.
11466 @item Ada.Wide_Wide_Text_IO.Fixed_IO
11467 Provides input-output facilities for ordinary fixed-point types.
11469 @item Ada.Wide_Wide_Text_IO.Float_IO
11470 Provides input-output facilities for float types. The following
11471 predefined instantiations of this generic package are available:
11475 @code{Short_Float_Wide_Wide_Text_IO}
11477 @code{Float_Wide_Wide_Text_IO}
11479 @code{Long_Float_Wide_Wide_Text_IO}
11482 @item Ada.Wide_Wide_Text_IO.Integer_IO
11483 Provides input-output facilities for integer types. The following
11484 predefined instantiations of this generic package are available:
11487 @item Short_Short_Integer
11488 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
11489 @item Short_Integer
11490 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
11492 @code{Ada.Integer_Wide_Wide_Text_IO}
11494 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
11495 @item Long_Long_Integer
11496 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
11499 @item Ada.Wide_Wide_Text_IO.Modular_IO
11500 Provides input-output facilities for modular (unsigned) types
11502 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
11503 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11504 external file supports wide character representations.
11506 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
11507 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11508 types are @code{Wide_Character} and @code{Wide_String} instead of
11509 @code{Character} and @code{String}.
11511 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
11512 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11513 types are @code{Wide_Character} and @code{Wide_String} instead of
11514 @code{Character} and @code{String}.
11519 @node The Implementation of Standard I/O
11520 @chapter The Implementation of Standard I/O
11523 GNAT implements all the required input-output facilities described in
11524 A.6 through A.14. These sections of the Ada Reference Manual describe the
11525 required behavior of these packages from the Ada point of view, and if
11526 you are writing a portable Ada program that does not need to know the
11527 exact manner in which Ada maps to the outside world when it comes to
11528 reading or writing external files, then you do not need to read this
11529 chapter. As long as your files are all regular files (not pipes or
11530 devices), and as long as you write and read the files only from Ada, the
11531 description in the Ada Reference Manual is sufficient.
11533 However, if you want to do input-output to pipes or other devices, such
11534 as the keyboard or screen, or if the files you are dealing with are
11535 either generated by some other language, or to be read by some other
11536 language, then you need to know more about the details of how the GNAT
11537 implementation of these input-output facilities behaves.
11539 In this chapter we give a detailed description of exactly how GNAT
11540 interfaces to the file system. As always, the sources of the system are
11541 available to you for answering questions at an even more detailed level,
11542 but for most purposes the information in this chapter will suffice.
11544 Another reason that you may need to know more about how input-output is
11545 implemented arises when you have a program written in mixed languages
11546 where, for example, files are shared between the C and Ada sections of
11547 the same program. GNAT provides some additional facilities, in the form
11548 of additional child library packages, that facilitate this sharing, and
11549 these additional facilities are also described in this chapter.
11552 * Standard I/O Packages::
11558 * Wide_Wide_Text_IO::
11561 * Filenames encoding::
11563 * Operations on C Streams::
11564 * Interfacing to C Streams::
11567 @node Standard I/O Packages
11568 @section Standard I/O Packages
11571 The Standard I/O packages described in Annex A for
11577 Ada.Text_IO.Complex_IO
11579 Ada.Text_IO.Text_Streams
11583 Ada.Wide_Text_IO.Complex_IO
11585 Ada.Wide_Text_IO.Text_Streams
11587 Ada.Wide_Wide_Text_IO
11589 Ada.Wide_Wide_Text_IO.Complex_IO
11591 Ada.Wide_Wide_Text_IO.Text_Streams
11601 are implemented using the C
11602 library streams facility; where
11606 All files are opened using @code{fopen}.
11608 All input/output operations use @code{fread}/@code{fwrite}.
11612 There is no internal buffering of any kind at the Ada library level. The only
11613 buffering is that provided at the system level in the implementation of the
11614 library routines that support streams. This facilitates shared use of these
11615 streams by mixed language programs. Note though that system level buffering is
11616 explicitly enabled at elaboration of the standard I/O packages and that can
11617 have an impact on mixed language programs, in particular those using I/O before
11618 calling the Ada elaboration routine (e.g. adainit). It is recommended to call
11619 the Ada elaboration routine before performing any I/O or when impractical,
11620 flush the common I/O streams and in particular Standard_Output before
11621 elaborating the Ada code.
11624 @section FORM Strings
11627 The format of a FORM string in GNAT is:
11630 "keyword=value,keyword=value,@dots{},keyword=value"
11634 where letters may be in upper or lower case, and there are no spaces
11635 between values. The order of the entries is not important. Currently
11636 there are two keywords defined.
11640 WCEM=[n|h|u|s|e|8|b]
11644 The use of these parameters is described later in this section.
11650 Direct_IO can only be instantiated for definite types. This is a
11651 restriction of the Ada language, which means that the records are fixed
11652 length (the length being determined by @code{@var{type}'Size}, rounded
11653 up to the next storage unit boundary if necessary).
11655 The records of a Direct_IO file are simply written to the file in index
11656 sequence, with the first record starting at offset zero, and subsequent
11657 records following. There is no control information of any kind. For
11658 example, if 32-bit integers are being written, each record takes
11659 4-bytes, so the record at index @var{K} starts at offset
11660 (@var{K}@minus{}1)*4.
11662 There is no limit on the size of Direct_IO files, they are expanded as
11663 necessary to accommodate whatever records are written to the file.
11665 @node Sequential_IO
11666 @section Sequential_IO
11669 Sequential_IO may be instantiated with either a definite (constrained)
11670 or indefinite (unconstrained) type.
11672 For the definite type case, the elements written to the file are simply
11673 the memory images of the data values with no control information of any
11674 kind. The resulting file should be read using the same type, no validity
11675 checking is performed on input.
11677 For the indefinite type case, the elements written consist of two
11678 parts. First is the size of the data item, written as the memory image
11679 of a @code{Interfaces.C.size_t} value, followed by the memory image of
11680 the data value. The resulting file can only be read using the same
11681 (unconstrained) type. Normal assignment checks are performed on these
11682 read operations, and if these checks fail, @code{Data_Error} is
11683 raised. In particular, in the array case, the lengths must match, and in
11684 the variant record case, if the variable for a particular read operation
11685 is constrained, the discriminants must match.
11687 Note that it is not possible to use Sequential_IO to write variable
11688 length array items, and then read the data back into different length
11689 arrays. For example, the following will raise @code{Data_Error}:
11691 @smallexample @c ada
11692 package IO is new Sequential_IO (String);
11697 IO.Write (F, "hello!")
11698 IO.Reset (F, Mode=>In_File);
11705 On some Ada implementations, this will print @code{hell}, but the program is
11706 clearly incorrect, since there is only one element in the file, and that
11707 element is the string @code{hello!}.
11709 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
11710 using Stream_IO, and this is the preferred mechanism. In particular, the
11711 above program fragment rewritten to use Stream_IO will work correctly.
11717 Text_IO files consist of a stream of characters containing the following
11718 special control characters:
11721 LF (line feed, 16#0A#) Line Mark
11722 FF (form feed, 16#0C#) Page Mark
11726 A canonical Text_IO file is defined as one in which the following
11727 conditions are met:
11731 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
11735 The character @code{FF} is used only as a page mark, i.e.@: to mark the
11736 end of a page and consequently can appear only immediately following a
11737 @code{LF} (line mark) character.
11740 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
11741 (line mark, page mark). In the former case, the page mark is implicitly
11742 assumed to be present.
11746 A file written using Text_IO will be in canonical form provided that no
11747 explicit @code{LF} or @code{FF} characters are written using @code{Put}
11748 or @code{Put_Line}. There will be no @code{FF} character at the end of
11749 the file unless an explicit @code{New_Page} operation was performed
11750 before closing the file.
11752 A canonical Text_IO file that is a regular file (i.e., not a device or a
11753 pipe) can be read using any of the routines in Text_IO@. The
11754 semantics in this case will be exactly as defined in the Ada Reference
11755 Manual, and all the routines in Text_IO are fully implemented.
11757 A text file that does not meet the requirements for a canonical Text_IO
11758 file has one of the following:
11762 The file contains @code{FF} characters not immediately following a
11763 @code{LF} character.
11766 The file contains @code{LF} or @code{FF} characters written by
11767 @code{Put} or @code{Put_Line}, which are not logically considered to be
11768 line marks or page marks.
11771 The file ends in a character other than @code{LF} or @code{FF},
11772 i.e.@: there is no explicit line mark or page mark at the end of the file.
11776 Text_IO can be used to read such non-standard text files but subprograms
11777 to do with line or page numbers do not have defined meanings. In
11778 particular, a @code{FF} character that does not follow a @code{LF}
11779 character may or may not be treated as a page mark from the point of
11780 view of page and line numbering. Every @code{LF} character is considered
11781 to end a line, and there is an implied @code{LF} character at the end of
11785 * Text_IO Stream Pointer Positioning::
11786 * Text_IO Reading and Writing Non-Regular Files::
11788 * Treating Text_IO Files as Streams::
11789 * Text_IO Extensions::
11790 * Text_IO Facilities for Unbounded Strings::
11793 @node Text_IO Stream Pointer Positioning
11794 @subsection Stream Pointer Positioning
11797 @code{Ada.Text_IO} has a definition of current position for a file that
11798 is being read. No internal buffering occurs in Text_IO, and usually the
11799 physical position in the stream used to implement the file corresponds
11800 to this logical position defined by Text_IO@. There are two exceptions:
11804 After a call to @code{End_Of_Page} that returns @code{True}, the stream
11805 is positioned past the @code{LF} (line mark) that precedes the page
11806 mark. Text_IO maintains an internal flag so that subsequent read
11807 operations properly handle the logical position which is unchanged by
11808 the @code{End_Of_Page} call.
11811 After a call to @code{End_Of_File} that returns @code{True}, if the
11812 Text_IO file was positioned before the line mark at the end of file
11813 before the call, then the logical position is unchanged, but the stream
11814 is physically positioned right at the end of file (past the line mark,
11815 and past a possible page mark following the line mark. Again Text_IO
11816 maintains internal flags so that subsequent read operations properly
11817 handle the logical position.
11821 These discrepancies have no effect on the observable behavior of
11822 Text_IO, but if a single Ada stream is shared between a C program and
11823 Ada program, or shared (using @samp{shared=yes} in the form string)
11824 between two Ada files, then the difference may be observable in some
11827 @node Text_IO Reading and Writing Non-Regular Files
11828 @subsection Reading and Writing Non-Regular Files
11831 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
11832 can be used for reading and writing. Writing is not affected and the
11833 sequence of characters output is identical to the normal file case, but
11834 for reading, the behavior of Text_IO is modified to avoid undesirable
11835 look-ahead as follows:
11837 An input file that is not a regular file is considered to have no page
11838 marks. Any @code{Ascii.FF} characters (the character normally used for a
11839 page mark) appearing in the file are considered to be data
11840 characters. In particular:
11844 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
11845 following a line mark. If a page mark appears, it will be treated as a
11849 This avoids the need to wait for an extra character to be typed or
11850 entered from the pipe to complete one of these operations.
11853 @code{End_Of_Page} always returns @code{False}
11856 @code{End_Of_File} will return @code{False} if there is a page mark at
11857 the end of the file.
11861 Output to non-regular files is the same as for regular files. Page marks
11862 may be written to non-regular files using @code{New_Page}, but as noted
11863 above they will not be treated as page marks on input if the output is
11864 piped to another Ada program.
11866 Another important discrepancy when reading non-regular files is that the end
11867 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
11868 pressing the @key{EOT} key,
11870 is signaled once (i.e.@: the test @code{End_Of_File}
11871 will yield @code{True}, or a read will
11872 raise @code{End_Error}), but then reading can resume
11873 to read data past that end of
11874 file indication, until another end of file indication is entered.
11876 @node Get_Immediate
11877 @subsection Get_Immediate
11878 @cindex Get_Immediate
11881 Get_Immediate returns the next character (including control characters)
11882 from the input file. In particular, Get_Immediate will return LF or FF
11883 characters used as line marks or page marks. Such operations leave the
11884 file positioned past the control character, and it is thus not treated
11885 as having its normal function. This means that page, line and column
11886 counts after this kind of Get_Immediate call are set as though the mark
11887 did not occur. In the case where a Get_Immediate leaves the file
11888 positioned between the line mark and page mark (which is not normally
11889 possible), it is undefined whether the FF character will be treated as a
11892 @node Treating Text_IO Files as Streams
11893 @subsection Treating Text_IO Files as Streams
11894 @cindex Stream files
11897 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
11898 as a stream. Data written to a Text_IO file in this stream mode is
11899 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
11900 16#0C# (@code{FF}), the resulting file may have non-standard
11901 format. Similarly if read operations are used to read from a Text_IO
11902 file treated as a stream, then @code{LF} and @code{FF} characters may be
11903 skipped and the effect is similar to that described above for
11904 @code{Get_Immediate}.
11906 @node Text_IO Extensions
11907 @subsection Text_IO Extensions
11908 @cindex Text_IO extensions
11911 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
11912 to the standard @code{Text_IO} package:
11915 @item function File_Exists (Name : String) return Boolean;
11916 Determines if a file of the given name exists.
11918 @item function Get_Line return String;
11919 Reads a string from the standard input file. The value returned is exactly
11920 the length of the line that was read.
11922 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
11923 Similar, except that the parameter File specifies the file from which
11924 the string is to be read.
11928 @node Text_IO Facilities for Unbounded Strings
11929 @subsection Text_IO Facilities for Unbounded Strings
11930 @cindex Text_IO for unbounded strings
11931 @cindex Unbounded_String, Text_IO operations
11934 The package @code{Ada.Strings.Unbounded.Text_IO}
11935 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
11936 subprograms useful for Text_IO operations on unbounded strings:
11940 @item function Get_Line (File : File_Type) return Unbounded_String;
11941 Reads a line from the specified file
11942 and returns the result as an unbounded string.
11944 @item procedure Put (File : File_Type; U : Unbounded_String);
11945 Writes the value of the given unbounded string to the specified file
11946 Similar to the effect of
11947 @code{Put (To_String (U))} except that an extra copy is avoided.
11949 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
11950 Writes the value of the given unbounded string to the specified file,
11951 followed by a @code{New_Line}.
11952 Similar to the effect of @code{Put_Line (To_String (U))} except
11953 that an extra copy is avoided.
11957 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
11958 and is optional. If the parameter is omitted, then the standard input or
11959 output file is referenced as appropriate.
11961 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
11962 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
11963 @code{Wide_Text_IO} functionality for unbounded wide strings.
11965 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
11966 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
11967 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
11970 @section Wide_Text_IO
11973 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
11974 both input and output files may contain special sequences that represent
11975 wide character values. The encoding scheme for a given file may be
11976 specified using a FORM parameter:
11983 as part of the FORM string (WCEM = wide character encoding method),
11984 where @var{x} is one of the following characters
11990 Upper half encoding
12002 The encoding methods match those that
12003 can be used in a source
12004 program, but there is no requirement that the encoding method used for
12005 the source program be the same as the encoding method used for files,
12006 and different files may use different encoding methods.
12008 The default encoding method for the standard files, and for opened files
12009 for which no WCEM parameter is given in the FORM string matches the
12010 wide character encoding specified for the main program (the default
12011 being brackets encoding if no coding method was specified with -gnatW).
12015 In this encoding, a wide character is represented by a five character
12023 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12024 characters (using upper case letters) of the wide character code. For
12025 example, ESC A345 is used to represent the wide character with code
12026 16#A345#. This scheme is compatible with use of the full
12027 @code{Wide_Character} set.
12029 @item Upper Half Coding
12030 The wide character with encoding 16#abcd#, where the upper bit is on
12031 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12032 16#cd#. The second byte may never be a format control character, but is
12033 not required to be in the upper half. This method can be also used for
12034 shift-JIS or EUC where the internal coding matches the external coding.
12036 @item Shift JIS Coding
12037 A wide character is represented by a two character sequence 16#ab# and
12038 16#cd#, with the restrictions described for upper half encoding as
12039 described above. The internal character code is the corresponding JIS
12040 character according to the standard algorithm for Shift-JIS
12041 conversion. Only characters defined in the JIS code set table can be
12042 used with this encoding method.
12045 A wide character is represented by a two character sequence 16#ab# and
12046 16#cd#, with both characters being in the upper half. The internal
12047 character code is the corresponding JIS character according to the EUC
12048 encoding algorithm. Only characters defined in the JIS code set table
12049 can be used with this encoding method.
12052 A wide character is represented using
12053 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12054 10646-1/Am.2. Depending on the character value, the representation
12055 is a one, two, or three byte sequence:
12058 16#0000#-16#007f#: 2#0xxxxxxx#
12059 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12060 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12064 where the xxx bits correspond to the left-padded bits of the
12065 16-bit character value. Note that all lower half ASCII characters
12066 are represented as ASCII bytes and all upper half characters and
12067 other wide characters are represented as sequences of upper-half
12068 (The full UTF-8 scheme allows for encoding 31-bit characters as
12069 6-byte sequences, but in this implementation, all UTF-8 sequences
12070 of four or more bytes length will raise a Constraint_Error, as
12071 will all invalid UTF-8 sequences.)
12073 @item Brackets Coding
12074 In this encoding, a wide character is represented by the following eight
12075 character sequence:
12082 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12083 characters (using uppercase letters) of the wide character code. For
12084 example, @code{["A345"]} is used to represent the wide character with code
12086 This scheme is compatible with use of the full Wide_Character set.
12087 On input, brackets coding can also be used for upper half characters,
12088 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12089 is only used for wide characters with a code greater than @code{16#FF#}.
12091 Note that brackets coding is not normally used in the context of
12092 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12093 a portable way of encoding source files. In the context of Wide_Text_IO
12094 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12095 any instance of the left bracket character other than to encode wide
12096 character values using the brackets encoding method. In practice it is
12097 expected that some standard wide character encoding method such
12098 as UTF-8 will be used for text input output.
12100 If brackets notation is used, then any occurrence of a left bracket
12101 in the input file which is not the start of a valid wide character
12102 sequence will cause Constraint_Error to be raised. It is possible to
12103 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12104 input will interpret this as a left bracket.
12106 However, when a left bracket is output, it will be output as a left bracket
12107 and not as ["5B"]. We make this decision because for normal use of
12108 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12109 brackets. For example, if we write:
12112 Put_Line ("Start of output [first run]");
12116 we really do not want to have the left bracket in this message clobbered so
12117 that the output reads:
12120 Start of output ["5B"]first run]
12124 In practice brackets encoding is reasonably useful for normal Put_Line use
12125 since we won't get confused between left brackets and wide character
12126 sequences in the output. But for input, or when files are written out
12127 and read back in, it really makes better sense to use one of the standard
12128 encoding methods such as UTF-8.
12133 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12134 not all wide character
12135 values can be represented. An attempt to output a character that cannot
12136 be represented using the encoding scheme for the file causes
12137 Constraint_Error to be raised. An invalid wide character sequence on
12138 input also causes Constraint_Error to be raised.
12141 * Wide_Text_IO Stream Pointer Positioning::
12142 * Wide_Text_IO Reading and Writing Non-Regular Files::
12145 @node Wide_Text_IO Stream Pointer Positioning
12146 @subsection Stream Pointer Positioning
12149 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12150 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12153 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12154 normal lower ASCII set (i.e.@: a character in the range:
12156 @smallexample @c ada
12157 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12161 then although the logical position of the file pointer is unchanged by
12162 the @code{Look_Ahead} call, the stream is physically positioned past the
12163 wide character sequence. Again this is to avoid the need for buffering
12164 or backup, and all @code{Wide_Text_IO} routines check the internal
12165 indication that this situation has occurred so that this is not visible
12166 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
12167 can be observed if the wide text file shares a stream with another file.
12169 @node Wide_Text_IO Reading and Writing Non-Regular Files
12170 @subsection Reading and Writing Non-Regular Files
12173 As in the case of Text_IO, when a non-regular file is read, it is
12174 assumed that the file contains no page marks (any form characters are
12175 treated as data characters), and @code{End_Of_Page} always returns
12176 @code{False}. Similarly, the end of file indication is not sticky, so
12177 it is possible to read beyond an end of file.
12179 @node Wide_Wide_Text_IO
12180 @section Wide_Wide_Text_IO
12183 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12184 both input and output files may contain special sequences that represent
12185 wide wide character values. The encoding scheme for a given file may be
12186 specified using a FORM parameter:
12193 as part of the FORM string (WCEM = wide character encoding method),
12194 where @var{x} is one of the following characters
12200 Upper half encoding
12212 The encoding methods match those that
12213 can be used in a source
12214 program, but there is no requirement that the encoding method used for
12215 the source program be the same as the encoding method used for files,
12216 and different files may use different encoding methods.
12218 The default encoding method for the standard files, and for opened files
12219 for which no WCEM parameter is given in the FORM string matches the
12220 wide character encoding specified for the main program (the default
12221 being brackets encoding if no coding method was specified with -gnatW).
12226 A wide character is represented using
12227 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12228 10646-1/Am.2. Depending on the character value, the representation
12229 is a one, two, three, or four byte sequence:
12232 16#000000#-16#00007f#: 2#0xxxxxxx#
12233 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12234 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12235 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12239 where the xxx bits correspond to the left-padded bits of the
12240 21-bit character value. Note that all lower half ASCII characters
12241 are represented as ASCII bytes and all upper half characters and
12242 other wide characters are represented as sequences of upper-half
12245 @item Brackets Coding
12246 In this encoding, a wide wide character is represented by the following eight
12247 character sequence if is in wide character range
12253 and by the following ten character sequence if not
12256 [ " a b c d e f " ]
12260 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12261 are the four or six hexadecimal
12262 characters (using uppercase letters) of the wide wide character code. For
12263 example, @code{["01A345"]} is used to represent the wide wide character
12264 with code @code{16#01A345#}.
12266 This scheme is compatible with use of the full Wide_Wide_Character set.
12267 On input, brackets coding can also be used for upper half characters,
12268 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12269 is only used for wide characters with a code greater than @code{16#FF#}.
12274 If is also possible to use the other Wide_Character encoding methods,
12275 such as Shift-JIS, but the other schemes cannot support the full range
12276 of wide wide characters.
12277 An attempt to output a character that cannot
12278 be represented using the encoding scheme for the file causes
12279 Constraint_Error to be raised. An invalid wide character sequence on
12280 input also causes Constraint_Error to be raised.
12283 * Wide_Wide_Text_IO Stream Pointer Positioning::
12284 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12287 @node Wide_Wide_Text_IO Stream Pointer Positioning
12288 @subsection Stream Pointer Positioning
12291 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12292 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12295 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12296 normal lower ASCII set (i.e.@: a character in the range:
12298 @smallexample @c ada
12299 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12303 then although the logical position of the file pointer is unchanged by
12304 the @code{Look_Ahead} call, the stream is physically positioned past the
12305 wide character sequence. Again this is to avoid the need for buffering
12306 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
12307 indication that this situation has occurred so that this is not visible
12308 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
12309 can be observed if the wide text file shares a stream with another file.
12311 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
12312 @subsection Reading and Writing Non-Regular Files
12315 As in the case of Text_IO, when a non-regular file is read, it is
12316 assumed that the file contains no page marks (any form characters are
12317 treated as data characters), and @code{End_Of_Page} always returns
12318 @code{False}. Similarly, the end of file indication is not sticky, so
12319 it is possible to read beyond an end of file.
12325 A stream file is a sequence of bytes, where individual elements are
12326 written to the file as described in the Ada Reference Manual. The type
12327 @code{Stream_Element} is simply a byte. There are two ways to read or
12328 write a stream file.
12332 The operations @code{Read} and @code{Write} directly read or write a
12333 sequence of stream elements with no control information.
12336 The stream attributes applied to a stream file transfer data in the
12337 manner described for stream attributes.
12341 @section Shared Files
12344 Section A.14 of the Ada Reference Manual allows implementations to
12345 provide a wide variety of behavior if an attempt is made to access the
12346 same external file with two or more internal files.
12348 To provide a full range of functionality, while at the same time
12349 minimizing the problems of portability caused by this implementation
12350 dependence, GNAT handles file sharing as follows:
12354 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
12355 to open two or more files with the same full name is considered an error
12356 and is not supported. The exception @code{Use_Error} will be
12357 raised. Note that a file that is not explicitly closed by the program
12358 remains open until the program terminates.
12361 If the form parameter @samp{shared=no} appears in the form string, the
12362 file can be opened or created with its own separate stream identifier,
12363 regardless of whether other files sharing the same external file are
12364 opened. The exact effect depends on how the C stream routines handle
12365 multiple accesses to the same external files using separate streams.
12368 If the form parameter @samp{shared=yes} appears in the form string for
12369 each of two or more files opened using the same full name, the same
12370 stream is shared between these files, and the semantics are as described
12371 in Ada Reference Manual, Section A.14.
12375 When a program that opens multiple files with the same name is ported
12376 from another Ada compiler to GNAT, the effect will be that
12377 @code{Use_Error} is raised.
12379 The documentation of the original compiler and the documentation of the
12380 program should then be examined to determine if file sharing was
12381 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
12382 and @code{Create} calls as required.
12384 When a program is ported from GNAT to some other Ada compiler, no
12385 special attention is required unless the @samp{shared=@var{xxx}} form
12386 parameter is used in the program. In this case, you must examine the
12387 documentation of the new compiler to see if it supports the required
12388 file sharing semantics, and form strings modified appropriately. Of
12389 course it may be the case that the program cannot be ported if the
12390 target compiler does not support the required functionality. The best
12391 approach in writing portable code is to avoid file sharing (and hence
12392 the use of the @samp{shared=@var{xxx}} parameter in the form string)
12395 One common use of file sharing in Ada 83 is the use of instantiations of
12396 Sequential_IO on the same file with different types, to achieve
12397 heterogeneous input-output. Although this approach will work in GNAT if
12398 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
12399 for this purpose (using the stream attributes)
12401 @node Filenames encoding
12402 @section Filenames encoding
12405 An encoding form parameter can be used to specify the filename
12406 encoding @samp{encoding=@var{xxx}}.
12410 If the form parameter @samp{encoding=utf8} appears in the form string, the
12411 filename must be encoded in UTF-8.
12414 If the form parameter @samp{encoding=8bits} appears in the form
12415 string, the filename must be a standard 8bits string.
12418 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
12419 value UTF-8 is used. This encoding form parameter is only supported on
12420 the Windows platform. On the other Operating Systems the runtime is
12421 supporting UTF-8 natively.
12424 @section Open Modes
12427 @code{Open} and @code{Create} calls result in a call to @code{fopen}
12428 using the mode shown in the following table:
12431 @center @code{Open} and @code{Create} Call Modes
12433 @b{OPEN } @b{CREATE}
12434 Append_File "r+" "w+"
12436 Out_File (Direct_IO) "r+" "w"
12437 Out_File (all other cases) "w" "w"
12438 Inout_File "r+" "w+"
12442 If text file translation is required, then either @samp{b} or @samp{t}
12443 is added to the mode, depending on the setting of Text. Text file
12444 translation refers to the mapping of CR/LF sequences in an external file
12445 to LF characters internally. This mapping only occurs in DOS and
12446 DOS-like systems, and is not relevant to other systems.
12448 A special case occurs with Stream_IO@. As shown in the above table, the
12449 file is initially opened in @samp{r} or @samp{w} mode for the
12450 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
12451 subsequently requires switching from reading to writing or vice-versa,
12452 then the file is reopened in @samp{r+} mode to permit the required operation.
12454 @node Operations on C Streams
12455 @section Operations on C Streams
12456 The package @code{Interfaces.C_Streams} provides an Ada program with direct
12457 access to the C library functions for operations on C streams:
12459 @smallexample @c adanocomment
12460 package Interfaces.C_Streams is
12461 -- Note: the reason we do not use the types that are in
12462 -- Interfaces.C is that we want to avoid dragging in the
12463 -- code in this unit if possible.
12464 subtype chars is System.Address;
12465 -- Pointer to null-terminated array of characters
12466 subtype FILEs is System.Address;
12467 -- Corresponds to the C type FILE*
12468 subtype voids is System.Address;
12469 -- Corresponds to the C type void*
12470 subtype int is Integer;
12471 subtype long is Long_Integer;
12472 -- Note: the above types are subtypes deliberately, and it
12473 -- is part of this spec that the above correspondences are
12474 -- guaranteed. This means that it is legitimate to, for
12475 -- example, use Integer instead of int. We provide these
12476 -- synonyms for clarity, but in some cases it may be
12477 -- convenient to use the underlying types (for example to
12478 -- avoid an unnecessary dependency of a spec on the spec
12480 type size_t is mod 2 ** Standard'Address_Size;
12481 NULL_Stream : constant FILEs;
12482 -- Value returned (NULL in C) to indicate an
12483 -- fdopen/fopen/tmpfile error
12484 ----------------------------------
12485 -- Constants Defined in stdio.h --
12486 ----------------------------------
12487 EOF : constant int;
12488 -- Used by a number of routines to indicate error or
12490 IOFBF : constant int;
12491 IOLBF : constant int;
12492 IONBF : constant int;
12493 -- Used to indicate buffering mode for setvbuf call
12494 SEEK_CUR : constant int;
12495 SEEK_END : constant int;
12496 SEEK_SET : constant int;
12497 -- Used to indicate origin for fseek call
12498 function stdin return FILEs;
12499 function stdout return FILEs;
12500 function stderr return FILEs;
12501 -- Streams associated with standard files
12502 --------------------------
12503 -- Standard C functions --
12504 --------------------------
12505 -- The functions selected below are ones that are
12506 -- available in DOS, OS/2, UNIX and Xenix (but not
12507 -- necessarily in ANSI C). These are very thin interfaces
12508 -- which copy exactly the C headers. For more
12509 -- documentation on these functions, see the Microsoft C
12510 -- "Run-Time Library Reference" (Microsoft Press, 1990,
12511 -- ISBN 1-55615-225-6), which includes useful information
12512 -- on system compatibility.
12513 procedure clearerr (stream : FILEs);
12514 function fclose (stream : FILEs) return int;
12515 function fdopen (handle : int; mode : chars) return FILEs;
12516 function feof (stream : FILEs) return int;
12517 function ferror (stream : FILEs) return int;
12518 function fflush (stream : FILEs) return int;
12519 function fgetc (stream : FILEs) return int;
12520 function fgets (strng : chars; n : int; stream : FILEs)
12522 function fileno (stream : FILEs) return int;
12523 function fopen (filename : chars; Mode : chars)
12525 -- Note: to maintain target independence, use
12526 -- text_translation_required, a boolean variable defined in
12527 -- a-sysdep.c to deal with the target dependent text
12528 -- translation requirement. If this variable is set,
12529 -- then b/t should be appended to the standard mode
12530 -- argument to set the text translation mode off or on
12532 function fputc (C : int; stream : FILEs) return int;
12533 function fputs (Strng : chars; Stream : FILEs) return int;
12550 function ftell (stream : FILEs) return long;
12557 function isatty (handle : int) return int;
12558 procedure mktemp (template : chars);
12559 -- The return value (which is just a pointer to template)
12561 procedure rewind (stream : FILEs);
12562 function rmtmp return int;
12570 function tmpfile return FILEs;
12571 function ungetc (c : int; stream : FILEs) return int;
12572 function unlink (filename : chars) return int;
12573 ---------------------
12574 -- Extra functions --
12575 ---------------------
12576 -- These functions supply slightly thicker bindings than
12577 -- those above. They are derived from functions in the
12578 -- C Run-Time Library, but may do a bit more work than
12579 -- just directly calling one of the Library functions.
12580 function is_regular_file (handle : int) return int;
12581 -- Tests if given handle is for a regular file (result 1)
12582 -- or for a non-regular file (pipe or device, result 0).
12583 ---------------------------------
12584 -- Control of Text/Binary Mode --
12585 ---------------------------------
12586 -- If text_translation_required is true, then the following
12587 -- functions may be used to dynamically switch a file from
12588 -- binary to text mode or vice versa. These functions have
12589 -- no effect if text_translation_required is false (i.e. in
12590 -- normal UNIX mode). Use fileno to get a stream handle.
12591 procedure set_binary_mode (handle : int);
12592 procedure set_text_mode (handle : int);
12593 ----------------------------
12594 -- Full Path Name support --
12595 ----------------------------
12596 procedure full_name (nam : chars; buffer : chars);
12597 -- Given a NUL terminated string representing a file
12598 -- name, returns in buffer a NUL terminated string
12599 -- representing the full path name for the file name.
12600 -- On systems where it is relevant the drive is also
12601 -- part of the full path name. It is the responsibility
12602 -- of the caller to pass an actual parameter for buffer
12603 -- that is big enough for any full path name. Use
12604 -- max_path_len given below as the size of buffer.
12605 max_path_len : integer;
12606 -- Maximum length of an allowable full path name on the
12607 -- system, including a terminating NUL character.
12608 end Interfaces.C_Streams;
12611 @node Interfacing to C Streams
12612 @section Interfacing to C Streams
12615 The packages in this section permit interfacing Ada files to C Stream
12618 @smallexample @c ada
12619 with Interfaces.C_Streams;
12620 package Ada.Sequential_IO.C_Streams is
12621 function C_Stream (F : File_Type)
12622 return Interfaces.C_Streams.FILEs;
12624 (File : in out File_Type;
12625 Mode : in File_Mode;
12626 C_Stream : in Interfaces.C_Streams.FILEs;
12627 Form : in String := "");
12628 end Ada.Sequential_IO.C_Streams;
12630 with Interfaces.C_Streams;
12631 package Ada.Direct_IO.C_Streams is
12632 function C_Stream (F : File_Type)
12633 return Interfaces.C_Streams.FILEs;
12635 (File : in out File_Type;
12636 Mode : in File_Mode;
12637 C_Stream : in Interfaces.C_Streams.FILEs;
12638 Form : in String := "");
12639 end Ada.Direct_IO.C_Streams;
12641 with Interfaces.C_Streams;
12642 package Ada.Text_IO.C_Streams is
12643 function C_Stream (F : File_Type)
12644 return Interfaces.C_Streams.FILEs;
12646 (File : in out File_Type;
12647 Mode : in File_Mode;
12648 C_Stream : in Interfaces.C_Streams.FILEs;
12649 Form : in String := "");
12650 end Ada.Text_IO.C_Streams;
12652 with Interfaces.C_Streams;
12653 package Ada.Wide_Text_IO.C_Streams is
12654 function C_Stream (F : File_Type)
12655 return Interfaces.C_Streams.FILEs;
12657 (File : in out File_Type;
12658 Mode : in File_Mode;
12659 C_Stream : in Interfaces.C_Streams.FILEs;
12660 Form : in String := "");
12661 end Ada.Wide_Text_IO.C_Streams;
12663 with Interfaces.C_Streams;
12664 package Ada.Wide_Wide_Text_IO.C_Streams is
12665 function C_Stream (F : File_Type)
12666 return Interfaces.C_Streams.FILEs;
12668 (File : in out File_Type;
12669 Mode : in File_Mode;
12670 C_Stream : in Interfaces.C_Streams.FILEs;
12671 Form : in String := "");
12672 end Ada.Wide_Wide_Text_IO.C_Streams;
12674 with Interfaces.C_Streams;
12675 package Ada.Stream_IO.C_Streams is
12676 function C_Stream (F : File_Type)
12677 return Interfaces.C_Streams.FILEs;
12679 (File : in out File_Type;
12680 Mode : in File_Mode;
12681 C_Stream : in Interfaces.C_Streams.FILEs;
12682 Form : in String := "");
12683 end Ada.Stream_IO.C_Streams;
12687 In each of these six packages, the @code{C_Stream} function obtains the
12688 @code{FILE} pointer from a currently opened Ada file. It is then
12689 possible to use the @code{Interfaces.C_Streams} package to operate on
12690 this stream, or the stream can be passed to a C program which can
12691 operate on it directly. Of course the program is responsible for
12692 ensuring that only appropriate sequences of operations are executed.
12694 One particular use of relevance to an Ada program is that the
12695 @code{setvbuf} function can be used to control the buffering of the
12696 stream used by an Ada file. In the absence of such a call the standard
12697 default buffering is used.
12699 The @code{Open} procedures in these packages open a file giving an
12700 existing C Stream instead of a file name. Typically this stream is
12701 imported from a C program, allowing an Ada file to operate on an
12704 @node The GNAT Library
12705 @chapter The GNAT Library
12708 The GNAT library contains a number of general and special purpose packages.
12709 It represents functionality that the GNAT developers have found useful, and
12710 which is made available to GNAT users. The packages described here are fully
12711 supported, and upwards compatibility will be maintained in future releases,
12712 so you can use these facilities with the confidence that the same functionality
12713 will be available in future releases.
12715 The chapter here simply gives a brief summary of the facilities available.
12716 The full documentation is found in the spec file for the package. The full
12717 sources of these library packages, including both spec and body, are provided
12718 with all GNAT releases. For example, to find out the full specifications of
12719 the SPITBOL pattern matching capability, including a full tutorial and
12720 extensive examples, look in the @file{g-spipat.ads} file in the library.
12722 For each entry here, the package name (as it would appear in a @code{with}
12723 clause) is given, followed by the name of the corresponding spec file in
12724 parentheses. The packages are children in four hierarchies, @code{Ada},
12725 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
12726 GNAT-specific hierarchy.
12728 Note that an application program should only use packages in one of these
12729 four hierarchies if the package is defined in the Ada Reference Manual,
12730 or is listed in this section of the GNAT Programmers Reference Manual.
12731 All other units should be considered internal implementation units and
12732 should not be directly @code{with}'ed by application code. The use of
12733 a @code{with} statement that references one of these internal implementation
12734 units makes an application potentially dependent on changes in versions
12735 of GNAT, and will generate a warning message.
12738 * Ada.Characters.Latin_9 (a-chlat9.ads)::
12739 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
12740 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
12741 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
12742 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
12743 * Ada.Command_Line.Remove (a-colire.ads)::
12744 * Ada.Command_Line.Environment (a-colien.ads)::
12745 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
12746 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
12747 * Ada.Exceptions.Traceback (a-exctra.ads)::
12748 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
12749 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
12750 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
12751 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
12752 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
12753 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
12754 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
12755 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
12756 * GNAT.Altivec (g-altive.ads)::
12757 * GNAT.Altivec.Conversions (g-altcon.ads)::
12758 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
12759 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
12760 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
12761 * GNAT.Array_Split (g-arrspl.ads)::
12762 * GNAT.AWK (g-awk.ads)::
12763 * GNAT.Bounded_Buffers (g-boubuf.ads)::
12764 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
12765 * GNAT.Bubble_Sort (g-bubsor.ads)::
12766 * GNAT.Bubble_Sort_A (g-busora.ads)::
12767 * GNAT.Bubble_Sort_G (g-busorg.ads)::
12768 * GNAT.Byte_Order_Mark (g-byorma.ads)::
12769 * GNAT.Byte_Swapping (g-bytswa.ads)::
12770 * GNAT.Calendar (g-calend.ads)::
12771 * GNAT.Calendar.Time_IO (g-catiio.ads)::
12772 * GNAT.CRC32 (g-crc32.ads)::
12773 * GNAT.Case_Util (g-casuti.ads)::
12774 * GNAT.CGI (g-cgi.ads)::
12775 * GNAT.CGI.Cookie (g-cgicoo.ads)::
12776 * GNAT.CGI.Debug (g-cgideb.ads)::
12777 * GNAT.Command_Line (g-comlin.ads)::
12778 * GNAT.Compiler_Version (g-comver.ads)::
12779 * GNAT.Ctrl_C (g-ctrl_c.ads)::
12780 * GNAT.Current_Exception (g-curexc.ads)::
12781 * GNAT.Debug_Pools (g-debpoo.ads)::
12782 * GNAT.Debug_Utilities (g-debuti.ads)::
12783 * GNAT.Decode_String (g-decstr.ads)::
12784 * GNAT.Decode_UTF8_String (g-deutst.ads)::
12785 * GNAT.Directory_Operations (g-dirope.ads)::
12786 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
12787 * GNAT.Dynamic_HTables (g-dynhta.ads)::
12788 * GNAT.Dynamic_Tables (g-dyntab.ads)::
12789 * GNAT.Encode_String (g-encstr.ads)::
12790 * GNAT.Encode_UTF8_String (g-enutst.ads)::
12791 * GNAT.Exception_Actions (g-excact.ads)::
12792 * GNAT.Exception_Traces (g-exctra.ads)::
12793 * GNAT.Exceptions (g-except.ads)::
12794 * GNAT.Expect (g-expect.ads)::
12795 * GNAT.Float_Control (g-flocon.ads)::
12796 * GNAT.Heap_Sort (g-heasor.ads)::
12797 * GNAT.Heap_Sort_A (g-hesora.ads)::
12798 * GNAT.Heap_Sort_G (g-hesorg.ads)::
12799 * GNAT.HTable (g-htable.ads)::
12800 * GNAT.IO (g-io.ads)::
12801 * GNAT.IO_Aux (g-io_aux.ads)::
12802 * GNAT.Lock_Files (g-locfil.ads)::
12803 * GNAT.MD5 (g-md5.ads)::
12804 * GNAT.Memory_Dump (g-memdum.ads)::
12805 * GNAT.Most_Recent_Exception (g-moreex.ads)::
12806 * GNAT.OS_Lib (g-os_lib.ads)::
12807 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
12808 * GNAT.Random_Numbers (g-rannum.ads)::
12809 * GNAT.Regexp (g-regexp.ads)::
12810 * GNAT.Registry (g-regist.ads)::
12811 * GNAT.Regpat (g-regpat.ads)::
12812 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
12813 * GNAT.Semaphores (g-semaph.ads)::
12814 * GNAT.SHA1 (g-sha1.ads)::
12815 * GNAT.Signals (g-signal.ads)::
12816 * GNAT.Sockets (g-socket.ads)::
12817 * GNAT.Source_Info (g-souinf.ads)::
12818 * GNAT.Spelling_Checker (g-speche.ads)::
12819 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
12820 * GNAT.Spitbol.Patterns (g-spipat.ads)::
12821 * GNAT.Spitbol (g-spitbo.ads)::
12822 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
12823 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
12824 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
12825 * GNAT.Strings (g-string.ads)::
12826 * GNAT.String_Split (g-strspl.ads)::
12827 * GNAT.Table (g-table.ads)::
12828 * GNAT.Task_Lock (g-tasloc.ads)::
12829 * GNAT.Threads (g-thread.ads)::
12830 * GNAT.Traceback (g-traceb.ads)::
12831 * GNAT.Traceback.Symbolic (g-trasym.ads)::
12832 * GNAT.UTF_32 (g-utf_32.ads)::
12833 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
12834 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
12835 * GNAT.Wide_String_Split (g-wistsp.ads)::
12836 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
12837 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
12838 * Interfaces.C.Extensions (i-cexten.ads)::
12839 * Interfaces.C.Streams (i-cstrea.ads)::
12840 * Interfaces.CPP (i-cpp.ads)::
12841 * Interfaces.Os2lib (i-os2lib.ads)::
12842 * Interfaces.Os2lib.Errors (i-os2err.ads)::
12843 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
12844 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
12845 * Interfaces.Packed_Decimal (i-pacdec.ads)::
12846 * Interfaces.VxWorks (i-vxwork.ads)::
12847 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
12848 * System.Address_Image (s-addima.ads)::
12849 * System.Assertions (s-assert.ads)::
12850 * System.Memory (s-memory.ads)::
12851 * System.Partition_Interface (s-parint.ads)::
12852 * System.Restrictions (s-restri.ads)::
12853 * System.Rident (s-rident.ads)::
12854 * System.Task_Info (s-tasinf.ads)::
12855 * System.Wch_Cnv (s-wchcnv.ads)::
12856 * System.Wch_Con (s-wchcon.ads)::
12859 @node Ada.Characters.Latin_9 (a-chlat9.ads)
12860 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12861 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12862 @cindex Latin_9 constants for Character
12865 This child of @code{Ada.Characters}
12866 provides a set of definitions corresponding to those in the
12867 RM-defined package @code{Ada.Characters.Latin_1} but with the
12868 few modifications required for @code{Latin-9}
12869 The provision of such a package
12870 is specifically authorized by the Ada Reference Manual
12873 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
12874 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12875 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12876 @cindex Latin_1 constants for Wide_Character
12879 This child of @code{Ada.Characters}
12880 provides a set of definitions corresponding to those in the
12881 RM-defined package @code{Ada.Characters.Latin_1} but with the
12882 types of the constants being @code{Wide_Character}
12883 instead of @code{Character}. The provision of such a package
12884 is specifically authorized by the Ada Reference Manual
12887 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
12888 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12889 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12890 @cindex Latin_9 constants for Wide_Character
12893 This child of @code{Ada.Characters}
12894 provides a set of definitions corresponding to those in the
12895 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12896 types of the constants being @code{Wide_Character}
12897 instead of @code{Character}. The provision of such a package
12898 is specifically authorized by the Ada Reference Manual
12901 @node Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)
12902 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12903 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12904 @cindex Latin_1 constants for Wide_Wide_Character
12907 This child of @code{Ada.Characters}
12908 provides a set of definitions corresponding to those in the
12909 RM-defined package @code{Ada.Characters.Latin_1} but with the
12910 types of the constants being @code{Wide_Wide_Character}
12911 instead of @code{Character}. The provision of such a package
12912 is specifically authorized by the Ada Reference Manual
12915 @node Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)
12916 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12917 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12918 @cindex Latin_9 constants for Wide_Wide_Character
12921 This child of @code{Ada.Characters}
12922 provides a set of definitions corresponding to those in the
12923 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12924 types of the constants being @code{Wide_Wide_Character}
12925 instead of @code{Character}. The provision of such a package
12926 is specifically authorized by the Ada Reference Manual
12929 @node Ada.Command_Line.Remove (a-colire.ads)
12930 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12931 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12932 @cindex Removing command line arguments
12933 @cindex Command line, argument removal
12936 This child of @code{Ada.Command_Line}
12937 provides a mechanism for logically removing
12938 arguments from the argument list. Once removed, an argument is not visible
12939 to further calls on the subprograms in @code{Ada.Command_Line} will not
12940 see the removed argument.
12942 @node Ada.Command_Line.Environment (a-colien.ads)
12943 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12944 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12945 @cindex Environment entries
12948 This child of @code{Ada.Command_Line}
12949 provides a mechanism for obtaining environment values on systems
12950 where this concept makes sense.
12952 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
12953 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12954 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12955 @cindex C Streams, Interfacing with Direct_IO
12958 This package provides subprograms that allow interfacing between
12959 C streams and @code{Direct_IO}. The stream identifier can be
12960 extracted from a file opened on the Ada side, and an Ada file
12961 can be constructed from a stream opened on the C side.
12963 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
12964 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12965 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12966 @cindex Null_Occurrence, testing for
12969 This child subprogram provides a way of testing for the null
12970 exception occurrence (@code{Null_Occurrence}) without raising
12973 @node Ada.Exceptions.Traceback (a-exctra.ads)
12974 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12975 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12976 @cindex Traceback for Exception Occurrence
12979 This child package provides the subprogram (@code{Tracebacks}) to
12980 give a traceback array of addresses based on an exception
12983 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
12984 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12985 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12986 @cindex C Streams, Interfacing with Sequential_IO
12989 This package provides subprograms that allow interfacing between
12990 C streams and @code{Sequential_IO}. The stream identifier can be
12991 extracted from a file opened on the Ada side, and an Ada file
12992 can be constructed from a stream opened on the C side.
12994 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
12995 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12996 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12997 @cindex C Streams, Interfacing with Stream_IO
13000 This package provides subprograms that allow interfacing between
13001 C streams and @code{Stream_IO}. The stream identifier can be
13002 extracted from a file opened on the Ada side, and an Ada file
13003 can be constructed from a stream opened on the C side.
13005 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13006 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13007 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13008 @cindex @code{Unbounded_String}, IO support
13009 @cindex @code{Text_IO}, extensions for unbounded strings
13012 This package provides subprograms for Text_IO for unbounded
13013 strings, avoiding the necessity for an intermediate operation
13014 with ordinary strings.
13016 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13017 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13018 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13019 @cindex @code{Unbounded_Wide_String}, IO support
13020 @cindex @code{Text_IO}, extensions for unbounded wide strings
13023 This package provides subprograms for Text_IO for unbounded
13024 wide strings, avoiding the necessity for an intermediate operation
13025 with ordinary wide strings.
13027 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13028 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13029 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13030 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13031 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13034 This package provides subprograms for Text_IO for unbounded
13035 wide wide strings, avoiding the necessity for an intermediate operation
13036 with ordinary wide wide strings.
13038 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13039 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13040 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13041 @cindex C Streams, Interfacing with @code{Text_IO}
13044 This package provides subprograms that allow interfacing between
13045 C streams and @code{Text_IO}. The stream identifier can be
13046 extracted from a file opened on the Ada side, and an Ada file
13047 can be constructed from a stream opened on the C side.
13049 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13050 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13051 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13052 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13055 This package provides subprograms that allow interfacing between
13056 C streams and @code{Wide_Text_IO}. The stream identifier can be
13057 extracted from a file opened on the Ada side, and an Ada file
13058 can be constructed from a stream opened on the C side.
13060 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13061 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13062 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13063 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13066 This package provides subprograms that allow interfacing between
13067 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
13068 extracted from a file opened on the Ada side, and an Ada file
13069 can be constructed from a stream opened on the C side.
13071 @node GNAT.Altivec (g-altive.ads)
13072 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13073 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13077 This is the root package of the GNAT AltiVec binding. It provides
13078 definitions of constants and types common to all the versions of the
13081 @node GNAT.Altivec.Conversions (g-altcon.ads)
13082 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13083 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13087 This package provides the Vector/View conversion routines.
13089 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13090 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13091 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13095 This package exposes the Ada interface to the AltiVec operations on
13096 vector objects. A soft emulation is included by default in the GNAT
13097 library. The hard binding is provided as a separate package. This unit
13098 is common to both bindings.
13100 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13101 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13102 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13106 This package exposes the various vector types part of the Ada binding
13107 to AltiVec facilities.
13109 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13110 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13111 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13115 This package provides public 'View' data types from/to which private
13116 vector representations can be converted via
13117 GNAT.Altivec.Conversions. This allows convenient access to individual
13118 vector elements and provides a simple way to initialize vector
13121 @node GNAT.Array_Split (g-arrspl.ads)
13122 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13123 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13124 @cindex Array splitter
13127 Useful array-manipulation routines: given a set of separators, split
13128 an array wherever the separators appear, and provide direct access
13129 to the resulting slices.
13131 @node GNAT.AWK (g-awk.ads)
13132 @section @code{GNAT.AWK} (@file{g-awk.ads})
13133 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13138 Provides AWK-like parsing functions, with an easy interface for parsing one
13139 or more files containing formatted data. The file is viewed as a database
13140 where each record is a line and a field is a data element in this line.
13142 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13143 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13144 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13146 @cindex Bounded Buffers
13149 Provides a concurrent generic bounded buffer abstraction. Instances are
13150 useful directly or as parts of the implementations of other abstractions,
13153 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13154 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13155 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13160 Provides a thread-safe asynchronous intertask mailbox communication facility.
13162 @node GNAT.Bubble_Sort (g-bubsor.ads)
13163 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13164 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13166 @cindex Bubble sort
13169 Provides a general implementation of bubble sort usable for sorting arbitrary
13170 data items. Exchange and comparison procedures are provided by passing
13171 access-to-procedure values.
13173 @node GNAT.Bubble_Sort_A (g-busora.ads)
13174 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13175 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13177 @cindex Bubble sort
13180 Provides a general implementation of bubble sort usable for sorting arbitrary
13181 data items. Move and comparison procedures are provided by passing
13182 access-to-procedure values. This is an older version, retained for
13183 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13185 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13186 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13187 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13189 @cindex Bubble sort
13192 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13193 are provided as generic parameters, this improves efficiency, especially
13194 if the procedures can be inlined, at the expense of duplicating code for
13195 multiple instantiations.
13197 @node GNAT.Byte_Order_Mark (g-byorma.ads)
13198 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13199 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13200 @cindex UTF-8 representation
13201 @cindex Wide characte representations
13204 Provides a routine which given a string, reads the start of the string to
13205 see whether it is one of the standard byte order marks (BOM's) which signal
13206 the encoding of the string. The routine includes detection of special XML
13207 sequences for various UCS input formats.
13209 @node GNAT.Byte_Swapping (g-bytswa.ads)
13210 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13211 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13212 @cindex Byte swapping
13216 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13217 Machine-specific implementations are available in some cases.
13219 @node GNAT.Calendar (g-calend.ads)
13220 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13221 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13222 @cindex @code{Calendar}
13225 Extends the facilities provided by @code{Ada.Calendar} to include handling
13226 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13227 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
13228 C @code{timeval} format.
13230 @node GNAT.Calendar.Time_IO (g-catiio.ads)
13231 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13232 @cindex @code{Calendar}
13234 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13236 @node GNAT.CRC32 (g-crc32.ads)
13237 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
13238 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
13240 @cindex Cyclic Redundancy Check
13243 This package implements the CRC-32 algorithm. For a full description
13244 of this algorithm see
13245 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
13246 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
13247 Aug.@: 1988. Sarwate, D.V@.
13249 @node GNAT.Case_Util (g-casuti.ads)
13250 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
13251 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
13252 @cindex Casing utilities
13253 @cindex Character handling (@code{GNAT.Case_Util})
13256 A set of simple routines for handling upper and lower casing of strings
13257 without the overhead of the full casing tables
13258 in @code{Ada.Characters.Handling}.
13260 @node GNAT.CGI (g-cgi.ads)
13261 @section @code{GNAT.CGI} (@file{g-cgi.ads})
13262 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
13263 @cindex CGI (Common Gateway Interface)
13266 This is a package for interfacing a GNAT program with a Web server via the
13267 Common Gateway Interface (CGI)@. Basically this package parses the CGI
13268 parameters, which are a set of key/value pairs sent by the Web server. It
13269 builds a table whose index is the key and provides some services to deal
13272 @node GNAT.CGI.Cookie (g-cgicoo.ads)
13273 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13274 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13275 @cindex CGI (Common Gateway Interface) cookie support
13276 @cindex Cookie support in CGI
13279 This is a package to interface a GNAT program with a Web server via the
13280 Common Gateway Interface (CGI). It exports services to deal with Web
13281 cookies (piece of information kept in the Web client software).
13283 @node GNAT.CGI.Debug (g-cgideb.ads)
13284 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13285 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13286 @cindex CGI (Common Gateway Interface) debugging
13289 This is a package to help debugging CGI (Common Gateway Interface)
13290 programs written in Ada.
13292 @node GNAT.Command_Line (g-comlin.ads)
13293 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
13294 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
13295 @cindex Command line
13298 Provides a high level interface to @code{Ada.Command_Line} facilities,
13299 including the ability to scan for named switches with optional parameters
13300 and expand file names using wild card notations.
13302 @node GNAT.Compiler_Version (g-comver.ads)
13303 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13304 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13305 @cindex Compiler Version
13306 @cindex Version, of compiler
13309 Provides a routine for obtaining the version of the compiler used to
13310 compile the program. More accurately this is the version of the binder
13311 used to bind the program (this will normally be the same as the version
13312 of the compiler if a consistent tool set is used to compile all units
13315 @node GNAT.Ctrl_C (g-ctrl_c.ads)
13316 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13317 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13321 Provides a simple interface to handle Ctrl-C keyboard events.
13323 @node GNAT.Current_Exception (g-curexc.ads)
13324 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13325 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13326 @cindex Current exception
13327 @cindex Exception retrieval
13330 Provides access to information on the current exception that has been raised
13331 without the need for using the Ada 95 / Ada 2005 exception choice parameter
13332 specification syntax.
13333 This is particularly useful in simulating typical facilities for
13334 obtaining information about exceptions provided by Ada 83 compilers.
13336 @node GNAT.Debug_Pools (g-debpoo.ads)
13337 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13338 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13340 @cindex Debug pools
13341 @cindex Memory corruption debugging
13344 Provide a debugging storage pools that helps tracking memory corruption
13345 problems. See section ``Finding memory problems with GNAT Debug Pool'' in
13346 the @cite{GNAT User's Guide}.
13348 @node GNAT.Debug_Utilities (g-debuti.ads)
13349 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13350 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13354 Provides a few useful utilities for debugging purposes, including conversion
13355 to and from string images of address values. Supports both C and Ada formats
13356 for hexadecimal literals.
13358 @node GNAT.Decode_String (g-decstr.ads)
13359 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
13360 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
13361 @cindex Decoding strings
13362 @cindex String decoding
13363 @cindex Wide chararacter encoding
13368 A generic package providing routines for decoding wide character and wide wide
13369 character strings encoded as sequences of 8-bit characters using a specified
13370 encoding method. Includes validation routines, and also routines for stepping
13371 to next or previous encoded character in an encoded string.
13372 Useful in conjunction with Unicode character coding. Note there is a
13373 preinstiation for UTF-8. See next entry.
13375 @node GNAT.Decode_UTF8_String (g-deutst.ads)
13376 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13377 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13378 @cindex Decoding strings
13379 @cindex Decoding UTF-8 strings
13380 @cindex UTF-8 string decoding
13381 @cindex Wide chararacter decoding
13386 A preinstantion of GNAT.Decode_Strings for UTF-8 encoding.
13388 @node GNAT.Directory_Operations (g-dirope.ads)
13389 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13390 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13391 @cindex Directory operations
13394 Provides a set of routines for manipulating directories, including changing
13395 the current directory, making new directories, and scanning the files in a
13398 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
13399 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
13400 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
13401 @cindex Directory operations iteration
13404 A child unit of GNAT.Directory_Operations providing additional operations
13405 for iterating through directories.
13407 @node GNAT.Dynamic_HTables (g-dynhta.ads)
13408 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13409 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13410 @cindex Hash tables
13413 A generic implementation of hash tables that can be used to hash arbitrary
13414 data. Provided in two forms, a simple form with built in hash functions,
13415 and a more complex form in which the hash function is supplied.
13418 This package provides a facility similar to that of @code{GNAT.HTable},
13419 except that this package declares a type that can be used to define
13420 dynamic instances of the hash table, while an instantiation of
13421 @code{GNAT.HTable} creates a single instance of the hash table.
13423 @node GNAT.Dynamic_Tables (g-dyntab.ads)
13424 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13425 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13426 @cindex Table implementation
13427 @cindex Arrays, extendable
13430 A generic package providing a single dimension array abstraction where the
13431 length of the array can be dynamically modified.
13434 This package provides a facility similar to that of @code{GNAT.Table},
13435 except that this package declares a type that can be used to define
13436 dynamic instances of the table, while an instantiation of
13437 @code{GNAT.Table} creates a single instance of the table type.
13439 @node GNAT.Encode_String (g-encstr.ads)
13440 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
13441 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
13442 @cindex Encoding strings
13443 @cindex String encoding
13444 @cindex Wide chararacter encoding
13449 A generic package providing routines for encoding wide character and wide
13450 wide character strings as sequences of 8-bit characters using a specified
13451 encoding method. Useful in conjunction with Unicode character coding.
13452 Note there is a preinstiation for UTF-8. See next entry.
13454 @node GNAT.Encode_UTF8_String (g-enutst.ads)
13455 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
13456 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
13457 @cindex Encoding strings
13458 @cindex Encoding UTF-8 strings
13459 @cindex UTF-8 string encoding
13460 @cindex Wide chararacter encoding
13465 A preinstantion of GNAT.Encode_Strings for UTF-8 encoding.
13467 @node GNAT.Exception_Actions (g-excact.ads)
13468 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13469 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13470 @cindex Exception actions
13473 Provides callbacks when an exception is raised. Callbacks can be registered
13474 for specific exceptions, or when any exception is raised. This
13475 can be used for instance to force a core dump to ease debugging.
13477 @node GNAT.Exception_Traces (g-exctra.ads)
13478 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13479 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13480 @cindex Exception traces
13484 Provides an interface allowing to control automatic output upon exception
13487 @node GNAT.Exceptions (g-except.ads)
13488 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
13489 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
13490 @cindex Exceptions, Pure
13491 @cindex Pure packages, exceptions
13494 Normally it is not possible to raise an exception with
13495 a message from a subprogram in a pure package, since the
13496 necessary types and subprograms are in @code{Ada.Exceptions}
13497 which is not a pure unit. @code{GNAT.Exceptions} provides a
13498 facility for getting around this limitation for a few
13499 predefined exceptions, and for example allow raising
13500 @code{Constraint_Error} with a message from a pure subprogram.
13502 @node GNAT.Expect (g-expect.ads)
13503 @section @code{GNAT.Expect} (@file{g-expect.ads})
13504 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
13507 Provides a set of subprograms similar to what is available
13508 with the standard Tcl Expect tool.
13509 It allows you to easily spawn and communicate with an external process.
13510 You can send commands or inputs to the process, and compare the output
13511 with some expected regular expression. Currently @code{GNAT.Expect}
13512 is implemented on all native GNAT ports except for OpenVMS@.
13513 It is not implemented for cross ports, and in particular is not
13514 implemented for VxWorks or LynxOS@.
13516 @node GNAT.Float_Control (g-flocon.ads)
13517 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
13518 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
13519 @cindex Floating-Point Processor
13522 Provides an interface for resetting the floating-point processor into the
13523 mode required for correct semantic operation in Ada. Some third party
13524 library calls may cause this mode to be modified, and the Reset procedure
13525 in this package can be used to reestablish the required mode.
13527 @node GNAT.Heap_Sort (g-heasor.ads)
13528 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13529 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13533 Provides a general implementation of heap sort usable for sorting arbitrary
13534 data items. Exchange and comparison procedures are provided by passing
13535 access-to-procedure values. The algorithm used is a modified heap sort
13536 that performs approximately N*log(N) comparisons in the worst case.
13538 @node GNAT.Heap_Sort_A (g-hesora.ads)
13539 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13540 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13544 Provides a general implementation of heap sort usable for sorting arbitrary
13545 data items. Move and comparison procedures are provided by passing
13546 access-to-procedure values. The algorithm used is a modified heap sort
13547 that performs approximately N*log(N) comparisons in the worst case.
13548 This differs from @code{GNAT.Heap_Sort} in having a less convenient
13549 interface, but may be slightly more efficient.
13551 @node GNAT.Heap_Sort_G (g-hesorg.ads)
13552 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13553 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13557 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
13558 are provided as generic parameters, this improves efficiency, especially
13559 if the procedures can be inlined, at the expense of duplicating code for
13560 multiple instantiations.
13562 @node GNAT.HTable (g-htable.ads)
13563 @section @code{GNAT.HTable} (@file{g-htable.ads})
13564 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
13565 @cindex Hash tables
13568 A generic implementation of hash tables that can be used to hash arbitrary
13569 data. Provides two approaches, one a simple static approach, and the other
13570 allowing arbitrary dynamic hash tables.
13572 @node GNAT.IO (g-io.ads)
13573 @section @code{GNAT.IO} (@file{g-io.ads})
13574 @cindex @code{GNAT.IO} (@file{g-io.ads})
13576 @cindex Input/Output facilities
13579 A simple preelaborable input-output package that provides a subset of
13580 simple Text_IO functions for reading characters and strings from
13581 Standard_Input, and writing characters, strings and integers to either
13582 Standard_Output or Standard_Error.
13584 @node GNAT.IO_Aux (g-io_aux.ads)
13585 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13586 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13588 @cindex Input/Output facilities
13590 Provides some auxiliary functions for use with Text_IO, including a test
13591 for whether a file exists, and functions for reading a line of text.
13593 @node GNAT.Lock_Files (g-locfil.ads)
13594 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13595 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13596 @cindex File locking
13597 @cindex Locking using files
13600 Provides a general interface for using files as locks. Can be used for
13601 providing program level synchronization.
13603 @node GNAT.MD5 (g-md5.ads)
13604 @section @code{GNAT.MD5} (@file{g-md5.ads})
13605 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
13606 @cindex Message Digest MD5
13609 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
13611 @node GNAT.Memory_Dump (g-memdum.ads)
13612 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13613 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13614 @cindex Dump Memory
13617 Provides a convenient routine for dumping raw memory to either the
13618 standard output or standard error files. Uses GNAT.IO for actual
13621 @node GNAT.Most_Recent_Exception (g-moreex.ads)
13622 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13623 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13624 @cindex Exception, obtaining most recent
13627 Provides access to the most recently raised exception. Can be used for
13628 various logging purposes, including duplicating functionality of some
13629 Ada 83 implementation dependent extensions.
13631 @node GNAT.OS_Lib (g-os_lib.ads)
13632 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13633 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13634 @cindex Operating System interface
13635 @cindex Spawn capability
13638 Provides a range of target independent operating system interface functions,
13639 including time/date management, file operations, subprocess management,
13640 including a portable spawn procedure, and access to environment variables
13641 and error return codes.
13643 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
13644 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13645 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13646 @cindex Hash functions
13649 Provides a generator of static minimal perfect hash functions. No
13650 collisions occur and each item can be retrieved from the table in one
13651 probe (perfect property). The hash table size corresponds to the exact
13652 size of the key set and no larger (minimal property). The key set has to
13653 be know in advance (static property). The hash functions are also order
13654 preserving. If w2 is inserted after w1 in the generator, their
13655 hashcode are in the same order. These hashing functions are very
13656 convenient for use with realtime applications.
13658 @node GNAT.Random_Numbers (g-rannum.ads)
13659 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
13660 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
13661 @cindex Random number generation
13664 Provides random number capabilities which extend those available in the
13665 standard Ada library and are more convenient to use.
13667 @node GNAT.Regexp (g-regexp.ads)
13668 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
13669 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
13670 @cindex Regular expressions
13671 @cindex Pattern matching
13674 A simple implementation of regular expressions, using a subset of regular
13675 expression syntax copied from familiar Unix style utilities. This is the
13676 simples of the three pattern matching packages provided, and is particularly
13677 suitable for ``file globbing'' applications.
13679 @node GNAT.Registry (g-regist.ads)
13680 @section @code{GNAT.Registry} (@file{g-regist.ads})
13681 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
13682 @cindex Windows Registry
13685 This is a high level binding to the Windows registry. It is possible to
13686 do simple things like reading a key value, creating a new key. For full
13687 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
13688 package provided with the Win32Ada binding
13690 @node GNAT.Regpat (g-regpat.ads)
13691 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
13692 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
13693 @cindex Regular expressions
13694 @cindex Pattern matching
13697 A complete implementation of Unix-style regular expression matching, copied
13698 from the original V7 style regular expression library written in C by
13699 Henry Spencer (and binary compatible with this C library).
13701 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
13702 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13703 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13704 @cindex Secondary Stack Info
13707 Provide the capability to query the high water mark of the current task's
13710 @node GNAT.Semaphores (g-semaph.ads)
13711 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
13712 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
13716 Provides classic counting and binary semaphores using protected types.
13718 @node GNAT.SHA1 (g-sha1.ads)
13719 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
13720 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
13721 @cindex Secure Hash Algorithm SHA-1
13724 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
13726 @node GNAT.Signals (g-signal.ads)
13727 @section @code{GNAT.Signals} (@file{g-signal.ads})
13728 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
13732 Provides the ability to manipulate the blocked status of signals on supported
13735 @node GNAT.Sockets (g-socket.ads)
13736 @section @code{GNAT.Sockets} (@file{g-socket.ads})
13737 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
13741 A high level and portable interface to develop sockets based applications.
13742 This package is based on the sockets thin binding found in
13743 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
13744 on all native GNAT ports except for OpenVMS@. It is not implemented
13745 for the LynxOS@ cross port.
13747 @node GNAT.Source_Info (g-souinf.ads)
13748 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
13749 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
13750 @cindex Source Information
13753 Provides subprograms that give access to source code information known at
13754 compile time, such as the current file name and line number.
13756 @node GNAT.Spelling_Checker (g-speche.ads)
13757 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
13758 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
13759 @cindex Spell checking
13762 Provides a function for determining whether one string is a plausible
13763 near misspelling of another string.
13765 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
13766 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
13767 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
13768 @cindex Spell checking
13771 Provides a generic function that can be instantiated with a string type for
13772 determining whether one string is a plausible near misspelling of another
13775 @node GNAT.Spitbol.Patterns (g-spipat.ads)
13776 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13777 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13778 @cindex SPITBOL pattern matching
13779 @cindex Pattern matching
13782 A complete implementation of SNOBOL4 style pattern matching. This is the
13783 most elaborate of the pattern matching packages provided. It fully duplicates
13784 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
13785 efficient algorithm developed by Robert Dewar for the SPITBOL system.
13787 @node GNAT.Spitbol (g-spitbo.ads)
13788 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13789 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13790 @cindex SPITBOL interface
13793 The top level package of the collection of SPITBOL-style functionality, this
13794 package provides basic SNOBOL4 string manipulation functions, such as
13795 Pad, Reverse, Trim, Substr capability, as well as a generic table function
13796 useful for constructing arbitrary mappings from strings in the style of
13797 the SNOBOL4 TABLE function.
13799 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
13800 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13801 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13802 @cindex Sets of strings
13803 @cindex SPITBOL Tables
13806 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13807 for type @code{Standard.Boolean}, giving an implementation of sets of
13810 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
13811 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13812 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13813 @cindex Integer maps
13815 @cindex SPITBOL Tables
13818 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13819 for type @code{Standard.Integer}, giving an implementation of maps
13820 from string to integer values.
13822 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
13823 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13824 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13825 @cindex String maps
13827 @cindex SPITBOL Tables
13830 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
13831 a variable length string type, giving an implementation of general
13832 maps from strings to strings.
13834 @node GNAT.Strings (g-string.ads)
13835 @section @code{GNAT.Strings} (@file{g-string.ads})
13836 @cindex @code{GNAT.Strings} (@file{g-string.ads})
13839 Common String access types and related subprograms. Basically it
13840 defines a string access and an array of string access types.
13842 @node GNAT.String_Split (g-strspl.ads)
13843 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
13844 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
13845 @cindex String splitter
13848 Useful string manipulation routines: given a set of separators, split
13849 a string wherever the separators appear, and provide direct access
13850 to the resulting slices. This package is instantiated from
13851 @code{GNAT.Array_Split}.
13853 @node GNAT.Table (g-table.ads)
13854 @section @code{GNAT.Table} (@file{g-table.ads})
13855 @cindex @code{GNAT.Table} (@file{g-table.ads})
13856 @cindex Table implementation
13857 @cindex Arrays, extendable
13860 A generic package providing a single dimension array abstraction where the
13861 length of the array can be dynamically modified.
13864 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
13865 except that this package declares a single instance of the table type,
13866 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
13867 used to define dynamic instances of the table.
13869 @node GNAT.Task_Lock (g-tasloc.ads)
13870 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13871 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13872 @cindex Task synchronization
13873 @cindex Task locking
13877 A very simple facility for locking and unlocking sections of code using a
13878 single global task lock. Appropriate for use in situations where contention
13879 between tasks is very rarely expected.
13881 @node GNAT.Threads (g-thread.ads)
13882 @section @code{GNAT.Threads} (@file{g-thread.ads})
13883 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
13884 @cindex Foreign threads
13885 @cindex Threads, foreign
13888 Provides facilities for dealing with foreign threads which need to be known
13889 by the GNAT run-time system. Consult the documentation of this package for
13890 further details if your program has threads that are created by a non-Ada
13891 environment which then accesses Ada code.
13893 @node GNAT.Traceback (g-traceb.ads)
13894 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
13895 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
13896 @cindex Trace back facilities
13899 Provides a facility for obtaining non-symbolic traceback information, useful
13900 in various debugging situations.
13902 @node GNAT.Traceback.Symbolic (g-trasym.ads)
13903 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13904 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13905 @cindex Trace back facilities
13907 @node GNAT.UTF_32 (g-utf_32.ads)
13908 @section @code{GNAT.UTF_32} (@file{g-table.ads})
13909 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
13910 @cindex Wide character codes
13913 This is a package intended to be used in conjunction with the
13914 @code{Wide_Character} type in Ada 95 and the
13915 @code{Wide_Wide_Character} type in Ada 2005 (available
13916 in @code{GNAT} in Ada 2005 mode). This package contains
13917 Unicode categorization routines, as well as lexical
13918 categorization routines corresponding to the Ada 2005
13919 lexical rules for identifiers and strings, and also a
13920 lower case to upper case fold routine corresponding to
13921 the Ada 2005 rules for identifier equivalence.
13923 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
13924 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
13925 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
13926 @cindex Spell checking
13929 Provides a function for determining whether one wide wide string is a plausible
13930 near misspelling of another wide wide string, where the strings are represented
13931 using the UTF_32_String type defined in System.Wch_Cnv.
13933 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
13934 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
13935 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
13936 @cindex Spell checking
13939 Provides a function for determining whether one wide string is a plausible
13940 near misspelling of another wide string.
13942 @node GNAT.Wide_String_Split (g-wistsp.ads)
13943 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13944 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13945 @cindex Wide_String splitter
13948 Useful wide string manipulation routines: given a set of separators, split
13949 a wide string wherever the separators appear, and provide direct access
13950 to the resulting slices. This package is instantiated from
13951 @code{GNAT.Array_Split}.
13953 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
13954 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
13955 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
13956 @cindex Spell checking
13959 Provides a function for determining whether one wide wide string is a plausible
13960 near misspelling of another wide wide string.
13962 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
13963 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13964 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13965 @cindex Wide_Wide_String splitter
13968 Useful wide wide string manipulation routines: given a set of separators, split
13969 a wide wide string wherever the separators appear, and provide direct access
13970 to the resulting slices. This package is instantiated from
13971 @code{GNAT.Array_Split}.
13973 @node Interfaces.C.Extensions (i-cexten.ads)
13974 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13975 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13978 This package contains additional C-related definitions, intended
13979 for use with either manually or automatically generated bindings
13982 @node Interfaces.C.Streams (i-cstrea.ads)
13983 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13984 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13985 @cindex C streams, interfacing
13988 This package is a binding for the most commonly used operations
13991 @node Interfaces.CPP (i-cpp.ads)
13992 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
13993 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
13994 @cindex C++ interfacing
13995 @cindex Interfacing, to C++
13998 This package provides facilities for use in interfacing to C++. It
13999 is primarily intended to be used in connection with automated tools
14000 for the generation of C++ interfaces.
14002 @node Interfaces.Os2lib (i-os2lib.ads)
14003 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
14004 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
14005 @cindex Interfacing, to OS/2
14006 @cindex OS/2 interfacing
14009 This package provides interface definitions to the OS/2 library.
14010 It is a thin binding which is a direct translation of the
14011 various @file{<bse@.h>} files.
14013 @node Interfaces.Os2lib.Errors (i-os2err.ads)
14014 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
14015 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
14016 @cindex OS/2 Error codes
14017 @cindex Interfacing, to OS/2
14018 @cindex OS/2 interfacing
14021 This package provides definitions of the OS/2 error codes.
14023 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
14024 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
14025 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
14026 @cindex Interfacing, to OS/2
14027 @cindex Synchronization, OS/2
14028 @cindex OS/2 synchronization primitives
14031 This is a child package that provides definitions for interfacing
14032 to the @code{OS/2} synchronization primitives.
14034 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
14035 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
14036 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
14037 @cindex Interfacing, to OS/2
14038 @cindex Thread control, OS/2
14039 @cindex OS/2 thread interfacing
14042 This is a child package that provides definitions for interfacing
14043 to the @code{OS/2} thread primitives.
14045 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14046 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14047 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14048 @cindex IBM Packed Format
14049 @cindex Packed Decimal
14052 This package provides a set of routines for conversions to and
14053 from a packed decimal format compatible with that used on IBM
14056 @node Interfaces.VxWorks (i-vxwork.ads)
14057 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14058 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14059 @cindex Interfacing to VxWorks
14060 @cindex VxWorks, interfacing
14063 This package provides a limited binding to the VxWorks API.
14064 In particular, it interfaces with the
14065 VxWorks hardware interrupt facilities.
14067 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14068 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14069 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14070 @cindex Interfacing to VxWorks' I/O
14071 @cindex VxWorks, I/O interfacing
14072 @cindex VxWorks, Get_Immediate
14073 @cindex Get_Immediate, VxWorks
14076 This package provides a binding to the ioctl (IO/Control)
14077 function of VxWorks, defining a set of option values and
14078 function codes. A particular use of this package is
14079 to enable the use of Get_Immediate under VxWorks.
14081 @node System.Address_Image (s-addima.ads)
14082 @section @code{System.Address_Image} (@file{s-addima.ads})
14083 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14084 @cindex Address image
14085 @cindex Image, of an address
14088 This function provides a useful debugging
14089 function that gives an (implementation dependent)
14090 string which identifies an address.
14092 @node System.Assertions (s-assert.ads)
14093 @section @code{System.Assertions} (@file{s-assert.ads})
14094 @cindex @code{System.Assertions} (@file{s-assert.ads})
14096 @cindex Assert_Failure, exception
14099 This package provides the declaration of the exception raised
14100 by an run-time assertion failure, as well as the routine that
14101 is used internally to raise this assertion.
14103 @node System.Memory (s-memory.ads)
14104 @section @code{System.Memory} (@file{s-memory.ads})
14105 @cindex @code{System.Memory} (@file{s-memory.ads})
14106 @cindex Memory allocation
14109 This package provides the interface to the low level routines used
14110 by the generated code for allocation and freeing storage for the
14111 default storage pool (analogous to the C routines malloc and free.
14112 It also provides a reallocation interface analogous to the C routine
14113 realloc. The body of this unit may be modified to provide alternative
14114 allocation mechanisms for the default pool, and in addition, direct
14115 calls to this unit may be made for low level allocation uses (for
14116 example see the body of @code{GNAT.Tables}).
14118 @node System.Partition_Interface (s-parint.ads)
14119 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14120 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14121 @cindex Partition interfacing functions
14124 This package provides facilities for partition interfacing. It
14125 is used primarily in a distribution context when using Annex E
14128 @node System.Restrictions (s-restri.ads)
14129 @section @code{System.Restrictions} (@file{s-restri.ads})
14130 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14131 @cindex Run-time restrictions access
14134 This package provides facilities for accessing at run time
14135 the status of restrictions specified at compile time for
14136 the partition. Information is available both with regard
14137 to actual restrictions specified, and with regard to
14138 compiler determined information on which restrictions
14139 are violated by one or more packages in the partition.
14141 @node System.Rident (s-rident.ads)
14142 @section @code{System.Rident} (@file{s-rident.ads})
14143 @cindex @code{System.Rident} (@file{s-rident.ads})
14144 @cindex Restrictions definitions
14147 This package provides definitions of the restrictions
14148 identifiers supported by GNAT, and also the format of
14149 the restrictions provided in package System.Restrictions.
14150 It is not normally necessary to @code{with} this generic package
14151 since the necessary instantiation is included in
14152 package System.Restrictions.
14154 @node System.Task_Info (s-tasinf.ads)
14155 @section @code{System.Task_Info} (@file{s-tasinf.ads})
14156 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
14157 @cindex Task_Info pragma
14160 This package provides target dependent functionality that is used
14161 to support the @code{Task_Info} pragma
14163 @node System.Wch_Cnv (s-wchcnv.ads)
14164 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14165 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14166 @cindex Wide Character, Representation
14167 @cindex Wide String, Conversion
14168 @cindex Representation of wide characters
14171 This package provides routines for converting between
14172 wide and wide wide characters and a representation as a value of type
14173 @code{Standard.String}, using a specified wide character
14174 encoding method. It uses definitions in
14175 package @code{System.Wch_Con}.
14177 @node System.Wch_Con (s-wchcon.ads)
14178 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
14179 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
14182 This package provides definitions and descriptions of
14183 the various methods used for encoding wide characters
14184 in ordinary strings. These definitions are used by
14185 the package @code{System.Wch_Cnv}.
14187 @node Interfacing to Other Languages
14188 @chapter Interfacing to Other Languages
14190 The facilities in annex B of the Ada Reference Manual are fully
14191 implemented in GNAT, and in addition, a full interface to C++ is
14195 * Interfacing to C::
14196 * Interfacing to C++::
14197 * Interfacing to COBOL::
14198 * Interfacing to Fortran::
14199 * Interfacing to non-GNAT Ada code::
14202 @node Interfacing to C
14203 @section Interfacing to C
14206 Interfacing to C with GNAT can use one of two approaches:
14210 The types in the package @code{Interfaces.C} may be used.
14212 Standard Ada types may be used directly. This may be less portable to
14213 other compilers, but will work on all GNAT compilers, which guarantee
14214 correspondence between the C and Ada types.
14218 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
14219 effect, since this is the default. The following table shows the
14220 correspondence between Ada scalar types and the corresponding C types.
14225 @item Short_Integer
14227 @item Short_Short_Integer
14231 @item Long_Long_Integer
14239 @item Long_Long_Float
14240 This is the longest floating-point type supported by the hardware.
14244 Additionally, there are the following general correspondences between Ada
14248 Ada enumeration types map to C enumeration types directly if pragma
14249 @code{Convention C} is specified, which causes them to have int
14250 length. Without pragma @code{Convention C}, Ada enumeration types map to
14251 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
14252 @code{int}, respectively) depending on the number of values passed.
14253 This is the only case in which pragma @code{Convention C} affects the
14254 representation of an Ada type.
14257 Ada access types map to C pointers, except for the case of pointers to
14258 unconstrained types in Ada, which have no direct C equivalent.
14261 Ada arrays map directly to C arrays.
14264 Ada records map directly to C structures.
14267 Packed Ada records map to C structures where all members are bit fields
14268 of the length corresponding to the @code{@var{type}'Size} value in Ada.
14271 @node Interfacing to C++
14272 @section Interfacing to C++
14275 The interface to C++ makes use of the following pragmas, which are
14276 primarily intended to be constructed automatically using a binding generator
14277 tool, although it is possible to construct them by hand. No suitable binding
14278 generator tool is supplied with GNAT though.
14280 Using these pragmas it is possible to achieve complete
14281 inter-operability between Ada tagged types and C++ class definitions.
14282 See @ref{Implementation Defined Pragmas}, for more details.
14285 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
14286 The argument denotes an entity in the current declarative region that is
14287 declared as a tagged or untagged record type. It indicates that the type
14288 corresponds to an externally declared C++ class type, and is to be laid
14289 out the same way that C++ would lay out the type.
14291 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
14292 for backward compatibility but its functionality is available
14293 using pragma @code{Import} with @code{Convention} = @code{CPP}.
14295 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
14296 This pragma identifies an imported function (imported in the usual way
14297 with pragma @code{Import}) as corresponding to a C++ constructor.
14300 @node Interfacing to COBOL
14301 @section Interfacing to COBOL
14304 Interfacing to COBOL is achieved as described in section B.4 of
14305 the Ada Reference Manual.
14307 @node Interfacing to Fortran
14308 @section Interfacing to Fortran
14311 Interfacing to Fortran is achieved as described in section B.5 of the
14312 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
14313 multi-dimensional array causes the array to be stored in column-major
14314 order as required for convenient interface to Fortran.
14316 @node Interfacing to non-GNAT Ada code
14317 @section Interfacing to non-GNAT Ada code
14319 It is possible to specify the convention @code{Ada} in a pragma
14320 @code{Import} or pragma @code{Export}. However this refers to
14321 the calling conventions used by GNAT, which may or may not be
14322 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
14323 compiler to allow interoperation.
14325 If arguments types are kept simple, and if the foreign compiler generally
14326 follows system calling conventions, then it may be possible to integrate
14327 files compiled by other Ada compilers, provided that the elaboration
14328 issues are adequately addressed (for example by eliminating the
14329 need for any load time elaboration).
14331 In particular, GNAT running on VMS is designed to
14332 be highly compatible with the DEC Ada 83 compiler, so this is one
14333 case in which it is possible to import foreign units of this type,
14334 provided that the data items passed are restricted to simple scalar
14335 values or simple record types without variants, or simple array
14336 types with fixed bounds.
14338 @node Specialized Needs Annexes
14339 @chapter Specialized Needs Annexes
14342 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
14343 required in all implementations. However, as described in this chapter,
14344 GNAT implements all of these annexes:
14347 @item Systems Programming (Annex C)
14348 The Systems Programming Annex is fully implemented.
14350 @item Real-Time Systems (Annex D)
14351 The Real-Time Systems Annex is fully implemented.
14353 @item Distributed Systems (Annex E)
14354 Stub generation is fully implemented in the GNAT compiler. In addition,
14355 a complete compatible PCS is available as part of the GLADE system,
14356 a separate product. When the two
14357 products are used in conjunction, this annex is fully implemented.
14359 @item Information Systems (Annex F)
14360 The Information Systems annex is fully implemented.
14362 @item Numerics (Annex G)
14363 The Numerics Annex is fully implemented.
14365 @item Safety and Security / High-Integrity Systems (Annex H)
14366 The Safety and Security Annex (termed the High-Integrity Systems Annex
14367 in Ada 2005) is fully implemented.
14370 @node Implementation of Specific Ada Features
14371 @chapter Implementation of Specific Ada Features
14374 This chapter describes the GNAT implementation of several Ada language
14378 * Machine Code Insertions::
14379 * GNAT Implementation of Tasking::
14380 * GNAT Implementation of Shared Passive Packages::
14381 * Code Generation for Array Aggregates::
14382 * The Size of Discriminated Records with Default Discriminants::
14383 * Strict Conformance to the Ada Reference Manual::
14386 @node Machine Code Insertions
14387 @section Machine Code Insertions
14388 @cindex Machine Code insertions
14391 Package @code{Machine_Code} provides machine code support as described
14392 in the Ada Reference Manual in two separate forms:
14395 Machine code statements, consisting of qualified expressions that
14396 fit the requirements of RM section 13.8.
14398 An intrinsic callable procedure, providing an alternative mechanism of
14399 including machine instructions in a subprogram.
14403 The two features are similar, and both are closely related to the mechanism
14404 provided by the asm instruction in the GNU C compiler. Full understanding
14405 and use of the facilities in this package requires understanding the asm
14406 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
14407 by Richard Stallman. The relevant section is titled ``Extensions to the C
14408 Language Family'' @result{} ``Assembler Instructions with C Expression
14411 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
14412 semantic restrictions and effects as described below. Both are provided so
14413 that the procedure call can be used as a statement, and the function call
14414 can be used to form a code_statement.
14416 The first example given in the GCC documentation is the C @code{asm}
14419 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
14423 The equivalent can be written for GNAT as:
14425 @smallexample @c ada
14426 Asm ("fsinx %1 %0",
14427 My_Float'Asm_Output ("=f", result),
14428 My_Float'Asm_Input ("f", angle));
14432 The first argument to @code{Asm} is the assembler template, and is
14433 identical to what is used in GNU C@. This string must be a static
14434 expression. The second argument is the output operand list. It is
14435 either a single @code{Asm_Output} attribute reference, or a list of such
14436 references enclosed in parentheses (technically an array aggregate of
14439 The @code{Asm_Output} attribute denotes a function that takes two
14440 parameters. The first is a string, the second is the name of a variable
14441 of the type designated by the attribute prefix. The first (string)
14442 argument is required to be a static expression and designates the
14443 constraint for the parameter (e.g.@: what kind of register is
14444 required). The second argument is the variable to be updated with the
14445 result. The possible values for constraint are the same as those used in
14446 the RTL, and are dependent on the configuration file used to build the
14447 GCC back end. If there are no output operands, then this argument may
14448 either be omitted, or explicitly given as @code{No_Output_Operands}.
14450 The second argument of @code{@var{my_float}'Asm_Output} functions as
14451 though it were an @code{out} parameter, which is a little curious, but
14452 all names have the form of expressions, so there is no syntactic
14453 irregularity, even though normally functions would not be permitted
14454 @code{out} parameters. The third argument is the list of input
14455 operands. It is either a single @code{Asm_Input} attribute reference, or
14456 a list of such references enclosed in parentheses (technically an array
14457 aggregate of such references).
14459 The @code{Asm_Input} attribute denotes a function that takes two
14460 parameters. The first is a string, the second is an expression of the
14461 type designated by the prefix. The first (string) argument is required
14462 to be a static expression, and is the constraint for the parameter,
14463 (e.g.@: what kind of register is required). The second argument is the
14464 value to be used as the input argument. The possible values for the
14465 constant are the same as those used in the RTL, and are dependent on
14466 the configuration file used to built the GCC back end.
14468 If there are no input operands, this argument may either be omitted, or
14469 explicitly given as @code{No_Input_Operands}. The fourth argument, not
14470 present in the above example, is a list of register names, called the
14471 @dfn{clobber} argument. This argument, if given, must be a static string
14472 expression, and is a space or comma separated list of names of registers
14473 that must be considered destroyed as a result of the @code{Asm} call. If
14474 this argument is the null string (the default value), then the code
14475 generator assumes that no additional registers are destroyed.
14477 The fifth argument, not present in the above example, called the
14478 @dfn{volatile} argument, is by default @code{False}. It can be set to
14479 the literal value @code{True} to indicate to the code generator that all
14480 optimizations with respect to the instruction specified should be
14481 suppressed, and that in particular, for an instruction that has outputs,
14482 the instruction will still be generated, even if none of the outputs are
14483 used. See the full description in the GCC manual for further details.
14484 Generally it is strongly advisable to use Volatile for any ASM statement
14485 that is missing either input or output operands, or when two or more ASM
14486 statements appear in sequence, to avoid unwanted optimizations. A warning
14487 is generated if this advice is not followed.
14489 The @code{Asm} subprograms may be used in two ways. First the procedure
14490 forms can be used anywhere a procedure call would be valid, and
14491 correspond to what the RM calls ``intrinsic'' routines. Such calls can
14492 be used to intersperse machine instructions with other Ada statements.
14493 Second, the function forms, which return a dummy value of the limited
14494 private type @code{Asm_Insn}, can be used in code statements, and indeed
14495 this is the only context where such calls are allowed. Code statements
14496 appear as aggregates of the form:
14498 @smallexample @c ada
14499 Asm_Insn'(Asm (@dots{}));
14500 Asm_Insn'(Asm_Volatile (@dots{}));
14504 In accordance with RM rules, such code statements are allowed only
14505 within subprograms whose entire body consists of such statements. It is
14506 not permissible to intermix such statements with other Ada statements.
14508 Typically the form using intrinsic procedure calls is more convenient
14509 and more flexible. The code statement form is provided to meet the RM
14510 suggestion that such a facility should be made available. The following
14511 is the exact syntax of the call to @code{Asm}. As usual, if named notation
14512 is used, the arguments may be given in arbitrary order, following the
14513 normal rules for use of positional and named arguments)
14517 [Template =>] static_string_EXPRESSION
14518 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
14519 [,[Inputs =>] INPUT_OPERAND_LIST ]
14520 [,[Clobber =>] static_string_EXPRESSION ]
14521 [,[Volatile =>] static_boolean_EXPRESSION] )
14523 OUTPUT_OPERAND_LIST ::=
14524 [PREFIX.]No_Output_Operands
14525 | OUTPUT_OPERAND_ATTRIBUTE
14526 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
14528 OUTPUT_OPERAND_ATTRIBUTE ::=
14529 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
14531 INPUT_OPERAND_LIST ::=
14532 [PREFIX.]No_Input_Operands
14533 | INPUT_OPERAND_ATTRIBUTE
14534 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
14536 INPUT_OPERAND_ATTRIBUTE ::=
14537 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
14541 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
14542 are declared in the package @code{Machine_Code} and must be referenced
14543 according to normal visibility rules. In particular if there is no
14544 @code{use} clause for this package, then appropriate package name
14545 qualification is required.
14547 @node GNAT Implementation of Tasking
14548 @section GNAT Implementation of Tasking
14551 This chapter outlines the basic GNAT approach to tasking (in particular,
14552 a multi-layered library for portability) and discusses issues related
14553 to compliance with the Real-Time Systems Annex.
14556 * Mapping Ada Tasks onto the Underlying Kernel Threads::
14557 * Ensuring Compliance with the Real-Time Annex::
14560 @node Mapping Ada Tasks onto the Underlying Kernel Threads
14561 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
14564 GNAT's run-time support comprises two layers:
14567 @item GNARL (GNAT Run-time Layer)
14568 @item GNULL (GNAT Low-level Library)
14572 In GNAT, Ada's tasking services rely on a platform and OS independent
14573 layer known as GNARL@. This code is responsible for implementing the
14574 correct semantics of Ada's task creation, rendezvous, protected
14577 GNARL decomposes Ada's tasking semantics into simpler lower level
14578 operations such as create a thread, set the priority of a thread,
14579 yield, create a lock, lock/unlock, etc. The spec for these low-level
14580 operations constitutes GNULLI, the GNULL Interface. This interface is
14581 directly inspired from the POSIX real-time API@.
14583 If the underlying executive or OS implements the POSIX standard
14584 faithfully, the GNULL Interface maps as is to the services offered by
14585 the underlying kernel. Otherwise, some target dependent glue code maps
14586 the services offered by the underlying kernel to the semantics expected
14589 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
14590 key point is that each Ada task is mapped on a thread in the underlying
14591 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
14593 In addition Ada task priorities map onto the underlying thread priorities.
14594 Mapping Ada tasks onto the underlying kernel threads has several advantages:
14598 The underlying scheduler is used to schedule the Ada tasks. This
14599 makes Ada tasks as efficient as kernel threads from a scheduling
14603 Interaction with code written in C containing threads is eased
14604 since at the lowest level Ada tasks and C threads map onto the same
14605 underlying kernel concept.
14608 When an Ada task is blocked during I/O the remaining Ada tasks are
14612 On multiprocessor systems Ada tasks can execute in parallel.
14616 Some threads libraries offer a mechanism to fork a new process, with the
14617 child process duplicating the threads from the parent.
14619 support this functionality when the parent contains more than one task.
14620 @cindex Forking a new process
14622 @node Ensuring Compliance with the Real-Time Annex
14623 @subsection Ensuring Compliance with the Real-Time Annex
14624 @cindex Real-Time Systems Annex compliance
14627 Although mapping Ada tasks onto
14628 the underlying threads has significant advantages, it does create some
14629 complications when it comes to respecting the scheduling semantics
14630 specified in the real-time annex (Annex D).
14632 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
14633 scheduling policy states:
14636 @emph{When the active priority of a ready task that is not running
14637 changes, or the setting of its base priority takes effect, the
14638 task is removed from the ready queue for its old active priority
14639 and is added at the tail of the ready queue for its new active
14640 priority, except in the case where the active priority is lowered
14641 due to the loss of inherited priority, in which case the task is
14642 added at the head of the ready queue for its new active priority.}
14646 While most kernels do put tasks at the end of the priority queue when
14647 a task changes its priority, (which respects the main
14648 FIFO_Within_Priorities requirement), almost none keep a thread at the
14649 beginning of its priority queue when its priority drops from the loss
14650 of inherited priority.
14652 As a result most vendors have provided incomplete Annex D implementations.
14654 The GNAT run-time, has a nice cooperative solution to this problem
14655 which ensures that accurate FIFO_Within_Priorities semantics are
14658 The principle is as follows. When an Ada task T is about to start
14659 running, it checks whether some other Ada task R with the same
14660 priority as T has been suspended due to the loss of priority
14661 inheritance. If this is the case, T yields and is placed at the end of
14662 its priority queue. When R arrives at the front of the queue it
14665 Note that this simple scheme preserves the relative order of the tasks
14666 that were ready to execute in the priority queue where R has been
14669 @node GNAT Implementation of Shared Passive Packages
14670 @section GNAT Implementation of Shared Passive Packages
14671 @cindex Shared passive packages
14674 GNAT fully implements the pragma @code{Shared_Passive} for
14675 @cindex pragma @code{Shared_Passive}
14676 the purpose of designating shared passive packages.
14677 This allows the use of passive partitions in the
14678 context described in the Ada Reference Manual; i.e. for communication
14679 between separate partitions of a distributed application using the
14680 features in Annex E.
14682 @cindex Distribution Systems Annex
14684 However, the implementation approach used by GNAT provides for more
14685 extensive usage as follows:
14688 @item Communication between separate programs
14690 This allows separate programs to access the data in passive
14691 partitions, using protected objects for synchronization where
14692 needed. The only requirement is that the two programs have a
14693 common shared file system. It is even possible for programs
14694 running on different machines with different architectures
14695 (e.g. different endianness) to communicate via the data in
14696 a passive partition.
14698 @item Persistence between program runs
14700 The data in a passive package can persist from one run of a
14701 program to another, so that a later program sees the final
14702 values stored by a previous run of the same program.
14707 The implementation approach used is to store the data in files. A
14708 separate stream file is created for each object in the package, and
14709 an access to an object causes the corresponding file to be read or
14712 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
14713 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
14714 set to the directory to be used for these files.
14715 The files in this directory
14716 have names that correspond to their fully qualified names. For
14717 example, if we have the package
14719 @smallexample @c ada
14721 pragma Shared_Passive (X);
14728 and the environment variable is set to @code{/stemp/}, then the files created
14729 will have the names:
14737 These files are created when a value is initially written to the object, and
14738 the files are retained until manually deleted. This provides the persistence
14739 semantics. If no file exists, it means that no partition has assigned a value
14740 to the variable; in this case the initial value declared in the package
14741 will be used. This model ensures that there are no issues in synchronizing
14742 the elaboration process, since elaboration of passive packages elaborates the
14743 initial values, but does not create the files.
14745 The files are written using normal @code{Stream_IO} access.
14746 If you want to be able
14747 to communicate between programs or partitions running on different
14748 architectures, then you should use the XDR versions of the stream attribute
14749 routines, since these are architecture independent.
14751 If active synchronization is required for access to the variables in the
14752 shared passive package, then as described in the Ada Reference Manual, the
14753 package may contain protected objects used for this purpose. In this case
14754 a lock file (whose name is @file{___lock} (three underscores)
14755 is created in the shared memory directory.
14756 @cindex @file{___lock} file (for shared passive packages)
14757 This is used to provide the required locking
14758 semantics for proper protected object synchronization.
14760 As of January 2003, GNAT supports shared passive packages on all platforms
14761 except for OpenVMS.
14763 @node Code Generation for Array Aggregates
14764 @section Code Generation for Array Aggregates
14767 * Static constant aggregates with static bounds::
14768 * Constant aggregates with unconstrained nominal types::
14769 * Aggregates with static bounds::
14770 * Aggregates with non-static bounds::
14771 * Aggregates in assignment statements::
14775 Aggregates have a rich syntax and allow the user to specify the values of
14776 complex data structures by means of a single construct. As a result, the
14777 code generated for aggregates can be quite complex and involve loops, case
14778 statements and multiple assignments. In the simplest cases, however, the
14779 compiler will recognize aggregates whose components and constraints are
14780 fully static, and in those cases the compiler will generate little or no
14781 executable code. The following is an outline of the code that GNAT generates
14782 for various aggregate constructs. For further details, you will find it
14783 useful to examine the output produced by the -gnatG flag to see the expanded
14784 source that is input to the code generator. You may also want to examine
14785 the assembly code generated at various levels of optimization.
14787 The code generated for aggregates depends on the context, the component values,
14788 and the type. In the context of an object declaration the code generated is
14789 generally simpler than in the case of an assignment. As a general rule, static
14790 component values and static subtypes also lead to simpler code.
14792 @node Static constant aggregates with static bounds
14793 @subsection Static constant aggregates with static bounds
14796 For the declarations:
14797 @smallexample @c ada
14798 type One_Dim is array (1..10) of integer;
14799 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
14803 GNAT generates no executable code: the constant ar0 is placed in static memory.
14804 The same is true for constant aggregates with named associations:
14806 @smallexample @c ada
14807 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
14808 Cr3 : constant One_Dim := (others => 7777);
14812 The same is true for multidimensional constant arrays such as:
14814 @smallexample @c ada
14815 type two_dim is array (1..3, 1..3) of integer;
14816 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
14820 The same is true for arrays of one-dimensional arrays: the following are
14823 @smallexample @c ada
14824 type ar1b is array (1..3) of boolean;
14825 type ar_ar is array (1..3) of ar1b;
14826 None : constant ar1b := (others => false); -- fully static
14827 None2 : constant ar_ar := (1..3 => None); -- fully static
14831 However, for multidimensional aggregates with named associations, GNAT will
14832 generate assignments and loops, even if all associations are static. The
14833 following two declarations generate a loop for the first dimension, and
14834 individual component assignments for the second dimension:
14836 @smallexample @c ada
14837 Zero1: constant two_dim := (1..3 => (1..3 => 0));
14838 Zero2: constant two_dim := (others => (others => 0));
14841 @node Constant aggregates with unconstrained nominal types
14842 @subsection Constant aggregates with unconstrained nominal types
14845 In such cases the aggregate itself establishes the subtype, so that
14846 associations with @code{others} cannot be used. GNAT determines the
14847 bounds for the actual subtype of the aggregate, and allocates the
14848 aggregate statically as well. No code is generated for the following:
14850 @smallexample @c ada
14851 type One_Unc is array (natural range <>) of integer;
14852 Cr_Unc : constant One_Unc := (12,24,36);
14855 @node Aggregates with static bounds
14856 @subsection Aggregates with static bounds
14859 In all previous examples the aggregate was the initial (and immutable) value
14860 of a constant. If the aggregate initializes a variable, then code is generated
14861 for it as a combination of individual assignments and loops over the target
14862 object. The declarations
14864 @smallexample @c ada
14865 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
14866 Cr_Var2 : One_Dim := (others > -1);
14870 generate the equivalent of
14872 @smallexample @c ada
14878 for I in Cr_Var2'range loop
14879 Cr_Var2 (I) := =-1;
14883 @node Aggregates with non-static bounds
14884 @subsection Aggregates with non-static bounds
14887 If the bounds of the aggregate are not statically compatible with the bounds
14888 of the nominal subtype of the target, then constraint checks have to be
14889 generated on the bounds. For a multidimensional array, constraint checks may
14890 have to be applied to sub-arrays individually, if they do not have statically
14891 compatible subtypes.
14893 @node Aggregates in assignment statements
14894 @subsection Aggregates in assignment statements
14897 In general, aggregate assignment requires the construction of a temporary,
14898 and a copy from the temporary to the target of the assignment. This is because
14899 it is not always possible to convert the assignment into a series of individual
14900 component assignments. For example, consider the simple case:
14902 @smallexample @c ada
14907 This cannot be converted into:
14909 @smallexample @c ada
14915 So the aggregate has to be built first in a separate location, and then
14916 copied into the target. GNAT recognizes simple cases where this intermediate
14917 step is not required, and the assignments can be performed in place, directly
14918 into the target. The following sufficient criteria are applied:
14922 The bounds of the aggregate are static, and the associations are static.
14924 The components of the aggregate are static constants, names of
14925 simple variables that are not renamings, or expressions not involving
14926 indexed components whose operands obey these rules.
14930 If any of these conditions are violated, the aggregate will be built in
14931 a temporary (created either by the front-end or the code generator) and then
14932 that temporary will be copied onto the target.
14935 @node The Size of Discriminated Records with Default Discriminants
14936 @section The Size of Discriminated Records with Default Discriminants
14939 If a discriminated type @code{T} has discriminants with default values, it is
14940 possible to declare an object of this type without providing an explicit
14943 @smallexample @c ada
14945 type Size is range 1..100;
14947 type Rec (D : Size := 15) is record
14948 Name : String (1..D);
14956 Such an object is said to be @emph{unconstrained}.
14957 The discriminant of the object
14958 can be modified by a full assignment to the object, as long as it preserves the
14959 relation between the value of the discriminant, and the value of the components
14962 @smallexample @c ada
14964 Word := (3, "yes");
14966 Word := (5, "maybe");
14968 Word := (5, "no"); -- raises Constraint_Error
14973 In order to support this behavior efficiently, an unconstrained object is
14974 given the maximum size that any value of the type requires. In the case
14975 above, @code{Word} has storage for the discriminant and for
14976 a @code{String} of length 100.
14977 It is important to note that unconstrained objects do not require dynamic
14978 allocation. It would be an improper implementation to place on the heap those
14979 components whose size depends on discriminants. (This improper implementation
14980 was used by some Ada83 compilers, where the @code{Name} component above
14982 been stored as a pointer to a dynamic string). Following the principle that
14983 dynamic storage management should never be introduced implicitly,
14984 an Ada compiler should reserve the full size for an unconstrained declared
14985 object, and place it on the stack.
14987 This maximum size approach
14988 has been a source of surprise to some users, who expect the default
14989 values of the discriminants to determine the size reserved for an
14990 unconstrained object: ``If the default is 15, why should the object occupy
14992 The answer, of course, is that the discriminant may be later modified,
14993 and its full range of values must be taken into account. This is why the
14998 type Rec (D : Positive := 15) is record
14999 Name : String (1..D);
15007 is flagged by the compiler with a warning:
15008 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15009 because the required size includes @code{Positive'Last}
15010 bytes. As the first example indicates, the proper approach is to declare an
15011 index type of ``reasonable'' range so that unconstrained objects are not too
15014 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15015 created in the heap by means of an allocator, then it is @emph{not}
15017 it is constrained by the default values of the discriminants, and those values
15018 cannot be modified by full assignment. This is because in the presence of
15019 aliasing all views of the object (which may be manipulated by different tasks,
15020 say) must be consistent, so it is imperative that the object, once created,
15023 @node Strict Conformance to the Ada Reference Manual
15024 @section Strict Conformance to the Ada Reference Manual
15027 The dynamic semantics defined by the Ada Reference Manual impose a set of
15028 run-time checks to be generated. By default, the GNAT compiler will insert many
15029 run-time checks into the compiled code, including most of those required by the
15030 Ada Reference Manual. However, there are three checks that are not enabled
15031 in the default mode for efficiency reasons: arithmetic overflow checking for
15032 integer operations (including division by zero), checks for access before
15033 elaboration on subprogram calls, and stack overflow checking (most operating
15034 systems do not perform this check by default).
15036 Strict conformance to the Ada Reference Manual can be achieved by adding
15037 three compiler options for overflow checking for integer operations
15038 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15039 calls and generic instantiations (@option{-gnatE}), and stack overflow
15040 checking (@option{-fstack-check}).
15042 Note that the result of a floating point arithmetic operation in overflow and
15043 invalid situations, when the @code{Machine_Overflows} attribute of the result
15044 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15045 case for machines compliant with the IEEE floating-point standard, but on
15046 machines that are not fully compliant with this standard, such as Alpha, the
15047 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15048 behavior (although at the cost of a significant performance penalty), so
15049 infinite and and NaN values are properly generated.
15052 @node Project File Reference
15053 @chapter Project File Reference
15056 This chapter describes the syntax and semantics of project files.
15057 Project files specify the options to be used when building a system.
15058 Project files can specify global settings for all tools,
15059 as well as tool-specific settings.
15060 See the chapter on project files in the GNAT Users guide for examples of use.
15064 * Lexical Elements::
15066 * Empty declarations::
15067 * Typed string declarations::
15071 * Project Attributes::
15072 * Attribute References::
15073 * External Values::
15074 * Case Construction::
15076 * Package Renamings::
15078 * Project Extensions::
15079 * Project File Elaboration::
15082 @node Reserved Words
15083 @section Reserved Words
15086 All Ada reserved words are reserved in project files, and cannot be used
15087 as variable names or project names. In addition, the following are
15088 also reserved in project files:
15091 @item @code{extends}
15093 @item @code{external}
15095 @item @code{project}
15099 @node Lexical Elements
15100 @section Lexical Elements
15103 Rules for identifiers are the same as in Ada. Identifiers
15104 are case-insensitive. Strings are case sensitive, except where noted.
15105 Comments have the same form as in Ada.
15115 simple_name @{. simple_name@}
15119 @section Declarations
15122 Declarations introduce new entities that denote types, variables, attributes,
15123 and packages. Some declarations can only appear immediately within a project
15124 declaration. Others can appear within a project or within a package.
15128 declarative_item ::=
15129 simple_declarative_item |
15130 typed_string_declaration |
15131 package_declaration
15133 simple_declarative_item ::=
15134 variable_declaration |
15135 typed_variable_declaration |
15136 attribute_declaration |
15137 case_construction |
15141 @node Empty declarations
15142 @section Empty declarations
15145 empty_declaration ::=
15149 An empty declaration is allowed anywhere a declaration is allowed.
15152 @node Typed string declarations
15153 @section Typed string declarations
15156 Typed strings are sequences of string literals. Typed strings are the only
15157 named types in project files. They are used in case constructions, where they
15158 provide support for conditional attribute definitions.
15162 typed_string_declaration ::=
15163 @b{type} <typed_string_>_simple_name @b{is}
15164 ( string_literal @{, string_literal@} );
15168 A typed string declaration can only appear immediately within a project
15171 All the string literals in a typed string declaration must be distinct.
15177 Variables denote values, and appear as constituents of expressions.
15180 typed_variable_declaration ::=
15181 <typed_variable_>simple_name : <typed_string_>name := string_expression ;
15183 variable_declaration ::=
15184 <variable_>simple_name := expression;
15188 The elaboration of a variable declaration introduces the variable and
15189 assigns to it the value of the expression. The name of the variable is
15190 available after the assignment symbol.
15193 A typed_variable can only be declare once.
15196 a non typed variable can be declared multiple times.
15199 Before the completion of its first declaration, the value of variable
15200 is the null string.
15203 @section Expressions
15206 An expression is a formula that defines a computation or retrieval of a value.
15207 In a project file the value of an expression is either a string or a list
15208 of strings. A string value in an expression is either a literal, the current
15209 value of a variable, an external value, an attribute reference, or a
15210 concatenation operation.
15223 attribute_reference
15229 ( <string_>expression @{ , <string_>expression @} )
15232 @subsection Concatenation
15234 The following concatenation functions are defined:
15236 @smallexample @c ada
15237 function "&" (X : String; Y : String) return String;
15238 function "&" (X : String_List; Y : String) return String_List;
15239 function "&" (X : String_List; Y : String_List) return String_List;
15243 @section Attributes
15246 An attribute declaration defines a property of a project or package. This
15247 property can later be queried by means of an attribute reference.
15248 Attribute values are strings or string lists.
15250 Some attributes are associative arrays. These attributes are mappings whose
15251 domain is a set of strings. These attributes are declared one association
15252 at a time, by specifying a point in the domain and the corresponding image
15253 of the attribute. They may also be declared as a full associative array,
15254 getting the same associations as the corresponding attribute in an imported
15255 or extended project.
15257 Attributes that are not associative arrays are called simple attributes.
15261 attribute_declaration ::=
15262 full_associative_array_declaration |
15263 @b{for} attribute_designator @b{use} expression ;
15265 full_associative_array_declaration ::=
15266 @b{for} <associative_array_attribute_>simple_name @b{use}
15267 <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
15269 attribute_designator ::=
15270 <simple_attribute_>simple_name |
15271 <associative_array_attribute_>simple_name ( string_literal )
15275 Some attributes are project-specific, and can only appear immediately within
15276 a project declaration. Others are package-specific, and can only appear within
15277 the proper package.
15279 The expression in an attribute definition must be a string or a string_list.
15280 The string literal appearing in the attribute_designator of an associative
15281 array attribute is case-insensitive.
15283 @node Project Attributes
15284 @section Project Attributes
15287 The following attributes apply to a project. All of them are simple
15292 Expression must be a path name. The attribute defines the
15293 directory in which the object files created by the build are to be placed. If
15294 not specified, object files are placed in the project directory.
15297 Expression must be a path name. The attribute defines the
15298 directory in which the executables created by the build are to be placed.
15299 If not specified, executables are placed in the object directory.
15302 Expression must be a list of path names. The attribute
15303 defines the directories in which the source files for the project are to be
15304 found. If not specified, source files are found in the project directory.
15305 If a string in the list ends with "/**", then the directory that precedes
15306 "/**" and all of its subdirectories (recursively) are included in the list
15307 of source directories.
15309 @item Excluded_Source_Dirs
15310 Expression must be a list of strings. Each entry designates a directory that
15311 is not to be included in the list of source directories of the project.
15312 This is normally used when there are strings ending with "/**" in the value
15313 of attribute Source_Dirs.
15316 Expression must be a list of file names. The attribute
15317 defines the individual files, in the project directory, which are to be used
15318 as sources for the project. File names are path_names that contain no directory
15319 information. If the project has no sources the attribute must be declared
15320 explicitly with an empty list.
15322 @item Excluded_Source_Files (Locally_Removed_Files)
15323 Expression must be a list of strings that are legal file names.
15324 Each file name must designate a source that would normally be a source file
15325 in the source directories of the project or, if the project file is an
15326 extending project file, inherited by the current project file. It cannot
15327 designate an immediate source that is not inherited. Each of the source files
15328 in the list are not considered to be sources of the project file: they are not
15329 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
15330 Excluded_Source_Files is preferred.
15332 @item Source_List_File
15333 Expression must a single path name. The attribute
15334 defines a text file that contains a list of source file names to be used
15335 as sources for the project
15338 Expression must be a path name. The attribute defines the
15339 directory in which a library is to be built. The directory must exist, must
15340 be distinct from the project's object directory, and must be writable.
15343 Expression must be a string that is a legal file name,
15344 without extension. The attribute defines a string that is used to generate
15345 the name of the library to be built by the project.
15348 Argument must be a string value that must be one of the
15349 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
15350 string is case-insensitive. If this attribute is not specified, the library is
15351 a static library. Otherwise, the library may be dynamic or relocatable. This
15352 distinction is operating-system dependent.
15354 @item Library_Version
15355 Expression must be a string value whose interpretation
15356 is platform dependent. On UNIX, it is used only for dynamic/relocatable
15357 libraries as the internal name of the library (the @code{"soname"}). If the
15358 library file name (built from the @code{Library_Name}) is different from the
15359 @code{Library_Version}, then the library file will be a symbolic link to the
15360 actual file whose name will be @code{Library_Version}.
15362 @item Library_Interface
15363 Expression must be a string list. Each element of the string list
15364 must designate a unit of the project.
15365 If this attribute is present in a Library Project File, then the project
15366 file is a Stand-alone Library_Project_File.
15368 @item Library_Auto_Init
15369 Expression must be a single string "true" or "false", case-insensitive.
15370 If this attribute is present in a Stand-alone Library Project File,
15371 it indicates if initialization is automatic when the dynamic library
15374 @item Library_Options
15375 Expression must be a string list. Indicates additional switches that
15376 are to be used when building a shared library.
15379 Expression must be a single string. Designates an alternative to "gcc"
15380 for building shared libraries.
15382 @item Library_Src_Dir
15383 Expression must be a path name. The attribute defines the
15384 directory in which the sources of the interfaces of a Stand-alone Library will
15385 be copied. The directory must exist, must be distinct from the project's
15386 object directory and source directories of all projects in the project tree,
15387 and must be writable.
15389 @item Library_Src_Dir
15390 Expression must be a path name. The attribute defines the
15391 directory in which the ALI files of a Library will
15392 be copied. The directory must exist, must be distinct from the project's
15393 object directory and source directories of all projects in the project tree,
15394 and must be writable.
15396 @item Library_Symbol_File
15397 Expression must be a single string. Its value is the single file name of a
15398 symbol file to be created when building a stand-alone library when the
15399 symbol policy is either "compliant", "controlled" or "restricted",
15400 on platforms that support symbol control, such as VMS. When symbol policy
15401 is "direct", then a file with this name must exist in the object directory.
15403 @item Library_Reference_Symbol_File
15404 Expression must be a single string. Its value is the path name of a
15405 reference symbol file that is read when the symbol policy is either
15406 "compliant" or "controlled", on platforms that support symbol control,
15407 such as VMS, when building a stand-alone library. The path may be an absolute
15408 path or a path relative to the project directory.
15410 @item Library_Symbol_Policy
15411 Expression must be a single string. Its case-insensitive value can only be
15412 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
15414 This attribute is not taken into account on all platforms. It controls the
15415 policy for exported symbols and, on some platforms (like VMS) that have the
15416 notions of major and minor IDs built in the library files, it controls
15417 the setting of these IDs.
15419 "autonomous" or "default": exported symbols are not controlled.
15421 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
15422 it is equivalent to policy "autonomous". If there are exported symbols in
15423 the reference symbol file that are not in the object files of the interfaces,
15424 the major ID of the library is increased. If there are symbols in the
15425 object files of the interfaces that are not in the reference symbol file,
15426 these symbols are put at the end of the list in the newly created symbol file
15427 and the minor ID is increased.
15429 "controlled": the attribute Library_Reference_Symbol_File must be defined.
15430 The library will fail to build if the exported symbols in the object files of
15431 the interfaces do not match exactly the symbol in the symbol file.
15433 "restricted": The attribute Library_Symbol_File must be defined. The library
15434 will fail to build if there are symbols in the symbol file that are not in
15435 the exported symbols of the object files of the interfaces. Additional symbols
15436 in the object files are not added to the symbol file.
15438 "direct": The attribute Library_Symbol_File must be defined and must designate
15439 an existing file in the object directory. This symbol file is passed directly
15440 to the underlying linker without any symbol processing.
15443 Expression must be a list of strings that are legal file names.
15444 These file names designate existing compilation units in the source directory
15445 that are legal main subprograms.
15447 When a project file is elaborated, as part of the execution of a gnatmake
15448 command, one or several executables are built and placed in the Exec_Dir.
15449 If the gnatmake command does not include explicit file names, the executables
15450 that are built correspond to the files specified by this attribute.
15452 @item Externally_Built
15453 Expression must be a single string. Its value must be either "true" of "false",
15454 case-insensitive. The default is "false". When the value of this attribute is
15455 "true", no attempt is made to compile the sources or to build the library,
15456 when the project is a library project.
15458 @item Main_Language
15459 This is a simple attribute. Its value is a string that specifies the
15460 language of the main program.
15463 Expression must be a string list. Each string designates
15464 a programming language that is known to GNAT. The strings are case-insensitive.
15468 @node Attribute References
15469 @section Attribute References
15472 Attribute references are used to retrieve the value of previously defined
15473 attribute for a package or project.
15476 attribute_reference ::=
15477 attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
15479 attribute_prefix ::=
15481 <project_simple_name | package_identifier |
15482 <project_>simple_name . package_identifier
15486 If an attribute has not been specified for a given package or project, its
15487 value is the null string or the empty list.
15489 @node External Values
15490 @section External Values
15493 An external value is an expression whose value is obtained from the command
15494 that invoked the processing of the current project file (typically a
15500 @b{external} ( string_literal [, string_literal] )
15504 The first string_literal is the string to be used on the command line or
15505 in the environment to specify the external value. The second string_literal,
15506 if present, is the default to use if there is no specification for this
15507 external value either on the command line or in the environment.
15509 @node Case Construction
15510 @section Case Construction
15513 A case construction supports attribute and variable declarations that depend
15514 on the value of a previously declared variable.
15518 case_construction ::=
15519 @b{case} <typed_variable_>name @b{is}
15524 @b{when} discrete_choice_list =>
15525 @{case_construction |
15526 attribute_declaration |
15527 variable_declaration |
15528 empty_declaration@}
15530 discrete_choice_list ::=
15531 string_literal @{| string_literal@} |
15536 Inside a case construction, variable declarations must be for variables that
15537 have already been declared before the case construction.
15539 All choices in a choice list must be distinct. The choice lists of two
15540 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
15541 alternatives do not need to include all values of the type. An @code{others}
15542 choice must appear last in the list of alternatives.
15548 A package provides a grouping of variable declarations and attribute
15549 declarations to be used when invoking various GNAT tools. The name of
15550 the package indicates the tool(s) to which it applies.
15554 package_declaration ::=
15555 package_specification | package_renaming
15557 package_specification ::=
15558 @b{package} package_identifier @b{is}
15559 @{simple_declarative_item@}
15560 @b{end} package_identifier ;
15562 package_identifier ::=
15563 @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
15564 @code{Linker} | @code{Finder} | @code{Cross_Reference} |
15565 @code{gnatls} | @code{IDE} | @code{Pretty_Printer}
15568 @subsection Package Naming
15571 The attributes of a @code{Naming} package specifies the naming conventions
15572 that apply to the source files in a project. When invoking other GNAT tools,
15573 they will use the sources in the source directories that satisfy these
15574 naming conventions.
15576 The following attributes apply to a @code{Naming} package:
15580 This is a simple attribute whose value is a string. Legal values of this
15581 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
15582 These strings are themselves case insensitive.
15585 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
15587 @item Dot_Replacement
15588 This is a simple attribute whose string value satisfies the following
15592 @item It must not be empty
15593 @item It cannot start or end with an alphanumeric character
15594 @item It cannot be a single underscore
15595 @item It cannot start with an underscore followed by an alphanumeric
15596 @item It cannot contain a dot @code{'.'} if longer than one character
15600 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
15603 This is an associative array attribute, defined on language names,
15604 whose image is a string that must satisfy the following
15608 @item It must not be empty
15609 @item It cannot start with an alphanumeric character
15610 @item It cannot start with an underscore followed by an alphanumeric character
15614 For Ada, the attribute denotes the suffix used in file names that contain
15615 library unit declarations, that is to say units that are package and
15616 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
15617 specified, then the default is @code{".ads"}.
15619 For C and C++, the attribute denotes the suffix used in file names that
15620 contain prototypes.
15623 This is an associative array attribute defined on language names,
15624 whose image is a string that must satisfy the following
15628 @item It must not be empty
15629 @item It cannot start with an alphanumeric character
15630 @item It cannot start with an underscore followed by an alphanumeric character
15631 @item It cannot be a suffix of @code{Spec_Suffix}
15635 For Ada, the attribute denotes the suffix used in file names that contain
15636 library bodies, that is to say units that are package and subprogram bodies.
15637 If @code{Body_Suffix ("Ada")} is not specified, then the default is
15640 For C and C++, the attribute denotes the suffix used in file names that contain
15643 @item Separate_Suffix
15644 This is a simple attribute whose value satisfies the same conditions as
15645 @code{Body_Suffix}.
15647 This attribute is specific to Ada. It denotes the suffix used in file names
15648 that contain separate bodies. If it is not specified, then it defaults to same
15649 value as @code{Body_Suffix ("Ada")}.
15652 This is an associative array attribute, specific to Ada, defined over
15653 compilation unit names. The image is a string that is the name of the file
15654 that contains that library unit. The file name is case sensitive if the
15655 conventions of the host operating system require it.
15658 This is an associative array attribute, specific to Ada, defined over
15659 compilation unit names. The image is a string that is the name of the file
15660 that contains the library unit body for the named unit. The file name is case
15661 sensitive if the conventions of the host operating system require it.
15663 @item Specification_Exceptions
15664 This is an associative array attribute defined on language names,
15665 whose value is a list of strings.
15667 This attribute is not significant for Ada.
15669 For C and C++, each string in the list denotes the name of a file that
15670 contains prototypes, but whose suffix is not necessarily the
15671 @code{Spec_Suffix} for the language.
15673 @item Implementation_Exceptions
15674 This is an associative array attribute defined on language names,
15675 whose value is a list of strings.
15677 This attribute is not significant for Ada.
15679 For C and C++, each string in the list denotes the name of a file that
15680 contains source code, but whose suffix is not necessarily the
15681 @code{Body_Suffix} for the language.
15684 The following attributes of package @code{Naming} are obsolescent. They are
15685 kept as synonyms of other attributes for compatibility with previous versions
15686 of the Project Manager.
15689 @item Specification_Suffix
15690 This is a synonym of @code{Spec_Suffix}.
15692 @item Implementation_Suffix
15693 This is a synonym of @code{Body_Suffix}.
15695 @item Specification
15696 This is a synonym of @code{Spec}.
15698 @item Implementation
15699 This is a synonym of @code{Body}.
15702 @subsection package Compiler
15705 The attributes of the @code{Compiler} package specify the compilation options
15706 to be used by the underlying compiler.
15709 @item Default_Switches
15710 This is an associative array attribute. Its
15711 domain is a set of language names. Its range is a string list that
15712 specifies the compilation options to be used when compiling a component
15713 written in that language, for which no file-specific switches have been
15717 This is an associative array attribute. Its domain is
15718 a set of file names. Its range is a string list that specifies the
15719 compilation options to be used when compiling the named file. If a file
15720 is not specified in the Switches attribute, it is compiled with the
15721 options specified by Default_Switches of its language, if defined.
15723 @item Local_Configuration_Pragmas.
15724 This is a simple attribute, whose
15725 value is a path name that designates a file containing configuration pragmas
15726 to be used for all invocations of the compiler for immediate sources of the
15730 @subsection package Builder
15733 The attributes of package @code{Builder} specify the compilation, binding, and
15734 linking options to be used when building an executable for a project. The
15735 following attributes apply to package @code{Builder}:
15738 @item Default_Switches
15739 This is an associative array attribute. Its
15740 domain is a set of language names. Its range is a string list that
15741 specifies options to be used when building a main
15742 written in that language, for which no file-specific switches have been
15746 This is an associative array attribute. Its domain is
15747 a set of file names. Its range is a string list that specifies
15748 options to be used when building the named main file. If a main file
15749 is not specified in the Switches attribute, it is built with the
15750 options specified by Default_Switches of its language, if defined.
15752 @item Global_Configuration_Pragmas
15753 This is a simple attribute, whose
15754 value is a path name that designates a file that contains configuration pragmas
15755 to be used in every build of an executable. If both local and global
15756 configuration pragmas are specified, a compilation makes use of both sets.
15760 This is an associative array attribute. Its domain is
15761 a set of main source file names. Its range is a simple string that specifies
15762 the executable file name to be used when linking the specified main source.
15763 If a main source is not specified in the Executable attribute, the executable
15764 file name is deducted from the main source file name.
15765 This attribute has no effect if its value is the empty string.
15767 @item Executable_Suffix
15768 This is a simple attribute whose value is the suffix to be added to
15769 the executables that don't have an attribute Executable specified.
15772 @subsection package Gnatls
15775 The attributes of package @code{Gnatls} specify the tool options to be used
15776 when invoking the library browser @command{gnatls}.
15777 The following attributes apply to package @code{Gnatls}:
15781 This is a single attribute with a string list value. Each non empty string
15782 in the list is an option when invoking @code{gnatls}.
15785 @subsection package Binder
15788 The attributes of package @code{Binder} specify the options to be used
15789 when invoking the binder in the construction of an executable.
15790 The following attributes apply to package @code{Binder}:
15793 @item Default_Switches
15794 This is an associative array attribute. Its
15795 domain is a set of language names. Its range is a string list that
15796 specifies options to be used when binding a main
15797 written in that language, for which no file-specific switches have been
15801 This is an associative array attribute. Its domain is
15802 a set of file names. Its range is a string list that specifies
15803 options to be used when binding the named main file. If a main file
15804 is not specified in the Switches attribute, it is bound with the
15805 options specified by Default_Switches of its language, if defined.
15808 @subsection package Linker
15811 The attributes of package @code{Linker} specify the options to be used when
15812 invoking the linker in the construction of an executable.
15813 The following attributes apply to package @code{Linker}:
15816 @item Default_Switches
15817 This is an associative array attribute. Its
15818 domain is a set of language names. Its range is a string list that
15819 specifies options to be used when linking a main
15820 written in that language, for which no file-specific switches have been
15824 This is an associative array attribute. Its domain is
15825 a set of file names. Its range is a string list that specifies
15826 options to be used when linking the named main file. If a main file
15827 is not specified in the Switches attribute, it is linked with the
15828 options specified by Default_Switches of its language, if defined.
15830 @item Linker_Options
15831 This is a string list attribute. Its value specifies additional options that
15832 be given to the linker when linking an executable. This attribute is not
15833 used in the main project, only in projects imported directly or indirectly.
15837 @subsection package Cross_Reference
15840 The attributes of package @code{Cross_Reference} specify the tool options
15842 when invoking the library tool @command{gnatxref}.
15843 The following attributes apply to package @code{Cross_Reference}:
15846 @item Default_Switches
15847 This is an associative array attribute. Its
15848 domain is a set of language names. Its range is a string list that
15849 specifies options to be used when calling @command{gnatxref} on a source
15850 written in that language, for which no file-specific switches have been
15854 This is an associative array attribute. Its domain is
15855 a set of file names. Its range is a string list that specifies
15856 options to be used when calling @command{gnatxref} on the named main source.
15857 If a source is not specified in the Switches attribute, @command{gnatxref} will
15858 be called with the options specified by Default_Switches of its language,
15862 @subsection package Finder
15865 The attributes of package @code{Finder} specify the tool options to be used
15866 when invoking the search tool @command{gnatfind}.
15867 The following attributes apply to package @code{Finder}:
15870 @item Default_Switches
15871 This is an associative array attribute. Its
15872 domain is a set of language names. Its range is a string list that
15873 specifies options to be used when calling @command{gnatfind} on a source
15874 written in that language, for which no file-specific switches have been
15878 This is an associative array attribute. Its domain is
15879 a set of file names. Its range is a string list that specifies
15880 options to be used when calling @command{gnatfind} on the named main source.
15881 If a source is not specified in the Switches attribute, @command{gnatfind} will
15882 be called with the options specified by Default_Switches of its language,
15886 @subsection package Pretty_Printer
15889 The attributes of package @code{Pretty_Printer}
15890 specify the tool options to be used
15891 when invoking the formatting tool @command{gnatpp}.
15892 The following attributes apply to package @code{Pretty_Printer}:
15895 @item Default_switches
15896 This is an associative array attribute. Its
15897 domain is a set of language names. Its range is a string list that
15898 specifies options to be used when calling @command{gnatpp} on a source
15899 written in that language, for which no file-specific switches have been
15903 This is an associative array attribute. Its domain is
15904 a set of file names. Its range is a string list that specifies
15905 options to be used when calling @command{gnatpp} on the named main source.
15906 If a source is not specified in the Switches attribute, @command{gnatpp} will
15907 be called with the options specified by Default_Switches of its language,
15911 @subsection package gnatstub
15914 The attributes of package @code{gnatstub}
15915 specify the tool options to be used
15916 when invoking the tool @command{gnatstub}.
15917 The following attributes apply to package @code{gnatstub}:
15920 @item Default_switches
15921 This is an associative array attribute. Its
15922 domain is a set of language names. Its range is a string list that
15923 specifies options to be used when calling @command{gnatstub} on a source
15924 written in that language, for which no file-specific switches have been
15928 This is an associative array attribute. Its domain is
15929 a set of file names. Its range is a string list that specifies
15930 options to be used when calling @command{gnatstub} on the named main source.
15931 If a source is not specified in the Switches attribute, @command{gnatpp} will
15932 be called with the options specified by Default_Switches of its language,
15936 @subsection package Eliminate
15939 The attributes of package @code{Eliminate}
15940 specify the tool options to be used
15941 when invoking the tool @command{gnatelim}.
15942 The following attributes apply to package @code{Eliminate}:
15945 @item Default_switches
15946 This is an associative array attribute. Its
15947 domain is a set of language names. Its range is a string list that
15948 specifies options to be used when calling @command{gnatelim} on a source
15949 written in that language, for which no file-specific switches have been
15953 This is an associative array attribute. Its domain is
15954 a set of file names. Its range is a string list that specifies
15955 options to be used when calling @command{gnatelim} on the named main source.
15956 If a source is not specified in the Switches attribute, @command{gnatelim} will
15957 be called with the options specified by Default_Switches of its language,
15961 @subsection package Metrics
15964 The attributes of package @code{Metrics}
15965 specify the tool options to be used
15966 when invoking the tool @command{gnatmetric}.
15967 The following attributes apply to package @code{Metrics}:
15970 @item Default_switches
15971 This is an associative array attribute. Its
15972 domain is a set of language names. Its range is a string list that
15973 specifies options to be used when calling @command{gnatmetric} on a source
15974 written in that language, for which no file-specific switches have been
15978 This is an associative array attribute. Its domain is
15979 a set of file names. Its range is a string list that specifies
15980 options to be used when calling @command{gnatmetric} on the named main source.
15981 If a source is not specified in the Switches attribute, @command{gnatmetric}
15982 will be called with the options specified by Default_Switches of its language,
15986 @subsection package IDE
15989 The attributes of package @code{IDE} specify the options to be used when using
15990 an Integrated Development Environment such as @command{GPS}.
15994 This is a simple attribute. Its value is a string that designates the remote
15995 host in a cross-compilation environment, to be used for remote compilation and
15996 debugging. This field should not be specified when running on the local
16000 This is a simple attribute. Its value is a string that specifies the
16001 name of IP address of the embedded target in a cross-compilation environment,
16002 on which the program should execute.
16004 @item Communication_Protocol
16005 This is a simple string attribute. Its value is the name of the protocol
16006 to use to communicate with the target in a cross-compilation environment,
16007 e.g. @code{"wtx"} or @code{"vxworks"}.
16009 @item Compiler_Command
16010 This is an associative array attribute, whose domain is a language name. Its
16011 value is string that denotes the command to be used to invoke the compiler.
16012 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16013 gnatmake, in particular in the handling of switches.
16015 @item Debugger_Command
16016 This is simple attribute, Its value is a string that specifies the name of
16017 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16019 @item Default_Switches
16020 This is an associative array attribute. Its indexes are the name of the
16021 external tools that the GNAT Programming System (GPS) is supporting. Its
16022 value is a list of switches to use when invoking that tool.
16025 This is a simple attribute. Its value is a string that specifies the name
16026 of the @command{gnatls} utility to be used to retrieve information about the
16027 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16030 This is a simple attribute. Its value is a string used to specify the
16031 Version Control System (VCS) to be used for this project, e.g CVS, RCS
16032 ClearCase or Perforce.
16034 @item VCS_File_Check
16035 This is a simple attribute. Its value is a string that specifies the
16036 command used by the VCS to check the validity of a file, either
16037 when the user explicitly asks for a check, or as a sanity check before
16038 doing the check-in.
16040 @item VCS_Log_Check
16041 This is a simple attribute. Its value is a string that specifies
16042 the command used by the VCS to check the validity of a log file.
16044 @item VCS_Repository_Root
16045 The VCS repository root path. This is used to create tags or branches
16046 of the repository. For subversion the value should be the @code{URL}
16047 as specified to check-out the working copy of the repository.
16049 @item VCS_Patch_Root
16050 The local root directory to use for building patch file. All patch chunks
16051 will be relative to this path. The root project directory is used if
16052 this value is not defined.
16056 @node Package Renamings
16057 @section Package Renamings
16060 A package can be defined by a renaming declaration. The new package renames
16061 a package declared in a different project file, and has the same attributes
16062 as the package it renames.
16065 package_renaming ::==
16066 @b{package} package_identifier @b{renames}
16067 <project_>simple_name.package_identifier ;
16071 The package_identifier of the renamed package must be the same as the
16072 package_identifier. The project whose name is the prefix of the renamed
16073 package must contain a package declaration with this name. This project
16074 must appear in the context_clause of the enclosing project declaration,
16075 or be the parent project of the enclosing child project.
16081 A project file specifies a set of rules for constructing a software system.
16082 A project file can be self-contained, or depend on other project files.
16083 Dependencies are expressed through a context clause that names other projects.
16089 context_clause project_declaration
16091 project_declaration ::=
16092 simple_project_declaration | project_extension
16094 simple_project_declaration ::=
16095 @b{project} <project_>simple_name @b{is}
16096 @{declarative_item@}
16097 @b{end} <project_>simple_name;
16103 [@b{limited}] @b{with} path_name @{ , path_name @} ;
16110 A path name denotes a project file. A path name can be absolute or relative.
16111 An absolute path name includes a sequence of directories, in the syntax of
16112 the host operating system, that identifies uniquely the project file in the
16113 file system. A relative path name identifies the project file, relative
16114 to the directory that contains the current project, or relative to a
16115 directory listed in the environment variable ADA_PROJECT_PATH.
16116 Path names are case sensitive if file names in the host operating system
16117 are case sensitive.
16119 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16120 directory names separated by colons (semicolons on Windows).
16122 A given project name can appear only once in a context_clause.
16124 It is illegal for a project imported by a context clause to refer, directly
16125 or indirectly, to the project in which this context clause appears (the
16126 dependency graph cannot contain cycles), except when one of the with_clause
16127 in the cycle is a @code{limited with}.
16129 @node Project Extensions
16130 @section Project Extensions
16133 A project extension introduces a new project, which inherits the declarations
16134 of another project.
16138 project_extension ::=
16139 @b{project} <project_>simple_name @b{extends} path_name @b{is}
16140 @{declarative_item@}
16141 @b{end} <project_>simple_name;
16145 The project extension declares a child project. The child project inherits
16146 all the declarations and all the files of the parent project, These inherited
16147 declaration can be overridden in the child project, by means of suitable
16150 @node Project File Elaboration
16151 @section Project File Elaboration
16154 A project file is processed as part of the invocation of a gnat tool that
16155 uses the project option. Elaboration of the process file consists in the
16156 sequential elaboration of all its declarations. The computed values of
16157 attributes and variables in the project are then used to establish the
16158 environment in which the gnat tool will execute.
16160 @node Obsolescent Features
16161 @chapter Obsolescent Features
16164 This chapter describes features that are provided by GNAT, but are
16165 considered obsolescent since there are preferred ways of achieving
16166 the same effect. These features are provided solely for historical
16167 compatibility purposes.
16170 * pragma No_Run_Time::
16171 * pragma Ravenscar::
16172 * pragma Restricted_Run_Time::
16175 @node pragma No_Run_Time
16176 @section pragma No_Run_Time
16178 The pragma @code{No_Run_Time} is used to achieve an affect similar
16179 to the use of the "Zero Foot Print" configurable run time, but without
16180 requiring a specially configured run time. The result of using this
16181 pragma, which must be used for all units in a partition, is to restrict
16182 the use of any language features requiring run-time support code. The
16183 preferred usage is to use an appropriately configured run-time that
16184 includes just those features that are to be made accessible.
16186 @node pragma Ravenscar
16187 @section pragma Ravenscar
16189 The pragma @code{Ravenscar} has exactly the same effect as pragma
16190 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16191 is part of the new Ada 2005 standard.
16193 @node pragma Restricted_Run_Time
16194 @section pragma Restricted_Run_Time
16196 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16197 pragma @code{Profile (Restricted)}. The latter usage is
16198 preferred since the Ada 2005 pragma @code{Profile} is intended for
16199 this kind of implementation dependent addition.
16202 @c GNU Free Documentation License
16204 @node Index,,GNU Free Documentation License, Top