1 \input texinfo @c -*-texinfo-*-
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
7 @c GNAT DOCUMENTATION o
11 @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
15 @setfilename gnat_rm.info
18 Copyright @copyright{} 1995-2008, Free Software Foundation, Inc.
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.2 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24 Manual'', and with no Back-Cover Texts. A copy of the license is
25 included in the section entitled ``GNU Free Documentation License''.
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
32 @settitle GNAT Reference Manual
34 @setchapternewpage odd
37 @include gcc-common.texi
39 @dircategory GNU Ada tools
41 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
50 @vskip 0pt plus 1filll
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
72 * Implementation Defined Pragmas::
73 * Implementation Defined Attributes::
74 * Implementation Advice::
75 * Implementation Defined Characteristics::
76 * Intrinsic Subprograms::
77 * Representation Clauses and Pragmas::
78 * Standard Library Routines::
79 * The Implementation of Standard I/O::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Project File Reference::
85 * Obsolescent Features::
86 * GNU Free Documentation License::
89 --- The Detailed Node Listing ---
93 * What This Reference Manual Contains::
94 * Related Information::
96 Implementation Defined Pragmas
98 * Pragma Abort_Defer::
105 * Pragma Assume_No_Invalid_Values::
107 * Pragma C_Pass_By_Copy::
109 * Pragma Check_Name::
110 * Pragma Check_Policy::
112 * Pragma Common_Object::
113 * Pragma Compile_Time_Error::
114 * Pragma Compile_Time_Warning::
115 * Pragma Complete_Representation::
116 * Pragma Complex_Representation::
117 * Pragma Component_Alignment::
118 * Pragma Convention_Identifier::
120 * Pragma CPP_Constructor::
121 * Pragma CPP_Virtual::
122 * Pragma CPP_Vtable::
124 * Pragma Debug_Policy::
125 * Pragma Detect_Blocking::
126 * Pragma Elaboration_Checks::
128 * Pragma Export_Exception::
129 * Pragma Export_Function::
130 * Pragma Export_Object::
131 * Pragma Export_Procedure::
132 * Pragma Export_Value::
133 * Pragma Export_Valued_Procedure::
134 * Pragma Extend_System::
136 * Pragma External_Name_Casing::
138 * Pragma Favor_Top_Level::
139 * Pragma Finalize_Storage_Only::
140 * Pragma Float_Representation::
142 * Pragma Implemented_By_Entry::
143 * Pragma Implicit_Packing::
144 * Pragma Import_Exception::
145 * Pragma Import_Function::
146 * Pragma Import_Object::
147 * Pragma Import_Procedure::
148 * Pragma Import_Valued_Procedure::
149 * Pragma Initialize_Scalars::
150 * Pragma Inline_Always::
151 * Pragma Inline_Generic::
153 * Pragma Interface_Name::
154 * Pragma Interrupt_Handler::
155 * Pragma Interrupt_State::
156 * Pragma Keep_Names::
159 * Pragma Linker_Alias::
160 * Pragma Linker_Constructor::
161 * Pragma Linker_Destructor::
162 * Pragma Linker_Section::
163 * Pragma Long_Float::
164 * Pragma Machine_Attribute::
166 * Pragma Main_Storage::
169 * Pragma No_Strict_Aliasing ::
170 * Pragma Normalize_Scalars::
171 * Pragma Obsolescent::
172 * Pragma Optimize_Alignment::
174 * Pragma Persistent_BSS::
176 * Pragma Postcondition::
177 * Pragma Precondition::
178 * Pragma Profile (Ravenscar)::
179 * Pragma Profile (Restricted)::
180 * Pragma Psect_Object::
181 * Pragma Pure_Function::
182 * Pragma Restriction_Warnings::
184 * Pragma Source_File_Name::
185 * Pragma Source_File_Name_Project::
186 * Pragma Source_Reference::
187 * Pragma Stream_Convert::
188 * Pragma Style_Checks::
191 * Pragma Suppress_All::
192 * Pragma Suppress_Exception_Locations::
193 * Pragma Suppress_Initialization::
196 * Pragma Task_Storage::
197 * Pragma Thread_Local_Storage::
198 * Pragma Time_Slice::
200 * Pragma Unchecked_Union::
201 * Pragma Unimplemented_Unit::
202 * Pragma Universal_Aliasing ::
203 * Pragma Universal_Data::
204 * Pragma Unmodified::
205 * Pragma Unreferenced::
206 * Pragma Unreferenced_Objects::
207 * Pragma Unreserve_All_Interrupts::
208 * Pragma Unsuppress::
209 * Pragma Use_VADS_Size::
210 * Pragma Validity_Checks::
213 * Pragma Weak_External::
214 * Pragma Wide_Character_Encoding::
216 Implementation Defined Attributes
227 * Default_Bit_Order::
237 * Has_Access_Values::
238 * Has_Discriminants::
245 * Max_Interrupt_Priority::
247 * Maximum_Alignment::
252 * Passed_By_Reference::
265 * Unconstrained_Array::
266 * Universal_Literal_String::
267 * Unrestricted_Access::
273 The Implementation of Standard I/O
275 * Standard I/O Packages::
281 * Wide_Wide_Text_IO::
285 * Filenames encoding::
287 * Operations on C Streams::
288 * Interfacing to C Streams::
292 * Ada.Characters.Latin_9 (a-chlat9.ads)::
293 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
294 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
295 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
296 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
297 * Ada.Command_Line.Environment (a-colien.ads)::
298 * Ada.Command_Line.Remove (a-colire.ads)::
299 * Ada.Command_Line.Response_File (a-clrefi.ads)::
300 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
301 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
302 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
303 * Ada.Exceptions.Traceback (a-exctra.ads)::
304 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
305 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
306 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
307 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
308 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
309 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
310 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
311 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
312 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
313 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
314 * GNAT.Altivec (g-altive.ads)::
315 * GNAT.Altivec.Conversions (g-altcon.ads)::
316 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
317 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
318 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
319 * GNAT.Array_Split (g-arrspl.ads)::
320 * GNAT.AWK (g-awk.ads)::
321 * GNAT.Bounded_Buffers (g-boubuf.ads)::
322 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
323 * GNAT.Bubble_Sort (g-bubsor.ads)::
324 * GNAT.Bubble_Sort_A (g-busora.ads)::
325 * GNAT.Bubble_Sort_G (g-busorg.ads)::
326 * GNAT.Byte_Order_Mark (g-byorma.ads)::
327 * GNAT.Byte_Swapping (g-bytswa.ads)::
328 * GNAT.Calendar (g-calend.ads)::
329 * GNAT.Calendar.Time_IO (g-catiio.ads)::
330 * GNAT.Case_Util (g-casuti.ads)::
331 * GNAT.CGI (g-cgi.ads)::
332 * GNAT.CGI.Cookie (g-cgicoo.ads)::
333 * GNAT.CGI.Debug (g-cgideb.ads)::
334 * GNAT.Command_Line (g-comlin.ads)::
335 * GNAT.Compiler_Version (g-comver.ads)::
336 * GNAT.Ctrl_C (g-ctrl_c.ads)::
337 * GNAT.CRC32 (g-crc32.ads)::
338 * GNAT.Current_Exception (g-curexc.ads)::
339 * GNAT.Debug_Pools (g-debpoo.ads)::
340 * GNAT.Debug_Utilities (g-debuti.ads)::
341 * GNAT.Decode_String (g-decstr.ads)::
342 * GNAT.Decode_UTF8_String (g-deutst.ads)::
343 * GNAT.Directory_Operations (g-dirope.ads)::
344 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
345 * GNAT.Dynamic_HTables (g-dynhta.ads)::
346 * GNAT.Dynamic_Tables (g-dyntab.ads)::
347 * GNAT.Encode_String (g-encstr.ads)::
348 * GNAT.Encode_UTF8_String (g-enutst.ads)::
349 * GNAT.Exception_Actions (g-excact.ads)::
350 * GNAT.Exception_Traces (g-exctra.ads)::
351 * GNAT.Exceptions (g-except.ads)::
352 * GNAT.Expect (g-expect.ads)::
353 * GNAT.Float_Control (g-flocon.ads)::
354 * GNAT.Heap_Sort (g-heasor.ads)::
355 * GNAT.Heap_Sort_A (g-hesora.ads)::
356 * GNAT.Heap_Sort_G (g-hesorg.ads)::
357 * GNAT.HTable (g-htable.ads)::
358 * GNAT.IO (g-io.ads)::
359 * GNAT.IO_Aux (g-io_aux.ads)::
360 * GNAT.Lock_Files (g-locfil.ads)::
361 * GNAT.MD5 (g-md5.ads)::
362 * GNAT.Memory_Dump (g-memdum.ads)::
363 * GNAT.Most_Recent_Exception (g-moreex.ads)::
364 * GNAT.OS_Lib (g-os_lib.ads)::
365 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
366 * GNAT.Random_Numbers (g-rannum.ads)::
367 * GNAT.Regexp (g-regexp.ads)::
368 * GNAT.Registry (g-regist.ads)::
369 * GNAT.Regpat (g-regpat.ads)::
370 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
371 * GNAT.Semaphores (g-semaph.ads)::
372 * GNAT.Serial_Communications (g-sercom.ads)::
373 * GNAT.SHA1 (g-sha1.ads)::
374 * GNAT.Signals (g-signal.ads)::
375 * GNAT.Sockets (g-socket.ads)::
376 * GNAT.Source_Info (g-souinf.ads)::
377 * GNAT.Spelling_Checker (g-speche.ads)::
378 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
379 * GNAT.Spitbol.Patterns (g-spipat.ads)::
380 * GNAT.Spitbol (g-spitbo.ads)::
381 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
382 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
383 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
384 * GNAT.SSE (g-sse.ads)::
385 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
386 * GNAT.Strings (g-string.ads)::
387 * GNAT.String_Split (g-strspl.ads)::
388 * GNAT.Table (g-table.ads)::
389 * GNAT.Task_Lock (g-tasloc.ads)::
390 * GNAT.Threads (g-thread.ads)::
391 * GNAT.Time_Stamp (g-timsta.ads)::
392 * GNAT.Traceback (g-traceb.ads)::
393 * GNAT.Traceback.Symbolic (g-trasym.ads)::
394 * GNAT.UTF_32 (g-utf_32.ads)::
395 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
396 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
397 * GNAT.Wide_String_Split (g-wistsp.ads)::
398 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
399 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
400 * Interfaces.C.Extensions (i-cexten.ads)::
401 * Interfaces.C.Streams (i-cstrea.ads)::
402 * Interfaces.CPP (i-cpp.ads)::
403 * Interfaces.Packed_Decimal (i-pacdec.ads)::
404 * Interfaces.VxWorks (i-vxwork.ads)::
405 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
406 * System.Address_Image (s-addima.ads)::
407 * System.Assertions (s-assert.ads)::
408 * System.Memory (s-memory.ads)::
409 * System.Partition_Interface (s-parint.ads)::
410 * System.Pool_Global (s-pooglo.ads)::
411 * System.Pool_Local (s-pooloc.ads)::
412 * System.Restrictions (s-restri.ads)::
413 * System.Rident (s-rident.ads)::
414 * System.Strings.Stream_Ops (s-ststop.ads)::
415 * System.Task_Info (s-tasinf.ads)::
416 * System.Wch_Cnv (s-wchcnv.ads)::
417 * System.Wch_Con (s-wchcon.ads)::
421 * Text_IO Stream Pointer Positioning::
422 * Text_IO Reading and Writing Non-Regular Files::
424 * Treating Text_IO Files as Streams::
425 * Text_IO Extensions::
426 * Text_IO Facilities for Unbounded Strings::
430 * Wide_Text_IO Stream Pointer Positioning::
431 * Wide_Text_IO Reading and Writing Non-Regular Files::
435 * Wide_Wide_Text_IO Stream Pointer Positioning::
436 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
438 Interfacing to Other Languages
441 * Interfacing to C++::
442 * Interfacing to COBOL::
443 * Interfacing to Fortran::
444 * Interfacing to non-GNAT Ada code::
446 Specialized Needs Annexes
448 Implementation of Specific Ada Features
449 * Machine Code Insertions::
450 * GNAT Implementation of Tasking::
451 * GNAT Implementation of Shared Passive Packages::
452 * Code Generation for Array Aggregates::
453 * The Size of Discriminated Records with Default Discriminants::
454 * Strict Conformance to the Ada Reference Manual::
456 Project File Reference
460 GNU Free Documentation License
467 @node About This Guide
468 @unnumbered About This Guide
471 This manual contains useful information in writing programs using the
472 @value{EDITION} compiler. It includes information on implementation dependent
473 characteristics of @value{EDITION}, including all the information required by
474 Annex M of the Ada language standard.
476 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
477 Ada 83 compatibility mode.
478 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
479 but you can override with a compiler switch
480 to explicitly specify the language version.
481 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
482 @value{EDITION} User's Guide}, for details on these switches.)
483 Throughout this manual, references to ``Ada'' without a year suffix
484 apply to both the Ada 95 and Ada 2005 versions of the language.
486 Ada is designed to be highly portable.
487 In general, a program will have the same effect even when compiled by
488 different compilers on different platforms.
489 However, since Ada is designed to be used in a
490 wide variety of applications, it also contains a number of system
491 dependent features to be used in interfacing to the external world.
492 @cindex Implementation-dependent features
495 Note: Any program that makes use of implementation-dependent features
496 may be non-portable. You should follow good programming practice and
497 isolate and clearly document any sections of your program that make use
498 of these features in a non-portable manner.
501 For ease of exposition, ``GNAT Pro'' will be referred to simply as
502 ``GNAT'' in the remainder of this document.
506 * What This Reference Manual Contains::
508 * Related Information::
511 @node What This Reference Manual Contains
512 @unnumberedsec What This Reference Manual Contains
515 This reference manual contains the following chapters:
519 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
520 pragmas, which can be used to extend and enhance the functionality of the
524 @ref{Implementation Defined Attributes}, lists GNAT
525 implementation-dependent attributes which can be used to extend and
526 enhance the functionality of the compiler.
529 @ref{Implementation Advice}, provides information on generally
530 desirable behavior which are not requirements that all compilers must
531 follow since it cannot be provided on all systems, or which may be
532 undesirable on some systems.
535 @ref{Implementation Defined Characteristics}, provides a guide to
536 minimizing implementation dependent features.
539 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
540 implemented by GNAT, and how they can be imported into user
541 application programs.
544 @ref{Representation Clauses and Pragmas}, describes in detail the
545 way that GNAT represents data, and in particular the exact set
546 of representation clauses and pragmas that is accepted.
549 @ref{Standard Library Routines}, provides a listing of packages and a
550 brief description of the functionality that is provided by Ada's
551 extensive set of standard library routines as implemented by GNAT@.
554 @ref{The Implementation of Standard I/O}, details how the GNAT
555 implementation of the input-output facilities.
558 @ref{The GNAT Library}, is a catalog of packages that complement
559 the Ada predefined library.
562 @ref{Interfacing to Other Languages}, describes how programs
563 written in Ada using GNAT can be interfaced to other programming
566 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
567 of the specialized needs annexes.
570 @ref{Implementation of Specific Ada Features}, discusses issues related
571 to GNAT's implementation of machine code insertions, tasking, and several
575 @ref{Project File Reference}, presents the syntax and semantics
579 @ref{Obsolescent Features} documents implementation dependent features,
580 including pragmas and attributes, which are considered obsolescent, since
581 there are other preferred ways of achieving the same results. These
582 obsolescent forms are retained for backwards compatibility.
586 @cindex Ada 95 Language Reference Manual
587 @cindex Ada 2005 Language Reference Manual
589 This reference manual assumes a basic familiarity with the Ada 95 language, as
590 described in the International Standard ANSI/ISO/IEC-8652:1995,
592 It does not require knowledge of the new features introduced by Ada 2005,
593 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
595 Both reference manuals are included in the GNAT documentation
599 @unnumberedsec Conventions
600 @cindex Conventions, typographical
601 @cindex Typographical conventions
604 Following are examples of the typographical and graphic conventions used
609 @code{Functions}, @code{utility program names}, @code{standard names},
616 @file{File names}, @samp{button names}, and @samp{field names}.
619 @code{Variables}, @env{environment variables}, and @var{metasyntactic
626 [optional information or parameters]
629 Examples are described by text
631 and then shown this way.
636 Commands that are entered by the user are preceded in this manual by the
637 characters @samp{$ } (dollar sign followed by space). If your system uses this
638 sequence as a prompt, then the commands will appear exactly as you see them
639 in the manual. If your system uses some other prompt, then the command will
640 appear with the @samp{$} replaced by whatever prompt character you are using.
642 @node Related Information
643 @unnumberedsec Related Information
645 See the following documents for further information on GNAT:
649 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
650 @value{EDITION} User's Guide}, which provides information on how to use the
651 GNAT compiler system.
654 @cite{Ada 95 Reference Manual}, which contains all reference
655 material for the Ada 95 programming language.
658 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
659 of the Ada 95 standard. The annotations describe
660 detailed aspects of the design decision, and in particular contain useful
661 sections on Ada 83 compatibility.
664 @cite{Ada 2005 Reference Manual}, which contains all reference
665 material for the Ada 2005 programming language.
668 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
669 of the Ada 2005 standard. The annotations describe
670 detailed aspects of the design decision, and in particular contain useful
671 sections on Ada 83 and Ada 95 compatibility.
674 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
675 which contains specific information on compatibility between GNAT and
679 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
680 describes in detail the pragmas and attributes provided by the DEC Ada 83
685 @node Implementation Defined Pragmas
686 @chapter Implementation Defined Pragmas
689 Ada defines a set of pragmas that can be used to supply additional
690 information to the compiler. These language defined pragmas are
691 implemented in GNAT and work as described in the Ada Reference Manual.
693 In addition, Ada allows implementations to define additional pragmas
694 whose meaning is defined by the implementation. GNAT provides a number
695 of these implementation-defined pragmas, which can be used to extend
696 and enhance the functionality of the compiler. This section of the GNAT
697 Reference Manual describes these additional pragmas.
699 Note that any program using these pragmas might not be portable to other
700 compilers (although GNAT implements this set of pragmas on all
701 platforms). Therefore if portability to other compilers is an important
702 consideration, the use of these pragmas should be minimized.
705 * Pragma Abort_Defer::
712 * Pragma Assume_No_Invalid_Values::
714 * Pragma C_Pass_By_Copy::
716 * Pragma Check_Name::
717 * Pragma Check_Policy::
719 * Pragma Common_Object::
720 * Pragma Compile_Time_Error::
721 * Pragma Compile_Time_Warning::
722 * Pragma Complete_Representation::
723 * Pragma Complex_Representation::
724 * Pragma Component_Alignment::
725 * Pragma Convention_Identifier::
727 * Pragma CPP_Constructor::
728 * Pragma CPP_Virtual::
729 * Pragma CPP_Vtable::
731 * Pragma Debug_Policy::
732 * Pragma Detect_Blocking::
733 * Pragma Elaboration_Checks::
735 * Pragma Export_Exception::
736 * Pragma Export_Function::
737 * Pragma Export_Object::
738 * Pragma Export_Procedure::
739 * Pragma Export_Value::
740 * Pragma Export_Valued_Procedure::
741 * Pragma Extend_System::
743 * Pragma External_Name_Casing::
745 * Pragma Favor_Top_Level::
746 * Pragma Finalize_Storage_Only::
747 * Pragma Float_Representation::
749 * Pragma Implemented_By_Entry::
750 * Pragma Implicit_Packing::
751 * Pragma Import_Exception::
752 * Pragma Import_Function::
753 * Pragma Import_Object::
754 * Pragma Import_Procedure::
755 * Pragma Import_Valued_Procedure::
756 * Pragma Initialize_Scalars::
757 * Pragma Inline_Always::
758 * Pragma Inline_Generic::
760 * Pragma Interface_Name::
761 * Pragma Interrupt_Handler::
762 * Pragma Interrupt_State::
763 * Pragma Keep_Names::
766 * Pragma Linker_Alias::
767 * Pragma Linker_Constructor::
768 * Pragma Linker_Destructor::
769 * Pragma Linker_Section::
770 * Pragma Long_Float::
771 * Pragma Machine_Attribute::
773 * Pragma Main_Storage::
776 * Pragma No_Strict_Aliasing::
777 * Pragma Normalize_Scalars::
778 * Pragma Obsolescent::
779 * Pragma Optimize_Alignment::
781 * Pragma Persistent_BSS::
783 * Pragma Postcondition::
784 * Pragma Precondition::
785 * Pragma Profile (Ravenscar)::
786 * Pragma Profile (Restricted)::
787 * Pragma Psect_Object::
788 * Pragma Pure_Function::
789 * Pragma Restriction_Warnings::
791 * Pragma Source_File_Name::
792 * Pragma Source_File_Name_Project::
793 * Pragma Source_Reference::
794 * Pragma Stream_Convert::
795 * Pragma Style_Checks::
798 * Pragma Suppress_All::
799 * Pragma Suppress_Exception_Locations::
800 * Pragma Suppress_Initialization::
803 * Pragma Task_Storage::
804 * Pragma Thread_Local_Storage::
805 * Pragma Time_Slice::
807 * Pragma Unchecked_Union::
808 * Pragma Unimplemented_Unit::
809 * Pragma Universal_Aliasing ::
810 * Pragma Universal_Data::
811 * Pragma Unmodified::
812 * Pragma Unreferenced::
813 * Pragma Unreferenced_Objects::
814 * Pragma Unreserve_All_Interrupts::
815 * Pragma Unsuppress::
816 * Pragma Use_VADS_Size::
817 * Pragma Validity_Checks::
820 * Pragma Weak_External::
821 * Pragma Wide_Character_Encoding::
824 @node Pragma Abort_Defer
825 @unnumberedsec Pragma Abort_Defer
827 @cindex Deferring aborts
835 This pragma must appear at the start of the statement sequence of a
836 handled sequence of statements (right after the @code{begin}). It has
837 the effect of deferring aborts for the sequence of statements (but not
838 for the declarations or handlers, if any, associated with this statement
842 @unnumberedsec Pragma Ada_83
851 A configuration pragma that establishes Ada 83 mode for the unit to
852 which it applies, regardless of the mode set by the command line
853 switches. In Ada 83 mode, GNAT attempts to be as compatible with
854 the syntax and semantics of Ada 83, as defined in the original Ada
855 83 Reference Manual as possible. In particular, the keywords added by Ada 95
856 and Ada 2005 are not recognized, optional package bodies are allowed,
857 and generics may name types with unknown discriminants without using
858 the @code{(<>)} notation. In addition, some but not all of the additional
859 restrictions of Ada 83 are enforced.
861 Ada 83 mode is intended for two purposes. Firstly, it allows existing
862 Ada 83 code to be compiled and adapted to GNAT with less effort.
863 Secondly, it aids in keeping code backwards compatible with Ada 83.
864 However, there is no guarantee that code that is processed correctly
865 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
866 83 compiler, since GNAT does not enforce all the additional checks
870 @unnumberedsec Pragma Ada_95
879 A configuration pragma that establishes Ada 95 mode for the unit to which
880 it applies, regardless of the mode set by the command line switches.
881 This mode is set automatically for the @code{Ada} and @code{System}
882 packages and their children, so you need not specify it in these
883 contexts. This pragma is useful when writing a reusable component that
884 itself uses Ada 95 features, but which is intended to be usable from
885 either Ada 83 or Ada 95 programs.
888 @unnumberedsec Pragma Ada_05
897 A configuration pragma that establishes Ada 2005 mode for the unit to which
898 it applies, regardless of the mode set by the command line switches.
899 This mode is set automatically for the @code{Ada} and @code{System}
900 packages and their children, so you need not specify it in these
901 contexts. This pragma is useful when writing a reusable component that
902 itself uses Ada 2005 features, but which is intended to be usable from
903 either Ada 83 or Ada 95 programs.
905 @node Pragma Ada_2005
906 @unnumberedsec Pragma Ada_2005
915 This configuration pragma is a synonym for pragma Ada_05 and has the
916 same syntax and effect.
918 @node Pragma Annotate
919 @unnumberedsec Pragma Annotate
924 pragma Annotate (IDENTIFIER @{, ARG@});
926 ARG ::= NAME | EXPRESSION
930 This pragma is used to annotate programs. @var{identifier} identifies
931 the type of annotation. GNAT verifies that it is an identifier, but does
932 not otherwise analyze it. The @var{arg} argument
933 can be either a string literal or an
934 expression. String literals are assumed to be of type
935 @code{Standard.String}. Names of entities are simply analyzed as entity
936 names. All other expressions are analyzed as expressions, and must be
939 The analyzed pragma is retained in the tree, but not otherwise processed
940 by any part of the GNAT compiler. This pragma is intended for use by
941 external tools, including ASIS@.
944 @unnumberedsec Pragma Assert
951 [, string_EXPRESSION]);
955 The effect of this pragma depends on whether the corresponding command
956 line switch is set to activate assertions. The pragma expands into code
957 equivalent to the following:
960 if assertions-enabled then
961 if not boolean_EXPRESSION then
962 System.Assertions.Raise_Assert_Failure
969 The string argument, if given, is the message that will be associated
970 with the exception occurrence if the exception is raised. If no second
971 argument is given, the default message is @samp{@var{file}:@var{nnn}},
972 where @var{file} is the name of the source file containing the assert,
973 and @var{nnn} is the line number of the assert. A pragma is not a
974 statement, so if a statement sequence contains nothing but a pragma
975 assert, then a null statement is required in addition, as in:
980 pragma Assert (K > 3, "Bad value for K");
986 Note that, as with the @code{if} statement to which it is equivalent, the
987 type of the expression is either @code{Standard.Boolean}, or any type derived
988 from this standard type.
990 If assertions are disabled (switch @option{-gnata} not used), then there
991 is no run-time effect (and in particular, any side effects from the
992 expression will not occur at run time). (The expression is still
993 analyzed at compile time, and may cause types to be frozen if they are
994 mentioned here for the first time).
996 If assertions are enabled, then the given expression is tested, and if
997 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
998 which results in the raising of @code{Assert_Failure} with the given message.
1000 You should generally avoid side effects in the expression arguments of
1001 this pragma, because these side effects will turn on and off with the
1002 setting of the assertions mode, resulting in assertions that have an
1003 effect on the program. However, the expressions are analyzed for
1004 semantic correctness whether or not assertions are enabled, so turning
1005 assertions on and off cannot affect the legality of a program.
1007 @node Pragma Assume_No_Invalid_Values
1008 @unnumberedsec Pragma Assume_No_Invalid_Values
1009 @findex Assume_No_Invalid_Values
1010 @cindex Invalid representations
1011 @cindex Invalid values
1014 @smallexample @c ada
1015 pragma Assume_No_Invalid_Values (On | Off);
1019 This is a configuration pragma that controls the assumptions made by the
1020 compiler about the occurrence of invalid representations (invalid values)
1023 The default behavior (corresponding to an Off argument for this pragma), is
1024 to assume that values may in general be invalid unless the compiler can
1025 prove they are valid. Consider the following example:
1027 @smallexample @c ada
1028 V1 : Integer range 1 .. 10;
1029 V2 : Integer range 11 .. 20;
1031 for J in V2 .. V1 loop
1037 if V1 and V2 have valid values, then the loop is known at compile
1038 time not to execute since the lower bound must be greater than the
1039 upper bound. However in default mode, no such assumption is made,
1040 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1041 is given, the compiler will assume that any occurrence of a variable
1042 other than in an explicit @code{'Valid} test always has a valid
1043 value, and the loop above will be optimized away.
1045 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1046 you know your code is free of uninitialized variables and other
1047 possible sources of invalid representations, and may result in
1048 more efficient code. A program that accesses an invalid representation
1049 with this pragma in effect is erroneous, so no guarantees can be made
1052 It is peculiar though permissible to use this pragma in conjunction
1053 with validity checking (-gnatVa). In such cases, accessing invalid
1054 values will generally give an exception, though formally the program
1055 is erroneous so there are no guarantees that this will always be the
1056 case, and it is recommended that these two options not be used together.
1058 @node Pragma Ast_Entry
1059 @unnumberedsec Pragma Ast_Entry
1064 @smallexample @c ada
1065 pragma AST_Entry (entry_IDENTIFIER);
1069 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1070 argument is the simple name of a single entry; at most one @code{AST_Entry}
1071 pragma is allowed for any given entry. This pragma must be used in
1072 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1073 the entry declaration and in the same task type specification or single task
1074 as the entry to which it applies. This pragma specifies that the given entry
1075 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1076 resulting from an OpenVMS system service call. The pragma does not affect
1077 normal use of the entry. For further details on this pragma, see the
1078 DEC Ada Language Reference Manual, section 9.12a.
1080 @node Pragma C_Pass_By_Copy
1081 @unnumberedsec Pragma C_Pass_By_Copy
1082 @cindex Passing by copy
1083 @findex C_Pass_By_Copy
1086 @smallexample @c ada
1087 pragma C_Pass_By_Copy
1088 ([Max_Size =>] static_integer_EXPRESSION);
1092 Normally the default mechanism for passing C convention records to C
1093 convention subprograms is to pass them by reference, as suggested by RM
1094 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1095 this default, by requiring that record formal parameters be passed by
1096 copy if all of the following conditions are met:
1100 The size of the record type does not exceed the value specified for
1103 The record type has @code{Convention C}.
1105 The formal parameter has this record type, and the subprogram has a
1106 foreign (non-Ada) convention.
1110 If these conditions are met the argument is passed by copy, i.e.@: in a
1111 manner consistent with what C expects if the corresponding formal in the
1112 C prototype is a struct (rather than a pointer to a struct).
1114 You can also pass records by copy by specifying the convention
1115 @code{C_Pass_By_Copy} for the record type, or by using the extended
1116 @code{Import} and @code{Export} pragmas, which allow specification of
1117 passing mechanisms on a parameter by parameter basis.
1120 @unnumberedsec Pragma Check
1122 @cindex Named assertions
1126 @smallexample @c ada
1128 [Name =>] Identifier,
1129 [Check =>] Boolean_EXPRESSION
1130 [, [Message =>] string_EXPRESSION] );
1134 This pragma is similar to the predefined pragma @code{Assert} except that an
1135 extra identifier argument is present. In conjunction with pragma
1136 @code{Check_Policy}, this can be used to define groups of assertions that can
1137 be independently controlled. The identifier @code{Assertion} is special, it
1138 refers to the normal set of pragma @code{Assert} statements. The identifiers
1139 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1140 names, so these three names would normally not be used directly in a pragma
1143 Checks introduced by this pragma are normally deactivated by default. They can
1144 be activated either by the command line option @option{-gnata}, which turns on
1145 all checks, or individually controlled using pragma @code{Check_Policy}.
1147 @node Pragma Check_Name
1148 @unnumberedsec Pragma Check_Name
1149 @cindex Defining check names
1150 @cindex Check names, defining
1154 @smallexample @c ada
1155 pragma Check_Name (check_name_IDENTIFIER);
1159 This is a configuration pragma that defines a new implementation
1160 defined check name (unless IDENTIFIER matches one of the predefined
1161 check names, in which case the pragma has no effect). Check names
1162 are global to a partition, so if two or more configuration pragmas
1163 are present in a partition mentioning the same name, only one new
1164 check name is introduced.
1166 An implementation defined check name introduced with this pragma may
1167 be used in only three contexts: @code{pragma Suppress},
1168 @code{pragma Unsuppress},
1169 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1170 any of these three cases, the check name must be visible. A check
1171 name is visible if it is in the configuration pragmas applying to
1172 the current unit, or if it appears at the start of any unit that
1173 is part of the dependency set of the current unit (e.g., units that
1174 are mentioned in @code{with} clauses).
1176 @node Pragma Check_Policy
1177 @unnumberedsec Pragma Check_Policy
1178 @cindex Controlling assertions
1179 @cindex Assertions, control
1180 @cindex Check pragma control
1181 @cindex Named assertions
1185 @smallexample @c ada
1187 ([Name =>] Identifier,
1188 [Policy =>] POLICY_IDENTIFIER);
1190 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1194 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1195 except that it controls sets of named assertions introduced using the
1196 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1197 @code{Assertion_Policy}) can be used within a declarative part, in which case
1198 it controls the status to the end of the corresponding construct (in a manner
1199 identical to pragma @code{Suppress)}.
1201 The identifier given as the first argument corresponds to a name used in
1202 associated @code{Check} pragmas. For example, if the pragma:
1204 @smallexample @c ada
1205 pragma Check_Policy (Critical_Error, Off);
1209 is given, then subsequent @code{Check} pragmas whose first argument is also
1210 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1211 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1212 @code{Check_Policy} with this identifier is similar to the normal
1213 @code{Assertion_Policy} pragma except that it can appear within a
1216 The special identifiers @code{Precondition} and @code{Postcondition} control
1217 the status of preconditions and postconditions. If a @code{Precondition} pragma
1218 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1219 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1220 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1223 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1224 to turn on corresponding checks. The default for a set of checks for which no
1225 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1226 @option{-gnata} is given, which turns on all checks by default.
1228 The check policy settings @code{Check} and @code{Ignore} are also recognized
1229 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1230 compatibility with the standard @code{Assertion_Policy} pragma.
1232 @node Pragma Comment
1233 @unnumberedsec Pragma Comment
1238 @smallexample @c ada
1239 pragma Comment (static_string_EXPRESSION);
1243 This is almost identical in effect to pragma @code{Ident}. It allows the
1244 placement of a comment into the object file and hence into the
1245 executable file if the operating system permits such usage. The
1246 difference is that @code{Comment}, unlike @code{Ident}, has
1247 no limitations on placement of the pragma (it can be placed
1248 anywhere in the main source unit), and if more than one pragma
1249 is used, all comments are retained.
1251 @node Pragma Common_Object
1252 @unnumberedsec Pragma Common_Object
1253 @findex Common_Object
1257 @smallexample @c ada
1258 pragma Common_Object (
1259 [Internal =>] LOCAL_NAME
1260 [, [External =>] EXTERNAL_SYMBOL]
1261 [, [Size =>] EXTERNAL_SYMBOL] );
1265 | static_string_EXPRESSION
1269 This pragma enables the shared use of variables stored in overlaid
1270 linker areas corresponding to the use of @code{COMMON}
1271 in Fortran. The single
1272 object @var{LOCAL_NAME} is assigned to the area designated by
1273 the @var{External} argument.
1274 You may define a record to correspond to a series
1275 of fields. The @var{Size} argument
1276 is syntax checked in GNAT, but otherwise ignored.
1278 @code{Common_Object} is not supported on all platforms. If no
1279 support is available, then the code generator will issue a message
1280 indicating that the necessary attribute for implementation of this
1281 pragma is not available.
1283 @node Pragma Compile_Time_Error
1284 @unnumberedsec Pragma Compile_Time_Error
1285 @findex Compile_Time_Error
1289 @smallexample @c ada
1290 pragma Compile_Time_Error
1291 (boolean_EXPRESSION, static_string_EXPRESSION);
1295 This pragma can be used to generate additional compile time
1297 is particularly useful in generics, where errors can be issued for
1298 specific problematic instantiations. The first parameter is a boolean
1299 expression. The pragma is effective only if the value of this expression
1300 is known at compile time, and has the value True. The set of expressions
1301 whose values are known at compile time includes all static boolean
1302 expressions, and also other values which the compiler can determine
1303 at compile time (e.g., the size of a record type set by an explicit
1304 size representation clause, or the value of a variable which was
1305 initialized to a constant and is known not to have been modified).
1306 If these conditions are met, an error message is generated using
1307 the value given as the second argument. This string value may contain
1308 embedded ASCII.LF characters to break the message into multiple lines.
1310 @node Pragma Compile_Time_Warning
1311 @unnumberedsec Pragma Compile_Time_Warning
1312 @findex Compile_Time_Warning
1316 @smallexample @c ada
1317 pragma Compile_Time_Warning
1318 (boolean_EXPRESSION, static_string_EXPRESSION);
1322 Same as pragma Compile_Time_Error, except a warning is issued instead
1323 of an error message. Note that if this pragma is used in a package that
1324 is with'ed by a client, the client will get the warning even though it
1325 is issued by a with'ed package (normally warnings in with'ed units are
1326 suppressed, but this is a special exception to that rule).
1328 One typical use is within a generic where compile time known characteristics
1329 of formal parameters are tested, and warnings given appropriately. Another use
1330 with a first parameter of True is to warn a client about use of a package,
1331 for example that it is not fully implemented.
1333 @node Pragma Complete_Representation
1334 @unnumberedsec Pragma Complete_Representation
1335 @findex Complete_Representation
1339 @smallexample @c ada
1340 pragma Complete_Representation;
1344 This pragma must appear immediately within a record representation
1345 clause. Typical placements are before the first component clause
1346 or after the last component clause. The effect is to give an error
1347 message if any component is missing a component clause. This pragma
1348 may be used to ensure that a record representation clause is
1349 complete, and that this invariant is maintained if fields are
1350 added to the record in the future.
1352 @node Pragma Complex_Representation
1353 @unnumberedsec Pragma Complex_Representation
1354 @findex Complex_Representation
1358 @smallexample @c ada
1359 pragma Complex_Representation
1360 ([Entity =>] LOCAL_NAME);
1364 The @var{Entity} argument must be the name of a record type which has
1365 two fields of the same floating-point type. The effect of this pragma is
1366 to force gcc to use the special internal complex representation form for
1367 this record, which may be more efficient. Note that this may result in
1368 the code for this type not conforming to standard ABI (application
1369 binary interface) requirements for the handling of record types. For
1370 example, in some environments, there is a requirement for passing
1371 records by pointer, and the use of this pragma may result in passing
1372 this type in floating-point registers.
1374 @node Pragma Component_Alignment
1375 @unnumberedsec Pragma Component_Alignment
1376 @cindex Alignments of components
1377 @findex Component_Alignment
1381 @smallexample @c ada
1382 pragma Component_Alignment (
1383 [Form =>] ALIGNMENT_CHOICE
1384 [, [Name =>] type_LOCAL_NAME]);
1386 ALIGNMENT_CHOICE ::=
1394 Specifies the alignment of components in array or record types.
1395 The meaning of the @var{Form} argument is as follows:
1398 @findex Component_Size
1399 @item Component_Size
1400 Aligns scalar components and subcomponents of the array or record type
1401 on boundaries appropriate to their inherent size (naturally
1402 aligned). For example, 1-byte components are aligned on byte boundaries,
1403 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1404 integer components are aligned on 4-byte boundaries and so on. These
1405 alignment rules correspond to the normal rules for C compilers on all
1406 machines except the VAX@.
1408 @findex Component_Size_4
1409 @item Component_Size_4
1410 Naturally aligns components with a size of four or fewer
1411 bytes. Components that are larger than 4 bytes are placed on the next
1414 @findex Storage_Unit
1416 Specifies that array or record components are byte aligned, i.e.@:
1417 aligned on boundaries determined by the value of the constant
1418 @code{System.Storage_Unit}.
1422 Specifies that array or record components are aligned on default
1423 boundaries, appropriate to the underlying hardware or operating system or
1424 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1425 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1426 the @code{Default} choice is the same as @code{Component_Size} (natural
1431 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1432 refer to a local record or array type, and the specified alignment
1433 choice applies to the specified type. The use of
1434 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1435 @code{Component_Alignment} pragma to be ignored. The use of
1436 @code{Component_Alignment} together with a record representation clause
1437 is only effective for fields not specified by the representation clause.
1439 If the @code{Name} parameter is absent, the pragma can be used as either
1440 a configuration pragma, in which case it applies to one or more units in
1441 accordance with the normal rules for configuration pragmas, or it can be
1442 used within a declarative part, in which case it applies to types that
1443 are declared within this declarative part, or within any nested scope
1444 within this declarative part. In either case it specifies the alignment
1445 to be applied to any record or array type which has otherwise standard
1448 If the alignment for a record or array type is not specified (using
1449 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1450 clause), the GNAT uses the default alignment as described previously.
1452 @node Pragma Convention_Identifier
1453 @unnumberedsec Pragma Convention_Identifier
1454 @findex Convention_Identifier
1455 @cindex Conventions, synonyms
1459 @smallexample @c ada
1460 pragma Convention_Identifier (
1461 [Name =>] IDENTIFIER,
1462 [Convention =>] convention_IDENTIFIER);
1466 This pragma provides a mechanism for supplying synonyms for existing
1467 convention identifiers. The @code{Name} identifier can subsequently
1468 be used as a synonym for the given convention in other pragmas (including
1469 for example pragma @code{Import} or another @code{Convention_Identifier}
1470 pragma). As an example of the use of this, suppose you had legacy code
1471 which used Fortran77 as the identifier for Fortran. Then the pragma:
1473 @smallexample @c ada
1474 pragma Convention_Identifier (Fortran77, Fortran);
1478 would allow the use of the convention identifier @code{Fortran77} in
1479 subsequent code, avoiding the need to modify the sources. As another
1480 example, you could use this to parametrize convention requirements
1481 according to systems. Suppose you needed to use @code{Stdcall} on
1482 windows systems, and @code{C} on some other system, then you could
1483 define a convention identifier @code{Library} and use a single
1484 @code{Convention_Identifier} pragma to specify which convention
1485 would be used system-wide.
1487 @node Pragma CPP_Class
1488 @unnumberedsec Pragma CPP_Class
1490 @cindex Interfacing with C++
1494 @smallexample @c ada
1495 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1499 The argument denotes an entity in the current declarative region that is
1500 declared as a record type. It indicates that the type corresponds to an
1501 externally declared C++ class type, and is to be laid out the same way
1502 that C++ would lay out the type. If the C++ class has virtual primitives
1503 then the record must be declared as a tagged record type.
1505 Types for which @code{CPP_Class} is specified do not have assignment or
1506 equality operators defined (such operations can be imported or declared
1507 as subprograms as required). Initialization is allowed only by constructor
1508 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1509 limited if not explicitly declared as limited or derived from a limited
1510 type, and an error is issued in that case.
1512 Pragma @code{CPP_Class} is intended primarily for automatic generation
1513 using an automatic binding generator tool.
1514 See @ref{Interfacing to C++} for related information.
1516 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1517 for backward compatibility but its functionality is available
1518 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1520 @node Pragma CPP_Constructor
1521 @unnumberedsec Pragma CPP_Constructor
1522 @cindex Interfacing with C++
1523 @findex CPP_Constructor
1527 @smallexample @c ada
1528 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1529 [, [External_Name =>] static_string_EXPRESSION ]
1530 [, [Link_Name =>] static_string_EXPRESSION ]);
1534 This pragma identifies an imported function (imported in the usual way
1535 with pragma @code{Import}) as corresponding to a C++ constructor. If
1536 @code{External_Name} and @code{Link_Name} are not specified then the
1537 @code{Entity} argument is a name that must have been previously mentioned
1538 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1539 must be of one of the following forms:
1543 @code{function @var{Fname} return @var{T}}
1547 @code{function @var{Fname} return @var{T}'Class}
1550 @code{function @var{Fname} (@dots{}) return @var{T}}
1554 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1558 where @var{T} is a limited record type imported from C++ with pragma
1559 @code{Import} and @code{Convention} = @code{CPP}.
1561 The first two forms import the default constructor, used when an object
1562 of type @var{T} is created on the Ada side with no explicit constructor.
1563 The latter two forms cover all the non-default constructors of the type.
1564 See the GNAT users guide for details.
1566 If no constructors are imported, it is impossible to create any objects
1567 on the Ada side and the type is implicitly declared abstract.
1569 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1570 using an automatic binding generator tool.
1571 See @ref{Interfacing to C++} for more related information.
1573 Note: The use of functions returning class-wide types for constructors is
1574 currently obsolete. They are supported for backward compatibility. The
1575 use of functions returning the type T leave the Ada sources more clear
1576 because the imported C++ constructors always return an object of type T;
1577 that is, they never return an object whose type is a descendant of type T.
1579 @node Pragma CPP_Virtual
1580 @unnumberedsec Pragma CPP_Virtual
1581 @cindex Interfacing to C++
1584 This pragma is now obsolete has has no effect because GNAT generates
1585 the same object layout than the G++ compiler.
1587 See @ref{Interfacing to C++} for related information.
1589 @node Pragma CPP_Vtable
1590 @unnumberedsec Pragma CPP_Vtable
1591 @cindex Interfacing with C++
1594 This pragma is now obsolete has has no effect because GNAT generates
1595 the same object layout than the G++ compiler.
1597 See @ref{Interfacing to C++} for related information.
1600 @unnumberedsec Pragma Debug
1605 @smallexample @c ada
1606 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1608 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1610 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1614 The procedure call argument has the syntactic form of an expression, meeting
1615 the syntactic requirements for pragmas.
1617 If debug pragmas are not enabled or if the condition is present and evaluates
1618 to False, this pragma has no effect. If debug pragmas are enabled, the
1619 semantics of the pragma is exactly equivalent to the procedure call statement
1620 corresponding to the argument with a terminating semicolon. Pragmas are
1621 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1622 intersperse calls to debug procedures in the middle of declarations. Debug
1623 pragmas can be enabled either by use of the command line switch @option{-gnata}
1624 or by use of the configuration pragma @code{Debug_Policy}.
1626 @node Pragma Debug_Policy
1627 @unnumberedsec Pragma Debug_Policy
1628 @findex Debug_Policy
1632 @smallexample @c ada
1633 pragma Debug_Policy (CHECK | IGNORE);
1637 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1638 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1639 This pragma overrides the effect of the @option{-gnata} switch on the
1642 @node Pragma Detect_Blocking
1643 @unnumberedsec Pragma Detect_Blocking
1644 @findex Detect_Blocking
1648 @smallexample @c ada
1649 pragma Detect_Blocking;
1653 This is a configuration pragma that forces the detection of potentially
1654 blocking operations within a protected operation, and to raise Program_Error
1657 @node Pragma Elaboration_Checks
1658 @unnumberedsec Pragma Elaboration_Checks
1659 @cindex Elaboration control
1660 @findex Elaboration_Checks
1664 @smallexample @c ada
1665 pragma Elaboration_Checks (Dynamic | Static);
1669 This is a configuration pragma that provides control over the
1670 elaboration model used by the compilation affected by the
1671 pragma. If the parameter is @code{Dynamic},
1672 then the dynamic elaboration
1673 model described in the Ada Reference Manual is used, as though
1674 the @option{-gnatE} switch had been specified on the command
1675 line. If the parameter is @code{Static}, then the default GNAT static
1676 model is used. This configuration pragma overrides the setting
1677 of the command line. For full details on the elaboration models
1678 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1679 gnat_ugn, @value{EDITION} User's Guide}.
1681 @node Pragma Eliminate
1682 @unnumberedsec Pragma Eliminate
1683 @cindex Elimination of unused subprograms
1688 @smallexample @c ada
1690 [Unit_Name =>] IDENTIFIER |
1691 SELECTED_COMPONENT);
1694 [Unit_Name =>] IDENTIFIER |
1696 [Entity =>] IDENTIFIER |
1697 SELECTED_COMPONENT |
1699 [,OVERLOADING_RESOLUTION]);
1701 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1704 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1707 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1709 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1710 Result_Type => result_SUBTYPE_NAME]
1712 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1713 SUBTYPE_NAME ::= STRING_VALUE
1715 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1716 SOURCE_TRACE ::= STRING_VALUE
1718 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1722 This pragma indicates that the given entity is not used outside the
1723 compilation unit it is defined in. The entity must be an explicitly declared
1724 subprogram; this includes generic subprogram instances and
1725 subprograms declared in generic package instances.
1727 If the entity to be eliminated is a library level subprogram, then
1728 the first form of pragma @code{Eliminate} is used with only a single argument.
1729 In this form, the @code{Unit_Name} argument specifies the name of the
1730 library level unit to be eliminated.
1732 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1733 are required. If item is an entity of a library package, then the first
1734 argument specifies the unit name, and the second argument specifies
1735 the particular entity. If the second argument is in string form, it must
1736 correspond to the internal manner in which GNAT stores entity names (see
1737 compilation unit Namet in the compiler sources for details).
1739 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1740 to distinguish between overloaded subprograms. If a pragma does not contain
1741 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1742 subprograms denoted by the first two parameters.
1744 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1745 to be eliminated in a manner similar to that used for the extended
1746 @code{Import} and @code{Export} pragmas, except that the subtype names are
1747 always given as strings. At the moment, this form of distinguishing
1748 overloaded subprograms is implemented only partially, so we do not recommend
1749 using it for practical subprogram elimination.
1751 Note that in case of a parameterless procedure its profile is represented
1752 as @code{Parameter_Types => ("")}
1754 Alternatively, the @code{Source_Location} parameter is used to specify
1755 which overloaded alternative is to be eliminated by pointing to the
1756 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1757 source text. The string literal (or concatenation of string literals)
1758 given as SOURCE_TRACE must have the following format:
1760 @smallexample @c ada
1761 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1766 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1767 FILE_NAME ::= STRING_LITERAL
1768 LINE_NUMBER ::= DIGIT @{DIGIT@}
1771 SOURCE_TRACE should be the short name of the source file (with no directory
1772 information), and LINE_NUMBER is supposed to point to the line where the
1773 defining name of the subprogram is located.
1775 For the subprograms that are not a part of generic instantiations, only one
1776 SOURCE_LOCATION is used. If a subprogram is declared in a package
1777 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1778 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1779 second one denotes the declaration of the corresponding subprogram in the
1780 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1781 in case of nested instantiations.
1783 The effect of the pragma is to allow the compiler to eliminate
1784 the code or data associated with the named entity. Any reference to
1785 an eliminated entity outside the compilation unit it is defined in,
1786 causes a compile time or link time error.
1788 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1789 in a system independent manner, with unused entities eliminated, without
1790 the requirement of modifying the source text. Normally the required set
1791 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1792 tool. Elimination of unused entities local to a compilation unit is
1793 automatic, without requiring the use of pragma @code{Eliminate}.
1795 Note that the reason this pragma takes string literals where names might
1796 be expected is that a pragma @code{Eliminate} can appear in a context where the
1797 relevant names are not visible.
1799 Note that any change in the source files that includes removing, splitting of
1800 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1803 It is legal to use pragma Eliminate where the referenced entity is a
1804 dispatching operation, but it is not clear what this would mean, since
1805 in general the call does not know which entity is actually being called.
1806 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1808 @node Pragma Export_Exception
1809 @unnumberedsec Pragma Export_Exception
1811 @findex Export_Exception
1815 @smallexample @c ada
1816 pragma Export_Exception (
1817 [Internal =>] LOCAL_NAME
1818 [, [External =>] EXTERNAL_SYMBOL]
1819 [, [Form =>] Ada | VMS]
1820 [, [Code =>] static_integer_EXPRESSION]);
1824 | static_string_EXPRESSION
1828 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1829 causes the specified exception to be propagated outside of the Ada program,
1830 so that it can be handled by programs written in other OpenVMS languages.
1831 This pragma establishes an external name for an Ada exception and makes the
1832 name available to the OpenVMS Linker as a global symbol. For further details
1833 on this pragma, see the
1834 DEC Ada Language Reference Manual, section 13.9a3.2.
1836 @node Pragma Export_Function
1837 @unnumberedsec Pragma Export_Function
1838 @cindex Argument passing mechanisms
1839 @findex Export_Function
1844 @smallexample @c ada
1845 pragma Export_Function (
1846 [Internal =>] LOCAL_NAME
1847 [, [External =>] EXTERNAL_SYMBOL]
1848 [, [Parameter_Types =>] PARAMETER_TYPES]
1849 [, [Result_Type =>] result_SUBTYPE_MARK]
1850 [, [Mechanism =>] MECHANISM]
1851 [, [Result_Mechanism =>] MECHANISM_NAME]);
1855 | static_string_EXPRESSION
1860 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1864 | subtype_Name ' Access
1868 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1870 MECHANISM_ASSOCIATION ::=
1871 [formal_parameter_NAME =>] MECHANISM_NAME
1876 | Descriptor [([Class =>] CLASS_NAME)]
1877 | Short_Descriptor [([Class =>] CLASS_NAME)]
1879 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1883 Use this pragma to make a function externally callable and optionally
1884 provide information on mechanisms to be used for passing parameter and
1885 result values. We recommend, for the purposes of improving portability,
1886 this pragma always be used in conjunction with a separate pragma
1887 @code{Export}, which must precede the pragma @code{Export_Function}.
1888 GNAT does not require a separate pragma @code{Export}, but if none is
1889 present, @code{Convention Ada} is assumed, which is usually
1890 not what is wanted, so it is usually appropriate to use this
1891 pragma in conjunction with a @code{Export} or @code{Convention}
1892 pragma that specifies the desired foreign convention.
1893 Pragma @code{Export_Function}
1894 (and @code{Export}, if present) must appear in the same declarative
1895 region as the function to which they apply.
1897 @var{internal_name} must uniquely designate the function to which the
1898 pragma applies. If more than one function name exists of this name in
1899 the declarative part you must use the @code{Parameter_Types} and
1900 @code{Result_Type} parameters is mandatory to achieve the required
1901 unique designation. @var{subtype_mark}s in these parameters must
1902 exactly match the subtypes in the corresponding function specification,
1903 using positional notation to match parameters with subtype marks.
1904 The form with an @code{'Access} attribute can be used to match an
1905 anonymous access parameter.
1908 @cindex Passing by descriptor
1909 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1910 The default behavior for Export_Function is to accept either 64bit or
1911 32bit descriptors unless short_descriptor is specified, then only 32bit
1912 descriptors are accepted.
1914 @cindex Suppressing external name
1915 Special treatment is given if the EXTERNAL is an explicit null
1916 string or a static string expressions that evaluates to the null
1917 string. In this case, no external name is generated. This form
1918 still allows the specification of parameter mechanisms.
1920 @node Pragma Export_Object
1921 @unnumberedsec Pragma Export_Object
1922 @findex Export_Object
1926 @smallexample @c ada
1927 pragma Export_Object
1928 [Internal =>] LOCAL_NAME
1929 [, [External =>] EXTERNAL_SYMBOL]
1930 [, [Size =>] EXTERNAL_SYMBOL]
1934 | static_string_EXPRESSION
1938 This pragma designates an object as exported, and apart from the
1939 extended rules for external symbols, is identical in effect to the use of
1940 the normal @code{Export} pragma applied to an object. You may use a
1941 separate Export pragma (and you probably should from the point of view
1942 of portability), but it is not required. @var{Size} is syntax checked,
1943 but otherwise ignored by GNAT@.
1945 @node Pragma Export_Procedure
1946 @unnumberedsec Pragma Export_Procedure
1947 @findex Export_Procedure
1951 @smallexample @c ada
1952 pragma Export_Procedure (
1953 [Internal =>] LOCAL_NAME
1954 [, [External =>] EXTERNAL_SYMBOL]
1955 [, [Parameter_Types =>] PARAMETER_TYPES]
1956 [, [Mechanism =>] MECHANISM]);
1960 | static_string_EXPRESSION
1965 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1969 | subtype_Name ' Access
1973 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1975 MECHANISM_ASSOCIATION ::=
1976 [formal_parameter_NAME =>] MECHANISM_NAME
1981 | Descriptor [([Class =>] CLASS_NAME)]
1982 | Short_Descriptor [([Class =>] CLASS_NAME)]
1984 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1988 This pragma is identical to @code{Export_Function} except that it
1989 applies to a procedure rather than a function and the parameters
1990 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1991 GNAT does not require a separate pragma @code{Export}, but if none is
1992 present, @code{Convention Ada} is assumed, which is usually
1993 not what is wanted, so it is usually appropriate to use this
1994 pragma in conjunction with a @code{Export} or @code{Convention}
1995 pragma that specifies the desired foreign convention.
1998 @cindex Passing by descriptor
1999 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2000 The default behavior for Export_Procedure is to accept either 64bit or
2001 32bit descriptors unless short_descriptor is specified, then only 32bit
2002 descriptors are accepted.
2004 @cindex Suppressing external name
2005 Special treatment is given if the EXTERNAL is an explicit null
2006 string or a static string expressions that evaluates to the null
2007 string. In this case, no external name is generated. This form
2008 still allows the specification of parameter mechanisms.
2010 @node Pragma Export_Value
2011 @unnumberedsec Pragma Export_Value
2012 @findex Export_Value
2016 @smallexample @c ada
2017 pragma Export_Value (
2018 [Value =>] static_integer_EXPRESSION,
2019 [Link_Name =>] static_string_EXPRESSION);
2023 This pragma serves to export a static integer value for external use.
2024 The first argument specifies the value to be exported. The Link_Name
2025 argument specifies the symbolic name to be associated with the integer
2026 value. This pragma is useful for defining a named static value in Ada
2027 that can be referenced in assembly language units to be linked with
2028 the application. This pragma is currently supported only for the
2029 AAMP target and is ignored for other targets.
2031 @node Pragma Export_Valued_Procedure
2032 @unnumberedsec Pragma Export_Valued_Procedure
2033 @findex Export_Valued_Procedure
2037 @smallexample @c ada
2038 pragma Export_Valued_Procedure (
2039 [Internal =>] LOCAL_NAME
2040 [, [External =>] EXTERNAL_SYMBOL]
2041 [, [Parameter_Types =>] PARAMETER_TYPES]
2042 [, [Mechanism =>] MECHANISM]);
2046 | static_string_EXPRESSION
2051 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2055 | subtype_Name ' Access
2059 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2061 MECHANISM_ASSOCIATION ::=
2062 [formal_parameter_NAME =>] MECHANISM_NAME
2067 | Descriptor [([Class =>] CLASS_NAME)]
2068 | Short_Descriptor [([Class =>] CLASS_NAME)]
2070 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2074 This pragma is identical to @code{Export_Procedure} except that the
2075 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2076 mode @code{OUT}, and externally the subprogram is treated as a function
2077 with this parameter as the result of the function. GNAT provides for
2078 this capability to allow the use of @code{OUT} and @code{IN OUT}
2079 parameters in interfacing to external functions (which are not permitted
2081 GNAT does not require a separate pragma @code{Export}, but if none is
2082 present, @code{Convention Ada} is assumed, which is almost certainly
2083 not what is wanted since the whole point of this pragma is to interface
2084 with foreign language functions, so it is usually appropriate to use this
2085 pragma in conjunction with a @code{Export} or @code{Convention}
2086 pragma that specifies the desired foreign convention.
2089 @cindex Passing by descriptor
2090 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2091 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2092 32bit descriptors unless short_descriptor is specified, then only 32bit
2093 descriptors are accepted.
2095 @cindex Suppressing external name
2096 Special treatment is given if the EXTERNAL is an explicit null
2097 string or a static string expressions that evaluates to the null
2098 string. In this case, no external name is generated. This form
2099 still allows the specification of parameter mechanisms.
2101 @node Pragma Extend_System
2102 @unnumberedsec Pragma Extend_System
2103 @cindex @code{system}, extending
2105 @findex Extend_System
2109 @smallexample @c ada
2110 pragma Extend_System ([Name =>] IDENTIFIER);
2114 This pragma is used to provide backwards compatibility with other
2115 implementations that extend the facilities of package @code{System}. In
2116 GNAT, @code{System} contains only the definitions that are present in
2117 the Ada RM@. However, other implementations, notably the DEC Ada 83
2118 implementation, provide many extensions to package @code{System}.
2120 For each such implementation accommodated by this pragma, GNAT provides a
2121 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2122 implementation, which provides the required additional definitions. You
2123 can use this package in two ways. You can @code{with} it in the normal
2124 way and access entities either by selection or using a @code{use}
2125 clause. In this case no special processing is required.
2127 However, if existing code contains references such as
2128 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2129 definitions provided in package @code{System}, you may use this pragma
2130 to extend visibility in @code{System} in a non-standard way that
2131 provides greater compatibility with the existing code. Pragma
2132 @code{Extend_System} is a configuration pragma whose single argument is
2133 the name of the package containing the extended definition
2134 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2135 control of this pragma will be processed using special visibility
2136 processing that looks in package @code{System.Aux_@var{xxx}} where
2137 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2138 package @code{System}, but not found in package @code{System}.
2140 You can use this pragma either to access a predefined @code{System}
2141 extension supplied with the compiler, for example @code{Aux_DEC} or
2142 you can construct your own extension unit following the above
2143 definition. Note that such a package is a child of @code{System}
2144 and thus is considered part of the implementation. To compile
2145 it you will have to use the appropriate switch for compiling
2146 system units. @xref{Top, @value{EDITION} User's Guide, About This
2147 Guide,, gnat_ugn, @value{EDITION} User's Guide}, for details.
2149 @node Pragma External
2150 @unnumberedsec Pragma External
2155 @smallexample @c ada
2157 [ Convention =>] convention_IDENTIFIER,
2158 [ Entity =>] LOCAL_NAME
2159 [, [External_Name =>] static_string_EXPRESSION ]
2160 [, [Link_Name =>] static_string_EXPRESSION ]);
2164 This pragma is identical in syntax and semantics to pragma
2165 @code{Export} as defined in the Ada Reference Manual. It is
2166 provided for compatibility with some Ada 83 compilers that
2167 used this pragma for exactly the same purposes as pragma
2168 @code{Export} before the latter was standardized.
2170 @node Pragma External_Name_Casing
2171 @unnumberedsec Pragma External_Name_Casing
2172 @cindex Dec Ada 83 casing compatibility
2173 @cindex External Names, casing
2174 @cindex Casing of External names
2175 @findex External_Name_Casing
2179 @smallexample @c ada
2180 pragma External_Name_Casing (
2181 Uppercase | Lowercase
2182 [, Uppercase | Lowercase | As_Is]);
2186 This pragma provides control over the casing of external names associated
2187 with Import and Export pragmas. There are two cases to consider:
2190 @item Implicit external names
2191 Implicit external names are derived from identifiers. The most common case
2192 arises when a standard Ada Import or Export pragma is used with only two
2195 @smallexample @c ada
2196 pragma Import (C, C_Routine);
2200 Since Ada is a case-insensitive language, the spelling of the identifier in
2201 the Ada source program does not provide any information on the desired
2202 casing of the external name, and so a convention is needed. In GNAT the
2203 default treatment is that such names are converted to all lower case
2204 letters. This corresponds to the normal C style in many environments.
2205 The first argument of pragma @code{External_Name_Casing} can be used to
2206 control this treatment. If @code{Uppercase} is specified, then the name
2207 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2208 then the normal default of all lower case letters will be used.
2210 This same implicit treatment is also used in the case of extended DEC Ada 83
2211 compatible Import and Export pragmas where an external name is explicitly
2212 specified using an identifier rather than a string.
2214 @item Explicit external names
2215 Explicit external names are given as string literals. The most common case
2216 arises when a standard Ada Import or Export pragma is used with three
2219 @smallexample @c ada
2220 pragma Import (C, C_Routine, "C_routine");
2224 In this case, the string literal normally provides the exact casing required
2225 for the external name. The second argument of pragma
2226 @code{External_Name_Casing} may be used to modify this behavior.
2227 If @code{Uppercase} is specified, then the name
2228 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2229 then the name will be forced to all lowercase letters. A specification of
2230 @code{As_Is} provides the normal default behavior in which the casing is
2231 taken from the string provided.
2235 This pragma may appear anywhere that a pragma is valid. In particular, it
2236 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2237 case it applies to all subsequent compilations, or it can be used as a program
2238 unit pragma, in which case it only applies to the current unit, or it can
2239 be used more locally to control individual Import/Export pragmas.
2241 It is primarily intended for use with OpenVMS systems, where many
2242 compilers convert all symbols to upper case by default. For interfacing to
2243 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2246 @smallexample @c ada
2247 pragma External_Name_Casing (Uppercase, Uppercase);
2251 to enforce the upper casing of all external symbols.
2253 @node Pragma Fast_Math
2254 @unnumberedsec Pragma Fast_Math
2259 @smallexample @c ada
2264 This is a configuration pragma which activates a mode in which speed is
2265 considered more important for floating-point operations than absolutely
2266 accurate adherence to the requirements of the standard. Currently the
2267 following operations are affected:
2270 @item Complex Multiplication
2271 The normal simple formula for complex multiplication can result in intermediate
2272 overflows for numbers near the end of the range. The Ada standard requires that
2273 this situation be detected and corrected by scaling, but in Fast_Math mode such
2274 cases will simply result in overflow. Note that to take advantage of this you
2275 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2276 under control of the pragma, rather than use the preinstantiated versions.
2279 @node Pragma Favor_Top_Level
2280 @unnumberedsec Pragma Favor_Top_Level
2281 @findex Favor_Top_Level
2285 @smallexample @c ada
2286 pragma Favor_Top_Level (type_NAME);
2290 The named type must be an access-to-subprogram type. This pragma is an
2291 efficiency hint to the compiler, regarding the use of 'Access or
2292 'Unrestricted_Access on nested (non-library-level) subprograms. The
2293 pragma means that nested subprograms are not used with this type, or
2294 are rare, so that the generated code should be efficient in the
2295 top-level case. When this pragma is used, dynamically generated
2296 trampolines may be used on some targets for nested subprograms.
2297 See also the No_Implicit_Dynamic_Code restriction.
2299 @node Pragma Finalize_Storage_Only
2300 @unnumberedsec Pragma Finalize_Storage_Only
2301 @findex Finalize_Storage_Only
2305 @smallexample @c ada
2306 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2310 This pragma allows the compiler not to emit a Finalize call for objects
2311 defined at the library level. This is mostly useful for types where
2312 finalization is only used to deal with storage reclamation since in most
2313 environments it is not necessary to reclaim memory just before terminating
2314 execution, hence the name.
2316 @node Pragma Float_Representation
2317 @unnumberedsec Pragma Float_Representation
2319 @findex Float_Representation
2323 @smallexample @c ada
2324 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2326 FLOAT_REP ::= VAX_Float | IEEE_Float
2330 In the one argument form, this pragma is a configuration pragma which
2331 allows control over the internal representation chosen for the predefined
2332 floating point types declared in the packages @code{Standard} and
2333 @code{System}. On all systems other than OpenVMS, the argument must
2334 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2335 argument may be @code{VAX_Float} to specify the use of the VAX float
2336 format for the floating-point types in Standard. This requires that
2337 the standard runtime libraries be recompiled. @xref{The GNAT Run-Time
2338 Library Builder gnatlbr,,, gnat_ugn, @value{EDITION} User's Guide
2339 OpenVMS}, for a description of the @code{GNAT LIBRARY} command.
2341 The two argument form specifies the representation to be used for
2342 the specified floating-point type. On all systems other than OpenVMS,
2344 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2345 argument may be @code{VAX_Float} to specify the use of the VAX float
2350 For digits values up to 6, F float format will be used.
2352 For digits values from 7 to 9, G float format will be used.
2354 For digits values from 10 to 15, F float format will be used.
2356 Digits values above 15 are not allowed.
2360 @unnumberedsec Pragma Ident
2365 @smallexample @c ada
2366 pragma Ident (static_string_EXPRESSION);
2370 This pragma provides a string identification in the generated object file,
2371 if the system supports the concept of this kind of identification string.
2372 This pragma is allowed only in the outermost declarative part or
2373 declarative items of a compilation unit. If more than one @code{Ident}
2374 pragma is given, only the last one processed is effective.
2376 On OpenVMS systems, the effect of the pragma is identical to the effect of
2377 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2378 maximum allowed length is 31 characters, so if it is important to
2379 maintain compatibility with this compiler, you should obey this length
2382 @node Pragma Implemented_By_Entry
2383 @unnumberedsec Pragma Implemented_By_Entry
2384 @findex Implemented_By_Entry
2388 @smallexample @c ada
2389 pragma Implemented_By_Entry (LOCAL_NAME);
2393 This is a representation pragma which applies to protected, synchronized and
2394 task interface primitives. If the pragma is applied to primitive operation Op
2395 of interface Iface, it is illegal to override Op in a type that implements
2396 Iface, with anything other than an entry.
2398 @smallexample @c ada
2399 type Iface is protected interface;
2400 procedure Do_Something (Object : in out Iface) is abstract;
2401 pragma Implemented_By_Entry (Do_Something);
2403 protected type P is new Iface with
2404 procedure Do_Something; -- Illegal
2407 task type T is new Iface with
2408 entry Do_Something; -- Legal
2413 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2414 is intended to be used in conjunction with dispatching requeue statements as
2415 described in AI05-0030. Should the ARG decide on an official name and syntax,
2416 this pragma will become language-defined rather than GNAT-specific.
2418 @node Pragma Implicit_Packing
2419 @unnumberedsec Pragma Implicit_Packing
2420 @findex Implicit_Packing
2424 @smallexample @c ada
2425 pragma Implicit_Packing;
2429 This is a configuration pragma that requests implicit packing for packed
2430 arrays for which a size clause is given but no explicit pragma Pack or
2431 specification of Component_Size is present. It also applies to records
2432 where no record representation clause is present. Consider this example:
2434 @smallexample @c ada
2435 type R is array (0 .. 7) of Boolean;
2440 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2441 does not change the layout of a composite object. So the Size clause in the
2442 above example is normally rejected, since the default layout of the array uses
2443 8-bit components, and thus the array requires a minimum of 64 bits.
2445 If this declaration is compiled in a region of code covered by an occurrence
2446 of the configuration pragma Implicit_Packing, then the Size clause in this
2447 and similar examples will cause implicit packing and thus be accepted. For
2448 this implicit packing to occur, the type in question must be an array of small
2449 components whose size is known at compile time, and the Size clause must
2450 specify the exact size that corresponds to the length of the array multiplied
2451 by the size in bits of the component type.
2452 @cindex Array packing
2454 Similarly, the following example shows the use in the record case
2456 @smallexample @c ada
2458 a, b, c, d, e, f, g, h : boolean;
2465 Without a pragma Pack, each Boolean field requires 8 bits, so the
2466 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2467 sufficient. The use of pragma Implciit_Packing allows this record
2468 declaration to compile without an explicit pragma Pack.
2469 @node Pragma Import_Exception
2470 @unnumberedsec Pragma Import_Exception
2472 @findex Import_Exception
2476 @smallexample @c ada
2477 pragma Import_Exception (
2478 [Internal =>] LOCAL_NAME
2479 [, [External =>] EXTERNAL_SYMBOL]
2480 [, [Form =>] Ada | VMS]
2481 [, [Code =>] static_integer_EXPRESSION]);
2485 | static_string_EXPRESSION
2489 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2490 It allows OpenVMS conditions (for example, from OpenVMS system services or
2491 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2492 The pragma specifies that the exception associated with an exception
2493 declaration in an Ada program be defined externally (in non-Ada code).
2494 For further details on this pragma, see the
2495 DEC Ada Language Reference Manual, section 13.9a.3.1.
2497 @node Pragma Import_Function
2498 @unnumberedsec Pragma Import_Function
2499 @findex Import_Function
2503 @smallexample @c ada
2504 pragma Import_Function (
2505 [Internal =>] LOCAL_NAME,
2506 [, [External =>] EXTERNAL_SYMBOL]
2507 [, [Parameter_Types =>] PARAMETER_TYPES]
2508 [, [Result_Type =>] SUBTYPE_MARK]
2509 [, [Mechanism =>] MECHANISM]
2510 [, [Result_Mechanism =>] MECHANISM_NAME]
2511 [, [First_Optional_Parameter =>] IDENTIFIER]);
2515 | static_string_EXPRESSION
2519 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2523 | subtype_Name ' Access
2527 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2529 MECHANISM_ASSOCIATION ::=
2530 [formal_parameter_NAME =>] MECHANISM_NAME
2535 | Descriptor [([Class =>] CLASS_NAME)]
2536 | Short_Descriptor [([Class =>] CLASS_NAME)]
2538 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2542 This pragma is used in conjunction with a pragma @code{Import} to
2543 specify additional information for an imported function. The pragma
2544 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2545 @code{Import_Function} pragma and both must appear in the same
2546 declarative part as the function specification.
2548 The @var{Internal} argument must uniquely designate
2549 the function to which the
2550 pragma applies. If more than one function name exists of this name in
2551 the declarative part you must use the @code{Parameter_Types} and
2552 @var{Result_Type} parameters to achieve the required unique
2553 designation. Subtype marks in these parameters must exactly match the
2554 subtypes in the corresponding function specification, using positional
2555 notation to match parameters with subtype marks.
2556 The form with an @code{'Access} attribute can be used to match an
2557 anonymous access parameter.
2559 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2560 parameters to specify passing mechanisms for the
2561 parameters and result. If you specify a single mechanism name, it
2562 applies to all parameters. Otherwise you may specify a mechanism on a
2563 parameter by parameter basis using either positional or named
2564 notation. If the mechanism is not specified, the default mechanism
2568 @cindex Passing by descriptor
2569 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2570 The default behavior for Import_Function is to pass a 64bit descriptor
2571 unless short_descriptor is specified, then a 32bit descriptor is passed.
2573 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2574 It specifies that the designated parameter and all following parameters
2575 are optional, meaning that they are not passed at the generated code
2576 level (this is distinct from the notion of optional parameters in Ada
2577 where the parameters are passed anyway with the designated optional
2578 parameters). All optional parameters must be of mode @code{IN} and have
2579 default parameter values that are either known at compile time
2580 expressions, or uses of the @code{'Null_Parameter} attribute.
2582 @node Pragma Import_Object
2583 @unnumberedsec Pragma Import_Object
2584 @findex Import_Object
2588 @smallexample @c ada
2589 pragma Import_Object
2590 [Internal =>] LOCAL_NAME
2591 [, [External =>] EXTERNAL_SYMBOL]
2592 [, [Size =>] EXTERNAL_SYMBOL]);
2596 | static_string_EXPRESSION
2600 This pragma designates an object as imported, and apart from the
2601 extended rules for external symbols, is identical in effect to the use of
2602 the normal @code{Import} pragma applied to an object. Unlike the
2603 subprogram case, you need not use a separate @code{Import} pragma,
2604 although you may do so (and probably should do so from a portability
2605 point of view). @var{size} is syntax checked, but otherwise ignored by
2608 @node Pragma Import_Procedure
2609 @unnumberedsec Pragma Import_Procedure
2610 @findex Import_Procedure
2614 @smallexample @c ada
2615 pragma Import_Procedure (
2616 [Internal =>] LOCAL_NAME
2617 [, [External =>] EXTERNAL_SYMBOL]
2618 [, [Parameter_Types =>] PARAMETER_TYPES]
2619 [, [Mechanism =>] MECHANISM]
2620 [, [First_Optional_Parameter =>] IDENTIFIER]);
2624 | static_string_EXPRESSION
2628 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2632 | subtype_Name ' Access
2636 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2638 MECHANISM_ASSOCIATION ::=
2639 [formal_parameter_NAME =>] MECHANISM_NAME
2644 | Descriptor [([Class =>] CLASS_NAME)]
2645 | Short_Descriptor [([Class =>] CLASS_NAME)]
2647 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2651 This pragma is identical to @code{Import_Function} except that it
2652 applies to a procedure rather than a function and the parameters
2653 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2655 @node Pragma Import_Valued_Procedure
2656 @unnumberedsec Pragma Import_Valued_Procedure
2657 @findex Import_Valued_Procedure
2661 @smallexample @c ada
2662 pragma Import_Valued_Procedure (
2663 [Internal =>] LOCAL_NAME
2664 [, [External =>] EXTERNAL_SYMBOL]
2665 [, [Parameter_Types =>] PARAMETER_TYPES]
2666 [, [Mechanism =>] MECHANISM]
2667 [, [First_Optional_Parameter =>] IDENTIFIER]);
2671 | static_string_EXPRESSION
2675 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2679 | subtype_Name ' Access
2683 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2685 MECHANISM_ASSOCIATION ::=
2686 [formal_parameter_NAME =>] MECHANISM_NAME
2691 | Descriptor [([Class =>] CLASS_NAME)]
2692 | Short_Descriptor [([Class =>] CLASS_NAME)]
2694 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2698 This pragma is identical to @code{Import_Procedure} except that the
2699 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2700 mode @code{OUT}, and externally the subprogram is treated as a function
2701 with this parameter as the result of the function. The purpose of this
2702 capability is to allow the use of @code{OUT} and @code{IN OUT}
2703 parameters in interfacing to external functions (which are not permitted
2704 in Ada functions). You may optionally use the @code{Mechanism}
2705 parameters to specify passing mechanisms for the parameters.
2706 If you specify a single mechanism name, it applies to all parameters.
2707 Otherwise you may specify a mechanism on a parameter by parameter
2708 basis using either positional or named notation. If the mechanism is not
2709 specified, the default mechanism is used.
2711 Note that it is important to use this pragma in conjunction with a separate
2712 pragma Import that specifies the desired convention, since otherwise the
2713 default convention is Ada, which is almost certainly not what is required.
2715 @node Pragma Initialize_Scalars
2716 @unnumberedsec Pragma Initialize_Scalars
2717 @findex Initialize_Scalars
2718 @cindex debugging with Initialize_Scalars
2722 @smallexample @c ada
2723 pragma Initialize_Scalars;
2727 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2728 two important differences. First, there is no requirement for the pragma
2729 to be used uniformly in all units of a partition, in particular, it is fine
2730 to use this just for some or all of the application units of a partition,
2731 without needing to recompile the run-time library.
2733 In the case where some units are compiled with the pragma, and some without,
2734 then a declaration of a variable where the type is defined in package
2735 Standard or is locally declared will always be subject to initialization,
2736 as will any declaration of a scalar variable. For composite variables,
2737 whether the variable is initialized may also depend on whether the package
2738 in which the type of the variable is declared is compiled with the pragma.
2740 The other important difference is that you can control the value used
2741 for initializing scalar objects. At bind time, you can select several
2742 options for initialization. You can
2743 initialize with invalid values (similar to Normalize_Scalars, though for
2744 Initialize_Scalars it is not always possible to determine the invalid
2745 values in complex cases like signed component fields with non-standard
2746 sizes). You can also initialize with high or
2747 low values, or with a specified bit pattern. See the users guide for binder
2748 options for specifying these cases.
2750 This means that you can compile a program, and then without having to
2751 recompile the program, you can run it with different values being used
2752 for initializing otherwise uninitialized values, to test if your program
2753 behavior depends on the choice. Of course the behavior should not change,
2754 and if it does, then most likely you have an erroneous reference to an
2755 uninitialized value.
2757 It is even possible to change the value at execution time eliminating even
2758 the need to rebind with a different switch using an environment variable.
2759 See the GNAT users guide for details.
2761 Note that pragma @code{Initialize_Scalars} is particularly useful in
2762 conjunction with the enhanced validity checking that is now provided
2763 in GNAT, which checks for invalid values under more conditions.
2764 Using this feature (see description of the @option{-gnatV} flag in the
2765 users guide) in conjunction with pragma @code{Initialize_Scalars}
2766 provides a powerful new tool to assist in the detection of problems
2767 caused by uninitialized variables.
2769 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2770 effect on the generated code. This may cause your code to be
2771 substantially larger. It may also cause an increase in the amount
2772 of stack required, so it is probably a good idea to turn on stack
2773 checking (see description of stack checking in the GNAT users guide)
2774 when using this pragma.
2776 @node Pragma Inline_Always
2777 @unnumberedsec Pragma Inline_Always
2778 @findex Inline_Always
2782 @smallexample @c ada
2783 pragma Inline_Always (NAME [, NAME]);
2787 Similar to pragma @code{Inline} except that inlining is not subject to
2788 the use of option @option{-gnatn} and the inlining happens regardless of
2789 whether this option is used.
2791 @node Pragma Inline_Generic
2792 @unnumberedsec Pragma Inline_Generic
2793 @findex Inline_Generic
2797 @smallexample @c ada
2798 pragma Inline_Generic (generic_package_NAME);
2802 This is implemented for compatibility with DEC Ada 83 and is recognized,
2803 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2804 by default when using GNAT@.
2806 @node Pragma Interface
2807 @unnumberedsec Pragma Interface
2812 @smallexample @c ada
2814 [Convention =>] convention_identifier,
2815 [Entity =>] local_NAME
2816 [, [External_Name =>] static_string_expression]
2817 [, [Link_Name =>] static_string_expression]);
2821 This pragma is identical in syntax and semantics to
2822 the standard Ada pragma @code{Import}. It is provided for compatibility
2823 with Ada 83. The definition is upwards compatible both with pragma
2824 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2825 with some extended implementations of this pragma in certain Ada 83
2828 @node Pragma Interface_Name
2829 @unnumberedsec Pragma Interface_Name
2830 @findex Interface_Name
2834 @smallexample @c ada
2835 pragma Interface_Name (
2836 [Entity =>] LOCAL_NAME
2837 [, [External_Name =>] static_string_EXPRESSION]
2838 [, [Link_Name =>] static_string_EXPRESSION]);
2842 This pragma provides an alternative way of specifying the interface name
2843 for an interfaced subprogram, and is provided for compatibility with Ada
2844 83 compilers that use the pragma for this purpose. You must provide at
2845 least one of @var{External_Name} or @var{Link_Name}.
2847 @node Pragma Interrupt_Handler
2848 @unnumberedsec Pragma Interrupt_Handler
2849 @findex Interrupt_Handler
2853 @smallexample @c ada
2854 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2858 This program unit pragma is supported for parameterless protected procedures
2859 as described in Annex C of the Ada Reference Manual. On the AAMP target
2860 the pragma can also be specified for nonprotected parameterless procedures
2861 that are declared at the library level (which includes procedures
2862 declared at the top level of a library package). In the case of AAMP,
2863 when this pragma is applied to a nonprotected procedure, the instruction
2864 @code{IERET} is generated for returns from the procedure, enabling
2865 maskable interrupts, in place of the normal return instruction.
2867 @node Pragma Interrupt_State
2868 @unnumberedsec Pragma Interrupt_State
2869 @findex Interrupt_State
2873 @smallexample @c ada
2874 pragma Interrupt_State
2876 [State =>] SYSTEM | RUNTIME | USER);
2880 Normally certain interrupts are reserved to the implementation. Any attempt
2881 to attach an interrupt causes Program_Error to be raised, as described in
2882 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
2883 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
2884 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2885 interrupt execution. Additionally, signals such as @code{SIGSEGV},
2886 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2887 Ada exceptions, or used to implement run-time functions such as the
2888 @code{abort} statement and stack overflow checking.
2890 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2891 such uses of interrupts. It subsumes the functionality of pragma
2892 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
2893 available on OS/2, Windows or VMS. On all other platforms than VxWorks,
2894 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2895 and may be used to mark interrupts required by the board support package
2898 Interrupts can be in one of three states:
2902 The interrupt is reserved (no Ada handler can be installed), and the
2903 Ada run-time may not install a handler. As a result you are guaranteed
2904 standard system default action if this interrupt is raised.
2908 The interrupt is reserved (no Ada handler can be installed). The run time
2909 is allowed to install a handler for internal control purposes, but is
2910 not required to do so.
2914 The interrupt is unreserved. The user may install a handler to provide
2919 These states are the allowed values of the @code{State} parameter of the
2920 pragma. The @code{Name} parameter is a value of the type
2921 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
2922 @code{Ada.Interrupts.Names}.
2924 This is a configuration pragma, and the binder will check that there
2925 are no inconsistencies between different units in a partition in how a
2926 given interrupt is specified. It may appear anywhere a pragma is legal.
2928 The effect is to move the interrupt to the specified state.
2930 By declaring interrupts to be SYSTEM, you guarantee the standard system
2931 action, such as a core dump.
2933 By declaring interrupts to be USER, you guarantee that you can install
2936 Note that certain signals on many operating systems cannot be caught and
2937 handled by applications. In such cases, the pragma is ignored. See the
2938 operating system documentation, or the value of the array @code{Reserved}
2939 declared in the spec of package @code{System.OS_Interface}.
2941 Overriding the default state of signals used by the Ada runtime may interfere
2942 with an application's runtime behavior in the cases of the synchronous signals,
2943 and in the case of the signal used to implement the @code{abort} statement.
2945 @node Pragma Keep_Names
2946 @unnumberedsec Pragma Keep_Names
2951 @smallexample @c ada
2952 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2956 The @var{LOCAL_NAME} argument
2957 must refer to an enumeration first subtype
2958 in the current declarative part. The effect is to retain the enumeration
2959 literal names for use by @code{Image} and @code{Value} even if a global
2960 @code{Discard_Names} pragma applies. This is useful when you want to
2961 generally suppress enumeration literal names and for example you therefore
2962 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2963 want to retain the names for specific enumeration types.
2965 @node Pragma License
2966 @unnumberedsec Pragma License
2968 @cindex License checking
2972 @smallexample @c ada
2973 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2977 This pragma is provided to allow automated checking for appropriate license
2978 conditions with respect to the standard and modified GPL@. A pragma
2979 @code{License}, which is a configuration pragma that typically appears at
2980 the start of a source file or in a separate @file{gnat.adc} file, specifies
2981 the licensing conditions of a unit as follows:
2985 This is used for a unit that can be freely used with no license restrictions.
2986 Examples of such units are public domain units, and units from the Ada
2990 This is used for a unit that is licensed under the unmodified GPL, and which
2991 therefore cannot be @code{with}'ed by a restricted unit.
2994 This is used for a unit licensed under the GNAT modified GPL that includes
2995 a special exception paragraph that specifically permits the inclusion of
2996 the unit in programs without requiring the entire program to be released
3000 This is used for a unit that is restricted in that it is not permitted to
3001 depend on units that are licensed under the GPL@. Typical examples are
3002 proprietary code that is to be released under more restrictive license
3003 conditions. Note that restricted units are permitted to @code{with} units
3004 which are licensed under the modified GPL (this is the whole point of the
3010 Normally a unit with no @code{License} pragma is considered to have an
3011 unknown license, and no checking is done. However, standard GNAT headers
3012 are recognized, and license information is derived from them as follows.
3016 A GNAT license header starts with a line containing 78 hyphens. The following
3017 comment text is searched for the appearance of any of the following strings.
3019 If the string ``GNU General Public License'' is found, then the unit is assumed
3020 to have GPL license, unless the string ``As a special exception'' follows, in
3021 which case the license is assumed to be modified GPL@.
3023 If one of the strings
3024 ``This specification is adapted from the Ada Semantic Interface'' or
3025 ``This specification is derived from the Ada Reference Manual'' is found
3026 then the unit is assumed to be unrestricted.
3030 These default actions means that a program with a restricted license pragma
3031 will automatically get warnings if a GPL unit is inappropriately
3032 @code{with}'ed. For example, the program:
3034 @smallexample @c ada
3037 procedure Secret_Stuff is
3043 if compiled with pragma @code{License} (@code{Restricted}) in a
3044 @file{gnat.adc} file will generate the warning:
3049 >>> license of withed unit "Sem_Ch3" is incompatible
3051 2. with GNAT.Sockets;
3052 3. procedure Secret_Stuff is
3056 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3057 compiler and is licensed under the
3058 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3059 run time, and is therefore licensed under the modified GPL@.
3061 @node Pragma Link_With
3062 @unnumberedsec Pragma Link_With
3067 @smallexample @c ada
3068 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3072 This pragma is provided for compatibility with certain Ada 83 compilers.
3073 It has exactly the same effect as pragma @code{Linker_Options} except
3074 that spaces occurring within one of the string expressions are treated
3075 as separators. For example, in the following case:
3077 @smallexample @c ada
3078 pragma Link_With ("-labc -ldef");
3082 results in passing the strings @code{-labc} and @code{-ldef} as two
3083 separate arguments to the linker. In addition pragma Link_With allows
3084 multiple arguments, with the same effect as successive pragmas.
3086 @node Pragma Linker_Alias
3087 @unnumberedsec Pragma Linker_Alias
3088 @findex Linker_Alias
3092 @smallexample @c ada
3093 pragma Linker_Alias (
3094 [Entity =>] LOCAL_NAME,
3095 [Target =>] static_string_EXPRESSION);
3099 @var{LOCAL_NAME} must refer to an object that is declared at the library
3100 level. This pragma establishes the given entity as a linker alias for the
3101 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3102 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3103 @var{static_string_EXPRESSION} in the object file, that is to say no space
3104 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3105 to the same address as @var{static_string_EXPRESSION} by the linker.
3107 The actual linker name for the target must be used (e.g.@: the fully
3108 encoded name with qualification in Ada, or the mangled name in C++),
3109 or it must be declared using the C convention with @code{pragma Import}
3110 or @code{pragma Export}.
3112 Not all target machines support this pragma. On some of them it is accepted
3113 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3115 @smallexample @c ada
3116 -- Example of the use of pragma Linker_Alias
3120 pragma Export (C, i);
3122 new_name_for_i : Integer;
3123 pragma Linker_Alias (new_name_for_i, "i");
3127 @node Pragma Linker_Constructor
3128 @unnumberedsec Pragma Linker_Constructor
3129 @findex Linker_Constructor
3133 @smallexample @c ada
3134 pragma Linker_Constructor (procedure_LOCAL_NAME);
3138 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3139 is declared at the library level. A procedure to which this pragma is
3140 applied will be treated as an initialization routine by the linker.
3141 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3142 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3143 of the executable is called (or immediately after the shared library is
3144 loaded if the procedure is linked in a shared library), in particular
3145 before the Ada run-time environment is set up.
3147 Because of these specific contexts, the set of operations such a procedure
3148 can perform is very limited and the type of objects it can manipulate is
3149 essentially restricted to the elementary types. In particular, it must only
3150 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3152 This pragma is used by GNAT to implement auto-initialization of shared Stand
3153 Alone Libraries, which provides a related capability without the restrictions
3154 listed above. Where possible, the use of Stand Alone Libraries is preferable
3155 to the use of this pragma.
3157 @node Pragma Linker_Destructor
3158 @unnumberedsec Pragma Linker_Destructor
3159 @findex Linker_Destructor
3163 @smallexample @c ada
3164 pragma Linker_Destructor (procedure_LOCAL_NAME);
3168 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3169 is declared at the library level. A procedure to which this pragma is
3170 applied will be treated as a finalization routine by the linker.
3171 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3172 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3173 of the executable has exited (or immediately before the shared library
3174 is unloaded if the procedure is linked in a shared library), in particular
3175 after the Ada run-time environment is shut down.
3177 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3178 because of these specific contexts.
3180 @node Pragma Linker_Section
3181 @unnumberedsec Pragma Linker_Section
3182 @findex Linker_Section
3186 @smallexample @c ada
3187 pragma Linker_Section (
3188 [Entity =>] LOCAL_NAME,
3189 [Section =>] static_string_EXPRESSION);
3193 @var{LOCAL_NAME} must refer to an object that is declared at the library
3194 level. This pragma specifies the name of the linker section for the given
3195 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3196 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3197 section of the executable (assuming the linker doesn't rename the section).
3199 The compiler normally places library-level objects in standard sections
3200 depending on their type: procedures and functions generally go in the
3201 @code{.text} section, initialized variables in the @code{.data} section
3202 and uninitialized variables in the @code{.bss} section.
3204 Other, special sections may exist on given target machines to map special
3205 hardware, for example I/O ports or flash memory. This pragma is a means to
3206 defer the final layout of the executable to the linker, thus fully working
3207 at the symbolic level with the compiler.
3209 Some file formats do not support arbitrary sections so not all target
3210 machines support this pragma. The use of this pragma may cause a program
3211 execution to be erroneous if it is used to place an entity into an
3212 inappropriate section (e.g.@: a modified variable into the @code{.text}
3213 section). See also @code{pragma Persistent_BSS}.
3215 @smallexample @c ada
3216 -- Example of the use of pragma Linker_Section
3220 pragma Volatile (Port_A);
3221 pragma Linker_Section (Port_A, ".bss.port_a");
3224 pragma Volatile (Port_B);
3225 pragma Linker_Section (Port_B, ".bss.port_b");
3229 @node Pragma Long_Float
3230 @unnumberedsec Pragma Long_Float
3236 @smallexample @c ada
3237 pragma Long_Float (FLOAT_FORMAT);
3239 FLOAT_FORMAT ::= D_Float | G_Float
3243 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3244 It allows control over the internal representation chosen for the predefined
3245 type @code{Long_Float} and for floating point type representations with
3246 @code{digits} specified in the range 7 through 15.
3247 For further details on this pragma, see the
3248 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3249 this pragma, the standard runtime libraries must be recompiled.
3250 @xref{The GNAT Run-Time Library Builder gnatlbr,,, gnat_ugn,
3251 @value{EDITION} User's Guide OpenVMS}, for a description of the
3252 @code{GNAT LIBRARY} command.
3254 @node Pragma Machine_Attribute
3255 @unnumberedsec Pragma Machine_Attribute
3256 @findex Machine_Attribute
3260 @smallexample @c ada
3261 pragma Machine_Attribute (
3262 [Entity =>] LOCAL_NAME,
3263 [Attribute_Name =>] static_string_EXPRESSION
3264 [, [Info =>] static_EXPRESSION] );
3268 Machine-dependent attributes can be specified for types and/or
3269 declarations. This pragma is semantically equivalent to
3270 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3271 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3272 in GNU C, where @code{@var{attribute_name}} is recognized by the
3273 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3274 specific macro. A string literal for the optional parameter @var{info}
3275 is transformed into an identifier, which may make this pragma unusable
3276 for some attributes. @xref{Target Attributes,, Defining target-specific
3277 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3278 Internals}, further information.
3281 @unnumberedsec Pragma Main
3287 @smallexample @c ada
3289 (MAIN_OPTION [, MAIN_OPTION]);
3292 [Stack_Size =>] static_integer_EXPRESSION
3293 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3294 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3298 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3299 no effect in GNAT, other than being syntax checked.
3301 @node Pragma Main_Storage
3302 @unnumberedsec Pragma Main_Storage
3304 @findex Main_Storage
3308 @smallexample @c ada
3310 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3312 MAIN_STORAGE_OPTION ::=
3313 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3314 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3318 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3319 no effect in GNAT, other than being syntax checked. Note that the pragma
3320 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3322 @node Pragma No_Body
3323 @unnumberedsec Pragma No_Body
3328 @smallexample @c ada
3333 There are a number of cases in which a package spec does not require a body,
3334 and in fact a body is not permitted. GNAT will not permit the spec to be
3335 compiled if there is a body around. The pragma No_Body allows you to provide
3336 a body file, even in a case where no body is allowed. The body file must
3337 contain only comments and a single No_Body pragma. This is recognized by
3338 the compiler as indicating that no body is logically present.
3340 This is particularly useful during maintenance when a package is modified in
3341 such a way that a body needed before is no longer needed. The provision of a
3342 dummy body with a No_Body pragma ensures that there is no interference from
3343 earlier versions of the package body.
3345 @node Pragma No_Return
3346 @unnumberedsec Pragma No_Return
3351 @smallexample @c ada
3352 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3356 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3357 declarations in the current declarative part. A procedure to which this
3358 pragma is applied may not contain any explicit @code{return} statements.
3359 In addition, if the procedure contains any implicit returns from falling
3360 off the end of a statement sequence, then execution of that implicit
3361 return will cause Program_Error to be raised.
3363 One use of this pragma is to identify procedures whose only purpose is to raise
3364 an exception. Another use of this pragma is to suppress incorrect warnings
3365 about missing returns in functions, where the last statement of a function
3366 statement sequence is a call to such a procedure.
3368 Note that in Ada 2005 mode, this pragma is part of the language, and is
3369 identical in effect to the pragma as implemented in Ada 95 mode.
3371 @node Pragma No_Strict_Aliasing
3372 @unnumberedsec Pragma No_Strict_Aliasing
3373 @findex No_Strict_Aliasing
3377 @smallexample @c ada
3378 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3382 @var{type_LOCAL_NAME} must refer to an access type
3383 declaration in the current declarative part. The effect is to inhibit
3384 strict aliasing optimization for the given type. The form with no
3385 arguments is a configuration pragma which applies to all access types
3386 declared in units to which the pragma applies. For a detailed
3387 description of the strict aliasing optimization, and the situations
3388 in which it must be suppressed, see @ref{Optimization and Strict
3389 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3391 @node Pragma Normalize_Scalars
3392 @unnumberedsec Pragma Normalize_Scalars
3393 @findex Normalize_Scalars
3397 @smallexample @c ada
3398 pragma Normalize_Scalars;
3402 This is a language defined pragma which is fully implemented in GNAT@. The
3403 effect is to cause all scalar objects that are not otherwise initialized
3404 to be initialized. The initial values are implementation dependent and
3408 @item Standard.Character
3410 Objects whose root type is Standard.Character are initialized to
3411 Character'Last unless the subtype range excludes NUL (in which case
3412 NUL is used). This choice will always generate an invalid value if
3415 @item Standard.Wide_Character
3417 Objects whose root type is Standard.Wide_Character are initialized to
3418 Wide_Character'Last unless the subtype range excludes NUL (in which case
3419 NUL is used). This choice will always generate an invalid value if
3422 @item Standard.Wide_Wide_Character
3424 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3425 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3426 which case NUL is used). This choice will always generate an invalid value if
3431 Objects of an integer type are treated differently depending on whether
3432 negative values are present in the subtype. If no negative values are
3433 present, then all one bits is used as the initial value except in the
3434 special case where zero is excluded from the subtype, in which case
3435 all zero bits are used. This choice will always generate an invalid
3436 value if one exists.
3438 For subtypes with negative values present, the largest negative number
3439 is used, except in the unusual case where this largest negative number
3440 is in the subtype, and the largest positive number is not, in which case
3441 the largest positive value is used. This choice will always generate
3442 an invalid value if one exists.
3444 @item Floating-Point Types
3445 Objects of all floating-point types are initialized to all 1-bits. For
3446 standard IEEE format, this corresponds to a NaN (not a number) which is
3447 indeed an invalid value.
3449 @item Fixed-Point Types
3450 Objects of all fixed-point types are treated as described above for integers,
3451 with the rules applying to the underlying integer value used to represent
3452 the fixed-point value.
3455 Objects of a modular type are initialized to all one bits, except in
3456 the special case where zero is excluded from the subtype, in which
3457 case all zero bits are used. This choice will always generate an
3458 invalid value if one exists.
3460 @item Enumeration types
3461 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3462 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3463 whose Pos value is zero, in which case a code of zero is used. This choice
3464 will always generate an invalid value if one exists.
3468 @node Pragma Obsolescent
3469 @unnumberedsec Pragma Obsolescent
3474 @smallexample @c ada
3477 pragma Obsolescent (
3478 [Message =>] static_string_EXPRESSION
3479 [,[Version =>] Ada_05]]);
3481 pragma Obsolescent (
3483 [,[Message =>] static_string_EXPRESSION
3484 [,[Version =>] Ada_05]] );
3488 This pragma can occur immediately following a declaration of an entity,
3489 including the case of a record component. If no Entity argument is present,
3490 then this declaration is the one to which the pragma applies. If an Entity
3491 parameter is present, it must either match the name of the entity in this
3492 declaration, or alternatively, the pragma can immediately follow an enumeration
3493 type declaration, where the Entity argument names one of the enumeration
3496 This pragma is used to indicate that the named entity
3497 is considered obsolescent and should not be used. Typically this is
3498 used when an API must be modified by eventually removing or modifying
3499 existing subprograms or other entities. The pragma can be used at an
3500 intermediate stage when the entity is still present, but will be
3503 The effect of this pragma is to output a warning message on a reference to
3504 an entity thus marked that the subprogram is obsolescent if the appropriate
3505 warning option in the compiler is activated. If the Message parameter is
3506 present, then a second warning message is given containing this text. In
3507 addition, a reference to the eneity is considered to be a violation of pragma
3508 Restrictions (No_Obsolescent_Features).
3510 This pragma can also be used as a program unit pragma for a package,
3511 in which case the entity name is the name of the package, and the
3512 pragma indicates that the entire package is considered
3513 obsolescent. In this case a client @code{with}'ing such a package
3514 violates the restriction, and the @code{with} statement is
3515 flagged with warnings if the warning option is set.
3517 If the Version parameter is present (which must be exactly
3518 the identifier Ada_05, no other argument is allowed), then the
3519 indication of obsolescence applies only when compiling in Ada 2005
3520 mode. This is primarily intended for dealing with the situations
3521 in the predefined library where subprograms or packages
3522 have become defined as obsolescent in Ada 2005
3523 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3525 The following examples show typical uses of this pragma:
3527 @smallexample @c ada
3529 pragma Obsolescent (p, Message => "use pp instead of p");
3534 pragma Obsolescent ("use q2new instead");
3536 type R is new integer;
3539 Message => "use RR in Ada 2005",
3549 type E is (a, bc, 'd', quack);
3550 pragma Obsolescent (Entity => bc)
3551 pragma Obsolescent (Entity => 'd')
3554 (a, b : character) return character;
3555 pragma Obsolescent (Entity => "+");
3560 Note that, as for all pragmas, if you use a pragma argument identifier,
3561 then all subsequent parameters must also use a pragma argument identifier.
3562 So if you specify "Entity =>" for the Entity argument, and a Message
3563 argument is present, it must be preceded by "Message =>".
3565 @node Pragma Optimize_Alignment
3566 @unnumberedsec Pragma Optimize_Alignment
3567 @findex Optimize_Alignment
3568 @cindex Alignment, default settings
3572 @smallexample @c ada
3573 pragma Optimize_Alignment (TIME | SPACE | OFF);
3577 This is a configuration pragma which affects the choice of default alignments
3578 for types where no alignment is explicitly specified. There is a time/space
3579 trade-off in the selection of these values. Large alignments result in more
3580 efficient code, at the expense of larger data space, since sizes have to be
3581 increased to match these alignments. Smaller alignments save space, but the
3582 access code is slower. The normal choice of default alignments (which is what
3583 you get if you do not use this pragma, or if you use an argument of OFF),
3584 tries to balance these two requirements.
3586 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3587 First any packed record is given an alignment of 1. Second, if a size is given
3588 for the type, then the alignment is chosen to avoid increasing this size. For
3591 @smallexample @c ada
3601 In the default mode, this type gets an alignment of 4, so that access to the
3602 Integer field X are efficient. But this means that objects of the type end up
3603 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3604 allowed to be bigger than the size of the type, but it can waste space if for
3605 example fields of type R appear in an enclosing record. If the above type is
3606 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3608 Specifying TIME causes larger default alignments to be chosen in the case of
3609 small types with sizes that are not a power of 2. For example, consider:
3611 @smallexample @c ada
3623 The default alignment for this record is normally 1, but if this type is
3624 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3625 to 4, which wastes space for objects of the type, since they are now 4 bytes
3626 long, but results in more efficient access when the whole record is referenced.
3628 As noted above, this is a configuration pragma, and there is a requirement
3629 that all units in a partition be compiled with a consistent setting of the
3630 optimization setting. This would normally be achieved by use of a configuration
3631 pragma file containing the appropriate setting. The exception to this rule is
3632 that units with an explicit configuration pragma in the same file as the source
3633 unit are excluded from the consistency check, as are all predefined units. The
3634 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3635 pragma appears at the start of the file.
3637 @node Pragma Passive
3638 @unnumberedsec Pragma Passive
3643 @smallexample @c ada
3644 pragma Passive [(Semaphore | No)];
3648 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3649 compatibility with DEC Ada 83 implementations, where it is used within a
3650 task definition to request that a task be made passive. If the argument
3651 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3652 treats the pragma as an assertion that the containing task is passive
3653 and that optimization of context switch with this task is permitted and
3654 desired. If the argument @code{No} is present, the task must not be
3655 optimized. GNAT does not attempt to optimize any tasks in this manner
3656 (since protected objects are available in place of passive tasks).
3658 @node Pragma Persistent_BSS
3659 @unnumberedsec Pragma Persistent_BSS
3660 @findex Persistent_BSS
3664 @smallexample @c ada
3665 pragma Persistent_BSS [(LOCAL_NAME)]
3669 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3670 section. On some targets the linker and loader provide for special
3671 treatment of this section, allowing a program to be reloaded without
3672 affecting the contents of this data (hence the name persistent).
3674 There are two forms of usage. If an argument is given, it must be the
3675 local name of a library level object, with no explicit initialization
3676 and whose type is potentially persistent. If no argument is given, then
3677 the pragma is a configuration pragma, and applies to all library level
3678 objects with no explicit initialization of potentially persistent types.
3680 A potentially persistent type is a scalar type, or a non-tagged,
3681 non-discriminated record, all of whose components have no explicit
3682 initialization and are themselves of a potentially persistent type,
3683 or an array, all of whose constraints are static, and whose component
3684 type is potentially persistent.
3686 If this pragma is used on a target where this feature is not supported,
3687 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3689 @node Pragma Polling
3690 @unnumberedsec Pragma Polling
3695 @smallexample @c ada
3696 pragma Polling (ON | OFF);
3700 This pragma controls the generation of polling code. This is normally off.
3701 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3702 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3703 runtime library, and can be found in file @file{a-excpol.adb}.
3705 Pragma @code{Polling} can appear as a configuration pragma (for example it
3706 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3707 can be used in the statement or declaration sequence to control polling
3710 A call to the polling routine is generated at the start of every loop and
3711 at the start of every subprogram call. This guarantees that the @code{Poll}
3712 routine is called frequently, and places an upper bound (determined by
3713 the complexity of the code) on the period between two @code{Poll} calls.
3715 The primary purpose of the polling interface is to enable asynchronous
3716 aborts on targets that cannot otherwise support it (for example Windows
3717 NT), but it may be used for any other purpose requiring periodic polling.
3718 The standard version is null, and can be replaced by a user program. This
3719 will require re-compilation of the @code{Ada.Exceptions} package that can
3720 be found in files @file{a-except.ads} and @file{a-except.adb}.
3722 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3723 distribution) is used to enable the asynchronous abort capability on
3724 targets that do not normally support the capability. The version of
3725 @code{Poll} in this file makes a call to the appropriate runtime routine
3726 to test for an abort condition.
3728 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3729 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3732 @node Pragma Postcondition
3733 @unnumberedsec Pragma Postcondition
3734 @cindex Postconditions
3735 @cindex Checks, postconditions
3736 @findex Postconditions
3740 @smallexample @c ada
3741 pragma Postcondition (
3742 [Check =>] Boolean_Expression
3743 [,[Message =>] String_Expression]);
3747 The @code{Postcondition} pragma allows specification of automatic
3748 postcondition checks for subprograms. These checks are similar to
3749 assertions, but are automatically inserted just prior to the return
3750 statements of the subprogram with which they are associated (including
3751 implicit returns at the end of procedure bodies and associated
3752 exception handlers).
3754 In addition, the boolean expression which is the condition which
3755 must be true may contain references to function'Result in the case
3756 of a function to refer to the returned value.
3758 @code{Postcondition} pragmas may appear either immediate following the
3759 (separate) declaration of a subprogram, or at the start of the
3760 declarations of a subprogram body. Only other pragmas may intervene
3761 (that is appear between the subprogram declaration and its
3762 postconditions, or appear before the postcondition in the
3763 declaration sequence in a subprogram body). In the case of a
3764 postcondition appearing after a subprogram declaration, the
3765 formal arguments of the subprogram are visible, and can be
3766 referenced in the postcondition expressions.
3768 The postconditions are collected and automatically tested just
3769 before any return (implicit or explicit) in the subprogram body.
3770 A postcondition is only recognized if postconditions are active
3771 at the time the pragma is encountered. The compiler switch @option{gnata}
3772 turns on all postconditions by default, and pragma @code{Check_Policy}
3773 with an identifier of @code{Postcondition} can also be used to
3774 control whether postconditions are active.
3776 The general approach is that postconditions are placed in the spec
3777 if they represent functional aspects which make sense to the client.
3778 For example we might have:
3780 @smallexample @c ada
3781 function Direction return Integer;
3782 pragma Postcondition
3783 (Direction'Result = +1
3785 Direction'Result = -1);
3789 which serves to document that the result must be +1 or -1, and
3790 will test that this is the case at run time if postcondition
3793 Postconditions within the subprogram body can be used to
3794 check that some internal aspect of the implementation,
3795 not visible to the client, is operating as expected.
3796 For instance if a square root routine keeps an internal
3797 counter of the number of times it is called, then we
3798 might have the following postcondition:
3800 @smallexample @c ada
3801 Sqrt_Calls : Natural := 0;
3803 function Sqrt (Arg : Float) return Float is
3804 pragma Postcondition
3805 (Sqrt_Calls = Sqrt_Calls'Old + 1);
3811 As this example, shows, the use of the @code{Old} attribute
3812 is often useful in postconditions to refer to the state on
3813 entry to the subprogram.
3815 Note that postconditions are only checked on normal returns
3816 from the subprogram. If an abnormal return results from
3817 raising an exception, then the postconditions are not checked.
3819 If a postcondition fails, then the exception
3820 @code{System.Assertions.Assert_Failure} is raised. If
3821 a message argument was supplied, then the given string
3822 will be used as the exception message. If no message
3823 argument was supplied, then the default message has
3824 the form "Postcondition failed at file:line". The
3825 exception is raised in the context of the subprogram
3826 body, so it is possible to catch postcondition failures
3827 within the subprogram body itself.
3829 Within a package spec, normal visibility rules
3830 in Ada would prevent forward references within a
3831 postcondition pragma to functions defined later in
3832 the same package. This would introduce undesirable
3833 ordering constraints. To avoid this problem, all
3834 postcondition pragmas are analyzed at the end of
3835 the package spec, allowing forward references.
3837 The following example shows that this even allows
3838 mutually recursive postconditions as in:
3840 @smallexample @c ada
3841 package Parity_Functions is
3842 function Odd (X : Natural) return Boolean;
3843 pragma Postcondition
3847 (x /= 0 and then Even (X - 1))));
3849 function Even (X : Natural) return Boolean;
3850 pragma Postcondition
3854 (x /= 1 and then Odd (X - 1))));
3856 end Parity_Functions;
3860 There are no restrictions on the complexity or form of
3861 conditions used within @code{Postcondition} pragmas.
3862 The following example shows that it is even possible
3863 to verify performance behavior.
3865 @smallexample @c ada
3868 Performance : constant Float;
3869 -- Performance constant set by implementation
3870 -- to match target architecture behavior.
3872 procedure Treesort (Arg : String);
3873 -- Sorts characters of argument using N*logN sort
3874 pragma Postcondition
3875 (Float (Clock - Clock'Old) <=
3876 Float (Arg'Length) *
3877 log (Float (Arg'Length)) *
3883 Note: postcondition pragmas associated with subprograms that are
3884 marked as Inline_Always, or those marked as Inline with front-end
3885 inlining (-gnatN option set) are accepted and legality-checked
3886 by the compiler, but are ignored at run-time even if postcondition
3887 checking is enabled.
3889 @node Pragma Precondition
3890 @unnumberedsec Pragma Precondition
3891 @cindex Preconditions
3892 @cindex Checks, preconditions
3893 @findex Preconditions
3897 @smallexample @c ada
3898 pragma Precondition (
3899 [Check =>] Boolean_Expression
3900 [,[Message =>] String_Expression]);
3904 The @code{Precondition} pragma is similar to @code{Postcondition}
3905 except that the corresponding checks take place immediately upon
3906 entry to the subprogram, and if a precondition fails, the exception
3907 is raised in the context of the caller, and the attribute 'Result
3908 cannot be used within the precondition expression.
3910 Otherwise, the placement and visibility rules are identical to those
3911 described for postconditions. The following is an example of use
3912 within a package spec:
3914 @smallexample @c ada
3915 package Math_Functions is
3917 function Sqrt (Arg : Float) return Float;
3918 pragma Precondition (Arg >= 0.0)
3924 @code{Precondition} pragmas may appear either immediate following the
3925 (separate) declaration of a subprogram, or at the start of the
3926 declarations of a subprogram body. Only other pragmas may intervene
3927 (that is appear between the subprogram declaration and its
3928 postconditions, or appear before the postcondition in the
3929 declaration sequence in a subprogram body).
3931 Note: postcondition pragmas associated with subprograms that are
3932 marked as Inline_Always, or those marked as Inline with front-end
3933 inlining (-gnatN option set) are accepted and legality-checked
3934 by the compiler, but are ignored at run-time even if postcondition
3935 checking is enabled.
3939 @node Pragma Profile (Ravenscar)
3940 @unnumberedsec Pragma Profile (Ravenscar)
3945 @smallexample @c ada
3946 pragma Profile (Ravenscar);
3950 A configuration pragma that establishes the following set of configuration
3954 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3955 [RM D.2.2] Tasks are dispatched following a preemptive
3956 priority-ordered scheduling policy.
3958 @item Locking_Policy (Ceiling_Locking)
3959 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3960 the ceiling priority of the corresponding protected object.
3962 @c @item Detect_Blocking
3963 @c This pragma forces the detection of potentially blocking operations within a
3964 @c protected operation, and to raise Program_Error if that happens.
3968 plus the following set of restrictions:
3971 @item Max_Entry_Queue_Length = 1
3972 Defines the maximum number of calls that are queued on a (protected) entry.
3973 Note that this restrictions is checked at run time. Violation of this
3974 restriction results in the raising of Program_Error exception at the point of
3975 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3976 always 1 and hence no task can be queued on a protected entry.
3978 @item Max_Protected_Entries = 1
3979 [RM D.7] Specifies the maximum number of entries per protected type. The
3980 bounds of every entry family of a protected unit shall be static, or shall be
3981 defined by a discriminant of a subtype whose corresponding bound is static.
3982 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3984 @item Max_Task_Entries = 0
3985 [RM D.7] Specifies the maximum number of entries
3986 per task. The bounds of every entry family
3987 of a task unit shall be static, or shall be
3988 defined by a discriminant of a subtype whose
3989 corresponding bound is static. A value of zero
3990 indicates that no rendezvous are possible. For
3991 the Profile (Ravenscar), the value of Max_Task_Entries is always
3994 @item No_Abort_Statements
3995 [RM D.7] There are no abort_statements, and there are
3996 no calls to Task_Identification.Abort_Task.
3998 @item No_Asynchronous_Control
3999 There are no semantic dependences on the package
4000 Asynchronous_Task_Control.
4003 There are no semantic dependencies on the package Ada.Calendar.
4005 @item No_Dynamic_Attachment
4006 There is no call to any of the operations defined in package Ada.Interrupts
4007 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
4008 Detach_Handler, and Reference).
4010 @item No_Dynamic_Priorities
4011 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
4013 @item No_Implicit_Heap_Allocations
4014 [RM D.7] No constructs are allowed to cause implicit heap allocation.
4016 @item No_Local_Protected_Objects
4017 Protected objects and access types that designate
4018 such objects shall be declared only at library level.
4020 @item No_Local_Timing_Events
4021 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4022 declared at the library level.
4024 @item No_Protected_Type_Allocators
4025 There are no allocators for protected types or
4026 types containing protected subcomponents.
4028 @item No_Relative_Delay
4029 There are no delay_relative statements.
4031 @item No_Requeue_Statements
4032 Requeue statements are not allowed.
4034 @item No_Select_Statements
4035 There are no select_statements.
4037 @item No_Specific_Termination_Handlers
4038 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4039 or to Ada.Task_Termination.Specific_Handler.
4041 @item No_Task_Allocators
4042 [RM D.7] There are no allocators for task types
4043 or types containing task subcomponents.
4045 @item No_Task_Attributes_Package
4046 There are no semantic dependencies on the Ada.Task_Attributes package.
4048 @item No_Task_Hierarchy
4049 [RM D.7] All (non-environment) tasks depend
4050 directly on the environment task of the partition.
4052 @item No_Task_Termination
4053 Tasks which terminate are erroneous.
4055 @item No_Unchecked_Conversion
4056 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
4058 @item No_Unchecked_Deallocation
4059 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
4061 @item Simple_Barriers
4062 Entry barrier condition expressions shall be either static
4063 boolean expressions or boolean objects which are declared in
4064 the protected type which contains the entry.
4068 This set of configuration pragmas and restrictions correspond to the
4069 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4070 published by the @cite{International Real-Time Ada Workshop}, 1997,
4071 and whose most recent description is available at
4072 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4074 The original definition of the profile was revised at subsequent IRTAW
4075 meetings. It has been included in the ISO
4076 @cite{Guide for the Use of the Ada Programming Language in High
4077 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4078 the next revision of the standard. The formal definition given by
4079 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4080 AI-305) available at
4081 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
4082 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
4085 The above set is a superset of the restrictions provided by pragma
4086 @code{Profile (Restricted)}, it includes six additional restrictions
4087 (@code{Simple_Barriers}, @code{No_Select_Statements},
4088 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4089 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4090 that pragma @code{Profile (Ravenscar)}, like the pragma
4091 @code{Profile (Restricted)},
4092 automatically causes the use of a simplified,
4093 more efficient version of the tasking run-time system.
4095 @node Pragma Profile (Restricted)
4096 @unnumberedsec Pragma Profile (Restricted)
4097 @findex Restricted Run Time
4101 @smallexample @c ada
4102 pragma Profile (Restricted);
4106 A configuration pragma that establishes the following set of restrictions:
4109 @item No_Abort_Statements
4110 @item No_Entry_Queue
4111 @item No_Task_Hierarchy
4112 @item No_Task_Allocators
4113 @item No_Dynamic_Priorities
4114 @item No_Terminate_Alternatives
4115 @item No_Dynamic_Attachment
4116 @item No_Protected_Type_Allocators
4117 @item No_Local_Protected_Objects
4118 @item No_Requeue_Statements
4119 @item No_Task_Attributes_Package
4120 @item Max_Asynchronous_Select_Nesting = 0
4121 @item Max_Task_Entries = 0
4122 @item Max_Protected_Entries = 1
4123 @item Max_Select_Alternatives = 0
4127 This set of restrictions causes the automatic selection of a simplified
4128 version of the run time that provides improved performance for the
4129 limited set of tasking functionality permitted by this set of restrictions.
4131 @node Pragma Psect_Object
4132 @unnumberedsec Pragma Psect_Object
4133 @findex Psect_Object
4137 @smallexample @c ada
4138 pragma Psect_Object (
4139 [Internal =>] LOCAL_NAME,
4140 [, [External =>] EXTERNAL_SYMBOL]
4141 [, [Size =>] EXTERNAL_SYMBOL]);
4145 | static_string_EXPRESSION
4149 This pragma is identical in effect to pragma @code{Common_Object}.
4151 @node Pragma Pure_Function
4152 @unnumberedsec Pragma Pure_Function
4153 @findex Pure_Function
4157 @smallexample @c ada
4158 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4162 This pragma appears in the same declarative part as a function
4163 declaration (or a set of function declarations if more than one
4164 overloaded declaration exists, in which case the pragma applies
4165 to all entities). It specifies that the function @code{Entity} is
4166 to be considered pure for the purposes of code generation. This means
4167 that the compiler can assume that there are no side effects, and
4168 in particular that two calls with identical arguments produce the
4169 same result. It also means that the function can be used in an
4172 Note that, quite deliberately, there are no static checks to try
4173 to ensure that this promise is met, so @code{Pure_Function} can be used
4174 with functions that are conceptually pure, even if they do modify
4175 global variables. For example, a square root function that is
4176 instrumented to count the number of times it is called is still
4177 conceptually pure, and can still be optimized, even though it
4178 modifies a global variable (the count). Memo functions are another
4179 example (where a table of previous calls is kept and consulted to
4180 avoid re-computation).
4183 Note: Most functions in a @code{Pure} package are automatically pure, and
4184 there is no need to use pragma @code{Pure_Function} for such functions. One
4185 exception is any function that has at least one formal of type
4186 @code{System.Address} or a type derived from it. Such functions are not
4187 considered pure by default, since the compiler assumes that the
4188 @code{Address} parameter may be functioning as a pointer and that the
4189 referenced data may change even if the address value does not.
4190 Similarly, imported functions are not considered to be pure by default,
4191 since there is no way of checking that they are in fact pure. The use
4192 of pragma @code{Pure_Function} for such a function will override these default
4193 assumption, and cause the compiler to treat a designated subprogram as pure
4196 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4197 applies to the underlying renamed function. This can be used to
4198 disambiguate cases of overloading where some but not all functions
4199 in a set of overloaded functions are to be designated as pure.
4201 If pragma @code{Pure_Function} is applied to a library level function, the
4202 function is also considered pure from an optimization point of view, but the
4203 unit is not a Pure unit in the categorization sense. So for example, a function
4204 thus marked is free to @code{with} non-pure units.
4206 @node Pragma Restriction_Warnings
4207 @unnumberedsec Pragma Restriction_Warnings
4208 @findex Restriction_Warnings
4212 @smallexample @c ada
4213 pragma Restriction_Warnings
4214 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4218 This pragma allows a series of restriction identifiers to be
4219 specified (the list of allowed identifiers is the same as for
4220 pragma @code{Restrictions}). For each of these identifiers
4221 the compiler checks for violations of the restriction, but
4222 generates a warning message rather than an error message
4223 if the restriction is violated.
4226 @unnumberedsec Pragma Shared
4230 This pragma is provided for compatibility with Ada 83. The syntax and
4231 semantics are identical to pragma Atomic.
4233 @node Pragma Source_File_Name
4234 @unnumberedsec Pragma Source_File_Name
4235 @findex Source_File_Name
4239 @smallexample @c ada
4240 pragma Source_File_Name (
4241 [Unit_Name =>] unit_NAME,
4242 Spec_File_Name => STRING_LITERAL,
4243 [Index => INTEGER_LITERAL]);
4245 pragma Source_File_Name (
4246 [Unit_Name =>] unit_NAME,
4247 Body_File_Name => STRING_LITERAL,
4248 [Index => INTEGER_LITERAL]);
4252 Use this to override the normal naming convention. It is a configuration
4253 pragma, and so has the usual applicability of configuration pragmas
4254 (i.e.@: it applies to either an entire partition, or to all units in a
4255 compilation, or to a single unit, depending on how it is used.
4256 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4257 the second argument is required, and indicates whether this is the file
4258 name for the spec or for the body.
4260 The optional Index argument should be used when a file contains multiple
4261 units, and when you do not want to use @code{gnatchop} to separate then
4262 into multiple files (which is the recommended procedure to limit the
4263 number of recompilation that are needed when some sources change).
4264 For instance, if the source file @file{source.ada} contains
4266 @smallexample @c ada
4278 you could use the following configuration pragmas:
4280 @smallexample @c ada
4281 pragma Source_File_Name
4282 (B, Spec_File_Name => "source.ada", Index => 1);
4283 pragma Source_File_Name
4284 (A, Body_File_Name => "source.ada", Index => 2);
4287 Note that the @code{gnatname} utility can also be used to generate those
4288 configuration pragmas.
4290 Another form of the @code{Source_File_Name} pragma allows
4291 the specification of patterns defining alternative file naming schemes
4292 to apply to all files.
4294 @smallexample @c ada
4295 pragma Source_File_Name
4296 ( [Spec_File_Name =>] STRING_LITERAL
4297 [,[Casing =>] CASING_SPEC]
4298 [,[Dot_Replacement =>] STRING_LITERAL]);
4300 pragma Source_File_Name
4301 ( [Body_File_Name =>] STRING_LITERAL
4302 [,[Casing =>] CASING_SPEC]
4303 [,[Dot_Replacement =>] STRING_LITERAL]);
4305 pragma Source_File_Name
4306 ( [Subunit_File_Name =>] STRING_LITERAL
4307 [,[Casing =>] CASING_SPEC]
4308 [,[Dot_Replacement =>] STRING_LITERAL]);
4310 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4314 The first argument is a pattern that contains a single asterisk indicating
4315 the point at which the unit name is to be inserted in the pattern string
4316 to form the file name. The second argument is optional. If present it
4317 specifies the casing of the unit name in the resulting file name string.
4318 The default is lower case. Finally the third argument allows for systematic
4319 replacement of any dots in the unit name by the specified string literal.
4321 A pragma Source_File_Name cannot appear after a
4322 @ref{Pragma Source_File_Name_Project}.
4324 For more details on the use of the @code{Source_File_Name} pragma,
4325 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4326 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4329 @node Pragma Source_File_Name_Project
4330 @unnumberedsec Pragma Source_File_Name_Project
4331 @findex Source_File_Name_Project
4334 This pragma has the same syntax and semantics as pragma Source_File_Name.
4335 It is only allowed as a stand alone configuration pragma.
4336 It cannot appear after a @ref{Pragma Source_File_Name}, and
4337 most importantly, once pragma Source_File_Name_Project appears,
4338 no further Source_File_Name pragmas are allowed.
4340 The intention is that Source_File_Name_Project pragmas are always
4341 generated by the Project Manager in a manner consistent with the naming
4342 specified in a project file, and when naming is controlled in this manner,
4343 it is not permissible to attempt to modify this naming scheme using
4344 Source_File_Name pragmas (which would not be known to the project manager).
4346 @node Pragma Source_Reference
4347 @unnumberedsec Pragma Source_Reference
4348 @findex Source_Reference
4352 @smallexample @c ada
4353 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4357 This pragma must appear as the first line of a source file.
4358 @var{integer_literal} is the logical line number of the line following
4359 the pragma line (for use in error messages and debugging
4360 information). @var{string_literal} is a static string constant that
4361 specifies the file name to be used in error messages and debugging
4362 information. This is most notably used for the output of @code{gnatchop}
4363 with the @option{-r} switch, to make sure that the original unchopped
4364 source file is the one referred to.
4366 The second argument must be a string literal, it cannot be a static
4367 string expression other than a string literal. This is because its value
4368 is needed for error messages issued by all phases of the compiler.
4370 @node Pragma Stream_Convert
4371 @unnumberedsec Pragma Stream_Convert
4372 @findex Stream_Convert
4376 @smallexample @c ada
4377 pragma Stream_Convert (
4378 [Entity =>] type_LOCAL_NAME,
4379 [Read =>] function_NAME,
4380 [Write =>] function_NAME);
4384 This pragma provides an efficient way of providing stream functions for
4385 types defined in packages. Not only is it simpler to use than declaring
4386 the necessary functions with attribute representation clauses, but more
4387 significantly, it allows the declaration to made in such a way that the
4388 stream packages are not loaded unless they are needed. The use of
4389 the Stream_Convert pragma adds no overhead at all, unless the stream
4390 attributes are actually used on the designated type.
4392 The first argument specifies the type for which stream functions are
4393 provided. The second parameter provides a function used to read values
4394 of this type. It must name a function whose argument type may be any
4395 subtype, and whose returned type must be the type given as the first
4396 argument to the pragma.
4398 The meaning of the @var{Read}
4399 parameter is that if a stream attribute directly
4400 or indirectly specifies reading of the type given as the first parameter,
4401 then a value of the type given as the argument to the Read function is
4402 read from the stream, and then the Read function is used to convert this
4403 to the required target type.
4405 Similarly the @var{Write} parameter specifies how to treat write attributes
4406 that directly or indirectly apply to the type given as the first parameter.
4407 It must have an input parameter of the type specified by the first parameter,
4408 and the return type must be the same as the input type of the Read function.
4409 The effect is to first call the Write function to convert to the given stream
4410 type, and then write the result type to the stream.
4412 The Read and Write functions must not be overloaded subprograms. If necessary
4413 renamings can be supplied to meet this requirement.
4414 The usage of this attribute is best illustrated by a simple example, taken
4415 from the GNAT implementation of package Ada.Strings.Unbounded:
4417 @smallexample @c ada
4418 function To_Unbounded (S : String)
4419 return Unbounded_String
4420 renames To_Unbounded_String;
4422 pragma Stream_Convert
4423 (Unbounded_String, To_Unbounded, To_String);
4427 The specifications of the referenced functions, as given in the Ada
4428 Reference Manual are:
4430 @smallexample @c ada
4431 function To_Unbounded_String (Source : String)
4432 return Unbounded_String;
4434 function To_String (Source : Unbounded_String)
4439 The effect is that if the value of an unbounded string is written to a stream,
4440 then the representation of the item in the stream is in the same format that
4441 would be used for @code{Standard.String'Output}, and this same representation
4442 is expected when a value of this type is read from the stream. Note that the
4443 value written always includes the bounds, even for Unbounded_String'Write,
4444 since Unbounded_String is not an array type.
4446 @node Pragma Style_Checks
4447 @unnumberedsec Pragma Style_Checks
4448 @findex Style_Checks
4452 @smallexample @c ada
4453 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4454 On | Off [, LOCAL_NAME]);
4458 This pragma is used in conjunction with compiler switches to control the
4459 built in style checking provided by GNAT@. The compiler switches, if set,
4460 provide an initial setting for the switches, and this pragma may be used
4461 to modify these settings, or the settings may be provided entirely by
4462 the use of the pragma. This pragma can be used anywhere that a pragma
4463 is legal, including use as a configuration pragma (including use in
4464 the @file{gnat.adc} file).
4466 The form with a string literal specifies which style options are to be
4467 activated. These are additive, so they apply in addition to any previously
4468 set style check options. The codes for the options are the same as those
4469 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4470 For example the following two methods can be used to enable
4475 @smallexample @c ada
4476 pragma Style_Checks ("l");
4481 gcc -c -gnatyl @dots{}
4486 The form ALL_CHECKS activates all standard checks (its use is equivalent
4487 to the use of the @code{gnaty} switch with no options. @xref{Top,
4488 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4489 @value{EDITION} User's Guide}, for details.
4491 The forms with @code{Off} and @code{On}
4492 can be used to temporarily disable style checks
4493 as shown in the following example:
4495 @smallexample @c ada
4499 pragma Style_Checks ("k"); -- requires keywords in lower case
4500 pragma Style_Checks (Off); -- turn off style checks
4501 NULL; -- this will not generate an error message
4502 pragma Style_Checks (On); -- turn style checks back on
4503 NULL; -- this will generate an error message
4507 Finally the two argument form is allowed only if the first argument is
4508 @code{On} or @code{Off}. The effect is to turn of semantic style checks
4509 for the specified entity, as shown in the following example:
4511 @smallexample @c ada
4515 pragma Style_Checks ("r"); -- require consistency of identifier casing
4517 Rf1 : Integer := ARG; -- incorrect, wrong case
4518 pragma Style_Checks (Off, Arg);
4519 Rf2 : Integer := ARG; -- OK, no error
4522 @node Pragma Subtitle
4523 @unnumberedsec Pragma Subtitle
4528 @smallexample @c ada
4529 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4533 This pragma is recognized for compatibility with other Ada compilers
4534 but is ignored by GNAT@.
4536 @node Pragma Suppress
4537 @unnumberedsec Pragma Suppress
4542 @smallexample @c ada
4543 pragma Suppress (Identifier [, [On =>] Name]);
4547 This is a standard pragma, and supports all the check names required in
4548 the RM. It is included here because GNAT recognizes one additional check
4549 name: @code{Alignment_Check} which can be used to suppress alignment checks
4550 on addresses used in address clauses. Such checks can also be suppressed
4551 by suppressing range checks, but the specific use of @code{Alignment_Check}
4552 allows suppression of alignment checks without suppressing other range checks.
4554 Note that pragma Suppress gives the compiler permission to omit
4555 checks, but does not require the compiler to omit checks. The compiler
4556 will generate checks if they are essentially free, even when they are
4557 suppressed. In particular, if the compiler can prove that a certain
4558 check will necessarily fail, it will generate code to do an
4559 unconditional ``raise'', even if checks are suppressed. The compiler
4562 Of course, run-time checks are omitted whenever the compiler can prove
4563 that they will not fail, whether or not checks are suppressed.
4565 @node Pragma Suppress_All
4566 @unnumberedsec Pragma Suppress_All
4567 @findex Suppress_All
4571 @smallexample @c ada
4572 pragma Suppress_All;
4576 This pragma can only appear immediately following a compilation
4577 unit. The effect is to apply @code{Suppress (All_Checks)} to the unit
4578 which it follows. This pragma is implemented for compatibility with DEC
4579 Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal
4580 configuration pragma is the preferred usage in GNAT@.
4582 @node Pragma Suppress_Exception_Locations
4583 @unnumberedsec Pragma Suppress_Exception_Locations
4584 @findex Suppress_Exception_Locations
4588 @smallexample @c ada
4589 pragma Suppress_Exception_Locations;
4593 In normal mode, a raise statement for an exception by default generates
4594 an exception message giving the file name and line number for the location
4595 of the raise. This is useful for debugging and logging purposes, but this
4596 entails extra space for the strings for the messages. The configuration
4597 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4598 generation of these strings, with the result that space is saved, but the
4599 exception message for such raises is null. This configuration pragma may
4600 appear in a global configuration pragma file, or in a specific unit as
4601 usual. It is not required that this pragma be used consistently within
4602 a partition, so it is fine to have some units within a partition compiled
4603 with this pragma and others compiled in normal mode without it.
4605 @node Pragma Suppress_Initialization
4606 @unnumberedsec Pragma Suppress_Initialization
4607 @findex Suppress_Initialization
4608 @cindex Suppressing initialization
4609 @cindex Initialization, suppression of
4613 @smallexample @c ada
4614 pragma Suppress_Initialization ([Entity =>] type_Name);
4618 This pragma suppresses any implicit or explicit initialization
4619 associated with the given type name for all variables of this type.
4621 @node Pragma Task_Info
4622 @unnumberedsec Pragma Task_Info
4627 @smallexample @c ada
4628 pragma Task_Info (EXPRESSION);
4632 This pragma appears within a task definition (like pragma
4633 @code{Priority}) and applies to the task in which it appears. The
4634 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4635 The @code{Task_Info} pragma provides system dependent control over
4636 aspects of tasking implementation, for example, the ability to map
4637 tasks to specific processors. For details on the facilities available
4638 for the version of GNAT that you are using, see the documentation
4639 in the spec of package System.Task_Info in the runtime
4642 @node Pragma Task_Name
4643 @unnumberedsec Pragma Task_Name
4648 @smallexample @c ada
4649 pragma Task_Name (string_EXPRESSION);
4653 This pragma appears within a task definition (like pragma
4654 @code{Priority}) and applies to the task in which it appears. The
4655 argument must be of type String, and provides a name to be used for
4656 the task instance when the task is created. Note that this expression
4657 is not required to be static, and in particular, it can contain
4658 references to task discriminants. This facility can be used to
4659 provide different names for different tasks as they are created,
4660 as illustrated in the example below.
4662 The task name is recorded internally in the run-time structures
4663 and is accessible to tools like the debugger. In addition the
4664 routine @code{Ada.Task_Identification.Image} will return this
4665 string, with a unique task address appended.
4667 @smallexample @c ada
4668 -- Example of the use of pragma Task_Name
4670 with Ada.Task_Identification;
4671 use Ada.Task_Identification;
4672 with Text_IO; use Text_IO;
4675 type Astring is access String;
4677 task type Task_Typ (Name : access String) is
4678 pragma Task_Name (Name.all);
4681 task body Task_Typ is
4682 Nam : constant String := Image (Current_Task);
4684 Put_Line ("-->" & Nam (1 .. 14) & "<--");
4687 type Ptr_Task is access Task_Typ;
4688 Task_Var : Ptr_Task;
4692 new Task_Typ (new String'("This is task 1"));
4694 new Task_Typ (new String'("This is task 2"));
4698 @node Pragma Task_Storage
4699 @unnumberedsec Pragma Task_Storage
4700 @findex Task_Storage
4703 @smallexample @c ada
4704 pragma Task_Storage (
4705 [Task_Type =>] LOCAL_NAME,
4706 [Top_Guard =>] static_integer_EXPRESSION);
4710 This pragma specifies the length of the guard area for tasks. The guard
4711 area is an additional storage area allocated to a task. A value of zero
4712 means that either no guard area is created or a minimal guard area is
4713 created, depending on the target. This pragma can appear anywhere a
4714 @code{Storage_Size} attribute definition clause is allowed for a task
4717 @node Pragma Thread_Local_Storage
4718 @unnumberedsec Pragma Thread_Local_Storage
4719 @findex Thread_Local_Storage
4720 @cindex Task specific storage
4721 @cindex TLS (Thread Local Storage)
4724 @smallexample @c ada
4725 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
4729 This pragma specifies that the specified entity, which must be
4730 a variable declared in a library level package, is to be marked as
4731 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
4732 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
4733 (and hence each Ada task) to see a distinct copy of the variable.
4735 The variable may not have default initialization, and if there is
4736 an explicit initialization, it must be either @code{null} for an
4737 access variable, or a static expression for a scalar variable.
4738 This provides a low level mechanism similar to that provided by
4739 the @code{Ada.Task_Attributes} package, but much more efficient
4740 and is also useful in writing interface code that will interact
4741 with foreign threads.
4743 If this pragma is used on a system where @code{TLS} is not supported,
4744 then an error message will be generated and the program will be rejected.
4746 @node Pragma Time_Slice
4747 @unnumberedsec Pragma Time_Slice
4752 @smallexample @c ada
4753 pragma Time_Slice (static_duration_EXPRESSION);
4757 For implementations of GNAT on operating systems where it is possible
4758 to supply a time slice value, this pragma may be used for this purpose.
4759 It is ignored if it is used in a system that does not allow this control,
4760 or if it appears in other than the main program unit.
4762 Note that the effect of this pragma is identical to the effect of the
4763 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4766 @unnumberedsec Pragma Title
4771 @smallexample @c ada
4772 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4775 [Title =>] STRING_LITERAL,
4776 | [Subtitle =>] STRING_LITERAL
4780 Syntax checked but otherwise ignored by GNAT@. This is a listing control
4781 pragma used in DEC Ada 83 implementations to provide a title and/or
4782 subtitle for the program listing. The program listing generated by GNAT
4783 does not have titles or subtitles.
4785 Unlike other pragmas, the full flexibility of named notation is allowed
4786 for this pragma, i.e.@: the parameters may be given in any order if named
4787 notation is used, and named and positional notation can be mixed
4788 following the normal rules for procedure calls in Ada.
4790 @node Pragma Unchecked_Union
4791 @unnumberedsec Pragma Unchecked_Union
4793 @findex Unchecked_Union
4797 @smallexample @c ada
4798 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4802 This pragma is used to specify a representation of a record type that is
4803 equivalent to a C union. It was introduced as a GNAT implementation defined
4804 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4805 pragma, making it language defined, and GNAT fully implements this extended
4806 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4807 details, consult the Ada 2005 Reference Manual, section B.3.3.
4809 @node Pragma Unimplemented_Unit
4810 @unnumberedsec Pragma Unimplemented_Unit
4811 @findex Unimplemented_Unit
4815 @smallexample @c ada
4816 pragma Unimplemented_Unit;
4820 If this pragma occurs in a unit that is processed by the compiler, GNAT
4821 aborts with the message @samp{@var{xxx} not implemented}, where
4822 @var{xxx} is the name of the current compilation unit. This pragma is
4823 intended to allow the compiler to handle unimplemented library units in
4826 The abort only happens if code is being generated. Thus you can use
4827 specs of unimplemented packages in syntax or semantic checking mode.
4829 @node Pragma Universal_Aliasing
4830 @unnumberedsec Pragma Universal_Aliasing
4831 @findex Universal_Aliasing
4835 @smallexample @c ada
4836 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4840 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4841 declarative part. The effect is to inhibit strict type-based aliasing
4842 optimization for the given type. In other words, the effect is as though
4843 access types designating this type were subject to pragma No_Strict_Aliasing.
4844 For a detailed description of the strict aliasing optimization, and the
4845 situations in which it must be suppressed, @xref{Optimization and Strict
4846 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4848 @node Pragma Universal_Data
4849 @unnumberedsec Pragma Universal_Data
4850 @findex Universal_Data
4854 @smallexample @c ada
4855 pragma Universal_Data [(library_unit_Name)];
4859 This pragma is supported only for the AAMP target and is ignored for
4860 other targets. The pragma specifies that all library-level objects
4861 (Counter 0 data) associated with the library unit are to be accessed
4862 and updated using universal addressing (24-bit addresses for AAMP5)
4863 rather than the default of 16-bit Data Environment (DENV) addressing.
4864 Use of this pragma will generally result in less efficient code for
4865 references to global data associated with the library unit, but
4866 allows such data to be located anywhere in memory. This pragma is
4867 a library unit pragma, but can also be used as a configuration pragma
4868 (including use in the @file{gnat.adc} file). The functionality
4869 of this pragma is also available by applying the -univ switch on the
4870 compilations of units where universal addressing of the data is desired.
4872 @node Pragma Unmodified
4873 @unnumberedsec Pragma Unmodified
4875 @cindex Warnings, unmodified
4879 @smallexample @c ada
4880 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4884 This pragma signals that the assignable entities (variables,
4885 @code{out} parameters, @code{in out} parameters) whose names are listed are
4886 deliberately not assigned in the current source unit. This
4887 suppresses warnings about the
4888 entities being referenced but not assigned, and in addition a warning will be
4889 generated if one of these entities is in fact assigned in the
4890 same unit as the pragma (or in the corresponding body, or one
4893 This is particularly useful for clearly signaling that a particular
4894 parameter is not modified, even though the spec suggests that it might
4897 @node Pragma Unreferenced
4898 @unnumberedsec Pragma Unreferenced
4899 @findex Unreferenced
4900 @cindex Warnings, unreferenced
4904 @smallexample @c ada
4905 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4906 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4910 This pragma signals that the entities whose names are listed are
4911 deliberately not referenced in the current source unit. This
4912 suppresses warnings about the
4913 entities being unreferenced, and in addition a warning will be
4914 generated if one of these entities is in fact referenced in the
4915 same unit as the pragma (or in the corresponding body, or one
4918 This is particularly useful for clearly signaling that a particular
4919 parameter is not referenced in some particular subprogram implementation
4920 and that this is deliberate. It can also be useful in the case of
4921 objects declared only for their initialization or finalization side
4924 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4925 current scope, then the entity most recently declared is the one to which
4926 the pragma applies. Note that in the case of accept formals, the pragma
4927 Unreferenced may appear immediately after the keyword @code{do} which
4928 allows the indication of whether or not accept formals are referenced
4929 or not to be given individually for each accept statement.
4931 The left hand side of an assignment does not count as a reference for the
4932 purpose of this pragma. Thus it is fine to assign to an entity for which
4933 pragma Unreferenced is given.
4935 Note that if a warning is desired for all calls to a given subprogram,
4936 regardless of whether they occur in the same unit as the subprogram
4937 declaration, then this pragma should not be used (calls from another
4938 unit would not be flagged); pragma Obsolescent can be used instead
4939 for this purpose, see @xref{Pragma Obsolescent}.
4941 The second form of pragma @code{Unreferenced} is used within a context
4942 clause. In this case the arguments must be unit names of units previously
4943 mentioned in @code{with} clauses (similar to the usage of pragma
4944 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4945 units and unreferenced entities within these units.
4947 @node Pragma Unreferenced_Objects
4948 @unnumberedsec Pragma Unreferenced_Objects
4949 @findex Unreferenced_Objects
4950 @cindex Warnings, unreferenced
4954 @smallexample @c ada
4955 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4959 This pragma signals that for the types or subtypes whose names are
4960 listed, objects which are declared with one of these types or subtypes may
4961 not be referenced, and if no references appear, no warnings are given.
4963 This is particularly useful for objects which are declared solely for their
4964 initialization and finalization effect. Such variables are sometimes referred
4965 to as RAII variables (Resource Acquisition Is Initialization). Using this
4966 pragma on the relevant type (most typically a limited controlled type), the
4967 compiler will automatically suppress unwanted warnings about these variables
4968 not being referenced.
4970 @node Pragma Unreserve_All_Interrupts
4971 @unnumberedsec Pragma Unreserve_All_Interrupts
4972 @findex Unreserve_All_Interrupts
4976 @smallexample @c ada
4977 pragma Unreserve_All_Interrupts;
4981 Normally certain interrupts are reserved to the implementation. Any attempt
4982 to attach an interrupt causes Program_Error to be raised, as described in
4983 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
4984 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
4985 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4986 interrupt execution.
4988 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4989 a program, then all such interrupts are unreserved. This allows the
4990 program to handle these interrupts, but disables their standard
4991 functions. For example, if this pragma is used, then pressing
4992 @kbd{Ctrl-C} will not automatically interrupt execution. However,
4993 a program can then handle the @code{SIGINT} interrupt as it chooses.
4995 For a full list of the interrupts handled in a specific implementation,
4996 see the source code for the spec of @code{Ada.Interrupts.Names} in
4997 file @file{a-intnam.ads}. This is a target dependent file that contains the
4998 list of interrupts recognized for a given target. The documentation in
4999 this file also specifies what interrupts are affected by the use of
5000 the @code{Unreserve_All_Interrupts} pragma.
5002 For a more general facility for controlling what interrupts can be
5003 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5004 of the @code{Unreserve_All_Interrupts} pragma.
5006 @node Pragma Unsuppress
5007 @unnumberedsec Pragma Unsuppress
5012 @smallexample @c ada
5013 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5017 This pragma undoes the effect of a previous pragma @code{Suppress}. If
5018 there is no corresponding pragma @code{Suppress} in effect, it has no
5019 effect. The range of the effect is the same as for pragma
5020 @code{Suppress}. The meaning of the arguments is identical to that used
5021 in pragma @code{Suppress}.
5023 One important application is to ensure that checks are on in cases where
5024 code depends on the checks for its correct functioning, so that the code
5025 will compile correctly even if the compiler switches are set to suppress
5028 @node Pragma Use_VADS_Size
5029 @unnumberedsec Pragma Use_VADS_Size
5030 @cindex @code{Size}, VADS compatibility
5031 @findex Use_VADS_Size
5035 @smallexample @c ada
5036 pragma Use_VADS_Size;
5040 This is a configuration pragma. In a unit to which it applies, any use
5041 of the 'Size attribute is automatically interpreted as a use of the
5042 'VADS_Size attribute. Note that this may result in incorrect semantic
5043 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
5044 the handling of existing code which depends on the interpretation of Size
5045 as implemented in the VADS compiler. See description of the VADS_Size
5046 attribute for further details.
5048 @node Pragma Validity_Checks
5049 @unnumberedsec Pragma Validity_Checks
5050 @findex Validity_Checks
5054 @smallexample @c ada
5055 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5059 This pragma is used in conjunction with compiler switches to control the
5060 built-in validity checking provided by GNAT@. The compiler switches, if set
5061 provide an initial setting for the switches, and this pragma may be used
5062 to modify these settings, or the settings may be provided entirely by
5063 the use of the pragma. This pragma can be used anywhere that a pragma
5064 is legal, including use as a configuration pragma (including use in
5065 the @file{gnat.adc} file).
5067 The form with a string literal specifies which validity options are to be
5068 activated. The validity checks are first set to include only the default
5069 reference manual settings, and then a string of letters in the string
5070 specifies the exact set of options required. The form of this string
5071 is exactly as described for the @option{-gnatVx} compiler switch (see the
5072 GNAT users guide for details). For example the following two methods
5073 can be used to enable validity checking for mode @code{in} and
5074 @code{in out} subprogram parameters:
5078 @smallexample @c ada
5079 pragma Validity_Checks ("im");
5084 gcc -c -gnatVim @dots{}
5089 The form ALL_CHECKS activates all standard checks (its use is equivalent
5090 to the use of the @code{gnatva} switch.
5092 The forms with @code{Off} and @code{On}
5093 can be used to temporarily disable validity checks
5094 as shown in the following example:
5096 @smallexample @c ada
5100 pragma Validity_Checks ("c"); -- validity checks for copies
5101 pragma Validity_Checks (Off); -- turn off validity checks
5102 A := B; -- B will not be validity checked
5103 pragma Validity_Checks (On); -- turn validity checks back on
5104 A := C; -- C will be validity checked
5107 @node Pragma Volatile
5108 @unnumberedsec Pragma Volatile
5113 @smallexample @c ada
5114 pragma Volatile (LOCAL_NAME);
5118 This pragma is defined by the Ada Reference Manual, and the GNAT
5119 implementation is fully conformant with this definition. The reason it
5120 is mentioned in this section is that a pragma of the same name was supplied
5121 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
5122 implementation of pragma Volatile is upwards compatible with the
5123 implementation in DEC Ada 83.
5125 @node Pragma Warnings
5126 @unnumberedsec Pragma Warnings
5131 @smallexample @c ada
5132 pragma Warnings (On | Off);
5133 pragma Warnings (On | Off, LOCAL_NAME);
5134 pragma Warnings (static_string_EXPRESSION);
5135 pragma Warnings (On | Off, static_string_EXPRESSION);
5139 Normally warnings are enabled, with the output being controlled by
5140 the command line switch. Warnings (@code{Off}) turns off generation of
5141 warnings until a Warnings (@code{On}) is encountered or the end of the
5142 current unit. If generation of warnings is turned off using this
5143 pragma, then no warning messages are output, regardless of the
5144 setting of the command line switches.
5146 The form with a single argument may be used as a configuration pragma.
5148 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5149 the specified entity. This suppression is effective from the point where
5150 it occurs till the end of the extended scope of the variable (similar to
5151 the scope of @code{Suppress}).
5153 The form with a single static_string_EXPRESSION argument provides more precise
5154 control over which warnings are active. The string is a list of letters
5155 specifying which warnings are to be activated and which deactivated. The
5156 code for these letters is the same as the string used in the command
5157 line switch controlling warnings. The following is a brief summary. For
5158 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5162 a turn on all optional warnings (except d h l .o)
5163 A turn off all optional warnings
5164 .a* turn on warnings for failing assertions
5165 .A turn off warnings for failing assertions
5166 b turn on warnings for bad fixed value (not multiple of small)
5167 B* turn off warnings for bad fixed value (not multiple of small)
5168 .b* turn on warnings for biased representation
5169 .B turn off warnings for biased representation
5170 c turn on warnings for constant conditional
5171 C* turn off warnings for constant conditional
5172 .c turn on warnings for unrepped components
5173 .C* turn off warnings for unrepped components
5174 d turn on warnings for implicit dereference
5175 D* turn off warnings for implicit dereference
5176 e treat all warnings as errors
5177 .e turn on every optional warning
5178 f turn on warnings for unreferenced formal
5179 F* turn off warnings for unreferenced formal
5180 g* turn on warnings for unrecognized pragma
5181 G turn off warnings for unrecognized pragma
5182 h turn on warnings for hiding variable
5183 H* turn off warnings for hiding variable
5184 i* turn on warnings for implementation unit
5185 I turn off warnings for implementation unit
5186 j turn on warnings for obsolescent (annex J) feature
5187 J* turn off warnings for obsolescent (annex J) feature
5188 k turn on warnings on constant variable
5189 K* turn off warnings on constant variable
5190 l turn on warnings for missing elaboration pragma
5191 L* turn off warnings for missing elaboration pragma
5192 m turn on warnings for variable assigned but not read
5193 M* turn off warnings for variable assigned but not read
5194 n* normal warning mode (cancels -gnatws/-gnatwe)
5195 o* turn on warnings for address clause overlay
5196 O turn off warnings for address clause overlay
5197 .o turn on warnings for out parameters assigned but not read
5198 .O* turn off warnings for out parameters assigned but not read
5199 p turn on warnings for ineffective pragma Inline in frontend
5200 P* turn off warnings for ineffective pragma Inline in frontend
5201 .p turn on warnings for parameter ordering
5202 .P* turn off warnings for parameter ordering
5203 q* turn on warnings for questionable missing parentheses
5204 Q turn off warnings for questionable missing parentheses
5205 r turn on warnings for redundant construct
5206 R* turn off warnings for redundant construct
5207 .r turn on warnings for object renaming function
5208 .R* turn off warnings for object renaming function
5209 s suppress all warnings
5210 t turn on warnings for tracking deleted code
5211 T* turn off warnings for tracking deleted code
5212 u turn on warnings for unused entity
5213 U* turn off warnings for unused entity
5214 v* turn on warnings for unassigned variable
5215 V turn off warnings for unassigned variable
5216 w* turn on warnings for wrong low bound assumption
5217 W turn off warnings for wrong low bound assumption
5218 .w turn on warnings for unnecessary Warnings Off pragmas
5219 .W* turn off warnings for unnecessary Warnings Off pragmas
5220 x* turn on warnings for export/import
5221 X turn off warnings for export/import
5222 .x turn on warnings for non-local exceptions
5223 .X* turn off warnings for non-local exceptions
5224 y* turn on warnings for Ada 2005 incompatibility
5225 Y turn off warnings for Ada 2005 incompatibility
5226 z* turn on convention/size/align warnings for unchecked conversion
5227 Z turn off convention/size/align warnings for unchecked conversion
5228 * indicates default in above list
5232 The specified warnings will be in effect until the end of the program
5233 or another pragma Warnings is encountered. The effect of the pragma is
5234 cumulative. Initially the set of warnings is the standard default set
5235 as possibly modified by compiler switches. Then each pragma Warning
5236 modifies this set of warnings as specified. This form of the pragma may
5237 also be used as a configuration pragma.
5239 The fourth form, with an On|Off parameter and a string, is used to
5240 control individual messages, based on their text. The string argument
5241 is a pattern that is used to match against the text of individual
5242 warning messages (not including the initial "warning: " tag).
5244 The pattern may contain asterisks, which match zero or more characters in
5245 the message. For example, you can use
5246 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5247 message @code{warning: 960 bits of "a" unused}. No other regular
5248 expression notations are permitted. All characters other than asterisk in
5249 these three specific cases are treated as literal characters in the match.
5251 There are two ways to use this pragma. The OFF form can be used as a
5252 configuration pragma. The effect is to suppress all warnings (if any)
5253 that match the pattern string throughout the compilation.
5255 The second usage is to suppress a warning locally, and in this case, two
5256 pragmas must appear in sequence:
5258 @smallexample @c ada
5259 pragma Warnings (Off, Pattern);
5260 @dots{} code where given warning is to be suppressed
5261 pragma Warnings (On, Pattern);
5265 In this usage, the pattern string must match in the Off and On pragmas,
5266 and at least one matching warning must be suppressed.
5268 @node Pragma Weak_External
5269 @unnumberedsec Pragma Weak_External
5270 @findex Weak_External
5274 @smallexample @c ada
5275 pragma Weak_External ([Entity =>] LOCAL_NAME);
5279 @var{LOCAL_NAME} must refer to an object that is declared at the library
5280 level. This pragma specifies that the given entity should be marked as a
5281 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5282 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5283 of a regular symbol, that is to say a symbol that does not have to be
5284 resolved by the linker if used in conjunction with a pragma Import.
5286 When a weak symbol is not resolved by the linker, its address is set to
5287 zero. This is useful in writing interfaces to external modules that may
5288 or may not be linked in the final executable, for example depending on
5289 configuration settings.
5291 If a program references at run time an entity to which this pragma has been
5292 applied, and the corresponding symbol was not resolved at link time, then
5293 the execution of the program is erroneous. It is not erroneous to take the
5294 Address of such an entity, for example to guard potential references,
5295 as shown in the example below.
5297 Some file formats do not support weak symbols so not all target machines
5298 support this pragma.
5300 @smallexample @c ada
5301 -- Example of the use of pragma Weak_External
5303 package External_Module is
5305 pragma Import (C, key);
5306 pragma Weak_External (key);
5307 function Present return boolean;
5308 end External_Module;
5310 with System; use System;
5311 package body External_Module is
5312 function Present return boolean is
5314 return key'Address /= System.Null_Address;
5316 end External_Module;
5319 @node Pragma Wide_Character_Encoding
5320 @unnumberedsec Pragma Wide_Character_Encoding
5321 @findex Wide_Character_Encoding
5325 @smallexample @c ada
5326 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5330 This pragma specifies the wide character encoding to be used in program
5331 source text appearing subsequently. It is a configuration pragma, but may
5332 also be used at any point that a pragma is allowed, and it is permissible
5333 to have more than one such pragma in a file, allowing multiple encodings
5334 to appear within the same file.
5336 The argument can be an identifier or a character literal. In the identifier
5337 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5338 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5339 case it is correspondingly one of the characters @samp{h}, @samp{u},
5340 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5342 Note that when the pragma is used within a file, it affects only the
5343 encoding within that file, and does not affect withed units, specs,
5346 @node Implementation Defined Attributes
5347 @chapter Implementation Defined Attributes
5348 Ada defines (throughout the Ada reference manual,
5349 summarized in Annex K),
5350 a set of attributes that provide useful additional functionality in all
5351 areas of the language. These language defined attributes are implemented
5352 in GNAT and work as described in the Ada Reference Manual.
5354 In addition, Ada allows implementations to define additional
5355 attributes whose meaning is defined by the implementation. GNAT provides
5356 a number of these implementation-dependent attributes which can be used
5357 to extend and enhance the functionality of the compiler. This section of
5358 the GNAT reference manual describes these additional attributes.
5360 Note that any program using these attributes may not be portable to
5361 other compilers (although GNAT implements this set of attributes on all
5362 platforms). Therefore if portability to other compilers is an important
5363 consideration, you should minimize the use of these attributes.
5373 * Compiler_Version::
5375 * Default_Bit_Order::
5385 * Has_Access_Values::
5386 * Has_Discriminants::
5393 * Max_Interrupt_Priority::
5395 * Maximum_Alignment::
5400 * Passed_By_Reference::
5413 * Unconstrained_Array::
5414 * Universal_Literal_String::
5415 * Unrestricted_Access::
5423 @unnumberedsec Abort_Signal
5424 @findex Abort_Signal
5426 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5427 prefix) provides the entity for the special exception used to signal
5428 task abort or asynchronous transfer of control. Normally this attribute
5429 should only be used in the tasking runtime (it is highly peculiar, and
5430 completely outside the normal semantics of Ada, for a user program to
5431 intercept the abort exception).
5434 @unnumberedsec Address_Size
5435 @cindex Size of @code{Address}
5436 @findex Address_Size
5438 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5439 prefix) is a static constant giving the number of bits in an
5440 @code{Address}. It is the same value as System.Address'Size,
5441 but has the advantage of being static, while a direct
5442 reference to System.Address'Size is non-static because Address
5446 @unnumberedsec Asm_Input
5449 The @code{Asm_Input} attribute denotes a function that takes two
5450 parameters. The first is a string, the second is an expression of the
5451 type designated by the prefix. The first (string) argument is required
5452 to be a static expression, and is the constraint for the parameter,
5453 (e.g.@: what kind of register is required). The second argument is the
5454 value to be used as the input argument. The possible values for the
5455 constant are the same as those used in the RTL, and are dependent on
5456 the configuration file used to built the GCC back end.
5457 @ref{Machine Code Insertions}
5460 @unnumberedsec Asm_Output
5463 The @code{Asm_Output} attribute denotes a function that takes two
5464 parameters. The first is a string, the second is the name of a variable
5465 of the type designated by the attribute prefix. The first (string)
5466 argument is required to be a static expression and designates the
5467 constraint for the parameter (e.g.@: what kind of register is
5468 required). The second argument is the variable to be updated with the
5469 result. The possible values for constraint are the same as those used in
5470 the RTL, and are dependent on the configuration file used to build the
5471 GCC back end. If there are no output operands, then this argument may
5472 either be omitted, or explicitly given as @code{No_Output_Operands}.
5473 @ref{Machine Code Insertions}
5476 @unnumberedsec AST_Entry
5480 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
5481 the name of an entry, it yields a value of the predefined type AST_Handler
5482 (declared in the predefined package System, as extended by the use of
5483 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
5484 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
5485 Language Reference Manual}, section 9.12a.
5490 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5491 offset within the storage unit (byte) that contains the first bit of
5492 storage allocated for the object. The value of this attribute is of the
5493 type @code{Universal_Integer}, and is always a non-negative number not
5494 exceeding the value of @code{System.Storage_Unit}.
5496 For an object that is a variable or a constant allocated in a register,
5497 the value is zero. (The use of this attribute does not force the
5498 allocation of a variable to memory).
5500 For an object that is a formal parameter, this attribute applies
5501 to either the matching actual parameter or to a copy of the
5502 matching actual parameter.
5504 For an access object the value is zero. Note that
5505 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5506 designated object. Similarly for a record component
5507 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5508 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5509 are subject to index checks.
5511 This attribute is designed to be compatible with the DEC Ada 83 definition
5512 and implementation of the @code{Bit} attribute.
5515 @unnumberedsec Bit_Position
5516 @findex Bit_Position
5518 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5519 of the fields of the record type, yields the bit
5520 offset within the record contains the first bit of
5521 storage allocated for the object. The value of this attribute is of the
5522 type @code{Universal_Integer}. The value depends only on the field
5523 @var{C} and is independent of the alignment of
5524 the containing record @var{R}.
5526 @node Compiler_Version
5527 @unnumberedsec Compiler_Version
5528 @findex Compiler_Version
5530 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
5531 prefix) yields a static string identifying the version of the compiler
5532 being used to compile the unit containing the attribute reference. A
5533 typical result would be something like "GNAT Pro 6.3.0w (20090221)".
5536 @unnumberedsec Code_Address
5537 @findex Code_Address
5538 @cindex Subprogram address
5539 @cindex Address of subprogram code
5542 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5543 intended effect seems to be to provide
5544 an address value which can be used to call the subprogram by means of
5545 an address clause as in the following example:
5547 @smallexample @c ada
5548 procedure K is @dots{}
5551 for L'Address use K'Address;
5552 pragma Import (Ada, L);
5556 A call to @code{L} is then expected to result in a call to @code{K}@.
5557 In Ada 83, where there were no access-to-subprogram values, this was
5558 a common work-around for getting the effect of an indirect call.
5559 GNAT implements the above use of @code{Address} and the technique
5560 illustrated by the example code works correctly.
5562 However, for some purposes, it is useful to have the address of the start
5563 of the generated code for the subprogram. On some architectures, this is
5564 not necessarily the same as the @code{Address} value described above.
5565 For example, the @code{Address} value may reference a subprogram
5566 descriptor rather than the subprogram itself.
5568 The @code{'Code_Address} attribute, which can only be applied to
5569 subprogram entities, always returns the address of the start of the
5570 generated code of the specified subprogram, which may or may not be
5571 the same value as is returned by the corresponding @code{'Address}
5574 @node Default_Bit_Order
5575 @unnumberedsec Default_Bit_Order
5577 @cindex Little endian
5578 @findex Default_Bit_Order
5580 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5581 permissible prefix), provides the value @code{System.Default_Bit_Order}
5582 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5583 @code{Low_Order_First}). This is used to construct the definition of
5584 @code{Default_Bit_Order} in package @code{System}.
5587 @unnumberedsec Elaborated
5590 The prefix of the @code{'Elaborated} attribute must be a unit name. The
5591 value is a Boolean which indicates whether or not the given unit has been
5592 elaborated. This attribute is primarily intended for internal use by the
5593 generated code for dynamic elaboration checking, but it can also be used
5594 in user programs. The value will always be True once elaboration of all
5595 units has been completed. An exception is for units which need no
5596 elaboration, the value is always False for such units.
5599 @unnumberedsec Elab_Body
5602 This attribute can only be applied to a program unit name. It returns
5603 the entity for the corresponding elaboration procedure for elaborating
5604 the body of the referenced unit. This is used in the main generated
5605 elaboration procedure by the binder and is not normally used in any
5606 other context. However, there may be specialized situations in which it
5607 is useful to be able to call this elaboration procedure from Ada code,
5608 e.g.@: if it is necessary to do selective re-elaboration to fix some
5612 @unnumberedsec Elab_Spec
5615 This attribute can only be applied to a program unit name. It returns
5616 the entity for the corresponding elaboration procedure for elaborating
5617 the spec of the referenced unit. This is used in the main
5618 generated elaboration procedure by the binder and is not normally used
5619 in any other context. However, there may be specialized situations in
5620 which it is useful to be able to call this elaboration procedure from
5621 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5626 @cindex Ada 83 attributes
5629 The @code{Emax} attribute is provided for compatibility with Ada 83. See
5630 the Ada 83 reference manual for an exact description of the semantics of
5634 @unnumberedsec Enabled
5637 The @code{Enabled} attribute allows an application program to check at compile
5638 time to see if the designated check is currently enabled. The prefix is a
5639 simple identifier, referencing any predefined check name (other than
5640 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5641 no argument is given for the attribute, the check is for the general state
5642 of the check, if an argument is given, then it is an entity name, and the
5643 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5644 given naming the entity (if not, then the argument is ignored).
5646 Note that instantiations inherit the check status at the point of the
5647 instantiation, so a useful idiom is to have a library package that
5648 introduces a check name with @code{pragma Check_Name}, and then contains
5649 generic packages or subprograms which use the @code{Enabled} attribute
5650 to see if the check is enabled. A user of this package can then issue
5651 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5652 the package or subprogram, controlling whether the check will be present.
5655 @unnumberedsec Enum_Rep
5656 @cindex Representation of enums
5659 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5660 function with the following spec:
5662 @smallexample @c ada
5663 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5664 return @i{Universal_Integer};
5668 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5669 enumeration type or to a non-overloaded enumeration
5670 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
5671 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5672 enumeration literal or object.
5674 The function returns the representation value for the given enumeration
5675 value. This will be equal to value of the @code{Pos} attribute in the
5676 absence of an enumeration representation clause. This is a static
5677 attribute (i.e.@: the result is static if the argument is static).
5679 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5680 in which case it simply returns the integer value. The reason for this
5681 is to allow it to be used for @code{(<>)} discrete formal arguments in
5682 a generic unit that can be instantiated with either enumeration types
5683 or integer types. Note that if @code{Enum_Rep} is used on a modular
5684 type whose upper bound exceeds the upper bound of the largest signed
5685 integer type, and the argument is a variable, so that the universal
5686 integer calculation is done at run time, then the call to @code{Enum_Rep}
5687 may raise @code{Constraint_Error}.
5690 @unnumberedsec Enum_Val
5691 @cindex Representation of enums
5694 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5695 function with the following spec:
5697 @smallexample @c ada
5698 function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5699 return @var{S}'Base};
5703 The function returns the enumeration value whose representation matches the
5704 argument, or raises Constraint_Error if no enumeration literal of the type
5705 has the matching value.
5706 This will be equal to value of the @code{Val} attribute in the
5707 absence of an enumeration representation clause. This is a static
5708 attribute (i.e.@: the result is static if the argument is static).
5711 @unnumberedsec Epsilon
5712 @cindex Ada 83 attributes
5715 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
5716 the Ada 83 reference manual for an exact description of the semantics of
5720 @unnumberedsec Fixed_Value
5723 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5724 function with the following specification:
5726 @smallexample @c ada
5727 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5732 The value returned is the fixed-point value @var{V} such that
5734 @smallexample @c ada
5735 @var{V} = Arg * @var{S}'Small
5739 The effect is thus similar to first converting the argument to the
5740 integer type used to represent @var{S}, and then doing an unchecked
5741 conversion to the fixed-point type. The difference is
5742 that there are full range checks, to ensure that the result is in range.
5743 This attribute is primarily intended for use in implementation of the
5744 input-output functions for fixed-point values.
5746 @node Has_Access_Values
5747 @unnumberedsec Has_Access_Values
5748 @cindex Access values, testing for
5749 @findex Has_Access_Values
5751 The prefix of the @code{Has_Access_Values} attribute is a type. The result
5752 is a Boolean value which is True if the is an access type, or is a composite
5753 type with a component (at any nesting depth) that is an access type, and is
5755 The intended use of this attribute is in conjunction with generic
5756 definitions. If the attribute is applied to a generic private type, it
5757 indicates whether or not the corresponding actual type has access values.
5759 @node Has_Discriminants
5760 @unnumberedsec Has_Discriminants
5761 @cindex Discriminants, testing for
5762 @findex Has_Discriminants
5764 The prefix of the @code{Has_Discriminants} attribute is a type. The result
5765 is a Boolean value which is True if the type has discriminants, and False
5766 otherwise. The intended use of this attribute is in conjunction with generic
5767 definitions. If the attribute is applied to a generic private type, it
5768 indicates whether or not the corresponding actual type has discriminants.
5774 The @code{Img} attribute differs from @code{Image} in that it may be
5775 applied to objects as well as types, in which case it gives the
5776 @code{Image} for the subtype of the object. This is convenient for
5779 @smallexample @c ada
5780 Put_Line ("X = " & X'Img);
5784 has the same meaning as the more verbose:
5786 @smallexample @c ada
5787 Put_Line ("X = " & @var{T}'Image (X));
5791 where @var{T} is the (sub)type of the object @code{X}.
5794 @unnumberedsec Integer_Value
5795 @findex Integer_Value
5797 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5798 function with the following spec:
5800 @smallexample @c ada
5801 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5806 The value returned is the integer value @var{V}, such that
5808 @smallexample @c ada
5809 Arg = @var{V} * @var{T}'Small
5813 where @var{T} is the type of @code{Arg}.
5814 The effect is thus similar to first doing an unchecked conversion from
5815 the fixed-point type to its corresponding implementation type, and then
5816 converting the result to the target integer type. The difference is
5817 that there are full range checks, to ensure that the result is in range.
5818 This attribute is primarily intended for use in implementation of the
5819 standard input-output functions for fixed-point values.
5822 @unnumberedsec Invalid_Value
5823 @findex Invalid_Value
5825 For every scalar type S, S'Invalid_Value returns an undefined value of the
5826 type. If possible this value is an invalid representation for the type. The
5827 value returned is identical to the value used to initialize an otherwise
5828 uninitialized value of the type if pragma Initialize_Scalars is used,
5829 including the ability to modify the value with the binder -Sxx flag and
5830 relevant environment variables at run time.
5833 @unnumberedsec Large
5834 @cindex Ada 83 attributes
5837 The @code{Large} attribute is provided for compatibility with Ada 83. See
5838 the Ada 83 reference manual for an exact description of the semantics of
5842 @unnumberedsec Machine_Size
5843 @findex Machine_Size
5845 This attribute is identical to the @code{Object_Size} attribute. It is
5846 provided for compatibility with the DEC Ada 83 attribute of this name.
5849 @unnumberedsec Mantissa
5850 @cindex Ada 83 attributes
5853 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
5854 the Ada 83 reference manual for an exact description of the semantics of
5857 @node Max_Interrupt_Priority
5858 @unnumberedsec Max_Interrupt_Priority
5859 @cindex Interrupt priority, maximum
5860 @findex Max_Interrupt_Priority
5862 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5863 permissible prefix), provides the same value as
5864 @code{System.Max_Interrupt_Priority}.
5867 @unnumberedsec Max_Priority
5868 @cindex Priority, maximum
5869 @findex Max_Priority
5871 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5872 prefix) provides the same value as @code{System.Max_Priority}.
5874 @node Maximum_Alignment
5875 @unnumberedsec Maximum_Alignment
5876 @cindex Alignment, maximum
5877 @findex Maximum_Alignment
5879 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5880 permissible prefix) provides the maximum useful alignment value for the
5881 target. This is a static value that can be used to specify the alignment
5882 for an object, guaranteeing that it is properly aligned in all
5885 @node Mechanism_Code
5886 @unnumberedsec Mechanism_Code
5887 @cindex Return values, passing mechanism
5888 @cindex Parameters, passing mechanism
5889 @findex Mechanism_Code
5891 @code{@var{function}'Mechanism_Code} yields an integer code for the
5892 mechanism used for the result of function, and
5893 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5894 used for formal parameter number @var{n} (a static integer value with 1
5895 meaning the first parameter) of @var{subprogram}. The code returned is:
5903 by descriptor (default descriptor class)
5905 by descriptor (UBS: unaligned bit string)
5907 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5909 by descriptor (UBA: unaligned bit array)
5911 by descriptor (S: string, also scalar access type parameter)
5913 by descriptor (SB: string with arbitrary bounds)
5915 by descriptor (A: contiguous array)
5917 by descriptor (NCA: non-contiguous array)
5921 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5924 @node Null_Parameter
5925 @unnumberedsec Null_Parameter
5926 @cindex Zero address, passing
5927 @findex Null_Parameter
5929 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5930 type or subtype @var{T} allocated at machine address zero. The attribute
5931 is allowed only as the default expression of a formal parameter, or as
5932 an actual expression of a subprogram call. In either case, the
5933 subprogram must be imported.
5935 The identity of the object is represented by the address zero in the
5936 argument list, independent of the passing mechanism (explicit or
5939 This capability is needed to specify that a zero address should be
5940 passed for a record or other composite object passed by reference.
5941 There is no way of indicating this without the @code{Null_Parameter}
5945 @unnumberedsec Object_Size
5946 @cindex Size, used for objects
5949 The size of an object is not necessarily the same as the size of the type
5950 of an object. This is because by default object sizes are increased to be
5951 a multiple of the alignment of the object. For example,
5952 @code{Natural'Size} is
5953 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5954 Similarly, a record containing an integer and a character:
5956 @smallexample @c ada
5964 will have a size of 40 (that is @code{Rec'Size} will be 40. The
5965 alignment will be 4, because of the
5966 integer field, and so the default size of record objects for this type
5967 will be 64 (8 bytes).
5971 @cindex Capturing Old values
5972 @cindex Postconditions
5974 The attribute Prefix'Old can be used within a
5975 subprogram to refer to the value of the prefix on entry. So for
5976 example if you have an argument of a record type X called Arg1,
5977 you can refer to Arg1.Field'Old which yields the value of
5978 Arg1.Field on entry. The implementation simply involves generating
5979 an object declaration which captures the value on entry. Any
5980 prefix is allowed except one of a limited type (since limited
5981 types cannot be copied to capture their values) or a local variable
5982 (since it does not exist at subprogram entry time).
5984 The following example shows the use of 'Old to implement
5985 a test of a postcondition:
5987 @smallexample @c ada
5998 package body Old_Pkg is
5999 Count : Natural := 0;
6003 ... code manipulating the value of Count
6005 pragma Assert (Count = Count'Old + 1);
6011 Note that it is allowed to apply 'Old to a constant entity, but this will
6012 result in a warning, since the old and new values will always be the same.
6014 @node Passed_By_Reference
6015 @unnumberedsec Passed_By_Reference
6016 @cindex Parameters, when passed by reference
6017 @findex Passed_By_Reference
6019 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6020 a value of type @code{Boolean} value that is @code{True} if the type is
6021 normally passed by reference and @code{False} if the type is normally
6022 passed by copy in calls. For scalar types, the result is always @code{False}
6023 and is static. For non-scalar types, the result is non-static.
6026 @unnumberedsec Pool_Address
6027 @cindex Parameters, when passed by reference
6028 @findex Pool_Address
6030 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6031 of X within its storage pool. This is the same as
6032 @code{@var{X}'Address}, except that for an unconstrained array whose
6033 bounds are allocated just before the first component,
6034 @code{@var{X}'Pool_Address} returns the address of those bounds,
6035 whereas @code{@var{X}'Address} returns the address of the first
6038 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6039 the object is allocated'', which could be a user-defined storage pool,
6040 the global heap, on the stack, or in a static memory area. For an
6041 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6042 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6045 @unnumberedsec Range_Length
6046 @findex Range_Length
6048 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6049 the number of values represented by the subtype (zero for a null
6050 range). The result is static for static subtypes. @code{Range_Length}
6051 applied to the index subtype of a one dimensional array always gives the
6052 same result as @code{Range} applied to the array itself.
6055 @unnumberedsec Safe_Emax
6056 @cindex Ada 83 attributes
6059 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
6060 the Ada 83 reference manual for an exact description of the semantics of
6064 @unnumberedsec Safe_Large
6065 @cindex Ada 83 attributes
6068 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
6069 the Ada 83 reference manual for an exact description of the semantics of
6073 @unnumberedsec Small
6074 @cindex Ada 83 attributes
6077 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6079 GNAT also allows this attribute to be applied to floating-point types
6080 for compatibility with Ada 83. See
6081 the Ada 83 reference manual for an exact description of the semantics of
6082 this attribute when applied to floating-point types.
6085 @unnumberedsec Storage_Unit
6086 @findex Storage_Unit
6088 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6089 prefix) provides the same value as @code{System.Storage_Unit}.
6092 @unnumberedsec Stub_Type
6095 The GNAT implementation of remote access-to-classwide types is
6096 organized as described in AARM section E.4 (20.t): a value of an RACW type
6097 (designating a remote object) is represented as a normal access
6098 value, pointing to a "stub" object which in turn contains the
6099 necessary information to contact the designated remote object. A
6100 call on any dispatching operation of such a stub object does the
6101 remote call, if necessary, using the information in the stub object
6102 to locate the target partition, etc.
6104 For a prefix @code{T} that denotes a remote access-to-classwide type,
6105 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6107 By construction, the layout of @code{T'Stub_Type} is identical to that of
6108 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6109 unit @code{System.Partition_Interface}. Use of this attribute will create
6110 an implicit dependency on this unit.
6113 @unnumberedsec Target_Name
6116 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6117 prefix) provides a static string value that identifies the target
6118 for the current compilation. For GCC implementations, this is the
6119 standard gcc target name without the terminating slash (for
6120 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6126 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6127 provides the same value as @code{System.Tick},
6130 @unnumberedsec To_Address
6133 The @code{System'To_Address}
6134 (@code{System} is the only permissible prefix)
6135 denotes a function identical to
6136 @code{System.Storage_Elements.To_Address} except that
6137 it is a static attribute. This means that if its argument is
6138 a static expression, then the result of the attribute is a
6139 static expression. The result is that such an expression can be
6140 used in contexts (e.g.@: preelaborable packages) which require a
6141 static expression and where the function call could not be used
6142 (since the function call is always non-static, even if its
6143 argument is static).
6146 @unnumberedsec Type_Class
6149 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6150 the value of the type class for the full type of @var{type}. If
6151 @var{type} is a generic formal type, the value is the value for the
6152 corresponding actual subtype. The value of this attribute is of type
6153 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6155 @smallexample @c ada
6157 (Type_Class_Enumeration,
6159 Type_Class_Fixed_Point,
6160 Type_Class_Floating_Point,
6165 Type_Class_Address);
6169 Protected types yield the value @code{Type_Class_Task}, which thus
6170 applies to all concurrent types. This attribute is designed to
6171 be compatible with the DEC Ada 83 attribute of the same name.
6174 @unnumberedsec UET_Address
6177 The @code{UET_Address} attribute can only be used for a prefix which
6178 denotes a library package. It yields the address of the unit exception
6179 table when zero cost exception handling is used. This attribute is
6180 intended only for use within the GNAT implementation. See the unit
6181 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6182 for details on how this attribute is used in the implementation.
6184 @node Unconstrained_Array
6185 @unnumberedsec Unconstrained_Array
6186 @findex Unconstrained_Array
6188 The @code{Unconstrained_Array} attribute can be used with a prefix that
6189 denotes any type or subtype. It is a static attribute that yields
6190 @code{True} if the prefix designates an unconstrained array,
6191 and @code{False} otherwise. In a generic instance, the result is
6192 still static, and yields the result of applying this test to the
6195 @node Universal_Literal_String
6196 @unnumberedsec Universal_Literal_String
6197 @cindex Named numbers, representation of
6198 @findex Universal_Literal_String
6200 The prefix of @code{Universal_Literal_String} must be a named
6201 number. The static result is the string consisting of the characters of
6202 the number as defined in the original source. This allows the user
6203 program to access the actual text of named numbers without intermediate
6204 conversions and without the need to enclose the strings in quotes (which
6205 would preclude their use as numbers). This is used internally for the
6206 construction of values of the floating-point attributes from the file
6207 @file{ttypef.ads}, but may also be used by user programs.
6209 For example, the following program prints the first 50 digits of pi:
6211 @smallexample @c ada
6212 with Text_IO; use Text_IO;
6216 Put (Ada.Numerics.Pi'Universal_Literal_String);
6220 @node Unrestricted_Access
6221 @unnumberedsec Unrestricted_Access
6222 @cindex @code{Access}, unrestricted
6223 @findex Unrestricted_Access
6225 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6226 except that all accessibility and aliased view checks are omitted. This
6227 is a user-beware attribute. It is similar to
6228 @code{Address}, for which it is a desirable replacement where the value
6229 desired is an access type. In other words, its effect is identical to
6230 first applying the @code{Address} attribute and then doing an unchecked
6231 conversion to a desired access type. In GNAT, but not necessarily in
6232 other implementations, the use of static chains for inner level
6233 subprograms means that @code{Unrestricted_Access} applied to a
6234 subprogram yields a value that can be called as long as the subprogram
6235 is in scope (normal Ada accessibility rules restrict this usage).
6237 It is possible to use @code{Unrestricted_Access} for any type, but care
6238 must be exercised if it is used to create pointers to unconstrained
6239 objects. In this case, the resulting pointer has the same scope as the
6240 context of the attribute, and may not be returned to some enclosing
6241 scope. For instance, a function cannot use @code{Unrestricted_Access}
6242 to create a unconstrained pointer and then return that value to the
6246 @unnumberedsec VADS_Size
6247 @cindex @code{Size}, VADS compatibility
6250 The @code{'VADS_Size} attribute is intended to make it easier to port
6251 legacy code which relies on the semantics of @code{'Size} as implemented
6252 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
6253 same semantic interpretation. In particular, @code{'VADS_Size} applied
6254 to a predefined or other primitive type with no Size clause yields the
6255 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6256 typical machines). In addition @code{'VADS_Size} applied to an object
6257 gives the result that would be obtained by applying the attribute to
6258 the corresponding type.
6261 @unnumberedsec Value_Size
6262 @cindex @code{Size}, setting for not-first subtype
6264 @code{@var{type}'Value_Size} is the number of bits required to represent
6265 a value of the given subtype. It is the same as @code{@var{type}'Size},
6266 but, unlike @code{Size}, may be set for non-first subtypes.
6269 @unnumberedsec Wchar_T_Size
6270 @findex Wchar_T_Size
6271 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6272 prefix) provides the size in bits of the C @code{wchar_t} type
6273 primarily for constructing the definition of this type in
6274 package @code{Interfaces.C}.
6277 @unnumberedsec Word_Size
6279 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6280 prefix) provides the value @code{System.Word_Size}.
6282 @c ------------------------
6283 @node Implementation Advice
6284 @chapter Implementation Advice
6286 The main text of the Ada Reference Manual describes the required
6287 behavior of all Ada compilers, and the GNAT compiler conforms to
6290 In addition, there are sections throughout the Ada Reference Manual headed
6291 by the phrase ``Implementation advice''. These sections are not normative,
6292 i.e., they do not specify requirements that all compilers must
6293 follow. Rather they provide advice on generally desirable behavior. You
6294 may wonder why they are not requirements. The most typical answer is
6295 that they describe behavior that seems generally desirable, but cannot
6296 be provided on all systems, or which may be undesirable on some systems.
6298 As far as practical, GNAT follows the implementation advice sections in
6299 the Ada Reference Manual. This chapter contains a table giving the
6300 reference manual section number, paragraph number and several keywords
6301 for each advice. Each entry consists of the text of the advice followed
6302 by the GNAT interpretation of this advice. Most often, this simply says
6303 ``followed'', which means that GNAT follows the advice. However, in a
6304 number of cases, GNAT deliberately deviates from this advice, in which
6305 case the text describes what GNAT does and why.
6307 @cindex Error detection
6308 @unnumberedsec 1.1.3(20): Error Detection
6311 If an implementation detects the use of an unsupported Specialized Needs
6312 Annex feature at run time, it should raise @code{Program_Error} if
6315 Not relevant. All specialized needs annex features are either supported,
6316 or diagnosed at compile time.
6319 @unnumberedsec 1.1.3(31): Child Units
6322 If an implementation wishes to provide implementation-defined
6323 extensions to the functionality of a language-defined library unit, it
6324 should normally do so by adding children to the library unit.
6328 @cindex Bounded errors
6329 @unnumberedsec 1.1.5(12): Bounded Errors
6332 If an implementation detects a bounded error or erroneous
6333 execution, it should raise @code{Program_Error}.
6335 Followed in all cases in which the implementation detects a bounded
6336 error or erroneous execution. Not all such situations are detected at
6340 @unnumberedsec 2.8(16): Pragmas
6343 Normally, implementation-defined pragmas should have no semantic effect
6344 for error-free programs; that is, if the implementation-defined pragmas
6345 are removed from a working program, the program should still be legal,
6346 and should still have the same semantics.
6348 The following implementation defined pragmas are exceptions to this
6360 @item CPP_Constructor
6364 @item Interface_Name
6366 @item Machine_Attribute
6368 @item Unimplemented_Unit
6370 @item Unchecked_Union
6375 In each of the above cases, it is essential to the purpose of the pragma
6376 that this advice not be followed. For details see the separate section
6377 on implementation defined pragmas.
6379 @unnumberedsec 2.8(17-19): Pragmas
6382 Normally, an implementation should not define pragmas that can
6383 make an illegal program legal, except as follows:
6387 A pragma used to complete a declaration, such as a pragma @code{Import};
6391 A pragma used to configure the environment by adding, removing, or
6392 replacing @code{library_items}.
6394 See response to paragraph 16 of this same section.
6396 @cindex Character Sets
6397 @cindex Alternative Character Sets
6398 @unnumberedsec 3.5.2(5): Alternative Character Sets
6401 If an implementation supports a mode with alternative interpretations
6402 for @code{Character} and @code{Wide_Character}, the set of graphic
6403 characters of @code{Character} should nevertheless remain a proper
6404 subset of the set of graphic characters of @code{Wide_Character}. Any
6405 character set ``localizations'' should be reflected in the results of
6406 the subprograms defined in the language-defined package
6407 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
6408 an alternative interpretation of @code{Character}, the implementation should
6409 also support a corresponding change in what is a legal
6410 @code{identifier_letter}.
6412 Not all wide character modes follow this advice, in particular the JIS
6413 and IEC modes reflect standard usage in Japan, and in these encoding,
6414 the upper half of the Latin-1 set is not part of the wide-character
6415 subset, since the most significant bit is used for wide character
6416 encoding. However, this only applies to the external forms. Internally
6417 there is no such restriction.
6419 @cindex Integer types
6420 @unnumberedsec 3.5.4(28): Integer Types
6424 An implementation should support @code{Long_Integer} in addition to
6425 @code{Integer} if the target machine supports 32-bit (or longer)
6426 arithmetic. No other named integer subtypes are recommended for package
6427 @code{Standard}. Instead, appropriate named integer subtypes should be
6428 provided in the library package @code{Interfaces} (see B.2).
6430 @code{Long_Integer} is supported. Other standard integer types are supported
6431 so this advice is not fully followed. These types
6432 are supported for convenient interface to C, and so that all hardware
6433 types of the machine are easily available.
6434 @unnumberedsec 3.5.4(29): Integer Types
6438 An implementation for a two's complement machine should support
6439 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
6440 implementation should support a non-binary modules up to @code{Integer'Last}.
6444 @cindex Enumeration values
6445 @unnumberedsec 3.5.5(8): Enumeration Values
6448 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6449 subtype, if the value of the operand does not correspond to the internal
6450 code for any enumeration literal of its type (perhaps due to an
6451 un-initialized variable), then the implementation should raise
6452 @code{Program_Error}. This is particularly important for enumeration
6453 types with noncontiguous internal codes specified by an
6454 enumeration_representation_clause.
6459 @unnumberedsec 3.5.7(17): Float Types
6462 An implementation should support @code{Long_Float} in addition to
6463 @code{Float} if the target machine supports 11 or more digits of
6464 precision. No other named floating point subtypes are recommended for
6465 package @code{Standard}. Instead, appropriate named floating point subtypes
6466 should be provided in the library package @code{Interfaces} (see B.2).
6468 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
6469 former provides improved compatibility with other implementations
6470 supporting this type. The latter corresponds to the highest precision
6471 floating-point type supported by the hardware. On most machines, this
6472 will be the same as @code{Long_Float}, but on some machines, it will
6473 correspond to the IEEE extended form. The notable case is all ia32
6474 (x86) implementations, where @code{Long_Long_Float} corresponds to
6475 the 80-bit extended precision format supported in hardware on this
6476 processor. Note that the 128-bit format on SPARC is not supported,
6477 since this is a software rather than a hardware format.
6479 @cindex Multidimensional arrays
6480 @cindex Arrays, multidimensional
6481 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6484 An implementation should normally represent multidimensional arrays in
6485 row-major order, consistent with the notation used for multidimensional
6486 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
6487 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6488 column-major order should be used instead (see B.5, ``Interfacing with
6493 @findex Duration'Small
6494 @unnumberedsec 9.6(30-31): Duration'Small
6497 Whenever possible in an implementation, the value of @code{Duration'Small}
6498 should be no greater than 100 microseconds.
6500 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
6504 The time base for @code{delay_relative_statements} should be monotonic;
6505 it need not be the same time base as used for @code{Calendar.Clock}.
6509 @unnumberedsec 10.2.1(12): Consistent Representation
6512 In an implementation, a type declared in a pre-elaborated package should
6513 have the same representation in every elaboration of a given version of
6514 the package, whether the elaborations occur in distinct executions of
6515 the same program, or in executions of distinct programs or partitions
6516 that include the given version.
6518 Followed, except in the case of tagged types. Tagged types involve
6519 implicit pointers to a local copy of a dispatch table, and these pointers
6520 have representations which thus depend on a particular elaboration of the
6521 package. It is not easy to see how it would be possible to follow this
6522 advice without severely impacting efficiency of execution.
6524 @cindex Exception information
6525 @unnumberedsec 11.4.1(19): Exception Information
6528 @code{Exception_Message} by default and @code{Exception_Information}
6529 should produce information useful for
6530 debugging. @code{Exception_Message} should be short, about one
6531 line. @code{Exception_Information} can be long. @code{Exception_Message}
6532 should not include the
6533 @code{Exception_Name}. @code{Exception_Information} should include both
6534 the @code{Exception_Name} and the @code{Exception_Message}.
6536 Followed. For each exception that doesn't have a specified
6537 @code{Exception_Message}, the compiler generates one containing the location
6538 of the raise statement. This location has the form ``file:line'', where
6539 file is the short file name (without path information) and line is the line
6540 number in the file. Note that in the case of the Zero Cost Exception
6541 mechanism, these messages become redundant with the Exception_Information that
6542 contains a full backtrace of the calling sequence, so they are disabled.
6543 To disable explicitly the generation of the source location message, use the
6544 Pragma @code{Discard_Names}.
6546 @cindex Suppression of checks
6547 @cindex Checks, suppression of
6548 @unnumberedsec 11.5(28): Suppression of Checks
6551 The implementation should minimize the code executed for checks that
6552 have been suppressed.
6556 @cindex Representation clauses
6557 @unnumberedsec 13.1 (21-24): Representation Clauses
6560 The recommended level of support for all representation items is
6561 qualified as follows:
6565 An implementation need not support representation items containing
6566 non-static expressions, except that an implementation should support a
6567 representation item for a given entity if each non-static expression in
6568 the representation item is a name that statically denotes a constant
6569 declared before the entity.
6571 Followed. In fact, GNAT goes beyond the recommended level of support
6572 by allowing nonstatic expressions in some representation clauses even
6573 without the need to declare constants initialized with the values of
6577 @smallexample @c ada
6580 for Y'Address use X'Address;>>
6586 An implementation need not support a specification for the @code{Size}
6587 for a given composite subtype, nor the size or storage place for an
6588 object (including a component) of a given composite subtype, unless the
6589 constraints on the subtype and its composite subcomponents (if any) are
6590 all static constraints.
6592 Followed. Size Clauses are not permitted on non-static components, as
6597 An aliased component, or a component whose type is by-reference, should
6598 always be allocated at an addressable location.
6602 @cindex Packed types
6603 @unnumberedsec 13.2(6-8): Packed Types
6606 If a type is packed, then the implementation should try to minimize
6607 storage allocated to objects of the type, possibly at the expense of
6608 speed of accessing components, subject to reasonable complexity in
6609 addressing calculations.
6613 The recommended level of support pragma @code{Pack} is:
6615 For a packed record type, the components should be packed as tightly as
6616 possible subject to the Sizes of the component subtypes, and subject to
6617 any @code{record_representation_clause} that applies to the type; the
6618 implementation may, but need not, reorder components or cross aligned
6619 word boundaries to improve the packing. A component whose @code{Size} is
6620 greater than the word size may be allocated an integral number of words.
6622 Followed. Tight packing of arrays is supported for all component sizes
6623 up to 64-bits. If the array component size is 1 (that is to say, if
6624 the component is a boolean type or an enumeration type with two values)
6625 then values of the type are implicitly initialized to zero. This
6626 happens both for objects of the packed type, and for objects that have a
6627 subcomponent of the packed type.
6631 An implementation should support Address clauses for imported
6635 @cindex @code{Address} clauses
6636 @unnumberedsec 13.3(14-19): Address Clauses
6640 For an array @var{X}, @code{@var{X}'Address} should point at the first
6641 component of the array, and not at the array bounds.
6647 The recommended level of support for the @code{Address} attribute is:
6649 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6650 object that is aliased or of a by-reference type, or is an entity whose
6651 @code{Address} has been specified.
6653 Followed. A valid address will be produced even if none of those
6654 conditions have been met. If necessary, the object is forced into
6655 memory to ensure the address is valid.
6659 An implementation should support @code{Address} clauses for imported
6666 Objects (including subcomponents) that are aliased or of a by-reference
6667 type should be allocated on storage element boundaries.
6673 If the @code{Address} of an object is specified, or it is imported or exported,
6674 then the implementation should not perform optimizations based on
6675 assumptions of no aliases.
6679 @cindex @code{Alignment} clauses
6680 @unnumberedsec 13.3(29-35): Alignment Clauses
6683 The recommended level of support for the @code{Alignment} attribute for
6686 An implementation should support specified Alignments that are factors
6687 and multiples of the number of storage elements per word, subject to the
6694 An implementation need not support specified @code{Alignment}s for
6695 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6696 loaded and stored by available machine instructions.
6702 An implementation need not support specified @code{Alignment}s that are
6703 greater than the maximum @code{Alignment} the implementation ever returns by
6710 The recommended level of support for the @code{Alignment} attribute for
6713 Same as above, for subtypes, but in addition:
6719 For stand-alone library-level objects of statically constrained
6720 subtypes, the implementation should support all @code{Alignment}s
6721 supported by the target linker. For example, page alignment is likely to
6722 be supported for such objects, but not for subtypes.
6726 @cindex @code{Size} clauses
6727 @unnumberedsec 13.3(42-43): Size Clauses
6730 The recommended level of support for the @code{Size} attribute of
6733 A @code{Size} clause should be supported for an object if the specified
6734 @code{Size} is at least as large as its subtype's @code{Size}, and
6735 corresponds to a size in storage elements that is a multiple of the
6736 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6740 @unnumberedsec 13.3(50-56): Size Clauses
6743 If the @code{Size} of a subtype is specified, and allows for efficient
6744 independent addressability (see 9.10) on the target architecture, then
6745 the @code{Size} of the following objects of the subtype should equal the
6746 @code{Size} of the subtype:
6748 Aliased objects (including components).
6754 @code{Size} clause on a composite subtype should not affect the
6755 internal layout of components.
6757 Followed. But note that this can be overridden by use of the implementation
6758 pragma Implicit_Packing in the case of packed arrays.
6762 The recommended level of support for the @code{Size} attribute of subtypes is:
6766 The @code{Size} (if not specified) of a static discrete or fixed point
6767 subtype should be the number of bits needed to represent each value
6768 belonging to the subtype using an unbiased representation, leaving space
6769 for a sign bit only if the subtype contains negative values. If such a
6770 subtype is a first subtype, then an implementation should support a
6771 specified @code{Size} for it that reflects this representation.
6777 For a subtype implemented with levels of indirection, the @code{Size}
6778 should include the size of the pointers, but not the size of what they
6783 @cindex @code{Component_Size} clauses
6784 @unnumberedsec 13.3(71-73): Component Size Clauses
6787 The recommended level of support for the @code{Component_Size}
6792 An implementation need not support specified @code{Component_Sizes} that are
6793 less than the @code{Size} of the component subtype.
6799 An implementation should support specified @code{Component_Size}s that
6800 are factors and multiples of the word size. For such
6801 @code{Component_Size}s, the array should contain no gaps between
6802 components. For other @code{Component_Size}s (if supported), the array
6803 should contain no gaps between components when packing is also
6804 specified; the implementation should forbid this combination in cases
6805 where it cannot support a no-gaps representation.
6809 @cindex Enumeration representation clauses
6810 @cindex Representation clauses, enumeration
6811 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6814 The recommended level of support for enumeration representation clauses
6817 An implementation need not support enumeration representation clauses
6818 for boolean types, but should at minimum support the internal codes in
6819 the range @code{System.Min_Int.System.Max_Int}.
6823 @cindex Record representation clauses
6824 @cindex Representation clauses, records
6825 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6828 The recommended level of support for
6829 @*@code{record_representation_clauses} is:
6831 An implementation should support storage places that can be extracted
6832 with a load, mask, shift sequence of machine code, and set with a load,
6833 shift, mask, store sequence, given the available machine instructions
6840 A storage place should be supported if its size is equal to the
6841 @code{Size} of the component subtype, and it starts and ends on a
6842 boundary that obeys the @code{Alignment} of the component subtype.
6848 If the default bit ordering applies to the declaration of a given type,
6849 then for a component whose subtype's @code{Size} is less than the word
6850 size, any storage place that does not cross an aligned word boundary
6851 should be supported.
6857 An implementation may reserve a storage place for the tag field of a
6858 tagged type, and disallow other components from overlapping that place.
6860 Followed. The storage place for the tag field is the beginning of the tagged
6861 record, and its size is Address'Size. GNAT will reject an explicit component
6862 clause for the tag field.
6866 An implementation need not support a @code{component_clause} for a
6867 component of an extension part if the storage place is not after the
6868 storage places of all components of the parent type, whether or not
6869 those storage places had been specified.
6871 Followed. The above advice on record representation clauses is followed,
6872 and all mentioned features are implemented.
6874 @cindex Storage place attributes
6875 @unnumberedsec 13.5.2(5): Storage Place Attributes
6878 If a component is represented using some form of pointer (such as an
6879 offset) to the actual data of the component, and this data is contiguous
6880 with the rest of the object, then the storage place attributes should
6881 reflect the place of the actual data, not the pointer. If a component is
6882 allocated discontinuously from the rest of the object, then a warning
6883 should be generated upon reference to one of its storage place
6886 Followed. There are no such components in GNAT@.
6888 @cindex Bit ordering
6889 @unnumberedsec 13.5.3(7-8): Bit Ordering
6892 The recommended level of support for the non-default bit ordering is:
6896 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6897 should support the non-default bit ordering in addition to the default
6900 Followed. Word size does not equal storage size in this implementation.
6901 Thus non-default bit ordering is not supported.
6903 @cindex @code{Address}, as private type
6904 @unnumberedsec 13.7(37): Address as Private
6907 @code{Address} should be of a private type.
6911 @cindex Operations, on @code{Address}
6912 @cindex @code{Address}, operations of
6913 @unnumberedsec 13.7.1(16): Address Operations
6916 Operations in @code{System} and its children should reflect the target
6917 environment semantics as closely as is reasonable. For example, on most
6918 machines, it makes sense for address arithmetic to ``wrap around''.
6919 Operations that do not make sense should raise @code{Program_Error}.
6921 Followed. Address arithmetic is modular arithmetic that wraps around. No
6922 operation raises @code{Program_Error}, since all operations make sense.
6924 @cindex Unchecked conversion
6925 @unnumberedsec 13.9(14-17): Unchecked Conversion
6928 The @code{Size} of an array object should not include its bounds; hence,
6929 the bounds should not be part of the converted data.
6935 The implementation should not generate unnecessary run-time checks to
6936 ensure that the representation of @var{S} is a representation of the
6937 target type. It should take advantage of the permission to return by
6938 reference when possible. Restrictions on unchecked conversions should be
6939 avoided unless required by the target environment.
6941 Followed. There are no restrictions on unchecked conversion. A warning is
6942 generated if the source and target types do not have the same size since
6943 the semantics in this case may be target dependent.
6947 The recommended level of support for unchecked conversions is:
6951 Unchecked conversions should be supported and should be reversible in
6952 the cases where this clause defines the result. To enable meaningful use
6953 of unchecked conversion, a contiguous representation should be used for
6954 elementary subtypes, for statically constrained array subtypes whose
6955 component subtype is one of the subtypes described in this paragraph,
6956 and for record subtypes without discriminants whose component subtypes
6957 are described in this paragraph.
6961 @cindex Heap usage, implicit
6962 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6965 An implementation should document any cases in which it dynamically
6966 allocates heap storage for a purpose other than the evaluation of an
6969 Followed, the only other points at which heap storage is dynamically
6970 allocated are as follows:
6974 At initial elaboration time, to allocate dynamically sized global
6978 To allocate space for a task when a task is created.
6981 To extend the secondary stack dynamically when needed. The secondary
6982 stack is used for returning variable length results.
6987 A default (implementation-provided) storage pool for an
6988 access-to-constant type should not have overhead to support deallocation of
6995 A storage pool for an anonymous access type should be created at the
6996 point of an allocator for the type, and be reclaimed when the designated
6997 object becomes inaccessible.
7001 @cindex Unchecked deallocation
7002 @unnumberedsec 13.11.2(17): Unchecked De-allocation
7005 For a standard storage pool, @code{Free} should actually reclaim the
7010 @cindex Stream oriented attributes
7011 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
7014 If a stream element is the same size as a storage element, then the
7015 normal in-memory representation should be used by @code{Read} and
7016 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
7017 should use the smallest number of stream elements needed to represent
7018 all values in the base range of the scalar type.
7021 Followed. By default, GNAT uses the interpretation suggested by AI-195,
7022 which specifies using the size of the first subtype.
7023 However, such an implementation is based on direct binary
7024 representations and is therefore target- and endianness-dependent.
7025 To address this issue, GNAT also supplies an alternate implementation
7026 of the stream attributes @code{Read} and @code{Write},
7027 which uses the target-independent XDR standard representation
7029 @cindex XDR representation
7030 @cindex @code{Read} attribute
7031 @cindex @code{Write} attribute
7032 @cindex Stream oriented attributes
7033 The XDR implementation is provided as an alternative body of the
7034 @code{System.Stream_Attributes} package, in the file
7035 @file{s-strxdr.adb} in the GNAT library.
7036 There is no @file{s-strxdr.ads} file.
7037 In order to install the XDR implementation, do the following:
7039 @item Replace the default implementation of the
7040 @code{System.Stream_Attributes} package with the XDR implementation.
7041 For example on a Unix platform issue the commands:
7043 $ mv s-stratt.adb s-strold.adb
7044 $ mv s-strxdr.adb s-stratt.adb
7048 Rebuild the GNAT run-time library as documented in
7049 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7052 @unnumberedsec A.1(52): Names of Predefined Numeric Types
7055 If an implementation provides additional named predefined integer types,
7056 then the names should end with @samp{Integer} as in
7057 @samp{Long_Integer}. If an implementation provides additional named
7058 predefined floating point types, then the names should end with
7059 @samp{Float} as in @samp{Long_Float}.
7063 @findex Ada.Characters.Handling
7064 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7067 If an implementation provides a localized definition of @code{Character}
7068 or @code{Wide_Character}, then the effects of the subprograms in
7069 @code{Characters.Handling} should reflect the localizations. See also
7072 Followed. GNAT provides no such localized definitions.
7074 @cindex Bounded-length strings
7075 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7078 Bounded string objects should not be implemented by implicit pointers
7079 and dynamic allocation.
7081 Followed. No implicit pointers or dynamic allocation are used.
7083 @cindex Random number generation
7084 @unnumberedsec A.5.2(46-47): Random Number Generation
7087 Any storage associated with an object of type @code{Generator} should be
7088 reclaimed on exit from the scope of the object.
7094 If the generator period is sufficiently long in relation to the number
7095 of distinct initiator values, then each possible value of
7096 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7097 random numbers that does not, in a practical sense, overlap the sequence
7098 initiated by any other value. If this is not possible, then the mapping
7099 between initiator values and generator states should be a rapidly
7100 varying function of the initiator value.
7102 Followed. The generator period is sufficiently long for the first
7103 condition here to hold true.
7105 @findex Get_Immediate
7106 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7109 The @code{Get_Immediate} procedures should be implemented with
7110 unbuffered input. For a device such as a keyboard, input should be
7111 @dfn{available} if a key has already been typed, whereas for a disk
7112 file, input should always be available except at end of file. For a file
7113 associated with a keyboard-like device, any line-editing features of the
7114 underlying operating system should be disabled during the execution of
7115 @code{Get_Immediate}.
7117 Followed on all targets except VxWorks. For VxWorks, there is no way to
7118 provide this functionality that does not result in the input buffer being
7119 flushed before the @code{Get_Immediate} call. A special unit
7120 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7124 @unnumberedsec B.1(39-41): Pragma @code{Export}
7127 If an implementation supports pragma @code{Export} to a given language,
7128 then it should also allow the main subprogram to be written in that
7129 language. It should support some mechanism for invoking the elaboration
7130 of the Ada library units included in the system, and for invoking the
7131 finalization of the environment task. On typical systems, the
7132 recommended mechanism is to provide two subprograms whose link names are
7133 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
7134 elaboration code for library units. @code{adafinal} should contain the
7135 finalization code. These subprograms should have no effect the second
7136 and subsequent time they are called.
7142 Automatic elaboration of pre-elaborated packages should be
7143 provided when pragma @code{Export} is supported.
7145 Followed when the main program is in Ada. If the main program is in a
7146 foreign language, then
7147 @code{adainit} must be called to elaborate pre-elaborated
7152 For each supported convention @var{L} other than @code{Intrinsic}, an
7153 implementation should support @code{Import} and @code{Export} pragmas
7154 for objects of @var{L}-compatible types and for subprograms, and pragma
7155 @code{Convention} for @var{L}-eligible types and for subprograms,
7156 presuming the other language has corresponding features. Pragma
7157 @code{Convention} need not be supported for scalar types.
7161 @cindex Package @code{Interfaces}
7163 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7166 For each implementation-defined convention identifier, there should be a
7167 child package of package Interfaces with the corresponding name. This
7168 package should contain any declarations that would be useful for
7169 interfacing to the language (implementation) represented by the
7170 convention. Any declarations useful for interfacing to any language on
7171 the given hardware architecture should be provided directly in
7174 Followed. An additional package not defined
7175 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7176 for interfacing to C++.
7180 An implementation supporting an interface to C, COBOL, or Fortran should
7181 provide the corresponding package or packages described in the following
7184 Followed. GNAT provides all the packages described in this section.
7186 @cindex C, interfacing with
7187 @unnumberedsec B.3(63-71): Interfacing with C
7190 An implementation should support the following interface correspondences
7197 An Ada procedure corresponds to a void-returning C function.
7203 An Ada function corresponds to a non-void C function.
7209 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7216 An Ada @code{in} parameter of an access-to-object type with designated
7217 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7218 where @var{t} is the C type corresponding to the Ada type @var{T}.
7224 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7225 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7226 argument to a C function, where @var{t} is the C type corresponding to
7227 the Ada type @var{T}. In the case of an elementary @code{out} or
7228 @code{in out} parameter, a pointer to a temporary copy is used to
7229 preserve by-copy semantics.
7235 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7236 @code{@var{t}*} argument to a C function, where @var{t} is the C
7237 structure corresponding to the Ada type @var{T}.
7239 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
7240 pragma, or Convention, or by explicitly specifying the mechanism for a given
7241 call using an extended import or export pragma.
7245 An Ada parameter of an array type with component type @var{T}, of any
7246 mode, is passed as a @code{@var{t}*} argument to a C function, where
7247 @var{t} is the C type corresponding to the Ada type @var{T}.
7253 An Ada parameter of an access-to-subprogram type is passed as a pointer
7254 to a C function whose prototype corresponds to the designated
7255 subprogram's specification.
7259 @cindex COBOL, interfacing with
7260 @unnumberedsec B.4(95-98): Interfacing with COBOL
7263 An Ada implementation should support the following interface
7264 correspondences between Ada and COBOL@.
7270 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7271 the COBOL type corresponding to @var{T}.
7277 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7278 the corresponding COBOL type.
7284 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7285 COBOL type corresponding to the Ada parameter type; for scalars, a local
7286 copy is used if necessary to ensure by-copy semantics.
7290 @cindex Fortran, interfacing with
7291 @unnumberedsec B.5(22-26): Interfacing with Fortran
7294 An Ada implementation should support the following interface
7295 correspondences between Ada and Fortran:
7301 An Ada procedure corresponds to a Fortran subroutine.
7307 An Ada function corresponds to a Fortran function.
7313 An Ada parameter of an elementary, array, or record type @var{T} is
7314 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7315 the Fortran type corresponding to the Ada type @var{T}, and where the
7316 INTENT attribute of the corresponding dummy argument matches the Ada
7317 formal parameter mode; the Fortran implementation's parameter passing
7318 conventions are used. For elementary types, a local copy is used if
7319 necessary to ensure by-copy semantics.
7325 An Ada parameter of an access-to-subprogram type is passed as a
7326 reference to a Fortran procedure whose interface corresponds to the
7327 designated subprogram's specification.
7331 @cindex Machine operations
7332 @unnumberedsec C.1(3-5): Access to Machine Operations
7335 The machine code or intrinsic support should allow access to all
7336 operations normally available to assembly language programmers for the
7337 target environment, including privileged instructions, if any.
7343 The interfacing pragmas (see Annex B) should support interface to
7344 assembler; the default assembler should be associated with the
7345 convention identifier @code{Assembler}.
7351 If an entity is exported to assembly language, then the implementation
7352 should allocate it at an addressable location, and should ensure that it
7353 is retained by the linking process, even if not otherwise referenced
7354 from the Ada code. The implementation should assume that any call to a
7355 machine code or assembler subprogram is allowed to read or update every
7356 object that is specified as exported.
7360 @unnumberedsec C.1(10-16): Access to Machine Operations
7363 The implementation should ensure that little or no overhead is
7364 associated with calling intrinsic and machine-code subprograms.
7366 Followed for both intrinsics and machine-code subprograms.
7370 It is recommended that intrinsic subprograms be provided for convenient
7371 access to any machine operations that provide special capabilities or
7372 efficiency and that are not otherwise available through the language
7375 Followed. A full set of machine operation intrinsic subprograms is provided.
7379 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7380 swap, decrement and test, enqueue/dequeue.
7382 Followed on any target supporting such operations.
7386 Standard numeric functions---e.g.@:, sin, log.
7388 Followed on any target supporting such operations.
7392 String manipulation operations---e.g.@:, translate and test.
7394 Followed on any target supporting such operations.
7398 Vector operations---e.g.@:, compare vector against thresholds.
7400 Followed on any target supporting such operations.
7404 Direct operations on I/O ports.
7406 Followed on any target supporting such operations.
7408 @cindex Interrupt support
7409 @unnumberedsec C.3(28): Interrupt Support
7412 If the @code{Ceiling_Locking} policy is not in effect, the
7413 implementation should provide means for the application to specify which
7414 interrupts are to be blocked during protected actions, if the underlying
7415 system allows for a finer-grain control of interrupt blocking.
7417 Followed. The underlying system does not allow for finer-grain control
7418 of interrupt blocking.
7420 @cindex Protected procedure handlers
7421 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7424 Whenever possible, the implementation should allow interrupt handlers to
7425 be called directly by the hardware.
7429 This is never possible under IRIX, so this is followed by default.
7431 Followed on any target where the underlying operating system permits
7436 Whenever practical, violations of any
7437 implementation-defined restrictions should be detected before run time.
7439 Followed. Compile time warnings are given when possible.
7441 @cindex Package @code{Interrupts}
7443 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7447 If implementation-defined forms of interrupt handler procedures are
7448 supported, such as protected procedures with parameters, then for each
7449 such form of a handler, a type analogous to @code{Parameterless_Handler}
7450 should be specified in a child package of @code{Interrupts}, with the
7451 same operations as in the predefined package Interrupts.
7455 @cindex Pre-elaboration requirements
7456 @unnumberedsec C.4(14): Pre-elaboration Requirements
7459 It is recommended that pre-elaborated packages be implemented in such a
7460 way that there should be little or no code executed at run time for the
7461 elaboration of entities not already covered by the Implementation
7464 Followed. Executable code is generated in some cases, e.g.@: loops
7465 to initialize large arrays.
7467 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7471 If the pragma applies to an entity, then the implementation should
7472 reduce the amount of storage used for storing names associated with that
7477 @cindex Package @code{Task_Attributes}
7478 @findex Task_Attributes
7479 @unnumberedsec C.7.2(30): The Package Task_Attributes
7482 Some implementations are targeted to domains in which memory use at run
7483 time must be completely deterministic. For such implementations, it is
7484 recommended that the storage for task attributes will be pre-allocated
7485 statically and not from the heap. This can be accomplished by either
7486 placing restrictions on the number and the size of the task's
7487 attributes, or by using the pre-allocated storage for the first @var{N}
7488 attribute objects, and the heap for the others. In the latter case,
7489 @var{N} should be documented.
7491 Not followed. This implementation is not targeted to such a domain.
7493 @cindex Locking Policies
7494 @unnumberedsec D.3(17): Locking Policies
7498 The implementation should use names that end with @samp{_Locking} for
7499 locking policies defined by the implementation.
7501 Followed. A single implementation-defined locking policy is defined,
7502 whose name (@code{Inheritance_Locking}) follows this suggestion.
7504 @cindex Entry queuing policies
7505 @unnumberedsec D.4(16): Entry Queuing Policies
7508 Names that end with @samp{_Queuing} should be used
7509 for all implementation-defined queuing policies.
7511 Followed. No such implementation-defined queuing policies exist.
7513 @cindex Preemptive abort
7514 @unnumberedsec D.6(9-10): Preemptive Abort
7517 Even though the @code{abort_statement} is included in the list of
7518 potentially blocking operations (see 9.5.1), it is recommended that this
7519 statement be implemented in a way that never requires the task executing
7520 the @code{abort_statement} to block.
7526 On a multi-processor, the delay associated with aborting a task on
7527 another processor should be bounded; the implementation should use
7528 periodic polling, if necessary, to achieve this.
7532 @cindex Tasking restrictions
7533 @unnumberedsec D.7(21): Tasking Restrictions
7536 When feasible, the implementation should take advantage of the specified
7537 restrictions to produce a more efficient implementation.
7539 GNAT currently takes advantage of these restrictions by providing an optimized
7540 run time when the Ravenscar profile and the GNAT restricted run time set
7541 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
7542 pragma @code{Profile (Restricted)} for more details.
7544 @cindex Time, monotonic
7545 @unnumberedsec D.8(47-49): Monotonic Time
7548 When appropriate, implementations should provide configuration
7549 mechanisms to change the value of @code{Tick}.
7551 Such configuration mechanisms are not appropriate to this implementation
7552 and are thus not supported.
7556 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7557 be implemented as transformations of the same time base.
7563 It is recommended that the @dfn{best} time base which exists in
7564 the underlying system be available to the application through
7565 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
7569 @cindex Partition communication subsystem
7571 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7574 Whenever possible, the PCS on the called partition should allow for
7575 multiple tasks to call the RPC-receiver with different messages and
7576 should allow them to block until the corresponding subprogram body
7579 Followed by GLADE, a separately supplied PCS that can be used with
7584 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7585 should raise @code{Storage_Error} if it runs out of space trying to
7586 write the @code{Item} into the stream.
7588 Followed by GLADE, a separately supplied PCS that can be used with
7591 @cindex COBOL support
7592 @unnumberedsec F(7): COBOL Support
7595 If COBOL (respectively, C) is widely supported in the target
7596 environment, implementations supporting the Information Systems Annex
7597 should provide the child package @code{Interfaces.COBOL} (respectively,
7598 @code{Interfaces.C}) specified in Annex B and should support a
7599 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7600 pragmas (see Annex B), thus allowing Ada programs to interface with
7601 programs written in that language.
7605 @cindex Decimal radix support
7606 @unnumberedsec F.1(2): Decimal Radix Support
7609 Packed decimal should be used as the internal representation for objects
7610 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7612 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
7616 @unnumberedsec G: Numerics
7619 If Fortran (respectively, C) is widely supported in the target
7620 environment, implementations supporting the Numerics Annex
7621 should provide the child package @code{Interfaces.Fortran} (respectively,
7622 @code{Interfaces.C}) specified in Annex B and should support a
7623 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7624 pragmas (see Annex B), thus allowing Ada programs to interface with
7625 programs written in that language.
7629 @cindex Complex types
7630 @unnumberedsec G.1.1(56-58): Complex Types
7633 Because the usual mathematical meaning of multiplication of a complex
7634 operand and a real operand is that of the scaling of both components of
7635 the former by the latter, an implementation should not perform this
7636 operation by first promoting the real operand to complex type and then
7637 performing a full complex multiplication. In systems that, in the
7638 future, support an Ada binding to IEC 559:1989, the latter technique
7639 will not generate the required result when one of the components of the
7640 complex operand is infinite. (Explicit multiplication of the infinite
7641 component by the zero component obtained during promotion yields a NaN
7642 that propagates into the final result.) Analogous advice applies in the
7643 case of multiplication of a complex operand and a pure-imaginary
7644 operand, and in the case of division of a complex operand by a real or
7645 pure-imaginary operand.
7651 Similarly, because the usual mathematical meaning of addition of a
7652 complex operand and a real operand is that the imaginary operand remains
7653 unchanged, an implementation should not perform this operation by first
7654 promoting the real operand to complex type and then performing a full
7655 complex addition. In implementations in which the @code{Signed_Zeros}
7656 attribute of the component type is @code{True} (and which therefore
7657 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7658 predefined arithmetic operations), the latter technique will not
7659 generate the required result when the imaginary component of the complex
7660 operand is a negatively signed zero. (Explicit addition of the negative
7661 zero to the zero obtained during promotion yields a positive zero.)
7662 Analogous advice applies in the case of addition of a complex operand
7663 and a pure-imaginary operand, and in the case of subtraction of a
7664 complex operand and a real or pure-imaginary operand.
7670 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7671 attempt to provide a rational treatment of the signs of zero results and
7672 result components. As one example, the result of the @code{Argument}
7673 function should have the sign of the imaginary component of the
7674 parameter @code{X} when the point represented by that parameter lies on
7675 the positive real axis; as another, the sign of the imaginary component
7676 of the @code{Compose_From_Polar} function should be the same as
7677 (respectively, the opposite of) that of the @code{Argument} parameter when that
7678 parameter has a value of zero and the @code{Modulus} parameter has a
7679 nonnegative (respectively, negative) value.
7683 @cindex Complex elementary functions
7684 @unnumberedsec G.1.2(49): Complex Elementary Functions
7687 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7688 @code{True} should attempt to provide a rational treatment of the signs
7689 of zero results and result components. For example, many of the complex
7690 elementary functions have components that are odd functions of one of
7691 the parameter components; in these cases, the result component should
7692 have the sign of the parameter component at the origin. Other complex
7693 elementary functions have zero components whose sign is opposite that of
7694 a parameter component at the origin, or is always positive or always
7699 @cindex Accuracy requirements
7700 @unnumberedsec G.2.4(19): Accuracy Requirements
7703 The versions of the forward trigonometric functions without a
7704 @code{Cycle} parameter should not be implemented by calling the
7705 corresponding version with a @code{Cycle} parameter of
7706 @code{2.0*Numerics.Pi}, since this will not provide the required
7707 accuracy in some portions of the domain. For the same reason, the
7708 version of @code{Log} without a @code{Base} parameter should not be
7709 implemented by calling the corresponding version with a @code{Base}
7710 parameter of @code{Numerics.e}.
7714 @cindex Complex arithmetic accuracy
7715 @cindex Accuracy, complex arithmetic
7716 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7720 The version of the @code{Compose_From_Polar} function without a
7721 @code{Cycle} parameter should not be implemented by calling the
7722 corresponding version with a @code{Cycle} parameter of
7723 @code{2.0*Numerics.Pi}, since this will not provide the required
7724 accuracy in some portions of the domain.
7728 @c -----------------------------------------
7729 @node Implementation Defined Characteristics
7730 @chapter Implementation Defined Characteristics
7733 In addition to the implementation dependent pragmas and attributes, and
7734 the implementation advice, there are a number of other Ada features
7735 that are potentially implementation dependent. These are mentioned
7736 throughout the Ada Reference Manual, and are summarized in Annex M@.
7738 A requirement for conforming Ada compilers is that they provide
7739 documentation describing how the implementation deals with each of these
7740 issues. In this chapter, you will find each point in Annex M listed
7741 followed by a description in italic font of how GNAT
7745 implementation on IRIX 5.3 operating system or greater
7747 handles the implementation dependence.
7749 You can use this chapter as a guide to minimizing implementation
7750 dependent features in your programs if portability to other compilers
7751 and other operating systems is an important consideration. The numbers
7752 in each section below correspond to the paragraph number in the Ada
7758 @strong{2}. Whether or not each recommendation given in Implementation
7759 Advice is followed. See 1.1.2(37).
7762 @xref{Implementation Advice}.
7767 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
7770 The complexity of programs that can be processed is limited only by the
7771 total amount of available virtual memory, and disk space for the
7772 generated object files.
7777 @strong{4}. Variations from the standard that are impractical to avoid
7778 given the implementation's execution environment. See 1.1.3(6).
7781 There are no variations from the standard.
7786 @strong{5}. Which @code{code_statement}s cause external
7787 interactions. See 1.1.3(10).
7790 Any @code{code_statement} can potentially cause external interactions.
7795 @strong{6}. The coded representation for the text of an Ada
7796 program. See 2.1(4).
7799 See separate section on source representation.
7804 @strong{7}. The control functions allowed in comments. See 2.1(14).
7807 See separate section on source representation.
7812 @strong{8}. The representation for an end of line. See 2.2(2).
7815 See separate section on source representation.
7820 @strong{9}. Maximum supported line length and lexical element
7821 length. See 2.2(15).
7824 The maximum line length is 255 characters and the maximum length of a
7825 lexical element is also 255 characters.
7830 @strong{10}. Implementation defined pragmas. See 2.8(14).
7834 @xref{Implementation Defined Pragmas}.
7839 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
7842 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7843 parameter, checks that the optimization flag is set, and aborts if it is
7849 @strong{12}. The sequence of characters of the value returned by
7850 @code{@var{S}'Image} when some of the graphic characters of
7851 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
7855 The sequence of characters is as defined by the wide character encoding
7856 method used for the source. See section on source representation for
7862 @strong{13}. The predefined integer types declared in
7863 @code{Standard}. See 3.5.4(25).
7867 @item Short_Short_Integer
7870 (Short) 16 bit signed
7874 64 bit signed (Alpha OpenVMS only)
7875 32 bit signed (all other targets)
7876 @item Long_Long_Integer
7883 @strong{14}. Any nonstandard integer types and the operators defined
7884 for them. See 3.5.4(26).
7887 There are no nonstandard integer types.
7892 @strong{15}. Any nonstandard real types and the operators defined for
7896 There are no nonstandard real types.
7901 @strong{16}. What combinations of requested decimal precision and range
7902 are supported for floating point types. See 3.5.7(7).
7905 The precision and range is as defined by the IEEE standard.
7910 @strong{17}. The predefined floating point types declared in
7911 @code{Standard}. See 3.5.7(16).
7918 (Short) 32 bit IEEE short
7921 @item Long_Long_Float
7922 64 bit IEEE long (80 bit IEEE long on x86 processors)
7928 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
7931 @code{Fine_Delta} is 2**(@minus{}63)
7936 @strong{19}. What combinations of small, range, and digits are
7937 supported for fixed point types. See 3.5.9(10).
7940 Any combinations are permitted that do not result in a small less than
7941 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7942 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7943 is 64 bits (true of all architectures except ia32), then the output from
7944 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
7945 is because floating-point conversions are used to convert fixed point.
7950 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
7951 within an unnamed @code{block_statement}. See 3.9(10).
7954 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7955 decimal integer are allocated.
7960 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
7963 @xref{Implementation Defined Attributes}.
7968 @strong{22}. Any implementation-defined time types. See 9.6(6).
7971 There are no implementation-defined time types.
7976 @strong{23}. The time base associated with relative delays.
7979 See 9.6(20). The time base used is that provided by the C library
7980 function @code{gettimeofday}.
7985 @strong{24}. The time base of the type @code{Calendar.Time}. See
7989 The time base used is that provided by the C library function
7990 @code{gettimeofday}.
7995 @strong{25}. The time zone used for package @code{Calendar}
7996 operations. See 9.6(24).
7999 The time zone used by package @code{Calendar} is the current system time zone
8000 setting for local time, as accessed by the C library function
8006 @strong{26}. Any limit on @code{delay_until_statements} of
8007 @code{select_statements}. See 9.6(29).
8010 There are no such limits.
8015 @strong{27}. Whether or not two non-overlapping parts of a composite
8016 object are independently addressable, in the case where packing, record
8017 layout, or @code{Component_Size} is specified for the object. See
8021 Separate components are independently addressable if they do not share
8022 overlapping storage units.
8027 @strong{28}. The representation for a compilation. See 10.1(2).
8030 A compilation is represented by a sequence of files presented to the
8031 compiler in a single invocation of the @command{gcc} command.
8036 @strong{29}. Any restrictions on compilations that contain multiple
8037 compilation_units. See 10.1(4).
8040 No single file can contain more than one compilation unit, but any
8041 sequence of files can be presented to the compiler as a single
8047 @strong{30}. The mechanisms for creating an environment and for adding
8048 and replacing compilation units. See 10.1.4(3).
8051 See separate section on compilation model.
8056 @strong{31}. The manner of explicitly assigning library units to a
8057 partition. See 10.2(2).
8060 If a unit contains an Ada main program, then the Ada units for the partition
8061 are determined by recursive application of the rules in the Ada Reference
8062 Manual section 10.2(2-6). In other words, the Ada units will be those that
8063 are needed by the main program, and then this definition of need is applied
8064 recursively to those units, and the partition contains the transitive
8065 closure determined by this relationship. In short, all the necessary units
8066 are included, with no need to explicitly specify the list. If additional
8067 units are required, e.g.@: by foreign language units, then all units must be
8068 mentioned in the context clause of one of the needed Ada units.
8070 If the partition contains no main program, or if the main program is in
8071 a language other than Ada, then GNAT
8072 provides the binder options @option{-z} and @option{-n} respectively, and in
8073 this case a list of units can be explicitly supplied to the binder for
8074 inclusion in the partition (all units needed by these units will also
8075 be included automatically). For full details on the use of these
8076 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8077 @value{EDITION} User's Guide}.
8082 @strong{32}. The implementation-defined means, if any, of specifying
8083 which compilation units are needed by a given compilation unit. See
8087 The units needed by a given compilation unit are as defined in
8088 the Ada Reference Manual section 10.2(2-6). There are no
8089 implementation-defined pragmas or other implementation-defined
8090 means for specifying needed units.
8095 @strong{33}. The manner of designating the main subprogram of a
8096 partition. See 10.2(7).
8099 The main program is designated by providing the name of the
8100 corresponding @file{ALI} file as the input parameter to the binder.
8105 @strong{34}. The order of elaboration of @code{library_items}. See
8109 The first constraint on ordering is that it meets the requirements of
8110 Chapter 10 of the Ada Reference Manual. This still leaves some
8111 implementation dependent choices, which are resolved by first
8112 elaborating bodies as early as possible (i.e., in preference to specs
8113 where there is a choice), and second by evaluating the immediate with
8114 clauses of a unit to determine the probably best choice, and
8115 third by elaborating in alphabetical order of unit names
8116 where a choice still remains.
8121 @strong{35}. Parameter passing and function return for the main
8122 subprogram. See 10.2(21).
8125 The main program has no parameters. It may be a procedure, or a function
8126 returning an integer type. In the latter case, the returned integer
8127 value is the return code of the program (overriding any value that
8128 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8133 @strong{36}. The mechanisms for building and running partitions. See
8137 GNAT itself supports programs with only a single partition. The GNATDIST
8138 tool provided with the GLADE package (which also includes an implementation
8139 of the PCS) provides a completely flexible method for building and running
8140 programs consisting of multiple partitions. See the separate GLADE manual
8146 @strong{37}. The details of program execution, including program
8147 termination. See 10.2(25).
8150 See separate section on compilation model.
8155 @strong{38}. The semantics of any non-active partitions supported by the
8156 implementation. See 10.2(28).
8159 Passive partitions are supported on targets where shared memory is
8160 provided by the operating system. See the GLADE reference manual for
8166 @strong{39}. The information returned by @code{Exception_Message}. See
8170 Exception message returns the null string unless a specific message has
8171 been passed by the program.
8176 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
8177 declared within an unnamed @code{block_statement}. See 11.4.1(12).
8180 Blocks have implementation defined names of the form @code{B@var{nnn}}
8181 where @var{nnn} is an integer.
8186 @strong{41}. The information returned by
8187 @code{Exception_Information}. See 11.4.1(13).
8190 @code{Exception_Information} returns a string in the following format:
8193 @emph{Exception_Name:} nnnnn
8194 @emph{Message:} mmmmm
8196 @emph{Call stack traceback locations:}
8197 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8205 @code{nnnn} is the fully qualified name of the exception in all upper
8206 case letters. This line is always present.
8209 @code{mmmm} is the message (this line present only if message is non-null)
8212 @code{ppp} is the Process Id value as a decimal integer (this line is
8213 present only if the Process Id is nonzero). Currently we are
8214 not making use of this field.
8217 The Call stack traceback locations line and the following values
8218 are present only if at least one traceback location was recorded.
8219 The values are given in C style format, with lower case letters
8220 for a-f, and only as many digits present as are necessary.
8224 The line terminator sequence at the end of each line, including
8225 the last line is a single @code{LF} character (@code{16#0A#}).
8230 @strong{42}. Implementation-defined check names. See 11.5(27).
8233 The implementation defined check name Alignment_Check controls checking of
8234 address clause values for proper alignment (that is, the address supplied
8235 must be consistent with the alignment of the type).
8237 In addition, a user program can add implementation-defined check names
8238 by means of the pragma Check_Name.
8243 @strong{43}. The interpretation of each aspect of representation. See
8247 See separate section on data representations.
8252 @strong{44}. Any restrictions placed upon representation items. See
8256 See separate section on data representations.
8261 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
8265 Size for an indefinite subtype is the maximum possible size, except that
8266 for the case of a subprogram parameter, the size of the parameter object
8272 @strong{46}. The default external representation for a type tag. See
8276 The default external representation for a type tag is the fully expanded
8277 name of the type in upper case letters.
8282 @strong{47}. What determines whether a compilation unit is the same in
8283 two different partitions. See 13.3(76).
8286 A compilation unit is the same in two different partitions if and only
8287 if it derives from the same source file.
8292 @strong{48}. Implementation-defined components. See 13.5.1(15).
8295 The only implementation defined component is the tag for a tagged type,
8296 which contains a pointer to the dispatching table.
8301 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
8302 ordering. See 13.5.3(5).
8305 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8306 implementation, so no non-default bit ordering is supported. The default
8307 bit ordering corresponds to the natural endianness of the target architecture.
8312 @strong{50}. The contents of the visible part of package @code{System}
8313 and its language-defined children. See 13.7(2).
8316 See the definition of these packages in files @file{system.ads} and
8317 @file{s-stoele.ads}.
8322 @strong{51}. The contents of the visible part of package
8323 @code{System.Machine_Code}, and the meaning of
8324 @code{code_statements}. See 13.8(7).
8327 See the definition and documentation in file @file{s-maccod.ads}.
8332 @strong{52}. The effect of unchecked conversion. See 13.9(11).
8335 Unchecked conversion between types of the same size
8336 results in an uninterpreted transmission of the bits from one type
8337 to the other. If the types are of unequal sizes, then in the case of
8338 discrete types, a shorter source is first zero or sign extended as
8339 necessary, and a shorter target is simply truncated on the left.
8340 For all non-discrete types, the source is first copied if necessary
8341 to ensure that the alignment requirements of the target are met, then
8342 a pointer is constructed to the source value, and the result is obtained
8343 by dereferencing this pointer after converting it to be a pointer to the
8344 target type. Unchecked conversions where the target subtype is an
8345 unconstrained array are not permitted. If the target alignment is
8346 greater than the source alignment, then a copy of the result is
8347 made with appropriate alignment
8352 @strong{53}. The manner of choosing a storage pool for an access type
8353 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
8356 There are 3 different standard pools used by the compiler when
8357 @code{Storage_Pool} is not specified depending whether the type is local
8358 to a subprogram or defined at the library level and whether
8359 @code{Storage_Size}is specified or not. See documentation in the runtime
8360 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8361 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8362 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8368 @strong{54}. Whether or not the implementation provides user-accessible
8369 names for the standard pool type(s). See 13.11(17).
8373 See documentation in the sources of the run time mentioned in paragraph
8374 @strong{53} . All these pools are accessible by means of @code{with}'ing
8380 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
8383 @code{Storage_Size} is measured in storage units, and refers to the
8384 total space available for an access type collection, or to the primary
8385 stack space for a task.
8390 @strong{56}. Implementation-defined aspects of storage pools. See
8394 See documentation in the sources of the run time mentioned in paragraph
8395 @strong{53} for details on GNAT-defined aspects of storage pools.
8400 @strong{57}. The set of restrictions allowed in a pragma
8401 @code{Restrictions}. See 13.12(7).
8404 All RM defined Restriction identifiers are implemented. The following
8405 additional restriction identifiers are provided. There are two separate
8406 lists of implementation dependent restriction identifiers. The first
8407 set requires consistency throughout a partition (in other words, if the
8408 restriction identifier is used for any compilation unit in the partition,
8409 then all compilation units in the partition must obey the restriction.
8413 @item Simple_Barriers
8414 @findex Simple_Barriers
8415 This restriction ensures at compile time that barriers in entry declarations
8416 for protected types are restricted to either static boolean expressions or
8417 references to simple boolean variables defined in the private part of the
8418 protected type. No other form of entry barriers is permitted. This is one
8419 of the restrictions of the Ravenscar profile for limited tasking (see also
8420 pragma @code{Profile (Ravenscar)}).
8422 @item Max_Entry_Queue_Length => Expr
8423 @findex Max_Entry_Queue_Length
8424 This restriction is a declaration that any protected entry compiled in
8425 the scope of the restriction has at most the specified number of
8426 tasks waiting on the entry
8427 at any one time, and so no queue is required. This restriction is not
8428 checked at compile time. A program execution is erroneous if an attempt
8429 is made to queue more than the specified number of tasks on such an entry.
8433 This restriction ensures at compile time that there is no implicit or
8434 explicit dependence on the package @code{Ada.Calendar}.
8436 @item No_Default_Initialization
8437 @findex No_Default_Initialization
8439 This restriction prohibits any instance of default initialization of variables.
8440 The binder implements a consistency rule which prevents any unit compiled
8441 without the restriction from with'ing a unit with the restriction (this allows
8442 the generation of initialization procedures to be skipped, since you can be
8443 sure that no call is ever generated to an initialization procedure in a unit
8444 with the restriction active). If used in conjunction with Initialize_Scalars or
8445 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8446 without a specific initializer (including the case of OUT scalar parameters).
8448 @item No_Direct_Boolean_Operators
8449 @findex No_Direct_Boolean_Operators
8450 This restriction ensures that no logical (and/or/xor) are used on
8451 operands of type Boolean (or any type derived
8452 from Boolean). This is intended for use in safety critical programs
8453 where the certification protocol requires the use of short-circuit
8454 (and then, or else) forms for all composite boolean operations.
8456 @item No_Dispatching_Calls
8457 @findex No_Dispatching_Calls
8458 This restriction ensures at compile time that the code generated by the
8459 compiler involves no dispatching calls. The use of this restriction allows the
8460 safe use of record extensions, classwide membership tests and other classwide
8461 features not involving implicit dispatching. This restriction ensures that
8462 the code contains no indirect calls through a dispatching mechanism. Note that
8463 this includes internally-generated calls created by the compiler, for example
8464 in the implementation of class-wide objects assignments. The
8465 membership test is allowed in the presence of this restriction, because its
8466 implementation requires no dispatching.
8467 This restriction is comparable to the official Ada restriction
8468 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8469 all classwide constructs that do not imply dispatching.
8470 The following example indicates constructs that violate this restriction.
8474 type T is tagged record
8477 procedure P (X : T);
8479 type DT is new T with record
8480 More_Data : Natural;
8482 procedure Q (X : DT);
8486 procedure Example is
8487 procedure Test (O : T'Class) is
8488 N : Natural := O'Size;-- Error: Dispatching call
8489 C : T'Class := O; -- Error: implicit Dispatching Call
8491 if O in DT'Class then -- OK : Membership test
8492 Q (DT (O)); -- OK : Type conversion plus direct call
8494 P (O); -- Error: Dispatching call
8500 P (Obj); -- OK : Direct call
8501 P (T (Obj)); -- OK : Type conversion plus direct call
8502 P (T'Class (Obj)); -- Error: Dispatching call
8504 Test (Obj); -- OK : Type conversion
8506 if Obj in T'Class then -- OK : Membership test
8512 @item No_Dynamic_Attachment
8513 @findex No_Dynamic_Attachment
8514 This restriction ensures that there is no call to any of the operations
8515 defined in package Ada.Interrupts.
8517 @item No_Enumeration_Maps
8518 @findex No_Enumeration_Maps
8519 This restriction ensures at compile time that no operations requiring
8520 enumeration maps are used (that is Image and Value attributes applied
8521 to enumeration types).
8523 @item No_Entry_Calls_In_Elaboration_Code
8524 @findex No_Entry_Calls_In_Elaboration_Code
8525 This restriction ensures at compile time that no task or protected entry
8526 calls are made during elaboration code. As a result of the use of this
8527 restriction, the compiler can assume that no code past an accept statement
8528 in a task can be executed at elaboration time.
8530 @item No_Exception_Handlers
8531 @findex No_Exception_Handlers
8532 This restriction ensures at compile time that there are no explicit
8533 exception handlers. It also indicates that no exception propagation will
8534 be provided. In this mode, exceptions may be raised but will result in
8535 an immediate call to the last chance handler, a routine that the user
8536 must define with the following profile:
8538 @smallexample @c ada
8539 procedure Last_Chance_Handler
8540 (Source_Location : System.Address; Line : Integer);
8541 pragma Export (C, Last_Chance_Handler,
8542 "__gnat_last_chance_handler");
8545 The parameter is a C null-terminated string representing a message to be
8546 associated with the exception (typically the source location of the raise
8547 statement generated by the compiler). The Line parameter when nonzero
8548 represents the line number in the source program where the raise occurs.
8550 @item No_Exception_Propagation
8551 @findex No_Exception_Propagation
8552 This restriction guarantees that exceptions are never propagated to an outer
8553 subprogram scope). The only case in which an exception may be raised is when
8554 the handler is statically in the same subprogram, so that the effect of a raise
8555 is essentially like a goto statement. Any other raise statement (implicit or
8556 explicit) will be considered unhandled. Exception handlers are allowed, but may
8557 not contain an exception occurrence identifier (exception choice). In addition
8558 use of the package GNAT.Current_Exception is not permitted, and reraise
8559 statements (raise with no operand) are not permitted.
8561 @item No_Exception_Registration
8562 @findex No_Exception_Registration
8563 This restriction ensures at compile time that no stream operations for
8564 types Exception_Id or Exception_Occurrence are used. This also makes it
8565 impossible to pass exceptions to or from a partition with this restriction
8566 in a distributed environment. If this exception is active, then the generated
8567 code is simplified by omitting the otherwise-required global registration
8568 of exceptions when they are declared.
8570 @item No_Implicit_Conditionals
8571 @findex No_Implicit_Conditionals
8572 This restriction ensures that the generated code does not contain any
8573 implicit conditionals, either by modifying the generated code where possible,
8574 or by rejecting any construct that would otherwise generate an implicit
8575 conditional. Note that this check does not include run time constraint
8576 checks, which on some targets may generate implicit conditionals as
8577 well. To control the latter, constraint checks can be suppressed in the
8578 normal manner. Constructs generating implicit conditionals include comparisons
8579 of composite objects and the Max/Min attributes.
8581 @item No_Implicit_Dynamic_Code
8582 @findex No_Implicit_Dynamic_Code
8584 This restriction prevents the compiler from building ``trampolines''.
8585 This is a structure that is built on the stack and contains dynamic
8586 code to be executed at run time. On some targets, a trampoline is
8587 built for the following features: @code{Access},
8588 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8589 nested task bodies; primitive operations of nested tagged types.
8590 Trampolines do not work on machines that prevent execution of stack
8591 data. For example, on windows systems, enabling DEP (data execution
8592 protection) will cause trampolines to raise an exception.
8593 Trampolines are also quite slow at run time.
8595 On many targets, trampolines have been largely eliminated. Look at the
8596 version of system.ads for your target --- if it has
8597 Always_Compatible_Rep equal to False, then trampolines are largely
8598 eliminated. In particular, a trampoline is built for the following
8599 features: @code{Address} of a nested subprogram;
8600 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8601 but only if pragma Favor_Top_Level applies, or the access type has a
8602 foreign-language convention; primitive operations of nested tagged
8605 @item No_Implicit_Loops
8606 @findex No_Implicit_Loops
8607 This restriction ensures that the generated code does not contain any
8608 implicit @code{for} loops, either by modifying
8609 the generated code where possible,
8610 or by rejecting any construct that would otherwise generate an implicit
8611 @code{for} loop. If this restriction is active, it is possible to build
8612 large array aggregates with all static components without generating an
8613 intermediate temporary, and without generating a loop to initialize individual
8614 components. Otherwise, a loop is created for arrays larger than about 5000
8617 @item No_Initialize_Scalars
8618 @findex No_Initialize_Scalars
8619 This restriction ensures that no unit in the partition is compiled with
8620 pragma Initialize_Scalars. This allows the generation of more efficient
8621 code, and in particular eliminates dummy null initialization routines that
8622 are otherwise generated for some record and array types.
8624 @item No_Local_Protected_Objects
8625 @findex No_Local_Protected_Objects
8626 This restriction ensures at compile time that protected objects are
8627 only declared at the library level.
8629 @item No_Protected_Type_Allocators
8630 @findex No_Protected_Type_Allocators
8631 This restriction ensures at compile time that there are no allocator
8632 expressions that attempt to allocate protected objects.
8634 @item No_Secondary_Stack
8635 @findex No_Secondary_Stack
8636 This restriction ensures at compile time that the generated code does not
8637 contain any reference to the secondary stack. The secondary stack is used
8638 to implement functions returning unconstrained objects (arrays or records)
8641 @item No_Select_Statements
8642 @findex No_Select_Statements
8643 This restriction ensures at compile time no select statements of any kind
8644 are permitted, that is the keyword @code{select} may not appear.
8645 This is one of the restrictions of the Ravenscar
8646 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8648 @item No_Standard_Storage_Pools
8649 @findex No_Standard_Storage_Pools
8650 This restriction ensures at compile time that no access types
8651 use the standard default storage pool. Any access type declared must
8652 have an explicit Storage_Pool attribute defined specifying a
8653 user-defined storage pool.
8657 This restriction ensures at compile/bind time that there are no
8658 stream objects created and no use of stream attributes.
8659 This restriction does not forbid dependences on the package
8660 @code{Ada.Streams}. So it is permissible to with
8661 @code{Ada.Streams} (or another package that does so itself)
8662 as long as no actual stream objects are created and no
8663 stream attributes are used.
8665 Note that the use of restriction allows optimization of tagged types,
8666 since they do not need to worry about dispatching stream operations.
8667 To take maximum advantage of this space-saving optimization, any
8668 unit declaring a tagged type should be compiled with the restriction,
8669 though this is not required.
8671 @item No_Task_Attributes_Package
8672 @findex No_Task_Attributes_Package
8673 This restriction ensures at compile time that there are no implicit or
8674 explicit dependencies on the package @code{Ada.Task_Attributes}.
8676 @item No_Task_Termination
8677 @findex No_Task_Termination
8678 This restriction ensures at compile time that no terminate alternatives
8679 appear in any task body.
8683 This restriction prevents the declaration of tasks or task types throughout
8684 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
8685 except that violations are caught at compile time and cause an error message
8686 to be output either by the compiler or binder.
8688 @item Static_Priorities
8689 @findex Static_Priorities
8690 This restriction ensures at compile time that all priority expressions
8691 are static, and that there are no dependencies on the package
8692 @code{Ada.Dynamic_Priorities}.
8694 @item Static_Storage_Size
8695 @findex Static_Storage_Size
8696 This restriction ensures at compile time that any expression appearing
8697 in a Storage_Size pragma or attribute definition clause is static.
8702 The second set of implementation dependent restriction identifiers
8703 does not require partition-wide consistency.
8704 The restriction may be enforced for a single
8705 compilation unit without any effect on any of the
8706 other compilation units in the partition.
8710 @item No_Elaboration_Code
8711 @findex No_Elaboration_Code
8712 This restriction ensures at compile time that no elaboration code is
8713 generated. Note that this is not the same condition as is enforced
8714 by pragma @code{Preelaborate}. There are cases in which pragma
8715 @code{Preelaborate} still permits code to be generated (e.g.@: code
8716 to initialize a large array to all zeroes), and there are cases of units
8717 which do not meet the requirements for pragma @code{Preelaborate},
8718 but for which no elaboration code is generated. Generally, it is
8719 the case that preelaborable units will meet the restrictions, with
8720 the exception of large aggregates initialized with an others_clause,
8721 and exception declarations (which generate calls to a run-time
8722 registry procedure). This restriction is enforced on
8723 a unit by unit basis, it need not be obeyed consistently
8724 throughout a partition.
8726 In the case of aggregates with others, if the aggregate has a dynamic
8727 size, there is no way to eliminate the elaboration code (such dynamic
8728 bounds would be incompatible with @code{Preelaborate} in any case). If
8729 the bounds are static, then use of this restriction actually modifies
8730 the code choice of the compiler to avoid generating a loop, and instead
8731 generate the aggregate statically if possible, no matter how many times
8732 the data for the others clause must be repeatedly generated.
8734 It is not possible to precisely document
8735 the constructs which are compatible with this restriction, since,
8736 unlike most other restrictions, this is not a restriction on the
8737 source code, but a restriction on the generated object code. For
8738 example, if the source contains a declaration:
8741 Val : constant Integer := X;
8745 where X is not a static constant, it may be possible, depending
8746 on complex optimization circuitry, for the compiler to figure
8747 out the value of X at compile time, in which case this initialization
8748 can be done by the loader, and requires no initialization code. It
8749 is not possible to document the precise conditions under which the
8750 optimizer can figure this out.
8752 Note that this the implementation of this restriction requires full
8753 code generation. If it is used in conjunction with "semantics only"
8754 checking, then some cases of violations may be missed.
8756 @item No_Entry_Queue
8757 @findex No_Entry_Queue
8758 This restriction is a declaration that any protected entry compiled in
8759 the scope of the restriction has at most one task waiting on the entry
8760 at any one time, and so no queue is required. This restriction is not
8761 checked at compile time. A program execution is erroneous if an attempt
8762 is made to queue a second task on such an entry.
8764 @item No_Implementation_Attributes
8765 @findex No_Implementation_Attributes
8766 This restriction checks at compile time that no GNAT-defined attributes
8767 are present. With this restriction, the only attributes that can be used
8768 are those defined in the Ada Reference Manual.
8770 @item No_Implementation_Pragmas
8771 @findex No_Implementation_Pragmas
8772 This restriction checks at compile time that no GNAT-defined pragmas
8773 are present. With this restriction, the only pragmas that can be used
8774 are those defined in the Ada Reference Manual.
8776 @item No_Implementation_Restrictions
8777 @findex No_Implementation_Restrictions
8778 This restriction checks at compile time that no GNAT-defined restriction
8779 identifiers (other than @code{No_Implementation_Restrictions} itself)
8780 are present. With this restriction, the only other restriction identifiers
8781 that can be used are those defined in the Ada Reference Manual.
8783 @item No_Wide_Characters
8784 @findex No_Wide_Characters
8785 This restriction ensures at compile time that no uses of the types
8786 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8788 appear, and that no wide or wide wide string or character literals
8789 appear in the program (that is literals representing characters not in
8790 type @code{Character}.
8797 @strong{58}. The consequences of violating limitations on
8798 @code{Restrictions} pragmas. See 13.12(9).
8801 Restrictions that can be checked at compile time result in illegalities
8802 if violated. Currently there are no other consequences of violating
8808 @strong{59}. The representation used by the @code{Read} and
8809 @code{Write} attributes of elementary types in terms of stream
8810 elements. See 13.13.2(9).
8813 The representation is the in-memory representation of the base type of
8814 the type, using the number of bits corresponding to the
8815 @code{@var{type}'Size} value, and the natural ordering of the machine.
8820 @strong{60}. The names and characteristics of the numeric subtypes
8821 declared in the visible part of package @code{Standard}. See A.1(3).
8824 See items describing the integer and floating-point types supported.
8829 @strong{61}. The accuracy actually achieved by the elementary
8830 functions. See A.5.1(1).
8833 The elementary functions correspond to the functions available in the C
8834 library. Only fast math mode is implemented.
8839 @strong{62}. The sign of a zero result from some of the operators or
8840 functions in @code{Numerics.Generic_Elementary_Functions}, when
8841 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
8844 The sign of zeroes follows the requirements of the IEEE 754 standard on
8850 @strong{63}. The value of
8851 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
8854 Maximum image width is 649, see library file @file{a-numran.ads}.
8859 @strong{64}. The value of
8860 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
8863 Maximum image width is 80, see library file @file{a-nudira.ads}.
8868 @strong{65}. The algorithms for random number generation. See
8872 The algorithm is documented in the source files @file{a-numran.ads} and
8873 @file{a-numran.adb}.
8878 @strong{66}. The string representation of a random number generator's
8879 state. See A.5.2(38).
8882 See the documentation contained in the file @file{a-numran.adb}.
8887 @strong{67}. The minimum time interval between calls to the
8888 time-dependent Reset procedure that are guaranteed to initiate different
8889 random number sequences. See A.5.2(45).
8892 The minimum period between reset calls to guarantee distinct series of
8893 random numbers is one microsecond.
8898 @strong{68}. The values of the @code{Model_Mantissa},
8899 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8900 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8901 Annex is not supported. See A.5.3(72).
8904 See the source file @file{ttypef.ads} for the values of all numeric
8910 @strong{69}. Any implementation-defined characteristics of the
8911 input-output packages. See A.7(14).
8914 There are no special implementation defined characteristics for these
8920 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
8924 All type representations are contiguous, and the @code{Buffer_Size} is
8925 the value of @code{@var{type}'Size} rounded up to the next storage unit
8931 @strong{71}. External files for standard input, standard output, and
8932 standard error See A.10(5).
8935 These files are mapped onto the files provided by the C streams
8936 libraries. See source file @file{i-cstrea.ads} for further details.
8941 @strong{72}. The accuracy of the value produced by @code{Put}. See
8945 If more digits are requested in the output than are represented by the
8946 precision of the value, zeroes are output in the corresponding least
8947 significant digit positions.
8952 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
8953 @code{Command_Name}. See A.15(1).
8956 These are mapped onto the @code{argv} and @code{argc} parameters of the
8957 main program in the natural manner.
8962 @strong{74}. Implementation-defined convention names. See B.1(11).
8965 The following convention names are supported
8973 Synonym for Assembler
8975 Synonym for Assembler
8978 @item C_Pass_By_Copy
8979 Allowed only for record types, like C, but also notes that record
8980 is to be passed by copy rather than reference.
8983 @item C_Plus_Plus (or CPP)
8986 Treated the same as C
8988 Treated the same as C
8992 For support of pragma @code{Import} with convention Intrinsic, see
8993 separate section on Intrinsic Subprograms.
8995 Stdcall (used for Windows implementations only). This convention correspond
8996 to the WINAPI (previously called Pascal convention) C/C++ convention under
8997 Windows. A function with this convention cleans the stack before exit.
9003 Stubbed is a special convention used to indicate that the body of the
9004 subprogram will be entirely ignored. Any call to the subprogram
9005 is converted into a raise of the @code{Program_Error} exception. If a
9006 pragma @code{Import} specifies convention @code{stubbed} then no body need
9007 be present at all. This convention is useful during development for the
9008 inclusion of subprograms whose body has not yet been written.
9012 In addition, all otherwise unrecognized convention names are also
9013 treated as being synonymous with convention C@. In all implementations
9014 except for VMS, use of such other names results in a warning. In VMS
9015 implementations, these names are accepted silently.
9020 @strong{75}. The meaning of link names. See B.1(36).
9023 Link names are the actual names used by the linker.
9028 @strong{76}. The manner of choosing link names when neither the link
9029 name nor the address of an imported or exported entity is specified. See
9033 The default linker name is that which would be assigned by the relevant
9034 external language, interpreting the Ada name as being in all lower case
9040 @strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37).
9043 The string passed to @code{Linker_Options} is presented uninterpreted as
9044 an argument to the link command, unless it contains ASCII.NUL characters.
9045 NUL characters if they appear act as argument separators, so for example
9047 @smallexample @c ada
9048 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9052 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9053 linker. The order of linker options is preserved for a given unit. The final
9054 list of options passed to the linker is in reverse order of the elaboration
9055 order. For example, linker options for a body always appear before the options
9056 from the corresponding package spec.
9061 @strong{78}. The contents of the visible part of package
9062 @code{Interfaces} and its language-defined descendants. See B.2(1).
9065 See files with prefix @file{i-} in the distributed library.
9070 @strong{79}. Implementation-defined children of package
9071 @code{Interfaces}. The contents of the visible part of package
9072 @code{Interfaces}. See B.2(11).
9075 See files with prefix @file{i-} in the distributed library.
9080 @strong{80}. The types @code{Floating}, @code{Long_Floating},
9081 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9082 @code{COBOL_Character}; and the initialization of the variables
9083 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9084 @code{Interfaces.COBOL}. See B.4(50).
9091 (Floating) Long_Float
9096 @item Decimal_Element
9098 @item COBOL_Character
9103 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9108 @strong{81}. Support for access to machine instructions. See C.1(1).
9111 See documentation in file @file{s-maccod.ads} in the distributed library.
9116 @strong{82}. Implementation-defined aspects of access to machine
9117 operations. See C.1(9).
9120 See documentation in file @file{s-maccod.ads} in the distributed library.
9125 @strong{83}. Implementation-defined aspects of interrupts. See C.3(2).
9128 Interrupts are mapped to signals or conditions as appropriate. See
9130 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9131 on the interrupts supported on a particular target.
9136 @strong{84}. Implementation-defined aspects of pre-elaboration. See
9140 GNAT does not permit a partition to be restarted without reloading,
9141 except under control of the debugger.
9146 @strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7).
9149 Pragma @code{Discard_Names} causes names of enumeration literals to
9150 be suppressed. In the presence of this pragma, the Image attribute
9151 provides the image of the Pos of the literal, and Value accepts
9157 @strong{86}. The result of the @code{Task_Identification.Image}
9158 attribute. See C.7.1(7).
9161 The result of this attribute is a string that identifies
9162 the object or component that denotes a given task. If a variable @code{Var}
9163 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9165 is the hexadecimal representation of the virtual address of the corresponding
9166 task control block. If the variable is an array of tasks, the image of each
9167 task will have the form of an indexed component indicating the position of a
9168 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9169 component of a record, the image of the task will have the form of a selected
9170 component. These rules are fully recursive, so that the image of a task that
9171 is a subcomponent of a composite object corresponds to the expression that
9172 designates this task.
9174 If a task is created by an allocator, its image depends on the context. If the
9175 allocator is part of an object declaration, the rules described above are used
9176 to construct its image, and this image is not affected by subsequent
9177 assignments. If the allocator appears within an expression, the image
9178 includes only the name of the task type.
9180 If the configuration pragma Discard_Names is present, or if the restriction
9181 No_Implicit_Heap_Allocation is in effect, the image reduces to
9182 the numeric suffix, that is to say the hexadecimal representation of the
9183 virtual address of the control block of the task.
9187 @strong{87}. The value of @code{Current_Task} when in a protected entry
9188 or interrupt handler. See C.7.1(17).
9191 Protected entries or interrupt handlers can be executed by any
9192 convenient thread, so the value of @code{Current_Task} is undefined.
9197 @strong{88}. The effect of calling @code{Current_Task} from an entry
9198 body or interrupt handler. See C.7.1(19).
9201 The effect of calling @code{Current_Task} from an entry body or
9202 interrupt handler is to return the identification of the task currently
9208 @strong{89}. Implementation-defined aspects of
9209 @code{Task_Attributes}. See C.7.2(19).
9212 There are no implementation-defined aspects of @code{Task_Attributes}.
9217 @strong{90}. Values of all @code{Metrics}. See D(2).
9220 The metrics information for GNAT depends on the performance of the
9221 underlying operating system. The sources of the run-time for tasking
9222 implementation, together with the output from @option{-gnatG} can be
9223 used to determine the exact sequence of operating systems calls made
9224 to implement various tasking constructs. Together with appropriate
9225 information on the performance of the underlying operating system,
9226 on the exact target in use, this information can be used to determine
9227 the required metrics.
9232 @strong{91}. The declarations of @code{Any_Priority} and
9233 @code{Priority}. See D.1(11).
9236 See declarations in file @file{system.ads}.
9241 @strong{92}. Implementation-defined execution resources. See D.1(15).
9244 There are no implementation-defined execution resources.
9249 @strong{93}. Whether, on a multiprocessor, a task that is waiting for
9250 access to a protected object keeps its processor busy. See D.2.1(3).
9253 On a multi-processor, a task that is waiting for access to a protected
9254 object does not keep its processor busy.
9259 @strong{94}. The affect of implementation defined execution resources
9260 on task dispatching. See D.2.1(9).
9265 Tasks map to IRIX threads, and the dispatching policy is as defined by
9266 the IRIX implementation of threads.
9268 Tasks map to threads in the threads package used by GNAT@. Where possible
9269 and appropriate, these threads correspond to native threads of the
9270 underlying operating system.
9275 @strong{95}. Implementation-defined @code{policy_identifiers} allowed
9276 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
9279 There are no implementation-defined policy-identifiers allowed in this
9285 @strong{96}. Implementation-defined aspects of priority inversion. See
9289 Execution of a task cannot be preempted by the implementation processing
9290 of delay expirations for lower priority tasks.
9295 @strong{97}. Implementation defined task dispatching. See D.2.2(18).
9300 Tasks map to IRIX threads, and the dispatching policy is as defined by
9301 the IRIX implementation of threads.
9303 The policy is the same as that of the underlying threads implementation.
9308 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
9309 in a pragma @code{Locking_Policy}. See D.3(4).
9312 The only implementation defined policy permitted in GNAT is
9313 @code{Inheritance_Locking}. On targets that support this policy, locking
9314 is implemented by inheritance, i.e.@: the task owning the lock operates
9315 at a priority equal to the highest priority of any task currently
9316 requesting the lock.
9321 @strong{99}. Default ceiling priorities. See D.3(10).
9324 The ceiling priority of protected objects of the type
9325 @code{System.Interrupt_Priority'Last} as described in the Ada
9326 Reference Manual D.3(10),
9331 @strong{100}. The ceiling of any protected object used internally by
9332 the implementation. See D.3(16).
9335 The ceiling priority of internal protected objects is
9336 @code{System.Priority'Last}.
9341 @strong{101}. Implementation-defined queuing policies. See D.4(1).
9344 There are no implementation-defined queuing policies.
9349 @strong{102}. On a multiprocessor, any conditions that cause the
9350 completion of an aborted construct to be delayed later than what is
9351 specified for a single processor. See D.6(3).
9354 The semantics for abort on a multi-processor is the same as on a single
9355 processor, there are no further delays.
9360 @strong{103}. Any operations that implicitly require heap storage
9361 allocation. See D.7(8).
9364 The only operation that implicitly requires heap storage allocation is
9370 @strong{104}. Implementation-defined aspects of pragma
9371 @code{Restrictions}. See D.7(20).
9374 There are no such implementation-defined aspects.
9379 @strong{105}. Implementation-defined aspects of package
9380 @code{Real_Time}. See D.8(17).
9383 There are no implementation defined aspects of package @code{Real_Time}.
9388 @strong{106}. Implementation-defined aspects of
9389 @code{delay_statements}. See D.9(8).
9392 Any difference greater than one microsecond will cause the task to be
9393 delayed (see D.9(7)).
9398 @strong{107}. The upper bound on the duration of interrupt blocking
9399 caused by the implementation. See D.12(5).
9402 The upper bound is determined by the underlying operating system. In
9403 no cases is it more than 10 milliseconds.
9408 @strong{108}. The means for creating and executing distributed
9412 The GLADE package provides a utility GNATDIST for creating and executing
9413 distributed programs. See the GLADE reference manual for further details.
9418 @strong{109}. Any events that can result in a partition becoming
9419 inaccessible. See E.1(7).
9422 See the GLADE reference manual for full details on such events.
9427 @strong{110}. The scheduling policies, treatment of priorities, and
9428 management of shared resources between partitions in certain cases. See
9432 See the GLADE reference manual for full details on these aspects of
9433 multi-partition execution.
9438 @strong{111}. Events that cause the version of a compilation unit to
9442 Editing the source file of a compilation unit, or the source files of
9443 any units on which it is dependent in a significant way cause the version
9444 to change. No other actions cause the version number to change. All changes
9445 are significant except those which affect only layout, capitalization or
9451 @strong{112}. Whether the execution of the remote subprogram is
9452 immediately aborted as a result of cancellation. See E.4(13).
9455 See the GLADE reference manual for details on the effect of abort in
9456 a distributed application.
9461 @strong{113}. Implementation-defined aspects of the PCS@. See E.5(25).
9464 See the GLADE reference manual for a full description of all implementation
9465 defined aspects of the PCS@.
9470 @strong{114}. Implementation-defined interfaces in the PCS@. See
9474 See the GLADE reference manual for a full description of all
9475 implementation defined interfaces.
9480 @strong{115}. The values of named numbers in the package
9481 @code{Decimal}. See F.2(7).
9493 @item Max_Decimal_Digits
9500 @strong{116}. The value of @code{Max_Picture_Length} in the package
9501 @code{Text_IO.Editing}. See F.3.3(16).
9509 @strong{117}. The value of @code{Max_Picture_Length} in the package
9510 @code{Wide_Text_IO.Editing}. See F.3.4(5).
9518 @strong{118}. The accuracy actually achieved by the complex elementary
9519 functions and by other complex arithmetic operations. See G.1(1).
9522 Standard library functions are used for the complex arithmetic
9523 operations. Only fast math mode is currently supported.
9528 @strong{119}. The sign of a zero result (or a component thereof) from
9529 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9530 @code{Real'Signed_Zeros} is True. See G.1.1(53).
9533 The signs of zero values are as recommended by the relevant
9534 implementation advice.
9539 @strong{120}. The sign of a zero result (or a component thereof) from
9540 any operator or function in
9541 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9542 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
9545 The signs of zero values are as recommended by the relevant
9546 implementation advice.
9551 @strong{121}. Whether the strict mode or the relaxed mode is the
9552 default. See G.2(2).
9555 The strict mode is the default. There is no separate relaxed mode. GNAT
9556 provides a highly efficient implementation of strict mode.
9561 @strong{122}. The result interval in certain cases of fixed-to-float
9562 conversion. See G.2.1(10).
9565 For cases where the result interval is implementation dependent, the
9566 accuracy is that provided by performing all operations in 64-bit IEEE
9567 floating-point format.
9572 @strong{123}. The result of a floating point arithmetic operation in
9573 overflow situations, when the @code{Machine_Overflows} attribute of the
9574 result type is @code{False}. See G.2.1(13).
9577 Infinite and NaN values are produced as dictated by the IEEE
9578 floating-point standard.
9580 Note that on machines that are not fully compliant with the IEEE
9581 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9582 must be used for achieving IEEE confirming behavior (although at the cost
9583 of a significant performance penalty), so infinite and NaN values are
9589 @strong{124}. The result interval for division (or exponentiation by a
9590 negative exponent), when the floating point hardware implements division
9591 as multiplication by a reciprocal. See G.2.1(16).
9594 Not relevant, division is IEEE exact.
9599 @strong{125}. The definition of close result set, which determines the
9600 accuracy of certain fixed point multiplications and divisions. See
9604 Operations in the close result set are performed using IEEE long format
9605 floating-point arithmetic. The input operands are converted to
9606 floating-point, the operation is done in floating-point, and the result
9607 is converted to the target type.
9612 @strong{126}. Conditions on a @code{universal_real} operand of a fixed
9613 point multiplication or division for which the result shall be in the
9614 perfect result set. See G.2.3(22).
9617 The result is only defined to be in the perfect result set if the result
9618 can be computed by a single scaling operation involving a scale factor
9619 representable in 64-bits.
9624 @strong{127}. The result of a fixed point arithmetic operation in
9625 overflow situations, when the @code{Machine_Overflows} attribute of the
9626 result type is @code{False}. See G.2.3(27).
9629 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9635 @strong{128}. The result of an elementary function reference in
9636 overflow situations, when the @code{Machine_Overflows} attribute of the
9637 result type is @code{False}. See G.2.4(4).
9640 IEEE infinite and Nan values are produced as appropriate.
9645 @strong{129}. The value of the angle threshold, within which certain
9646 elementary functions, complex arithmetic operations, and complex
9647 elementary functions yield results conforming to a maximum relative
9648 error bound. See G.2.4(10).
9651 Information on this subject is not yet available.
9656 @strong{130}. The accuracy of certain elementary functions for
9657 parameters beyond the angle threshold. See G.2.4(10).
9660 Information on this subject is not yet available.
9665 @strong{131}. The result of a complex arithmetic operation or complex
9666 elementary function reference in overflow situations, when the
9667 @code{Machine_Overflows} attribute of the corresponding real type is
9668 @code{False}. See G.2.6(5).
9671 IEEE infinite and Nan values are produced as appropriate.
9676 @strong{132}. The accuracy of certain complex arithmetic operations and
9677 certain complex elementary functions for parameters (or components
9678 thereof) beyond the angle threshold. See G.2.6(8).
9681 Information on those subjects is not yet available.
9686 @strong{133}. Information regarding bounded errors and erroneous
9687 execution. See H.2(1).
9690 Information on this subject is not yet available.
9695 @strong{134}. Implementation-defined aspects of pragma
9696 @code{Inspection_Point}. See H.3.2(8).
9699 Pragma @code{Inspection_Point} ensures that the variable is live and can
9700 be examined by the debugger at the inspection point.
9705 @strong{135}. Implementation-defined aspects of pragma
9706 @code{Restrictions}. See H.4(25).
9709 There are no implementation-defined aspects of pragma @code{Restrictions}. The
9710 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9711 generated code. Checks must suppressed by use of pragma @code{Suppress}.
9716 @strong{136}. Any restrictions on pragma @code{Restrictions}. See
9720 There are no restrictions on pragma @code{Restrictions}.
9722 @node Intrinsic Subprograms
9723 @chapter Intrinsic Subprograms
9724 @cindex Intrinsic Subprograms
9727 * Intrinsic Operators::
9728 * Enclosing_Entity::
9729 * Exception_Information::
9730 * Exception_Message::
9738 * Shift_Right_Arithmetic::
9743 GNAT allows a user application program to write the declaration:
9745 @smallexample @c ada
9746 pragma Import (Intrinsic, name);
9750 providing that the name corresponds to one of the implemented intrinsic
9751 subprograms in GNAT, and that the parameter profile of the referenced
9752 subprogram meets the requirements. This chapter describes the set of
9753 implemented intrinsic subprograms, and the requirements on parameter profiles.
9754 Note that no body is supplied; as with other uses of pragma Import, the
9755 body is supplied elsewhere (in this case by the compiler itself). Note
9756 that any use of this feature is potentially non-portable, since the
9757 Ada standard does not require Ada compilers to implement this feature.
9759 @node Intrinsic Operators
9760 @section Intrinsic Operators
9761 @cindex Intrinsic operator
9764 All the predefined numeric operators in package Standard
9765 in @code{pragma Import (Intrinsic,..)}
9766 declarations. In the binary operator case, the operands must have the same
9767 size. The operand or operands must also be appropriate for
9768 the operator. For example, for addition, the operands must
9769 both be floating-point or both be fixed-point, and the
9770 right operand for @code{"**"} must have a root type of
9771 @code{Standard.Integer'Base}.
9772 You can use an intrinsic operator declaration as in the following example:
9774 @smallexample @c ada
9775 type Int1 is new Integer;
9776 type Int2 is new Integer;
9778 function "+" (X1 : Int1; X2 : Int2) return Int1;
9779 function "+" (X1 : Int1; X2 : Int2) return Int2;
9780 pragma Import (Intrinsic, "+");
9784 This declaration would permit ``mixed mode'' arithmetic on items
9785 of the differing types @code{Int1} and @code{Int2}.
9786 It is also possible to specify such operators for private types, if the
9787 full views are appropriate arithmetic types.
9789 @node Enclosing_Entity
9790 @section Enclosing_Entity
9791 @cindex Enclosing_Entity
9793 This intrinsic subprogram is used in the implementation of the
9794 library routine @code{GNAT.Source_Info}. The only useful use of the
9795 intrinsic import in this case is the one in this unit, so an
9796 application program should simply call the function
9797 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9798 the current subprogram, package, task, entry, or protected subprogram.
9800 @node Exception_Information
9801 @section Exception_Information
9802 @cindex Exception_Information'
9804 This intrinsic subprogram is used in the implementation of the
9805 library routine @code{GNAT.Current_Exception}. The only useful
9806 use of the intrinsic import in this case is the one in this unit,
9807 so an application program should simply call the function
9808 @code{GNAT.Current_Exception.Exception_Information} to obtain
9809 the exception information associated with the current exception.
9811 @node Exception_Message
9812 @section Exception_Message
9813 @cindex Exception_Message
9815 This intrinsic subprogram is used in the implementation of the
9816 library routine @code{GNAT.Current_Exception}. The only useful
9817 use of the intrinsic import in this case is the one in this unit,
9818 so an application program should simply call the function
9819 @code{GNAT.Current_Exception.Exception_Message} to obtain
9820 the message associated with the current exception.
9822 @node Exception_Name
9823 @section Exception_Name
9824 @cindex Exception_Name
9826 This intrinsic subprogram is used in the implementation of the
9827 library routine @code{GNAT.Current_Exception}. The only useful
9828 use of the intrinsic import in this case is the one in this unit,
9829 so an application program should simply call the function
9830 @code{GNAT.Current_Exception.Exception_Name} to obtain
9831 the name of the current exception.
9837 This intrinsic subprogram is used in the implementation of the
9838 library routine @code{GNAT.Source_Info}. The only useful use of the
9839 intrinsic import in this case is the one in this unit, so an
9840 application program should simply call the function
9841 @code{GNAT.Source_Info.File} to obtain the name of the current
9848 This intrinsic subprogram is used in the implementation of the
9849 library routine @code{GNAT.Source_Info}. The only useful use of the
9850 intrinsic import in this case is the one in this unit, so an
9851 application program should simply call the function
9852 @code{GNAT.Source_Info.Line} to obtain the number of the current
9856 @section Rotate_Left
9859 In standard Ada, the @code{Rotate_Left} function is available only
9860 for the predefined modular types in package @code{Interfaces}. However, in
9861 GNAT it is possible to define a Rotate_Left function for a user
9862 defined modular type or any signed integer type as in this example:
9864 @smallexample @c ada
9866 (Value : My_Modular_Type;
9868 return My_Modular_Type;
9872 The requirements are that the profile be exactly as in the example
9873 above. The only modifications allowed are in the formal parameter
9874 names, and in the type of @code{Value} and the return type, which
9875 must be the same, and must be either a signed integer type, or
9876 a modular integer type with a binary modulus, and the size must
9877 be 8. 16, 32 or 64 bits.
9880 @section Rotate_Right
9881 @cindex Rotate_Right
9883 A @code{Rotate_Right} function can be defined for any user defined
9884 binary modular integer type, or signed integer type, as described
9885 above for @code{Rotate_Left}.
9891 A @code{Shift_Left} function can be defined for any user defined
9892 binary modular integer type, or signed integer type, as described
9893 above for @code{Rotate_Left}.
9896 @section Shift_Right
9899 A @code{Shift_Right} function can be defined for any user defined
9900 binary modular integer type, or signed integer type, as described
9901 above for @code{Rotate_Left}.
9903 @node Shift_Right_Arithmetic
9904 @section Shift_Right_Arithmetic
9905 @cindex Shift_Right_Arithmetic
9907 A @code{Shift_Right_Arithmetic} function can be defined for any user
9908 defined binary modular integer type, or signed integer type, as described
9909 above for @code{Rotate_Left}.
9911 @node Source_Location
9912 @section Source_Location
9913 @cindex Source_Location
9915 This intrinsic subprogram is used in the implementation of the
9916 library routine @code{GNAT.Source_Info}. The only useful use of the
9917 intrinsic import in this case is the one in this unit, so an
9918 application program should simply call the function
9919 @code{GNAT.Source_Info.Source_Location} to obtain the current
9920 source file location.
9922 @node Representation Clauses and Pragmas
9923 @chapter Representation Clauses and Pragmas
9924 @cindex Representation Clauses
9927 * Alignment Clauses::
9929 * Storage_Size Clauses::
9930 * Size of Variant Record Objects::
9931 * Biased Representation ::
9932 * Value_Size and Object_Size Clauses::
9933 * Component_Size Clauses::
9934 * Bit_Order Clauses::
9935 * Effect of Bit_Order on Byte Ordering::
9936 * Pragma Pack for Arrays::
9937 * Pragma Pack for Records::
9938 * Record Representation Clauses::
9939 * Enumeration Clauses::
9941 * Effect of Convention on Representation::
9942 * Determining the Representations chosen by GNAT::
9946 @cindex Representation Clause
9947 @cindex Representation Pragma
9948 @cindex Pragma, representation
9949 This section describes the representation clauses accepted by GNAT, and
9950 their effect on the representation of corresponding data objects.
9952 GNAT fully implements Annex C (Systems Programming). This means that all
9953 the implementation advice sections in chapter 13 are fully implemented.
9954 However, these sections only require a minimal level of support for
9955 representation clauses. GNAT provides much more extensive capabilities,
9956 and this section describes the additional capabilities provided.
9958 @node Alignment Clauses
9959 @section Alignment Clauses
9960 @cindex Alignment Clause
9963 GNAT requires that all alignment clauses specify a power of 2, and all
9964 default alignments are always a power of 2. The default alignment
9965 values are as follows:
9968 @item @emph{Primitive Types}.
9969 For primitive types, the alignment is the minimum of the actual size of
9970 objects of the type divided by @code{Storage_Unit},
9971 and the maximum alignment supported by the target.
9972 (This maximum alignment is given by the GNAT-specific attribute
9973 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9974 @cindex @code{Maximum_Alignment} attribute
9975 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9976 default alignment will be 8 on any target that supports alignments
9977 this large, but on some targets, the maximum alignment may be smaller
9978 than 8, in which case objects of type @code{Long_Float} will be maximally
9981 @item @emph{Arrays}.
9982 For arrays, the alignment is equal to the alignment of the component type
9983 for the normal case where no packing or component size is given. If the
9984 array is packed, and the packing is effective (see separate section on
9985 packed arrays), then the alignment will be one for long packed arrays,
9986 or arrays whose length is not known at compile time. For short packed
9987 arrays, which are handled internally as modular types, the alignment
9988 will be as described for primitive types, e.g.@: a packed array of length
9989 31 bits will have an object size of four bytes, and an alignment of 4.
9991 @item @emph{Records}.
9992 For the normal non-packed case, the alignment of a record is equal to
9993 the maximum alignment of any of its components. For tagged records, this
9994 includes the implicit access type used for the tag. If a pragma @code{Pack}
9995 is used and all components are packable (see separate section on pragma
9996 @code{Pack}), then the resulting alignment is 1, unless the layout of the
9997 record makes it profitable to increase it.
9999 A special case is when:
10002 the size of the record is given explicitly, or a
10003 full record representation clause is given, and
10005 the size of the record is 2, 4, or 8 bytes.
10008 In this case, an alignment is chosen to match the
10009 size of the record. For example, if we have:
10011 @smallexample @c ada
10012 type Small is record
10015 for Small'Size use 16;
10019 then the default alignment of the record type @code{Small} is 2, not 1. This
10020 leads to more efficient code when the record is treated as a unit, and also
10021 allows the type to specified as @code{Atomic} on architectures requiring
10027 An alignment clause may specify a larger alignment than the default value
10028 up to some maximum value dependent on the target (obtainable by using the
10029 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
10030 a smaller alignment than the default value for enumeration, integer and
10031 fixed point types, as well as for record types, for example
10033 @smallexample @c ada
10038 for V'alignment use 1;
10042 @cindex Alignment, default
10043 The default alignment for the type @code{V} is 4, as a result of the
10044 Integer field in the record, but it is permissible, as shown, to
10045 override the default alignment of the record with a smaller value.
10048 @section Size Clauses
10049 @cindex Size Clause
10052 The default size for a type @code{T} is obtainable through the
10053 language-defined attribute @code{T'Size} and also through the
10054 equivalent GNAT-defined attribute @code{T'Value_Size}.
10055 For objects of type @code{T}, GNAT will generally increase the type size
10056 so that the object size (obtainable through the GNAT-defined attribute
10057 @code{T'Object_Size})
10058 is a multiple of @code{T'Alignment * Storage_Unit}.
10061 @smallexample @c ada
10062 type Smallint is range 1 .. 6;
10071 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10072 as specified by the RM rules,
10073 but objects of this type will have a size of 8
10074 (@code{Smallint'Object_Size} = 8),
10075 since objects by default occupy an integral number
10076 of storage units. On some targets, notably older
10077 versions of the Digital Alpha, the size of stand
10078 alone objects of this type may be 32, reflecting
10079 the inability of the hardware to do byte load/stores.
10081 Similarly, the size of type @code{Rec} is 40 bits
10082 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10083 the alignment is 4, so objects of this type will have
10084 their size increased to 64 bits so that it is a multiple
10085 of the alignment (in bits). This decision is
10086 in accordance with the specific Implementation Advice in RM 13.3(43):
10089 A @code{Size} clause should be supported for an object if the specified
10090 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10091 to a size in storage elements that is a multiple of the object's
10092 @code{Alignment} (if the @code{Alignment} is nonzero).
10096 An explicit size clause may be used to override the default size by
10097 increasing it. For example, if we have:
10099 @smallexample @c ada
10100 type My_Boolean is new Boolean;
10101 for My_Boolean'Size use 32;
10105 then values of this type will always be 32 bits long. In the case of
10106 discrete types, the size can be increased up to 64 bits, with the effect
10107 that the entire specified field is used to hold the value, sign- or
10108 zero-extended as appropriate. If more than 64 bits is specified, then
10109 padding space is allocated after the value, and a warning is issued that
10110 there are unused bits.
10112 Similarly the size of records and arrays may be increased, and the effect
10113 is to add padding bits after the value. This also causes a warning message
10116 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
10117 Size in bits, this corresponds to an object of size 256 megabytes (minus
10118 one). This limitation is true on all targets. The reason for this
10119 limitation is that it improves the quality of the code in many cases
10120 if it is known that a Size value can be accommodated in an object of
10123 @node Storage_Size Clauses
10124 @section Storage_Size Clauses
10125 @cindex Storage_Size Clause
10128 For tasks, the @code{Storage_Size} clause specifies the amount of space
10129 to be allocated for the task stack. This cannot be extended, and if the
10130 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10131 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
10132 or a @code{Storage_Size} pragma in the task definition to set the
10133 appropriate required size. A useful technique is to include in every
10134 task definition a pragma of the form:
10136 @smallexample @c ada
10137 pragma Storage_Size (Default_Stack_Size);
10141 Then @code{Default_Stack_Size} can be defined in a global package, and
10142 modified as required. Any tasks requiring stack sizes different from the
10143 default can have an appropriate alternative reference in the pragma.
10145 You can also use the @option{-d} binder switch to modify the default stack
10148 For access types, the @code{Storage_Size} clause specifies the maximum
10149 space available for allocation of objects of the type. If this space is
10150 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10151 In the case where the access type is declared local to a subprogram, the
10152 use of a @code{Storage_Size} clause triggers automatic use of a special
10153 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10154 space for the pool is automatically reclaimed on exit from the scope in
10155 which the type is declared.
10157 A special case recognized by the compiler is the specification of a
10158 @code{Storage_Size} of zero for an access type. This means that no
10159 items can be allocated from the pool, and this is recognized at compile
10160 time, and all the overhead normally associated with maintaining a fixed
10161 size storage pool is eliminated. Consider the following example:
10163 @smallexample @c ada
10165 type R is array (Natural) of Character;
10166 type P is access all R;
10167 for P'Storage_Size use 0;
10168 -- Above access type intended only for interfacing purposes
10172 procedure g (m : P);
10173 pragma Import (C, g);
10184 As indicated in this example, these dummy storage pools are often useful in
10185 connection with interfacing where no object will ever be allocated. If you
10186 compile the above example, you get the warning:
10189 p.adb:16:09: warning: allocation from empty storage pool
10190 p.adb:16:09: warning: Storage_Error will be raised at run time
10194 Of course in practice, there will not be any explicit allocators in the
10195 case of such an access declaration.
10197 @node Size of Variant Record Objects
10198 @section Size of Variant Record Objects
10199 @cindex Size, variant record objects
10200 @cindex Variant record objects, size
10203 In the case of variant record objects, there is a question whether Size gives
10204 information about a particular variant, or the maximum size required
10205 for any variant. Consider the following program
10207 @smallexample @c ada
10208 with Text_IO; use Text_IO;
10210 type R1 (A : Boolean := False) is record
10212 when True => X : Character;
10213 when False => null;
10221 Put_Line (Integer'Image (V1'Size));
10222 Put_Line (Integer'Image (V2'Size));
10227 Here we are dealing with a variant record, where the True variant
10228 requires 16 bits, and the False variant requires 8 bits.
10229 In the above example, both V1 and V2 contain the False variant,
10230 which is only 8 bits long. However, the result of running the
10239 The reason for the difference here is that the discriminant value of
10240 V1 is fixed, and will always be False. It is not possible to assign
10241 a True variant value to V1, therefore 8 bits is sufficient. On the
10242 other hand, in the case of V2, the initial discriminant value is
10243 False (from the default), but it is possible to assign a True
10244 variant value to V2, therefore 16 bits must be allocated for V2
10245 in the general case, even fewer bits may be needed at any particular
10246 point during the program execution.
10248 As can be seen from the output of this program, the @code{'Size}
10249 attribute applied to such an object in GNAT gives the actual allocated
10250 size of the variable, which is the largest size of any of the variants.
10251 The Ada Reference Manual is not completely clear on what choice should
10252 be made here, but the GNAT behavior seems most consistent with the
10253 language in the RM@.
10255 In some cases, it may be desirable to obtain the size of the current
10256 variant, rather than the size of the largest variant. This can be
10257 achieved in GNAT by making use of the fact that in the case of a
10258 subprogram parameter, GNAT does indeed return the size of the current
10259 variant (because a subprogram has no way of knowing how much space
10260 is actually allocated for the actual).
10262 Consider the following modified version of the above program:
10264 @smallexample @c ada
10265 with Text_IO; use Text_IO;
10267 type R1 (A : Boolean := False) is record
10269 when True => X : Character;
10270 when False => null;
10276 function Size (V : R1) return Integer is
10282 Put_Line (Integer'Image (V2'Size));
10283 Put_Line (Integer'IMage (Size (V2)));
10285 Put_Line (Integer'Image (V2'Size));
10286 Put_Line (Integer'IMage (Size (V2)));
10291 The output from this program is
10301 Here we see that while the @code{'Size} attribute always returns
10302 the maximum size, regardless of the current variant value, the
10303 @code{Size} function does indeed return the size of the current
10306 @node Biased Representation
10307 @section Biased Representation
10308 @cindex Size for biased representation
10309 @cindex Biased representation
10312 In the case of scalars with a range starting at other than zero, it is
10313 possible in some cases to specify a size smaller than the default minimum
10314 value, and in such cases, GNAT uses an unsigned biased representation,
10315 in which zero is used to represent the lower bound, and successive values
10316 represent successive values of the type.
10318 For example, suppose we have the declaration:
10320 @smallexample @c ada
10321 type Small is range -7 .. -4;
10322 for Small'Size use 2;
10326 Although the default size of type @code{Small} is 4, the @code{Size}
10327 clause is accepted by GNAT and results in the following representation
10331 -7 is represented as 2#00#
10332 -6 is represented as 2#01#
10333 -5 is represented as 2#10#
10334 -4 is represented as 2#11#
10338 Biased representation is only used if the specified @code{Size} clause
10339 cannot be accepted in any other manner. These reduced sizes that force
10340 biased representation can be used for all discrete types except for
10341 enumeration types for which a representation clause is given.
10343 @node Value_Size and Object_Size Clauses
10344 @section Value_Size and Object_Size Clauses
10346 @findex Object_Size
10347 @cindex Size, of objects
10350 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10351 number of bits required to hold values of type @code{T}.
10352 Although this interpretation was allowed in Ada 83, it was not required,
10353 and this requirement in practice can cause some significant difficulties.
10354 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10355 However, in Ada 95 and Ada 2005,
10356 @code{Natural'Size} is
10357 typically 31. This means that code may change in behavior when moving
10358 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
10360 @smallexample @c ada
10361 type Rec is record;
10367 at 0 range 0 .. Natural'Size - 1;
10368 at 0 range Natural'Size .. 2 * Natural'Size - 1;
10373 In the above code, since the typical size of @code{Natural} objects
10374 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10375 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10376 there are cases where the fact that the object size can exceed the
10377 size of the type causes surprises.
10379 To help get around this problem GNAT provides two implementation
10380 defined attributes, @code{Value_Size} and @code{Object_Size}. When
10381 applied to a type, these attributes yield the size of the type
10382 (corresponding to the RM defined size attribute), and the size of
10383 objects of the type respectively.
10385 The @code{Object_Size} is used for determining the default size of
10386 objects and components. This size value can be referred to using the
10387 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
10388 the basis of the determination of the size. The backend is free to
10389 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10390 character might be stored in 32 bits on a machine with no efficient
10391 byte access instructions such as the Alpha.
10393 The default rules for the value of @code{Object_Size} for
10394 discrete types are as follows:
10398 The @code{Object_Size} for base subtypes reflect the natural hardware
10399 size in bits (run the compiler with @option{-gnatS} to find those values
10400 for numeric types). Enumeration types and fixed-point base subtypes have
10401 8, 16, 32 or 64 bits for this size, depending on the range of values
10405 The @code{Object_Size} of a subtype is the same as the
10406 @code{Object_Size} of
10407 the type from which it is obtained.
10410 The @code{Object_Size} of a derived base type is copied from the parent
10411 base type, and the @code{Object_Size} of a derived first subtype is copied
10412 from the parent first subtype.
10416 The @code{Value_Size} attribute
10417 is the (minimum) number of bits required to store a value
10419 This value is used to determine how tightly to pack
10420 records or arrays with components of this type, and also affects
10421 the semantics of unchecked conversion (unchecked conversions where
10422 the @code{Value_Size} values differ generate a warning, and are potentially
10425 The default rules for the value of @code{Value_Size} are as follows:
10429 The @code{Value_Size} for a base subtype is the minimum number of bits
10430 required to store all values of the type (including the sign bit
10431 only if negative values are possible).
10434 If a subtype statically matches the first subtype of a given type, then it has
10435 by default the same @code{Value_Size} as the first subtype. This is a
10436 consequence of RM 13.1(14) (``if two subtypes statically match,
10437 then their subtype-specific aspects are the same''.)
10440 All other subtypes have a @code{Value_Size} corresponding to the minimum
10441 number of bits required to store all values of the subtype. For
10442 dynamic bounds, it is assumed that the value can range down or up
10443 to the corresponding bound of the ancestor
10447 The RM defined attribute @code{Size} corresponds to the
10448 @code{Value_Size} attribute.
10450 The @code{Size} attribute may be defined for a first-named subtype. This sets
10451 the @code{Value_Size} of
10452 the first-named subtype to the given value, and the
10453 @code{Object_Size} of this first-named subtype to the given value padded up
10454 to an appropriate boundary. It is a consequence of the default rules
10455 above that this @code{Object_Size} will apply to all further subtypes. On the
10456 other hand, @code{Value_Size} is affected only for the first subtype, any
10457 dynamic subtypes obtained from it directly, and any statically matching
10458 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
10460 @code{Value_Size} and
10461 @code{Object_Size} may be explicitly set for any subtype using
10462 an attribute definition clause. Note that the use of these attributes
10463 can cause the RM 13.1(14) rule to be violated. If two access types
10464 reference aliased objects whose subtypes have differing @code{Object_Size}
10465 values as a result of explicit attribute definition clauses, then it
10466 is erroneous to convert from one access subtype to the other.
10468 At the implementation level, Esize stores the Object_Size and the
10469 RM_Size field stores the @code{Value_Size} (and hence the value of the
10470 @code{Size} attribute,
10471 which, as noted above, is equivalent to @code{Value_Size}).
10473 To get a feel for the difference, consider the following examples (note
10474 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10477 Object_Size Value_Size
10479 type x1 is range 0 .. 5; 8 3
10481 type x2 is range 0 .. 5;
10482 for x2'size use 12; 16 12
10484 subtype x3 is x2 range 0 .. 3; 16 2
10486 subtype x4 is x2'base range 0 .. 10; 8 4
10488 subtype x5 is x2 range 0 .. dynamic; 16 3*
10490 subtype x6 is x2'base range 0 .. dynamic; 8 3*
10495 Note: the entries marked ``3*'' are not actually specified by the Ada
10496 Reference Manual, but it seems in the spirit of the RM rules to allocate
10497 the minimum number of bits (here 3, given the range for @code{x2})
10498 known to be large enough to hold the given range of values.
10500 So far, so good, but GNAT has to obey the RM rules, so the question is
10501 under what conditions must the RM @code{Size} be used.
10502 The following is a list
10503 of the occasions on which the RM @code{Size} must be used:
10507 Component size for packed arrays or records
10510 Value of the attribute @code{Size} for a type
10513 Warning about sizes not matching for unchecked conversion
10517 For record types, the @code{Object_Size} is always a multiple of the
10518 alignment of the type (this is true for all types). In some cases the
10519 @code{Value_Size} can be smaller. Consider:
10529 On a typical 32-bit architecture, the X component will be four bytes, and
10530 require four-byte alignment, and the Y component will be one byte. In this
10531 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10532 required to store a value of this type, and for example, it is permissible
10533 to have a component of type R in an outer array whose component size is
10534 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10535 since it must be rounded up so that this value is a multiple of the
10536 alignment (4 bytes = 32 bits).
10539 For all other types, the @code{Object_Size}
10540 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10541 Only @code{Size} may be specified for such types.
10543 @node Component_Size Clauses
10544 @section Component_Size Clauses
10545 @cindex Component_Size Clause
10548 Normally, the value specified in a component size clause must be consistent
10549 with the subtype of the array component with regard to size and alignment.
10550 In other words, the value specified must be at least equal to the size
10551 of this subtype, and must be a multiple of the alignment value.
10553 In addition, component size clauses are allowed which cause the array
10554 to be packed, by specifying a smaller value. A first case is for
10555 component size values in the range 1 through 63. The value specified
10556 must not be smaller than the Size of the subtype. GNAT will accurately
10557 honor all packing requests in this range. For example, if we have:
10559 @smallexample @c ada
10560 type r is array (1 .. 8) of Natural;
10561 for r'Component_Size use 31;
10565 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10566 Of course access to the components of such an array is considerably
10567 less efficient than if the natural component size of 32 is used.
10568 A second case is when the subtype of the component is a record type
10569 padded because of its default alignment. For example, if we have:
10571 @smallexample @c ada
10578 type a is array (1 .. 8) of r;
10579 for a'Component_Size use 72;
10583 then the resulting array has a length of 72 bytes, instead of 96 bytes
10584 if the alignment of the record (4) was obeyed.
10586 Note that there is no point in giving both a component size clause
10587 and a pragma Pack for the same array type. if such duplicate
10588 clauses are given, the pragma Pack will be ignored.
10590 @node Bit_Order Clauses
10591 @section Bit_Order Clauses
10592 @cindex Bit_Order Clause
10593 @cindex bit ordering
10594 @cindex ordering, of bits
10597 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10598 attribute. The specification may either correspond to the default bit
10599 order for the target, in which case the specification has no effect and
10600 places no additional restrictions, or it may be for the non-standard
10601 setting (that is the opposite of the default).
10603 In the case where the non-standard value is specified, the effect is
10604 to renumber bits within each byte, but the ordering of bytes is not
10605 affected. There are certain
10606 restrictions placed on component clauses as follows:
10610 @item Components fitting within a single storage unit.
10612 These are unrestricted, and the effect is merely to renumber bits. For
10613 example if we are on a little-endian machine with @code{Low_Order_First}
10614 being the default, then the following two declarations have exactly
10617 @smallexample @c ada
10620 B : Integer range 1 .. 120;
10624 A at 0 range 0 .. 0;
10625 B at 0 range 1 .. 7;
10630 B : Integer range 1 .. 120;
10633 for R2'Bit_Order use High_Order_First;
10636 A at 0 range 7 .. 7;
10637 B at 0 range 0 .. 6;
10642 The useful application here is to write the second declaration with the
10643 @code{Bit_Order} attribute definition clause, and know that it will be treated
10644 the same, regardless of whether the target is little-endian or big-endian.
10646 @item Components occupying an integral number of bytes.
10648 These are components that exactly fit in two or more bytes. Such component
10649 declarations are allowed, but have no effect, since it is important to realize
10650 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10651 In particular, the following attempt at getting an endian-independent integer
10654 @smallexample @c ada
10659 for R2'Bit_Order use High_Order_First;
10662 A at 0 range 0 .. 31;
10667 This declaration will result in a little-endian integer on a
10668 little-endian machine, and a big-endian integer on a big-endian machine.
10669 If byte flipping is required for interoperability between big- and
10670 little-endian machines, this must be explicitly programmed. This capability
10671 is not provided by @code{Bit_Order}.
10673 @item Components that are positioned across byte boundaries
10675 but do not occupy an integral number of bytes. Given that bytes are not
10676 reordered, such fields would occupy a non-contiguous sequence of bits
10677 in memory, requiring non-trivial code to reassemble. They are for this
10678 reason not permitted, and any component clause specifying such a layout
10679 will be flagged as illegal by GNAT@.
10684 Since the misconception that Bit_Order automatically deals with all
10685 endian-related incompatibilities is a common one, the specification of
10686 a component field that is an integral number of bytes will always
10687 generate a warning. This warning may be suppressed using @code{pragma
10688 Warnings (Off)} if desired. The following section contains additional
10689 details regarding the issue of byte ordering.
10691 @node Effect of Bit_Order on Byte Ordering
10692 @section Effect of Bit_Order on Byte Ordering
10693 @cindex byte ordering
10694 @cindex ordering, of bytes
10697 In this section we will review the effect of the @code{Bit_Order} attribute
10698 definition clause on byte ordering. Briefly, it has no effect at all, but
10699 a detailed example will be helpful. Before giving this
10700 example, let us review the precise
10701 definition of the effect of defining @code{Bit_Order}. The effect of a
10702 non-standard bit order is described in section 15.5.3 of the Ada
10706 2 A bit ordering is a method of interpreting the meaning of
10707 the storage place attributes.
10711 To understand the precise definition of storage place attributes in
10712 this context, we visit section 13.5.1 of the manual:
10715 13 A record_representation_clause (without the mod_clause)
10716 specifies the layout. The storage place attributes (see 13.5.2)
10717 are taken from the values of the position, first_bit, and last_bit
10718 expressions after normalizing those values so that first_bit is
10719 less than Storage_Unit.
10723 The critical point here is that storage places are taken from
10724 the values after normalization, not before. So the @code{Bit_Order}
10725 interpretation applies to normalized values. The interpretation
10726 is described in the later part of the 15.5.3 paragraph:
10729 2 A bit ordering is a method of interpreting the meaning of
10730 the storage place attributes. High_Order_First (known in the
10731 vernacular as ``big endian'') means that the first bit of a
10732 storage element (bit 0) is the most significant bit (interpreting
10733 the sequence of bits that represent a component as an unsigned
10734 integer value). Low_Order_First (known in the vernacular as
10735 ``little endian'') means the opposite: the first bit is the
10740 Note that the numbering is with respect to the bits of a storage
10741 unit. In other words, the specification affects only the numbering
10742 of bits within a single storage unit.
10744 We can make the effect clearer by giving an example.
10746 Suppose that we have an external device which presents two bytes, the first
10747 byte presented, which is the first (low addressed byte) of the two byte
10748 record is called Master, and the second byte is called Slave.
10750 The left most (most significant bit is called Control for each byte, and
10751 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10752 (least significant) bit.
10754 On a big-endian machine, we can write the following representation clause
10756 @smallexample @c ada
10757 type Data is record
10758 Master_Control : Bit;
10766 Slave_Control : Bit;
10776 for Data use record
10777 Master_Control at 0 range 0 .. 0;
10778 Master_V1 at 0 range 1 .. 1;
10779 Master_V2 at 0 range 2 .. 2;
10780 Master_V3 at 0 range 3 .. 3;
10781 Master_V4 at 0 range 4 .. 4;
10782 Master_V5 at 0 range 5 .. 5;
10783 Master_V6 at 0 range 6 .. 6;
10784 Master_V7 at 0 range 7 .. 7;
10785 Slave_Control at 1 range 0 .. 0;
10786 Slave_V1 at 1 range 1 .. 1;
10787 Slave_V2 at 1 range 2 .. 2;
10788 Slave_V3 at 1 range 3 .. 3;
10789 Slave_V4 at 1 range 4 .. 4;
10790 Slave_V5 at 1 range 5 .. 5;
10791 Slave_V6 at 1 range 6 .. 6;
10792 Slave_V7 at 1 range 7 .. 7;
10797 Now if we move this to a little endian machine, then the bit ordering within
10798 the byte is backwards, so we have to rewrite the record rep clause as:
10800 @smallexample @c ada
10801 for Data use record
10802 Master_Control at 0 range 7 .. 7;
10803 Master_V1 at 0 range 6 .. 6;
10804 Master_V2 at 0 range 5 .. 5;
10805 Master_V3 at 0 range 4 .. 4;
10806 Master_V4 at 0 range 3 .. 3;
10807 Master_V5 at 0 range 2 .. 2;
10808 Master_V6 at 0 range 1 .. 1;
10809 Master_V7 at 0 range 0 .. 0;
10810 Slave_Control at 1 range 7 .. 7;
10811 Slave_V1 at 1 range 6 .. 6;
10812 Slave_V2 at 1 range 5 .. 5;
10813 Slave_V3 at 1 range 4 .. 4;
10814 Slave_V4 at 1 range 3 .. 3;
10815 Slave_V5 at 1 range 2 .. 2;
10816 Slave_V6 at 1 range 1 .. 1;
10817 Slave_V7 at 1 range 0 .. 0;
10822 It is a nuisance to have to rewrite the clause, especially if
10823 the code has to be maintained on both machines. However,
10824 this is a case that we can handle with the
10825 @code{Bit_Order} attribute if it is implemented.
10826 Note that the implementation is not required on byte addressed
10827 machines, but it is indeed implemented in GNAT.
10828 This means that we can simply use the
10829 first record clause, together with the declaration
10831 @smallexample @c ada
10832 for Data'Bit_Order use High_Order_First;
10836 and the effect is what is desired, namely the layout is exactly the same,
10837 independent of whether the code is compiled on a big-endian or little-endian
10840 The important point to understand is that byte ordering is not affected.
10841 A @code{Bit_Order} attribute definition never affects which byte a field
10842 ends up in, only where it ends up in that byte.
10843 To make this clear, let us rewrite the record rep clause of the previous
10846 @smallexample @c ada
10847 for Data'Bit_Order use High_Order_First;
10848 for Data use record
10849 Master_Control at 0 range 0 .. 0;
10850 Master_V1 at 0 range 1 .. 1;
10851 Master_V2 at 0 range 2 .. 2;
10852 Master_V3 at 0 range 3 .. 3;
10853 Master_V4 at 0 range 4 .. 4;
10854 Master_V5 at 0 range 5 .. 5;
10855 Master_V6 at 0 range 6 .. 6;
10856 Master_V7 at 0 range 7 .. 7;
10857 Slave_Control at 0 range 8 .. 8;
10858 Slave_V1 at 0 range 9 .. 9;
10859 Slave_V2 at 0 range 10 .. 10;
10860 Slave_V3 at 0 range 11 .. 11;
10861 Slave_V4 at 0 range 12 .. 12;
10862 Slave_V5 at 0 range 13 .. 13;
10863 Slave_V6 at 0 range 14 .. 14;
10864 Slave_V7 at 0 range 15 .. 15;
10869 This is exactly equivalent to saying (a repeat of the first example):
10871 @smallexample @c ada
10872 for Data'Bit_Order use High_Order_First;
10873 for Data use record
10874 Master_Control at 0 range 0 .. 0;
10875 Master_V1 at 0 range 1 .. 1;
10876 Master_V2 at 0 range 2 .. 2;
10877 Master_V3 at 0 range 3 .. 3;
10878 Master_V4 at 0 range 4 .. 4;
10879 Master_V5 at 0 range 5 .. 5;
10880 Master_V6 at 0 range 6 .. 6;
10881 Master_V7 at 0 range 7 .. 7;
10882 Slave_Control at 1 range 0 .. 0;
10883 Slave_V1 at 1 range 1 .. 1;
10884 Slave_V2 at 1 range 2 .. 2;
10885 Slave_V3 at 1 range 3 .. 3;
10886 Slave_V4 at 1 range 4 .. 4;
10887 Slave_V5 at 1 range 5 .. 5;
10888 Slave_V6 at 1 range 6 .. 6;
10889 Slave_V7 at 1 range 7 .. 7;
10894 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10895 field. The storage place attributes are obtained by normalizing the
10896 values given so that the @code{First_Bit} value is less than 8. After
10897 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10898 we specified in the other case.
10900 Now one might expect that the @code{Bit_Order} attribute might affect
10901 bit numbering within the entire record component (two bytes in this
10902 case, thus affecting which byte fields end up in), but that is not
10903 the way this feature is defined, it only affects numbering of bits,
10904 not which byte they end up in.
10906 Consequently it never makes sense to specify a starting bit number
10907 greater than 7 (for a byte addressable field) if an attribute
10908 definition for @code{Bit_Order} has been given, and indeed it
10909 may be actively confusing to specify such a value, so the compiler
10910 generates a warning for such usage.
10912 If you do need to control byte ordering then appropriate conditional
10913 values must be used. If in our example, the slave byte came first on
10914 some machines we might write:
10916 @smallexample @c ada
10917 Master_Byte_First constant Boolean := @dots{};
10919 Master_Byte : constant Natural :=
10920 1 - Boolean'Pos (Master_Byte_First);
10921 Slave_Byte : constant Natural :=
10922 Boolean'Pos (Master_Byte_First);
10924 for Data'Bit_Order use High_Order_First;
10925 for Data use record
10926 Master_Control at Master_Byte range 0 .. 0;
10927 Master_V1 at Master_Byte range 1 .. 1;
10928 Master_V2 at Master_Byte range 2 .. 2;
10929 Master_V3 at Master_Byte range 3 .. 3;
10930 Master_V4 at Master_Byte range 4 .. 4;
10931 Master_V5 at Master_Byte range 5 .. 5;
10932 Master_V6 at Master_Byte range 6 .. 6;
10933 Master_V7 at Master_Byte range 7 .. 7;
10934 Slave_Control at Slave_Byte range 0 .. 0;
10935 Slave_V1 at Slave_Byte range 1 .. 1;
10936 Slave_V2 at Slave_Byte range 2 .. 2;
10937 Slave_V3 at Slave_Byte range 3 .. 3;
10938 Slave_V4 at Slave_Byte range 4 .. 4;
10939 Slave_V5 at Slave_Byte range 5 .. 5;
10940 Slave_V6 at Slave_Byte range 6 .. 6;
10941 Slave_V7 at Slave_Byte range 7 .. 7;
10946 Now to switch between machines, all that is necessary is
10947 to set the boolean constant @code{Master_Byte_First} in
10948 an appropriate manner.
10950 @node Pragma Pack for Arrays
10951 @section Pragma Pack for Arrays
10952 @cindex Pragma Pack (for arrays)
10955 Pragma @code{Pack} applied to an array has no effect unless the component type
10956 is packable. For a component type to be packable, it must be one of the
10963 Any type whose size is specified with a size clause
10965 Any packed array type with a static size
10967 Any record type padded because of its default alignment
10971 For all these cases, if the component subtype size is in the range
10972 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10973 component size were specified giving the component subtype size.
10974 For example if we have:
10976 @smallexample @c ada
10977 type r is range 0 .. 17;
10979 type ar is array (1 .. 8) of r;
10984 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10985 and the size of the array @code{ar} will be exactly 40 bits.
10987 Note that in some cases this rather fierce approach to packing can produce
10988 unexpected effects. For example, in Ada 95 and Ada 2005,
10989 subtype @code{Natural} typically has a size of 31, meaning that if you
10990 pack an array of @code{Natural}, you get 31-bit
10991 close packing, which saves a few bits, but results in far less efficient
10992 access. Since many other Ada compilers will ignore such a packing request,
10993 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10994 might not be what is intended. You can easily remove this warning by
10995 using an explicit @code{Component_Size} setting instead, which never generates
10996 a warning, since the intention of the programmer is clear in this case.
10998 GNAT treats packed arrays in one of two ways. If the size of the array is
10999 known at compile time and is less than 64 bits, then internally the array
11000 is represented as a single modular type, of exactly the appropriate number
11001 of bits. If the length is greater than 63 bits, or is not known at compile
11002 time, then the packed array is represented as an array of bytes, and the
11003 length is always a multiple of 8 bits.
11005 Note that to represent a packed array as a modular type, the alignment must
11006 be suitable for the modular type involved. For example, on typical machines
11007 a 32-bit packed array will be represented by a 32-bit modular integer with
11008 an alignment of four bytes. If you explicitly override the default alignment
11009 with an alignment clause that is too small, the modular representation
11010 cannot be used. For example, consider the following set of declarations:
11012 @smallexample @c ada
11013 type R is range 1 .. 3;
11014 type S is array (1 .. 31) of R;
11015 for S'Component_Size use 2;
11017 for S'Alignment use 1;
11021 If the alignment clause were not present, then a 62-bit modular
11022 representation would be chosen (typically with an alignment of 4 or 8
11023 bytes depending on the target). But the default alignment is overridden
11024 with the explicit alignment clause. This means that the modular
11025 representation cannot be used, and instead the array of bytes
11026 representation must be used, meaning that the length must be a multiple
11027 of 8. Thus the above set of declarations will result in a diagnostic
11028 rejecting the size clause and noting that the minimum size allowed is 64.
11030 @cindex Pragma Pack (for type Natural)
11031 @cindex Pragma Pack warning
11033 One special case that is worth noting occurs when the base type of the
11034 component size is 8/16/32 and the subtype is one bit less. Notably this
11035 occurs with subtype @code{Natural}. Consider:
11037 @smallexample @c ada
11038 type Arr is array (1 .. 32) of Natural;
11043 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
11044 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
11045 Ada 83 compilers did not attempt 31 bit packing.
11047 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
11048 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
11049 substantial unintended performance penalty when porting legacy Ada 83 code.
11050 To help prevent this, GNAT generates a warning in such cases. If you really
11051 want 31 bit packing in a case like this, you can set the component size
11054 @smallexample @c ada
11055 type Arr is array (1 .. 32) of Natural;
11056 for Arr'Component_Size use 31;
11060 Here 31-bit packing is achieved as required, and no warning is generated,
11061 since in this case the programmer intention is clear.
11063 @node Pragma Pack for Records
11064 @section Pragma Pack for Records
11065 @cindex Pragma Pack (for records)
11068 Pragma @code{Pack} applied to a record will pack the components to reduce
11069 wasted space from alignment gaps and by reducing the amount of space
11070 taken by components. We distinguish between @emph{packable} components and
11071 @emph{non-packable} components.
11072 Components of the following types are considered packable:
11075 All primitive types are packable.
11078 Small packed arrays, whose size does not exceed 64 bits, and where the
11079 size is statically known at compile time, are represented internally
11080 as modular integers, and so they are also packable.
11085 All packable components occupy the exact number of bits corresponding to
11086 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11087 can start on an arbitrary bit boundary.
11089 All other types are non-packable, they occupy an integral number of
11091 are placed at a boundary corresponding to their alignment requirements.
11093 For example, consider the record
11095 @smallexample @c ada
11096 type Rb1 is array (1 .. 13) of Boolean;
11099 type Rb2 is array (1 .. 65) of Boolean;
11114 The representation for the record x2 is as follows:
11116 @smallexample @c ada
11117 for x2'Size use 224;
11119 l1 at 0 range 0 .. 0;
11120 l2 at 0 range 1 .. 64;
11121 l3 at 12 range 0 .. 31;
11122 l4 at 16 range 0 .. 0;
11123 l5 at 16 range 1 .. 13;
11124 l6 at 18 range 0 .. 71;
11129 Studying this example, we see that the packable fields @code{l1}
11131 of length equal to their sizes, and placed at specific bit boundaries (and
11132 not byte boundaries) to
11133 eliminate padding. But @code{l3} is of a non-packable float type, so
11134 it is on the next appropriate alignment boundary.
11136 The next two fields are fully packable, so @code{l4} and @code{l5} are
11137 minimally packed with no gaps. However, type @code{Rb2} is a packed
11138 array that is longer than 64 bits, so it is itself non-packable. Thus
11139 the @code{l6} field is aligned to the next byte boundary, and takes an
11140 integral number of bytes, i.e.@: 72 bits.
11142 @node Record Representation Clauses
11143 @section Record Representation Clauses
11144 @cindex Record Representation Clause
11147 Record representation clauses may be given for all record types, including
11148 types obtained by record extension. Component clauses are allowed for any
11149 static component. The restrictions on component clauses depend on the type
11152 @cindex Component Clause
11153 For all components of an elementary type, the only restriction on component
11154 clauses is that the size must be at least the 'Size value of the type
11155 (actually the Value_Size). There are no restrictions due to alignment,
11156 and such components may freely cross storage boundaries.
11158 Packed arrays with a size up to and including 64 bits are represented
11159 internally using a modular type with the appropriate number of bits, and
11160 thus the same lack of restriction applies. For example, if you declare:
11162 @smallexample @c ada
11163 type R is array (1 .. 49) of Boolean;
11169 then a component clause for a component of type R may start on any
11170 specified bit boundary, and may specify a value of 49 bits or greater.
11172 For packed bit arrays that are longer than 64 bits, there are two
11173 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11174 including the important case of single bits or boolean values, then
11175 there are no limitations on placement of such components, and they
11176 may start and end at arbitrary bit boundaries.
11178 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11179 an array of this type longer than 64 bits must always be placed on
11180 on a storage unit (byte) boundary and occupy an integral number
11181 of storage units (bytes). Any component clause that does not
11182 meet this requirement will be rejected.
11184 Any aliased component, or component of an aliased type, must
11185 have its normal alignment and size. A component clause that
11186 does not meet this requirement will be rejected.
11188 The tag field of a tagged type always occupies an address sized field at
11189 the start of the record. No component clause may attempt to overlay this
11190 tag. When a tagged type appears as a component, the tag field must have
11193 In the case of a record extension T1, of a type T, no component clause applied
11194 to the type T1 can specify a storage location that would overlap the first
11195 T'Size bytes of the record.
11197 For all other component types, including non-bit-packed arrays,
11198 the component can be placed at an arbitrary bit boundary,
11199 so for example, the following is permitted:
11201 @smallexample @c ada
11202 type R is array (1 .. 10) of Boolean;
11211 G at 0 range 0 .. 0;
11212 H at 0 range 1 .. 1;
11213 L at 0 range 2 .. 81;
11214 R at 0 range 82 .. 161;
11219 Note: the above rules apply to recent releases of GNAT 5.
11220 In GNAT 3, there are more severe restrictions on larger components.
11221 For non-primitive types, including packed arrays with a size greater than
11222 64 bits, component clauses must respect the alignment requirement of the
11223 type, in particular, always starting on a byte boundary, and the length
11224 must be a multiple of the storage unit.
11226 @node Enumeration Clauses
11227 @section Enumeration Clauses
11229 The only restriction on enumeration clauses is that the range of values
11230 must be representable. For the signed case, if one or more of the
11231 representation values are negative, all values must be in the range:
11233 @smallexample @c ada
11234 System.Min_Int .. System.Max_Int
11238 For the unsigned case, where all values are nonnegative, the values must
11241 @smallexample @c ada
11242 0 .. System.Max_Binary_Modulus;
11246 A @emph{confirming} representation clause is one in which the values range
11247 from 0 in sequence, i.e.@: a clause that confirms the default representation
11248 for an enumeration type.
11249 Such a confirming representation
11250 is permitted by these rules, and is specially recognized by the compiler so
11251 that no extra overhead results from the use of such a clause.
11253 If an array has an index type which is an enumeration type to which an
11254 enumeration clause has been applied, then the array is stored in a compact
11255 manner. Consider the declarations:
11257 @smallexample @c ada
11258 type r is (A, B, C);
11259 for r use (A => 1, B => 5, C => 10);
11260 type t is array (r) of Character;
11264 The array type t corresponds to a vector with exactly three elements and
11265 has a default size equal to @code{3*Character'Size}. This ensures efficient
11266 use of space, but means that accesses to elements of the array will incur
11267 the overhead of converting representation values to the corresponding
11268 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11270 @node Address Clauses
11271 @section Address Clauses
11272 @cindex Address Clause
11274 The reference manual allows a general restriction on representation clauses,
11275 as found in RM 13.1(22):
11278 An implementation need not support representation
11279 items containing nonstatic expressions, except that
11280 an implementation should support a representation item
11281 for a given entity if each nonstatic expression in the
11282 representation item is a name that statically denotes
11283 a constant declared before the entity.
11287 In practice this is applicable only to address clauses, since this is the
11288 only case in which a non-static expression is permitted by the syntax. As
11289 the AARM notes in sections 13.1 (22.a-22.h):
11292 22.a Reason: This is to avoid the following sort of thing:
11294 22.b X : Integer := F(@dots{});
11295 Y : Address := G(@dots{});
11296 for X'Address use Y;
11298 22.c In the above, we have to evaluate the
11299 initialization expression for X before we
11300 know where to put the result. This seems
11301 like an unreasonable implementation burden.
11303 22.d The above code should instead be written
11306 22.e Y : constant Address := G(@dots{});
11307 X : Integer := F(@dots{});
11308 for X'Address use Y;
11310 22.f This allows the expression ``Y'' to be safely
11311 evaluated before X is created.
11313 22.g The constant could be a formal parameter of mode in.
11315 22.h An implementation can support other nonstatic
11316 expressions if it wants to. Expressions of type
11317 Address are hardly ever static, but their value
11318 might be known at compile time anyway in many
11323 GNAT does indeed permit many additional cases of non-static expressions. In
11324 particular, if the type involved is elementary there are no restrictions
11325 (since in this case, holding a temporary copy of the initialization value,
11326 if one is present, is inexpensive). In addition, if there is no implicit or
11327 explicit initialization, then there are no restrictions. GNAT will reject
11328 only the case where all three of these conditions hold:
11333 The type of the item is non-elementary (e.g.@: a record or array).
11336 There is explicit or implicit initialization required for the object.
11337 Note that access values are always implicitly initialized, and also
11338 in GNAT, certain bit-packed arrays (those having a dynamic length or
11339 a length greater than 64) will also be implicitly initialized to zero.
11342 The address value is non-static. Here GNAT is more permissive than the
11343 RM, and allows the address value to be the address of a previously declared
11344 stand-alone variable, as long as it does not itself have an address clause.
11346 @smallexample @c ada
11347 Anchor : Some_Initialized_Type;
11348 Overlay : Some_Initialized_Type;
11349 for Overlay'Address use Anchor'Address;
11353 However, the prefix of the address clause cannot be an array component, or
11354 a component of a discriminated record.
11359 As noted above in section 22.h, address values are typically non-static. In
11360 particular the To_Address function, even if applied to a literal value, is
11361 a non-static function call. To avoid this minor annoyance, GNAT provides
11362 the implementation defined attribute 'To_Address. The following two
11363 expressions have identical values:
11367 @smallexample @c ada
11368 To_Address (16#1234_0000#)
11369 System'To_Address (16#1234_0000#);
11373 except that the second form is considered to be a static expression, and
11374 thus when used as an address clause value is always permitted.
11377 Additionally, GNAT treats as static an address clause that is an
11378 unchecked_conversion of a static integer value. This simplifies the porting
11379 of legacy code, and provides a portable equivalent to the GNAT attribute
11382 Another issue with address clauses is the interaction with alignment
11383 requirements. When an address clause is given for an object, the address
11384 value must be consistent with the alignment of the object (which is usually
11385 the same as the alignment of the type of the object). If an address clause
11386 is given that specifies an inappropriately aligned address value, then the
11387 program execution is erroneous.
11389 Since this source of erroneous behavior can have unfortunate effects, GNAT
11390 checks (at compile time if possible, generating a warning, or at execution
11391 time with a run-time check) that the alignment is appropriate. If the
11392 run-time check fails, then @code{Program_Error} is raised. This run-time
11393 check is suppressed if range checks are suppressed, or if the special GNAT
11394 check Alignment_Check is suppressed, or if
11395 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11397 Finally, GNAT does not permit overlaying of objects of controlled types or
11398 composite types containing a controlled component. In most cases, the compiler
11399 can detect an attempt at such overlays and will generate a warning at compile
11400 time and a Program_Error exception at run time.
11403 An address clause cannot be given for an exported object. More
11404 understandably the real restriction is that objects with an address
11405 clause cannot be exported. This is because such variables are not
11406 defined by the Ada program, so there is no external object to export.
11409 It is permissible to give an address clause and a pragma Import for the
11410 same object. In this case, the variable is not really defined by the
11411 Ada program, so there is no external symbol to be linked. The link name
11412 and the external name are ignored in this case. The reason that we allow this
11413 combination is that it provides a useful idiom to avoid unwanted
11414 initializations on objects with address clauses.
11416 When an address clause is given for an object that has implicit or
11417 explicit initialization, then by default initialization takes place. This
11418 means that the effect of the object declaration is to overwrite the
11419 memory at the specified address. This is almost always not what the
11420 programmer wants, so GNAT will output a warning:
11430 for Ext'Address use System'To_Address (16#1234_1234#);
11432 >>> warning: implicit initialization of "Ext" may
11433 modify overlaid storage
11434 >>> warning: use pragma Import for "Ext" to suppress
11435 initialization (RM B(24))
11441 As indicated by the warning message, the solution is to use a (dummy) pragma
11442 Import to suppress this initialization. The pragma tell the compiler that the
11443 object is declared and initialized elsewhere. The following package compiles
11444 without warnings (and the initialization is suppressed):
11446 @smallexample @c ada
11454 for Ext'Address use System'To_Address (16#1234_1234#);
11455 pragma Import (Ada, Ext);
11460 A final issue with address clauses involves their use for overlaying
11461 variables, as in the following example:
11462 @cindex Overlaying of objects
11464 @smallexample @c ada
11467 for B'Address use A'Address;
11471 or alternatively, using the form recommended by the RM:
11473 @smallexample @c ada
11475 Addr : constant Address := A'Address;
11477 for B'Address use Addr;
11481 In both of these cases, @code{A}
11482 and @code{B} become aliased to one another via the
11483 address clause. This use of address clauses to overlay
11484 variables, achieving an effect similar to unchecked
11485 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11486 the effect is implementation defined. Furthermore, the
11487 Ada RM specifically recommends that in a situation
11488 like this, @code{B} should be subject to the following
11489 implementation advice (RM 13.3(19)):
11492 19 If the Address of an object is specified, or it is imported
11493 or exported, then the implementation should not perform
11494 optimizations based on assumptions of no aliases.
11498 GNAT follows this recommendation, and goes further by also applying
11499 this recommendation to the overlaid variable (@code{A}
11500 in the above example) in this case. This means that the overlay
11501 works "as expected", in that a modification to one of the variables
11502 will affect the value of the other.
11504 @node Effect of Convention on Representation
11505 @section Effect of Convention on Representation
11506 @cindex Convention, effect on representation
11509 Normally the specification of a foreign language convention for a type or
11510 an object has no effect on the chosen representation. In particular, the
11511 representation chosen for data in GNAT generally meets the standard system
11512 conventions, and for example records are laid out in a manner that is
11513 consistent with C@. This means that specifying convention C (for example)
11516 There are four exceptions to this general rule:
11520 @item Convention Fortran and array subtypes
11521 If pragma Convention Fortran is specified for an array subtype, then in
11522 accordance with the implementation advice in section 3.6.2(11) of the
11523 Ada Reference Manual, the array will be stored in a Fortran-compatible
11524 column-major manner, instead of the normal default row-major order.
11526 @item Convention C and enumeration types
11527 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11528 to accommodate all values of the type. For example, for the enumeration
11531 @smallexample @c ada
11532 type Color is (Red, Green, Blue);
11536 8 bits is sufficient to store all values of the type, so by default, objects
11537 of type @code{Color} will be represented using 8 bits. However, normal C
11538 convention is to use 32 bits for all enum values in C, since enum values
11539 are essentially of type int. If pragma @code{Convention C} is specified for an
11540 Ada enumeration type, then the size is modified as necessary (usually to
11541 32 bits) to be consistent with the C convention for enum values.
11543 Note that this treatment applies only to types. If Convention C is given for
11544 an enumeration object, where the enumeration type is not Convention C, then
11545 Object_Size bits are allocated. For example, for a normal enumeration type,
11546 with less than 256 elements, only 8 bits will be allocated for the object.
11547 Since this may be a surprise in terms of what C expects, GNAT will issue a
11548 warning in this situation. The warning can be suppressed by giving an explicit
11549 size clause specifying the desired size.
11551 @item Convention C/Fortran and Boolean types
11552 In C, the usual convention for boolean values, that is values used for
11553 conditions, is that zero represents false, and nonzero values represent
11554 true. In Ada, the normal convention is that two specific values, typically
11555 0/1, are used to represent false/true respectively.
11557 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11558 value represents true).
11560 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11561 C or Fortran convention for a derived Boolean, as in the following example:
11563 @smallexample @c ada
11564 type C_Switch is new Boolean;
11565 pragma Convention (C, C_Switch);
11569 then the GNAT generated code will treat any nonzero value as true. For truth
11570 values generated by GNAT, the conventional value 1 will be used for True, but
11571 when one of these values is read, any nonzero value is treated as True.
11573 @item Access types on OpenVMS
11574 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11575 arrays) are 64-bits long. An exception to this rule is for the case of
11576 C-convention access types where there is no explicit size clause present (or
11577 inherited for derived types). In this case, GNAT chooses to make these
11578 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11579 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11583 @node Determining the Representations chosen by GNAT
11584 @section Determining the Representations chosen by GNAT
11585 @cindex Representation, determination of
11586 @cindex @option{-gnatR} switch
11589 Although the descriptions in this section are intended to be complete, it is
11590 often easier to simply experiment to see what GNAT accepts and what the
11591 effect is on the layout of types and objects.
11593 As required by the Ada RM, if a representation clause is not accepted, then
11594 it must be rejected as illegal by the compiler. However, when a
11595 representation clause or pragma is accepted, there can still be questions
11596 of what the compiler actually does. For example, if a partial record
11597 representation clause specifies the location of some components and not
11598 others, then where are the non-specified components placed? Or if pragma
11599 @code{Pack} is used on a record, then exactly where are the resulting
11600 fields placed? The section on pragma @code{Pack} in this chapter can be
11601 used to answer the second question, but it is often easier to just see
11602 what the compiler does.
11604 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
11605 with this option, then the compiler will output information on the actual
11606 representations chosen, in a format similar to source representation
11607 clauses. For example, if we compile the package:
11609 @smallexample @c ada
11611 type r (x : boolean) is tagged record
11613 when True => S : String (1 .. 100);
11614 when False => null;
11618 type r2 is new r (false) with record
11623 y2 at 16 range 0 .. 31;
11630 type x1 is array (1 .. 10) of x;
11631 for x1'component_size use 11;
11633 type ia is access integer;
11635 type Rb1 is array (1 .. 13) of Boolean;
11638 type Rb2 is array (1 .. 65) of Boolean;
11654 using the switch @option{-gnatR} we obtain the following output:
11657 Representation information for unit q
11658 -------------------------------------
11661 for r'Alignment use 4;
11663 x at 4 range 0 .. 7;
11664 _tag at 0 range 0 .. 31;
11665 s at 5 range 0 .. 799;
11668 for r2'Size use 160;
11669 for r2'Alignment use 4;
11671 x at 4 range 0 .. 7;
11672 _tag at 0 range 0 .. 31;
11673 _parent at 0 range 0 .. 63;
11674 y2 at 16 range 0 .. 31;
11678 for x'Alignment use 1;
11680 y at 0 range 0 .. 7;
11683 for x1'Size use 112;
11684 for x1'Alignment use 1;
11685 for x1'Component_Size use 11;
11687 for rb1'Size use 13;
11688 for rb1'Alignment use 2;
11689 for rb1'Component_Size use 1;
11691 for rb2'Size use 72;
11692 for rb2'Alignment use 1;
11693 for rb2'Component_Size use 1;
11695 for x2'Size use 224;
11696 for x2'Alignment use 4;
11698 l1 at 0 range 0 .. 0;
11699 l2 at 0 range 1 .. 64;
11700 l3 at 12 range 0 .. 31;
11701 l4 at 16 range 0 .. 0;
11702 l5 at 16 range 1 .. 13;
11703 l6 at 18 range 0 .. 71;
11708 The Size values are actually the Object_Size, i.e.@: the default size that
11709 will be allocated for objects of the type.
11710 The ?? size for type r indicates that we have a variant record, and the
11711 actual size of objects will depend on the discriminant value.
11713 The Alignment values show the actual alignment chosen by the compiler
11714 for each record or array type.
11716 The record representation clause for type r shows where all fields
11717 are placed, including the compiler generated tag field (whose location
11718 cannot be controlled by the programmer).
11720 The record representation clause for the type extension r2 shows all the
11721 fields present, including the parent field, which is a copy of the fields
11722 of the parent type of r2, i.e.@: r1.
11724 The component size and size clauses for types rb1 and rb2 show
11725 the exact effect of pragma @code{Pack} on these arrays, and the record
11726 representation clause for type x2 shows how pragma @code{Pack} affects
11729 In some cases, it may be useful to cut and paste the representation clauses
11730 generated by the compiler into the original source to fix and guarantee
11731 the actual representation to be used.
11733 @node Standard Library Routines
11734 @chapter Standard Library Routines
11737 The Ada Reference Manual contains in Annex A a full description of an
11738 extensive set of standard library routines that can be used in any Ada
11739 program, and which must be provided by all Ada compilers. They are
11740 analogous to the standard C library used by C programs.
11742 GNAT implements all of the facilities described in annex A, and for most
11743 purposes the description in the Ada Reference Manual, or appropriate Ada
11744 text book, will be sufficient for making use of these facilities.
11746 In the case of the input-output facilities,
11747 @xref{The Implementation of Standard I/O},
11748 gives details on exactly how GNAT interfaces to the
11749 file system. For the remaining packages, the Ada Reference Manual
11750 should be sufficient. The following is a list of the packages included,
11751 together with a brief description of the functionality that is provided.
11753 For completeness, references are included to other predefined library
11754 routines defined in other sections of the Ada Reference Manual (these are
11755 cross-indexed from Annex A).
11759 This is a parent package for all the standard library packages. It is
11760 usually included implicitly in your program, and itself contains no
11761 useful data or routines.
11763 @item Ada.Calendar (9.6)
11764 @code{Calendar} provides time of day access, and routines for
11765 manipulating times and durations.
11767 @item Ada.Characters (A.3.1)
11768 This is a dummy parent package that contains no useful entities
11770 @item Ada.Characters.Handling (A.3.2)
11771 This package provides some basic character handling capabilities,
11772 including classification functions for classes of characters (e.g.@: test
11773 for letters, or digits).
11775 @item Ada.Characters.Latin_1 (A.3.3)
11776 This package includes a complete set of definitions of the characters
11777 that appear in type CHARACTER@. It is useful for writing programs that
11778 will run in international environments. For example, if you want an
11779 upper case E with an acute accent in a string, it is often better to use
11780 the definition of @code{UC_E_Acute} in this package. Then your program
11781 will print in an understandable manner even if your environment does not
11782 support these extended characters.
11784 @item Ada.Command_Line (A.15)
11785 This package provides access to the command line parameters and the name
11786 of the current program (analogous to the use of @code{argc} and @code{argv}
11787 in C), and also allows the exit status for the program to be set in a
11788 system-independent manner.
11790 @item Ada.Decimal (F.2)
11791 This package provides constants describing the range of decimal numbers
11792 implemented, and also a decimal divide routine (analogous to the COBOL
11793 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11795 @item Ada.Direct_IO (A.8.4)
11796 This package provides input-output using a model of a set of records of
11797 fixed-length, containing an arbitrary definite Ada type, indexed by an
11798 integer record number.
11800 @item Ada.Dynamic_Priorities (D.5)
11801 This package allows the priorities of a task to be adjusted dynamically
11802 as the task is running.
11804 @item Ada.Exceptions (11.4.1)
11805 This package provides additional information on exceptions, and also
11806 contains facilities for treating exceptions as data objects, and raising
11807 exceptions with associated messages.
11809 @item Ada.Finalization (7.6)
11810 This package contains the declarations and subprograms to support the
11811 use of controlled types, providing for automatic initialization and
11812 finalization (analogous to the constructors and destructors of C++)
11814 @item Ada.Interrupts (C.3.2)
11815 This package provides facilities for interfacing to interrupts, which
11816 includes the set of signals or conditions that can be raised and
11817 recognized as interrupts.
11819 @item Ada.Interrupts.Names (C.3.2)
11820 This package provides the set of interrupt names (actually signal
11821 or condition names) that can be handled by GNAT@.
11823 @item Ada.IO_Exceptions (A.13)
11824 This package defines the set of exceptions that can be raised by use of
11825 the standard IO packages.
11828 This package contains some standard constants and exceptions used
11829 throughout the numerics packages. Note that the constants pi and e are
11830 defined here, and it is better to use these definitions than rolling
11833 @item Ada.Numerics.Complex_Elementary_Functions
11834 Provides the implementation of standard elementary functions (such as
11835 log and trigonometric functions) operating on complex numbers using the
11836 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11837 created by the package @code{Numerics.Complex_Types}.
11839 @item Ada.Numerics.Complex_Types
11840 This is a predefined instantiation of
11841 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11842 build the type @code{Complex} and @code{Imaginary}.
11844 @item Ada.Numerics.Discrete_Random
11845 This package provides a random number generator suitable for generating
11846 random integer values from a specified range.
11848 @item Ada.Numerics.Float_Random
11849 This package provides a random number generator suitable for generating
11850 uniformly distributed floating point values.
11852 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11853 This is a generic version of the package that provides the
11854 implementation of standard elementary functions (such as log and
11855 trigonometric functions) for an arbitrary complex type.
11857 The following predefined instantiations of this package are provided:
11861 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11863 @code{Ada.Numerics.Complex_Elementary_Functions}
11865 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
11868 @item Ada.Numerics.Generic_Complex_Types
11869 This is a generic package that allows the creation of complex types,
11870 with associated complex arithmetic operations.
11872 The following predefined instantiations of this package exist
11875 @code{Ada.Numerics.Short_Complex_Complex_Types}
11877 @code{Ada.Numerics.Complex_Complex_Types}
11879 @code{Ada.Numerics.Long_Complex_Complex_Types}
11882 @item Ada.Numerics.Generic_Elementary_Functions
11883 This is a generic package that provides the implementation of standard
11884 elementary functions (such as log an trigonometric functions) for an
11885 arbitrary float type.
11887 The following predefined instantiations of this package exist
11891 @code{Ada.Numerics.Short_Elementary_Functions}
11893 @code{Ada.Numerics.Elementary_Functions}
11895 @code{Ada.Numerics.Long_Elementary_Functions}
11898 @item Ada.Real_Time (D.8)
11899 This package provides facilities similar to those of @code{Calendar}, but
11900 operating with a finer clock suitable for real time control. Note that
11901 annex D requires that there be no backward clock jumps, and GNAT generally
11902 guarantees this behavior, but of course if the external clock on which
11903 the GNAT runtime depends is deliberately reset by some external event,
11904 then such a backward jump may occur.
11906 @item Ada.Sequential_IO (A.8.1)
11907 This package provides input-output facilities for sequential files,
11908 which can contain a sequence of values of a single type, which can be
11909 any Ada type, including indefinite (unconstrained) types.
11911 @item Ada.Storage_IO (A.9)
11912 This package provides a facility for mapping arbitrary Ada types to and
11913 from a storage buffer. It is primarily intended for the creation of new
11916 @item Ada.Streams (13.13.1)
11917 This is a generic package that provides the basic support for the
11918 concept of streams as used by the stream attributes (@code{Input},
11919 @code{Output}, @code{Read} and @code{Write}).
11921 @item Ada.Streams.Stream_IO (A.12.1)
11922 This package is a specialization of the type @code{Streams} defined in
11923 package @code{Streams} together with a set of operations providing
11924 Stream_IO capability. The Stream_IO model permits both random and
11925 sequential access to a file which can contain an arbitrary set of values
11926 of one or more Ada types.
11928 @item Ada.Strings (A.4.1)
11929 This package provides some basic constants used by the string handling
11932 @item Ada.Strings.Bounded (A.4.4)
11933 This package provides facilities for handling variable length
11934 strings. The bounded model requires a maximum length. It is thus
11935 somewhat more limited than the unbounded model, but avoids the use of
11936 dynamic allocation or finalization.
11938 @item Ada.Strings.Fixed (A.4.3)
11939 This package provides facilities for handling fixed length strings.
11941 @item Ada.Strings.Maps (A.4.2)
11942 This package provides facilities for handling character mappings and
11943 arbitrarily defined subsets of characters. For instance it is useful in
11944 defining specialized translation tables.
11946 @item Ada.Strings.Maps.Constants (A.4.6)
11947 This package provides a standard set of predefined mappings and
11948 predefined character sets. For example, the standard upper to lower case
11949 conversion table is found in this package. Note that upper to lower case
11950 conversion is non-trivial if you want to take the entire set of
11951 characters, including extended characters like E with an acute accent,
11952 into account. You should use the mappings in this package (rather than
11953 adding 32 yourself) to do case mappings.
11955 @item Ada.Strings.Unbounded (A.4.5)
11956 This package provides facilities for handling variable length
11957 strings. The unbounded model allows arbitrary length strings, but
11958 requires the use of dynamic allocation and finalization.
11960 @item Ada.Strings.Wide_Bounded (A.4.7)
11961 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11962 @itemx Ada.Strings.Wide_Maps (A.4.7)
11963 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11964 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11965 These packages provide analogous capabilities to the corresponding
11966 packages without @samp{Wide_} in the name, but operate with the types
11967 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11968 and @code{Character}.
11970 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11971 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11972 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11973 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11974 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11975 These packages provide analogous capabilities to the corresponding
11976 packages without @samp{Wide_} in the name, but operate with the types
11977 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11978 of @code{String} and @code{Character}.
11980 @item Ada.Synchronous_Task_Control (D.10)
11981 This package provides some standard facilities for controlling task
11982 communication in a synchronous manner.
11985 This package contains definitions for manipulation of the tags of tagged
11988 @item Ada.Task_Attributes
11989 This package provides the capability of associating arbitrary
11990 task-specific data with separate tasks.
11993 This package provides basic text input-output capabilities for
11994 character, string and numeric data. The subpackages of this
11995 package are listed next.
11997 @item Ada.Text_IO.Decimal_IO
11998 Provides input-output facilities for decimal fixed-point types
12000 @item Ada.Text_IO.Enumeration_IO
12001 Provides input-output facilities for enumeration types.
12003 @item Ada.Text_IO.Fixed_IO
12004 Provides input-output facilities for ordinary fixed-point types.
12006 @item Ada.Text_IO.Float_IO
12007 Provides input-output facilities for float types. The following
12008 predefined instantiations of this generic package are available:
12012 @code{Short_Float_Text_IO}
12014 @code{Float_Text_IO}
12016 @code{Long_Float_Text_IO}
12019 @item Ada.Text_IO.Integer_IO
12020 Provides input-output facilities for integer types. The following
12021 predefined instantiations of this generic package are available:
12024 @item Short_Short_Integer
12025 @code{Ada.Short_Short_Integer_Text_IO}
12026 @item Short_Integer
12027 @code{Ada.Short_Integer_Text_IO}
12029 @code{Ada.Integer_Text_IO}
12031 @code{Ada.Long_Integer_Text_IO}
12032 @item Long_Long_Integer
12033 @code{Ada.Long_Long_Integer_Text_IO}
12036 @item Ada.Text_IO.Modular_IO
12037 Provides input-output facilities for modular (unsigned) types
12039 @item Ada.Text_IO.Complex_IO (G.1.3)
12040 This package provides basic text input-output capabilities for complex
12043 @item Ada.Text_IO.Editing (F.3.3)
12044 This package contains routines for edited output, analogous to the use
12045 of pictures in COBOL@. The picture formats used by this package are a
12046 close copy of the facility in COBOL@.
12048 @item Ada.Text_IO.Text_Streams (A.12.2)
12049 This package provides a facility that allows Text_IO files to be treated
12050 as streams, so that the stream attributes can be used for writing
12051 arbitrary data, including binary data, to Text_IO files.
12053 @item Ada.Unchecked_Conversion (13.9)
12054 This generic package allows arbitrary conversion from one type to
12055 another of the same size, providing for breaking the type safety in
12056 special circumstances.
12058 If the types have the same Size (more accurately the same Value_Size),
12059 then the effect is simply to transfer the bits from the source to the
12060 target type without any modification. This usage is well defined, and
12061 for simple types whose representation is typically the same across
12062 all implementations, gives a portable method of performing such
12065 If the types do not have the same size, then the result is implementation
12066 defined, and thus may be non-portable. The following describes how GNAT
12067 handles such unchecked conversion cases.
12069 If the types are of different sizes, and are both discrete types, then
12070 the effect is of a normal type conversion without any constraint checking.
12071 In particular if the result type has a larger size, the result will be
12072 zero or sign extended. If the result type has a smaller size, the result
12073 will be truncated by ignoring high order bits.
12075 If the types are of different sizes, and are not both discrete types,
12076 then the conversion works as though pointers were created to the source
12077 and target, and the pointer value is converted. The effect is that bits
12078 are copied from successive low order storage units and bits of the source
12079 up to the length of the target type.
12081 A warning is issued if the lengths differ, since the effect in this
12082 case is implementation dependent, and the above behavior may not match
12083 that of some other compiler.
12085 A pointer to one type may be converted to a pointer to another type using
12086 unchecked conversion. The only case in which the effect is undefined is
12087 when one or both pointers are pointers to unconstrained array types. In
12088 this case, the bounds information may get incorrectly transferred, and in
12089 particular, GNAT uses double size pointers for such types, and it is
12090 meaningless to convert between such pointer types. GNAT will issue a
12091 warning if the alignment of the target designated type is more strict
12092 than the alignment of the source designated type (since the result may
12093 be unaligned in this case).
12095 A pointer other than a pointer to an unconstrained array type may be
12096 converted to and from System.Address. Such usage is common in Ada 83
12097 programs, but note that Ada.Address_To_Access_Conversions is the
12098 preferred method of performing such conversions in Ada 95 and Ada 2005.
12100 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12101 used in conjunction with pointers to unconstrained objects, since
12102 the bounds information cannot be handled correctly in this case.
12104 @item Ada.Unchecked_Deallocation (13.11.2)
12105 This generic package allows explicit freeing of storage previously
12106 allocated by use of an allocator.
12108 @item Ada.Wide_Text_IO (A.11)
12109 This package is similar to @code{Ada.Text_IO}, except that the external
12110 file supports wide character representations, and the internal types are
12111 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12112 and @code{String}. It contains generic subpackages listed next.
12114 @item Ada.Wide_Text_IO.Decimal_IO
12115 Provides input-output facilities for decimal fixed-point types
12117 @item Ada.Wide_Text_IO.Enumeration_IO
12118 Provides input-output facilities for enumeration types.
12120 @item Ada.Wide_Text_IO.Fixed_IO
12121 Provides input-output facilities for ordinary fixed-point types.
12123 @item Ada.Wide_Text_IO.Float_IO
12124 Provides input-output facilities for float types. The following
12125 predefined instantiations of this generic package are available:
12129 @code{Short_Float_Wide_Text_IO}
12131 @code{Float_Wide_Text_IO}
12133 @code{Long_Float_Wide_Text_IO}
12136 @item Ada.Wide_Text_IO.Integer_IO
12137 Provides input-output facilities for integer types. The following
12138 predefined instantiations of this generic package are available:
12141 @item Short_Short_Integer
12142 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12143 @item Short_Integer
12144 @code{Ada.Short_Integer_Wide_Text_IO}
12146 @code{Ada.Integer_Wide_Text_IO}
12148 @code{Ada.Long_Integer_Wide_Text_IO}
12149 @item Long_Long_Integer
12150 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12153 @item Ada.Wide_Text_IO.Modular_IO
12154 Provides input-output facilities for modular (unsigned) types
12156 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12157 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12158 external file supports wide character representations.
12160 @item Ada.Wide_Text_IO.Editing (F.3.4)
12161 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12162 types are @code{Wide_Character} and @code{Wide_String} instead of
12163 @code{Character} and @code{String}.
12165 @item Ada.Wide_Text_IO.Streams (A.12.3)
12166 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12167 types are @code{Wide_Character} and @code{Wide_String} instead of
12168 @code{Character} and @code{String}.
12170 @item Ada.Wide_Wide_Text_IO (A.11)
12171 This package is similar to @code{Ada.Text_IO}, except that the external
12172 file supports wide character representations, and the internal types are
12173 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12174 and @code{String}. It contains generic subpackages listed next.
12176 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12177 Provides input-output facilities for decimal fixed-point types
12179 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12180 Provides input-output facilities for enumeration types.
12182 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12183 Provides input-output facilities for ordinary fixed-point types.
12185 @item Ada.Wide_Wide_Text_IO.Float_IO
12186 Provides input-output facilities for float types. The following
12187 predefined instantiations of this generic package are available:
12191 @code{Short_Float_Wide_Wide_Text_IO}
12193 @code{Float_Wide_Wide_Text_IO}
12195 @code{Long_Float_Wide_Wide_Text_IO}
12198 @item Ada.Wide_Wide_Text_IO.Integer_IO
12199 Provides input-output facilities for integer types. The following
12200 predefined instantiations of this generic package are available:
12203 @item Short_Short_Integer
12204 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12205 @item Short_Integer
12206 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12208 @code{Ada.Integer_Wide_Wide_Text_IO}
12210 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12211 @item Long_Long_Integer
12212 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12215 @item Ada.Wide_Wide_Text_IO.Modular_IO
12216 Provides input-output facilities for modular (unsigned) types
12218 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12219 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12220 external file supports wide character representations.
12222 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12223 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12224 types are @code{Wide_Character} and @code{Wide_String} instead of
12225 @code{Character} and @code{String}.
12227 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12228 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12229 types are @code{Wide_Character} and @code{Wide_String} instead of
12230 @code{Character} and @code{String}.
12235 @node The Implementation of Standard I/O
12236 @chapter The Implementation of Standard I/O
12239 GNAT implements all the required input-output facilities described in
12240 A.6 through A.14. These sections of the Ada Reference Manual describe the
12241 required behavior of these packages from the Ada point of view, and if
12242 you are writing a portable Ada program that does not need to know the
12243 exact manner in which Ada maps to the outside world when it comes to
12244 reading or writing external files, then you do not need to read this
12245 chapter. As long as your files are all regular files (not pipes or
12246 devices), and as long as you write and read the files only from Ada, the
12247 description in the Ada Reference Manual is sufficient.
12249 However, if you want to do input-output to pipes or other devices, such
12250 as the keyboard or screen, or if the files you are dealing with are
12251 either generated by some other language, or to be read by some other
12252 language, then you need to know more about the details of how the GNAT
12253 implementation of these input-output facilities behaves.
12255 In this chapter we give a detailed description of exactly how GNAT
12256 interfaces to the file system. As always, the sources of the system are
12257 available to you for answering questions at an even more detailed level,
12258 but for most purposes the information in this chapter will suffice.
12260 Another reason that you may need to know more about how input-output is
12261 implemented arises when you have a program written in mixed languages
12262 where, for example, files are shared between the C and Ada sections of
12263 the same program. GNAT provides some additional facilities, in the form
12264 of additional child library packages, that facilitate this sharing, and
12265 these additional facilities are also described in this chapter.
12268 * Standard I/O Packages::
12274 * Wide_Wide_Text_IO::
12276 * Text Translation::
12278 * Filenames encoding::
12280 * Operations on C Streams::
12281 * Interfacing to C Streams::
12284 @node Standard I/O Packages
12285 @section Standard I/O Packages
12288 The Standard I/O packages described in Annex A for
12294 Ada.Text_IO.Complex_IO
12296 Ada.Text_IO.Text_Streams
12300 Ada.Wide_Text_IO.Complex_IO
12302 Ada.Wide_Text_IO.Text_Streams
12304 Ada.Wide_Wide_Text_IO
12306 Ada.Wide_Wide_Text_IO.Complex_IO
12308 Ada.Wide_Wide_Text_IO.Text_Streams
12318 are implemented using the C
12319 library streams facility; where
12323 All files are opened using @code{fopen}.
12325 All input/output operations use @code{fread}/@code{fwrite}.
12329 There is no internal buffering of any kind at the Ada library level. The only
12330 buffering is that provided at the system level in the implementation of the
12331 library routines that support streams. This facilitates shared use of these
12332 streams by mixed language programs. Note though that system level buffering is
12333 explicitly enabled at elaboration of the standard I/O packages and that can
12334 have an impact on mixed language programs, in particular those using I/O before
12335 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12336 the Ada elaboration routine before performing any I/O or when impractical,
12337 flush the common I/O streams and in particular Standard_Output before
12338 elaborating the Ada code.
12341 @section FORM Strings
12344 The format of a FORM string in GNAT is:
12347 "keyword=value,keyword=value,@dots{},keyword=value"
12351 where letters may be in upper or lower case, and there are no spaces
12352 between values. The order of the entries is not important. Currently
12353 the following keywords defined.
12356 TEXT_TRANSLATION=[YES|NO]
12358 WCEM=[n|h|u|s|e|8|b]
12359 ENCODING=[UTF8|8BITS]
12363 The use of these parameters is described later in this section.
12369 Direct_IO can only be instantiated for definite types. This is a
12370 restriction of the Ada language, which means that the records are fixed
12371 length (the length being determined by @code{@var{type}'Size}, rounded
12372 up to the next storage unit boundary if necessary).
12374 The records of a Direct_IO file are simply written to the file in index
12375 sequence, with the first record starting at offset zero, and subsequent
12376 records following. There is no control information of any kind. For
12377 example, if 32-bit integers are being written, each record takes
12378 4-bytes, so the record at index @var{K} starts at offset
12379 (@var{K}@minus{}1)*4.
12381 There is no limit on the size of Direct_IO files, they are expanded as
12382 necessary to accommodate whatever records are written to the file.
12384 @node Sequential_IO
12385 @section Sequential_IO
12388 Sequential_IO may be instantiated with either a definite (constrained)
12389 or indefinite (unconstrained) type.
12391 For the definite type case, the elements written to the file are simply
12392 the memory images of the data values with no control information of any
12393 kind. The resulting file should be read using the same type, no validity
12394 checking is performed on input.
12396 For the indefinite type case, the elements written consist of two
12397 parts. First is the size of the data item, written as the memory image
12398 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12399 the data value. The resulting file can only be read using the same
12400 (unconstrained) type. Normal assignment checks are performed on these
12401 read operations, and if these checks fail, @code{Data_Error} is
12402 raised. In particular, in the array case, the lengths must match, and in
12403 the variant record case, if the variable for a particular read operation
12404 is constrained, the discriminants must match.
12406 Note that it is not possible to use Sequential_IO to write variable
12407 length array items, and then read the data back into different length
12408 arrays. For example, the following will raise @code{Data_Error}:
12410 @smallexample @c ada
12411 package IO is new Sequential_IO (String);
12416 IO.Write (F, "hello!")
12417 IO.Reset (F, Mode=>In_File);
12424 On some Ada implementations, this will print @code{hell}, but the program is
12425 clearly incorrect, since there is only one element in the file, and that
12426 element is the string @code{hello!}.
12428 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12429 using Stream_IO, and this is the preferred mechanism. In particular, the
12430 above program fragment rewritten to use Stream_IO will work correctly.
12436 Text_IO files consist of a stream of characters containing the following
12437 special control characters:
12440 LF (line feed, 16#0A#) Line Mark
12441 FF (form feed, 16#0C#) Page Mark
12445 A canonical Text_IO file is defined as one in which the following
12446 conditions are met:
12450 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12454 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12455 end of a page and consequently can appear only immediately following a
12456 @code{LF} (line mark) character.
12459 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12460 (line mark, page mark). In the former case, the page mark is implicitly
12461 assumed to be present.
12465 A file written using Text_IO will be in canonical form provided that no
12466 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12467 or @code{Put_Line}. There will be no @code{FF} character at the end of
12468 the file unless an explicit @code{New_Page} operation was performed
12469 before closing the file.
12471 A canonical Text_IO file that is a regular file (i.e., not a device or a
12472 pipe) can be read using any of the routines in Text_IO@. The
12473 semantics in this case will be exactly as defined in the Ada Reference
12474 Manual, and all the routines in Text_IO are fully implemented.
12476 A text file that does not meet the requirements for a canonical Text_IO
12477 file has one of the following:
12481 The file contains @code{FF} characters not immediately following a
12482 @code{LF} character.
12485 The file contains @code{LF} or @code{FF} characters written by
12486 @code{Put} or @code{Put_Line}, which are not logically considered to be
12487 line marks or page marks.
12490 The file ends in a character other than @code{LF} or @code{FF},
12491 i.e.@: there is no explicit line mark or page mark at the end of the file.
12495 Text_IO can be used to read such non-standard text files but subprograms
12496 to do with line or page numbers do not have defined meanings. In
12497 particular, a @code{FF} character that does not follow a @code{LF}
12498 character may or may not be treated as a page mark from the point of
12499 view of page and line numbering. Every @code{LF} character is considered
12500 to end a line, and there is an implied @code{LF} character at the end of
12504 * Text_IO Stream Pointer Positioning::
12505 * Text_IO Reading and Writing Non-Regular Files::
12507 * Treating Text_IO Files as Streams::
12508 * Text_IO Extensions::
12509 * Text_IO Facilities for Unbounded Strings::
12512 @node Text_IO Stream Pointer Positioning
12513 @subsection Stream Pointer Positioning
12516 @code{Ada.Text_IO} has a definition of current position for a file that
12517 is being read. No internal buffering occurs in Text_IO, and usually the
12518 physical position in the stream used to implement the file corresponds
12519 to this logical position defined by Text_IO@. There are two exceptions:
12523 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12524 is positioned past the @code{LF} (line mark) that precedes the page
12525 mark. Text_IO maintains an internal flag so that subsequent read
12526 operations properly handle the logical position which is unchanged by
12527 the @code{End_Of_Page} call.
12530 After a call to @code{End_Of_File} that returns @code{True}, if the
12531 Text_IO file was positioned before the line mark at the end of file
12532 before the call, then the logical position is unchanged, but the stream
12533 is physically positioned right at the end of file (past the line mark,
12534 and past a possible page mark following the line mark. Again Text_IO
12535 maintains internal flags so that subsequent read operations properly
12536 handle the logical position.
12540 These discrepancies have no effect on the observable behavior of
12541 Text_IO, but if a single Ada stream is shared between a C program and
12542 Ada program, or shared (using @samp{shared=yes} in the form string)
12543 between two Ada files, then the difference may be observable in some
12546 @node Text_IO Reading and Writing Non-Regular Files
12547 @subsection Reading and Writing Non-Regular Files
12550 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
12551 can be used for reading and writing. Writing is not affected and the
12552 sequence of characters output is identical to the normal file case, but
12553 for reading, the behavior of Text_IO is modified to avoid undesirable
12554 look-ahead as follows:
12556 An input file that is not a regular file is considered to have no page
12557 marks. Any @code{Ascii.FF} characters (the character normally used for a
12558 page mark) appearing in the file are considered to be data
12559 characters. In particular:
12563 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12564 following a line mark. If a page mark appears, it will be treated as a
12568 This avoids the need to wait for an extra character to be typed or
12569 entered from the pipe to complete one of these operations.
12572 @code{End_Of_Page} always returns @code{False}
12575 @code{End_Of_File} will return @code{False} if there is a page mark at
12576 the end of the file.
12580 Output to non-regular files is the same as for regular files. Page marks
12581 may be written to non-regular files using @code{New_Page}, but as noted
12582 above they will not be treated as page marks on input if the output is
12583 piped to another Ada program.
12585 Another important discrepancy when reading non-regular files is that the end
12586 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
12587 pressing the @key{EOT} key,
12589 is signaled once (i.e.@: the test @code{End_Of_File}
12590 will yield @code{True}, or a read will
12591 raise @code{End_Error}), but then reading can resume
12592 to read data past that end of
12593 file indication, until another end of file indication is entered.
12595 @node Get_Immediate
12596 @subsection Get_Immediate
12597 @cindex Get_Immediate
12600 Get_Immediate returns the next character (including control characters)
12601 from the input file. In particular, Get_Immediate will return LF or FF
12602 characters used as line marks or page marks. Such operations leave the
12603 file positioned past the control character, and it is thus not treated
12604 as having its normal function. This means that page, line and column
12605 counts after this kind of Get_Immediate call are set as though the mark
12606 did not occur. In the case where a Get_Immediate leaves the file
12607 positioned between the line mark and page mark (which is not normally
12608 possible), it is undefined whether the FF character will be treated as a
12611 @node Treating Text_IO Files as Streams
12612 @subsection Treating Text_IO Files as Streams
12613 @cindex Stream files
12616 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12617 as a stream. Data written to a Text_IO file in this stream mode is
12618 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
12619 16#0C# (@code{FF}), the resulting file may have non-standard
12620 format. Similarly if read operations are used to read from a Text_IO
12621 file treated as a stream, then @code{LF} and @code{FF} characters may be
12622 skipped and the effect is similar to that described above for
12623 @code{Get_Immediate}.
12625 @node Text_IO Extensions
12626 @subsection Text_IO Extensions
12627 @cindex Text_IO extensions
12630 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12631 to the standard @code{Text_IO} package:
12634 @item function File_Exists (Name : String) return Boolean;
12635 Determines if a file of the given name exists.
12637 @item function Get_Line return String;
12638 Reads a string from the standard input file. The value returned is exactly
12639 the length of the line that was read.
12641 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12642 Similar, except that the parameter File specifies the file from which
12643 the string is to be read.
12647 @node Text_IO Facilities for Unbounded Strings
12648 @subsection Text_IO Facilities for Unbounded Strings
12649 @cindex Text_IO for unbounded strings
12650 @cindex Unbounded_String, Text_IO operations
12653 The package @code{Ada.Strings.Unbounded.Text_IO}
12654 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12655 subprograms useful for Text_IO operations on unbounded strings:
12659 @item function Get_Line (File : File_Type) return Unbounded_String;
12660 Reads a line from the specified file
12661 and returns the result as an unbounded string.
12663 @item procedure Put (File : File_Type; U : Unbounded_String);
12664 Writes the value of the given unbounded string to the specified file
12665 Similar to the effect of
12666 @code{Put (To_String (U))} except that an extra copy is avoided.
12668 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12669 Writes the value of the given unbounded string to the specified file,
12670 followed by a @code{New_Line}.
12671 Similar to the effect of @code{Put_Line (To_String (U))} except
12672 that an extra copy is avoided.
12676 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12677 and is optional. If the parameter is omitted, then the standard input or
12678 output file is referenced as appropriate.
12680 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12681 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12682 @code{Wide_Text_IO} functionality for unbounded wide strings.
12684 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12685 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12686 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12689 @section Wide_Text_IO
12692 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12693 both input and output files may contain special sequences that represent
12694 wide character values. The encoding scheme for a given file may be
12695 specified using a FORM parameter:
12702 as part of the FORM string (WCEM = wide character encoding method),
12703 where @var{x} is one of the following characters
12709 Upper half encoding
12721 The encoding methods match those that
12722 can be used in a source
12723 program, but there is no requirement that the encoding method used for
12724 the source program be the same as the encoding method used for files,
12725 and different files may use different encoding methods.
12727 The default encoding method for the standard files, and for opened files
12728 for which no WCEM parameter is given in the FORM string matches the
12729 wide character encoding specified for the main program (the default
12730 being brackets encoding if no coding method was specified with -gnatW).
12734 In this encoding, a wide character is represented by a five character
12742 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12743 characters (using upper case letters) of the wide character code. For
12744 example, ESC A345 is used to represent the wide character with code
12745 16#A345#. This scheme is compatible with use of the full
12746 @code{Wide_Character} set.
12748 @item Upper Half Coding
12749 The wide character with encoding 16#abcd#, where the upper bit is on
12750 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12751 16#cd#. The second byte may never be a format control character, but is
12752 not required to be in the upper half. This method can be also used for
12753 shift-JIS or EUC where the internal coding matches the external coding.
12755 @item Shift JIS Coding
12756 A wide character is represented by a two character sequence 16#ab# and
12757 16#cd#, with the restrictions described for upper half encoding as
12758 described above. The internal character code is the corresponding JIS
12759 character according to the standard algorithm for Shift-JIS
12760 conversion. Only characters defined in the JIS code set table can be
12761 used with this encoding method.
12764 A wide character is represented by a two character sequence 16#ab# and
12765 16#cd#, with both characters being in the upper half. The internal
12766 character code is the corresponding JIS character according to the EUC
12767 encoding algorithm. Only characters defined in the JIS code set table
12768 can be used with this encoding method.
12771 A wide character is represented using
12772 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12773 10646-1/Am.2. Depending on the character value, the representation
12774 is a one, two, or three byte sequence:
12777 16#0000#-16#007f#: 2#0xxxxxxx#
12778 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12779 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12783 where the @var{xxx} bits correspond to the left-padded bits of the
12784 16-bit character value. Note that all lower half ASCII characters
12785 are represented as ASCII bytes and all upper half characters and
12786 other wide characters are represented as sequences of upper-half
12787 (The full UTF-8 scheme allows for encoding 31-bit characters as
12788 6-byte sequences, but in this implementation, all UTF-8 sequences
12789 of four or more bytes length will raise a Constraint_Error, as
12790 will all invalid UTF-8 sequences.)
12792 @item Brackets Coding
12793 In this encoding, a wide character is represented by the following eight
12794 character sequence:
12801 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12802 characters (using uppercase letters) of the wide character code. For
12803 example, @code{["A345"]} is used to represent the wide character with code
12805 This scheme is compatible with use of the full Wide_Character set.
12806 On input, brackets coding can also be used for upper half characters,
12807 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12808 is only used for wide characters with a code greater than @code{16#FF#}.
12810 Note that brackets coding is not normally used in the context of
12811 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12812 a portable way of encoding source files. In the context of Wide_Text_IO
12813 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12814 any instance of the left bracket character other than to encode wide
12815 character values using the brackets encoding method. In practice it is
12816 expected that some standard wide character encoding method such
12817 as UTF-8 will be used for text input output.
12819 If brackets notation is used, then any occurrence of a left bracket
12820 in the input file which is not the start of a valid wide character
12821 sequence will cause Constraint_Error to be raised. It is possible to
12822 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12823 input will interpret this as a left bracket.
12825 However, when a left bracket is output, it will be output as a left bracket
12826 and not as ["5B"]. We make this decision because for normal use of
12827 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12828 brackets. For example, if we write:
12831 Put_Line ("Start of output [first run]");
12835 we really do not want to have the left bracket in this message clobbered so
12836 that the output reads:
12839 Start of output ["5B"]first run]
12843 In practice brackets encoding is reasonably useful for normal Put_Line use
12844 since we won't get confused between left brackets and wide character
12845 sequences in the output. But for input, or when files are written out
12846 and read back in, it really makes better sense to use one of the standard
12847 encoding methods such as UTF-8.
12852 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12853 not all wide character
12854 values can be represented. An attempt to output a character that cannot
12855 be represented using the encoding scheme for the file causes
12856 Constraint_Error to be raised. An invalid wide character sequence on
12857 input also causes Constraint_Error to be raised.
12860 * Wide_Text_IO Stream Pointer Positioning::
12861 * Wide_Text_IO Reading and Writing Non-Regular Files::
12864 @node Wide_Text_IO Stream Pointer Positioning
12865 @subsection Stream Pointer Positioning
12868 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12869 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12872 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12873 normal lower ASCII set (i.e.@: a character in the range:
12875 @smallexample @c ada
12876 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12880 then although the logical position of the file pointer is unchanged by
12881 the @code{Look_Ahead} call, the stream is physically positioned past the
12882 wide character sequence. Again this is to avoid the need for buffering
12883 or backup, and all @code{Wide_Text_IO} routines check the internal
12884 indication that this situation has occurred so that this is not visible
12885 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
12886 can be observed if the wide text file shares a stream with another file.
12888 @node Wide_Text_IO Reading and Writing Non-Regular Files
12889 @subsection Reading and Writing Non-Regular Files
12892 As in the case of Text_IO, when a non-regular file is read, it is
12893 assumed that the file contains no page marks (any form characters are
12894 treated as data characters), and @code{End_Of_Page} always returns
12895 @code{False}. Similarly, the end of file indication is not sticky, so
12896 it is possible to read beyond an end of file.
12898 @node Wide_Wide_Text_IO
12899 @section Wide_Wide_Text_IO
12902 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12903 both input and output files may contain special sequences that represent
12904 wide wide character values. The encoding scheme for a given file may be
12905 specified using a FORM parameter:
12912 as part of the FORM string (WCEM = wide character encoding method),
12913 where @var{x} is one of the following characters
12919 Upper half encoding
12931 The encoding methods match those that
12932 can be used in a source
12933 program, but there is no requirement that the encoding method used for
12934 the source program be the same as the encoding method used for files,
12935 and different files may use different encoding methods.
12937 The default encoding method for the standard files, and for opened files
12938 for which no WCEM parameter is given in the FORM string matches the
12939 wide character encoding specified for the main program (the default
12940 being brackets encoding if no coding method was specified with -gnatW).
12945 A wide character is represented using
12946 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12947 10646-1/Am.2. Depending on the character value, the representation
12948 is a one, two, three, or four byte sequence:
12951 16#000000#-16#00007f#: 2#0xxxxxxx#
12952 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12953 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12954 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12958 where the @var{xxx} bits correspond to the left-padded bits of the
12959 21-bit character value. Note that all lower half ASCII characters
12960 are represented as ASCII bytes and all upper half characters and
12961 other wide characters are represented as sequences of upper-half
12964 @item Brackets Coding
12965 In this encoding, a wide wide character is represented by the following eight
12966 character sequence if is in wide character range
12972 and by the following ten character sequence if not
12975 [ " a b c d e f " ]
12979 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12980 are the four or six hexadecimal
12981 characters (using uppercase letters) of the wide wide character code. For
12982 example, @code{["01A345"]} is used to represent the wide wide character
12983 with code @code{16#01A345#}.
12985 This scheme is compatible with use of the full Wide_Wide_Character set.
12986 On input, brackets coding can also be used for upper half characters,
12987 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12988 is only used for wide characters with a code greater than @code{16#FF#}.
12993 If is also possible to use the other Wide_Character encoding methods,
12994 such as Shift-JIS, but the other schemes cannot support the full range
12995 of wide wide characters.
12996 An attempt to output a character that cannot
12997 be represented using the encoding scheme for the file causes
12998 Constraint_Error to be raised. An invalid wide character sequence on
12999 input also causes Constraint_Error to be raised.
13002 * Wide_Wide_Text_IO Stream Pointer Positioning::
13003 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
13006 @node Wide_Wide_Text_IO Stream Pointer Positioning
13007 @subsection Stream Pointer Positioning
13010 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13011 of stream pointer positioning (@pxref{Text_IO}). There is one additional
13014 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
13015 normal lower ASCII set (i.e.@: a character in the range:
13017 @smallexample @c ada
13018 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
13022 then although the logical position of the file pointer is unchanged by
13023 the @code{Look_Ahead} call, the stream is physically positioned past the
13024 wide character sequence. Again this is to avoid the need for buffering
13025 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
13026 indication that this situation has occurred so that this is not visible
13027 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
13028 can be observed if the wide text file shares a stream with another file.
13030 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
13031 @subsection Reading and Writing Non-Regular Files
13034 As in the case of Text_IO, when a non-regular file is read, it is
13035 assumed that the file contains no page marks (any form characters are
13036 treated as data characters), and @code{End_Of_Page} always returns
13037 @code{False}. Similarly, the end of file indication is not sticky, so
13038 it is possible to read beyond an end of file.
13044 A stream file is a sequence of bytes, where individual elements are
13045 written to the file as described in the Ada Reference Manual. The type
13046 @code{Stream_Element} is simply a byte. There are two ways to read or
13047 write a stream file.
13051 The operations @code{Read} and @code{Write} directly read or write a
13052 sequence of stream elements with no control information.
13055 The stream attributes applied to a stream file transfer data in the
13056 manner described for stream attributes.
13059 @node Text Translation
13060 @section Text Translation
13063 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13064 passed to Text_IO.Create and Text_IO.Open:
13065 @samp{Text_Translation=@var{Yes}} is the default, which means to
13066 translate LF to/from CR/LF on Windows systems.
13067 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13068 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13069 may be used to create Unix-style files on
13070 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13074 @section Shared Files
13077 Section A.14 of the Ada Reference Manual allows implementations to
13078 provide a wide variety of behavior if an attempt is made to access the
13079 same external file with two or more internal files.
13081 To provide a full range of functionality, while at the same time
13082 minimizing the problems of portability caused by this implementation
13083 dependence, GNAT handles file sharing as follows:
13087 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13088 to open two or more files with the same full name is considered an error
13089 and is not supported. The exception @code{Use_Error} will be
13090 raised. Note that a file that is not explicitly closed by the program
13091 remains open until the program terminates.
13094 If the form parameter @samp{shared=no} appears in the form string, the
13095 file can be opened or created with its own separate stream identifier,
13096 regardless of whether other files sharing the same external file are
13097 opened. The exact effect depends on how the C stream routines handle
13098 multiple accesses to the same external files using separate streams.
13101 If the form parameter @samp{shared=yes} appears in the form string for
13102 each of two or more files opened using the same full name, the same
13103 stream is shared between these files, and the semantics are as described
13104 in Ada Reference Manual, Section A.14.
13108 When a program that opens multiple files with the same name is ported
13109 from another Ada compiler to GNAT, the effect will be that
13110 @code{Use_Error} is raised.
13112 The documentation of the original compiler and the documentation of the
13113 program should then be examined to determine if file sharing was
13114 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13115 and @code{Create} calls as required.
13117 When a program is ported from GNAT to some other Ada compiler, no
13118 special attention is required unless the @samp{shared=@var{xxx}} form
13119 parameter is used in the program. In this case, you must examine the
13120 documentation of the new compiler to see if it supports the required
13121 file sharing semantics, and form strings modified appropriately. Of
13122 course it may be the case that the program cannot be ported if the
13123 target compiler does not support the required functionality. The best
13124 approach in writing portable code is to avoid file sharing (and hence
13125 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13128 One common use of file sharing in Ada 83 is the use of instantiations of
13129 Sequential_IO on the same file with different types, to achieve
13130 heterogeneous input-output. Although this approach will work in GNAT if
13131 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13132 for this purpose (using the stream attributes)
13134 @node Filenames encoding
13135 @section Filenames encoding
13138 An encoding form parameter can be used to specify the filename
13139 encoding @samp{encoding=@var{xxx}}.
13143 If the form parameter @samp{encoding=utf8} appears in the form string, the
13144 filename must be encoded in UTF-8.
13147 If the form parameter @samp{encoding=8bits} appears in the form
13148 string, the filename must be a standard 8bits string.
13151 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13152 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13153 variable. And if not set @samp{utf8} is assumed.
13157 The current system Windows ANSI code page.
13162 This encoding form parameter is only supported on the Windows
13163 platform. On the other Operating Systems the run-time is supporting
13167 @section Open Modes
13170 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13171 using the mode shown in the following table:
13174 @center @code{Open} and @code{Create} Call Modes
13176 @b{OPEN } @b{CREATE}
13177 Append_File "r+" "w+"
13179 Out_File (Direct_IO) "r+" "w"
13180 Out_File (all other cases) "w" "w"
13181 Inout_File "r+" "w+"
13185 If text file translation is required, then either @samp{b} or @samp{t}
13186 is added to the mode, depending on the setting of Text. Text file
13187 translation refers to the mapping of CR/LF sequences in an external file
13188 to LF characters internally. This mapping only occurs in DOS and
13189 DOS-like systems, and is not relevant to other systems.
13191 A special case occurs with Stream_IO@. As shown in the above table, the
13192 file is initially opened in @samp{r} or @samp{w} mode for the
13193 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
13194 subsequently requires switching from reading to writing or vice-versa,
13195 then the file is reopened in @samp{r+} mode to permit the required operation.
13197 @node Operations on C Streams
13198 @section Operations on C Streams
13199 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13200 access to the C library functions for operations on C streams:
13202 @smallexample @c adanocomment
13203 package Interfaces.C_Streams is
13204 -- Note: the reason we do not use the types that are in
13205 -- Interfaces.C is that we want to avoid dragging in the
13206 -- code in this unit if possible.
13207 subtype chars is System.Address;
13208 -- Pointer to null-terminated array of characters
13209 subtype FILEs is System.Address;
13210 -- Corresponds to the C type FILE*
13211 subtype voids is System.Address;
13212 -- Corresponds to the C type void*
13213 subtype int is Integer;
13214 subtype long is Long_Integer;
13215 -- Note: the above types are subtypes deliberately, and it
13216 -- is part of this spec that the above correspondences are
13217 -- guaranteed. This means that it is legitimate to, for
13218 -- example, use Integer instead of int. We provide these
13219 -- synonyms for clarity, but in some cases it may be
13220 -- convenient to use the underlying types (for example to
13221 -- avoid an unnecessary dependency of a spec on the spec
13223 type size_t is mod 2 ** Standard'Address_Size;
13224 NULL_Stream : constant FILEs;
13225 -- Value returned (NULL in C) to indicate an
13226 -- fdopen/fopen/tmpfile error
13227 ----------------------------------
13228 -- Constants Defined in stdio.h --
13229 ----------------------------------
13230 EOF : constant int;
13231 -- Used by a number of routines to indicate error or
13233 IOFBF : constant int;
13234 IOLBF : constant int;
13235 IONBF : constant int;
13236 -- Used to indicate buffering mode for setvbuf call
13237 SEEK_CUR : constant int;
13238 SEEK_END : constant int;
13239 SEEK_SET : constant int;
13240 -- Used to indicate origin for fseek call
13241 function stdin return FILEs;
13242 function stdout return FILEs;
13243 function stderr return FILEs;
13244 -- Streams associated with standard files
13245 --------------------------
13246 -- Standard C functions --
13247 --------------------------
13248 -- The functions selected below are ones that are
13249 -- available in DOS, OS/2, UNIX and Xenix (but not
13250 -- necessarily in ANSI C). These are very thin interfaces
13251 -- which copy exactly the C headers. For more
13252 -- documentation on these functions, see the Microsoft C
13253 -- "Run-Time Library Reference" (Microsoft Press, 1990,
13254 -- ISBN 1-55615-225-6), which includes useful information
13255 -- on system compatibility.
13256 procedure clearerr (stream : FILEs);
13257 function fclose (stream : FILEs) return int;
13258 function fdopen (handle : int; mode : chars) return FILEs;
13259 function feof (stream : FILEs) return int;
13260 function ferror (stream : FILEs) return int;
13261 function fflush (stream : FILEs) return int;
13262 function fgetc (stream : FILEs) return int;
13263 function fgets (strng : chars; n : int; stream : FILEs)
13265 function fileno (stream : FILEs) return int;
13266 function fopen (filename : chars; Mode : chars)
13268 -- Note: to maintain target independence, use
13269 -- text_translation_required, a boolean variable defined in
13270 -- a-sysdep.c to deal with the target dependent text
13271 -- translation requirement. If this variable is set,
13272 -- then b/t should be appended to the standard mode
13273 -- argument to set the text translation mode off or on
13275 function fputc (C : int; stream : FILEs) return int;
13276 function fputs (Strng : chars; Stream : FILEs) return int;
13293 function ftell (stream : FILEs) return long;
13300 function isatty (handle : int) return int;
13301 procedure mktemp (template : chars);
13302 -- The return value (which is just a pointer to template)
13304 procedure rewind (stream : FILEs);
13305 function rmtmp return int;
13313 function tmpfile return FILEs;
13314 function ungetc (c : int; stream : FILEs) return int;
13315 function unlink (filename : chars) return int;
13316 ---------------------
13317 -- Extra functions --
13318 ---------------------
13319 -- These functions supply slightly thicker bindings than
13320 -- those above. They are derived from functions in the
13321 -- C Run-Time Library, but may do a bit more work than
13322 -- just directly calling one of the Library functions.
13323 function is_regular_file (handle : int) return int;
13324 -- Tests if given handle is for a regular file (result 1)
13325 -- or for a non-regular file (pipe or device, result 0).
13326 ---------------------------------
13327 -- Control of Text/Binary Mode --
13328 ---------------------------------
13329 -- If text_translation_required is true, then the following
13330 -- functions may be used to dynamically switch a file from
13331 -- binary to text mode or vice versa. These functions have
13332 -- no effect if text_translation_required is false (i.e.@: in
13333 -- normal UNIX mode). Use fileno to get a stream handle.
13334 procedure set_binary_mode (handle : int);
13335 procedure set_text_mode (handle : int);
13336 ----------------------------
13337 -- Full Path Name support --
13338 ----------------------------
13339 procedure full_name (nam : chars; buffer : chars);
13340 -- Given a NUL terminated string representing a file
13341 -- name, returns in buffer a NUL terminated string
13342 -- representing the full path name for the file name.
13343 -- On systems where it is relevant the drive is also
13344 -- part of the full path name. It is the responsibility
13345 -- of the caller to pass an actual parameter for buffer
13346 -- that is big enough for any full path name. Use
13347 -- max_path_len given below as the size of buffer.
13348 max_path_len : integer;
13349 -- Maximum length of an allowable full path name on the
13350 -- system, including a terminating NUL character.
13351 end Interfaces.C_Streams;
13354 @node Interfacing to C Streams
13355 @section Interfacing to C Streams
13358 The packages in this section permit interfacing Ada files to C Stream
13361 @smallexample @c ada
13362 with Interfaces.C_Streams;
13363 package Ada.Sequential_IO.C_Streams is
13364 function C_Stream (F : File_Type)
13365 return Interfaces.C_Streams.FILEs;
13367 (File : in out File_Type;
13368 Mode : in File_Mode;
13369 C_Stream : in Interfaces.C_Streams.FILEs;
13370 Form : in String := "");
13371 end Ada.Sequential_IO.C_Streams;
13373 with Interfaces.C_Streams;
13374 package Ada.Direct_IO.C_Streams is
13375 function C_Stream (F : File_Type)
13376 return Interfaces.C_Streams.FILEs;
13378 (File : in out File_Type;
13379 Mode : in File_Mode;
13380 C_Stream : in Interfaces.C_Streams.FILEs;
13381 Form : in String := "");
13382 end Ada.Direct_IO.C_Streams;
13384 with Interfaces.C_Streams;
13385 package Ada.Text_IO.C_Streams is
13386 function C_Stream (F : File_Type)
13387 return Interfaces.C_Streams.FILEs;
13389 (File : in out File_Type;
13390 Mode : in File_Mode;
13391 C_Stream : in Interfaces.C_Streams.FILEs;
13392 Form : in String := "");
13393 end Ada.Text_IO.C_Streams;
13395 with Interfaces.C_Streams;
13396 package Ada.Wide_Text_IO.C_Streams is
13397 function C_Stream (F : File_Type)
13398 return Interfaces.C_Streams.FILEs;
13400 (File : in out File_Type;
13401 Mode : in File_Mode;
13402 C_Stream : in Interfaces.C_Streams.FILEs;
13403 Form : in String := "");
13404 end Ada.Wide_Text_IO.C_Streams;
13406 with Interfaces.C_Streams;
13407 package Ada.Wide_Wide_Text_IO.C_Streams is
13408 function C_Stream (F : File_Type)
13409 return Interfaces.C_Streams.FILEs;
13411 (File : in out File_Type;
13412 Mode : in File_Mode;
13413 C_Stream : in Interfaces.C_Streams.FILEs;
13414 Form : in String := "");
13415 end Ada.Wide_Wide_Text_IO.C_Streams;
13417 with Interfaces.C_Streams;
13418 package Ada.Stream_IO.C_Streams is
13419 function C_Stream (F : File_Type)
13420 return Interfaces.C_Streams.FILEs;
13422 (File : in out File_Type;
13423 Mode : in File_Mode;
13424 C_Stream : in Interfaces.C_Streams.FILEs;
13425 Form : in String := "");
13426 end Ada.Stream_IO.C_Streams;
13430 In each of these six packages, the @code{C_Stream} function obtains the
13431 @code{FILE} pointer from a currently opened Ada file. It is then
13432 possible to use the @code{Interfaces.C_Streams} package to operate on
13433 this stream, or the stream can be passed to a C program which can
13434 operate on it directly. Of course the program is responsible for
13435 ensuring that only appropriate sequences of operations are executed.
13437 One particular use of relevance to an Ada program is that the
13438 @code{setvbuf} function can be used to control the buffering of the
13439 stream used by an Ada file. In the absence of such a call the standard
13440 default buffering is used.
13442 The @code{Open} procedures in these packages open a file giving an
13443 existing C Stream instead of a file name. Typically this stream is
13444 imported from a C program, allowing an Ada file to operate on an
13447 @node The GNAT Library
13448 @chapter The GNAT Library
13451 The GNAT library contains a number of general and special purpose packages.
13452 It represents functionality that the GNAT developers have found useful, and
13453 which is made available to GNAT users. The packages described here are fully
13454 supported, and upwards compatibility will be maintained in future releases,
13455 so you can use these facilities with the confidence that the same functionality
13456 will be available in future releases.
13458 The chapter here simply gives a brief summary of the facilities available.
13459 The full documentation is found in the spec file for the package. The full
13460 sources of these library packages, including both spec and body, are provided
13461 with all GNAT releases. For example, to find out the full specifications of
13462 the SPITBOL pattern matching capability, including a full tutorial and
13463 extensive examples, look in the @file{g-spipat.ads} file in the library.
13465 For each entry here, the package name (as it would appear in a @code{with}
13466 clause) is given, followed by the name of the corresponding spec file in
13467 parentheses. The packages are children in four hierarchies, @code{Ada},
13468 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13469 GNAT-specific hierarchy.
13471 Note that an application program should only use packages in one of these
13472 four hierarchies if the package is defined in the Ada Reference Manual,
13473 or is listed in this section of the GNAT Programmers Reference Manual.
13474 All other units should be considered internal implementation units and
13475 should not be directly @code{with}'ed by application code. The use of
13476 a @code{with} statement that references one of these internal implementation
13477 units makes an application potentially dependent on changes in versions
13478 of GNAT, and will generate a warning message.
13481 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13482 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13483 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13484 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13485 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13486 * Ada.Command_Line.Environment (a-colien.ads)::
13487 * Ada.Command_Line.Remove (a-colire.ads)::
13488 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13489 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13490 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13491 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13492 * Ada.Exceptions.Traceback (a-exctra.ads)::
13493 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13494 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13495 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13496 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13497 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13498 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13499 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13500 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13501 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13502 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13503 * GNAT.Altivec (g-altive.ads)::
13504 * GNAT.Altivec.Conversions (g-altcon.ads)::
13505 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13506 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13507 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13508 * GNAT.Array_Split (g-arrspl.ads)::
13509 * GNAT.AWK (g-awk.ads)::
13510 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13511 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13512 * GNAT.Bubble_Sort (g-bubsor.ads)::
13513 * GNAT.Bubble_Sort_A (g-busora.ads)::
13514 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13515 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13516 * GNAT.Byte_Swapping (g-bytswa.ads)::
13517 * GNAT.Calendar (g-calend.ads)::
13518 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13519 * GNAT.Case_Util (g-casuti.ads)::
13520 * GNAT.CGI (g-cgi.ads)::
13521 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13522 * GNAT.CGI.Debug (g-cgideb.ads)::
13523 * GNAT.Command_Line (g-comlin.ads)::
13524 * GNAT.Compiler_Version (g-comver.ads)::
13525 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13526 * GNAT.CRC32 (g-crc32.ads)::
13527 * GNAT.Current_Exception (g-curexc.ads)::
13528 * GNAT.Debug_Pools (g-debpoo.ads)::
13529 * GNAT.Debug_Utilities (g-debuti.ads)::
13530 * GNAT.Decode_String (g-decstr.ads)::
13531 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13532 * GNAT.Directory_Operations (g-dirope.ads)::
13533 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13534 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13535 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13536 * GNAT.Encode_String (g-encstr.ads)::
13537 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13538 * GNAT.Exception_Actions (g-excact.ads)::
13539 * GNAT.Exception_Traces (g-exctra.ads)::
13540 * GNAT.Exceptions (g-except.ads)::
13541 * GNAT.Expect (g-expect.ads)::
13542 * GNAT.Float_Control (g-flocon.ads)::
13543 * GNAT.Heap_Sort (g-heasor.ads)::
13544 * GNAT.Heap_Sort_A (g-hesora.ads)::
13545 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13546 * GNAT.HTable (g-htable.ads)::
13547 * GNAT.IO (g-io.ads)::
13548 * GNAT.IO_Aux (g-io_aux.ads)::
13549 * GNAT.Lock_Files (g-locfil.ads)::
13550 * GNAT.MD5 (g-md5.ads)::
13551 * GNAT.Memory_Dump (g-memdum.ads)::
13552 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13553 * GNAT.OS_Lib (g-os_lib.ads)::
13554 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13555 * GNAT.Random_Numbers (g-rannum.ads)::
13556 * GNAT.Regexp (g-regexp.ads)::
13557 * GNAT.Registry (g-regist.ads)::
13558 * GNAT.Regpat (g-regpat.ads)::
13559 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13560 * GNAT.Semaphores (g-semaph.ads)::
13561 * GNAT.Serial_Communications (g-sercom.ads)::
13562 * GNAT.SHA1 (g-sha1.ads)::
13563 * GNAT.Signals (g-signal.ads)::
13564 * GNAT.Sockets (g-socket.ads)::
13565 * GNAT.Source_Info (g-souinf.ads)::
13566 * GNAT.Spelling_Checker (g-speche.ads)::
13567 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13568 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13569 * GNAT.Spitbol (g-spitbo.ads)::
13570 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13571 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13572 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13573 * GNAT.SSE (g-sse.ads)::
13574 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
13575 * GNAT.Strings (g-string.ads)::
13576 * GNAT.String_Split (g-strspl.ads)::
13577 * GNAT.Table (g-table.ads)::
13578 * GNAT.Task_Lock (g-tasloc.ads)::
13579 * GNAT.Threads (g-thread.ads)::
13580 * GNAT.Time_Stamp (g-timsta.ads)::
13581 * GNAT.Traceback (g-traceb.ads)::
13582 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13583 * GNAT.UTF_32 (g-utf_32.ads)::
13584 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13585 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13586 * GNAT.Wide_String_Split (g-wistsp.ads)::
13587 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13588 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13589 * Interfaces.C.Extensions (i-cexten.ads)::
13590 * Interfaces.C.Streams (i-cstrea.ads)::
13591 * Interfaces.CPP (i-cpp.ads)::
13592 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13593 * Interfaces.VxWorks (i-vxwork.ads)::
13594 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13595 * System.Address_Image (s-addima.ads)::
13596 * System.Assertions (s-assert.ads)::
13597 * System.Memory (s-memory.ads)::
13598 * System.Partition_Interface (s-parint.ads)::
13599 * System.Pool_Global (s-pooglo.ads)::
13600 * System.Pool_Local (s-pooloc.ads)::
13601 * System.Restrictions (s-restri.ads)::
13602 * System.Rident (s-rident.ads)::
13603 * System.Strings.Stream_Ops (s-ststop.ads)::
13604 * System.Task_Info (s-tasinf.ads)::
13605 * System.Wch_Cnv (s-wchcnv.ads)::
13606 * System.Wch_Con (s-wchcon.ads)::
13609 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13610 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13611 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13612 @cindex Latin_9 constants for Character
13615 This child of @code{Ada.Characters}
13616 provides a set of definitions corresponding to those in the
13617 RM-defined package @code{Ada.Characters.Latin_1} but with the
13618 few modifications required for @code{Latin-9}
13619 The provision of such a package
13620 is specifically authorized by the Ada Reference Manual
13623 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13624 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13625 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13626 @cindex Latin_1 constants for Wide_Character
13629 This child of @code{Ada.Characters}
13630 provides a set of definitions corresponding to those in the
13631 RM-defined package @code{Ada.Characters.Latin_1} but with the
13632 types of the constants being @code{Wide_Character}
13633 instead of @code{Character}. The provision of such a package
13634 is specifically authorized by the Ada Reference Manual
13637 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13638 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13639 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13640 @cindex Latin_9 constants for Wide_Character
13643 This child of @code{Ada.Characters}
13644 provides a set of definitions corresponding to those in the
13645 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13646 types of the constants being @code{Wide_Character}
13647 instead of @code{Character}. The provision of such a package
13648 is specifically authorized by the Ada Reference Manual
13651 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13652 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13653 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13654 @cindex Latin_1 constants for Wide_Wide_Character
13657 This child of @code{Ada.Characters}
13658 provides a set of definitions corresponding to those in the
13659 RM-defined package @code{Ada.Characters.Latin_1} but with the
13660 types of the constants being @code{Wide_Wide_Character}
13661 instead of @code{Character}. The provision of such a package
13662 is specifically authorized by the Ada Reference Manual
13665 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13666 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13667 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13668 @cindex Latin_9 constants for Wide_Wide_Character
13671 This child of @code{Ada.Characters}
13672 provides a set of definitions corresponding to those in the
13673 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13674 types of the constants being @code{Wide_Wide_Character}
13675 instead of @code{Character}. The provision of such a package
13676 is specifically authorized by the Ada Reference Manual
13679 @node Ada.Command_Line.Environment (a-colien.ads)
13680 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13681 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13682 @cindex Environment entries
13685 This child of @code{Ada.Command_Line}
13686 provides a mechanism for obtaining environment values on systems
13687 where this concept makes sense.
13689 @node Ada.Command_Line.Remove (a-colire.ads)
13690 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13691 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13692 @cindex Removing command line arguments
13693 @cindex Command line, argument removal
13696 This child of @code{Ada.Command_Line}
13697 provides a mechanism for logically removing
13698 arguments from the argument list. Once removed, an argument is not visible
13699 to further calls on the subprograms in @code{Ada.Command_Line} will not
13700 see the removed argument.
13702 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13703 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13704 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13705 @cindex Response file for command line
13706 @cindex Command line, response file
13707 @cindex Command line, handling long command lines
13710 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13711 getting command line arguments from a text file, called a "response file".
13712 Using a response file allow passing a set of arguments to an executable longer
13713 than the maximum allowed by the system on the command line.
13715 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13716 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13717 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13718 @cindex C Streams, Interfacing with Direct_IO
13721 This package provides subprograms that allow interfacing between
13722 C streams and @code{Direct_IO}. The stream identifier can be
13723 extracted from a file opened on the Ada side, and an Ada file
13724 can be constructed from a stream opened on the C side.
13726 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13727 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13728 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13729 @cindex Null_Occurrence, testing for
13732 This child subprogram provides a way of testing for the null
13733 exception occurrence (@code{Null_Occurrence}) without raising
13736 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13737 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13738 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13739 @cindex Null_Occurrence, testing for
13742 This child subprogram is used for handling otherwise unhandled
13743 exceptions (hence the name last chance), and perform clean ups before
13744 terminating the program. Note that this subprogram never returns.
13746 @node Ada.Exceptions.Traceback (a-exctra.ads)
13747 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13748 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13749 @cindex Traceback for Exception Occurrence
13752 This child package provides the subprogram (@code{Tracebacks}) to
13753 give a traceback array of addresses based on an exception
13756 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13757 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13758 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13759 @cindex C Streams, Interfacing with Sequential_IO
13762 This package provides subprograms that allow interfacing between
13763 C streams and @code{Sequential_IO}. The stream identifier can be
13764 extracted from a file opened on the Ada side, and an Ada file
13765 can be constructed from a stream opened on the C side.
13767 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13768 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13769 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13770 @cindex C Streams, Interfacing with Stream_IO
13773 This package provides subprograms that allow interfacing between
13774 C streams and @code{Stream_IO}. The stream identifier can be
13775 extracted from a file opened on the Ada side, and an Ada file
13776 can be constructed from a stream opened on the C side.
13778 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13779 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13780 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13781 @cindex @code{Unbounded_String}, IO support
13782 @cindex @code{Text_IO}, extensions for unbounded strings
13785 This package provides subprograms for Text_IO for unbounded
13786 strings, avoiding the necessity for an intermediate operation
13787 with ordinary strings.
13789 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13790 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13791 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13792 @cindex @code{Unbounded_Wide_String}, IO support
13793 @cindex @code{Text_IO}, extensions for unbounded wide strings
13796 This package provides subprograms for Text_IO for unbounded
13797 wide strings, avoiding the necessity for an intermediate operation
13798 with ordinary wide strings.
13800 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13801 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13802 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13803 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13804 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13807 This package provides subprograms for Text_IO for unbounded
13808 wide wide strings, avoiding the necessity for an intermediate operation
13809 with ordinary wide wide strings.
13811 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13812 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13813 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13814 @cindex C Streams, Interfacing with @code{Text_IO}
13817 This package provides subprograms that allow interfacing between
13818 C streams and @code{Text_IO}. The stream identifier can be
13819 extracted from a file opened on the Ada side, and an Ada file
13820 can be constructed from a stream opened on the C side.
13822 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
13823 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13824 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13825 @cindex Unicode categorization, Wide_Character
13828 This package provides subprograms that allow categorization of
13829 Wide_Character values according to Unicode categories.
13831 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13832 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13833 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13834 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13837 This package provides subprograms that allow interfacing between
13838 C streams and @code{Wide_Text_IO}. The stream identifier can be
13839 extracted from a file opened on the Ada side, and an Ada file
13840 can be constructed from a stream opened on the C side.
13842 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13843 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13844 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13845 @cindex Unicode categorization, Wide_Wide_Character
13848 This package provides subprograms that allow categorization of
13849 Wide_Wide_Character values according to Unicode categories.
13851 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13852 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13853 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13854 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13857 This package provides subprograms that allow interfacing between
13858 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
13859 extracted from a file opened on the Ada side, and an Ada file
13860 can be constructed from a stream opened on the C side.
13862 @node GNAT.Altivec (g-altive.ads)
13863 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13864 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13868 This is the root package of the GNAT AltiVec binding. It provides
13869 definitions of constants and types common to all the versions of the
13872 @node GNAT.Altivec.Conversions (g-altcon.ads)
13873 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13874 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13878 This package provides the Vector/View conversion routines.
13880 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13881 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13882 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13886 This package exposes the Ada interface to the AltiVec operations on
13887 vector objects. A soft emulation is included by default in the GNAT
13888 library. The hard binding is provided as a separate package. This unit
13889 is common to both bindings.
13891 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13892 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13893 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13897 This package exposes the various vector types part of the Ada binding
13898 to AltiVec facilities.
13900 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13901 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13902 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13906 This package provides public 'View' data types from/to which private
13907 vector representations can be converted via
13908 GNAT.Altivec.Conversions. This allows convenient access to individual
13909 vector elements and provides a simple way to initialize vector
13912 @node GNAT.Array_Split (g-arrspl.ads)
13913 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13914 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13915 @cindex Array splitter
13918 Useful array-manipulation routines: given a set of separators, split
13919 an array wherever the separators appear, and provide direct access
13920 to the resulting slices.
13922 @node GNAT.AWK (g-awk.ads)
13923 @section @code{GNAT.AWK} (@file{g-awk.ads})
13924 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13929 Provides AWK-like parsing functions, with an easy interface for parsing one
13930 or more files containing formatted data. The file is viewed as a database
13931 where each record is a line and a field is a data element in this line.
13933 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13934 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13935 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13937 @cindex Bounded Buffers
13940 Provides a concurrent generic bounded buffer abstraction. Instances are
13941 useful directly or as parts of the implementations of other abstractions,
13944 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13945 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13946 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13951 Provides a thread-safe asynchronous intertask mailbox communication facility.
13953 @node GNAT.Bubble_Sort (g-bubsor.ads)
13954 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13955 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13957 @cindex Bubble sort
13960 Provides a general implementation of bubble sort usable for sorting arbitrary
13961 data items. Exchange and comparison procedures are provided by passing
13962 access-to-procedure values.
13964 @node GNAT.Bubble_Sort_A (g-busora.ads)
13965 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13966 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13968 @cindex Bubble sort
13971 Provides a general implementation of bubble sort usable for sorting arbitrary
13972 data items. Move and comparison procedures are provided by passing
13973 access-to-procedure values. This is an older version, retained for
13974 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13976 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13977 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13978 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13980 @cindex Bubble sort
13983 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13984 are provided as generic parameters, this improves efficiency, especially
13985 if the procedures can be inlined, at the expense of duplicating code for
13986 multiple instantiations.
13988 @node GNAT.Byte_Order_Mark (g-byorma.ads)
13989 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13990 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13991 @cindex UTF-8 representation
13992 @cindex Wide characte representations
13995 Provides a routine which given a string, reads the start of the string to
13996 see whether it is one of the standard byte order marks (BOM's) which signal
13997 the encoding of the string. The routine includes detection of special XML
13998 sequences for various UCS input formats.
14000 @node GNAT.Byte_Swapping (g-bytswa.ads)
14001 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14002 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14003 @cindex Byte swapping
14007 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
14008 Machine-specific implementations are available in some cases.
14010 @node GNAT.Calendar (g-calend.ads)
14011 @section @code{GNAT.Calendar} (@file{g-calend.ads})
14012 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
14013 @cindex @code{Calendar}
14016 Extends the facilities provided by @code{Ada.Calendar} to include handling
14017 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
14018 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
14019 C @code{timeval} format.
14021 @node GNAT.Calendar.Time_IO (g-catiio.ads)
14022 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14023 @cindex @code{Calendar}
14025 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14027 @node GNAT.CRC32 (g-crc32.ads)
14028 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
14029 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
14031 @cindex Cyclic Redundancy Check
14034 This package implements the CRC-32 algorithm. For a full description
14035 of this algorithm see
14036 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
14037 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
14038 Aug.@: 1988. Sarwate, D.V@.
14040 @node GNAT.Case_Util (g-casuti.ads)
14041 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
14042 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
14043 @cindex Casing utilities
14044 @cindex Character handling (@code{GNAT.Case_Util})
14047 A set of simple routines for handling upper and lower casing of strings
14048 without the overhead of the full casing tables
14049 in @code{Ada.Characters.Handling}.
14051 @node GNAT.CGI (g-cgi.ads)
14052 @section @code{GNAT.CGI} (@file{g-cgi.ads})
14053 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
14054 @cindex CGI (Common Gateway Interface)
14057 This is a package for interfacing a GNAT program with a Web server via the
14058 Common Gateway Interface (CGI)@. Basically this package parses the CGI
14059 parameters, which are a set of key/value pairs sent by the Web server. It
14060 builds a table whose index is the key and provides some services to deal
14063 @node GNAT.CGI.Cookie (g-cgicoo.ads)
14064 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14065 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14066 @cindex CGI (Common Gateway Interface) cookie support
14067 @cindex Cookie support in CGI
14070 This is a package to interface a GNAT program with a Web server via the
14071 Common Gateway Interface (CGI). It exports services to deal with Web
14072 cookies (piece of information kept in the Web client software).
14074 @node GNAT.CGI.Debug (g-cgideb.ads)
14075 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14076 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14077 @cindex CGI (Common Gateway Interface) debugging
14080 This is a package to help debugging CGI (Common Gateway Interface)
14081 programs written in Ada.
14083 @node GNAT.Command_Line (g-comlin.ads)
14084 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14085 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14086 @cindex Command line
14089 Provides a high level interface to @code{Ada.Command_Line} facilities,
14090 including the ability to scan for named switches with optional parameters
14091 and expand file names using wild card notations.
14093 @node GNAT.Compiler_Version (g-comver.ads)
14094 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14095 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14096 @cindex Compiler Version
14097 @cindex Version, of compiler
14100 Provides a routine for obtaining the version of the compiler used to
14101 compile the program. More accurately this is the version of the binder
14102 used to bind the program (this will normally be the same as the version
14103 of the compiler if a consistent tool set is used to compile all units
14106 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14107 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14108 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14112 Provides a simple interface to handle Ctrl-C keyboard events.
14114 @node GNAT.Current_Exception (g-curexc.ads)
14115 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14116 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14117 @cindex Current exception
14118 @cindex Exception retrieval
14121 Provides access to information on the current exception that has been raised
14122 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14123 specification syntax.
14124 This is particularly useful in simulating typical facilities for
14125 obtaining information about exceptions provided by Ada 83 compilers.
14127 @node GNAT.Debug_Pools (g-debpoo.ads)
14128 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14129 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14131 @cindex Debug pools
14132 @cindex Memory corruption debugging
14135 Provide a debugging storage pools that helps tracking memory corruption
14136 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14137 @value{EDITION} User's Guide}.
14139 @node GNAT.Debug_Utilities (g-debuti.ads)
14140 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14141 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14145 Provides a few useful utilities for debugging purposes, including conversion
14146 to and from string images of address values. Supports both C and Ada formats
14147 for hexadecimal literals.
14149 @node GNAT.Decode_String (g-decstr.ads)
14150 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14151 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14152 @cindex Decoding strings
14153 @cindex String decoding
14154 @cindex Wide character encoding
14159 A generic package providing routines for decoding wide character and wide wide
14160 character strings encoded as sequences of 8-bit characters using a specified
14161 encoding method. Includes validation routines, and also routines for stepping
14162 to next or previous encoded character in an encoded string.
14163 Useful in conjunction with Unicode character coding. Note there is a
14164 preinstantiation for UTF-8. See next entry.
14166 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14167 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14168 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14169 @cindex Decoding strings
14170 @cindex Decoding UTF-8 strings
14171 @cindex UTF-8 string decoding
14172 @cindex Wide character decoding
14177 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14179 @node GNAT.Directory_Operations (g-dirope.ads)
14180 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14181 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14182 @cindex Directory operations
14185 Provides a set of routines for manipulating directories, including changing
14186 the current directory, making new directories, and scanning the files in a
14189 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14190 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14191 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14192 @cindex Directory operations iteration
14195 A child unit of GNAT.Directory_Operations providing additional operations
14196 for iterating through directories.
14198 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14199 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14200 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14201 @cindex Hash tables
14204 A generic implementation of hash tables that can be used to hash arbitrary
14205 data. Provided in two forms, a simple form with built in hash functions,
14206 and a more complex form in which the hash function is supplied.
14209 This package provides a facility similar to that of @code{GNAT.HTable},
14210 except that this package declares a type that can be used to define
14211 dynamic instances of the hash table, while an instantiation of
14212 @code{GNAT.HTable} creates a single instance of the hash table.
14214 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14215 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14216 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14217 @cindex Table implementation
14218 @cindex Arrays, extendable
14221 A generic package providing a single dimension array abstraction where the
14222 length of the array can be dynamically modified.
14225 This package provides a facility similar to that of @code{GNAT.Table},
14226 except that this package declares a type that can be used to define
14227 dynamic instances of the table, while an instantiation of
14228 @code{GNAT.Table} creates a single instance of the table type.
14230 @node GNAT.Encode_String (g-encstr.ads)
14231 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14232 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14233 @cindex Encoding strings
14234 @cindex String encoding
14235 @cindex Wide character encoding
14240 A generic package providing routines for encoding wide character and wide
14241 wide character strings as sequences of 8-bit characters using a specified
14242 encoding method. Useful in conjunction with Unicode character coding.
14243 Note there is a preinstantiation for UTF-8. See next entry.
14245 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14246 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14247 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14248 @cindex Encoding strings
14249 @cindex Encoding UTF-8 strings
14250 @cindex UTF-8 string encoding
14251 @cindex Wide character encoding
14256 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14258 @node GNAT.Exception_Actions (g-excact.ads)
14259 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14260 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14261 @cindex Exception actions
14264 Provides callbacks when an exception is raised. Callbacks can be registered
14265 for specific exceptions, or when any exception is raised. This
14266 can be used for instance to force a core dump to ease debugging.
14268 @node GNAT.Exception_Traces (g-exctra.ads)
14269 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14270 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14271 @cindex Exception traces
14275 Provides an interface allowing to control automatic output upon exception
14278 @node GNAT.Exceptions (g-except.ads)
14279 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14280 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14281 @cindex Exceptions, Pure
14282 @cindex Pure packages, exceptions
14285 Normally it is not possible to raise an exception with
14286 a message from a subprogram in a pure package, since the
14287 necessary types and subprograms are in @code{Ada.Exceptions}
14288 which is not a pure unit. @code{GNAT.Exceptions} provides a
14289 facility for getting around this limitation for a few
14290 predefined exceptions, and for example allow raising
14291 @code{Constraint_Error} with a message from a pure subprogram.
14293 @node GNAT.Expect (g-expect.ads)
14294 @section @code{GNAT.Expect} (@file{g-expect.ads})
14295 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14298 Provides a set of subprograms similar to what is available
14299 with the standard Tcl Expect tool.
14300 It allows you to easily spawn and communicate with an external process.
14301 You can send commands or inputs to the process, and compare the output
14302 with some expected regular expression. Currently @code{GNAT.Expect}
14303 is implemented on all native GNAT ports except for OpenVMS@.
14304 It is not implemented for cross ports, and in particular is not
14305 implemented for VxWorks or LynxOS@.
14307 @node GNAT.Float_Control (g-flocon.ads)
14308 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14309 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14310 @cindex Floating-Point Processor
14313 Provides an interface for resetting the floating-point processor into the
14314 mode required for correct semantic operation in Ada. Some third party
14315 library calls may cause this mode to be modified, and the Reset procedure
14316 in this package can be used to reestablish the required mode.
14318 @node GNAT.Heap_Sort (g-heasor.ads)
14319 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14320 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14324 Provides a general implementation of heap sort usable for sorting arbitrary
14325 data items. Exchange and comparison procedures are provided by passing
14326 access-to-procedure values. The algorithm used is a modified heap sort
14327 that performs approximately N*log(N) comparisons in the worst case.
14329 @node GNAT.Heap_Sort_A (g-hesora.ads)
14330 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14331 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14335 Provides a general implementation of heap sort usable for sorting arbitrary
14336 data items. Move and comparison procedures are provided by passing
14337 access-to-procedure values. The algorithm used is a modified heap sort
14338 that performs approximately N*log(N) comparisons in the worst case.
14339 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14340 interface, but may be slightly more efficient.
14342 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14343 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14344 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14348 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14349 are provided as generic parameters, this improves efficiency, especially
14350 if the procedures can be inlined, at the expense of duplicating code for
14351 multiple instantiations.
14353 @node GNAT.HTable (g-htable.ads)
14354 @section @code{GNAT.HTable} (@file{g-htable.ads})
14355 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14356 @cindex Hash tables
14359 A generic implementation of hash tables that can be used to hash arbitrary
14360 data. Provides two approaches, one a simple static approach, and the other
14361 allowing arbitrary dynamic hash tables.
14363 @node GNAT.IO (g-io.ads)
14364 @section @code{GNAT.IO} (@file{g-io.ads})
14365 @cindex @code{GNAT.IO} (@file{g-io.ads})
14367 @cindex Input/Output facilities
14370 A simple preelaborable input-output package that provides a subset of
14371 simple Text_IO functions for reading characters and strings from
14372 Standard_Input, and writing characters, strings and integers to either
14373 Standard_Output or Standard_Error.
14375 @node GNAT.IO_Aux (g-io_aux.ads)
14376 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14377 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14379 @cindex Input/Output facilities
14381 Provides some auxiliary functions for use with Text_IO, including a test
14382 for whether a file exists, and functions for reading a line of text.
14384 @node GNAT.Lock_Files (g-locfil.ads)
14385 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14386 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14387 @cindex File locking
14388 @cindex Locking using files
14391 Provides a general interface for using files as locks. Can be used for
14392 providing program level synchronization.
14394 @node GNAT.MD5 (g-md5.ads)
14395 @section @code{GNAT.MD5} (@file{g-md5.ads})
14396 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14397 @cindex Message Digest MD5
14400 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14402 @node GNAT.Memory_Dump (g-memdum.ads)
14403 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14404 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14405 @cindex Dump Memory
14408 Provides a convenient routine for dumping raw memory to either the
14409 standard output or standard error files. Uses GNAT.IO for actual
14412 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14413 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14414 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14415 @cindex Exception, obtaining most recent
14418 Provides access to the most recently raised exception. Can be used for
14419 various logging purposes, including duplicating functionality of some
14420 Ada 83 implementation dependent extensions.
14422 @node GNAT.OS_Lib (g-os_lib.ads)
14423 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14424 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14425 @cindex Operating System interface
14426 @cindex Spawn capability
14429 Provides a range of target independent operating system interface functions,
14430 including time/date management, file operations, subprocess management,
14431 including a portable spawn procedure, and access to environment variables
14432 and error return codes.
14434 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14435 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14436 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14437 @cindex Hash functions
14440 Provides a generator of static minimal perfect hash functions. No
14441 collisions occur and each item can be retrieved from the table in one
14442 probe (perfect property). The hash table size corresponds to the exact
14443 size of the key set and no larger (minimal property). The key set has to
14444 be know in advance (static property). The hash functions are also order
14445 preserving. If w2 is inserted after w1 in the generator, their
14446 hashcode are in the same order. These hashing functions are very
14447 convenient for use with realtime applications.
14449 @node GNAT.Random_Numbers (g-rannum.ads)
14450 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14451 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14452 @cindex Random number generation
14455 Provides random number capabilities which extend those available in the
14456 standard Ada library and are more convenient to use.
14458 @node GNAT.Regexp (g-regexp.ads)
14459 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14460 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14461 @cindex Regular expressions
14462 @cindex Pattern matching
14465 A simple implementation of regular expressions, using a subset of regular
14466 expression syntax copied from familiar Unix style utilities. This is the
14467 simples of the three pattern matching packages provided, and is particularly
14468 suitable for ``file globbing'' applications.
14470 @node GNAT.Registry (g-regist.ads)
14471 @section @code{GNAT.Registry} (@file{g-regist.ads})
14472 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14473 @cindex Windows Registry
14476 This is a high level binding to the Windows registry. It is possible to
14477 do simple things like reading a key value, creating a new key. For full
14478 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14479 package provided with the Win32Ada binding
14481 @node GNAT.Regpat (g-regpat.ads)
14482 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14483 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14484 @cindex Regular expressions
14485 @cindex Pattern matching
14488 A complete implementation of Unix-style regular expression matching, copied
14489 from the original V7 style regular expression library written in C by
14490 Henry Spencer (and binary compatible with this C library).
14492 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14493 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14494 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14495 @cindex Secondary Stack Info
14498 Provide the capability to query the high water mark of the current task's
14501 @node GNAT.Semaphores (g-semaph.ads)
14502 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14503 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14507 Provides classic counting and binary semaphores using protected types.
14509 @node GNAT.Serial_Communications (g-sercom.ads)
14510 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14511 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14512 @cindex Serial_Communications
14515 Provides a simple interface to send and receive data over a serial
14516 port. This is only supported on GNU/Linux and Windows.
14518 @node GNAT.SHA1 (g-sha1.ads)
14519 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14520 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14521 @cindex Secure Hash Algorithm SHA-1
14524 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
14526 @node GNAT.Signals (g-signal.ads)
14527 @section @code{GNAT.Signals} (@file{g-signal.ads})
14528 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14532 Provides the ability to manipulate the blocked status of signals on supported
14535 @node GNAT.Sockets (g-socket.ads)
14536 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14537 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14541 A high level and portable interface to develop sockets based applications.
14542 This package is based on the sockets thin binding found in
14543 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14544 on all native GNAT ports except for OpenVMS@. It is not implemented
14545 for the LynxOS@ cross port.
14547 @node GNAT.Source_Info (g-souinf.ads)
14548 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14549 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14550 @cindex Source Information
14553 Provides subprograms that give access to source code information known at
14554 compile time, such as the current file name and line number.
14556 @node GNAT.Spelling_Checker (g-speche.ads)
14557 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14558 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14559 @cindex Spell checking
14562 Provides a function for determining whether one string is a plausible
14563 near misspelling of another string.
14565 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14566 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14567 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14568 @cindex Spell checking
14571 Provides a generic function that can be instantiated with a string type for
14572 determining whether one string is a plausible near misspelling of another
14575 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14576 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14577 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14578 @cindex SPITBOL pattern matching
14579 @cindex Pattern matching
14582 A complete implementation of SNOBOL4 style pattern matching. This is the
14583 most elaborate of the pattern matching packages provided. It fully duplicates
14584 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14585 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14587 @node GNAT.Spitbol (g-spitbo.ads)
14588 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14589 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14590 @cindex SPITBOL interface
14593 The top level package of the collection of SPITBOL-style functionality, this
14594 package provides basic SNOBOL4 string manipulation functions, such as
14595 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14596 useful for constructing arbitrary mappings from strings in the style of
14597 the SNOBOL4 TABLE function.
14599 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14600 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14601 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14602 @cindex Sets of strings
14603 @cindex SPITBOL Tables
14606 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14607 for type @code{Standard.Boolean}, giving an implementation of sets of
14610 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14611 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14612 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14613 @cindex Integer maps
14615 @cindex SPITBOL Tables
14618 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14619 for type @code{Standard.Integer}, giving an implementation of maps
14620 from string to integer values.
14622 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14623 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14624 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14625 @cindex String maps
14627 @cindex SPITBOL Tables
14630 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14631 a variable length string type, giving an implementation of general
14632 maps from strings to strings.
14634 @node GNAT.SSE (g-sse.ads)
14635 @section @code{GNAT.SSE} (@file{g-sse.ads})
14636 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
14639 Root of a set of units aimed at offering Ada bindings to a subset of
14640 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
14641 targets. It exposes vector component types together with a general
14642 introduction to the binding contents and use.
14644 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
14645 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
14646 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
14649 SSE vector types for use with SSE related intrinsics.
14651 @node GNAT.Strings (g-string.ads)
14652 @section @code{GNAT.Strings} (@file{g-string.ads})
14653 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14656 Common String access types and related subprograms. Basically it
14657 defines a string access and an array of string access types.
14659 @node GNAT.String_Split (g-strspl.ads)
14660 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14661 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14662 @cindex String splitter
14665 Useful string manipulation routines: given a set of separators, split
14666 a string wherever the separators appear, and provide direct access
14667 to the resulting slices. This package is instantiated from
14668 @code{GNAT.Array_Split}.
14670 @node GNAT.Table (g-table.ads)
14671 @section @code{GNAT.Table} (@file{g-table.ads})
14672 @cindex @code{GNAT.Table} (@file{g-table.ads})
14673 @cindex Table implementation
14674 @cindex Arrays, extendable
14677 A generic package providing a single dimension array abstraction where the
14678 length of the array can be dynamically modified.
14681 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14682 except that this package declares a single instance of the table type,
14683 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14684 used to define dynamic instances of the table.
14686 @node GNAT.Task_Lock (g-tasloc.ads)
14687 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14688 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14689 @cindex Task synchronization
14690 @cindex Task locking
14694 A very simple facility for locking and unlocking sections of code using a
14695 single global task lock. Appropriate for use in situations where contention
14696 between tasks is very rarely expected.
14698 @node GNAT.Time_Stamp (g-timsta.ads)
14699 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14700 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14702 @cindex Current time
14705 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14706 represents the current date and time in ISO 8601 format. This is a very simple
14707 routine with minimal code and there are no dependencies on any other unit.
14709 @node GNAT.Threads (g-thread.ads)
14710 @section @code{GNAT.Threads} (@file{g-thread.ads})
14711 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14712 @cindex Foreign threads
14713 @cindex Threads, foreign
14716 Provides facilities for dealing with foreign threads which need to be known
14717 by the GNAT run-time system. Consult the documentation of this package for
14718 further details if your program has threads that are created by a non-Ada
14719 environment which then accesses Ada code.
14721 @node GNAT.Traceback (g-traceb.ads)
14722 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14723 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14724 @cindex Trace back facilities
14727 Provides a facility for obtaining non-symbolic traceback information, useful
14728 in various debugging situations.
14730 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14731 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14732 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14733 @cindex Trace back facilities
14735 @node GNAT.UTF_32 (g-utf_32.ads)
14736 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14737 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14738 @cindex Wide character codes
14741 This is a package intended to be used in conjunction with the
14742 @code{Wide_Character} type in Ada 95 and the
14743 @code{Wide_Wide_Character} type in Ada 2005 (available
14744 in @code{GNAT} in Ada 2005 mode). This package contains
14745 Unicode categorization routines, as well as lexical
14746 categorization routines corresponding to the Ada 2005
14747 lexical rules for identifiers and strings, and also a
14748 lower case to upper case fold routine corresponding to
14749 the Ada 2005 rules for identifier equivalence.
14751 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14752 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14753 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14754 @cindex Spell checking
14757 Provides a function for determining whether one wide wide string is a plausible
14758 near misspelling of another wide wide string, where the strings are represented
14759 using the UTF_32_String type defined in System.Wch_Cnv.
14761 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14762 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14763 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14764 @cindex Spell checking
14767 Provides a function for determining whether one wide string is a plausible
14768 near misspelling of another wide string.
14770 @node GNAT.Wide_String_Split (g-wistsp.ads)
14771 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14772 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14773 @cindex Wide_String splitter
14776 Useful wide string manipulation routines: given a set of separators, split
14777 a wide string wherever the separators appear, and provide direct access
14778 to the resulting slices. This package is instantiated from
14779 @code{GNAT.Array_Split}.
14781 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14782 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14783 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14784 @cindex Spell checking
14787 Provides a function for determining whether one wide wide string is a plausible
14788 near misspelling of another wide wide string.
14790 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14791 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14792 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14793 @cindex Wide_Wide_String splitter
14796 Useful wide wide string manipulation routines: given a set of separators, split
14797 a wide wide string wherever the separators appear, and provide direct access
14798 to the resulting slices. This package is instantiated from
14799 @code{GNAT.Array_Split}.
14801 @node Interfaces.C.Extensions (i-cexten.ads)
14802 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14803 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14806 This package contains additional C-related definitions, intended
14807 for use with either manually or automatically generated bindings
14810 @node Interfaces.C.Streams (i-cstrea.ads)
14811 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14812 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14813 @cindex C streams, interfacing
14816 This package is a binding for the most commonly used operations
14819 @node Interfaces.CPP (i-cpp.ads)
14820 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
14821 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14822 @cindex C++ interfacing
14823 @cindex Interfacing, to C++
14826 This package provides facilities for use in interfacing to C++. It
14827 is primarily intended to be used in connection with automated tools
14828 for the generation of C++ interfaces.
14830 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14831 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14832 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14833 @cindex IBM Packed Format
14834 @cindex Packed Decimal
14837 This package provides a set of routines for conversions to and
14838 from a packed decimal format compatible with that used on IBM
14841 @node Interfaces.VxWorks (i-vxwork.ads)
14842 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14843 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14844 @cindex Interfacing to VxWorks
14845 @cindex VxWorks, interfacing
14848 This package provides a limited binding to the VxWorks API.
14849 In particular, it interfaces with the
14850 VxWorks hardware interrupt facilities.
14852 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14853 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14854 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14855 @cindex Interfacing to VxWorks' I/O
14856 @cindex VxWorks, I/O interfacing
14857 @cindex VxWorks, Get_Immediate
14858 @cindex Get_Immediate, VxWorks
14861 This package provides a binding to the ioctl (IO/Control)
14862 function of VxWorks, defining a set of option values and
14863 function codes. A particular use of this package is
14864 to enable the use of Get_Immediate under VxWorks.
14866 @node System.Address_Image (s-addima.ads)
14867 @section @code{System.Address_Image} (@file{s-addima.ads})
14868 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14869 @cindex Address image
14870 @cindex Image, of an address
14873 This function provides a useful debugging
14874 function that gives an (implementation dependent)
14875 string which identifies an address.
14877 @node System.Assertions (s-assert.ads)
14878 @section @code{System.Assertions} (@file{s-assert.ads})
14879 @cindex @code{System.Assertions} (@file{s-assert.ads})
14881 @cindex Assert_Failure, exception
14884 This package provides the declaration of the exception raised
14885 by an run-time assertion failure, as well as the routine that
14886 is used internally to raise this assertion.
14888 @node System.Memory (s-memory.ads)
14889 @section @code{System.Memory} (@file{s-memory.ads})
14890 @cindex @code{System.Memory} (@file{s-memory.ads})
14891 @cindex Memory allocation
14894 This package provides the interface to the low level routines used
14895 by the generated code for allocation and freeing storage for the
14896 default storage pool (analogous to the C routines malloc and free.
14897 It also provides a reallocation interface analogous to the C routine
14898 realloc. The body of this unit may be modified to provide alternative
14899 allocation mechanisms for the default pool, and in addition, direct
14900 calls to this unit may be made for low level allocation uses (for
14901 example see the body of @code{GNAT.Tables}).
14903 @node System.Partition_Interface (s-parint.ads)
14904 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14905 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14906 @cindex Partition interfacing functions
14909 This package provides facilities for partition interfacing. It
14910 is used primarily in a distribution context when using Annex E
14913 @node System.Pool_Global (s-pooglo.ads)
14914 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
14915 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
14916 @cindex Storage pool, global
14917 @cindex Global storage pool
14920 This package provides a storage pool that is equivalent to the default
14921 storage pool used for access types for which no pool is specifically
14922 declared. It uses malloc/free to allocate/free and does not attempt to
14923 do any automatic reclamation.
14925 @node System.Pool_Local (s-pooloc.ads)
14926 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
14927 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
14928 @cindex Storage pool, local
14929 @cindex Local storage pool
14932 This package provides a storage pool that is intended for use with locally
14933 defined access types. It uses malloc/free for allocate/free, and maintains
14934 a list of allocated blocks, so that all storage allocated for the pool can
14935 be freed automatically when the pool is finalized.
14937 @node System.Restrictions (s-restri.ads)
14938 @section @code{System.Restrictions} (@file{s-restri.ads})
14939 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14940 @cindex Run-time restrictions access
14943 This package provides facilities for accessing at run time
14944 the status of restrictions specified at compile time for
14945 the partition. Information is available both with regard
14946 to actual restrictions specified, and with regard to
14947 compiler determined information on which restrictions
14948 are violated by one or more packages in the partition.
14950 @node System.Rident (s-rident.ads)
14951 @section @code{System.Rident} (@file{s-rident.ads})
14952 @cindex @code{System.Rident} (@file{s-rident.ads})
14953 @cindex Restrictions definitions
14956 This package provides definitions of the restrictions
14957 identifiers supported by GNAT, and also the format of
14958 the restrictions provided in package System.Restrictions.
14959 It is not normally necessary to @code{with} this generic package
14960 since the necessary instantiation is included in
14961 package System.Restrictions.
14963 @node System.Strings.Stream_Ops (s-ststop.ads)
14964 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
14965 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
14966 @cindex Stream operations
14967 @cindex String stream operations
14970 This package provides a set of stream subprograms for standard string types.
14971 It is intended primarily to support implicit use of such subprograms when
14972 stream attributes are applied to string types, but the subprograms in this
14973 package can be used directly by application programs.
14975 @node System.Task_Info (s-tasinf.ads)
14976 @section @code{System.Task_Info} (@file{s-tasinf.ads})
14977 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
14978 @cindex Task_Info pragma
14981 This package provides target dependent functionality that is used
14982 to support the @code{Task_Info} pragma
14984 @node System.Wch_Cnv (s-wchcnv.ads)
14985 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14986 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14987 @cindex Wide Character, Representation
14988 @cindex Wide String, Conversion
14989 @cindex Representation of wide characters
14992 This package provides routines for converting between
14993 wide and wide wide characters and a representation as a value of type
14994 @code{Standard.String}, using a specified wide character
14995 encoding method. It uses definitions in
14996 package @code{System.Wch_Con}.
14998 @node System.Wch_Con (s-wchcon.ads)
14999 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
15000 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
15003 This package provides definitions and descriptions of
15004 the various methods used for encoding wide characters
15005 in ordinary strings. These definitions are used by
15006 the package @code{System.Wch_Cnv}.
15008 @node Interfacing to Other Languages
15009 @chapter Interfacing to Other Languages
15011 The facilities in annex B of the Ada Reference Manual are fully
15012 implemented in GNAT, and in addition, a full interface to C++ is
15016 * Interfacing to C::
15017 * Interfacing to C++::
15018 * Interfacing to COBOL::
15019 * Interfacing to Fortran::
15020 * Interfacing to non-GNAT Ada code::
15023 @node Interfacing to C
15024 @section Interfacing to C
15027 Interfacing to C with GNAT can use one of two approaches:
15031 The types in the package @code{Interfaces.C} may be used.
15033 Standard Ada types may be used directly. This may be less portable to
15034 other compilers, but will work on all GNAT compilers, which guarantee
15035 correspondence between the C and Ada types.
15039 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
15040 effect, since this is the default. The following table shows the
15041 correspondence between Ada scalar types and the corresponding C types.
15046 @item Short_Integer
15048 @item Short_Short_Integer
15052 @item Long_Long_Integer
15060 @item Long_Long_Float
15061 This is the longest floating-point type supported by the hardware.
15065 Additionally, there are the following general correspondences between Ada
15069 Ada enumeration types map to C enumeration types directly if pragma
15070 @code{Convention C} is specified, which causes them to have int
15071 length. Without pragma @code{Convention C}, Ada enumeration types map to
15072 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
15073 @code{int}, respectively) depending on the number of values passed.
15074 This is the only case in which pragma @code{Convention C} affects the
15075 representation of an Ada type.
15078 Ada access types map to C pointers, except for the case of pointers to
15079 unconstrained types in Ada, which have no direct C equivalent.
15082 Ada arrays map directly to C arrays.
15085 Ada records map directly to C structures.
15088 Packed Ada records map to C structures where all members are bit fields
15089 of the length corresponding to the @code{@var{type}'Size} value in Ada.
15092 @node Interfacing to C++
15093 @section Interfacing to C++
15096 The interface to C++ makes use of the following pragmas, which are
15097 primarily intended to be constructed automatically using a binding generator
15098 tool, although it is possible to construct them by hand. No suitable binding
15099 generator tool is supplied with GNAT though.
15101 Using these pragmas it is possible to achieve complete
15102 inter-operability between Ada tagged types and C++ class definitions.
15103 See @ref{Implementation Defined Pragmas}, for more details.
15106 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15107 The argument denotes an entity in the current declarative region that is
15108 declared as a tagged or untagged record type. It indicates that the type
15109 corresponds to an externally declared C++ class type, and is to be laid
15110 out the same way that C++ would lay out the type.
15112 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15113 for backward compatibility but its functionality is available
15114 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15116 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15117 This pragma identifies an imported function (imported in the usual way
15118 with pragma @code{Import}) as corresponding to a C++ constructor.
15121 @node Interfacing to COBOL
15122 @section Interfacing to COBOL
15125 Interfacing to COBOL is achieved as described in section B.4 of
15126 the Ada Reference Manual.
15128 @node Interfacing to Fortran
15129 @section Interfacing to Fortran
15132 Interfacing to Fortran is achieved as described in section B.5 of the
15133 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
15134 multi-dimensional array causes the array to be stored in column-major
15135 order as required for convenient interface to Fortran.
15137 @node Interfacing to non-GNAT Ada code
15138 @section Interfacing to non-GNAT Ada code
15140 It is possible to specify the convention @code{Ada} in a pragma
15141 @code{Import} or pragma @code{Export}. However this refers to
15142 the calling conventions used by GNAT, which may or may not be
15143 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15144 compiler to allow interoperation.
15146 If arguments types are kept simple, and if the foreign compiler generally
15147 follows system calling conventions, then it may be possible to integrate
15148 files compiled by other Ada compilers, provided that the elaboration
15149 issues are adequately addressed (for example by eliminating the
15150 need for any load time elaboration).
15152 In particular, GNAT running on VMS is designed to
15153 be highly compatible with the DEC Ada 83 compiler, so this is one
15154 case in which it is possible to import foreign units of this type,
15155 provided that the data items passed are restricted to simple scalar
15156 values or simple record types without variants, or simple array
15157 types with fixed bounds.
15159 @node Specialized Needs Annexes
15160 @chapter Specialized Needs Annexes
15163 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15164 required in all implementations. However, as described in this chapter,
15165 GNAT implements all of these annexes:
15168 @item Systems Programming (Annex C)
15169 The Systems Programming Annex is fully implemented.
15171 @item Real-Time Systems (Annex D)
15172 The Real-Time Systems Annex is fully implemented.
15174 @item Distributed Systems (Annex E)
15175 Stub generation is fully implemented in the GNAT compiler. In addition,
15176 a complete compatible PCS is available as part of the GLADE system,
15177 a separate product. When the two
15178 products are used in conjunction, this annex is fully implemented.
15180 @item Information Systems (Annex F)
15181 The Information Systems annex is fully implemented.
15183 @item Numerics (Annex G)
15184 The Numerics Annex is fully implemented.
15186 @item Safety and Security / High-Integrity Systems (Annex H)
15187 The Safety and Security Annex (termed the High-Integrity Systems Annex
15188 in Ada 2005) is fully implemented.
15191 @node Implementation of Specific Ada Features
15192 @chapter Implementation of Specific Ada Features
15195 This chapter describes the GNAT implementation of several Ada language
15199 * Machine Code Insertions::
15200 * GNAT Implementation of Tasking::
15201 * GNAT Implementation of Shared Passive Packages::
15202 * Code Generation for Array Aggregates::
15203 * The Size of Discriminated Records with Default Discriminants::
15204 * Strict Conformance to the Ada Reference Manual::
15207 @node Machine Code Insertions
15208 @section Machine Code Insertions
15209 @cindex Machine Code insertions
15212 Package @code{Machine_Code} provides machine code support as described
15213 in the Ada Reference Manual in two separate forms:
15216 Machine code statements, consisting of qualified expressions that
15217 fit the requirements of RM section 13.8.
15219 An intrinsic callable procedure, providing an alternative mechanism of
15220 including machine instructions in a subprogram.
15224 The two features are similar, and both are closely related to the mechanism
15225 provided by the asm instruction in the GNU C compiler. Full understanding
15226 and use of the facilities in this package requires understanding the asm
15227 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15228 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15230 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15231 semantic restrictions and effects as described below. Both are provided so
15232 that the procedure call can be used as a statement, and the function call
15233 can be used to form a code_statement.
15235 The first example given in the GCC documentation is the C @code{asm}
15238 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15242 The equivalent can be written for GNAT as:
15244 @smallexample @c ada
15245 Asm ("fsinx %1 %0",
15246 My_Float'Asm_Output ("=f", result),
15247 My_Float'Asm_Input ("f", angle));
15251 The first argument to @code{Asm} is the assembler template, and is
15252 identical to what is used in GNU C@. This string must be a static
15253 expression. The second argument is the output operand list. It is
15254 either a single @code{Asm_Output} attribute reference, or a list of such
15255 references enclosed in parentheses (technically an array aggregate of
15258 The @code{Asm_Output} attribute denotes a function that takes two
15259 parameters. The first is a string, the second is the name of a variable
15260 of the type designated by the attribute prefix. The first (string)
15261 argument is required to be a static expression and designates the
15262 constraint for the parameter (e.g.@: what kind of register is
15263 required). The second argument is the variable to be updated with the
15264 result. The possible values for constraint are the same as those used in
15265 the RTL, and are dependent on the configuration file used to build the
15266 GCC back end. If there are no output operands, then this argument may
15267 either be omitted, or explicitly given as @code{No_Output_Operands}.
15269 The second argument of @code{@var{my_float}'Asm_Output} functions as
15270 though it were an @code{out} parameter, which is a little curious, but
15271 all names have the form of expressions, so there is no syntactic
15272 irregularity, even though normally functions would not be permitted
15273 @code{out} parameters. The third argument is the list of input
15274 operands. It is either a single @code{Asm_Input} attribute reference, or
15275 a list of such references enclosed in parentheses (technically an array
15276 aggregate of such references).
15278 The @code{Asm_Input} attribute denotes a function that takes two
15279 parameters. The first is a string, the second is an expression of the
15280 type designated by the prefix. The first (string) argument is required
15281 to be a static expression, and is the constraint for the parameter,
15282 (e.g.@: what kind of register is required). The second argument is the
15283 value to be used as the input argument. The possible values for the
15284 constant are the same as those used in the RTL, and are dependent on
15285 the configuration file used to built the GCC back end.
15287 If there are no input operands, this argument may either be omitted, or
15288 explicitly given as @code{No_Input_Operands}. The fourth argument, not
15289 present in the above example, is a list of register names, called the
15290 @dfn{clobber} argument. This argument, if given, must be a static string
15291 expression, and is a space or comma separated list of names of registers
15292 that must be considered destroyed as a result of the @code{Asm} call. If
15293 this argument is the null string (the default value), then the code
15294 generator assumes that no additional registers are destroyed.
15296 The fifth argument, not present in the above example, called the
15297 @dfn{volatile} argument, is by default @code{False}. It can be set to
15298 the literal value @code{True} to indicate to the code generator that all
15299 optimizations with respect to the instruction specified should be
15300 suppressed, and that in particular, for an instruction that has outputs,
15301 the instruction will still be generated, even if none of the outputs are
15302 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15303 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15304 Generally it is strongly advisable to use Volatile for any ASM statement
15305 that is missing either input or output operands, or when two or more ASM
15306 statements appear in sequence, to avoid unwanted optimizations. A warning
15307 is generated if this advice is not followed.
15309 The @code{Asm} subprograms may be used in two ways. First the procedure
15310 forms can be used anywhere a procedure call would be valid, and
15311 correspond to what the RM calls ``intrinsic'' routines. Such calls can
15312 be used to intersperse machine instructions with other Ada statements.
15313 Second, the function forms, which return a dummy value of the limited
15314 private type @code{Asm_Insn}, can be used in code statements, and indeed
15315 this is the only context where such calls are allowed. Code statements
15316 appear as aggregates of the form:
15318 @smallexample @c ada
15319 Asm_Insn'(Asm (@dots{}));
15320 Asm_Insn'(Asm_Volatile (@dots{}));
15324 In accordance with RM rules, such code statements are allowed only
15325 within subprograms whose entire body consists of such statements. It is
15326 not permissible to intermix such statements with other Ada statements.
15328 Typically the form using intrinsic procedure calls is more convenient
15329 and more flexible. The code statement form is provided to meet the RM
15330 suggestion that such a facility should be made available. The following
15331 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15332 is used, the arguments may be given in arbitrary order, following the
15333 normal rules for use of positional and named arguments)
15337 [Template =>] static_string_EXPRESSION
15338 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
15339 [,[Inputs =>] INPUT_OPERAND_LIST ]
15340 [,[Clobber =>] static_string_EXPRESSION ]
15341 [,[Volatile =>] static_boolean_EXPRESSION] )
15343 OUTPUT_OPERAND_LIST ::=
15344 [PREFIX.]No_Output_Operands
15345 | OUTPUT_OPERAND_ATTRIBUTE
15346 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15348 OUTPUT_OPERAND_ATTRIBUTE ::=
15349 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15351 INPUT_OPERAND_LIST ::=
15352 [PREFIX.]No_Input_Operands
15353 | INPUT_OPERAND_ATTRIBUTE
15354 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15356 INPUT_OPERAND_ATTRIBUTE ::=
15357 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15361 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15362 are declared in the package @code{Machine_Code} and must be referenced
15363 according to normal visibility rules. In particular if there is no
15364 @code{use} clause for this package, then appropriate package name
15365 qualification is required.
15367 @node GNAT Implementation of Tasking
15368 @section GNAT Implementation of Tasking
15371 This chapter outlines the basic GNAT approach to tasking (in particular,
15372 a multi-layered library for portability) and discusses issues related
15373 to compliance with the Real-Time Systems Annex.
15376 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15377 * Ensuring Compliance with the Real-Time Annex::
15380 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15381 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15384 GNAT's run-time support comprises two layers:
15387 @item GNARL (GNAT Run-time Layer)
15388 @item GNULL (GNAT Low-level Library)
15392 In GNAT, Ada's tasking services rely on a platform and OS independent
15393 layer known as GNARL@. This code is responsible for implementing the
15394 correct semantics of Ada's task creation, rendezvous, protected
15397 GNARL decomposes Ada's tasking semantics into simpler lower level
15398 operations such as create a thread, set the priority of a thread,
15399 yield, create a lock, lock/unlock, etc. The spec for these low-level
15400 operations constitutes GNULLI, the GNULL Interface. This interface is
15401 directly inspired from the POSIX real-time API@.
15403 If the underlying executive or OS implements the POSIX standard
15404 faithfully, the GNULL Interface maps as is to the services offered by
15405 the underlying kernel. Otherwise, some target dependent glue code maps
15406 the services offered by the underlying kernel to the semantics expected
15409 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
15410 key point is that each Ada task is mapped on a thread in the underlying
15411 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
15413 In addition Ada task priorities map onto the underlying thread priorities.
15414 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15418 The underlying scheduler is used to schedule the Ada tasks. This
15419 makes Ada tasks as efficient as kernel threads from a scheduling
15423 Interaction with code written in C containing threads is eased
15424 since at the lowest level Ada tasks and C threads map onto the same
15425 underlying kernel concept.
15428 When an Ada task is blocked during I/O the remaining Ada tasks are
15432 On multiprocessor systems Ada tasks can execute in parallel.
15436 Some threads libraries offer a mechanism to fork a new process, with the
15437 child process duplicating the threads from the parent.
15439 support this functionality when the parent contains more than one task.
15440 @cindex Forking a new process
15442 @node Ensuring Compliance with the Real-Time Annex
15443 @subsection Ensuring Compliance with the Real-Time Annex
15444 @cindex Real-Time Systems Annex compliance
15447 Although mapping Ada tasks onto
15448 the underlying threads has significant advantages, it does create some
15449 complications when it comes to respecting the scheduling semantics
15450 specified in the real-time annex (Annex D).
15452 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15453 scheduling policy states:
15456 @emph{When the active priority of a ready task that is not running
15457 changes, or the setting of its base priority takes effect, the
15458 task is removed from the ready queue for its old active priority
15459 and is added at the tail of the ready queue for its new active
15460 priority, except in the case where the active priority is lowered
15461 due to the loss of inherited priority, in which case the task is
15462 added at the head of the ready queue for its new active priority.}
15466 While most kernels do put tasks at the end of the priority queue when
15467 a task changes its priority, (which respects the main
15468 FIFO_Within_Priorities requirement), almost none keep a thread at the
15469 beginning of its priority queue when its priority drops from the loss
15470 of inherited priority.
15472 As a result most vendors have provided incomplete Annex D implementations.
15474 The GNAT run-time, has a nice cooperative solution to this problem
15475 which ensures that accurate FIFO_Within_Priorities semantics are
15478 The principle is as follows. When an Ada task T is about to start
15479 running, it checks whether some other Ada task R with the same
15480 priority as T has been suspended due to the loss of priority
15481 inheritance. If this is the case, T yields and is placed at the end of
15482 its priority queue. When R arrives at the front of the queue it
15485 Note that this simple scheme preserves the relative order of the tasks
15486 that were ready to execute in the priority queue where R has been
15489 @node GNAT Implementation of Shared Passive Packages
15490 @section GNAT Implementation of Shared Passive Packages
15491 @cindex Shared passive packages
15494 GNAT fully implements the pragma @code{Shared_Passive} for
15495 @cindex pragma @code{Shared_Passive}
15496 the purpose of designating shared passive packages.
15497 This allows the use of passive partitions in the
15498 context described in the Ada Reference Manual; i.e., for communication
15499 between separate partitions of a distributed application using the
15500 features in Annex E.
15502 @cindex Distribution Systems Annex
15504 However, the implementation approach used by GNAT provides for more
15505 extensive usage as follows:
15508 @item Communication between separate programs
15510 This allows separate programs to access the data in passive
15511 partitions, using protected objects for synchronization where
15512 needed. The only requirement is that the two programs have a
15513 common shared file system. It is even possible for programs
15514 running on different machines with different architectures
15515 (e.g.@: different endianness) to communicate via the data in
15516 a passive partition.
15518 @item Persistence between program runs
15520 The data in a passive package can persist from one run of a
15521 program to another, so that a later program sees the final
15522 values stored by a previous run of the same program.
15527 The implementation approach used is to store the data in files. A
15528 separate stream file is created for each object in the package, and
15529 an access to an object causes the corresponding file to be read or
15532 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15533 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15534 set to the directory to be used for these files.
15535 The files in this directory
15536 have names that correspond to their fully qualified names. For
15537 example, if we have the package
15539 @smallexample @c ada
15541 pragma Shared_Passive (X);
15548 and the environment variable is set to @code{/stemp/}, then the files created
15549 will have the names:
15557 These files are created when a value is initially written to the object, and
15558 the files are retained until manually deleted. This provides the persistence
15559 semantics. If no file exists, it means that no partition has assigned a value
15560 to the variable; in this case the initial value declared in the package
15561 will be used. This model ensures that there are no issues in synchronizing
15562 the elaboration process, since elaboration of passive packages elaborates the
15563 initial values, but does not create the files.
15565 The files are written using normal @code{Stream_IO} access.
15566 If you want to be able
15567 to communicate between programs or partitions running on different
15568 architectures, then you should use the XDR versions of the stream attribute
15569 routines, since these are architecture independent.
15571 If active synchronization is required for access to the variables in the
15572 shared passive package, then as described in the Ada Reference Manual, the
15573 package may contain protected objects used for this purpose. In this case
15574 a lock file (whose name is @file{___lock} (three underscores)
15575 is created in the shared memory directory.
15576 @cindex @file{___lock} file (for shared passive packages)
15577 This is used to provide the required locking
15578 semantics for proper protected object synchronization.
15580 As of January 2003, GNAT supports shared passive packages on all platforms
15581 except for OpenVMS.
15583 @node Code Generation for Array Aggregates
15584 @section Code Generation for Array Aggregates
15587 * Static constant aggregates with static bounds::
15588 * Constant aggregates with unconstrained nominal types::
15589 * Aggregates with static bounds::
15590 * Aggregates with non-static bounds::
15591 * Aggregates in assignment statements::
15595 Aggregates have a rich syntax and allow the user to specify the values of
15596 complex data structures by means of a single construct. As a result, the
15597 code generated for aggregates can be quite complex and involve loops, case
15598 statements and multiple assignments. In the simplest cases, however, the
15599 compiler will recognize aggregates whose components and constraints are
15600 fully static, and in those cases the compiler will generate little or no
15601 executable code. The following is an outline of the code that GNAT generates
15602 for various aggregate constructs. For further details, you will find it
15603 useful to examine the output produced by the -gnatG flag to see the expanded
15604 source that is input to the code generator. You may also want to examine
15605 the assembly code generated at various levels of optimization.
15607 The code generated for aggregates depends on the context, the component values,
15608 and the type. In the context of an object declaration the code generated is
15609 generally simpler than in the case of an assignment. As a general rule, static
15610 component values and static subtypes also lead to simpler code.
15612 @node Static constant aggregates with static bounds
15613 @subsection Static constant aggregates with static bounds
15616 For the declarations:
15617 @smallexample @c ada
15618 type One_Dim is array (1..10) of integer;
15619 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15623 GNAT generates no executable code: the constant ar0 is placed in static memory.
15624 The same is true for constant aggregates with named associations:
15626 @smallexample @c ada
15627 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15628 Cr3 : constant One_Dim := (others => 7777);
15632 The same is true for multidimensional constant arrays such as:
15634 @smallexample @c ada
15635 type two_dim is array (1..3, 1..3) of integer;
15636 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15640 The same is true for arrays of one-dimensional arrays: the following are
15643 @smallexample @c ada
15644 type ar1b is array (1..3) of boolean;
15645 type ar_ar is array (1..3) of ar1b;
15646 None : constant ar1b := (others => false); -- fully static
15647 None2 : constant ar_ar := (1..3 => None); -- fully static
15651 However, for multidimensional aggregates with named associations, GNAT will
15652 generate assignments and loops, even if all associations are static. The
15653 following two declarations generate a loop for the first dimension, and
15654 individual component assignments for the second dimension:
15656 @smallexample @c ada
15657 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15658 Zero2: constant two_dim := (others => (others => 0));
15661 @node Constant aggregates with unconstrained nominal types
15662 @subsection Constant aggregates with unconstrained nominal types
15665 In such cases the aggregate itself establishes the subtype, so that
15666 associations with @code{others} cannot be used. GNAT determines the
15667 bounds for the actual subtype of the aggregate, and allocates the
15668 aggregate statically as well. No code is generated for the following:
15670 @smallexample @c ada
15671 type One_Unc is array (natural range <>) of integer;
15672 Cr_Unc : constant One_Unc := (12,24,36);
15675 @node Aggregates with static bounds
15676 @subsection Aggregates with static bounds
15679 In all previous examples the aggregate was the initial (and immutable) value
15680 of a constant. If the aggregate initializes a variable, then code is generated
15681 for it as a combination of individual assignments and loops over the target
15682 object. The declarations
15684 @smallexample @c ada
15685 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15686 Cr_Var2 : One_Dim := (others > -1);
15690 generate the equivalent of
15692 @smallexample @c ada
15698 for I in Cr_Var2'range loop
15703 @node Aggregates with non-static bounds
15704 @subsection Aggregates with non-static bounds
15707 If the bounds of the aggregate are not statically compatible with the bounds
15708 of the nominal subtype of the target, then constraint checks have to be
15709 generated on the bounds. For a multidimensional array, constraint checks may
15710 have to be applied to sub-arrays individually, if they do not have statically
15711 compatible subtypes.
15713 @node Aggregates in assignment statements
15714 @subsection Aggregates in assignment statements
15717 In general, aggregate assignment requires the construction of a temporary,
15718 and a copy from the temporary to the target of the assignment. This is because
15719 it is not always possible to convert the assignment into a series of individual
15720 component assignments. For example, consider the simple case:
15722 @smallexample @c ada
15727 This cannot be converted into:
15729 @smallexample @c ada
15735 So the aggregate has to be built first in a separate location, and then
15736 copied into the target. GNAT recognizes simple cases where this intermediate
15737 step is not required, and the assignments can be performed in place, directly
15738 into the target. The following sufficient criteria are applied:
15742 The bounds of the aggregate are static, and the associations are static.
15744 The components of the aggregate are static constants, names of
15745 simple variables that are not renamings, or expressions not involving
15746 indexed components whose operands obey these rules.
15750 If any of these conditions are violated, the aggregate will be built in
15751 a temporary (created either by the front-end or the code generator) and then
15752 that temporary will be copied onto the target.
15755 @node The Size of Discriminated Records with Default Discriminants
15756 @section The Size of Discriminated Records with Default Discriminants
15759 If a discriminated type @code{T} has discriminants with default values, it is
15760 possible to declare an object of this type without providing an explicit
15763 @smallexample @c ada
15765 type Size is range 1..100;
15767 type Rec (D : Size := 15) is record
15768 Name : String (1..D);
15776 Such an object is said to be @emph{unconstrained}.
15777 The discriminant of the object
15778 can be modified by a full assignment to the object, as long as it preserves the
15779 relation between the value of the discriminant, and the value of the components
15782 @smallexample @c ada
15784 Word := (3, "yes");
15786 Word := (5, "maybe");
15788 Word := (5, "no"); -- raises Constraint_Error
15793 In order to support this behavior efficiently, an unconstrained object is
15794 given the maximum size that any value of the type requires. In the case
15795 above, @code{Word} has storage for the discriminant and for
15796 a @code{String} of length 100.
15797 It is important to note that unconstrained objects do not require dynamic
15798 allocation. It would be an improper implementation to place on the heap those
15799 components whose size depends on discriminants. (This improper implementation
15800 was used by some Ada83 compilers, where the @code{Name} component above
15802 been stored as a pointer to a dynamic string). Following the principle that
15803 dynamic storage management should never be introduced implicitly,
15804 an Ada compiler should reserve the full size for an unconstrained declared
15805 object, and place it on the stack.
15807 This maximum size approach
15808 has been a source of surprise to some users, who expect the default
15809 values of the discriminants to determine the size reserved for an
15810 unconstrained object: ``If the default is 15, why should the object occupy
15812 The answer, of course, is that the discriminant may be later modified,
15813 and its full range of values must be taken into account. This is why the
15818 type Rec (D : Positive := 15) is record
15819 Name : String (1..D);
15827 is flagged by the compiler with a warning:
15828 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15829 because the required size includes @code{Positive'Last}
15830 bytes. As the first example indicates, the proper approach is to declare an
15831 index type of ``reasonable'' range so that unconstrained objects are not too
15834 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15835 created in the heap by means of an allocator, then it is @emph{not}
15837 it is constrained by the default values of the discriminants, and those values
15838 cannot be modified by full assignment. This is because in the presence of
15839 aliasing all views of the object (which may be manipulated by different tasks,
15840 say) must be consistent, so it is imperative that the object, once created,
15843 @node Strict Conformance to the Ada Reference Manual
15844 @section Strict Conformance to the Ada Reference Manual
15847 The dynamic semantics defined by the Ada Reference Manual impose a set of
15848 run-time checks to be generated. By default, the GNAT compiler will insert many
15849 run-time checks into the compiled code, including most of those required by the
15850 Ada Reference Manual. However, there are three checks that are not enabled
15851 in the default mode for efficiency reasons: arithmetic overflow checking for
15852 integer operations (including division by zero), checks for access before
15853 elaboration on subprogram calls, and stack overflow checking (most operating
15854 systems do not perform this check by default).
15856 Strict conformance to the Ada Reference Manual can be achieved by adding
15857 three compiler options for overflow checking for integer operations
15858 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15859 calls and generic instantiations (@option{-gnatE}), and stack overflow
15860 checking (@option{-fstack-check}).
15862 Note that the result of a floating point arithmetic operation in overflow and
15863 invalid situations, when the @code{Machine_Overflows} attribute of the result
15864 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15865 case for machines compliant with the IEEE floating-point standard, but on
15866 machines that are not fully compliant with this standard, such as Alpha, the
15867 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15868 behavior (although at the cost of a significant performance penalty), so
15869 infinite and and NaN values are properly generated.
15872 @node Project File Reference
15873 @chapter Project File Reference
15876 This chapter describes the syntax and semantics of project files.
15877 Project files specify the options to be used when building a system.
15878 Project files can specify global settings for all tools,
15879 as well as tool-specific settings.
15880 @xref{Examples of Project Files,,, gnat_ugn, @value{EDITION} User's Guide},
15881 for examples of use.
15885 * Lexical Elements::
15887 * Empty declarations::
15888 * Typed string declarations::
15892 * Project Attributes::
15893 * Attribute References::
15894 * External Values::
15895 * Case Construction::
15897 * Package Renamings::
15899 * Project Extensions::
15900 * Project File Elaboration::
15903 @node Reserved Words
15904 @section Reserved Words
15907 All Ada reserved words are reserved in project files, and cannot be used
15908 as variable names or project names. In addition, the following are
15909 also reserved in project files:
15912 @item @code{extends}
15914 @item @code{external}
15916 @item @code{project}
15920 @node Lexical Elements
15921 @section Lexical Elements
15924 Rules for identifiers are the same as in Ada. Identifiers
15925 are case-insensitive. Strings are case sensitive, except where noted.
15926 Comments have the same form as in Ada.
15936 simple_name @{. simple_name@}
15940 @section Declarations
15943 Declarations introduce new entities that denote types, variables, attributes,
15944 and packages. Some declarations can only appear immediately within a project
15945 declaration. Others can appear within a project or within a package.
15949 declarative_item ::=
15950 simple_declarative_item |
15951 typed_string_declaration |
15952 package_declaration
15954 simple_declarative_item ::=
15955 variable_declaration |
15956 typed_variable_declaration |
15957 attribute_declaration |
15958 case_construction |
15962 @node Empty declarations
15963 @section Empty declarations
15966 empty_declaration ::=
15970 An empty declaration is allowed anywhere a declaration is allowed.
15973 @node Typed string declarations
15974 @section Typed string declarations
15977 Typed strings are sequences of string literals. Typed strings are the only
15978 named types in project files. They are used in case constructions, where they
15979 provide support for conditional attribute definitions.
15983 typed_string_declaration ::=
15984 @b{type} <typed_string_>_simple_name @b{is}
15985 ( string_literal @{, string_literal@} );
15989 A typed string declaration can only appear immediately within a project
15992 All the string literals in a typed string declaration must be distinct.
15998 Variables denote values, and appear as constituents of expressions.
16001 typed_variable_declaration ::=
16002 <typed_variable_>simple_name : <typed_string_>name := string_expression ;
16004 variable_declaration ::=
16005 <variable_>simple_name := expression;
16009 The elaboration of a variable declaration introduces the variable and
16010 assigns to it the value of the expression. The name of the variable is
16011 available after the assignment symbol.
16014 A typed_variable can only be declare once.
16017 a non-typed variable can be declared multiple times.
16020 Before the completion of its first declaration, the value of variable
16021 is the null string.
16024 @section Expressions
16027 An expression is a formula that defines a computation or retrieval of a value.
16028 In a project file the value of an expression is either a string or a list
16029 of strings. A string value in an expression is either a literal, the current
16030 value of a variable, an external value, an attribute reference, or a
16031 concatenation operation.
16044 attribute_reference
16050 ( <string_>expression @{ , <string_>expression @} )
16053 @subsection Concatenation
16055 The following concatenation functions are defined:
16057 @smallexample @c ada
16058 function "&" (X : String; Y : String) return String;
16059 function "&" (X : String_List; Y : String) return String_List;
16060 function "&" (X : String_List; Y : String_List) return String_List;
16064 @section Attributes
16067 An attribute declaration defines a property of a project or package. This
16068 property can later be queried by means of an attribute reference.
16069 Attribute values are strings or string lists.
16071 Some attributes are associative arrays. These attributes are mappings whose
16072 domain is a set of strings. These attributes are declared one association
16073 at a time, by specifying a point in the domain and the corresponding image
16074 of the attribute. They may also be declared as a full associative array,
16075 getting the same associations as the corresponding attribute in an imported
16076 or extended project.
16078 Attributes that are not associative arrays are called simple attributes.
16082 attribute_declaration ::=
16083 full_associative_array_declaration |
16084 @b{for} attribute_designator @b{use} expression ;
16086 full_associative_array_declaration ::=
16087 @b{for} <associative_array_attribute_>simple_name @b{use}
16088 <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
16090 attribute_designator ::=
16091 <simple_attribute_>simple_name |
16092 <associative_array_attribute_>simple_name ( string_literal )
16096 Some attributes are project-specific, and can only appear immediately within
16097 a project declaration. Others are package-specific, and can only appear within
16098 the proper package.
16100 The expression in an attribute definition must be a string or a string_list.
16101 The string literal appearing in the attribute_designator of an associative
16102 array attribute is case-insensitive.
16104 @node Project Attributes
16105 @section Project Attributes
16108 The following attributes apply to a project. All of them are simple
16113 Expression must be a path name. The attribute defines the
16114 directory in which the object files created by the build are to be placed. If
16115 not specified, object files are placed in the project directory.
16118 Expression must be a path name. The attribute defines the
16119 directory in which the executables created by the build are to be placed.
16120 If not specified, executables are placed in the object directory.
16123 Expression must be a list of path names. The attribute
16124 defines the directories in which the source files for the project are to be
16125 found. If not specified, source files are found in the project directory.
16126 If a string in the list ends with "/**", then the directory that precedes
16127 "/**" and all of its subdirectories (recursively) are included in the list
16128 of source directories.
16130 @item Excluded_Source_Dirs
16131 Expression must be a list of strings. Each entry designates a directory that
16132 is not to be included in the list of source directories of the project.
16133 This is normally used when there are strings ending with "/**" in the value
16134 of attribute Source_Dirs.
16137 Expression must be a list of file names. The attribute
16138 defines the individual files, in the project directory, which are to be used
16139 as sources for the project. File names are path_names that contain no directory
16140 information. If the project has no sources the attribute must be declared
16141 explicitly with an empty list.
16143 @item Excluded_Source_Files (Locally_Removed_Files)
16144 Expression must be a list of strings that are legal file names.
16145 Each file name must designate a source that would normally be a source file
16146 in the source directories of the project or, if the project file is an
16147 extending project file, inherited by the current project file. It cannot
16148 designate an immediate source that is not inherited. Each of the source files
16149 in the list are not considered to be sources of the project file: they are not
16150 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
16151 Excluded_Source_Files is preferred.
16153 @item Source_List_File
16154 Expression must a single path name. The attribute
16155 defines a text file that contains a list of source file names to be used
16156 as sources for the project
16159 Expression must be a path name. The attribute defines the
16160 directory in which a library is to be built. The directory must exist, must
16161 be distinct from the project's object directory, and must be writable.
16164 Expression must be a string that is a legal file name,
16165 without extension. The attribute defines a string that is used to generate
16166 the name of the library to be built by the project.
16169 Argument must be a string value that must be one of the
16170 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
16171 string is case-insensitive. If this attribute is not specified, the library is
16172 a static library. Otherwise, the library may be dynamic or relocatable. This
16173 distinction is operating-system dependent.
16175 @item Library_Version
16176 Expression must be a string value whose interpretation
16177 is platform dependent. On UNIX, it is used only for dynamic/relocatable
16178 libraries as the internal name of the library (the @code{"soname"}). If the
16179 library file name (built from the @code{Library_Name}) is different from the
16180 @code{Library_Version}, then the library file will be a symbolic link to the
16181 actual file whose name will be @code{Library_Version}.
16183 @item Library_Interface
16184 Expression must be a string list. Each element of the string list
16185 must designate a unit of the project.
16186 If this attribute is present in a Library Project File, then the project
16187 file is a Stand-alone Library_Project_File.
16189 @item Library_Auto_Init
16190 Expression must be a single string "true" or "false", case-insensitive.
16191 If this attribute is present in a Stand-alone Library Project File,
16192 it indicates if initialization is automatic when the dynamic library
16195 @item Library_Options
16196 Expression must be a string list. Indicates additional switches that
16197 are to be used when building a shared library.
16200 Expression must be a single string. Designates an alternative to "gcc"
16201 for building shared libraries.
16203 @item Library_Src_Dir
16204 Expression must be a path name. The attribute defines the
16205 directory in which the sources of the interfaces of a Stand-alone Library will
16206 be copied. The directory must exist, must be distinct from the project's
16207 object directory and source directories of all projects in the project tree,
16208 and must be writable.
16210 @item Library_Src_Dir
16211 Expression must be a path name. The attribute defines the
16212 directory in which the ALI files of a Library will
16213 be copied. The directory must exist, must be distinct from the project's
16214 object directory and source directories of all projects in the project tree,
16215 and must be writable.
16217 @item Library_Symbol_File
16218 Expression must be a single string. Its value is the single file name of a
16219 symbol file to be created when building a stand-alone library when the
16220 symbol policy is either "compliant", "controlled" or "restricted",
16221 on platforms that support symbol control, such as VMS. When symbol policy
16222 is "direct", then a file with this name must exist in the object directory.
16224 @item Library_Reference_Symbol_File
16225 Expression must be a single string. Its value is the path name of a
16226 reference symbol file that is read when the symbol policy is either
16227 "compliant" or "controlled", on platforms that support symbol control,
16228 such as VMS, when building a stand-alone library. The path may be an absolute
16229 path or a path relative to the project directory.
16231 @item Library_Symbol_Policy
16232 Expression must be a single string. Its case-insensitive value can only be
16233 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
16235 This attribute is not taken into account on all platforms. It controls the
16236 policy for exported symbols and, on some platforms (like VMS) that have the
16237 notions of major and minor IDs built in the library files, it controls
16238 the setting of these IDs.
16240 "autonomous" or "default": exported symbols are not controlled.
16242 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
16243 it is equivalent to policy "autonomous". If there are exported symbols in
16244 the reference symbol file that are not in the object files of the interfaces,
16245 the major ID of the library is increased. If there are symbols in the
16246 object files of the interfaces that are not in the reference symbol file,
16247 these symbols are put at the end of the list in the newly created symbol file
16248 and the minor ID is increased.
16250 "controlled": the attribute Library_Reference_Symbol_File must be defined.
16251 The library will fail to build if the exported symbols in the object files of
16252 the interfaces do not match exactly the symbol in the symbol file.
16254 "restricted": The attribute Library_Symbol_File must be defined. The library
16255 will fail to build if there are symbols in the symbol file that are not in
16256 the exported symbols of the object files of the interfaces. Additional symbols
16257 in the object files are not added to the symbol file.
16259 "direct": The attribute Library_Symbol_File must be defined and must designate
16260 an existing file in the object directory. This symbol file is passed directly
16261 to the underlying linker without any symbol processing.
16264 Expression must be a list of strings that are legal file names.
16265 These file names designate existing compilation units in the source directory
16266 that are legal main subprograms.
16268 When a project file is elaborated, as part of the execution of a gnatmake
16269 command, one or several executables are built and placed in the Exec_Dir.
16270 If the gnatmake command does not include explicit file names, the executables
16271 that are built correspond to the files specified by this attribute.
16273 @item Externally_Built
16274 Expression must be a single string. Its value must be either "true" of "false",
16275 case-insensitive. The default is "false". When the value of this attribute is
16276 "true", no attempt is made to compile the sources or to build the library,
16277 when the project is a library project.
16279 @item Main_Language
16280 This is a simple attribute. Its value is a string that specifies the
16281 language of the main program.
16284 Expression must be a string list. Each string designates
16285 a programming language that is known to GNAT. The strings are case-insensitive.
16289 @node Attribute References
16290 @section Attribute References
16293 Attribute references are used to retrieve the value of previously defined
16294 attribute for a package or project.
16297 attribute_reference ::=
16298 attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
16300 attribute_prefix ::=
16302 <project_simple_name | package_identifier |
16303 <project_>simple_name . package_identifier
16307 If an attribute has not been specified for a given package or project, its
16308 value is the null string or the empty list.
16310 @node External Values
16311 @section External Values
16314 An external value is an expression whose value is obtained from the command
16315 that invoked the processing of the current project file (typically a
16321 @b{external} ( string_literal [, string_literal] )
16325 The first string_literal is the string to be used on the command line or
16326 in the environment to specify the external value. The second string_literal,
16327 if present, is the default to use if there is no specification for this
16328 external value either on the command line or in the environment.
16330 @node Case Construction
16331 @section Case Construction
16334 A case construction supports attribute and variable declarations that depend
16335 on the value of a previously declared variable.
16339 case_construction ::=
16340 @b{case} <typed_variable_>name @b{is}
16345 @b{when} discrete_choice_list =>
16346 @{case_construction |
16347 attribute_declaration |
16348 variable_declaration |
16349 empty_declaration@}
16351 discrete_choice_list ::=
16352 string_literal @{| string_literal@} |
16357 Inside a case construction, variable declarations must be for variables that
16358 have already been declared before the case construction.
16360 All choices in a choice list must be distinct. The choice lists of two
16361 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
16362 alternatives do not need to include all values of the type. An @code{others}
16363 choice must appear last in the list of alternatives.
16369 A package provides a grouping of variable declarations and attribute
16370 declarations to be used when invoking various GNAT tools. The name of
16371 the package indicates the tool(s) to which it applies.
16375 package_declaration ::=
16376 package_spec | package_renaming
16379 @b{package} package_identifier @b{is}
16380 @{simple_declarative_item@}
16381 @b{end} package_identifier ;
16383 package_identifier ::=
16384 @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
16385 @code{Linker} | @code{Finder} | @code{Cross_Reference} |
16386 @code{gnatls} | @code{IDE} | @code{Pretty_Printer}
16389 @subsection Package Naming
16392 The attributes of a @code{Naming} package specifies the naming conventions
16393 that apply to the source files in a project. When invoking other GNAT tools,
16394 they will use the sources in the source directories that satisfy these
16395 naming conventions.
16397 The following attributes apply to a @code{Naming} package:
16401 This is a simple attribute whose value is a string. Legal values of this
16402 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
16403 These strings are themselves case insensitive.
16406 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
16408 @item Dot_Replacement
16409 This is a simple attribute whose string value satisfies the following
16413 @item It must not be empty
16414 @item It cannot start or end with an alphanumeric character
16415 @item It cannot be a single underscore
16416 @item It cannot start with an underscore followed by an alphanumeric
16417 @item It cannot contain a dot @code{'.'} if longer than one character
16421 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
16424 This is an associative array attribute, defined on language names,
16425 whose image is a string that must satisfy the following
16429 @item It must not be empty
16430 @item It cannot start with an alphanumeric character
16431 @item It cannot start with an underscore followed by an alphanumeric character
16435 For Ada, the attribute denotes the suffix used in file names that contain
16436 library unit declarations, that is to say units that are package and
16437 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
16438 specified, then the default is @code{".ads"}.
16440 For C and C++, the attribute denotes the suffix used in file names that
16441 contain prototypes.
16444 This is an associative array attribute defined on language names,
16445 whose image is a string that must satisfy the following
16449 @item It must not be empty
16450 @item It cannot start with an alphanumeric character
16451 @item It cannot start with an underscore followed by an alphanumeric character
16452 @item It cannot be a suffix of @code{Spec_Suffix}
16456 For Ada, the attribute denotes the suffix used in file names that contain
16457 library bodies, that is to say units that are package and subprogram bodies.
16458 If @code{Body_Suffix ("Ada")} is not specified, then the default is
16461 For C and C++, the attribute denotes the suffix used in file names that contain
16464 @item Separate_Suffix
16465 This is a simple attribute whose value satisfies the same conditions as
16466 @code{Body_Suffix}.
16468 This attribute is specific to Ada. It denotes the suffix used in file names
16469 that contain separate bodies. If it is not specified, then it defaults to same
16470 value as @code{Body_Suffix ("Ada")}.
16473 This is an associative array attribute, specific to Ada, defined over
16474 compilation unit names. The image is a string that is the name of the file
16475 that contains that library unit. The file name is case sensitive if the
16476 conventions of the host operating system require it.
16479 This is an associative array attribute, specific to Ada, defined over
16480 compilation unit names. The image is a string that is the name of the file
16481 that contains the library unit body for the named unit. The file name is case
16482 sensitive if the conventions of the host operating system require it.
16484 @item Specification_Exceptions
16485 This is an associative array attribute defined on language names,
16486 whose value is a list of strings.
16488 This attribute is not significant for Ada.
16490 For C and C++, each string in the list denotes the name of a file that
16491 contains prototypes, but whose suffix is not necessarily the
16492 @code{Spec_Suffix} for the language.
16494 @item Implementation_Exceptions
16495 This is an associative array attribute defined on language names,
16496 whose value is a list of strings.
16498 This attribute is not significant for Ada.
16500 For C and C++, each string in the list denotes the name of a file that
16501 contains source code, but whose suffix is not necessarily the
16502 @code{Body_Suffix} for the language.
16505 The following attributes of package @code{Naming} are obsolescent. They are
16506 kept as synonyms of other attributes for compatibility with previous versions
16507 of the Project Manager.
16510 @item Specification_Suffix
16511 This is a synonym of @code{Spec_Suffix}.
16513 @item Implementation_Suffix
16514 This is a synonym of @code{Body_Suffix}.
16516 @item Specification
16517 This is a synonym of @code{Spec}.
16519 @item Implementation
16520 This is a synonym of @code{Body}.
16523 @subsection package Compiler
16526 The attributes of the @code{Compiler} package specify the compilation options
16527 to be used by the underlying compiler.
16530 @item Default_Switches
16531 This is an associative array attribute. Its
16532 domain is a set of language names. Its range is a string list that
16533 specifies the compilation options to be used when compiling a component
16534 written in that language, for which no file-specific switches have been
16538 This is an associative array attribute. Its domain is
16539 a set of file names. Its range is a string list that specifies the
16540 compilation options to be used when compiling the named file. If a file
16541 is not specified in the Switches attribute, it is compiled with the
16542 options specified by Default_Switches of its language, if defined.
16544 @item Local_Configuration_Pragmas.
16545 This is a simple attribute, whose
16546 value is a path name that designates a file containing configuration pragmas
16547 to be used for all invocations of the compiler for immediate sources of the
16551 @subsection package Builder
16554 The attributes of package @code{Builder} specify the compilation, binding, and
16555 linking options to be used when building an executable for a project. The
16556 following attributes apply to package @code{Builder}:
16559 @item Default_Switches
16560 This is an associative array attribute. Its
16561 domain is a set of language names. Its range is a string list that
16562 specifies options to be used when building a main
16563 written in that language, for which no file-specific switches have been
16567 This is an associative array attribute. Its domain is
16568 a set of file names. Its range is a string list that specifies
16569 options to be used when building the named main file. If a main file
16570 is not specified in the Switches attribute, it is built with the
16571 options specified by Default_Switches of its language, if defined.
16573 @item Global_Configuration_Pragmas
16574 This is a simple attribute, whose
16575 value is a path name that designates a file that contains configuration pragmas
16576 to be used in every build of an executable. If both local and global
16577 configuration pragmas are specified, a compilation makes use of both sets.
16581 This is an associative array attribute. Its domain is
16582 a set of main source file names. Its range is a simple string that specifies
16583 the executable file name to be used when linking the specified main source.
16584 If a main source is not specified in the Executable attribute, the executable
16585 file name is deducted from the main source file name.
16586 This attribute has no effect if its value is the empty string.
16588 @item Executable_Suffix
16589 This is a simple attribute whose value is the suffix to be added to
16590 the executables that don't have an attribute Executable specified.
16593 @subsection package Gnatls
16596 The attributes of package @code{Gnatls} specify the tool options to be used
16597 when invoking the library browser @command{gnatls}.
16598 The following attributes apply to package @code{Gnatls}:
16602 This is a single attribute with a string list value. Each nonempty string
16603 in the list is an option when invoking @code{gnatls}.
16606 @subsection package Binder
16609 The attributes of package @code{Binder} specify the options to be used
16610 when invoking the binder in the construction of an executable.
16611 The following attributes apply to package @code{Binder}:
16614 @item Default_Switches
16615 This is an associative array attribute. Its
16616 domain is a set of language names. Its range is a string list that
16617 specifies options to be used when binding a main
16618 written in that language, for which no file-specific switches have been
16622 This is an associative array attribute. Its domain is
16623 a set of file names. Its range is a string list that specifies
16624 options to be used when binding the named main file. If a main file
16625 is not specified in the Switches attribute, it is bound with the
16626 options specified by Default_Switches of its language, if defined.
16629 @subsection package Linker
16632 The attributes of package @code{Linker} specify the options to be used when
16633 invoking the linker in the construction of an executable.
16634 The following attributes apply to package @code{Linker}:
16637 @item Default_Switches
16638 This is an associative array attribute. Its
16639 domain is a set of language names. Its range is a string list that
16640 specifies options to be used when linking a main
16641 written in that language, for which no file-specific switches have been
16645 This is an associative array attribute. Its domain is
16646 a set of file names. Its range is a string list that specifies
16647 options to be used when linking the named main file. If a main file
16648 is not specified in the Switches attribute, it is linked with the
16649 options specified by Default_Switches of its language, if defined.
16651 @item Linker_Options
16652 This is a string list attribute. Its value specifies additional options that
16653 be given to the linker when linking an executable. This attribute is not
16654 used in the main project, only in projects imported directly or indirectly.
16658 @subsection package Cross_Reference
16661 The attributes of package @code{Cross_Reference} specify the tool options
16663 when invoking the library tool @command{gnatxref}.
16664 The following attributes apply to package @code{Cross_Reference}:
16667 @item Default_Switches
16668 This is an associative array attribute. Its
16669 domain is a set of language names. Its range is a string list that
16670 specifies options to be used when calling @command{gnatxref} on a source
16671 written in that language, for which no file-specific switches have been
16675 This is an associative array attribute. Its domain is
16676 a set of file names. Its range is a string list that specifies
16677 options to be used when calling @command{gnatxref} on the named main source.
16678 If a source is not specified in the Switches attribute, @command{gnatxref} will
16679 be called with the options specified by Default_Switches of its language,
16683 @subsection package Finder
16686 The attributes of package @code{Finder} specify the tool options to be used
16687 when invoking the search tool @command{gnatfind}.
16688 The following attributes apply to package @code{Finder}:
16691 @item Default_Switches
16692 This is an associative array attribute. Its
16693 domain is a set of language names. Its range is a string list that
16694 specifies options to be used when calling @command{gnatfind} on a source
16695 written in that language, for which no file-specific switches have been
16699 This is an associative array attribute. Its domain is
16700 a set of file names. Its range is a string list that specifies
16701 options to be used when calling @command{gnatfind} on the named main source.
16702 If a source is not specified in the Switches attribute, @command{gnatfind} will
16703 be called with the options specified by Default_Switches of its language,
16707 @subsection package Pretty_Printer
16710 The attributes of package @code{Pretty_Printer}
16711 specify the tool options to be used
16712 when invoking the formatting tool @command{gnatpp}.
16713 The following attributes apply to package @code{Pretty_Printer}:
16716 @item Default_switches
16717 This is an associative array attribute. Its
16718 domain is a set of language names. Its range is a string list that
16719 specifies options to be used when calling @command{gnatpp} on a source
16720 written in that language, for which no file-specific switches have been
16724 This is an associative array attribute. Its domain is
16725 a set of file names. Its range is a string list that specifies
16726 options to be used when calling @command{gnatpp} on the named main source.
16727 If a source is not specified in the Switches attribute, @command{gnatpp} will
16728 be called with the options specified by Default_Switches of its language,
16732 @subsection package gnatstub
16735 The attributes of package @code{gnatstub}
16736 specify the tool options to be used
16737 when invoking the tool @command{gnatstub}.
16738 The following attributes apply to package @code{gnatstub}:
16741 @item Default_switches
16742 This is an associative array attribute. Its
16743 domain is a set of language names. Its range is a string list that
16744 specifies options to be used when calling @command{gnatstub} on a source
16745 written in that language, for which no file-specific switches have been
16749 This is an associative array attribute. Its domain is
16750 a set of file names. Its range is a string list that specifies
16751 options to be used when calling @command{gnatstub} on the named main source.
16752 If a source is not specified in the Switches attribute, @command{gnatpp} will
16753 be called with the options specified by Default_Switches of its language,
16757 @subsection package Eliminate
16760 The attributes of package @code{Eliminate}
16761 specify the tool options to be used
16762 when invoking the tool @command{gnatelim}.
16763 The following attributes apply to package @code{Eliminate}:
16766 @item Default_switches
16767 This is an associative array attribute. Its
16768 domain is a set of language names. Its range is a string list that
16769 specifies options to be used when calling @command{gnatelim} on a source
16770 written in that language, for which no file-specific switches have been
16774 This is an associative array attribute. Its domain is
16775 a set of file names. Its range is a string list that specifies
16776 options to be used when calling @command{gnatelim} on the named main source.
16777 If a source is not specified in the Switches attribute, @command{gnatelim} will
16778 be called with the options specified by Default_Switches of its language,
16782 @subsection package Metrics
16785 The attributes of package @code{Metrics}
16786 specify the tool options to be used
16787 when invoking the tool @command{gnatmetric}.
16788 The following attributes apply to package @code{Metrics}:
16791 @item Default_switches
16792 This is an associative array attribute. Its
16793 domain is a set of language names. Its range is a string list that
16794 specifies options to be used when calling @command{gnatmetric} on a source
16795 written in that language, for which no file-specific switches have been
16799 This is an associative array attribute. Its domain is
16800 a set of file names. Its range is a string list that specifies
16801 options to be used when calling @command{gnatmetric} on the named main source.
16802 If a source is not specified in the Switches attribute, @command{gnatmetric}
16803 will be called with the options specified by Default_Switches of its language,
16807 @subsection package IDE
16810 The attributes of package @code{IDE} specify the options to be used when using
16811 an Integrated Development Environment such as @command{GPS}.
16815 This is a simple attribute. Its value is a string that designates the remote
16816 host in a cross-compilation environment, to be used for remote compilation and
16817 debugging. This field should not be specified when running on the local
16821 This is a simple attribute. Its value is a string that specifies the
16822 name of IP address of the embedded target in a cross-compilation environment,
16823 on which the program should execute.
16825 @item Communication_Protocol
16826 This is a simple string attribute. Its value is the name of the protocol
16827 to use to communicate with the target in a cross-compilation environment,
16828 e.g.@: @code{"wtx"} or @code{"vxworks"}.
16830 @item Compiler_Command
16831 This is an associative array attribute, whose domain is a language name. Its
16832 value is string that denotes the command to be used to invoke the compiler.
16833 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16834 gnatmake, in particular in the handling of switches.
16836 @item Debugger_Command
16837 This is simple attribute, Its value is a string that specifies the name of
16838 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16840 @item Default_Switches
16841 This is an associative array attribute. Its indexes are the name of the
16842 external tools that the GNAT Programming System (GPS) is supporting. Its
16843 value is a list of switches to use when invoking that tool.
16846 This is a simple attribute. Its value is a string that specifies the name
16847 of the @command{gnatls} utility to be used to retrieve information about the
16848 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16851 This is a simple attribute. Its value is a string used to specify the
16852 Version Control System (VCS) to be used for this project, e.g.@: CVS, RCS
16853 ClearCase or Perforce.
16855 @item VCS_File_Check
16856 This is a simple attribute. Its value is a string that specifies the
16857 command used by the VCS to check the validity of a file, either
16858 when the user explicitly asks for a check, or as a sanity check before
16859 doing the check-in.
16861 @item VCS_Log_Check
16862 This is a simple attribute. Its value is a string that specifies
16863 the command used by the VCS to check the validity of a log file.
16865 @item VCS_Repository_Root
16866 The VCS repository root path. This is used to create tags or branches
16867 of the repository. For subversion the value should be the @code{URL}
16868 as specified to check-out the working copy of the repository.
16870 @item VCS_Patch_Root
16871 The local root directory to use for building patch file. All patch chunks
16872 will be relative to this path. The root project directory is used if
16873 this value is not defined.
16877 @node Package Renamings
16878 @section Package Renamings
16881 A package can be defined by a renaming declaration. The new package renames
16882 a package declared in a different project file, and has the same attributes
16883 as the package it renames.
16886 package_renaming ::==
16887 @b{package} package_identifier @b{renames}
16888 <project_>simple_name.package_identifier ;
16892 The package_identifier of the renamed package must be the same as the
16893 package_identifier. The project whose name is the prefix of the renamed
16894 package must contain a package declaration with this name. This project
16895 must appear in the context_clause of the enclosing project declaration,
16896 or be the parent project of the enclosing child project.
16902 A project file specifies a set of rules for constructing a software system.
16903 A project file can be self-contained, or depend on other project files.
16904 Dependencies are expressed through a context clause that names other projects.
16910 context_clause project_declaration
16912 project_declaration ::=
16913 simple_project_declaration | project_extension
16915 simple_project_declaration ::=
16916 @b{project} <project_>simple_name @b{is}
16917 @{declarative_item@}
16918 @b{end} <project_>simple_name;
16924 [@b{limited}] @b{with} path_name @{ , path_name @} ;
16931 A path name denotes a project file. A path name can be absolute or relative.
16932 An absolute path name includes a sequence of directories, in the syntax of
16933 the host operating system, that identifies uniquely the project file in the
16934 file system. A relative path name identifies the project file, relative
16935 to the directory that contains the current project, or relative to a
16936 directory listed in the environment variable ADA_PROJECT_PATH.
16937 Path names are case sensitive if file names in the host operating system
16938 are case sensitive.
16940 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16941 directory names separated by colons (semicolons on Windows).
16943 A given project name can appear only once in a context_clause.
16945 It is illegal for a project imported by a context clause to refer, directly
16946 or indirectly, to the project in which this context clause appears (the
16947 dependency graph cannot contain cycles), except when one of the with_clause
16948 in the cycle is a @code{limited with}.
16950 @node Project Extensions
16951 @section Project Extensions
16954 A project extension introduces a new project, which inherits the declarations
16955 of another project.
16959 project_extension ::=
16960 @b{project} <project_>simple_name @b{extends} path_name @b{is}
16961 @{declarative_item@}
16962 @b{end} <project_>simple_name;
16966 The project extension declares a child project. The child project inherits
16967 all the declarations and all the files of the parent project, These inherited
16968 declaration can be overridden in the child project, by means of suitable
16971 @node Project File Elaboration
16972 @section Project File Elaboration
16975 A project file is processed as part of the invocation of a gnat tool that
16976 uses the project option. Elaboration of the process file consists in the
16977 sequential elaboration of all its declarations. The computed values of
16978 attributes and variables in the project are then used to establish the
16979 environment in which the gnat tool will execute.
16981 @node Obsolescent Features
16982 @chapter Obsolescent Features
16985 This chapter describes features that are provided by GNAT, but are
16986 considered obsolescent since there are preferred ways of achieving
16987 the same effect. These features are provided solely for historical
16988 compatibility purposes.
16991 * pragma No_Run_Time::
16992 * pragma Ravenscar::
16993 * pragma Restricted_Run_Time::
16996 @node pragma No_Run_Time
16997 @section pragma No_Run_Time
16999 The pragma @code{No_Run_Time} is used to achieve an affect similar
17000 to the use of the "Zero Foot Print" configurable run time, but without
17001 requiring a specially configured run time. The result of using this
17002 pragma, which must be used for all units in a partition, is to restrict
17003 the use of any language features requiring run-time support code. The
17004 preferred usage is to use an appropriately configured run-time that
17005 includes just those features that are to be made accessible.
17007 @node pragma Ravenscar
17008 @section pragma Ravenscar
17010 The pragma @code{Ravenscar} has exactly the same effect as pragma
17011 @code{Profile (Ravenscar)}. The latter usage is preferred since it
17012 is part of the new Ada 2005 standard.
17014 @node pragma Restricted_Run_Time
17015 @section pragma Restricted_Run_Time
17017 The pragma @code{Restricted_Run_Time} has exactly the same effect as
17018 pragma @code{Profile (Restricted)}. The latter usage is
17019 preferred since the Ada 2005 pragma @code{Profile} is intended for
17020 this kind of implementation dependent addition.
17023 @c GNU Free Documentation License
17025 @node Index,,GNU Free Documentation License, Top