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.Strings (g-string.ads)::
385 * GNAT.String_Split (g-strspl.ads)::
386 * GNAT.Table (g-table.ads)::
387 * GNAT.Task_Lock (g-tasloc.ads)::
388 * GNAT.Threads (g-thread.ads)::
389 * GNAT.Time_Stamp (g-timsta.ads)::
390 * GNAT.Traceback (g-traceb.ads)::
391 * GNAT.Traceback.Symbolic (g-trasym.ads)::
392 * GNAT.UTF_32 (g-utf_32.ads)::
393 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
394 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
395 * GNAT.Wide_String_Split (g-wistsp.ads)::
396 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
397 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
398 * Interfaces.C.Extensions (i-cexten.ads)::
399 * Interfaces.C.Streams (i-cstrea.ads)::
400 * Interfaces.CPP (i-cpp.ads)::
401 * Interfaces.Packed_Decimal (i-pacdec.ads)::
402 * Interfaces.VxWorks (i-vxwork.ads)::
403 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
404 * System.Address_Image (s-addima.ads)::
405 * System.Assertions (s-assert.ads)::
406 * System.Memory (s-memory.ads)::
407 * System.Partition_Interface (s-parint.ads)::
408 * System.Pool_Global (s-pooglo.ads)::
409 * System.Pool_Local (s-pooloc.ads)::
410 * System.Restrictions (s-restri.ads)::
411 * System.Rident (s-rident.ads)::
412 * System.Task_Info (s-tasinf.ads)::
413 * System.Wch_Cnv (s-wchcnv.ads)::
414 * System.Wch_Con (s-wchcon.ads)::
418 * Text_IO Stream Pointer Positioning::
419 * Text_IO Reading and Writing Non-Regular Files::
421 * Treating Text_IO Files as Streams::
422 * Text_IO Extensions::
423 * Text_IO Facilities for Unbounded Strings::
427 * Wide_Text_IO Stream Pointer Positioning::
428 * Wide_Text_IO Reading and Writing Non-Regular Files::
432 * Wide_Wide_Text_IO Stream Pointer Positioning::
433 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
435 Interfacing to Other Languages
438 * Interfacing to C++::
439 * Interfacing to COBOL::
440 * Interfacing to Fortran::
441 * Interfacing to non-GNAT Ada code::
443 Specialized Needs Annexes
445 Implementation of Specific Ada Features
446 * Machine Code Insertions::
447 * GNAT Implementation of Tasking::
448 * GNAT Implementation of Shared Passive Packages::
449 * Code Generation for Array Aggregates::
450 * The Size of Discriminated Records with Default Discriminants::
451 * Strict Conformance to the Ada Reference Manual::
453 Project File Reference
457 GNU Free Documentation License
464 @node About This Guide
465 @unnumbered About This Guide
468 This manual contains useful information in writing programs using the
469 @value{EDITION} compiler. It includes information on implementation dependent
470 characteristics of @value{EDITION}, including all the information required by
471 Annex M of the Ada language standard.
473 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
474 Ada 83 compatibility mode.
475 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
476 but you can override with a compiler switch
477 to explicitly specify the language version.
478 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
479 @value{EDITION} User's Guide}, for details on these switches.)
480 Throughout this manual, references to ``Ada'' without a year suffix
481 apply to both the Ada 95 and Ada 2005 versions of the language.
483 Ada is designed to be highly portable.
484 In general, a program will have the same effect even when compiled by
485 different compilers on different platforms.
486 However, since Ada is designed to be used in a
487 wide variety of applications, it also contains a number of system
488 dependent features to be used in interfacing to the external world.
489 @cindex Implementation-dependent features
492 Note: Any program that makes use of implementation-dependent features
493 may be non-portable. You should follow good programming practice and
494 isolate and clearly document any sections of your program that make use
495 of these features in a non-portable manner.
498 For ease of exposition, ``GNAT Pro'' will be referred to simply as
499 ``GNAT'' in the remainder of this document.
503 * What This Reference Manual Contains::
505 * Related Information::
508 @node What This Reference Manual Contains
509 @unnumberedsec What This Reference Manual Contains
512 This reference manual contains the following chapters:
516 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
517 pragmas, which can be used to extend and enhance the functionality of the
521 @ref{Implementation Defined Attributes}, lists GNAT
522 implementation-dependent attributes which can be used to extend and
523 enhance the functionality of the compiler.
526 @ref{Implementation Advice}, provides information on generally
527 desirable behavior which are not requirements that all compilers must
528 follow since it cannot be provided on all systems, or which may be
529 undesirable on some systems.
532 @ref{Implementation Defined Characteristics}, provides a guide to
533 minimizing implementation dependent features.
536 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
537 implemented by GNAT, and how they can be imported into user
538 application programs.
541 @ref{Representation Clauses and Pragmas}, describes in detail the
542 way that GNAT represents data, and in particular the exact set
543 of representation clauses and pragmas that is accepted.
546 @ref{Standard Library Routines}, provides a listing of packages and a
547 brief description of the functionality that is provided by Ada's
548 extensive set of standard library routines as implemented by GNAT@.
551 @ref{The Implementation of Standard I/O}, details how the GNAT
552 implementation of the input-output facilities.
555 @ref{The GNAT Library}, is a catalog of packages that complement
556 the Ada predefined library.
559 @ref{Interfacing to Other Languages}, describes how programs
560 written in Ada using GNAT can be interfaced to other programming
563 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
564 of the specialized needs annexes.
567 @ref{Implementation of Specific Ada Features}, discusses issues related
568 to GNAT's implementation of machine code insertions, tasking, and several
572 @ref{Project File Reference}, presents the syntax and semantics
576 @ref{Obsolescent Features} documents implementation dependent features,
577 including pragmas and attributes, which are considered obsolescent, since
578 there are other preferred ways of achieving the same results. These
579 obsolescent forms are retained for backwards compatibility.
583 @cindex Ada 95 Language Reference Manual
584 @cindex Ada 2005 Language Reference Manual
586 This reference manual assumes a basic familiarity with the Ada 95 language, as
587 described in the International Standard ANSI/ISO/IEC-8652:1995,
589 It does not require knowledge of the new features introduced by Ada 2005,
590 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
592 Both reference manuals are included in the GNAT documentation
596 @unnumberedsec Conventions
597 @cindex Conventions, typographical
598 @cindex Typographical conventions
601 Following are examples of the typographical and graphic conventions used
606 @code{Functions}, @code{utility program names}, @code{standard names},
613 @file{File names}, @samp{button names}, and @samp{field names}.
616 @code{Variables}, @env{environment variables}, and @var{metasyntactic
623 [optional information or parameters]
626 Examples are described by text
628 and then shown this way.
633 Commands that are entered by the user are preceded in this manual by the
634 characters @samp{$ } (dollar sign followed by space). If your system uses this
635 sequence as a prompt, then the commands will appear exactly as you see them
636 in the manual. If your system uses some other prompt, then the command will
637 appear with the @samp{$} replaced by whatever prompt character you are using.
639 @node Related Information
640 @unnumberedsec Related Information
642 See the following documents for further information on GNAT:
646 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
647 @value{EDITION} User's Guide}, which provides information on how to use the
648 GNAT compiler system.
651 @cite{Ada 95 Reference Manual}, which contains all reference
652 material for the Ada 95 programming language.
655 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
656 of the Ada 95 standard. The annotations describe
657 detailed aspects of the design decision, and in particular contain useful
658 sections on Ada 83 compatibility.
661 @cite{Ada 2005 Reference Manual}, which contains all reference
662 material for the Ada 2005 programming language.
665 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
666 of the Ada 2005 standard. The annotations describe
667 detailed aspects of the design decision, and in particular contain useful
668 sections on Ada 83 and Ada 95 compatibility.
671 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
672 which contains specific information on compatibility between GNAT and
676 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
677 describes in detail the pragmas and attributes provided by the DEC Ada 83
682 @node Implementation Defined Pragmas
683 @chapter Implementation Defined Pragmas
686 Ada defines a set of pragmas that can be used to supply additional
687 information to the compiler. These language defined pragmas are
688 implemented in GNAT and work as described in the Ada Reference Manual.
690 In addition, Ada allows implementations to define additional pragmas
691 whose meaning is defined by the implementation. GNAT provides a number
692 of these implementation-defined pragmas, which can be used to extend
693 and enhance the functionality of the compiler. This section of the GNAT
694 Reference Manual describes these additional pragmas.
696 Note that any program using these pragmas might not be portable to other
697 compilers (although GNAT implements this set of pragmas on all
698 platforms). Therefore if portability to other compilers is an important
699 consideration, the use of these pragmas should be minimized.
702 * Pragma Abort_Defer::
709 * Pragma Assume_No_Invalid_Values::
711 * Pragma C_Pass_By_Copy::
713 * Pragma Check_Name::
714 * Pragma Check_Policy::
716 * Pragma Common_Object::
717 * Pragma Compile_Time_Error::
718 * Pragma Compile_Time_Warning::
719 * Pragma Complete_Representation::
720 * Pragma Complex_Representation::
721 * Pragma Component_Alignment::
722 * Pragma Convention_Identifier::
724 * Pragma CPP_Constructor::
725 * Pragma CPP_Virtual::
726 * Pragma CPP_Vtable::
728 * Pragma Debug_Policy::
729 * Pragma Detect_Blocking::
730 * Pragma Elaboration_Checks::
732 * Pragma Export_Exception::
733 * Pragma Export_Function::
734 * Pragma Export_Object::
735 * Pragma Export_Procedure::
736 * Pragma Export_Value::
737 * Pragma Export_Valued_Procedure::
738 * Pragma Extend_System::
740 * Pragma External_Name_Casing::
742 * Pragma Favor_Top_Level::
743 * Pragma Finalize_Storage_Only::
744 * Pragma Float_Representation::
746 * Pragma Implemented_By_Entry::
747 * Pragma Implicit_Packing::
748 * Pragma Import_Exception::
749 * Pragma Import_Function::
750 * Pragma Import_Object::
751 * Pragma Import_Procedure::
752 * Pragma Import_Valued_Procedure::
753 * Pragma Initialize_Scalars::
754 * Pragma Inline_Always::
755 * Pragma Inline_Generic::
757 * Pragma Interface_Name::
758 * Pragma Interrupt_Handler::
759 * Pragma Interrupt_State::
760 * Pragma Keep_Names::
763 * Pragma Linker_Alias::
764 * Pragma Linker_Constructor::
765 * Pragma Linker_Destructor::
766 * Pragma Linker_Section::
767 * Pragma Long_Float::
768 * Pragma Machine_Attribute::
770 * Pragma Main_Storage::
773 * Pragma No_Strict_Aliasing::
774 * Pragma Normalize_Scalars::
775 * Pragma Obsolescent::
776 * Pragma Optimize_Alignment::
778 * Pragma Persistent_BSS::
780 * Pragma Postcondition::
781 * Pragma Precondition::
782 * Pragma Profile (Ravenscar)::
783 * Pragma Profile (Restricted)::
784 * Pragma Psect_Object::
785 * Pragma Pure_Function::
786 * Pragma Restriction_Warnings::
788 * Pragma Source_File_Name::
789 * Pragma Source_File_Name_Project::
790 * Pragma Source_Reference::
791 * Pragma Stream_Convert::
792 * Pragma Style_Checks::
795 * Pragma Suppress_All::
796 * Pragma Suppress_Exception_Locations::
797 * Pragma Suppress_Initialization::
800 * Pragma Task_Storage::
801 * Pragma Thread_Local_Storage::
802 * Pragma Time_Slice::
804 * Pragma Unchecked_Union::
805 * Pragma Unimplemented_Unit::
806 * Pragma Universal_Aliasing ::
807 * Pragma Universal_Data::
808 * Pragma Unmodified::
809 * Pragma Unreferenced::
810 * Pragma Unreferenced_Objects::
811 * Pragma Unreserve_All_Interrupts::
812 * Pragma Unsuppress::
813 * Pragma Use_VADS_Size::
814 * Pragma Validity_Checks::
817 * Pragma Weak_External::
818 * Pragma Wide_Character_Encoding::
821 @node Pragma Abort_Defer
822 @unnumberedsec Pragma Abort_Defer
824 @cindex Deferring aborts
832 This pragma must appear at the start of the statement sequence of a
833 handled sequence of statements (right after the @code{begin}). It has
834 the effect of deferring aborts for the sequence of statements (but not
835 for the declarations or handlers, if any, associated with this statement
839 @unnumberedsec Pragma Ada_83
848 A configuration pragma that establishes Ada 83 mode for the unit to
849 which it applies, regardless of the mode set by the command line
850 switches. In Ada 83 mode, GNAT attempts to be as compatible with
851 the syntax and semantics of Ada 83, as defined in the original Ada
852 83 Reference Manual as possible. In particular, the keywords added by Ada 95
853 and Ada 2005 are not recognized, optional package bodies are allowed,
854 and generics may name types with unknown discriminants without using
855 the @code{(<>)} notation. In addition, some but not all of the additional
856 restrictions of Ada 83 are enforced.
858 Ada 83 mode is intended for two purposes. Firstly, it allows existing
859 Ada 83 code to be compiled and adapted to GNAT with less effort.
860 Secondly, it aids in keeping code backwards compatible with Ada 83.
861 However, there is no guarantee that code that is processed correctly
862 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
863 83 compiler, since GNAT does not enforce all the additional checks
867 @unnumberedsec Pragma Ada_95
876 A configuration pragma that establishes Ada 95 mode for the unit to which
877 it applies, regardless of the mode set by the command line switches.
878 This mode is set automatically for the @code{Ada} and @code{System}
879 packages and their children, so you need not specify it in these
880 contexts. This pragma is useful when writing a reusable component that
881 itself uses Ada 95 features, but which is intended to be usable from
882 either Ada 83 or Ada 95 programs.
885 @unnumberedsec Pragma Ada_05
894 A configuration pragma that establishes Ada 2005 mode for the unit to which
895 it applies, regardless of the mode set by the command line switches.
896 This mode is set automatically for the @code{Ada} and @code{System}
897 packages and their children, so you need not specify it in these
898 contexts. This pragma is useful when writing a reusable component that
899 itself uses Ada 2005 features, but which is intended to be usable from
900 either Ada 83 or Ada 95 programs.
902 @node Pragma Ada_2005
903 @unnumberedsec Pragma Ada_2005
912 This configuration pragma is a synonym for pragma Ada_05 and has the
913 same syntax and effect.
915 @node Pragma Annotate
916 @unnumberedsec Pragma Annotate
921 pragma Annotate (IDENTIFIER @{, ARG@});
923 ARG ::= NAME | EXPRESSION
927 This pragma is used to annotate programs. @var{identifier} identifies
928 the type of annotation. GNAT verifies that it is an identifier, but does
929 not otherwise analyze it. The @var{arg} argument
930 can be either a string literal or an
931 expression. String literals are assumed to be of type
932 @code{Standard.String}. Names of entities are simply analyzed as entity
933 names. All other expressions are analyzed as expressions, and must be
936 The analyzed pragma is retained in the tree, but not otherwise processed
937 by any part of the GNAT compiler. This pragma is intended for use by
938 external tools, including ASIS@.
941 @unnumberedsec Pragma Assert
948 [, string_EXPRESSION]);
952 The effect of this pragma depends on whether the corresponding command
953 line switch is set to activate assertions. The pragma expands into code
954 equivalent to the following:
957 if assertions-enabled then
958 if not boolean_EXPRESSION then
959 System.Assertions.Raise_Assert_Failure
966 The string argument, if given, is the message that will be associated
967 with the exception occurrence if the exception is raised. If no second
968 argument is given, the default message is @samp{@var{file}:@var{nnn}},
969 where @var{file} is the name of the source file containing the assert,
970 and @var{nnn} is the line number of the assert. A pragma is not a
971 statement, so if a statement sequence contains nothing but a pragma
972 assert, then a null statement is required in addition, as in:
977 pragma Assert (K > 3, "Bad value for K");
983 Note that, as with the @code{if} statement to which it is equivalent, the
984 type of the expression is either @code{Standard.Boolean}, or any type derived
985 from this standard type.
987 If assertions are disabled (switch @option{-gnata} not used), then there
988 is no run-time effect (and in particular, any side effects from the
989 expression will not occur at run time). (The expression is still
990 analyzed at compile time, and may cause types to be frozen if they are
991 mentioned here for the first time).
993 If assertions are enabled, then the given expression is tested, and if
994 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
995 which results in the raising of @code{Assert_Failure} with the given message.
997 You should generally avoid side effects in the expression arguments of
998 this pragma, because these side effects will turn on and off with the
999 setting of the assertions mode, resulting in assertions that have an
1000 effect on the program. However, the expressions are analyzed for
1001 semantic correctness whether or not assertions are enabled, so turning
1002 assertions on and off cannot affect the legality of a program.
1004 @node Pragma Assume_No_Invalid_Values
1005 @unnumberedsec Pragma Assume_No_Invalid_Values
1006 @findex Assume_No_Invalid_Values
1007 @cindex Invalid representations
1008 @cindex Invalid values
1011 @smallexample @c ada
1012 pragma Assume_No_Invalid_Values (On | Off);
1016 This is a configuration pragma that controls the assumptions made by the
1017 compiler about the occurrence of invalid representations (invalid values)
1020 The default behavior (corresponding to an Off argument for this pragma), is
1021 to assume that values may in general be invalid unless the compiler can
1022 prove they are valid. Consider the following example:
1024 @smallexample @c ada
1025 V1 : Integer range 1 .. 10;
1026 V2 : Integer range 11 .. 20;
1028 for J in V2 .. V1 loop
1034 if V1 and V2 have valid values, then the loop is known at compile
1035 time not to execute since the lower bound must be greater than the
1036 upper bound. However in default mode, no such assumption is made,
1037 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1038 is given, the compiler will assume that any occurrence of a variable
1039 other than in an explicit @code{'Valid} test always has a valid
1040 value, and the loop above will be optimized away.
1042 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1043 you know your code is free of uninitialized variables and other
1044 possible sources of invalid representations, and may result in
1045 more efficient code. A program that accesses an invalid representation
1046 with this pragma in effect is erroneous, so no guarantees can be made
1049 It is peculiar though permissible to use this pragma in conjunction
1050 with validity checking (-gnatVa). In such cases, accessing invalid
1051 values will generally give an exception, though formally the program
1052 is erroneous so there are no guarantees that this will always be the
1053 case, and it is recommended that these two options not be used together.
1055 @node Pragma Ast_Entry
1056 @unnumberedsec Pragma Ast_Entry
1061 @smallexample @c ada
1062 pragma AST_Entry (entry_IDENTIFIER);
1066 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1067 argument is the simple name of a single entry; at most one @code{AST_Entry}
1068 pragma is allowed for any given entry. This pragma must be used in
1069 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1070 the entry declaration and in the same task type specification or single task
1071 as the entry to which it applies. This pragma specifies that the given entry
1072 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1073 resulting from an OpenVMS system service call. The pragma does not affect
1074 normal use of the entry. For further details on this pragma, see the
1075 DEC Ada Language Reference Manual, section 9.12a.
1077 @node Pragma C_Pass_By_Copy
1078 @unnumberedsec Pragma C_Pass_By_Copy
1079 @cindex Passing by copy
1080 @findex C_Pass_By_Copy
1083 @smallexample @c ada
1084 pragma C_Pass_By_Copy
1085 ([Max_Size =>] static_integer_EXPRESSION);
1089 Normally the default mechanism for passing C convention records to C
1090 convention subprograms is to pass them by reference, as suggested by RM
1091 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1092 this default, by requiring that record formal parameters be passed by
1093 copy if all of the following conditions are met:
1097 The size of the record type does not exceed the value specified for
1100 The record type has @code{Convention C}.
1102 The formal parameter has this record type, and the subprogram has a
1103 foreign (non-Ada) convention.
1107 If these conditions are met the argument is passed by copy, i.e.@: in a
1108 manner consistent with what C expects if the corresponding formal in the
1109 C prototype is a struct (rather than a pointer to a struct).
1111 You can also pass records by copy by specifying the convention
1112 @code{C_Pass_By_Copy} for the record type, or by using the extended
1113 @code{Import} and @code{Export} pragmas, which allow specification of
1114 passing mechanisms on a parameter by parameter basis.
1117 @unnumberedsec Pragma Check
1119 @cindex Named assertions
1123 @smallexample @c ada
1125 [Name =>] Identifier,
1126 [Check =>] Boolean_EXPRESSION
1127 [, [Message =>] string_EXPRESSION] );
1131 This pragma is similar to the predefined pragma @code{Assert} except that an
1132 extra identifier argument is present. In conjunction with pragma
1133 @code{Check_Policy}, this can be used to define groups of assertions that can
1134 be independently controlled. The identifier @code{Assertion} is special, it
1135 refers to the normal set of pragma @code{Assert} statements. The identifiers
1136 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1137 names, so these three names would normally not be used directly in a pragma
1140 Checks introduced by this pragma are normally deactivated by default. They can
1141 be activated either by the command line option @option{-gnata}, which turns on
1142 all checks, or individually controlled using pragma @code{Check_Policy}.
1144 @node Pragma Check_Name
1145 @unnumberedsec Pragma Check_Name
1146 @cindex Defining check names
1147 @cindex Check names, defining
1151 @smallexample @c ada
1152 pragma Check_Name (check_name_IDENTIFIER);
1156 This is a configuration pragma that defines a new implementation
1157 defined check name (unless IDENTIFIER matches one of the predefined
1158 check names, in which case the pragma has no effect). Check names
1159 are global to a partition, so if two or more configuration pragmas
1160 are present in a partition mentioning the same name, only one new
1161 check name is introduced.
1163 An implementation defined check name introduced with this pragma may
1164 be used in only three contexts: @code{pragma Suppress},
1165 @code{pragma Unsuppress},
1166 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1167 any of these three cases, the check name must be visible. A check
1168 name is visible if it is in the configuration pragmas applying to
1169 the current unit, or if it appears at the start of any unit that
1170 is part of the dependency set of the current unit (e.g., units that
1171 are mentioned in @code{with} clauses).
1173 @node Pragma Check_Policy
1174 @unnumberedsec Pragma Check_Policy
1175 @cindex Controlling assertions
1176 @cindex Assertions, control
1177 @cindex Check pragma control
1178 @cindex Named assertions
1182 @smallexample @c ada
1184 ([Name =>] Identifier,
1185 [Policy =>] POLICY_IDENTIFIER);
1187 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1191 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1192 except that it controls sets of named assertions introduced using the
1193 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1194 @code{Assertion_Policy}) can be used within a declarative part, in which case
1195 it controls the status to the end of the corresponding construct (in a manner
1196 identical to pragma @code{Suppress)}.
1198 The identifier given as the first argument corresponds to a name used in
1199 associated @code{Check} pragmas. For example, if the pragma:
1201 @smallexample @c ada
1202 pragma Check_Policy (Critical_Error, Off);
1206 is given, then subsequent @code{Check} pragmas whose first argument is also
1207 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1208 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1209 @code{Check_Policy} with this identifier is similar to the normal
1210 @code{Assertion_Policy} pragma except that it can appear within a
1213 The special identifiers @code{Precondition} and @code{Postcondition} control
1214 the status of preconditions and postconditions. If a @code{Precondition} pragma
1215 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1216 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1217 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1220 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1221 to turn on corresponding checks. The default for a set of checks for which no
1222 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1223 @option{-gnata} is given, which turns on all checks by default.
1225 The check policy settings @code{Check} and @code{Ignore} are also recognized
1226 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1227 compatibility with the standard @code{Assertion_Policy} pragma.
1229 @node Pragma Comment
1230 @unnumberedsec Pragma Comment
1235 @smallexample @c ada
1236 pragma Comment (static_string_EXPRESSION);
1240 This is almost identical in effect to pragma @code{Ident}. It allows the
1241 placement of a comment into the object file and hence into the
1242 executable file if the operating system permits such usage. The
1243 difference is that @code{Comment}, unlike @code{Ident}, has
1244 no limitations on placement of the pragma (it can be placed
1245 anywhere in the main source unit), and if more than one pragma
1246 is used, all comments are retained.
1248 @node Pragma Common_Object
1249 @unnumberedsec Pragma Common_Object
1250 @findex Common_Object
1254 @smallexample @c ada
1255 pragma Common_Object (
1256 [Internal =>] LOCAL_NAME
1257 [, [External =>] EXTERNAL_SYMBOL]
1258 [, [Size =>] EXTERNAL_SYMBOL] );
1262 | static_string_EXPRESSION
1266 This pragma enables the shared use of variables stored in overlaid
1267 linker areas corresponding to the use of @code{COMMON}
1268 in Fortran. The single
1269 object @var{LOCAL_NAME} is assigned to the area designated by
1270 the @var{External} argument.
1271 You may define a record to correspond to a series
1272 of fields. The @var{Size} argument
1273 is syntax checked in GNAT, but otherwise ignored.
1275 @code{Common_Object} is not supported on all platforms. If no
1276 support is available, then the code generator will issue a message
1277 indicating that the necessary attribute for implementation of this
1278 pragma is not available.
1280 @node Pragma Compile_Time_Error
1281 @unnumberedsec Pragma Compile_Time_Error
1282 @findex Compile_Time_Error
1286 @smallexample @c ada
1287 pragma Compile_Time_Error
1288 (boolean_EXPRESSION, static_string_EXPRESSION);
1292 This pragma can be used to generate additional compile time
1294 is particularly useful in generics, where errors can be issued for
1295 specific problematic instantiations. The first parameter is a boolean
1296 expression. The pragma is effective only if the value of this expression
1297 is known at compile time, and has the value True. The set of expressions
1298 whose values are known at compile time includes all static boolean
1299 expressions, and also other values which the compiler can determine
1300 at compile time (e.g., the size of a record type set by an explicit
1301 size representation clause, or the value of a variable which was
1302 initialized to a constant and is known not to have been modified).
1303 If these conditions are met, an error message is generated using
1304 the value given as the second argument. This string value may contain
1305 embedded ASCII.LF characters to break the message into multiple lines.
1307 @node Pragma Compile_Time_Warning
1308 @unnumberedsec Pragma Compile_Time_Warning
1309 @findex Compile_Time_Warning
1313 @smallexample @c ada
1314 pragma Compile_Time_Warning
1315 (boolean_EXPRESSION, static_string_EXPRESSION);
1319 Same as pragma Compile_Time_Error, except a warning is issued instead
1320 of an error message. Note that if this pragma is used in a package that
1321 is with'ed by a client, the client will get the warning even though it
1322 is issued by a with'ed package (normally warnings in with'ed units are
1323 suppressed, but this is a special exception to that rule).
1325 One typical use is within a generic where compile time known characteristics
1326 of formal parameters are tested, and warnings given appropriately. Another use
1327 with a first parameter of True is to warn a client about use of a package,
1328 for example that it is not fully implemented.
1330 @node Pragma Complete_Representation
1331 @unnumberedsec Pragma Complete_Representation
1332 @findex Complete_Representation
1336 @smallexample @c ada
1337 pragma Complete_Representation;
1341 This pragma must appear immediately within a record representation
1342 clause. Typical placements are before the first component clause
1343 or after the last component clause. The effect is to give an error
1344 message if any component is missing a component clause. This pragma
1345 may be used to ensure that a record representation clause is
1346 complete, and that this invariant is maintained if fields are
1347 added to the record in the future.
1349 @node Pragma Complex_Representation
1350 @unnumberedsec Pragma Complex_Representation
1351 @findex Complex_Representation
1355 @smallexample @c ada
1356 pragma Complex_Representation
1357 ([Entity =>] LOCAL_NAME);
1361 The @var{Entity} argument must be the name of a record type which has
1362 two fields of the same floating-point type. The effect of this pragma is
1363 to force gcc to use the special internal complex representation form for
1364 this record, which may be more efficient. Note that this may result in
1365 the code for this type not conforming to standard ABI (application
1366 binary interface) requirements for the handling of record types. For
1367 example, in some environments, there is a requirement for passing
1368 records by pointer, and the use of this pragma may result in passing
1369 this type in floating-point registers.
1371 @node Pragma Component_Alignment
1372 @unnumberedsec Pragma Component_Alignment
1373 @cindex Alignments of components
1374 @findex Component_Alignment
1378 @smallexample @c ada
1379 pragma Component_Alignment (
1380 [Form =>] ALIGNMENT_CHOICE
1381 [, [Name =>] type_LOCAL_NAME]);
1383 ALIGNMENT_CHOICE ::=
1391 Specifies the alignment of components in array or record types.
1392 The meaning of the @var{Form} argument is as follows:
1395 @findex Component_Size
1396 @item Component_Size
1397 Aligns scalar components and subcomponents of the array or record type
1398 on boundaries appropriate to their inherent size (naturally
1399 aligned). For example, 1-byte components are aligned on byte boundaries,
1400 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1401 integer components are aligned on 4-byte boundaries and so on. These
1402 alignment rules correspond to the normal rules for C compilers on all
1403 machines except the VAX@.
1405 @findex Component_Size_4
1406 @item Component_Size_4
1407 Naturally aligns components with a size of four or fewer
1408 bytes. Components that are larger than 4 bytes are placed on the next
1411 @findex Storage_Unit
1413 Specifies that array or record components are byte aligned, i.e.@:
1414 aligned on boundaries determined by the value of the constant
1415 @code{System.Storage_Unit}.
1419 Specifies that array or record components are aligned on default
1420 boundaries, appropriate to the underlying hardware or operating system or
1421 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1422 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1423 the @code{Default} choice is the same as @code{Component_Size} (natural
1428 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1429 refer to a local record or array type, and the specified alignment
1430 choice applies to the specified type. The use of
1431 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1432 @code{Component_Alignment} pragma to be ignored. The use of
1433 @code{Component_Alignment} together with a record representation clause
1434 is only effective for fields not specified by the representation clause.
1436 If the @code{Name} parameter is absent, the pragma can be used as either
1437 a configuration pragma, in which case it applies to one or more units in
1438 accordance with the normal rules for configuration pragmas, or it can be
1439 used within a declarative part, in which case it applies to types that
1440 are declared within this declarative part, or within any nested scope
1441 within this declarative part. In either case it specifies the alignment
1442 to be applied to any record or array type which has otherwise standard
1445 If the alignment for a record or array type is not specified (using
1446 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1447 clause), the GNAT uses the default alignment as described previously.
1449 @node Pragma Convention_Identifier
1450 @unnumberedsec Pragma Convention_Identifier
1451 @findex Convention_Identifier
1452 @cindex Conventions, synonyms
1456 @smallexample @c ada
1457 pragma Convention_Identifier (
1458 [Name =>] IDENTIFIER,
1459 [Convention =>] convention_IDENTIFIER);
1463 This pragma provides a mechanism for supplying synonyms for existing
1464 convention identifiers. The @code{Name} identifier can subsequently
1465 be used as a synonym for the given convention in other pragmas (including
1466 for example pragma @code{Import} or another @code{Convention_Identifier}
1467 pragma). As an example of the use of this, suppose you had legacy code
1468 which used Fortran77 as the identifier for Fortran. Then the pragma:
1470 @smallexample @c ada
1471 pragma Convention_Identifier (Fortran77, Fortran);
1475 would allow the use of the convention identifier @code{Fortran77} in
1476 subsequent code, avoiding the need to modify the sources. As another
1477 example, you could use this to parametrize convention requirements
1478 according to systems. Suppose you needed to use @code{Stdcall} on
1479 windows systems, and @code{C} on some other system, then you could
1480 define a convention identifier @code{Library} and use a single
1481 @code{Convention_Identifier} pragma to specify which convention
1482 would be used system-wide.
1484 @node Pragma CPP_Class
1485 @unnumberedsec Pragma CPP_Class
1487 @cindex Interfacing with C++
1491 @smallexample @c ada
1492 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1496 The argument denotes an entity in the current declarative region that is
1497 declared as a tagged record type. It indicates that the type corresponds
1498 to an externally declared C++ class type, and is to be laid out the same
1499 way that C++ would lay out the type.
1501 Types for which @code{CPP_Class} is specified do not have assignment or
1502 equality operators defined (such operations can be imported or declared
1503 as subprograms as required). Initialization is allowed only by constructor
1504 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1505 limited if not explicitly declared as limited or derived from a limited
1506 type, and an error is issued in that case.
1508 Pragma @code{CPP_Class} is intended primarily for automatic generation
1509 using an automatic binding generator tool.
1510 See @ref{Interfacing to C++} for related information.
1512 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1513 for backward compatibility but its functionality is available
1514 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1516 @node Pragma CPP_Constructor
1517 @unnumberedsec Pragma CPP_Constructor
1518 @cindex Interfacing with C++
1519 @findex CPP_Constructor
1523 @smallexample @c ada
1524 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1525 [, [External_Name =>] static_string_EXPRESSION ]
1526 [, [Link_Name =>] static_string_EXPRESSION ]);
1530 This pragma identifies an imported function (imported in the usual way
1531 with pragma @code{Import}) as corresponding to a C++ constructor. If
1532 @code{External_Name} and @code{Link_Name} are not specified then the
1533 @code{Entity} argument is a name that must have been previously mentioned
1534 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1535 must be of one of the following forms:
1539 @code{function @var{Fname} return @var{T}'Class}
1542 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1546 where @var{T} is a tagged limited type imported from C++ with pragma
1547 @code{Import} and @code{Convention} = @code{CPP}.
1549 The first form is the default constructor, used when an object of type
1550 @var{T} is created on the Ada side with no explicit constructor. The
1551 second form covers all the non-default constructors of the type. See
1552 the GNAT users guide for details.
1554 If no constructors are imported, it is impossible to create any objects
1555 on the Ada side and the type is implicitly declared abstract.
1557 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1558 using an automatic binding generator tool.
1559 See @ref{Interfacing to C++} for more related information.
1561 @node Pragma CPP_Virtual
1562 @unnumberedsec Pragma CPP_Virtual
1563 @cindex Interfacing to C++
1566 This pragma is now obsolete has has no effect because GNAT generates
1567 the same object layout than the G++ compiler.
1569 See @ref{Interfacing to C++} for related information.
1571 @node Pragma CPP_Vtable
1572 @unnumberedsec Pragma CPP_Vtable
1573 @cindex Interfacing with C++
1576 This pragma is now obsolete has has no effect because GNAT generates
1577 the same object layout than the G++ compiler.
1579 See @ref{Interfacing to C++} for related information.
1582 @unnumberedsec Pragma Debug
1587 @smallexample @c ada
1588 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1590 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1592 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1596 The procedure call argument has the syntactic form of an expression, meeting
1597 the syntactic requirements for pragmas.
1599 If debug pragmas are not enabled or if the condition is present and evaluates
1600 to False, this pragma has no effect. If debug pragmas are enabled, the
1601 semantics of the pragma is exactly equivalent to the procedure call statement
1602 corresponding to the argument with a terminating semicolon. Pragmas are
1603 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1604 intersperse calls to debug procedures in the middle of declarations. Debug
1605 pragmas can be enabled either by use of the command line switch @option{-gnata}
1606 or by use of the configuration pragma @code{Debug_Policy}.
1608 @node Pragma Debug_Policy
1609 @unnumberedsec Pragma Debug_Policy
1610 @findex Debug_Policy
1614 @smallexample @c ada
1615 pragma Debug_Policy (CHECK | IGNORE);
1619 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1620 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1621 This pragma overrides the effect of the @option{-gnata} switch on the
1624 @node Pragma Detect_Blocking
1625 @unnumberedsec Pragma Detect_Blocking
1626 @findex Detect_Blocking
1630 @smallexample @c ada
1631 pragma Detect_Blocking;
1635 This is a configuration pragma that forces the detection of potentially
1636 blocking operations within a protected operation, and to raise Program_Error
1639 @node Pragma Elaboration_Checks
1640 @unnumberedsec Pragma Elaboration_Checks
1641 @cindex Elaboration control
1642 @findex Elaboration_Checks
1646 @smallexample @c ada
1647 pragma Elaboration_Checks (Dynamic | Static);
1651 This is a configuration pragma that provides control over the
1652 elaboration model used by the compilation affected by the
1653 pragma. If the parameter is @code{Dynamic},
1654 then the dynamic elaboration
1655 model described in the Ada Reference Manual is used, as though
1656 the @option{-gnatE} switch had been specified on the command
1657 line. If the parameter is @code{Static}, then the default GNAT static
1658 model is used. This configuration pragma overrides the setting
1659 of the command line. For full details on the elaboration models
1660 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1661 gnat_ugn, @value{EDITION} User's Guide}.
1663 @node Pragma Eliminate
1664 @unnumberedsec Pragma Eliminate
1665 @cindex Elimination of unused subprograms
1670 @smallexample @c ada
1672 [Unit_Name =>] IDENTIFIER |
1673 SELECTED_COMPONENT);
1676 [Unit_Name =>] IDENTIFIER |
1678 [Entity =>] IDENTIFIER |
1679 SELECTED_COMPONENT |
1681 [,OVERLOADING_RESOLUTION]);
1683 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1686 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1689 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1691 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1692 Result_Type => result_SUBTYPE_NAME]
1694 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1695 SUBTYPE_NAME ::= STRING_VALUE
1697 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1698 SOURCE_TRACE ::= STRING_VALUE
1700 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1704 This pragma indicates that the given entity is not used outside the
1705 compilation unit it is defined in. The entity must be an explicitly declared
1706 subprogram; this includes generic subprogram instances and
1707 subprograms declared in generic package instances.
1709 If the entity to be eliminated is a library level subprogram, then
1710 the first form of pragma @code{Eliminate} is used with only a single argument.
1711 In this form, the @code{Unit_Name} argument specifies the name of the
1712 library level unit to be eliminated.
1714 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1715 are required. If item is an entity of a library package, then the first
1716 argument specifies the unit name, and the second argument specifies
1717 the particular entity. If the second argument is in string form, it must
1718 correspond to the internal manner in which GNAT stores entity names (see
1719 compilation unit Namet in the compiler sources for details).
1721 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1722 to distinguish between overloaded subprograms. If a pragma does not contain
1723 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1724 subprograms denoted by the first two parameters.
1726 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1727 to be eliminated in a manner similar to that used for the extended
1728 @code{Import} and @code{Export} pragmas, except that the subtype names are
1729 always given as strings. At the moment, this form of distinguishing
1730 overloaded subprograms is implemented only partially, so we do not recommend
1731 using it for practical subprogram elimination.
1733 Note that in case of a parameterless procedure its profile is represented
1734 as @code{Parameter_Types => ("")}
1736 Alternatively, the @code{Source_Location} parameter is used to specify
1737 which overloaded alternative is to be eliminated by pointing to the
1738 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1739 source text. The string literal (or concatenation of string literals)
1740 given as SOURCE_TRACE must have the following format:
1742 @smallexample @c ada
1743 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1748 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1749 FILE_NAME ::= STRING_LITERAL
1750 LINE_NUMBER ::= DIGIT @{DIGIT@}
1753 SOURCE_TRACE should be the short name of the source file (with no directory
1754 information), and LINE_NUMBER is supposed to point to the line where the
1755 defining name of the subprogram is located.
1757 For the subprograms that are not a part of generic instantiations, only one
1758 SOURCE_LOCATION is used. If a subprogram is declared in a package
1759 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1760 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1761 second one denotes the declaration of the corresponding subprogram in the
1762 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1763 in case of nested instantiations.
1765 The effect of the pragma is to allow the compiler to eliminate
1766 the code or data associated with the named entity. Any reference to
1767 an eliminated entity outside the compilation unit it is defined in,
1768 causes a compile time or link time error.
1770 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1771 in a system independent manner, with unused entities eliminated, without
1772 the requirement of modifying the source text. Normally the required set
1773 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1774 tool. Elimination of unused entities local to a compilation unit is
1775 automatic, without requiring the use of pragma @code{Eliminate}.
1777 Note that the reason this pragma takes string literals where names might
1778 be expected is that a pragma @code{Eliminate} can appear in a context where the
1779 relevant names are not visible.
1781 Note that any change in the source files that includes removing, splitting of
1782 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1785 It is legal to use pragma Eliminate where the referenced entity is a
1786 dispatching operation, but it is not clear what this would mean, since
1787 in general the call does not know which entity is actually being called.
1788 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1790 @node Pragma Export_Exception
1791 @unnumberedsec Pragma Export_Exception
1793 @findex Export_Exception
1797 @smallexample @c ada
1798 pragma Export_Exception (
1799 [Internal =>] LOCAL_NAME
1800 [, [External =>] EXTERNAL_SYMBOL]
1801 [, [Form =>] Ada | VMS]
1802 [, [Code =>] static_integer_EXPRESSION]);
1806 | static_string_EXPRESSION
1810 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1811 causes the specified exception to be propagated outside of the Ada program,
1812 so that it can be handled by programs written in other OpenVMS languages.
1813 This pragma establishes an external name for an Ada exception and makes the
1814 name available to the OpenVMS Linker as a global symbol. For further details
1815 on this pragma, see the
1816 DEC Ada Language Reference Manual, section 13.9a3.2.
1818 @node Pragma Export_Function
1819 @unnumberedsec Pragma Export_Function
1820 @cindex Argument passing mechanisms
1821 @findex Export_Function
1826 @smallexample @c ada
1827 pragma Export_Function (
1828 [Internal =>] LOCAL_NAME
1829 [, [External =>] EXTERNAL_SYMBOL]
1830 [, [Parameter_Types =>] PARAMETER_TYPES]
1831 [, [Result_Type =>] result_SUBTYPE_MARK]
1832 [, [Mechanism =>] MECHANISM]
1833 [, [Result_Mechanism =>] MECHANISM_NAME]);
1837 | static_string_EXPRESSION
1842 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1846 | subtype_Name ' Access
1850 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1852 MECHANISM_ASSOCIATION ::=
1853 [formal_parameter_NAME =>] MECHANISM_NAME
1858 | Descriptor [([Class =>] CLASS_NAME)]
1859 | Short_Descriptor [([Class =>] CLASS_NAME)]
1861 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1865 Use this pragma to make a function externally callable and optionally
1866 provide information on mechanisms to be used for passing parameter and
1867 result values. We recommend, for the purposes of improving portability,
1868 this pragma always be used in conjunction with a separate pragma
1869 @code{Export}, which must precede the pragma @code{Export_Function}.
1870 GNAT does not require a separate pragma @code{Export}, but if none is
1871 present, @code{Convention Ada} is assumed, which is usually
1872 not what is wanted, so it is usually appropriate to use this
1873 pragma in conjunction with a @code{Export} or @code{Convention}
1874 pragma that specifies the desired foreign convention.
1875 Pragma @code{Export_Function}
1876 (and @code{Export}, if present) must appear in the same declarative
1877 region as the function to which they apply.
1879 @var{internal_name} must uniquely designate the function to which the
1880 pragma applies. If more than one function name exists of this name in
1881 the declarative part you must use the @code{Parameter_Types} and
1882 @code{Result_Type} parameters is mandatory to achieve the required
1883 unique designation. @var{subtype_mark}s in these parameters must
1884 exactly match the subtypes in the corresponding function specification,
1885 using positional notation to match parameters with subtype marks.
1886 The form with an @code{'Access} attribute can be used to match an
1887 anonymous access parameter.
1890 @cindex Passing by descriptor
1891 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1892 The default behavior for Export_Function is to accept either 64bit or
1893 32bit descriptors unless short_descriptor is specified, then only 32bit
1894 descriptors are accepted.
1896 @cindex Suppressing external name
1897 Special treatment is given if the EXTERNAL is an explicit null
1898 string or a static string expressions that evaluates to the null
1899 string. In this case, no external name is generated. This form
1900 still allows the specification of parameter mechanisms.
1902 @node Pragma Export_Object
1903 @unnumberedsec Pragma Export_Object
1904 @findex Export_Object
1908 @smallexample @c ada
1909 pragma Export_Object
1910 [Internal =>] LOCAL_NAME
1911 [, [External =>] EXTERNAL_SYMBOL]
1912 [, [Size =>] EXTERNAL_SYMBOL]
1916 | static_string_EXPRESSION
1920 This pragma designates an object as exported, and apart from the
1921 extended rules for external symbols, is identical in effect to the use of
1922 the normal @code{Export} pragma applied to an object. You may use a
1923 separate Export pragma (and you probably should from the point of view
1924 of portability), but it is not required. @var{Size} is syntax checked,
1925 but otherwise ignored by GNAT@.
1927 @node Pragma Export_Procedure
1928 @unnumberedsec Pragma Export_Procedure
1929 @findex Export_Procedure
1933 @smallexample @c ada
1934 pragma Export_Procedure (
1935 [Internal =>] LOCAL_NAME
1936 [, [External =>] EXTERNAL_SYMBOL]
1937 [, [Parameter_Types =>] PARAMETER_TYPES]
1938 [, [Mechanism =>] MECHANISM]);
1942 | static_string_EXPRESSION
1947 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1951 | subtype_Name ' Access
1955 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1957 MECHANISM_ASSOCIATION ::=
1958 [formal_parameter_NAME =>] MECHANISM_NAME
1963 | Descriptor [([Class =>] CLASS_NAME)]
1964 | Short_Descriptor [([Class =>] CLASS_NAME)]
1966 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1970 This pragma is identical to @code{Export_Function} except that it
1971 applies to a procedure rather than a function and the parameters
1972 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1973 GNAT does not require a separate pragma @code{Export}, but if none is
1974 present, @code{Convention Ada} is assumed, which is usually
1975 not what is wanted, so it is usually appropriate to use this
1976 pragma in conjunction with a @code{Export} or @code{Convention}
1977 pragma that specifies the desired foreign convention.
1980 @cindex Passing by descriptor
1981 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1982 The default behavior for Export_Procedure is to accept either 64bit or
1983 32bit descriptors unless short_descriptor is specified, then only 32bit
1984 descriptors are accepted.
1986 @cindex Suppressing external name
1987 Special treatment is given if the EXTERNAL is an explicit null
1988 string or a static string expressions that evaluates to the null
1989 string. In this case, no external name is generated. This form
1990 still allows the specification of parameter mechanisms.
1992 @node Pragma Export_Value
1993 @unnumberedsec Pragma Export_Value
1994 @findex Export_Value
1998 @smallexample @c ada
1999 pragma Export_Value (
2000 [Value =>] static_integer_EXPRESSION,
2001 [Link_Name =>] static_string_EXPRESSION);
2005 This pragma serves to export a static integer value for external use.
2006 The first argument specifies the value to be exported. The Link_Name
2007 argument specifies the symbolic name to be associated with the integer
2008 value. This pragma is useful for defining a named static value in Ada
2009 that can be referenced in assembly language units to be linked with
2010 the application. This pragma is currently supported only for the
2011 AAMP target and is ignored for other targets.
2013 @node Pragma Export_Valued_Procedure
2014 @unnumberedsec Pragma Export_Valued_Procedure
2015 @findex Export_Valued_Procedure
2019 @smallexample @c ada
2020 pragma Export_Valued_Procedure (
2021 [Internal =>] LOCAL_NAME
2022 [, [External =>] EXTERNAL_SYMBOL]
2023 [, [Parameter_Types =>] PARAMETER_TYPES]
2024 [, [Mechanism =>] MECHANISM]);
2028 | static_string_EXPRESSION
2033 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2037 | subtype_Name ' Access
2041 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2043 MECHANISM_ASSOCIATION ::=
2044 [formal_parameter_NAME =>] MECHANISM_NAME
2049 | Descriptor [([Class =>] CLASS_NAME)]
2050 | Short_Descriptor [([Class =>] CLASS_NAME)]
2052 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2056 This pragma is identical to @code{Export_Procedure} except that the
2057 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2058 mode @code{OUT}, and externally the subprogram is treated as a function
2059 with this parameter as the result of the function. GNAT provides for
2060 this capability to allow the use of @code{OUT} and @code{IN OUT}
2061 parameters in interfacing to external functions (which are not permitted
2063 GNAT does not require a separate pragma @code{Export}, but if none is
2064 present, @code{Convention Ada} is assumed, which is almost certainly
2065 not what is wanted since the whole point of this pragma is to interface
2066 with foreign language functions, so it is usually appropriate to use this
2067 pragma in conjunction with a @code{Export} or @code{Convention}
2068 pragma that specifies the desired foreign convention.
2071 @cindex Passing by descriptor
2072 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2073 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2074 32bit descriptors unless short_descriptor is specified, then only 32bit
2075 descriptors are accepted.
2077 @cindex Suppressing external name
2078 Special treatment is given if the EXTERNAL is an explicit null
2079 string or a static string expressions that evaluates to the null
2080 string. In this case, no external name is generated. This form
2081 still allows the specification of parameter mechanisms.
2083 @node Pragma Extend_System
2084 @unnumberedsec Pragma Extend_System
2085 @cindex @code{system}, extending
2087 @findex Extend_System
2091 @smallexample @c ada
2092 pragma Extend_System ([Name =>] IDENTIFIER);
2096 This pragma is used to provide backwards compatibility with other
2097 implementations that extend the facilities of package @code{System}. In
2098 GNAT, @code{System} contains only the definitions that are present in
2099 the Ada RM@. However, other implementations, notably the DEC Ada 83
2100 implementation, provide many extensions to package @code{System}.
2102 For each such implementation accommodated by this pragma, GNAT provides a
2103 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2104 implementation, which provides the required additional definitions. You
2105 can use this package in two ways. You can @code{with} it in the normal
2106 way and access entities either by selection or using a @code{use}
2107 clause. In this case no special processing is required.
2109 However, if existing code contains references such as
2110 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2111 definitions provided in package @code{System}, you may use this pragma
2112 to extend visibility in @code{System} in a non-standard way that
2113 provides greater compatibility with the existing code. Pragma
2114 @code{Extend_System} is a configuration pragma whose single argument is
2115 the name of the package containing the extended definition
2116 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2117 control of this pragma will be processed using special visibility
2118 processing that looks in package @code{System.Aux_@var{xxx}} where
2119 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2120 package @code{System}, but not found in package @code{System}.
2122 You can use this pragma either to access a predefined @code{System}
2123 extension supplied with the compiler, for example @code{Aux_DEC} or
2124 you can construct your own extension unit following the above
2125 definition. Note that such a package is a child of @code{System}
2126 and thus is considered part of the implementation. To compile
2127 it you will have to use the appropriate switch for compiling
2128 system units. @xref{Top, @value{EDITION} User's Guide, About This
2129 Guide,, gnat_ugn, @value{EDITION} User's Guide}, for details.
2131 @node Pragma External
2132 @unnumberedsec Pragma External
2137 @smallexample @c ada
2139 [ Convention =>] convention_IDENTIFIER,
2140 [ Entity =>] LOCAL_NAME
2141 [, [External_Name =>] static_string_EXPRESSION ]
2142 [, [Link_Name =>] static_string_EXPRESSION ]);
2146 This pragma is identical in syntax and semantics to pragma
2147 @code{Export} as defined in the Ada Reference Manual. It is
2148 provided for compatibility with some Ada 83 compilers that
2149 used this pragma for exactly the same purposes as pragma
2150 @code{Export} before the latter was standardized.
2152 @node Pragma External_Name_Casing
2153 @unnumberedsec Pragma External_Name_Casing
2154 @cindex Dec Ada 83 casing compatibility
2155 @cindex External Names, casing
2156 @cindex Casing of External names
2157 @findex External_Name_Casing
2161 @smallexample @c ada
2162 pragma External_Name_Casing (
2163 Uppercase | Lowercase
2164 [, Uppercase | Lowercase | As_Is]);
2168 This pragma provides control over the casing of external names associated
2169 with Import and Export pragmas. There are two cases to consider:
2172 @item Implicit external names
2173 Implicit external names are derived from identifiers. The most common case
2174 arises when a standard Ada Import or Export pragma is used with only two
2177 @smallexample @c ada
2178 pragma Import (C, C_Routine);
2182 Since Ada is a case-insensitive language, the spelling of the identifier in
2183 the Ada source program does not provide any information on the desired
2184 casing of the external name, and so a convention is needed. In GNAT the
2185 default treatment is that such names are converted to all lower case
2186 letters. This corresponds to the normal C style in many environments.
2187 The first argument of pragma @code{External_Name_Casing} can be used to
2188 control this treatment. If @code{Uppercase} is specified, then the name
2189 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2190 then the normal default of all lower case letters will be used.
2192 This same implicit treatment is also used in the case of extended DEC Ada 83
2193 compatible Import and Export pragmas where an external name is explicitly
2194 specified using an identifier rather than a string.
2196 @item Explicit external names
2197 Explicit external names are given as string literals. The most common case
2198 arises when a standard Ada Import or Export pragma is used with three
2201 @smallexample @c ada
2202 pragma Import (C, C_Routine, "C_routine");
2206 In this case, the string literal normally provides the exact casing required
2207 for the external name. The second argument of pragma
2208 @code{External_Name_Casing} may be used to modify this behavior.
2209 If @code{Uppercase} is specified, then the name
2210 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2211 then the name will be forced to all lowercase letters. A specification of
2212 @code{As_Is} provides the normal default behavior in which the casing is
2213 taken from the string provided.
2217 This pragma may appear anywhere that a pragma is valid. In particular, it
2218 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2219 case it applies to all subsequent compilations, or it can be used as a program
2220 unit pragma, in which case it only applies to the current unit, or it can
2221 be used more locally to control individual Import/Export pragmas.
2223 It is primarily intended for use with OpenVMS systems, where many
2224 compilers convert all symbols to upper case by default. For interfacing to
2225 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2228 @smallexample @c ada
2229 pragma External_Name_Casing (Uppercase, Uppercase);
2233 to enforce the upper casing of all external symbols.
2235 @node Pragma Fast_Math
2236 @unnumberedsec Pragma Fast_Math
2241 @smallexample @c ada
2246 This is a configuration pragma which activates a mode in which speed is
2247 considered more important for floating-point operations than absolutely
2248 accurate adherence to the requirements of the standard. Currently the
2249 following operations are affected:
2252 @item Complex Multiplication
2253 The normal simple formula for complex multiplication can result in intermediate
2254 overflows for numbers near the end of the range. The Ada standard requires that
2255 this situation be detected and corrected by scaling, but in Fast_Math mode such
2256 cases will simply result in overflow. Note that to take advantage of this you
2257 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2258 under control of the pragma, rather than use the preinstantiated versions.
2261 @node Pragma Favor_Top_Level
2262 @unnumberedsec Pragma Favor_Top_Level
2263 @findex Favor_Top_Level
2267 @smallexample @c ada
2268 pragma Favor_Top_Level (type_NAME);
2272 The named type must be an access-to-subprogram type. This pragma is an
2273 efficiency hint to the compiler, regarding the use of 'Access or
2274 'Unrestricted_Access on nested (non-library-level) subprograms. The
2275 pragma means that nested subprograms are not used with this type, or
2276 are rare, so that the generated code should be efficient in the
2277 top-level case. When this pragma is used, dynamically generated
2278 trampolines may be used on some targets for nested subprograms.
2279 See also the No_Implicit_Dynamic_Code restriction.
2281 @node Pragma Finalize_Storage_Only
2282 @unnumberedsec Pragma Finalize_Storage_Only
2283 @findex Finalize_Storage_Only
2287 @smallexample @c ada
2288 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2292 This pragma allows the compiler not to emit a Finalize call for objects
2293 defined at the library level. This is mostly useful for types where
2294 finalization is only used to deal with storage reclamation since in most
2295 environments it is not necessary to reclaim memory just before terminating
2296 execution, hence the name.
2298 @node Pragma Float_Representation
2299 @unnumberedsec Pragma Float_Representation
2301 @findex Float_Representation
2305 @smallexample @c ada
2306 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2308 FLOAT_REP ::= VAX_Float | IEEE_Float
2312 In the one argument form, this pragma is a configuration pragma which
2313 allows control over the internal representation chosen for the predefined
2314 floating point types declared in the packages @code{Standard} and
2315 @code{System}. On all systems other than OpenVMS, the argument must
2316 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2317 argument may be @code{VAX_Float} to specify the use of the VAX float
2318 format for the floating-point types in Standard. This requires that
2319 the standard runtime libraries be recompiled. @xref{The GNAT Run-Time
2320 Library Builder gnatlbr,,, gnat_ugn, @value{EDITION} User's Guide
2321 OpenVMS}, for a description of the @code{GNAT LIBRARY} command.
2323 The two argument form specifies the representation to be used for
2324 the specified floating-point type. On all systems other than OpenVMS,
2326 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2327 argument may be @code{VAX_Float} to specify the use of the VAX float
2332 For digits values up to 6, F float format will be used.
2334 For digits values from 7 to 9, G float format will be used.
2336 For digits values from 10 to 15, F float format will be used.
2338 Digits values above 15 are not allowed.
2342 @unnumberedsec Pragma Ident
2347 @smallexample @c ada
2348 pragma Ident (static_string_EXPRESSION);
2352 This pragma provides a string identification in the generated object file,
2353 if the system supports the concept of this kind of identification string.
2354 This pragma is allowed only in the outermost declarative part or
2355 declarative items of a compilation unit. If more than one @code{Ident}
2356 pragma is given, only the last one processed is effective.
2358 On OpenVMS systems, the effect of the pragma is identical to the effect of
2359 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2360 maximum allowed length is 31 characters, so if it is important to
2361 maintain compatibility with this compiler, you should obey this length
2364 @node Pragma Implemented_By_Entry
2365 @unnumberedsec Pragma Implemented_By_Entry
2366 @findex Implemented_By_Entry
2370 @smallexample @c ada
2371 pragma Implemented_By_Entry (LOCAL_NAME);
2375 This is a representation pragma which applies to protected, synchronized and
2376 task interface primitives. If the pragma is applied to primitive operation Op
2377 of interface Iface, it is illegal to override Op in a type that implements
2378 Iface, with anything other than an entry.
2380 @smallexample @c ada
2381 type Iface is protected interface;
2382 procedure Do_Something (Object : in out Iface) is abstract;
2383 pragma Implemented_By_Entry (Do_Something);
2385 protected type P is new Iface with
2386 procedure Do_Something; -- Illegal
2389 task type T is new Iface with
2390 entry Do_Something; -- Legal
2395 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2396 is intended to be used in conjunction with dispatching requeue statements as
2397 described in AI05-0030. Should the ARG decide on an official name and syntax,
2398 this pragma will become language-defined rather than GNAT-specific.
2400 @node Pragma Implicit_Packing
2401 @unnumberedsec Pragma Implicit_Packing
2402 @findex Implicit_Packing
2406 @smallexample @c ada
2407 pragma Implicit_Packing;
2411 This is a configuration pragma that requests implicit packing for packed
2412 arrays for which a size clause is given but no explicit pragma Pack or
2413 specification of Component_Size is present. It also applies to records
2414 where no record representation clause is present. Consider this example:
2416 @smallexample @c ada
2417 type R is array (0 .. 7) of Boolean;
2422 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2423 does not change the layout of a composite object. So the Size clause in the
2424 above example is normally rejected, since the default layout of the array uses
2425 8-bit components, and thus the array requires a minimum of 64 bits.
2427 If this declaration is compiled in a region of code covered by an occurrence
2428 of the configuration pragma Implicit_Packing, then the Size clause in this
2429 and similar examples will cause implicit packing and thus be accepted. For
2430 this implicit packing to occur, the type in question must be an array of small
2431 components whose size is known at compile time, and the Size clause must
2432 specify the exact size that corresponds to the length of the array multiplied
2433 by the size in bits of the component type.
2434 @cindex Array packing
2436 Similarly, the following example shows the use in the record case
2438 @smallexample @c ada
2440 a, b, c, d, e, f, g, h : boolean;
2447 Without a pragma Pack, each Boolean field requires 8 bits, so the
2448 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2449 sufficient. The use of pragma Implciit_Packing allows this record
2450 declaration to compile without an explicit pragma Pack.
2451 @node Pragma Import_Exception
2452 @unnumberedsec Pragma Import_Exception
2454 @findex Import_Exception
2458 @smallexample @c ada
2459 pragma Import_Exception (
2460 [Internal =>] LOCAL_NAME
2461 [, [External =>] EXTERNAL_SYMBOL]
2462 [, [Form =>] Ada | VMS]
2463 [, [Code =>] static_integer_EXPRESSION]);
2467 | static_string_EXPRESSION
2471 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2472 It allows OpenVMS conditions (for example, from OpenVMS system services or
2473 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2474 The pragma specifies that the exception associated with an exception
2475 declaration in an Ada program be defined externally (in non-Ada code).
2476 For further details on this pragma, see the
2477 DEC Ada Language Reference Manual, section 13.9a.3.1.
2479 @node Pragma Import_Function
2480 @unnumberedsec Pragma Import_Function
2481 @findex Import_Function
2485 @smallexample @c ada
2486 pragma Import_Function (
2487 [Internal =>] LOCAL_NAME,
2488 [, [External =>] EXTERNAL_SYMBOL]
2489 [, [Parameter_Types =>] PARAMETER_TYPES]
2490 [, [Result_Type =>] SUBTYPE_MARK]
2491 [, [Mechanism =>] MECHANISM]
2492 [, [Result_Mechanism =>] MECHANISM_NAME]
2493 [, [First_Optional_Parameter =>] IDENTIFIER]);
2497 | static_string_EXPRESSION
2501 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2505 | subtype_Name ' Access
2509 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2511 MECHANISM_ASSOCIATION ::=
2512 [formal_parameter_NAME =>] MECHANISM_NAME
2517 | Descriptor [([Class =>] CLASS_NAME)]
2518 | Short_Descriptor [([Class =>] CLASS_NAME)]
2520 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2524 This pragma is used in conjunction with a pragma @code{Import} to
2525 specify additional information for an imported function. The pragma
2526 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2527 @code{Import_Function} pragma and both must appear in the same
2528 declarative part as the function specification.
2530 The @var{Internal} argument must uniquely designate
2531 the function to which the
2532 pragma applies. If more than one function name exists of this name in
2533 the declarative part you must use the @code{Parameter_Types} and
2534 @var{Result_Type} parameters to achieve the required unique
2535 designation. Subtype marks in these parameters must exactly match the
2536 subtypes in the corresponding function specification, using positional
2537 notation to match parameters with subtype marks.
2538 The form with an @code{'Access} attribute can be used to match an
2539 anonymous access parameter.
2541 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2542 parameters to specify passing mechanisms for the
2543 parameters and result. If you specify a single mechanism name, it
2544 applies to all parameters. Otherwise you may specify a mechanism on a
2545 parameter by parameter basis using either positional or named
2546 notation. If the mechanism is not specified, the default mechanism
2550 @cindex Passing by descriptor
2551 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2552 The default behavior for Import_Function is to pass a 64bit descriptor
2553 unless short_descriptor is specified, then a 32bit descriptor is passed.
2555 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2556 It specifies that the designated parameter and all following parameters
2557 are optional, meaning that they are not passed at the generated code
2558 level (this is distinct from the notion of optional parameters in Ada
2559 where the parameters are passed anyway with the designated optional
2560 parameters). All optional parameters must be of mode @code{IN} and have
2561 default parameter values that are either known at compile time
2562 expressions, or uses of the @code{'Null_Parameter} attribute.
2564 @node Pragma Import_Object
2565 @unnumberedsec Pragma Import_Object
2566 @findex Import_Object
2570 @smallexample @c ada
2571 pragma Import_Object
2572 [Internal =>] LOCAL_NAME
2573 [, [External =>] EXTERNAL_SYMBOL]
2574 [, [Size =>] EXTERNAL_SYMBOL]);
2578 | static_string_EXPRESSION
2582 This pragma designates an object as imported, and apart from the
2583 extended rules for external symbols, is identical in effect to the use of
2584 the normal @code{Import} pragma applied to an object. Unlike the
2585 subprogram case, you need not use a separate @code{Import} pragma,
2586 although you may do so (and probably should do so from a portability
2587 point of view). @var{size} is syntax checked, but otherwise ignored by
2590 @node Pragma Import_Procedure
2591 @unnumberedsec Pragma Import_Procedure
2592 @findex Import_Procedure
2596 @smallexample @c ada
2597 pragma Import_Procedure (
2598 [Internal =>] LOCAL_NAME
2599 [, [External =>] EXTERNAL_SYMBOL]
2600 [, [Parameter_Types =>] PARAMETER_TYPES]
2601 [, [Mechanism =>] MECHANISM]
2602 [, [First_Optional_Parameter =>] IDENTIFIER]);
2606 | static_string_EXPRESSION
2610 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2614 | subtype_Name ' Access
2618 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2620 MECHANISM_ASSOCIATION ::=
2621 [formal_parameter_NAME =>] MECHANISM_NAME
2626 | Descriptor [([Class =>] CLASS_NAME)]
2627 | Short_Descriptor [([Class =>] CLASS_NAME)]
2629 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2633 This pragma is identical to @code{Import_Function} except that it
2634 applies to a procedure rather than a function and the parameters
2635 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2637 @node Pragma Import_Valued_Procedure
2638 @unnumberedsec Pragma Import_Valued_Procedure
2639 @findex Import_Valued_Procedure
2643 @smallexample @c ada
2644 pragma Import_Valued_Procedure (
2645 [Internal =>] LOCAL_NAME
2646 [, [External =>] EXTERNAL_SYMBOL]
2647 [, [Parameter_Types =>] PARAMETER_TYPES]
2648 [, [Mechanism =>] MECHANISM]
2649 [, [First_Optional_Parameter =>] IDENTIFIER]);
2653 | static_string_EXPRESSION
2657 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2661 | subtype_Name ' Access
2665 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2667 MECHANISM_ASSOCIATION ::=
2668 [formal_parameter_NAME =>] MECHANISM_NAME
2673 | Descriptor [([Class =>] CLASS_NAME)]
2674 | Short_Descriptor [([Class =>] CLASS_NAME)]
2676 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2680 This pragma is identical to @code{Import_Procedure} except that the
2681 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2682 mode @code{OUT}, and externally the subprogram is treated as a function
2683 with this parameter as the result of the function. The purpose of this
2684 capability is to allow the use of @code{OUT} and @code{IN OUT}
2685 parameters in interfacing to external functions (which are not permitted
2686 in Ada functions). You may optionally use the @code{Mechanism}
2687 parameters to specify passing mechanisms for the parameters.
2688 If you specify a single mechanism name, it applies to all parameters.
2689 Otherwise you may specify a mechanism on a parameter by parameter
2690 basis using either positional or named notation. If the mechanism is not
2691 specified, the default mechanism is used.
2693 Note that it is important to use this pragma in conjunction with a separate
2694 pragma Import that specifies the desired convention, since otherwise the
2695 default convention is Ada, which is almost certainly not what is required.
2697 @node Pragma Initialize_Scalars
2698 @unnumberedsec Pragma Initialize_Scalars
2699 @findex Initialize_Scalars
2700 @cindex debugging with Initialize_Scalars
2704 @smallexample @c ada
2705 pragma Initialize_Scalars;
2709 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2710 two important differences. First, there is no requirement for the pragma
2711 to be used uniformly in all units of a partition, in particular, it is fine
2712 to use this just for some or all of the application units of a partition,
2713 without needing to recompile the run-time library.
2715 In the case where some units are compiled with the pragma, and some without,
2716 then a declaration of a variable where the type is defined in package
2717 Standard or is locally declared will always be subject to initialization,
2718 as will any declaration of a scalar variable. For composite variables,
2719 whether the variable is initialized may also depend on whether the package
2720 in which the type of the variable is declared is compiled with the pragma.
2722 The other important difference is that you can control the value used
2723 for initializing scalar objects. At bind time, you can select several
2724 options for initialization. You can
2725 initialize with invalid values (similar to Normalize_Scalars, though for
2726 Initialize_Scalars it is not always possible to determine the invalid
2727 values in complex cases like signed component fields with non-standard
2728 sizes). You can also initialize with high or
2729 low values, or with a specified bit pattern. See the users guide for binder
2730 options for specifying these cases.
2732 This means that you can compile a program, and then without having to
2733 recompile the program, you can run it with different values being used
2734 for initializing otherwise uninitialized values, to test if your program
2735 behavior depends on the choice. Of course the behavior should not change,
2736 and if it does, then most likely you have an erroneous reference to an
2737 uninitialized value.
2739 It is even possible to change the value at execution time eliminating even
2740 the need to rebind with a different switch using an environment variable.
2741 See the GNAT users guide for details.
2743 Note that pragma @code{Initialize_Scalars} is particularly useful in
2744 conjunction with the enhanced validity checking that is now provided
2745 in GNAT, which checks for invalid values under more conditions.
2746 Using this feature (see description of the @option{-gnatV} flag in the
2747 users guide) in conjunction with pragma @code{Initialize_Scalars}
2748 provides a powerful new tool to assist in the detection of problems
2749 caused by uninitialized variables.
2751 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2752 effect on the generated code. This may cause your code to be
2753 substantially larger. It may also cause an increase in the amount
2754 of stack required, so it is probably a good idea to turn on stack
2755 checking (see description of stack checking in the GNAT users guide)
2756 when using this pragma.
2758 @node Pragma Inline_Always
2759 @unnumberedsec Pragma Inline_Always
2760 @findex Inline_Always
2764 @smallexample @c ada
2765 pragma Inline_Always (NAME [, NAME]);
2769 Similar to pragma @code{Inline} except that inlining is not subject to
2770 the use of option @option{-gnatn} and the inlining happens regardless of
2771 whether this option is used.
2773 @node Pragma Inline_Generic
2774 @unnumberedsec Pragma Inline_Generic
2775 @findex Inline_Generic
2779 @smallexample @c ada
2780 pragma Inline_Generic (generic_package_NAME);
2784 This is implemented for compatibility with DEC Ada 83 and is recognized,
2785 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2786 by default when using GNAT@.
2788 @node Pragma Interface
2789 @unnumberedsec Pragma Interface
2794 @smallexample @c ada
2796 [Convention =>] convention_identifier,
2797 [Entity =>] local_NAME
2798 [, [External_Name =>] static_string_expression]
2799 [, [Link_Name =>] static_string_expression]);
2803 This pragma is identical in syntax and semantics to
2804 the standard Ada pragma @code{Import}. It is provided for compatibility
2805 with Ada 83. The definition is upwards compatible both with pragma
2806 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2807 with some extended implementations of this pragma in certain Ada 83
2810 @node Pragma Interface_Name
2811 @unnumberedsec Pragma Interface_Name
2812 @findex Interface_Name
2816 @smallexample @c ada
2817 pragma Interface_Name (
2818 [Entity =>] LOCAL_NAME
2819 [, [External_Name =>] static_string_EXPRESSION]
2820 [, [Link_Name =>] static_string_EXPRESSION]);
2824 This pragma provides an alternative way of specifying the interface name
2825 for an interfaced subprogram, and is provided for compatibility with Ada
2826 83 compilers that use the pragma for this purpose. You must provide at
2827 least one of @var{External_Name} or @var{Link_Name}.
2829 @node Pragma Interrupt_Handler
2830 @unnumberedsec Pragma Interrupt_Handler
2831 @findex Interrupt_Handler
2835 @smallexample @c ada
2836 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2840 This program unit pragma is supported for parameterless protected procedures
2841 as described in Annex C of the Ada Reference Manual. On the AAMP target
2842 the pragma can also be specified for nonprotected parameterless procedures
2843 that are declared at the library level (which includes procedures
2844 declared at the top level of a library package). In the case of AAMP,
2845 when this pragma is applied to a nonprotected procedure, the instruction
2846 @code{IERET} is generated for returns from the procedure, enabling
2847 maskable interrupts, in place of the normal return instruction.
2849 @node Pragma Interrupt_State
2850 @unnumberedsec Pragma Interrupt_State
2851 @findex Interrupt_State
2855 @smallexample @c ada
2856 pragma Interrupt_State
2858 [State =>] SYSTEM | RUNTIME | USER);
2862 Normally certain interrupts are reserved to the implementation. Any attempt
2863 to attach an interrupt causes Program_Error to be raised, as described in
2864 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
2865 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
2866 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2867 interrupt execution. Additionally, signals such as @code{SIGSEGV},
2868 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2869 Ada exceptions, or used to implement run-time functions such as the
2870 @code{abort} statement and stack overflow checking.
2872 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2873 such uses of interrupts. It subsumes the functionality of pragma
2874 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
2875 available on OS/2, Windows or VMS. On all other platforms than VxWorks,
2876 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2877 and may be used to mark interrupts required by the board support package
2880 Interrupts can be in one of three states:
2884 The interrupt is reserved (no Ada handler can be installed), and the
2885 Ada run-time may not install a handler. As a result you are guaranteed
2886 standard system default action if this interrupt is raised.
2890 The interrupt is reserved (no Ada handler can be installed). The run time
2891 is allowed to install a handler for internal control purposes, but is
2892 not required to do so.
2896 The interrupt is unreserved. The user may install a handler to provide
2901 These states are the allowed values of the @code{State} parameter of the
2902 pragma. The @code{Name} parameter is a value of the type
2903 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
2904 @code{Ada.Interrupts.Names}.
2906 This is a configuration pragma, and the binder will check that there
2907 are no inconsistencies between different units in a partition in how a
2908 given interrupt is specified. It may appear anywhere a pragma is legal.
2910 The effect is to move the interrupt to the specified state.
2912 By declaring interrupts to be SYSTEM, you guarantee the standard system
2913 action, such as a core dump.
2915 By declaring interrupts to be USER, you guarantee that you can install
2918 Note that certain signals on many operating systems cannot be caught and
2919 handled by applications. In such cases, the pragma is ignored. See the
2920 operating system documentation, or the value of the array @code{Reserved}
2921 declared in the spec of package @code{System.OS_Interface}.
2923 Overriding the default state of signals used by the Ada runtime may interfere
2924 with an application's runtime behavior in the cases of the synchronous signals,
2925 and in the case of the signal used to implement the @code{abort} statement.
2927 @node Pragma Keep_Names
2928 @unnumberedsec Pragma Keep_Names
2933 @smallexample @c ada
2934 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2938 The @var{LOCAL_NAME} argument
2939 must refer to an enumeration first subtype
2940 in the current declarative part. The effect is to retain the enumeration
2941 literal names for use by @code{Image} and @code{Value} even if a global
2942 @code{Discard_Names} pragma applies. This is useful when you want to
2943 generally suppress enumeration literal names and for example you therefore
2944 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2945 want to retain the names for specific enumeration types.
2947 @node Pragma License
2948 @unnumberedsec Pragma License
2950 @cindex License checking
2954 @smallexample @c ada
2955 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2959 This pragma is provided to allow automated checking for appropriate license
2960 conditions with respect to the standard and modified GPL@. A pragma
2961 @code{License}, which is a configuration pragma that typically appears at
2962 the start of a source file or in a separate @file{gnat.adc} file, specifies
2963 the licensing conditions of a unit as follows:
2967 This is used for a unit that can be freely used with no license restrictions.
2968 Examples of such units are public domain units, and units from the Ada
2972 This is used for a unit that is licensed under the unmodified GPL, and which
2973 therefore cannot be @code{with}'ed by a restricted unit.
2976 This is used for a unit licensed under the GNAT modified GPL that includes
2977 a special exception paragraph that specifically permits the inclusion of
2978 the unit in programs without requiring the entire program to be released
2982 This is used for a unit that is restricted in that it is not permitted to
2983 depend on units that are licensed under the GPL@. Typical examples are
2984 proprietary code that is to be released under more restrictive license
2985 conditions. Note that restricted units are permitted to @code{with} units
2986 which are licensed under the modified GPL (this is the whole point of the
2992 Normally a unit with no @code{License} pragma is considered to have an
2993 unknown license, and no checking is done. However, standard GNAT headers
2994 are recognized, and license information is derived from them as follows.
2998 A GNAT license header starts with a line containing 78 hyphens. The following
2999 comment text is searched for the appearance of any of the following strings.
3001 If the string ``GNU General Public License'' is found, then the unit is assumed
3002 to have GPL license, unless the string ``As a special exception'' follows, in
3003 which case the license is assumed to be modified GPL@.
3005 If one of the strings
3006 ``This specification is adapted from the Ada Semantic Interface'' or
3007 ``This specification is derived from the Ada Reference Manual'' is found
3008 then the unit is assumed to be unrestricted.
3012 These default actions means that a program with a restricted license pragma
3013 will automatically get warnings if a GPL unit is inappropriately
3014 @code{with}'ed. For example, the program:
3016 @smallexample @c ada
3019 procedure Secret_Stuff is
3025 if compiled with pragma @code{License} (@code{Restricted}) in a
3026 @file{gnat.adc} file will generate the warning:
3031 >>> license of withed unit "Sem_Ch3" is incompatible
3033 2. with GNAT.Sockets;
3034 3. procedure Secret_Stuff is
3038 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3039 compiler and is licensed under the
3040 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3041 run time, and is therefore licensed under the modified GPL@.
3043 @node Pragma Link_With
3044 @unnumberedsec Pragma Link_With
3049 @smallexample @c ada
3050 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3054 This pragma is provided for compatibility with certain Ada 83 compilers.
3055 It has exactly the same effect as pragma @code{Linker_Options} except
3056 that spaces occurring within one of the string expressions are treated
3057 as separators. For example, in the following case:
3059 @smallexample @c ada
3060 pragma Link_With ("-labc -ldef");
3064 results in passing the strings @code{-labc} and @code{-ldef} as two
3065 separate arguments to the linker. In addition pragma Link_With allows
3066 multiple arguments, with the same effect as successive pragmas.
3068 @node Pragma Linker_Alias
3069 @unnumberedsec Pragma Linker_Alias
3070 @findex Linker_Alias
3074 @smallexample @c ada
3075 pragma Linker_Alias (
3076 [Entity =>] LOCAL_NAME,
3077 [Target =>] static_string_EXPRESSION);
3081 @var{LOCAL_NAME} must refer to an object that is declared at the library
3082 level. This pragma establishes the given entity as a linker alias for the
3083 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3084 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3085 @var{static_string_EXPRESSION} in the object file, that is to say no space
3086 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3087 to the same address as @var{static_string_EXPRESSION} by the linker.
3089 The actual linker name for the target must be used (e.g.@: the fully
3090 encoded name with qualification in Ada, or the mangled name in C++),
3091 or it must be declared using the C convention with @code{pragma Import}
3092 or @code{pragma Export}.
3094 Not all target machines support this pragma. On some of them it is accepted
3095 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3097 @smallexample @c ada
3098 -- Example of the use of pragma Linker_Alias
3102 pragma Export (C, i);
3104 new_name_for_i : Integer;
3105 pragma Linker_Alias (new_name_for_i, "i");
3109 @node Pragma Linker_Constructor
3110 @unnumberedsec Pragma Linker_Constructor
3111 @findex Linker_Constructor
3115 @smallexample @c ada
3116 pragma Linker_Constructor (procedure_LOCAL_NAME);
3120 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3121 is declared at the library level. A procedure to which this pragma is
3122 applied will be treated as an initialization routine by the linker.
3123 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3124 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3125 of the executable is called (or immediately after the shared library is
3126 loaded if the procedure is linked in a shared library), in particular
3127 before the Ada run-time environment is set up.
3129 Because of these specific contexts, the set of operations such a procedure
3130 can perform is very limited and the type of objects it can manipulate is
3131 essentially restricted to the elementary types. In particular, it must only
3132 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3134 This pragma is used by GNAT to implement auto-initialization of shared Stand
3135 Alone Libraries, which provides a related capability without the restrictions
3136 listed above. Where possible, the use of Stand Alone Libraries is preferable
3137 to the use of this pragma.
3139 @node Pragma Linker_Destructor
3140 @unnumberedsec Pragma Linker_Destructor
3141 @findex Linker_Destructor
3145 @smallexample @c ada
3146 pragma Linker_Destructor (procedure_LOCAL_NAME);
3150 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3151 is declared at the library level. A procedure to which this pragma is
3152 applied will be treated as a finalization routine by the linker.
3153 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3154 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3155 of the executable has exited (or immediately before the shared library
3156 is unloaded if the procedure is linked in a shared library), in particular
3157 after the Ada run-time environment is shut down.
3159 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3160 because of these specific contexts.
3162 @node Pragma Linker_Section
3163 @unnumberedsec Pragma Linker_Section
3164 @findex Linker_Section
3168 @smallexample @c ada
3169 pragma Linker_Section (
3170 [Entity =>] LOCAL_NAME,
3171 [Section =>] static_string_EXPRESSION);
3175 @var{LOCAL_NAME} must refer to an object that is declared at the library
3176 level. This pragma specifies the name of the linker section for the given
3177 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3178 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3179 section of the executable (assuming the linker doesn't rename the section).
3181 The compiler normally places library-level objects in standard sections
3182 depending on their type: procedures and functions generally go in the
3183 @code{.text} section, initialized variables in the @code{.data} section
3184 and uninitialized variables in the @code{.bss} section.
3186 Other, special sections may exist on given target machines to map special
3187 hardware, for example I/O ports or flash memory. This pragma is a means to
3188 defer the final layout of the executable to the linker, thus fully working
3189 at the symbolic level with the compiler.
3191 Some file formats do not support arbitrary sections so not all target
3192 machines support this pragma. The use of this pragma may cause a program
3193 execution to be erroneous if it is used to place an entity into an
3194 inappropriate section (e.g.@: a modified variable into the @code{.text}
3195 section). See also @code{pragma Persistent_BSS}.
3197 @smallexample @c ada
3198 -- Example of the use of pragma Linker_Section
3202 pragma Volatile (Port_A);
3203 pragma Linker_Section (Port_A, ".bss.port_a");
3206 pragma Volatile (Port_B);
3207 pragma Linker_Section (Port_B, ".bss.port_b");
3211 @node Pragma Long_Float
3212 @unnumberedsec Pragma Long_Float
3218 @smallexample @c ada
3219 pragma Long_Float (FLOAT_FORMAT);
3221 FLOAT_FORMAT ::= D_Float | G_Float
3225 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3226 It allows control over the internal representation chosen for the predefined
3227 type @code{Long_Float} and for floating point type representations with
3228 @code{digits} specified in the range 7 through 15.
3229 For further details on this pragma, see the
3230 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3231 this pragma, the standard runtime libraries must be recompiled.
3232 @xref{The GNAT Run-Time Library Builder gnatlbr,,, gnat_ugn,
3233 @value{EDITION} User's Guide OpenVMS}, for a description of the
3234 @code{GNAT LIBRARY} command.
3236 @node Pragma Machine_Attribute
3237 @unnumberedsec Pragma Machine_Attribute
3238 @findex Machine_Attribute
3242 @smallexample @c ada
3243 pragma Machine_Attribute (
3244 [Entity =>] LOCAL_NAME,
3245 [Attribute_Name =>] static_string_EXPRESSION
3246 [, [Info =>] static_EXPRESSION] );
3250 Machine-dependent attributes can be specified for types and/or
3251 declarations. This pragma is semantically equivalent to
3252 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3253 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3254 in GNU C, where @code{@var{attribute_name}} is recognized by the
3255 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3256 specific macro. A string literal for the optional parameter @var{info}
3257 is transformed into an identifier, which may make this pragma unusable
3258 for some attributes. @xref{Target Attributes,, Defining target-specific
3259 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3260 Internals}, further information.
3263 @unnumberedsec Pragma Main
3269 @smallexample @c ada
3271 (MAIN_OPTION [, MAIN_OPTION]);
3274 [Stack_Size =>] static_integer_EXPRESSION
3275 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3276 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3280 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3281 no effect in GNAT, other than being syntax checked.
3283 @node Pragma Main_Storage
3284 @unnumberedsec Pragma Main_Storage
3286 @findex Main_Storage
3290 @smallexample @c ada
3292 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3294 MAIN_STORAGE_OPTION ::=
3295 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3296 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3300 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3301 no effect in GNAT, other than being syntax checked. Note that the pragma
3302 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3304 @node Pragma No_Body
3305 @unnumberedsec Pragma No_Body
3310 @smallexample @c ada
3315 There are a number of cases in which a package spec does not require a body,
3316 and in fact a body is not permitted. GNAT will not permit the spec to be
3317 compiled if there is a body around. The pragma No_Body allows you to provide
3318 a body file, even in a case where no body is allowed. The body file must
3319 contain only comments and a single No_Body pragma. This is recognized by
3320 the compiler as indicating that no body is logically present.
3322 This is particularly useful during maintenance when a package is modified in
3323 such a way that a body needed before is no longer needed. The provision of a
3324 dummy body with a No_Body pragma ensures that there is no interference from
3325 earlier versions of the package body.
3327 @node Pragma No_Return
3328 @unnumberedsec Pragma No_Return
3333 @smallexample @c ada
3334 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3338 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3339 declarations in the current declarative part. A procedure to which this
3340 pragma is applied may not contain any explicit @code{return} statements.
3341 In addition, if the procedure contains any implicit returns from falling
3342 off the end of a statement sequence, then execution of that implicit
3343 return will cause Program_Error to be raised.
3345 One use of this pragma is to identify procedures whose only purpose is to raise
3346 an exception. Another use of this pragma is to suppress incorrect warnings
3347 about missing returns in functions, where the last statement of a function
3348 statement sequence is a call to such a procedure.
3350 Note that in Ada 2005 mode, this pragma is part of the language, and is
3351 identical in effect to the pragma as implemented in Ada 95 mode.
3353 @node Pragma No_Strict_Aliasing
3354 @unnumberedsec Pragma No_Strict_Aliasing
3355 @findex No_Strict_Aliasing
3359 @smallexample @c ada
3360 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3364 @var{type_LOCAL_NAME} must refer to an access type
3365 declaration in the current declarative part. The effect is to inhibit
3366 strict aliasing optimization for the given type. The form with no
3367 arguments is a configuration pragma which applies to all access types
3368 declared in units to which the pragma applies. For a detailed
3369 description of the strict aliasing optimization, and the situations
3370 in which it must be suppressed, see @ref{Optimization and Strict
3371 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3373 @node Pragma Normalize_Scalars
3374 @unnumberedsec Pragma Normalize_Scalars
3375 @findex Normalize_Scalars
3379 @smallexample @c ada
3380 pragma Normalize_Scalars;
3384 This is a language defined pragma which is fully implemented in GNAT@. The
3385 effect is to cause all scalar objects that are not otherwise initialized
3386 to be initialized. The initial values are implementation dependent and
3390 @item Standard.Character
3392 Objects whose root type is Standard.Character are initialized to
3393 Character'Last unless the subtype range excludes NUL (in which case
3394 NUL is used). This choice will always generate an invalid value if
3397 @item Standard.Wide_Character
3399 Objects whose root type is Standard.Wide_Character are initialized to
3400 Wide_Character'Last unless the subtype range excludes NUL (in which case
3401 NUL is used). This choice will always generate an invalid value if
3404 @item Standard.Wide_Wide_Character
3406 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3407 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3408 which case NUL is used). This choice will always generate an invalid value if
3413 Objects of an integer type are treated differently depending on whether
3414 negative values are present in the subtype. If no negative values are
3415 present, then all one bits is used as the initial value except in the
3416 special case where zero is excluded from the subtype, in which case
3417 all zero bits are used. This choice will always generate an invalid
3418 value if one exists.
3420 For subtypes with negative values present, the largest negative number
3421 is used, except in the unusual case where this largest negative number
3422 is in the subtype, and the largest positive number is not, in which case
3423 the largest positive value is used. This choice will always generate
3424 an invalid value if one exists.
3426 @item Floating-Point Types
3427 Objects of all floating-point types are initialized to all 1-bits. For
3428 standard IEEE format, this corresponds to a NaN (not a number) which is
3429 indeed an invalid value.
3431 @item Fixed-Point Types
3432 Objects of all fixed-point types are treated as described above for integers,
3433 with the rules applying to the underlying integer value used to represent
3434 the fixed-point value.
3437 Objects of a modular type are initialized to all one bits, except in
3438 the special case where zero is excluded from the subtype, in which
3439 case all zero bits are used. This choice will always generate an
3440 invalid value if one exists.
3442 @item Enumeration types
3443 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3444 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3445 whose Pos value is zero, in which case a code of zero is used. This choice
3446 will always generate an invalid value if one exists.
3450 @node Pragma Obsolescent
3451 @unnumberedsec Pragma Obsolescent
3456 @smallexample @c ada
3459 pragma Obsolescent (
3460 [Message =>] static_string_EXPRESSION
3461 [,[Version =>] Ada_05]]);
3463 pragma Obsolescent (
3465 [,[Message =>] static_string_EXPRESSION
3466 [,[Version =>] Ada_05]] );
3470 This pragma can occur immediately following a declaration of an entity,
3471 including the case of a record component. If no Entity argument is present,
3472 then this declaration is the one to which the pragma applies. If an Entity
3473 parameter is present, it must either match the name of the entity in this
3474 declaration, or alternatively, the pragma can immediately follow an enumeration
3475 type declaration, where the Entity argument names one of the enumeration
3478 This pragma is used to indicate that the named entity
3479 is considered obsolescent and should not be used. Typically this is
3480 used when an API must be modified by eventually removing or modifying
3481 existing subprograms or other entities. The pragma can be used at an
3482 intermediate stage when the entity is still present, but will be
3485 The effect of this pragma is to output a warning message on a reference to
3486 an entity thus marked that the subprogram is obsolescent if the appropriate
3487 warning option in the compiler is activated. If the Message parameter is
3488 present, then a second warning message is given containing this text. In
3489 addition, a reference to the eneity is considered to be a violation of pragma
3490 Restrictions (No_Obsolescent_Features).
3492 This pragma can also be used as a program unit pragma for a package,
3493 in which case the entity name is the name of the package, and the
3494 pragma indicates that the entire package is considered
3495 obsolescent. In this case a client @code{with}'ing such a package
3496 violates the restriction, and the @code{with} statement is
3497 flagged with warnings if the warning option is set.
3499 If the Version parameter is present (which must be exactly
3500 the identifier Ada_05, no other argument is allowed), then the
3501 indication of obsolescence applies only when compiling in Ada 2005
3502 mode. This is primarily intended for dealing with the situations
3503 in the predefined library where subprograms or packages
3504 have become defined as obsolescent in Ada 2005
3505 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3507 The following examples show typical uses of this pragma:
3509 @smallexample @c ada
3511 pragma Obsolescent (p, Message => "use pp instead of p");
3516 pragma Obsolescent ("use q2new instead");
3518 type R is new integer;
3521 Message => "use RR in Ada 2005",
3531 type E is (a, bc, 'd', quack);
3532 pragma Obsolescent (Entity => bc)
3533 pragma Obsolescent (Entity => 'd')
3536 (a, b : character) return character;
3537 pragma Obsolescent (Entity => "+");
3542 Note that, as for all pragmas, if you use a pragma argument identifier,
3543 then all subsequent parameters must also use a pragma argument identifier.
3544 So if you specify "Entity =>" for the Entity argument, and a Message
3545 argument is present, it must be preceded by "Message =>".
3547 @node Pragma Optimize_Alignment
3548 @unnumberedsec Pragma Optimize_Alignment
3549 @findex Optimize_Alignment
3550 @cindex Alignment, default settings
3554 @smallexample @c ada
3555 pragma Optimize_Alignment (TIME | SPACE | OFF);
3559 This is a configuration pragma which affects the choice of default alignments
3560 for types where no alignment is explicitly specified. There is a time/space
3561 trade-off in the selection of these values. Large alignments result in more
3562 efficient code, at the expense of larger data space, since sizes have to be
3563 increased to match these alignments. Smaller alignments save space, but the
3564 access code is slower. The normal choice of default alignments (which is what
3565 you get if you do not use this pragma, or if you use an argument of OFF),
3566 tries to balance these two requirements.
3568 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3569 First any packed record is given an alignment of 1. Second, if a size is given
3570 for the type, then the alignment is chosen to avoid increasing this size. For
3573 @smallexample @c ada
3583 In the default mode, this type gets an alignment of 4, so that access to the
3584 Integer field X are efficient. But this means that objects of the type end up
3585 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3586 allowed to be bigger than the size of the type, but it can waste space if for
3587 example fields of type R appear in an enclosing record. If the above type is
3588 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3590 Specifying TIME causes larger default alignments to be chosen in the case of
3591 small types with sizes that are not a power of 2. For example, consider:
3593 @smallexample @c ada
3605 The default alignment for this record is normally 1, but if this type is
3606 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3607 to 4, which wastes space for objects of the type, since they are now 4 bytes
3608 long, but results in more efficient access when the whole record is referenced.
3610 As noted above, this is a configuration pragma, and there is a requirement
3611 that all units in a partition be compiled with a consistent setting of the
3612 optimization setting. This would normally be achieved by use of a configuration
3613 pragma file containing the appropriate setting. The exception to this rule is
3614 that units with an explicit configuration pragma in the same file as the source
3615 unit are excluded from the consistency check, as are all predefined units. The
3616 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3617 pragma appears at the start of the file.
3619 @node Pragma Passive
3620 @unnumberedsec Pragma Passive
3625 @smallexample @c ada
3626 pragma Passive [(Semaphore | No)];
3630 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3631 compatibility with DEC Ada 83 implementations, where it is used within a
3632 task definition to request that a task be made passive. If the argument
3633 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3634 treats the pragma as an assertion that the containing task is passive
3635 and that optimization of context switch with this task is permitted and
3636 desired. If the argument @code{No} is present, the task must not be
3637 optimized. GNAT does not attempt to optimize any tasks in this manner
3638 (since protected objects are available in place of passive tasks).
3640 @node Pragma Persistent_BSS
3641 @unnumberedsec Pragma Persistent_BSS
3642 @findex Persistent_BSS
3646 @smallexample @c ada
3647 pragma Persistent_BSS [(LOCAL_NAME)]
3651 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3652 section. On some targets the linker and loader provide for special
3653 treatment of this section, allowing a program to be reloaded without
3654 affecting the contents of this data (hence the name persistent).
3656 There are two forms of usage. If an argument is given, it must be the
3657 local name of a library level object, with no explicit initialization
3658 and whose type is potentially persistent. If no argument is given, then
3659 the pragma is a configuration pragma, and applies to all library level
3660 objects with no explicit initialization of potentially persistent types.
3662 A potentially persistent type is a scalar type, or a non-tagged,
3663 non-discriminated record, all of whose components have no explicit
3664 initialization and are themselves of a potentially persistent type,
3665 or an array, all of whose constraints are static, and whose component
3666 type is potentially persistent.
3668 If this pragma is used on a target where this feature is not supported,
3669 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3671 @node Pragma Polling
3672 @unnumberedsec Pragma Polling
3677 @smallexample @c ada
3678 pragma Polling (ON | OFF);
3682 This pragma controls the generation of polling code. This is normally off.
3683 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3684 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3685 runtime library, and can be found in file @file{a-excpol.adb}.
3687 Pragma @code{Polling} can appear as a configuration pragma (for example it
3688 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3689 can be used in the statement or declaration sequence to control polling
3692 A call to the polling routine is generated at the start of every loop and
3693 at the start of every subprogram call. This guarantees that the @code{Poll}
3694 routine is called frequently, and places an upper bound (determined by
3695 the complexity of the code) on the period between two @code{Poll} calls.
3697 The primary purpose of the polling interface is to enable asynchronous
3698 aborts on targets that cannot otherwise support it (for example Windows
3699 NT), but it may be used for any other purpose requiring periodic polling.
3700 The standard version is null, and can be replaced by a user program. This
3701 will require re-compilation of the @code{Ada.Exceptions} package that can
3702 be found in files @file{a-except.ads} and @file{a-except.adb}.
3704 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3705 distribution) is used to enable the asynchronous abort capability on
3706 targets that do not normally support the capability. The version of
3707 @code{Poll} in this file makes a call to the appropriate runtime routine
3708 to test for an abort condition.
3710 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3711 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3714 @node Pragma Postcondition
3715 @unnumberedsec Pragma Postcondition
3716 @cindex Postconditions
3717 @cindex Checks, postconditions
3718 @findex Postconditions
3722 @smallexample @c ada
3723 pragma Postcondition (
3724 [Check =>] Boolean_Expression
3725 [,[Message =>] String_Expression]);
3729 The @code{Postcondition} pragma allows specification of automatic
3730 postcondition checks for subprograms. These checks are similar to
3731 assertions, but are automatically inserted just prior to the return
3732 statements of the subprogram with which they are associated (including
3733 implicit returns at the end of procedure bodies and associated
3734 exception handlers).
3736 In addition, the boolean expression which is the condition which
3737 must be true may contain references to function'Result in the case
3738 of a function to refer to the returned value.
3740 @code{Postcondition} pragmas may appear either immediate following the
3741 (separate) declaration of a subprogram, or at the start of the
3742 declarations of a subprogram body. Only other pragmas may intervene
3743 (that is appear between the subprogram declaration and its
3744 postconditions, or appear before the postcondition in the
3745 declaration sequence in a subprogram body). In the case of a
3746 postcondition appearing after a subprogram declaration, the
3747 formal arguments of the subprogram are visible, and can be
3748 referenced in the postcondition expressions.
3750 The postconditions are collected and automatically tested just
3751 before any return (implicit or explicit) in the subprogram body.
3752 A postcondition is only recognized if postconditions are active
3753 at the time the pragma is encountered. The compiler switch @option{gnata}
3754 turns on all postconditions by default, and pragma @code{Check_Policy}
3755 with an identifier of @code{Postcondition} can also be used to
3756 control whether postconditions are active.
3758 The general approach is that postconditions are placed in the spec
3759 if they represent functional aspects which make sense to the client.
3760 For example we might have:
3762 @smallexample @c ada
3763 function Direction return Integer;
3764 pragma Postcondition
3765 (Direction'Result = +1
3767 Direction'Result = -1);
3771 which serves to document that the result must be +1 or -1, and
3772 will test that this is the case at run time if postcondition
3775 Postconditions within the subprogram body can be used to
3776 check that some internal aspect of the implementation,
3777 not visible to the client, is operating as expected.
3778 For instance if a square root routine keeps an internal
3779 counter of the number of times it is called, then we
3780 might have the following postcondition:
3782 @smallexample @c ada
3783 Sqrt_Calls : Natural := 0;
3785 function Sqrt (Arg : Float) return Float is
3786 pragma Postcondition
3787 (Sqrt_Calls = Sqrt_Calls'Old + 1);
3793 As this example, shows, the use of the @code{Old} attribute
3794 is often useful in postconditions to refer to the state on
3795 entry to the subprogram.
3797 Note that postconditions are only checked on normal returns
3798 from the subprogram. If an abnormal return results from
3799 raising an exception, then the postconditions are not checked.
3801 If a postcondition fails, then the exception
3802 @code{System.Assertions.Assert_Failure} is raised. If
3803 a message argument was supplied, then the given string
3804 will be used as the exception message. If no message
3805 argument was supplied, then the default message has
3806 the form "Postcondition failed at file:line". The
3807 exception is raised in the context of the subprogram
3808 body, so it is possible to catch postcondition failures
3809 within the subprogram body itself.
3811 Within a package spec, normal visibility rules
3812 in Ada would prevent forward references within a
3813 postcondition pragma to functions defined later in
3814 the same package. This would introduce undesirable
3815 ordering constraints. To avoid this problem, all
3816 postcondition pragmas are analyzed at the end of
3817 the package spec, allowing forward references.
3819 The following example shows that this even allows
3820 mutually recursive postconditions as in:
3822 @smallexample @c ada
3823 package Parity_Functions is
3824 function Odd (X : Natural) return Boolean;
3825 pragma Postcondition
3829 (x /= 0 and then Even (X - 1))));
3831 function Even (X : Natural) return Boolean;
3832 pragma Postcondition
3836 (x /= 1 and then Odd (X - 1))));
3838 end Parity_Functions;
3842 There are no restrictions on the complexity or form of
3843 conditions used within @code{Postcondition} pragmas.
3844 The following example shows that it is even possible
3845 to verify performance behavior.
3847 @smallexample @c ada
3850 Performance : constant Float;
3851 -- Performance constant set by implementation
3852 -- to match target architecture behavior.
3854 procedure Treesort (Arg : String);
3855 -- Sorts characters of argument using N*logN sort
3856 pragma Postcondition
3857 (Float (Clock - Clock'Old) <=
3858 Float (Arg'Length) *
3859 log (Float (Arg'Length)) *
3865 Note: postcondition pragmas associated with subprograms that are
3866 marked as Inline_Always, or those marked as Inline with front-end
3867 inlining (-gnatN option set) are accepted and legality-checked
3868 by the compiler, but are ignored at run-time even if postcondition
3869 checking is enabled.
3871 @node Pragma Precondition
3872 @unnumberedsec Pragma Precondition
3873 @cindex Preconditions
3874 @cindex Checks, preconditions
3875 @findex Preconditions
3879 @smallexample @c ada
3880 pragma Precondition (
3881 [Check =>] Boolean_Expression
3882 [,[Message =>] String_Expression]);
3886 The @code{Precondition} pragma is similar to @code{Postcondition}
3887 except that the corresponding checks take place immediately upon
3888 entry to the subprogram, and if a precondition fails, the exception
3889 is raised in the context of the caller, and the attribute 'Result
3890 cannot be used within the precondition expression.
3892 Otherwise, the placement and visibility rules are identical to those
3893 described for postconditions. The following is an example of use
3894 within a package spec:
3896 @smallexample @c ada
3897 package Math_Functions is
3899 function Sqrt (Arg : Float) return Float;
3900 pragma Precondition (Arg >= 0.0)
3906 @code{Precondition} pragmas may appear either immediate following the
3907 (separate) declaration of a subprogram, or at the start of the
3908 declarations of a subprogram body. Only other pragmas may intervene
3909 (that is appear between the subprogram declaration and its
3910 postconditions, or appear before the postcondition in the
3911 declaration sequence in a subprogram body).
3913 Note: postcondition pragmas associated with subprograms that are
3914 marked as Inline_Always, or those marked as Inline with front-end
3915 inlining (-gnatN option set) are accepted and legality-checked
3916 by the compiler, but are ignored at run-time even if postcondition
3917 checking is enabled.
3921 @node Pragma Profile (Ravenscar)
3922 @unnumberedsec Pragma Profile (Ravenscar)
3927 @smallexample @c ada
3928 pragma Profile (Ravenscar);
3932 A configuration pragma that establishes the following set of configuration
3936 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3937 [RM D.2.2] Tasks are dispatched following a preemptive
3938 priority-ordered scheduling policy.
3940 @item Locking_Policy (Ceiling_Locking)
3941 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3942 the ceiling priority of the corresponding protected object.
3944 @c @item Detect_Blocking
3945 @c This pragma forces the detection of potentially blocking operations within a
3946 @c protected operation, and to raise Program_Error if that happens.
3950 plus the following set of restrictions:
3953 @item Max_Entry_Queue_Length = 1
3954 Defines the maximum number of calls that are queued on a (protected) entry.
3955 Note that this restrictions is checked at run time. Violation of this
3956 restriction results in the raising of Program_Error exception at the point of
3957 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3958 always 1 and hence no task can be queued on a protected entry.
3960 @item Max_Protected_Entries = 1
3961 [RM D.7] Specifies the maximum number of entries per protected type. The
3962 bounds of every entry family of a protected unit shall be static, or shall be
3963 defined by a discriminant of a subtype whose corresponding bound is static.
3964 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3966 @item Max_Task_Entries = 0
3967 [RM D.7] Specifies the maximum number of entries
3968 per task. The bounds of every entry family
3969 of a task unit shall be static, or shall be
3970 defined by a discriminant of a subtype whose
3971 corresponding bound is static. A value of zero
3972 indicates that no rendezvous are possible. For
3973 the Profile (Ravenscar), the value of Max_Task_Entries is always
3976 @item No_Abort_Statements
3977 [RM D.7] There are no abort_statements, and there are
3978 no calls to Task_Identification.Abort_Task.
3980 @item No_Asynchronous_Control
3981 There are no semantic dependences on the package
3982 Asynchronous_Task_Control.
3985 There are no semantic dependencies on the package Ada.Calendar.
3987 @item No_Dynamic_Attachment
3988 There is no call to any of the operations defined in package Ada.Interrupts
3989 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3990 Detach_Handler, and Reference).
3992 @item No_Dynamic_Priorities
3993 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3995 @item No_Implicit_Heap_Allocations
3996 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3998 @item No_Local_Protected_Objects
3999 Protected objects and access types that designate
4000 such objects shall be declared only at library level.
4002 @item No_Local_Timing_Events
4003 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4004 declared at the library level.
4006 @item No_Protected_Type_Allocators
4007 There are no allocators for protected types or
4008 types containing protected subcomponents.
4010 @item No_Relative_Delay
4011 There are no delay_relative statements.
4013 @item No_Requeue_Statements
4014 Requeue statements are not allowed.
4016 @item No_Select_Statements
4017 There are no select_statements.
4019 @item No_Specific_Termination_Handlers
4020 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4021 or to Ada.Task_Termination.Specific_Handler.
4023 @item No_Task_Allocators
4024 [RM D.7] There are no allocators for task types
4025 or types containing task subcomponents.
4027 @item No_Task_Attributes_Package
4028 There are no semantic dependencies on the Ada.Task_Attributes package.
4030 @item No_Task_Hierarchy
4031 [RM D.7] All (non-environment) tasks depend
4032 directly on the environment task of the partition.
4034 @item No_Task_Termination
4035 Tasks which terminate are erroneous.
4037 @item No_Unchecked_Conversion
4038 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
4040 @item No_Unchecked_Deallocation
4041 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
4043 @item Simple_Barriers
4044 Entry barrier condition expressions shall be either static
4045 boolean expressions or boolean objects which are declared in
4046 the protected type which contains the entry.
4050 This set of configuration pragmas and restrictions correspond to the
4051 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4052 published by the @cite{International Real-Time Ada Workshop}, 1997,
4053 and whose most recent description is available at
4054 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4056 The original definition of the profile was revised at subsequent IRTAW
4057 meetings. It has been included in the ISO
4058 @cite{Guide for the Use of the Ada Programming Language in High
4059 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4060 the next revision of the standard. The formal definition given by
4061 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4062 AI-305) available at
4063 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
4064 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
4067 The above set is a superset of the restrictions provided by pragma
4068 @code{Profile (Restricted)}, it includes six additional restrictions
4069 (@code{Simple_Barriers}, @code{No_Select_Statements},
4070 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4071 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4072 that pragma @code{Profile (Ravenscar)}, like the pragma
4073 @code{Profile (Restricted)},
4074 automatically causes the use of a simplified,
4075 more efficient version of the tasking run-time system.
4077 @node Pragma Profile (Restricted)
4078 @unnumberedsec Pragma Profile (Restricted)
4079 @findex Restricted Run Time
4083 @smallexample @c ada
4084 pragma Profile (Restricted);
4088 A configuration pragma that establishes the following set of restrictions:
4091 @item No_Abort_Statements
4092 @item No_Entry_Queue
4093 @item No_Task_Hierarchy
4094 @item No_Task_Allocators
4095 @item No_Dynamic_Priorities
4096 @item No_Terminate_Alternatives
4097 @item No_Dynamic_Attachment
4098 @item No_Protected_Type_Allocators
4099 @item No_Local_Protected_Objects
4100 @item No_Requeue_Statements
4101 @item No_Task_Attributes_Package
4102 @item Max_Asynchronous_Select_Nesting = 0
4103 @item Max_Task_Entries = 0
4104 @item Max_Protected_Entries = 1
4105 @item Max_Select_Alternatives = 0
4109 This set of restrictions causes the automatic selection of a simplified
4110 version of the run time that provides improved performance for the
4111 limited set of tasking functionality permitted by this set of restrictions.
4113 @node Pragma Psect_Object
4114 @unnumberedsec Pragma Psect_Object
4115 @findex Psect_Object
4119 @smallexample @c ada
4120 pragma Psect_Object (
4121 [Internal =>] LOCAL_NAME,
4122 [, [External =>] EXTERNAL_SYMBOL]
4123 [, [Size =>] EXTERNAL_SYMBOL]);
4127 | static_string_EXPRESSION
4131 This pragma is identical in effect to pragma @code{Common_Object}.
4133 @node Pragma Pure_Function
4134 @unnumberedsec Pragma Pure_Function
4135 @findex Pure_Function
4139 @smallexample @c ada
4140 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4144 This pragma appears in the same declarative part as a function
4145 declaration (or a set of function declarations if more than one
4146 overloaded declaration exists, in which case the pragma applies
4147 to all entities). It specifies that the function @code{Entity} is
4148 to be considered pure for the purposes of code generation. This means
4149 that the compiler can assume that there are no side effects, and
4150 in particular that two calls with identical arguments produce the
4151 same result. It also means that the function can be used in an
4154 Note that, quite deliberately, there are no static checks to try
4155 to ensure that this promise is met, so @code{Pure_Function} can be used
4156 with functions that are conceptually pure, even if they do modify
4157 global variables. For example, a square root function that is
4158 instrumented to count the number of times it is called is still
4159 conceptually pure, and can still be optimized, even though it
4160 modifies a global variable (the count). Memo functions are another
4161 example (where a table of previous calls is kept and consulted to
4162 avoid re-computation).
4165 Note: Most functions in a @code{Pure} package are automatically pure, and
4166 there is no need to use pragma @code{Pure_Function} for such functions. One
4167 exception is any function that has at least one formal of type
4168 @code{System.Address} or a type derived from it. Such functions are not
4169 considered pure by default, since the compiler assumes that the
4170 @code{Address} parameter may be functioning as a pointer and that the
4171 referenced data may change even if the address value does not.
4172 Similarly, imported functions are not considered to be pure by default,
4173 since there is no way of checking that they are in fact pure. The use
4174 of pragma @code{Pure_Function} for such a function will override these default
4175 assumption, and cause the compiler to treat a designated subprogram as pure
4178 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4179 applies to the underlying renamed function. This can be used to
4180 disambiguate cases of overloading where some but not all functions
4181 in a set of overloaded functions are to be designated as pure.
4183 If pragma @code{Pure_Function} is applied to a library level function, the
4184 function is also considered pure from an optimization point of view, but the
4185 unit is not a Pure unit in the categorization sense. So for example, a function
4186 thus marked is free to @code{with} non-pure units.
4188 @node Pragma Restriction_Warnings
4189 @unnumberedsec Pragma Restriction_Warnings
4190 @findex Restriction_Warnings
4194 @smallexample @c ada
4195 pragma Restriction_Warnings
4196 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4200 This pragma allows a series of restriction identifiers to be
4201 specified (the list of allowed identifiers is the same as for
4202 pragma @code{Restrictions}). For each of these identifiers
4203 the compiler checks for violations of the restriction, but
4204 generates a warning message rather than an error message
4205 if the restriction is violated.
4208 @unnumberedsec Pragma Shared
4212 This pragma is provided for compatibility with Ada 83. The syntax and
4213 semantics are identical to pragma Atomic.
4215 @node Pragma Source_File_Name
4216 @unnumberedsec Pragma Source_File_Name
4217 @findex Source_File_Name
4221 @smallexample @c ada
4222 pragma Source_File_Name (
4223 [Unit_Name =>] unit_NAME,
4224 Spec_File_Name => STRING_LITERAL,
4225 [Index => INTEGER_LITERAL]);
4227 pragma Source_File_Name (
4228 [Unit_Name =>] unit_NAME,
4229 Body_File_Name => STRING_LITERAL,
4230 [Index => INTEGER_LITERAL]);
4234 Use this to override the normal naming convention. It is a configuration
4235 pragma, and so has the usual applicability of configuration pragmas
4236 (i.e.@: it applies to either an entire partition, or to all units in a
4237 compilation, or to a single unit, depending on how it is used.
4238 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4239 the second argument is required, and indicates whether this is the file
4240 name for the spec or for the body.
4242 The optional Index argument should be used when a file contains multiple
4243 units, and when you do not want to use @code{gnatchop} to separate then
4244 into multiple files (which is the recommended procedure to limit the
4245 number of recompilation that are needed when some sources change).
4246 For instance, if the source file @file{source.ada} contains
4248 @smallexample @c ada
4260 you could use the following configuration pragmas:
4262 @smallexample @c ada
4263 pragma Source_File_Name
4264 (B, Spec_File_Name => "source.ada", Index => 1);
4265 pragma Source_File_Name
4266 (A, Body_File_Name => "source.ada", Index => 2);
4269 Note that the @code{gnatname} utility can also be used to generate those
4270 configuration pragmas.
4272 Another form of the @code{Source_File_Name} pragma allows
4273 the specification of patterns defining alternative file naming schemes
4274 to apply to all files.
4276 @smallexample @c ada
4277 pragma Source_File_Name
4278 ( [Spec_File_Name =>] STRING_LITERAL
4279 [,[Casing =>] CASING_SPEC]
4280 [,[Dot_Replacement =>] STRING_LITERAL]);
4282 pragma Source_File_Name
4283 ( [Body_File_Name =>] STRING_LITERAL
4284 [,[Casing =>] CASING_SPEC]
4285 [,[Dot_Replacement =>] STRING_LITERAL]);
4287 pragma Source_File_Name
4288 ( [Subunit_File_Name =>] STRING_LITERAL
4289 [,[Casing =>] CASING_SPEC]
4290 [,[Dot_Replacement =>] STRING_LITERAL]);
4292 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4296 The first argument is a pattern that contains a single asterisk indicating
4297 the point at which the unit name is to be inserted in the pattern string
4298 to form the file name. The second argument is optional. If present it
4299 specifies the casing of the unit name in the resulting file name string.
4300 The default is lower case. Finally the third argument allows for systematic
4301 replacement of any dots in the unit name by the specified string literal.
4303 A pragma Source_File_Name cannot appear after a
4304 @ref{Pragma Source_File_Name_Project}.
4306 For more details on the use of the @code{Source_File_Name} pragma,
4307 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4308 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4311 @node Pragma Source_File_Name_Project
4312 @unnumberedsec Pragma Source_File_Name_Project
4313 @findex Source_File_Name_Project
4316 This pragma has the same syntax and semantics as pragma Source_File_Name.
4317 It is only allowed as a stand alone configuration pragma.
4318 It cannot appear after a @ref{Pragma Source_File_Name}, and
4319 most importantly, once pragma Source_File_Name_Project appears,
4320 no further Source_File_Name pragmas are allowed.
4322 The intention is that Source_File_Name_Project pragmas are always
4323 generated by the Project Manager in a manner consistent with the naming
4324 specified in a project file, and when naming is controlled in this manner,
4325 it is not permissible to attempt to modify this naming scheme using
4326 Source_File_Name pragmas (which would not be known to the project manager).
4328 @node Pragma Source_Reference
4329 @unnumberedsec Pragma Source_Reference
4330 @findex Source_Reference
4334 @smallexample @c ada
4335 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4339 This pragma must appear as the first line of a source file.
4340 @var{integer_literal} is the logical line number of the line following
4341 the pragma line (for use in error messages and debugging
4342 information). @var{string_literal} is a static string constant that
4343 specifies the file name to be used in error messages and debugging
4344 information. This is most notably used for the output of @code{gnatchop}
4345 with the @option{-r} switch, to make sure that the original unchopped
4346 source file is the one referred to.
4348 The second argument must be a string literal, it cannot be a static
4349 string expression other than a string literal. This is because its value
4350 is needed for error messages issued by all phases of the compiler.
4352 @node Pragma Stream_Convert
4353 @unnumberedsec Pragma Stream_Convert
4354 @findex Stream_Convert
4358 @smallexample @c ada
4359 pragma Stream_Convert (
4360 [Entity =>] type_LOCAL_NAME,
4361 [Read =>] function_NAME,
4362 [Write =>] function_NAME);
4366 This pragma provides an efficient way of providing stream functions for
4367 types defined in packages. Not only is it simpler to use than declaring
4368 the necessary functions with attribute representation clauses, but more
4369 significantly, it allows the declaration to made in such a way that the
4370 stream packages are not loaded unless they are needed. The use of
4371 the Stream_Convert pragma adds no overhead at all, unless the stream
4372 attributes are actually used on the designated type.
4374 The first argument specifies the type for which stream functions are
4375 provided. The second parameter provides a function used to read values
4376 of this type. It must name a function whose argument type may be any
4377 subtype, and whose returned type must be the type given as the first
4378 argument to the pragma.
4380 The meaning of the @var{Read}
4381 parameter is that if a stream attribute directly
4382 or indirectly specifies reading of the type given as the first parameter,
4383 then a value of the type given as the argument to the Read function is
4384 read from the stream, and then the Read function is used to convert this
4385 to the required target type.
4387 Similarly the @var{Write} parameter specifies how to treat write attributes
4388 that directly or indirectly apply to the type given as the first parameter.
4389 It must have an input parameter of the type specified by the first parameter,
4390 and the return type must be the same as the input type of the Read function.
4391 The effect is to first call the Write function to convert to the given stream
4392 type, and then write the result type to the stream.
4394 The Read and Write functions must not be overloaded subprograms. If necessary
4395 renamings can be supplied to meet this requirement.
4396 The usage of this attribute is best illustrated by a simple example, taken
4397 from the GNAT implementation of package Ada.Strings.Unbounded:
4399 @smallexample @c ada
4400 function To_Unbounded (S : String)
4401 return Unbounded_String
4402 renames To_Unbounded_String;
4404 pragma Stream_Convert
4405 (Unbounded_String, To_Unbounded, To_String);
4409 The specifications of the referenced functions, as given in the Ada
4410 Reference Manual are:
4412 @smallexample @c ada
4413 function To_Unbounded_String (Source : String)
4414 return Unbounded_String;
4416 function To_String (Source : Unbounded_String)
4421 The effect is that if the value of an unbounded string is written to a
4422 stream, then the representation of the item in the stream is in the same
4423 format used for @code{Standard.String}, and this same representation is
4424 expected when a value of this type is read from the stream.
4426 @node Pragma Style_Checks
4427 @unnumberedsec Pragma Style_Checks
4428 @findex Style_Checks
4432 @smallexample @c ada
4433 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4434 On | Off [, LOCAL_NAME]);
4438 This pragma is used in conjunction with compiler switches to control the
4439 built in style checking provided by GNAT@. The compiler switches, if set,
4440 provide an initial setting for the switches, and this pragma may be used
4441 to modify these settings, or the settings may be provided entirely by
4442 the use of the pragma. This pragma can be used anywhere that a pragma
4443 is legal, including use as a configuration pragma (including use in
4444 the @file{gnat.adc} file).
4446 The form with a string literal specifies which style options are to be
4447 activated. These are additive, so they apply in addition to any previously
4448 set style check options. The codes for the options are the same as those
4449 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4450 For example the following two methods can be used to enable
4455 @smallexample @c ada
4456 pragma Style_Checks ("l");
4461 gcc -c -gnatyl @dots{}
4466 The form ALL_CHECKS activates all standard checks (its use is equivalent
4467 to the use of the @code{gnaty} switch with no options. @xref{Top,
4468 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4469 @value{EDITION} User's Guide}, for details.
4471 The forms with @code{Off} and @code{On}
4472 can be used to temporarily disable style checks
4473 as shown in the following example:
4475 @smallexample @c ada
4479 pragma Style_Checks ("k"); -- requires keywords in lower case
4480 pragma Style_Checks (Off); -- turn off style checks
4481 NULL; -- this will not generate an error message
4482 pragma Style_Checks (On); -- turn style checks back on
4483 NULL; -- this will generate an error message
4487 Finally the two argument form is allowed only if the first argument is
4488 @code{On} or @code{Off}. The effect is to turn of semantic style checks
4489 for the specified entity, as shown in the following example:
4491 @smallexample @c ada
4495 pragma Style_Checks ("r"); -- require consistency of identifier casing
4497 Rf1 : Integer := ARG; -- incorrect, wrong case
4498 pragma Style_Checks (Off, Arg);
4499 Rf2 : Integer := ARG; -- OK, no error
4502 @node Pragma Subtitle
4503 @unnumberedsec Pragma Subtitle
4508 @smallexample @c ada
4509 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4513 This pragma is recognized for compatibility with other Ada compilers
4514 but is ignored by GNAT@.
4516 @node Pragma Suppress
4517 @unnumberedsec Pragma Suppress
4522 @smallexample @c ada
4523 pragma Suppress (Identifier [, [On =>] Name]);
4527 This is a standard pragma, and supports all the check names required in
4528 the RM. It is included here because GNAT recognizes one additional check
4529 name: @code{Alignment_Check} which can be used to suppress alignment checks
4530 on addresses used in address clauses. Such checks can also be suppressed
4531 by suppressing range checks, but the specific use of @code{Alignment_Check}
4532 allows suppression of alignment checks without suppressing other range checks.
4534 Note that pragma Suppress gives the compiler permission to omit
4535 checks, but does not require the compiler to omit checks. The compiler
4536 will generate checks if they are essentially free, even when they are
4537 suppressed. In particular, if the compiler can prove that a certain
4538 check will necessarily fail, it will generate code to do an
4539 unconditional ``raise'', even if checks are suppressed. The compiler
4542 Of course, run-time checks are omitted whenever the compiler can prove
4543 that they will not fail, whether or not checks are suppressed.
4545 @node Pragma Suppress_All
4546 @unnumberedsec Pragma Suppress_All
4547 @findex Suppress_All
4551 @smallexample @c ada
4552 pragma Suppress_All;
4556 This pragma can only appear immediately following a compilation
4557 unit. The effect is to apply @code{Suppress (All_Checks)} to the unit
4558 which it follows. This pragma is implemented for compatibility with DEC
4559 Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal
4560 configuration pragma is the preferred usage in GNAT@.
4562 @node Pragma Suppress_Exception_Locations
4563 @unnumberedsec Pragma Suppress_Exception_Locations
4564 @findex Suppress_Exception_Locations
4568 @smallexample @c ada
4569 pragma Suppress_Exception_Locations;
4573 In normal mode, a raise statement for an exception by default generates
4574 an exception message giving the file name and line number for the location
4575 of the raise. This is useful for debugging and logging purposes, but this
4576 entails extra space for the strings for the messages. The configuration
4577 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4578 generation of these strings, with the result that space is saved, but the
4579 exception message for such raises is null. This configuration pragma may
4580 appear in a global configuration pragma file, or in a specific unit as
4581 usual. It is not required that this pragma be used consistently within
4582 a partition, so it is fine to have some units within a partition compiled
4583 with this pragma and others compiled in normal mode without it.
4585 @node Pragma Suppress_Initialization
4586 @unnumberedsec Pragma Suppress_Initialization
4587 @findex Suppress_Initialization
4588 @cindex Suppressing initialization
4589 @cindex Initialization, suppression of
4593 @smallexample @c ada
4594 pragma Suppress_Initialization ([Entity =>] type_Name);
4598 This pragma suppresses any implicit or explicit initialization
4599 associated with the given type name for all variables of this type.
4601 @node Pragma Task_Info
4602 @unnumberedsec Pragma Task_Info
4607 @smallexample @c ada
4608 pragma Task_Info (EXPRESSION);
4612 This pragma appears within a task definition (like pragma
4613 @code{Priority}) and applies to the task in which it appears. The
4614 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4615 The @code{Task_Info} pragma provides system dependent control over
4616 aspects of tasking implementation, for example, the ability to map
4617 tasks to specific processors. For details on the facilities available
4618 for the version of GNAT that you are using, see the documentation
4619 in the spec of package System.Task_Info in the runtime
4622 @node Pragma Task_Name
4623 @unnumberedsec Pragma Task_Name
4628 @smallexample @c ada
4629 pragma Task_Name (string_EXPRESSION);
4633 This pragma appears within a task definition (like pragma
4634 @code{Priority}) and applies to the task in which it appears. The
4635 argument must be of type String, and provides a name to be used for
4636 the task instance when the task is created. Note that this expression
4637 is not required to be static, and in particular, it can contain
4638 references to task discriminants. This facility can be used to
4639 provide different names for different tasks as they are created,
4640 as illustrated in the example below.
4642 The task name is recorded internally in the run-time structures
4643 and is accessible to tools like the debugger. In addition the
4644 routine @code{Ada.Task_Identification.Image} will return this
4645 string, with a unique task address appended.
4647 @smallexample @c ada
4648 -- Example of the use of pragma Task_Name
4650 with Ada.Task_Identification;
4651 use Ada.Task_Identification;
4652 with Text_IO; use Text_IO;
4655 type Astring is access String;
4657 task type Task_Typ (Name : access String) is
4658 pragma Task_Name (Name.all);
4661 task body Task_Typ is
4662 Nam : constant String := Image (Current_Task);
4664 Put_Line ("-->" & Nam (1 .. 14) & "<--");
4667 type Ptr_Task is access Task_Typ;
4668 Task_Var : Ptr_Task;
4672 new Task_Typ (new String'("This is task 1"));
4674 new Task_Typ (new String'("This is task 2"));
4678 @node Pragma Task_Storage
4679 @unnumberedsec Pragma Task_Storage
4680 @findex Task_Storage
4683 @smallexample @c ada
4684 pragma Task_Storage (
4685 [Task_Type =>] LOCAL_NAME,
4686 [Top_Guard =>] static_integer_EXPRESSION);
4690 This pragma specifies the length of the guard area for tasks. The guard
4691 area is an additional storage area allocated to a task. A value of zero
4692 means that either no guard area is created or a minimal guard area is
4693 created, depending on the target. This pragma can appear anywhere a
4694 @code{Storage_Size} attribute definition clause is allowed for a task
4697 @node Pragma Thread_Local_Storage
4698 @unnumberedsec Pragma Thread_Local_Storage
4699 @findex Thread_Local_Storage
4700 @cindex Task specific storage
4701 @cindex TLS (Thread Local Storage)
4704 @smallexample @c ada
4705 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
4709 This pragma specifies that the specified entity, which must be
4710 a variable declared in a library level package, is to be marked as
4711 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
4712 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
4713 (and hence each Ada task) to see a distinct copy of the variable.
4715 The variable may not have default initialization, and if there is
4716 an explicit initialization, it must be either @code{null} for an
4717 access variable, or a static expression for a scalar variable.
4718 This provides a low level mechanism similar to that provided by
4719 the @code{Ada.Task_Attributes} package, but much more efficient
4720 and is also useful in writing interface code that will interact
4721 with foreign threads.
4723 If this pragma is used on a system where @code{TLS} is not supported,
4724 then an error message will be generated and the program will be rejected.
4726 @node Pragma Time_Slice
4727 @unnumberedsec Pragma Time_Slice
4732 @smallexample @c ada
4733 pragma Time_Slice (static_duration_EXPRESSION);
4737 For implementations of GNAT on operating systems where it is possible
4738 to supply a time slice value, this pragma may be used for this purpose.
4739 It is ignored if it is used in a system that does not allow this control,
4740 or if it appears in other than the main program unit.
4742 Note that the effect of this pragma is identical to the effect of the
4743 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4746 @unnumberedsec Pragma Title
4751 @smallexample @c ada
4752 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4755 [Title =>] STRING_LITERAL,
4756 | [Subtitle =>] STRING_LITERAL
4760 Syntax checked but otherwise ignored by GNAT@. This is a listing control
4761 pragma used in DEC Ada 83 implementations to provide a title and/or
4762 subtitle for the program listing. The program listing generated by GNAT
4763 does not have titles or subtitles.
4765 Unlike other pragmas, the full flexibility of named notation is allowed
4766 for this pragma, i.e.@: the parameters may be given in any order if named
4767 notation is used, and named and positional notation can be mixed
4768 following the normal rules for procedure calls in Ada.
4770 @node Pragma Unchecked_Union
4771 @unnumberedsec Pragma Unchecked_Union
4773 @findex Unchecked_Union
4777 @smallexample @c ada
4778 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4782 This pragma is used to specify a representation of a record type that is
4783 equivalent to a C union. It was introduced as a GNAT implementation defined
4784 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4785 pragma, making it language defined, and GNAT fully implements this extended
4786 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4787 details, consult the Ada 2005 Reference Manual, section B.3.3.
4789 @node Pragma Unimplemented_Unit
4790 @unnumberedsec Pragma Unimplemented_Unit
4791 @findex Unimplemented_Unit
4795 @smallexample @c ada
4796 pragma Unimplemented_Unit;
4800 If this pragma occurs in a unit that is processed by the compiler, GNAT
4801 aborts with the message @samp{@var{xxx} not implemented}, where
4802 @var{xxx} is the name of the current compilation unit. This pragma is
4803 intended to allow the compiler to handle unimplemented library units in
4806 The abort only happens if code is being generated. Thus you can use
4807 specs of unimplemented packages in syntax or semantic checking mode.
4809 @node Pragma Universal_Aliasing
4810 @unnumberedsec Pragma Universal_Aliasing
4811 @findex Universal_Aliasing
4815 @smallexample @c ada
4816 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4820 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4821 declarative part. The effect is to inhibit strict type-based aliasing
4822 optimization for the given type. In other words, the effect is as though
4823 access types designating this type were subject to pragma No_Strict_Aliasing.
4824 For a detailed description of the strict aliasing optimization, and the
4825 situations in which it must be suppressed, @xref{Optimization and Strict
4826 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4828 @node Pragma Universal_Data
4829 @unnumberedsec Pragma Universal_Data
4830 @findex Universal_Data
4834 @smallexample @c ada
4835 pragma Universal_Data [(library_unit_Name)];
4839 This pragma is supported only for the AAMP target and is ignored for
4840 other targets. The pragma specifies that all library-level objects
4841 (Counter 0 data) associated with the library unit are to be accessed
4842 and updated using universal addressing (24-bit addresses for AAMP5)
4843 rather than the default of 16-bit Data Environment (DENV) addressing.
4844 Use of this pragma will generally result in less efficient code for
4845 references to global data associated with the library unit, but
4846 allows such data to be located anywhere in memory. This pragma is
4847 a library unit pragma, but can also be used as a configuration pragma
4848 (including use in the @file{gnat.adc} file). The functionality
4849 of this pragma is also available by applying the -univ switch on the
4850 compilations of units where universal addressing of the data is desired.
4852 @node Pragma Unmodified
4853 @unnumberedsec Pragma Unmodified
4855 @cindex Warnings, unmodified
4859 @smallexample @c ada
4860 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4864 This pragma signals that the assignable entities (variables,
4865 @code{out} parameters, @code{in out} parameters) whose names are listed are
4866 deliberately not assigned in the current source unit. This
4867 suppresses warnings about the
4868 entities being referenced but not assigned, and in addition a warning will be
4869 generated if one of these entities is in fact assigned in the
4870 same unit as the pragma (or in the corresponding body, or one
4873 This is particularly useful for clearly signaling that a particular
4874 parameter is not modified, even though the spec suggests that it might
4877 @node Pragma Unreferenced
4878 @unnumberedsec Pragma Unreferenced
4879 @findex Unreferenced
4880 @cindex Warnings, unreferenced
4884 @smallexample @c ada
4885 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4886 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4890 This pragma signals that the entities whose names are listed are
4891 deliberately not referenced in the current source unit. This
4892 suppresses warnings about the
4893 entities being unreferenced, and in addition a warning will be
4894 generated if one of these entities is in fact referenced in the
4895 same unit as the pragma (or in the corresponding body, or one
4898 This is particularly useful for clearly signaling that a particular
4899 parameter is not referenced in some particular subprogram implementation
4900 and that this is deliberate. It can also be useful in the case of
4901 objects declared only for their initialization or finalization side
4904 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4905 current scope, then the entity most recently declared is the one to which
4906 the pragma applies. Note that in the case of accept formals, the pragma
4907 Unreferenced may appear immediately after the keyword @code{do} which
4908 allows the indication of whether or not accept formals are referenced
4909 or not to be given individually for each accept statement.
4911 The left hand side of an assignment does not count as a reference for the
4912 purpose of this pragma. Thus it is fine to assign to an entity for which
4913 pragma Unreferenced is given.
4915 Note that if a warning is desired for all calls to a given subprogram,
4916 regardless of whether they occur in the same unit as the subprogram
4917 declaration, then this pragma should not be used (calls from another
4918 unit would not be flagged); pragma Obsolescent can be used instead
4919 for this purpose, see @xref{Pragma Obsolescent}.
4921 The second form of pragma @code{Unreferenced} is used within a context
4922 clause. In this case the arguments must be unit names of units previously
4923 mentioned in @code{with} clauses (similar to the usage of pragma
4924 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4925 units and unreferenced entities within these units.
4927 @node Pragma Unreferenced_Objects
4928 @unnumberedsec Pragma Unreferenced_Objects
4929 @findex Unreferenced_Objects
4930 @cindex Warnings, unreferenced
4934 @smallexample @c ada
4935 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4939 This pragma signals that for the types or subtypes whose names are
4940 listed, objects which are declared with one of these types or subtypes may
4941 not be referenced, and if no references appear, no warnings are given.
4943 This is particularly useful for objects which are declared solely for their
4944 initialization and finalization effect. Such variables are sometimes referred
4945 to as RAII variables (Resource Acquisition Is Initialization). Using this
4946 pragma on the relevant type (most typically a limited controlled type), the
4947 compiler will automatically suppress unwanted warnings about these variables
4948 not being referenced.
4950 @node Pragma Unreserve_All_Interrupts
4951 @unnumberedsec Pragma Unreserve_All_Interrupts
4952 @findex Unreserve_All_Interrupts
4956 @smallexample @c ada
4957 pragma Unreserve_All_Interrupts;
4961 Normally certain interrupts are reserved to the implementation. Any attempt
4962 to attach an interrupt causes Program_Error to be raised, as described in
4963 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
4964 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
4965 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4966 interrupt execution.
4968 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4969 a program, then all such interrupts are unreserved. This allows the
4970 program to handle these interrupts, but disables their standard
4971 functions. For example, if this pragma is used, then pressing
4972 @kbd{Ctrl-C} will not automatically interrupt execution. However,
4973 a program can then handle the @code{SIGINT} interrupt as it chooses.
4975 For a full list of the interrupts handled in a specific implementation,
4976 see the source code for the spec of @code{Ada.Interrupts.Names} in
4977 file @file{a-intnam.ads}. This is a target dependent file that contains the
4978 list of interrupts recognized for a given target. The documentation in
4979 this file also specifies what interrupts are affected by the use of
4980 the @code{Unreserve_All_Interrupts} pragma.
4982 For a more general facility for controlling what interrupts can be
4983 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4984 of the @code{Unreserve_All_Interrupts} pragma.
4986 @node Pragma Unsuppress
4987 @unnumberedsec Pragma Unsuppress
4992 @smallexample @c ada
4993 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4997 This pragma undoes the effect of a previous pragma @code{Suppress}. If
4998 there is no corresponding pragma @code{Suppress} in effect, it has no
4999 effect. The range of the effect is the same as for pragma
5000 @code{Suppress}. The meaning of the arguments is identical to that used
5001 in pragma @code{Suppress}.
5003 One important application is to ensure that checks are on in cases where
5004 code depends on the checks for its correct functioning, so that the code
5005 will compile correctly even if the compiler switches are set to suppress
5008 @node Pragma Use_VADS_Size
5009 @unnumberedsec Pragma Use_VADS_Size
5010 @cindex @code{Size}, VADS compatibility
5011 @findex Use_VADS_Size
5015 @smallexample @c ada
5016 pragma Use_VADS_Size;
5020 This is a configuration pragma. In a unit to which it applies, any use
5021 of the 'Size attribute is automatically interpreted as a use of the
5022 'VADS_Size attribute. Note that this may result in incorrect semantic
5023 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
5024 the handling of existing code which depends on the interpretation of Size
5025 as implemented in the VADS compiler. See description of the VADS_Size
5026 attribute for further details.
5028 @node Pragma Validity_Checks
5029 @unnumberedsec Pragma Validity_Checks
5030 @findex Validity_Checks
5034 @smallexample @c ada
5035 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5039 This pragma is used in conjunction with compiler switches to control the
5040 built-in validity checking provided by GNAT@. The compiler switches, if set
5041 provide an initial setting for the switches, and this pragma may be used
5042 to modify these settings, or the settings may be provided entirely by
5043 the use of the pragma. This pragma can be used anywhere that a pragma
5044 is legal, including use as a configuration pragma (including use in
5045 the @file{gnat.adc} file).
5047 The form with a string literal specifies which validity options are to be
5048 activated. The validity checks are first set to include only the default
5049 reference manual settings, and then a string of letters in the string
5050 specifies the exact set of options required. The form of this string
5051 is exactly as described for the @option{-gnatVx} compiler switch (see the
5052 GNAT users guide for details). For example the following two methods
5053 can be used to enable validity checking for mode @code{in} and
5054 @code{in out} subprogram parameters:
5058 @smallexample @c ada
5059 pragma Validity_Checks ("im");
5064 gcc -c -gnatVim @dots{}
5069 The form ALL_CHECKS activates all standard checks (its use is equivalent
5070 to the use of the @code{gnatva} switch.
5072 The forms with @code{Off} and @code{On}
5073 can be used to temporarily disable validity checks
5074 as shown in the following example:
5076 @smallexample @c ada
5080 pragma Validity_Checks ("c"); -- validity checks for copies
5081 pragma Validity_Checks (Off); -- turn off validity checks
5082 A := B; -- B will not be validity checked
5083 pragma Validity_Checks (On); -- turn validity checks back on
5084 A := C; -- C will be validity checked
5087 @node Pragma Volatile
5088 @unnumberedsec Pragma Volatile
5093 @smallexample @c ada
5094 pragma Volatile (LOCAL_NAME);
5098 This pragma is defined by the Ada Reference Manual, and the GNAT
5099 implementation is fully conformant with this definition. The reason it
5100 is mentioned in this section is that a pragma of the same name was supplied
5101 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
5102 implementation of pragma Volatile is upwards compatible with the
5103 implementation in DEC Ada 83.
5105 @node Pragma Warnings
5106 @unnumberedsec Pragma Warnings
5111 @smallexample @c ada
5112 pragma Warnings (On | Off);
5113 pragma Warnings (On | Off, LOCAL_NAME);
5114 pragma Warnings (static_string_EXPRESSION);
5115 pragma Warnings (On | Off, static_string_EXPRESSION);
5119 Normally warnings are enabled, with the output being controlled by
5120 the command line switch. Warnings (@code{Off}) turns off generation of
5121 warnings until a Warnings (@code{On}) is encountered or the end of the
5122 current unit. If generation of warnings is turned off using this
5123 pragma, then no warning messages are output, regardless of the
5124 setting of the command line switches.
5126 The form with a single argument may be used as a configuration pragma.
5128 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5129 the specified entity. This suppression is effective from the point where
5130 it occurs till the end of the extended scope of the variable (similar to
5131 the scope of @code{Suppress}).
5133 The form with a single static_string_EXPRESSION argument provides more precise
5134 control over which warnings are active. The string is a list of letters
5135 specifying which warnings are to be activated and which deactivated. The
5136 code for these letters is the same as the string used in the command
5137 line switch controlling warnings. The following is a brief summary. For
5138 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5142 a turn on all optional warnings (except d h l .o)
5143 A turn off all optional warnings
5144 .a* turn on warnings for failing assertions
5145 .A turn off warnings for failing assertions
5146 b turn on warnings for bad fixed value (not multiple of small)
5147 B* turn off warnings for bad fixed value (not multiple of small)
5148 .b* turn on warnings for biased representation
5149 .B turn off warnings for biased representation
5150 c turn on warnings for constant conditional
5151 C* turn off warnings for constant conditional
5152 .c turn on warnings for unrepped components
5153 .C* turn off warnings for unrepped components
5154 d turn on warnings for implicit dereference
5155 D* turn off warnings for implicit dereference
5156 e treat all warnings as errors
5157 .e turn on every optional warning
5158 f turn on warnings for unreferenced formal
5159 F* turn off warnings for unreferenced formal
5160 g* turn on warnings for unrecognized pragma
5161 G turn off warnings for unrecognized pragma
5162 h turn on warnings for hiding variable
5163 H* turn off warnings for hiding variable
5164 i* turn on warnings for implementation unit
5165 I turn off warnings for implementation unit
5166 j turn on warnings for obsolescent (annex J) feature
5167 J* turn off warnings for obsolescent (annex J) feature
5168 k turn on warnings on constant variable
5169 K* turn off warnings on constant variable
5170 l turn on warnings for missing elaboration pragma
5171 L* turn off warnings for missing elaboration pragma
5172 m turn on warnings for variable assigned but not read
5173 M* turn off warnings for variable assigned but not read
5174 n* normal warning mode (cancels -gnatws/-gnatwe)
5175 o* turn on warnings for address clause overlay
5176 O turn off warnings for address clause overlay
5177 .o turn on warnings for out parameters assigned but not read
5178 .O* turn off warnings for out parameters assigned but not read
5179 p turn on warnings for ineffective pragma Inline in frontend
5180 P* turn off warnings for ineffective pragma Inline in frontend
5181 .p turn on warnings for parameter ordering
5182 .P* turn off warnings for parameter ordering
5183 q* turn on warnings for questionable missing parentheses
5184 Q turn off warnings for questionable missing parentheses
5185 r turn on warnings for redundant construct
5186 R* turn off warnings for redundant construct
5187 .r turn on warnings for object renaming function
5188 .R* turn off warnings for object renaming function
5189 s suppress all warnings
5190 t turn on warnings for tracking deleted code
5191 T* turn off warnings for tracking deleted code
5192 u turn on warnings for unused entity
5193 U* turn off warnings for unused entity
5194 v* turn on warnings for unassigned variable
5195 V turn off warnings for unassigned variable
5196 w* turn on warnings for wrong low bound assumption
5197 W turn off warnings for wrong low bound assumption
5198 .w turn on warnings for unnecessary Warnings Off pragmas
5199 .W* turn off warnings for unnecessary Warnings Off pragmas
5200 x* turn on warnings for export/import
5201 X turn off warnings for export/import
5202 .x turn on warnings for non-local exceptions
5203 .X* turn off warnings for non-local exceptions
5204 y* turn on warnings for Ada 2005 incompatibility
5205 Y turn off warnings for Ada 2005 incompatibility
5206 z* turn on convention/size/align warnings for unchecked conversion
5207 Z turn off convention/size/align warnings for unchecked conversion
5208 * indicates default in above list
5212 The specified warnings will be in effect until the end of the program
5213 or another pragma Warnings is encountered. The effect of the pragma is
5214 cumulative. Initially the set of warnings is the standard default set
5215 as possibly modified by compiler switches. Then each pragma Warning
5216 modifies this set of warnings as specified. This form of the pragma may
5217 also be used as a configuration pragma.
5219 The fourth form, with an On|Off parameter and a string, is used to
5220 control individual messages, based on their text. The string argument
5221 is a pattern that is used to match against the text of individual
5222 warning messages (not including the initial "warning: " tag).
5224 The pattern may contain asterisks, which match zero or more characters in
5225 the message. For example, you can use
5226 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5227 message @code{warning: 960 bits of "a" unused}. No other regular
5228 expression notations are permitted. All characters other than asterisk in
5229 these three specific cases are treated as literal characters in the match.
5231 There are two ways to use this pragma. The OFF form can be used as a
5232 configuration pragma. The effect is to suppress all warnings (if any)
5233 that match the pattern string throughout the compilation.
5235 The second usage is to suppress a warning locally, and in this case, two
5236 pragmas must appear in sequence:
5238 @smallexample @c ada
5239 pragma Warnings (Off, Pattern);
5240 @dots{} code where given warning is to be suppressed
5241 pragma Warnings (On, Pattern);
5245 In this usage, the pattern string must match in the Off and On pragmas,
5246 and at least one matching warning must be suppressed.
5248 @node Pragma Weak_External
5249 @unnumberedsec Pragma Weak_External
5250 @findex Weak_External
5254 @smallexample @c ada
5255 pragma Weak_External ([Entity =>] LOCAL_NAME);
5259 @var{LOCAL_NAME} must refer to an object that is declared at the library
5260 level. This pragma specifies that the given entity should be marked as a
5261 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5262 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5263 of a regular symbol, that is to say a symbol that does not have to be
5264 resolved by the linker if used in conjunction with a pragma Import.
5266 When a weak symbol is not resolved by the linker, its address is set to
5267 zero. This is useful in writing interfaces to external modules that may
5268 or may not be linked in the final executable, for example depending on
5269 configuration settings.
5271 If a program references at run time an entity to which this pragma has been
5272 applied, and the corresponding symbol was not resolved at link time, then
5273 the execution of the program is erroneous. It is not erroneous to take the
5274 Address of such an entity, for example to guard potential references,
5275 as shown in the example below.
5277 Some file formats do not support weak symbols so not all target machines
5278 support this pragma.
5280 @smallexample @c ada
5281 -- Example of the use of pragma Weak_External
5283 package External_Module is
5285 pragma Import (C, key);
5286 pragma Weak_External (key);
5287 function Present return boolean;
5288 end External_Module;
5290 with System; use System;
5291 package body External_Module is
5292 function Present return boolean is
5294 return key'Address /= System.Null_Address;
5296 end External_Module;
5299 @node Pragma Wide_Character_Encoding
5300 @unnumberedsec Pragma Wide_Character_Encoding
5301 @findex Wide_Character_Encoding
5305 @smallexample @c ada
5306 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5310 This pragma specifies the wide character encoding to be used in program
5311 source text appearing subsequently. It is a configuration pragma, but may
5312 also be used at any point that a pragma is allowed, and it is permissible
5313 to have more than one such pragma in a file, allowing multiple encodings
5314 to appear within the same file.
5316 The argument can be an identifier or a character literal. In the identifier
5317 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5318 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5319 case it is correspondingly one of the characters @samp{h}, @samp{u},
5320 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5322 Note that when the pragma is used within a file, it affects only the
5323 encoding within that file, and does not affect withed units, specs,
5326 @node Implementation Defined Attributes
5327 @chapter Implementation Defined Attributes
5328 Ada defines (throughout the Ada reference manual,
5329 summarized in Annex K),
5330 a set of attributes that provide useful additional functionality in all
5331 areas of the language. These language defined attributes are implemented
5332 in GNAT and work as described in the Ada Reference Manual.
5334 In addition, Ada allows implementations to define additional
5335 attributes whose meaning is defined by the implementation. GNAT provides
5336 a number of these implementation-dependent attributes which can be used
5337 to extend and enhance the functionality of the compiler. This section of
5338 the GNAT reference manual describes these additional attributes.
5340 Note that any program using these attributes may not be portable to
5341 other compilers (although GNAT implements this set of attributes on all
5342 platforms). Therefore if portability to other compilers is an important
5343 consideration, you should minimize the use of these attributes.
5353 * Compiler_Version::
5355 * Default_Bit_Order::
5365 * Has_Access_Values::
5366 * Has_Discriminants::
5373 * Max_Interrupt_Priority::
5375 * Maximum_Alignment::
5380 * Passed_By_Reference::
5393 * Unconstrained_Array::
5394 * Universal_Literal_String::
5395 * Unrestricted_Access::
5403 @unnumberedsec Abort_Signal
5404 @findex Abort_Signal
5406 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5407 prefix) provides the entity for the special exception used to signal
5408 task abort or asynchronous transfer of control. Normally this attribute
5409 should only be used in the tasking runtime (it is highly peculiar, and
5410 completely outside the normal semantics of Ada, for a user program to
5411 intercept the abort exception).
5414 @unnumberedsec Address_Size
5415 @cindex Size of @code{Address}
5416 @findex Address_Size
5418 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5419 prefix) is a static constant giving the number of bits in an
5420 @code{Address}. It is the same value as System.Address'Size,
5421 but has the advantage of being static, while a direct
5422 reference to System.Address'Size is non-static because Address
5426 @unnumberedsec Asm_Input
5429 The @code{Asm_Input} attribute denotes a function that takes two
5430 parameters. The first is a string, the second is an expression of the
5431 type designated by the prefix. The first (string) argument is required
5432 to be a static expression, and is the constraint for the parameter,
5433 (e.g.@: what kind of register is required). The second argument is the
5434 value to be used as the input argument. The possible values for the
5435 constant are the same as those used in the RTL, and are dependent on
5436 the configuration file used to built the GCC back end.
5437 @ref{Machine Code Insertions}
5440 @unnumberedsec Asm_Output
5443 The @code{Asm_Output} attribute denotes a function that takes two
5444 parameters. The first is a string, the second is the name of a variable
5445 of the type designated by the attribute prefix. The first (string)
5446 argument is required to be a static expression and designates the
5447 constraint for the parameter (e.g.@: what kind of register is
5448 required). The second argument is the variable to be updated with the
5449 result. The possible values for constraint are the same as those used in
5450 the RTL, and are dependent on the configuration file used to build the
5451 GCC back end. If there are no output operands, then this argument may
5452 either be omitted, or explicitly given as @code{No_Output_Operands}.
5453 @ref{Machine Code Insertions}
5456 @unnumberedsec AST_Entry
5460 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
5461 the name of an entry, it yields a value of the predefined type AST_Handler
5462 (declared in the predefined package System, as extended by the use of
5463 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
5464 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
5465 Language Reference Manual}, section 9.12a.
5470 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5471 offset within the storage unit (byte) that contains the first bit of
5472 storage allocated for the object. The value of this attribute is of the
5473 type @code{Universal_Integer}, and is always a non-negative number not
5474 exceeding the value of @code{System.Storage_Unit}.
5476 For an object that is a variable or a constant allocated in a register,
5477 the value is zero. (The use of this attribute does not force the
5478 allocation of a variable to memory).
5480 For an object that is a formal parameter, this attribute applies
5481 to either the matching actual parameter or to a copy of the
5482 matching actual parameter.
5484 For an access object the value is zero. Note that
5485 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5486 designated object. Similarly for a record component
5487 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5488 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5489 are subject to index checks.
5491 This attribute is designed to be compatible with the DEC Ada 83 definition
5492 and implementation of the @code{Bit} attribute.
5495 @unnumberedsec Bit_Position
5496 @findex Bit_Position
5498 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5499 of the fields of the record type, yields the bit
5500 offset within the record contains the first bit of
5501 storage allocated for the object. The value of this attribute is of the
5502 type @code{Universal_Integer}. The value depends only on the field
5503 @var{C} and is independent of the alignment of
5504 the containing record @var{R}.
5506 @node Compiler_Version
5507 @unnumberedsec Compiler_Version
5508 @findex Compiler_Version
5510 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
5511 prefix) yields a static string identifying the version of the compiler
5512 being used to compile the unit containing the attribute reference. A
5513 typical result would be something like "GNAT Pro 6.3.0w (20090221)".
5516 @unnumberedsec Code_Address
5517 @findex Code_Address
5518 @cindex Subprogram address
5519 @cindex Address of subprogram code
5522 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5523 intended effect seems to be to provide
5524 an address value which can be used to call the subprogram by means of
5525 an address clause as in the following example:
5527 @smallexample @c ada
5528 procedure K is @dots{}
5531 for L'Address use K'Address;
5532 pragma Import (Ada, L);
5536 A call to @code{L} is then expected to result in a call to @code{K}@.
5537 In Ada 83, where there were no access-to-subprogram values, this was
5538 a common work-around for getting the effect of an indirect call.
5539 GNAT implements the above use of @code{Address} and the technique
5540 illustrated by the example code works correctly.
5542 However, for some purposes, it is useful to have the address of the start
5543 of the generated code for the subprogram. On some architectures, this is
5544 not necessarily the same as the @code{Address} value described above.
5545 For example, the @code{Address} value may reference a subprogram
5546 descriptor rather than the subprogram itself.
5548 The @code{'Code_Address} attribute, which can only be applied to
5549 subprogram entities, always returns the address of the start of the
5550 generated code of the specified subprogram, which may or may not be
5551 the same value as is returned by the corresponding @code{'Address}
5554 @node Default_Bit_Order
5555 @unnumberedsec Default_Bit_Order
5557 @cindex Little endian
5558 @findex Default_Bit_Order
5560 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5561 permissible prefix), provides the value @code{System.Default_Bit_Order}
5562 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5563 @code{Low_Order_First}). This is used to construct the definition of
5564 @code{Default_Bit_Order} in package @code{System}.
5567 @unnumberedsec Elaborated
5570 The prefix of the @code{'Elaborated} attribute must be a unit name. The
5571 value is a Boolean which indicates whether or not the given unit has been
5572 elaborated. This attribute is primarily intended for internal use by the
5573 generated code for dynamic elaboration checking, but it can also be used
5574 in user programs. The value will always be True once elaboration of all
5575 units has been completed. An exception is for units which need no
5576 elaboration, the value is always False for such units.
5579 @unnumberedsec Elab_Body
5582 This attribute can only be applied to a program unit name. It returns
5583 the entity for the corresponding elaboration procedure for elaborating
5584 the body of the referenced unit. This is used in the main generated
5585 elaboration procedure by the binder and is not normally used in any
5586 other context. However, there may be specialized situations in which it
5587 is useful to be able to call this elaboration procedure from Ada code,
5588 e.g.@: if it is necessary to do selective re-elaboration to fix some
5592 @unnumberedsec Elab_Spec
5595 This attribute can only be applied to a program unit name. It returns
5596 the entity for the corresponding elaboration procedure for elaborating
5597 the spec of the referenced unit. This is used in the main
5598 generated elaboration procedure by the binder and is not normally used
5599 in any other context. However, there may be specialized situations in
5600 which it is useful to be able to call this elaboration procedure from
5601 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5606 @cindex Ada 83 attributes
5609 The @code{Emax} attribute is provided for compatibility with Ada 83. See
5610 the Ada 83 reference manual for an exact description of the semantics of
5614 @unnumberedsec Enabled
5617 The @code{Enabled} attribute allows an application program to check at compile
5618 time to see if the designated check is currently enabled. The prefix is a
5619 simple identifier, referencing any predefined check name (other than
5620 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5621 no argument is given for the attribute, the check is for the general state
5622 of the check, if an argument is given, then it is an entity name, and the
5623 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5624 given naming the entity (if not, then the argument is ignored).
5626 Note that instantiations inherit the check status at the point of the
5627 instantiation, so a useful idiom is to have a library package that
5628 introduces a check name with @code{pragma Check_Name}, and then contains
5629 generic packages or subprograms which use the @code{Enabled} attribute
5630 to see if the check is enabled. A user of this package can then issue
5631 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5632 the package or subprogram, controlling whether the check will be present.
5635 @unnumberedsec Enum_Rep
5636 @cindex Representation of enums
5639 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5640 function with the following spec:
5642 @smallexample @c ada
5643 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5644 return @i{Universal_Integer};
5648 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5649 enumeration type or to a non-overloaded enumeration
5650 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
5651 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5652 enumeration literal or object.
5654 The function returns the representation value for the given enumeration
5655 value. This will be equal to value of the @code{Pos} attribute in the
5656 absence of an enumeration representation clause. This is a static
5657 attribute (i.e.@: the result is static if the argument is static).
5659 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5660 in which case it simply returns the integer value. The reason for this
5661 is to allow it to be used for @code{(<>)} discrete formal arguments in
5662 a generic unit that can be instantiated with either enumeration types
5663 or integer types. Note that if @code{Enum_Rep} is used on a modular
5664 type whose upper bound exceeds the upper bound of the largest signed
5665 integer type, and the argument is a variable, so that the universal
5666 integer calculation is done at run time, then the call to @code{Enum_Rep}
5667 may raise @code{Constraint_Error}.
5670 @unnumberedsec Enum_Val
5671 @cindex Representation of enums
5674 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5675 function with the following spec:
5677 @smallexample @c ada
5678 function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5679 return @var{S}'Base};
5683 The function returns the enumeration value whose representation matches the
5684 argument, or raises Constraint_Error if no enumeration literal of the type
5685 has the matching value.
5686 This will be equal to value of the @code{Val} attribute in the
5687 absence of an enumeration representation clause. This is a static
5688 attribute (i.e.@: the result is static if the argument is static).
5691 @unnumberedsec Epsilon
5692 @cindex Ada 83 attributes
5695 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
5696 the Ada 83 reference manual for an exact description of the semantics of
5700 @unnumberedsec Fixed_Value
5703 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5704 function with the following specification:
5706 @smallexample @c ada
5707 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5712 The value returned is the fixed-point value @var{V} such that
5714 @smallexample @c ada
5715 @var{V} = Arg * @var{S}'Small
5719 The effect is thus similar to first converting the argument to the
5720 integer type used to represent @var{S}, and then doing an unchecked
5721 conversion to the fixed-point type. The difference is
5722 that there are full range checks, to ensure that the result is in range.
5723 This attribute is primarily intended for use in implementation of the
5724 input-output functions for fixed-point values.
5726 @node Has_Access_Values
5727 @unnumberedsec Has_Access_Values
5728 @cindex Access values, testing for
5729 @findex Has_Access_Values
5731 The prefix of the @code{Has_Access_Values} attribute is a type. The result
5732 is a Boolean value which is True if the is an access type, or is a composite
5733 type with a component (at any nesting depth) that is an access type, and is
5735 The intended use of this attribute is in conjunction with generic
5736 definitions. If the attribute is applied to a generic private type, it
5737 indicates whether or not the corresponding actual type has access values.
5739 @node Has_Discriminants
5740 @unnumberedsec Has_Discriminants
5741 @cindex Discriminants, testing for
5742 @findex Has_Discriminants
5744 The prefix of the @code{Has_Discriminants} attribute is a type. The result
5745 is a Boolean value which is True if the type has discriminants, and False
5746 otherwise. The intended use of this attribute is in conjunction with generic
5747 definitions. If the attribute is applied to a generic private type, it
5748 indicates whether or not the corresponding actual type has discriminants.
5754 The @code{Img} attribute differs from @code{Image} in that it may be
5755 applied to objects as well as types, in which case it gives the
5756 @code{Image} for the subtype of the object. This is convenient for
5759 @smallexample @c ada
5760 Put_Line ("X = " & X'Img);
5764 has the same meaning as the more verbose:
5766 @smallexample @c ada
5767 Put_Line ("X = " & @var{T}'Image (X));
5771 where @var{T} is the (sub)type of the object @code{X}.
5774 @unnumberedsec Integer_Value
5775 @findex Integer_Value
5777 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5778 function with the following spec:
5780 @smallexample @c ada
5781 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5786 The value returned is the integer value @var{V}, such that
5788 @smallexample @c ada
5789 Arg = @var{V} * @var{T}'Small
5793 where @var{T} is the type of @code{Arg}.
5794 The effect is thus similar to first doing an unchecked conversion from
5795 the fixed-point type to its corresponding implementation type, and then
5796 converting the result to the target integer type. The difference is
5797 that there are full range checks, to ensure that the result is in range.
5798 This attribute is primarily intended for use in implementation of the
5799 standard input-output functions for fixed-point values.
5802 @unnumberedsec Invalid_Value
5803 @findex Invalid_Value
5805 For every scalar type S, S'Invalid_Value returns an undefined value of the
5806 type. If possible this value is an invalid representation for the type. The
5807 value returned is identical to the value used to initialize an otherwise
5808 uninitialized value of the type if pragma Initialize_Scalars is used,
5809 including the ability to modify the value with the binder -Sxx flag and
5810 relevant environment variables at run time.
5813 @unnumberedsec Large
5814 @cindex Ada 83 attributes
5817 The @code{Large} attribute is provided for compatibility with Ada 83. See
5818 the Ada 83 reference manual for an exact description of the semantics of
5822 @unnumberedsec Machine_Size
5823 @findex Machine_Size
5825 This attribute is identical to the @code{Object_Size} attribute. It is
5826 provided for compatibility with the DEC Ada 83 attribute of this name.
5829 @unnumberedsec Mantissa
5830 @cindex Ada 83 attributes
5833 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
5834 the Ada 83 reference manual for an exact description of the semantics of
5837 @node Max_Interrupt_Priority
5838 @unnumberedsec Max_Interrupt_Priority
5839 @cindex Interrupt priority, maximum
5840 @findex Max_Interrupt_Priority
5842 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5843 permissible prefix), provides the same value as
5844 @code{System.Max_Interrupt_Priority}.
5847 @unnumberedsec Max_Priority
5848 @cindex Priority, maximum
5849 @findex Max_Priority
5851 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5852 prefix) provides the same value as @code{System.Max_Priority}.
5854 @node Maximum_Alignment
5855 @unnumberedsec Maximum_Alignment
5856 @cindex Alignment, maximum
5857 @findex Maximum_Alignment
5859 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5860 permissible prefix) provides the maximum useful alignment value for the
5861 target. This is a static value that can be used to specify the alignment
5862 for an object, guaranteeing that it is properly aligned in all
5865 @node Mechanism_Code
5866 @unnumberedsec Mechanism_Code
5867 @cindex Return values, passing mechanism
5868 @cindex Parameters, passing mechanism
5869 @findex Mechanism_Code
5871 @code{@var{function}'Mechanism_Code} yields an integer code for the
5872 mechanism used for the result of function, and
5873 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5874 used for formal parameter number @var{n} (a static integer value with 1
5875 meaning the first parameter) of @var{subprogram}. The code returned is:
5883 by descriptor (default descriptor class)
5885 by descriptor (UBS: unaligned bit string)
5887 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5889 by descriptor (UBA: unaligned bit array)
5891 by descriptor (S: string, also scalar access type parameter)
5893 by descriptor (SB: string with arbitrary bounds)
5895 by descriptor (A: contiguous array)
5897 by descriptor (NCA: non-contiguous array)
5901 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5904 @node Null_Parameter
5905 @unnumberedsec Null_Parameter
5906 @cindex Zero address, passing
5907 @findex Null_Parameter
5909 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5910 type or subtype @var{T} allocated at machine address zero. The attribute
5911 is allowed only as the default expression of a formal parameter, or as
5912 an actual expression of a subprogram call. In either case, the
5913 subprogram must be imported.
5915 The identity of the object is represented by the address zero in the
5916 argument list, independent of the passing mechanism (explicit or
5919 This capability is needed to specify that a zero address should be
5920 passed for a record or other composite object passed by reference.
5921 There is no way of indicating this without the @code{Null_Parameter}
5925 @unnumberedsec Object_Size
5926 @cindex Size, used for objects
5929 The size of an object is not necessarily the same as the size of the type
5930 of an object. This is because by default object sizes are increased to be
5931 a multiple of the alignment of the object. For example,
5932 @code{Natural'Size} is
5933 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5934 Similarly, a record containing an integer and a character:
5936 @smallexample @c ada
5944 will have a size of 40 (that is @code{Rec'Size} will be 40. The
5945 alignment will be 4, because of the
5946 integer field, and so the default size of record objects for this type
5947 will be 64 (8 bytes).
5951 @cindex Capturing Old values
5952 @cindex Postconditions
5954 The attribute Prefix'Old can be used within a
5955 subprogram to refer to the value of the prefix on entry. So for
5956 example if you have an argument of a record type X called Arg1,
5957 you can refer to Arg1.Field'Old which yields the value of
5958 Arg1.Field on entry. The implementation simply involves generating
5959 an object declaration which captures the value on entry. Any
5960 prefix is allowed except one of a limited type (since limited
5961 types cannot be copied to capture their values) or a local variable
5962 (since it does not exist at subprogram entry time).
5964 The following example shows the use of 'Old to implement
5965 a test of a postcondition:
5967 @smallexample @c ada
5978 package body Old_Pkg is
5979 Count : Natural := 0;
5983 ... code manipulating the value of Count
5985 pragma Assert (Count = Count'Old + 1);
5991 Note that it is allowed to apply 'Old to a constant entity, but this will
5992 result in a warning, since the old and new values will always be the same.
5994 @node Passed_By_Reference
5995 @unnumberedsec Passed_By_Reference
5996 @cindex Parameters, when passed by reference
5997 @findex Passed_By_Reference
5999 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6000 a value of type @code{Boolean} value that is @code{True} if the type is
6001 normally passed by reference and @code{False} if the type is normally
6002 passed by copy in calls. For scalar types, the result is always @code{False}
6003 and is static. For non-scalar types, the result is non-static.
6006 @unnumberedsec Pool_Address
6007 @cindex Parameters, when passed by reference
6008 @findex Pool_Address
6010 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6011 of X within its storage pool. This is the same as
6012 @code{@var{X}'Address}, except that for an unconstrained array whose
6013 bounds are allocated just before the first component,
6014 @code{@var{X}'Pool_Address} returns the address of those bounds,
6015 whereas @code{@var{X}'Address} returns the address of the first
6018 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6019 the object is allocated'', which could be a user-defined storage pool,
6020 the global heap, on the stack, or in a static memory area. For an
6021 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6022 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6025 @unnumberedsec Range_Length
6026 @findex Range_Length
6028 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6029 the number of values represented by the subtype (zero for a null
6030 range). The result is static for static subtypes. @code{Range_Length}
6031 applied to the index subtype of a one dimensional array always gives the
6032 same result as @code{Range} applied to the array itself.
6035 @unnumberedsec Safe_Emax
6036 @cindex Ada 83 attributes
6039 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
6040 the Ada 83 reference manual for an exact description of the semantics of
6044 @unnumberedsec Safe_Large
6045 @cindex Ada 83 attributes
6048 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
6049 the Ada 83 reference manual for an exact description of the semantics of
6053 @unnumberedsec Small
6054 @cindex Ada 83 attributes
6057 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6059 GNAT also allows this attribute to be applied to floating-point types
6060 for compatibility with Ada 83. See
6061 the Ada 83 reference manual for an exact description of the semantics of
6062 this attribute when applied to floating-point types.
6065 @unnumberedsec Storage_Unit
6066 @findex Storage_Unit
6068 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6069 prefix) provides the same value as @code{System.Storage_Unit}.
6072 @unnumberedsec Stub_Type
6075 The GNAT implementation of remote access-to-classwide types is
6076 organized as described in AARM section E.4 (20.t): a value of an RACW type
6077 (designating a remote object) is represented as a normal access
6078 value, pointing to a "stub" object which in turn contains the
6079 necessary information to contact the designated remote object. A
6080 call on any dispatching operation of such a stub object does the
6081 remote call, if necessary, using the information in the stub object
6082 to locate the target partition, etc.
6084 For a prefix @code{T} that denotes a remote access-to-classwide type,
6085 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6087 By construction, the layout of @code{T'Stub_Type} is identical to that of
6088 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6089 unit @code{System.Partition_Interface}. Use of this attribute will create
6090 an implicit dependency on this unit.
6093 @unnumberedsec Target_Name
6096 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6097 prefix) provides a static string value that identifies the target
6098 for the current compilation. For GCC implementations, this is the
6099 standard gcc target name without the terminating slash (for
6100 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6106 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6107 provides the same value as @code{System.Tick},
6110 @unnumberedsec To_Address
6113 The @code{System'To_Address}
6114 (@code{System} is the only permissible prefix)
6115 denotes a function identical to
6116 @code{System.Storage_Elements.To_Address} except that
6117 it is a static attribute. This means that if its argument is
6118 a static expression, then the result of the attribute is a
6119 static expression. The result is that such an expression can be
6120 used in contexts (e.g.@: preelaborable packages) which require a
6121 static expression and where the function call could not be used
6122 (since the function call is always non-static, even if its
6123 argument is static).
6126 @unnumberedsec Type_Class
6129 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6130 the value of the type class for the full type of @var{type}. If
6131 @var{type} is a generic formal type, the value is the value for the
6132 corresponding actual subtype. The value of this attribute is of type
6133 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6135 @smallexample @c ada
6137 (Type_Class_Enumeration,
6139 Type_Class_Fixed_Point,
6140 Type_Class_Floating_Point,
6145 Type_Class_Address);
6149 Protected types yield the value @code{Type_Class_Task}, which thus
6150 applies to all concurrent types. This attribute is designed to
6151 be compatible with the DEC Ada 83 attribute of the same name.
6154 @unnumberedsec UET_Address
6157 The @code{UET_Address} attribute can only be used for a prefix which
6158 denotes a library package. It yields the address of the unit exception
6159 table when zero cost exception handling is used. This attribute is
6160 intended only for use within the GNAT implementation. See the unit
6161 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6162 for details on how this attribute is used in the implementation.
6164 @node Unconstrained_Array
6165 @unnumberedsec Unconstrained_Array
6166 @findex Unconstrained_Array
6168 The @code{Unconstrained_Array} attribute can be used with a prefix that
6169 denotes any type or subtype. It is a static attribute that yields
6170 @code{True} if the prefix designates an unconstrained array,
6171 and @code{False} otherwise. In a generic instance, the result is
6172 still static, and yields the result of applying this test to the
6175 @node Universal_Literal_String
6176 @unnumberedsec Universal_Literal_String
6177 @cindex Named numbers, representation of
6178 @findex Universal_Literal_String
6180 The prefix of @code{Universal_Literal_String} must be a named
6181 number. The static result is the string consisting of the characters of
6182 the number as defined in the original source. This allows the user
6183 program to access the actual text of named numbers without intermediate
6184 conversions and without the need to enclose the strings in quotes (which
6185 would preclude their use as numbers). This is used internally for the
6186 construction of values of the floating-point attributes from the file
6187 @file{ttypef.ads}, but may also be used by user programs.
6189 For example, the following program prints the first 50 digits of pi:
6191 @smallexample @c ada
6192 with Text_IO; use Text_IO;
6196 Put (Ada.Numerics.Pi'Universal_Literal_String);
6200 @node Unrestricted_Access
6201 @unnumberedsec Unrestricted_Access
6202 @cindex @code{Access}, unrestricted
6203 @findex Unrestricted_Access
6205 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6206 except that all accessibility and aliased view checks are omitted. This
6207 is a user-beware attribute. It is similar to
6208 @code{Address}, for which it is a desirable replacement where the value
6209 desired is an access type. In other words, its effect is identical to
6210 first applying the @code{Address} attribute and then doing an unchecked
6211 conversion to a desired access type. In GNAT, but not necessarily in
6212 other implementations, the use of static chains for inner level
6213 subprograms means that @code{Unrestricted_Access} applied to a
6214 subprogram yields a value that can be called as long as the subprogram
6215 is in scope (normal Ada accessibility rules restrict this usage).
6217 It is possible to use @code{Unrestricted_Access} for any type, but care
6218 must be exercised if it is used to create pointers to unconstrained
6219 objects. In this case, the resulting pointer has the same scope as the
6220 context of the attribute, and may not be returned to some enclosing
6221 scope. For instance, a function cannot use @code{Unrestricted_Access}
6222 to create a unconstrained pointer and then return that value to the
6226 @unnumberedsec VADS_Size
6227 @cindex @code{Size}, VADS compatibility
6230 The @code{'VADS_Size} attribute is intended to make it easier to port
6231 legacy code which relies on the semantics of @code{'Size} as implemented
6232 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
6233 same semantic interpretation. In particular, @code{'VADS_Size} applied
6234 to a predefined or other primitive type with no Size clause yields the
6235 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6236 typical machines). In addition @code{'VADS_Size} applied to an object
6237 gives the result that would be obtained by applying the attribute to
6238 the corresponding type.
6241 @unnumberedsec Value_Size
6242 @cindex @code{Size}, setting for not-first subtype
6244 @code{@var{type}'Value_Size} is the number of bits required to represent
6245 a value of the given subtype. It is the same as @code{@var{type}'Size},
6246 but, unlike @code{Size}, may be set for non-first subtypes.
6249 @unnumberedsec Wchar_T_Size
6250 @findex Wchar_T_Size
6251 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6252 prefix) provides the size in bits of the C @code{wchar_t} type
6253 primarily for constructing the definition of this type in
6254 package @code{Interfaces.C}.
6257 @unnumberedsec Word_Size
6259 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6260 prefix) provides the value @code{System.Word_Size}.
6262 @c ------------------------
6263 @node Implementation Advice
6264 @chapter Implementation Advice
6266 The main text of the Ada Reference Manual describes the required
6267 behavior of all Ada compilers, and the GNAT compiler conforms to
6270 In addition, there are sections throughout the Ada Reference Manual headed
6271 by the phrase ``Implementation advice''. These sections are not normative,
6272 i.e., they do not specify requirements that all compilers must
6273 follow. Rather they provide advice on generally desirable behavior. You
6274 may wonder why they are not requirements. The most typical answer is
6275 that they describe behavior that seems generally desirable, but cannot
6276 be provided on all systems, or which may be undesirable on some systems.
6278 As far as practical, GNAT follows the implementation advice sections in
6279 the Ada Reference Manual. This chapter contains a table giving the
6280 reference manual section number, paragraph number and several keywords
6281 for each advice. Each entry consists of the text of the advice followed
6282 by the GNAT interpretation of this advice. Most often, this simply says
6283 ``followed'', which means that GNAT follows the advice. However, in a
6284 number of cases, GNAT deliberately deviates from this advice, in which
6285 case the text describes what GNAT does and why.
6287 @cindex Error detection
6288 @unnumberedsec 1.1.3(20): Error Detection
6291 If an implementation detects the use of an unsupported Specialized Needs
6292 Annex feature at run time, it should raise @code{Program_Error} if
6295 Not relevant. All specialized needs annex features are either supported,
6296 or diagnosed at compile time.
6299 @unnumberedsec 1.1.3(31): Child Units
6302 If an implementation wishes to provide implementation-defined
6303 extensions to the functionality of a language-defined library unit, it
6304 should normally do so by adding children to the library unit.
6308 @cindex Bounded errors
6309 @unnumberedsec 1.1.5(12): Bounded Errors
6312 If an implementation detects a bounded error or erroneous
6313 execution, it should raise @code{Program_Error}.
6315 Followed in all cases in which the implementation detects a bounded
6316 error or erroneous execution. Not all such situations are detected at
6320 @unnumberedsec 2.8(16): Pragmas
6323 Normally, implementation-defined pragmas should have no semantic effect
6324 for error-free programs; that is, if the implementation-defined pragmas
6325 are removed from a working program, the program should still be legal,
6326 and should still have the same semantics.
6328 The following implementation defined pragmas are exceptions to this
6340 @item CPP_Constructor
6344 @item Interface_Name
6346 @item Machine_Attribute
6348 @item Unimplemented_Unit
6350 @item Unchecked_Union
6355 In each of the above cases, it is essential to the purpose of the pragma
6356 that this advice not be followed. For details see the separate section
6357 on implementation defined pragmas.
6359 @unnumberedsec 2.8(17-19): Pragmas
6362 Normally, an implementation should not define pragmas that can
6363 make an illegal program legal, except as follows:
6367 A pragma used to complete a declaration, such as a pragma @code{Import};
6371 A pragma used to configure the environment by adding, removing, or
6372 replacing @code{library_items}.
6374 See response to paragraph 16 of this same section.
6376 @cindex Character Sets
6377 @cindex Alternative Character Sets
6378 @unnumberedsec 3.5.2(5): Alternative Character Sets
6381 If an implementation supports a mode with alternative interpretations
6382 for @code{Character} and @code{Wide_Character}, the set of graphic
6383 characters of @code{Character} should nevertheless remain a proper
6384 subset of the set of graphic characters of @code{Wide_Character}. Any
6385 character set ``localizations'' should be reflected in the results of
6386 the subprograms defined in the language-defined package
6387 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
6388 an alternative interpretation of @code{Character}, the implementation should
6389 also support a corresponding change in what is a legal
6390 @code{identifier_letter}.
6392 Not all wide character modes follow this advice, in particular the JIS
6393 and IEC modes reflect standard usage in Japan, and in these encoding,
6394 the upper half of the Latin-1 set is not part of the wide-character
6395 subset, since the most significant bit is used for wide character
6396 encoding. However, this only applies to the external forms. Internally
6397 there is no such restriction.
6399 @cindex Integer types
6400 @unnumberedsec 3.5.4(28): Integer Types
6404 An implementation should support @code{Long_Integer} in addition to
6405 @code{Integer} if the target machine supports 32-bit (or longer)
6406 arithmetic. No other named integer subtypes are recommended for package
6407 @code{Standard}. Instead, appropriate named integer subtypes should be
6408 provided in the library package @code{Interfaces} (see B.2).
6410 @code{Long_Integer} is supported. Other standard integer types are supported
6411 so this advice is not fully followed. These types
6412 are supported for convenient interface to C, and so that all hardware
6413 types of the machine are easily available.
6414 @unnumberedsec 3.5.4(29): Integer Types
6418 An implementation for a two's complement machine should support
6419 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
6420 implementation should support a non-binary modules up to @code{Integer'Last}.
6424 @cindex Enumeration values
6425 @unnumberedsec 3.5.5(8): Enumeration Values
6428 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6429 subtype, if the value of the operand does not correspond to the internal
6430 code for any enumeration literal of its type (perhaps due to an
6431 un-initialized variable), then the implementation should raise
6432 @code{Program_Error}. This is particularly important for enumeration
6433 types with noncontiguous internal codes specified by an
6434 enumeration_representation_clause.
6439 @unnumberedsec 3.5.7(17): Float Types
6442 An implementation should support @code{Long_Float} in addition to
6443 @code{Float} if the target machine supports 11 or more digits of
6444 precision. No other named floating point subtypes are recommended for
6445 package @code{Standard}. Instead, appropriate named floating point subtypes
6446 should be provided in the library package @code{Interfaces} (see B.2).
6448 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
6449 former provides improved compatibility with other implementations
6450 supporting this type. The latter corresponds to the highest precision
6451 floating-point type supported by the hardware. On most machines, this
6452 will be the same as @code{Long_Float}, but on some machines, it will
6453 correspond to the IEEE extended form. The notable case is all ia32
6454 (x86) implementations, where @code{Long_Long_Float} corresponds to
6455 the 80-bit extended precision format supported in hardware on this
6456 processor. Note that the 128-bit format on SPARC is not supported,
6457 since this is a software rather than a hardware format.
6459 @cindex Multidimensional arrays
6460 @cindex Arrays, multidimensional
6461 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6464 An implementation should normally represent multidimensional arrays in
6465 row-major order, consistent with the notation used for multidimensional
6466 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
6467 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6468 column-major order should be used instead (see B.5, ``Interfacing with
6473 @findex Duration'Small
6474 @unnumberedsec 9.6(30-31): Duration'Small
6477 Whenever possible in an implementation, the value of @code{Duration'Small}
6478 should be no greater than 100 microseconds.
6480 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
6484 The time base for @code{delay_relative_statements} should be monotonic;
6485 it need not be the same time base as used for @code{Calendar.Clock}.
6489 @unnumberedsec 10.2.1(12): Consistent Representation
6492 In an implementation, a type declared in a pre-elaborated package should
6493 have the same representation in every elaboration of a given version of
6494 the package, whether the elaborations occur in distinct executions of
6495 the same program, or in executions of distinct programs or partitions
6496 that include the given version.
6498 Followed, except in the case of tagged types. Tagged types involve
6499 implicit pointers to a local copy of a dispatch table, and these pointers
6500 have representations which thus depend on a particular elaboration of the
6501 package. It is not easy to see how it would be possible to follow this
6502 advice without severely impacting efficiency of execution.
6504 @cindex Exception information
6505 @unnumberedsec 11.4.1(19): Exception Information
6508 @code{Exception_Message} by default and @code{Exception_Information}
6509 should produce information useful for
6510 debugging. @code{Exception_Message} should be short, about one
6511 line. @code{Exception_Information} can be long. @code{Exception_Message}
6512 should not include the
6513 @code{Exception_Name}. @code{Exception_Information} should include both
6514 the @code{Exception_Name} and the @code{Exception_Message}.
6516 Followed. For each exception that doesn't have a specified
6517 @code{Exception_Message}, the compiler generates one containing the location
6518 of the raise statement. This location has the form ``file:line'', where
6519 file is the short file name (without path information) and line is the line
6520 number in the file. Note that in the case of the Zero Cost Exception
6521 mechanism, these messages become redundant with the Exception_Information that
6522 contains a full backtrace of the calling sequence, so they are disabled.
6523 To disable explicitly the generation of the source location message, use the
6524 Pragma @code{Discard_Names}.
6526 @cindex Suppression of checks
6527 @cindex Checks, suppression of
6528 @unnumberedsec 11.5(28): Suppression of Checks
6531 The implementation should minimize the code executed for checks that
6532 have been suppressed.
6536 @cindex Representation clauses
6537 @unnumberedsec 13.1 (21-24): Representation Clauses
6540 The recommended level of support for all representation items is
6541 qualified as follows:
6545 An implementation need not support representation items containing
6546 non-static expressions, except that an implementation should support a
6547 representation item for a given entity if each non-static expression in
6548 the representation item is a name that statically denotes a constant
6549 declared before the entity.
6551 Followed. In fact, GNAT goes beyond the recommended level of support
6552 by allowing nonstatic expressions in some representation clauses even
6553 without the need to declare constants initialized with the values of
6557 @smallexample @c ada
6560 for Y'Address use X'Address;>>
6566 An implementation need not support a specification for the @code{Size}
6567 for a given composite subtype, nor the size or storage place for an
6568 object (including a component) of a given composite subtype, unless the
6569 constraints on the subtype and its composite subcomponents (if any) are
6570 all static constraints.
6572 Followed. Size Clauses are not permitted on non-static components, as
6577 An aliased component, or a component whose type is by-reference, should
6578 always be allocated at an addressable location.
6582 @cindex Packed types
6583 @unnumberedsec 13.2(6-8): Packed Types
6586 If a type is packed, then the implementation should try to minimize
6587 storage allocated to objects of the type, possibly at the expense of
6588 speed of accessing components, subject to reasonable complexity in
6589 addressing calculations.
6593 The recommended level of support pragma @code{Pack} is:
6595 For a packed record type, the components should be packed as tightly as
6596 possible subject to the Sizes of the component subtypes, and subject to
6597 any @code{record_representation_clause} that applies to the type; the
6598 implementation may, but need not, reorder components or cross aligned
6599 word boundaries to improve the packing. A component whose @code{Size} is
6600 greater than the word size may be allocated an integral number of words.
6602 Followed. Tight packing of arrays is supported for all component sizes
6603 up to 64-bits. If the array component size is 1 (that is to say, if
6604 the component is a boolean type or an enumeration type with two values)
6605 then values of the type are implicitly initialized to zero. This
6606 happens both for objects of the packed type, and for objects that have a
6607 subcomponent of the packed type.
6611 An implementation should support Address clauses for imported
6615 @cindex @code{Address} clauses
6616 @unnumberedsec 13.3(14-19): Address Clauses
6620 For an array @var{X}, @code{@var{X}'Address} should point at the first
6621 component of the array, and not at the array bounds.
6627 The recommended level of support for the @code{Address} attribute is:
6629 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6630 object that is aliased or of a by-reference type, or is an entity whose
6631 @code{Address} has been specified.
6633 Followed. A valid address will be produced even if none of those
6634 conditions have been met. If necessary, the object is forced into
6635 memory to ensure the address is valid.
6639 An implementation should support @code{Address} clauses for imported
6646 Objects (including subcomponents) that are aliased or of a by-reference
6647 type should be allocated on storage element boundaries.
6653 If the @code{Address} of an object is specified, or it is imported or exported,
6654 then the implementation should not perform optimizations based on
6655 assumptions of no aliases.
6659 @cindex @code{Alignment} clauses
6660 @unnumberedsec 13.3(29-35): Alignment Clauses
6663 The recommended level of support for the @code{Alignment} attribute for
6666 An implementation should support specified Alignments that are factors
6667 and multiples of the number of storage elements per word, subject to the
6674 An implementation need not support specified @code{Alignment}s for
6675 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6676 loaded and stored by available machine instructions.
6682 An implementation need not support specified @code{Alignment}s that are
6683 greater than the maximum @code{Alignment} the implementation ever returns by
6690 The recommended level of support for the @code{Alignment} attribute for
6693 Same as above, for subtypes, but in addition:
6699 For stand-alone library-level objects of statically constrained
6700 subtypes, the implementation should support all @code{Alignment}s
6701 supported by the target linker. For example, page alignment is likely to
6702 be supported for such objects, but not for subtypes.
6706 @cindex @code{Size} clauses
6707 @unnumberedsec 13.3(42-43): Size Clauses
6710 The recommended level of support for the @code{Size} attribute of
6713 A @code{Size} clause should be supported for an object if the specified
6714 @code{Size} is at least as large as its subtype's @code{Size}, and
6715 corresponds to a size in storage elements that is a multiple of the
6716 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6720 @unnumberedsec 13.3(50-56): Size Clauses
6723 If the @code{Size} of a subtype is specified, and allows for efficient
6724 independent addressability (see 9.10) on the target architecture, then
6725 the @code{Size} of the following objects of the subtype should equal the
6726 @code{Size} of the subtype:
6728 Aliased objects (including components).
6734 @code{Size} clause on a composite subtype should not affect the
6735 internal layout of components.
6737 Followed. But note that this can be overridden by use of the implementation
6738 pragma Implicit_Packing in the case of packed arrays.
6742 The recommended level of support for the @code{Size} attribute of subtypes is:
6746 The @code{Size} (if not specified) of a static discrete or fixed point
6747 subtype should be the number of bits needed to represent each value
6748 belonging to the subtype using an unbiased representation, leaving space
6749 for a sign bit only if the subtype contains negative values. If such a
6750 subtype is a first subtype, then an implementation should support a
6751 specified @code{Size} for it that reflects this representation.
6757 For a subtype implemented with levels of indirection, the @code{Size}
6758 should include the size of the pointers, but not the size of what they
6763 @cindex @code{Component_Size} clauses
6764 @unnumberedsec 13.3(71-73): Component Size Clauses
6767 The recommended level of support for the @code{Component_Size}
6772 An implementation need not support specified @code{Component_Sizes} that are
6773 less than the @code{Size} of the component subtype.
6779 An implementation should support specified @code{Component_Size}s that
6780 are factors and multiples of the word size. For such
6781 @code{Component_Size}s, the array should contain no gaps between
6782 components. For other @code{Component_Size}s (if supported), the array
6783 should contain no gaps between components when packing is also
6784 specified; the implementation should forbid this combination in cases
6785 where it cannot support a no-gaps representation.
6789 @cindex Enumeration representation clauses
6790 @cindex Representation clauses, enumeration
6791 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6794 The recommended level of support for enumeration representation clauses
6797 An implementation need not support enumeration representation clauses
6798 for boolean types, but should at minimum support the internal codes in
6799 the range @code{System.Min_Int.System.Max_Int}.
6803 @cindex Record representation clauses
6804 @cindex Representation clauses, records
6805 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6808 The recommended level of support for
6809 @*@code{record_representation_clauses} is:
6811 An implementation should support storage places that can be extracted
6812 with a load, mask, shift sequence of machine code, and set with a load,
6813 shift, mask, store sequence, given the available machine instructions
6820 A storage place should be supported if its size is equal to the
6821 @code{Size} of the component subtype, and it starts and ends on a
6822 boundary that obeys the @code{Alignment} of the component subtype.
6828 If the default bit ordering applies to the declaration of a given type,
6829 then for a component whose subtype's @code{Size} is less than the word
6830 size, any storage place that does not cross an aligned word boundary
6831 should be supported.
6837 An implementation may reserve a storage place for the tag field of a
6838 tagged type, and disallow other components from overlapping that place.
6840 Followed. The storage place for the tag field is the beginning of the tagged
6841 record, and its size is Address'Size. GNAT will reject an explicit component
6842 clause for the tag field.
6846 An implementation need not support a @code{component_clause} for a
6847 component of an extension part if the storage place is not after the
6848 storage places of all components of the parent type, whether or not
6849 those storage places had been specified.
6851 Followed. The above advice on record representation clauses is followed,
6852 and all mentioned features are implemented.
6854 @cindex Storage place attributes
6855 @unnumberedsec 13.5.2(5): Storage Place Attributes
6858 If a component is represented using some form of pointer (such as an
6859 offset) to the actual data of the component, and this data is contiguous
6860 with the rest of the object, then the storage place attributes should
6861 reflect the place of the actual data, not the pointer. If a component is
6862 allocated discontinuously from the rest of the object, then a warning
6863 should be generated upon reference to one of its storage place
6866 Followed. There are no such components in GNAT@.
6868 @cindex Bit ordering
6869 @unnumberedsec 13.5.3(7-8): Bit Ordering
6872 The recommended level of support for the non-default bit ordering is:
6876 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6877 should support the non-default bit ordering in addition to the default
6880 Followed. Word size does not equal storage size in this implementation.
6881 Thus non-default bit ordering is not supported.
6883 @cindex @code{Address}, as private type
6884 @unnumberedsec 13.7(37): Address as Private
6887 @code{Address} should be of a private type.
6891 @cindex Operations, on @code{Address}
6892 @cindex @code{Address}, operations of
6893 @unnumberedsec 13.7.1(16): Address Operations
6896 Operations in @code{System} and its children should reflect the target
6897 environment semantics as closely as is reasonable. For example, on most
6898 machines, it makes sense for address arithmetic to ``wrap around''.
6899 Operations that do not make sense should raise @code{Program_Error}.
6901 Followed. Address arithmetic is modular arithmetic that wraps around. No
6902 operation raises @code{Program_Error}, since all operations make sense.
6904 @cindex Unchecked conversion
6905 @unnumberedsec 13.9(14-17): Unchecked Conversion
6908 The @code{Size} of an array object should not include its bounds; hence,
6909 the bounds should not be part of the converted data.
6915 The implementation should not generate unnecessary run-time checks to
6916 ensure that the representation of @var{S} is a representation of the
6917 target type. It should take advantage of the permission to return by
6918 reference when possible. Restrictions on unchecked conversions should be
6919 avoided unless required by the target environment.
6921 Followed. There are no restrictions on unchecked conversion. A warning is
6922 generated if the source and target types do not have the same size since
6923 the semantics in this case may be target dependent.
6927 The recommended level of support for unchecked conversions is:
6931 Unchecked conversions should be supported and should be reversible in
6932 the cases where this clause defines the result. To enable meaningful use
6933 of unchecked conversion, a contiguous representation should be used for
6934 elementary subtypes, for statically constrained array subtypes whose
6935 component subtype is one of the subtypes described in this paragraph,
6936 and for record subtypes without discriminants whose component subtypes
6937 are described in this paragraph.
6941 @cindex Heap usage, implicit
6942 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6945 An implementation should document any cases in which it dynamically
6946 allocates heap storage for a purpose other than the evaluation of an
6949 Followed, the only other points at which heap storage is dynamically
6950 allocated are as follows:
6954 At initial elaboration time, to allocate dynamically sized global
6958 To allocate space for a task when a task is created.
6961 To extend the secondary stack dynamically when needed. The secondary
6962 stack is used for returning variable length results.
6967 A default (implementation-provided) storage pool for an
6968 access-to-constant type should not have overhead to support deallocation of
6975 A storage pool for an anonymous access type should be created at the
6976 point of an allocator for the type, and be reclaimed when the designated
6977 object becomes inaccessible.
6981 @cindex Unchecked deallocation
6982 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6985 For a standard storage pool, @code{Free} should actually reclaim the
6990 @cindex Stream oriented attributes
6991 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6994 If a stream element is the same size as a storage element, then the
6995 normal in-memory representation should be used by @code{Read} and
6996 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
6997 should use the smallest number of stream elements needed to represent
6998 all values in the base range of the scalar type.
7001 Followed. By default, GNAT uses the interpretation suggested by AI-195,
7002 which specifies using the size of the first subtype.
7003 However, such an implementation is based on direct binary
7004 representations and is therefore target- and endianness-dependent.
7005 To address this issue, GNAT also supplies an alternate implementation
7006 of the stream attributes @code{Read} and @code{Write},
7007 which uses the target-independent XDR standard representation
7009 @cindex XDR representation
7010 @cindex @code{Read} attribute
7011 @cindex @code{Write} attribute
7012 @cindex Stream oriented attributes
7013 The XDR implementation is provided as an alternative body of the
7014 @code{System.Stream_Attributes} package, in the file
7015 @file{s-strxdr.adb} in the GNAT library.
7016 There is no @file{s-strxdr.ads} file.
7017 In order to install the XDR implementation, do the following:
7019 @item Replace the default implementation of the
7020 @code{System.Stream_Attributes} package with the XDR implementation.
7021 For example on a Unix platform issue the commands:
7023 $ mv s-stratt.adb s-strold.adb
7024 $ mv s-strxdr.adb s-stratt.adb
7028 Rebuild the GNAT run-time library as documented in
7029 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7032 @unnumberedsec A.1(52): Names of Predefined Numeric Types
7035 If an implementation provides additional named predefined integer types,
7036 then the names should end with @samp{Integer} as in
7037 @samp{Long_Integer}. If an implementation provides additional named
7038 predefined floating point types, then the names should end with
7039 @samp{Float} as in @samp{Long_Float}.
7043 @findex Ada.Characters.Handling
7044 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7047 If an implementation provides a localized definition of @code{Character}
7048 or @code{Wide_Character}, then the effects of the subprograms in
7049 @code{Characters.Handling} should reflect the localizations. See also
7052 Followed. GNAT provides no such localized definitions.
7054 @cindex Bounded-length strings
7055 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7058 Bounded string objects should not be implemented by implicit pointers
7059 and dynamic allocation.
7061 Followed. No implicit pointers or dynamic allocation are used.
7063 @cindex Random number generation
7064 @unnumberedsec A.5.2(46-47): Random Number Generation
7067 Any storage associated with an object of type @code{Generator} should be
7068 reclaimed on exit from the scope of the object.
7074 If the generator period is sufficiently long in relation to the number
7075 of distinct initiator values, then each possible value of
7076 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7077 random numbers that does not, in a practical sense, overlap the sequence
7078 initiated by any other value. If this is not possible, then the mapping
7079 between initiator values and generator states should be a rapidly
7080 varying function of the initiator value.
7082 Followed. The generator period is sufficiently long for the first
7083 condition here to hold true.
7085 @findex Get_Immediate
7086 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7089 The @code{Get_Immediate} procedures should be implemented with
7090 unbuffered input. For a device such as a keyboard, input should be
7091 @dfn{available} if a key has already been typed, whereas for a disk
7092 file, input should always be available except at end of file. For a file
7093 associated with a keyboard-like device, any line-editing features of the
7094 underlying operating system should be disabled during the execution of
7095 @code{Get_Immediate}.
7097 Followed on all targets except VxWorks. For VxWorks, there is no way to
7098 provide this functionality that does not result in the input buffer being
7099 flushed before the @code{Get_Immediate} call. A special unit
7100 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7104 @unnumberedsec B.1(39-41): Pragma @code{Export}
7107 If an implementation supports pragma @code{Export} to a given language,
7108 then it should also allow the main subprogram to be written in that
7109 language. It should support some mechanism for invoking the elaboration
7110 of the Ada library units included in the system, and for invoking the
7111 finalization of the environment task. On typical systems, the
7112 recommended mechanism is to provide two subprograms whose link names are
7113 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
7114 elaboration code for library units. @code{adafinal} should contain the
7115 finalization code. These subprograms should have no effect the second
7116 and subsequent time they are called.
7122 Automatic elaboration of pre-elaborated packages should be
7123 provided when pragma @code{Export} is supported.
7125 Followed when the main program is in Ada. If the main program is in a
7126 foreign language, then
7127 @code{adainit} must be called to elaborate pre-elaborated
7132 For each supported convention @var{L} other than @code{Intrinsic}, an
7133 implementation should support @code{Import} and @code{Export} pragmas
7134 for objects of @var{L}-compatible types and for subprograms, and pragma
7135 @code{Convention} for @var{L}-eligible types and for subprograms,
7136 presuming the other language has corresponding features. Pragma
7137 @code{Convention} need not be supported for scalar types.
7141 @cindex Package @code{Interfaces}
7143 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7146 For each implementation-defined convention identifier, there should be a
7147 child package of package Interfaces with the corresponding name. This
7148 package should contain any declarations that would be useful for
7149 interfacing to the language (implementation) represented by the
7150 convention. Any declarations useful for interfacing to any language on
7151 the given hardware architecture should be provided directly in
7154 Followed. An additional package not defined
7155 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7156 for interfacing to C++.
7160 An implementation supporting an interface to C, COBOL, or Fortran should
7161 provide the corresponding package or packages described in the following
7164 Followed. GNAT provides all the packages described in this section.
7166 @cindex C, interfacing with
7167 @unnumberedsec B.3(63-71): Interfacing with C
7170 An implementation should support the following interface correspondences
7177 An Ada procedure corresponds to a void-returning C function.
7183 An Ada function corresponds to a non-void C function.
7189 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7196 An Ada @code{in} parameter of an access-to-object type with designated
7197 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7198 where @var{t} is the C type corresponding to the Ada type @var{T}.
7204 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7205 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7206 argument to a C function, where @var{t} is the C type corresponding to
7207 the Ada type @var{T}. In the case of an elementary @code{out} or
7208 @code{in out} parameter, a pointer to a temporary copy is used to
7209 preserve by-copy semantics.
7215 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7216 @code{@var{t}*} argument to a C function, where @var{t} is the C
7217 structure corresponding to the Ada type @var{T}.
7219 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
7220 pragma, or Convention, or by explicitly specifying the mechanism for a given
7221 call using an extended import or export pragma.
7225 An Ada parameter of an array type with component type @var{T}, of any
7226 mode, is passed as a @code{@var{t}*} argument to a C function, where
7227 @var{t} is the C type corresponding to the Ada type @var{T}.
7233 An Ada parameter of an access-to-subprogram type is passed as a pointer
7234 to a C function whose prototype corresponds to the designated
7235 subprogram's specification.
7239 @cindex COBOL, interfacing with
7240 @unnumberedsec B.4(95-98): Interfacing with COBOL
7243 An Ada implementation should support the following interface
7244 correspondences between Ada and COBOL@.
7250 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7251 the COBOL type corresponding to @var{T}.
7257 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7258 the corresponding COBOL type.
7264 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7265 COBOL type corresponding to the Ada parameter type; for scalars, a local
7266 copy is used if necessary to ensure by-copy semantics.
7270 @cindex Fortran, interfacing with
7271 @unnumberedsec B.5(22-26): Interfacing with Fortran
7274 An Ada implementation should support the following interface
7275 correspondences between Ada and Fortran:
7281 An Ada procedure corresponds to a Fortran subroutine.
7287 An Ada function corresponds to a Fortran function.
7293 An Ada parameter of an elementary, array, or record type @var{T} is
7294 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7295 the Fortran type corresponding to the Ada type @var{T}, and where the
7296 INTENT attribute of the corresponding dummy argument matches the Ada
7297 formal parameter mode; the Fortran implementation's parameter passing
7298 conventions are used. For elementary types, a local copy is used if
7299 necessary to ensure by-copy semantics.
7305 An Ada parameter of an access-to-subprogram type is passed as a
7306 reference to a Fortran procedure whose interface corresponds to the
7307 designated subprogram's specification.
7311 @cindex Machine operations
7312 @unnumberedsec C.1(3-5): Access to Machine Operations
7315 The machine code or intrinsic support should allow access to all
7316 operations normally available to assembly language programmers for the
7317 target environment, including privileged instructions, if any.
7323 The interfacing pragmas (see Annex B) should support interface to
7324 assembler; the default assembler should be associated with the
7325 convention identifier @code{Assembler}.
7331 If an entity is exported to assembly language, then the implementation
7332 should allocate it at an addressable location, and should ensure that it
7333 is retained by the linking process, even if not otherwise referenced
7334 from the Ada code. The implementation should assume that any call to a
7335 machine code or assembler subprogram is allowed to read or update every
7336 object that is specified as exported.
7340 @unnumberedsec C.1(10-16): Access to Machine Operations
7343 The implementation should ensure that little or no overhead is
7344 associated with calling intrinsic and machine-code subprograms.
7346 Followed for both intrinsics and machine-code subprograms.
7350 It is recommended that intrinsic subprograms be provided for convenient
7351 access to any machine operations that provide special capabilities or
7352 efficiency and that are not otherwise available through the language
7355 Followed. A full set of machine operation intrinsic subprograms is provided.
7359 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7360 swap, decrement and test, enqueue/dequeue.
7362 Followed on any target supporting such operations.
7366 Standard numeric functions---e.g.@:, sin, log.
7368 Followed on any target supporting such operations.
7372 String manipulation operations---e.g.@:, translate and test.
7374 Followed on any target supporting such operations.
7378 Vector operations---e.g.@:, compare vector against thresholds.
7380 Followed on any target supporting such operations.
7384 Direct operations on I/O ports.
7386 Followed on any target supporting such operations.
7388 @cindex Interrupt support
7389 @unnumberedsec C.3(28): Interrupt Support
7392 If the @code{Ceiling_Locking} policy is not in effect, the
7393 implementation should provide means for the application to specify which
7394 interrupts are to be blocked during protected actions, if the underlying
7395 system allows for a finer-grain control of interrupt blocking.
7397 Followed. The underlying system does not allow for finer-grain control
7398 of interrupt blocking.
7400 @cindex Protected procedure handlers
7401 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7404 Whenever possible, the implementation should allow interrupt handlers to
7405 be called directly by the hardware.
7409 This is never possible under IRIX, so this is followed by default.
7411 Followed on any target where the underlying operating system permits
7416 Whenever practical, violations of any
7417 implementation-defined restrictions should be detected before run time.
7419 Followed. Compile time warnings are given when possible.
7421 @cindex Package @code{Interrupts}
7423 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7427 If implementation-defined forms of interrupt handler procedures are
7428 supported, such as protected procedures with parameters, then for each
7429 such form of a handler, a type analogous to @code{Parameterless_Handler}
7430 should be specified in a child package of @code{Interrupts}, with the
7431 same operations as in the predefined package Interrupts.
7435 @cindex Pre-elaboration requirements
7436 @unnumberedsec C.4(14): Pre-elaboration Requirements
7439 It is recommended that pre-elaborated packages be implemented in such a
7440 way that there should be little or no code executed at run time for the
7441 elaboration of entities not already covered by the Implementation
7444 Followed. Executable code is generated in some cases, e.g.@: loops
7445 to initialize large arrays.
7447 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7451 If the pragma applies to an entity, then the implementation should
7452 reduce the amount of storage used for storing names associated with that
7457 @cindex Package @code{Task_Attributes}
7458 @findex Task_Attributes
7459 @unnumberedsec C.7.2(30): The Package Task_Attributes
7462 Some implementations are targeted to domains in which memory use at run
7463 time must be completely deterministic. For such implementations, it is
7464 recommended that the storage for task attributes will be pre-allocated
7465 statically and not from the heap. This can be accomplished by either
7466 placing restrictions on the number and the size of the task's
7467 attributes, or by using the pre-allocated storage for the first @var{N}
7468 attribute objects, and the heap for the others. In the latter case,
7469 @var{N} should be documented.
7471 Not followed. This implementation is not targeted to such a domain.
7473 @cindex Locking Policies
7474 @unnumberedsec D.3(17): Locking Policies
7478 The implementation should use names that end with @samp{_Locking} for
7479 locking policies defined by the implementation.
7481 Followed. A single implementation-defined locking policy is defined,
7482 whose name (@code{Inheritance_Locking}) follows this suggestion.
7484 @cindex Entry queuing policies
7485 @unnumberedsec D.4(16): Entry Queuing Policies
7488 Names that end with @samp{_Queuing} should be used
7489 for all implementation-defined queuing policies.
7491 Followed. No such implementation-defined queuing policies exist.
7493 @cindex Preemptive abort
7494 @unnumberedsec D.6(9-10): Preemptive Abort
7497 Even though the @code{abort_statement} is included in the list of
7498 potentially blocking operations (see 9.5.1), it is recommended that this
7499 statement be implemented in a way that never requires the task executing
7500 the @code{abort_statement} to block.
7506 On a multi-processor, the delay associated with aborting a task on
7507 another processor should be bounded; the implementation should use
7508 periodic polling, if necessary, to achieve this.
7512 @cindex Tasking restrictions
7513 @unnumberedsec D.7(21): Tasking Restrictions
7516 When feasible, the implementation should take advantage of the specified
7517 restrictions to produce a more efficient implementation.
7519 GNAT currently takes advantage of these restrictions by providing an optimized
7520 run time when the Ravenscar profile and the GNAT restricted run time set
7521 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
7522 pragma @code{Profile (Restricted)} for more details.
7524 @cindex Time, monotonic
7525 @unnumberedsec D.8(47-49): Monotonic Time
7528 When appropriate, implementations should provide configuration
7529 mechanisms to change the value of @code{Tick}.
7531 Such configuration mechanisms are not appropriate to this implementation
7532 and are thus not supported.
7536 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7537 be implemented as transformations of the same time base.
7543 It is recommended that the @dfn{best} time base which exists in
7544 the underlying system be available to the application through
7545 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
7549 @cindex Partition communication subsystem
7551 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7554 Whenever possible, the PCS on the called partition should allow for
7555 multiple tasks to call the RPC-receiver with different messages and
7556 should allow them to block until the corresponding subprogram body
7559 Followed by GLADE, a separately supplied PCS that can be used with
7564 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7565 should raise @code{Storage_Error} if it runs out of space trying to
7566 write the @code{Item} into the stream.
7568 Followed by GLADE, a separately supplied PCS that can be used with
7571 @cindex COBOL support
7572 @unnumberedsec F(7): COBOL Support
7575 If COBOL (respectively, C) is widely supported in the target
7576 environment, implementations supporting the Information Systems Annex
7577 should provide the child package @code{Interfaces.COBOL} (respectively,
7578 @code{Interfaces.C}) specified in Annex B and should support a
7579 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7580 pragmas (see Annex B), thus allowing Ada programs to interface with
7581 programs written in that language.
7585 @cindex Decimal radix support
7586 @unnumberedsec F.1(2): Decimal Radix Support
7589 Packed decimal should be used as the internal representation for objects
7590 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7592 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
7596 @unnumberedsec G: Numerics
7599 If Fortran (respectively, C) is widely supported in the target
7600 environment, implementations supporting the Numerics Annex
7601 should provide the child package @code{Interfaces.Fortran} (respectively,
7602 @code{Interfaces.C}) specified in Annex B and should support a
7603 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7604 pragmas (see Annex B), thus allowing Ada programs to interface with
7605 programs written in that language.
7609 @cindex Complex types
7610 @unnumberedsec G.1.1(56-58): Complex Types
7613 Because the usual mathematical meaning of multiplication of a complex
7614 operand and a real operand is that of the scaling of both components of
7615 the former by the latter, an implementation should not perform this
7616 operation by first promoting the real operand to complex type and then
7617 performing a full complex multiplication. In systems that, in the
7618 future, support an Ada binding to IEC 559:1989, the latter technique
7619 will not generate the required result when one of the components of the
7620 complex operand is infinite. (Explicit multiplication of the infinite
7621 component by the zero component obtained during promotion yields a NaN
7622 that propagates into the final result.) Analogous advice applies in the
7623 case of multiplication of a complex operand and a pure-imaginary
7624 operand, and in the case of division of a complex operand by a real or
7625 pure-imaginary operand.
7631 Similarly, because the usual mathematical meaning of addition of a
7632 complex operand and a real operand is that the imaginary operand remains
7633 unchanged, an implementation should not perform this operation by first
7634 promoting the real operand to complex type and then performing a full
7635 complex addition. In implementations in which the @code{Signed_Zeros}
7636 attribute of the component type is @code{True} (and which therefore
7637 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7638 predefined arithmetic operations), the latter technique will not
7639 generate the required result when the imaginary component of the complex
7640 operand is a negatively signed zero. (Explicit addition of the negative
7641 zero to the zero obtained during promotion yields a positive zero.)
7642 Analogous advice applies in the case of addition of a complex operand
7643 and a pure-imaginary operand, and in the case of subtraction of a
7644 complex operand and a real or pure-imaginary operand.
7650 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7651 attempt to provide a rational treatment of the signs of zero results and
7652 result components. As one example, the result of the @code{Argument}
7653 function should have the sign of the imaginary component of the
7654 parameter @code{X} when the point represented by that parameter lies on
7655 the positive real axis; as another, the sign of the imaginary component
7656 of the @code{Compose_From_Polar} function should be the same as
7657 (respectively, the opposite of) that of the @code{Argument} parameter when that
7658 parameter has a value of zero and the @code{Modulus} parameter has a
7659 nonnegative (respectively, negative) value.
7663 @cindex Complex elementary functions
7664 @unnumberedsec G.1.2(49): Complex Elementary Functions
7667 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7668 @code{True} should attempt to provide a rational treatment of the signs
7669 of zero results and result components. For example, many of the complex
7670 elementary functions have components that are odd functions of one of
7671 the parameter components; in these cases, the result component should
7672 have the sign of the parameter component at the origin. Other complex
7673 elementary functions have zero components whose sign is opposite that of
7674 a parameter component at the origin, or is always positive or always
7679 @cindex Accuracy requirements
7680 @unnumberedsec G.2.4(19): Accuracy Requirements
7683 The versions of the forward trigonometric functions without a
7684 @code{Cycle} parameter should not be implemented by calling the
7685 corresponding version with a @code{Cycle} parameter of
7686 @code{2.0*Numerics.Pi}, since this will not provide the required
7687 accuracy in some portions of the domain. For the same reason, the
7688 version of @code{Log} without a @code{Base} parameter should not be
7689 implemented by calling the corresponding version with a @code{Base}
7690 parameter of @code{Numerics.e}.
7694 @cindex Complex arithmetic accuracy
7695 @cindex Accuracy, complex arithmetic
7696 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7700 The version of the @code{Compose_From_Polar} function without a
7701 @code{Cycle} parameter should not be implemented by calling the
7702 corresponding version with a @code{Cycle} parameter of
7703 @code{2.0*Numerics.Pi}, since this will not provide the required
7704 accuracy in some portions of the domain.
7708 @c -----------------------------------------
7709 @node Implementation Defined Characteristics
7710 @chapter Implementation Defined Characteristics
7713 In addition to the implementation dependent pragmas and attributes, and
7714 the implementation advice, there are a number of other Ada features
7715 that are potentially implementation dependent. These are mentioned
7716 throughout the Ada Reference Manual, and are summarized in annex M@.
7718 A requirement for conforming Ada compilers is that they provide
7719 documentation describing how the implementation deals with each of these
7720 issues. In this chapter, you will find each point in annex M listed
7721 followed by a description in italic font of how GNAT
7725 implementation on IRIX 5.3 operating system or greater
7727 handles the implementation dependence.
7729 You can use this chapter as a guide to minimizing implementation
7730 dependent features in your programs if portability to other compilers
7731 and other operating systems is an important consideration. The numbers
7732 in each section below correspond to the paragraph number in the Ada
7738 @strong{2}. Whether or not each recommendation given in Implementation
7739 Advice is followed. See 1.1.2(37).
7742 @xref{Implementation Advice}.
7747 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
7750 The complexity of programs that can be processed is limited only by the
7751 total amount of available virtual memory, and disk space for the
7752 generated object files.
7757 @strong{4}. Variations from the standard that are impractical to avoid
7758 given the implementation's execution environment. See 1.1.3(6).
7761 There are no variations from the standard.
7766 @strong{5}. Which @code{code_statement}s cause external
7767 interactions. See 1.1.3(10).
7770 Any @code{code_statement} can potentially cause external interactions.
7775 @strong{6}. The coded representation for the text of an Ada
7776 program. See 2.1(4).
7779 See separate section on source representation.
7784 @strong{7}. The control functions allowed in comments. See 2.1(14).
7787 See separate section on source representation.
7792 @strong{8}. The representation for an end of line. See 2.2(2).
7795 See separate section on source representation.
7800 @strong{9}. Maximum supported line length and lexical element
7801 length. See 2.2(15).
7804 The maximum line length is 255 characters and the maximum length of a
7805 lexical element is also 255 characters.
7810 @strong{10}. Implementation defined pragmas. See 2.8(14).
7814 @xref{Implementation Defined Pragmas}.
7819 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
7822 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7823 parameter, checks that the optimization flag is set, and aborts if it is
7829 @strong{12}. The sequence of characters of the value returned by
7830 @code{@var{S}'Image} when some of the graphic characters of
7831 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
7835 The sequence of characters is as defined by the wide character encoding
7836 method used for the source. See section on source representation for
7842 @strong{13}. The predefined integer types declared in
7843 @code{Standard}. See 3.5.4(25).
7847 @item Short_Short_Integer
7850 (Short) 16 bit signed
7854 64 bit signed (Alpha OpenVMS only)
7855 32 bit signed (all other targets)
7856 @item Long_Long_Integer
7863 @strong{14}. Any nonstandard integer types and the operators defined
7864 for them. See 3.5.4(26).
7867 There are no nonstandard integer types.
7872 @strong{15}. Any nonstandard real types and the operators defined for
7876 There are no nonstandard real types.
7881 @strong{16}. What combinations of requested decimal precision and range
7882 are supported for floating point types. See 3.5.7(7).
7885 The precision and range is as defined by the IEEE standard.
7890 @strong{17}. The predefined floating point types declared in
7891 @code{Standard}. See 3.5.7(16).
7898 (Short) 32 bit IEEE short
7901 @item Long_Long_Float
7902 64 bit IEEE long (80 bit IEEE long on x86 processors)
7908 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
7911 @code{Fine_Delta} is 2**(@minus{}63)
7916 @strong{19}. What combinations of small, range, and digits are
7917 supported for fixed point types. See 3.5.9(10).
7920 Any combinations are permitted that do not result in a small less than
7921 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7922 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7923 is 64 bits (true of all architectures except ia32), then the output from
7924 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
7925 is because floating-point conversions are used to convert fixed point.
7930 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
7931 within an unnamed @code{block_statement}. See 3.9(10).
7934 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7935 decimal integer are allocated.
7940 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
7943 @xref{Implementation Defined Attributes}.
7948 @strong{22}. Any implementation-defined time types. See 9.6(6).
7951 There are no implementation-defined time types.
7956 @strong{23}. The time base associated with relative delays.
7959 See 9.6(20). The time base used is that provided by the C library
7960 function @code{gettimeofday}.
7965 @strong{24}. The time base of the type @code{Calendar.Time}. See
7969 The time base used is that provided by the C library function
7970 @code{gettimeofday}.
7975 @strong{25}. The time zone used for package @code{Calendar}
7976 operations. See 9.6(24).
7979 The time zone used by package @code{Calendar} is the current system time zone
7980 setting for local time, as accessed by the C library function
7986 @strong{26}. Any limit on @code{delay_until_statements} of
7987 @code{select_statements}. See 9.6(29).
7990 There are no such limits.
7995 @strong{27}. Whether or not two non-overlapping parts of a composite
7996 object are independently addressable, in the case where packing, record
7997 layout, or @code{Component_Size} is specified for the object. See
8001 Separate components are independently addressable if they do not share
8002 overlapping storage units.
8007 @strong{28}. The representation for a compilation. See 10.1(2).
8010 A compilation is represented by a sequence of files presented to the
8011 compiler in a single invocation of the @command{gcc} command.
8016 @strong{29}. Any restrictions on compilations that contain multiple
8017 compilation_units. See 10.1(4).
8020 No single file can contain more than one compilation unit, but any
8021 sequence of files can be presented to the compiler as a single
8027 @strong{30}. The mechanisms for creating an environment and for adding
8028 and replacing compilation units. See 10.1.4(3).
8031 See separate section on compilation model.
8036 @strong{31}. The manner of explicitly assigning library units to a
8037 partition. See 10.2(2).
8040 If a unit contains an Ada main program, then the Ada units for the partition
8041 are determined by recursive application of the rules in the Ada Reference
8042 Manual section 10.2(2-6). In other words, the Ada units will be those that
8043 are needed by the main program, and then this definition of need is applied
8044 recursively to those units, and the partition contains the transitive
8045 closure determined by this relationship. In short, all the necessary units
8046 are included, with no need to explicitly specify the list. If additional
8047 units are required, e.g.@: by foreign language units, then all units must be
8048 mentioned in the context clause of one of the needed Ada units.
8050 If the partition contains no main program, or if the main program is in
8051 a language other than Ada, then GNAT
8052 provides the binder options @option{-z} and @option{-n} respectively, and in
8053 this case a list of units can be explicitly supplied to the binder for
8054 inclusion in the partition (all units needed by these units will also
8055 be included automatically). For full details on the use of these
8056 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8057 @value{EDITION} User's Guide}.
8062 @strong{32}. The implementation-defined means, if any, of specifying
8063 which compilation units are needed by a given compilation unit. See
8067 The units needed by a given compilation unit are as defined in
8068 the Ada Reference Manual section 10.2(2-6). There are no
8069 implementation-defined pragmas or other implementation-defined
8070 means for specifying needed units.
8075 @strong{33}. The manner of designating the main subprogram of a
8076 partition. See 10.2(7).
8079 The main program is designated by providing the name of the
8080 corresponding @file{ALI} file as the input parameter to the binder.
8085 @strong{34}. The order of elaboration of @code{library_items}. See
8089 The first constraint on ordering is that it meets the requirements of
8090 Chapter 10 of the Ada Reference Manual. This still leaves some
8091 implementation dependent choices, which are resolved by first
8092 elaborating bodies as early as possible (i.e., in preference to specs
8093 where there is a choice), and second by evaluating the immediate with
8094 clauses of a unit to determine the probably best choice, and
8095 third by elaborating in alphabetical order of unit names
8096 where a choice still remains.
8101 @strong{35}. Parameter passing and function return for the main
8102 subprogram. See 10.2(21).
8105 The main program has no parameters. It may be a procedure, or a function
8106 returning an integer type. In the latter case, the returned integer
8107 value is the return code of the program (overriding any value that
8108 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8113 @strong{36}. The mechanisms for building and running partitions. See
8117 GNAT itself supports programs with only a single partition. The GNATDIST
8118 tool provided with the GLADE package (which also includes an implementation
8119 of the PCS) provides a completely flexible method for building and running
8120 programs consisting of multiple partitions. See the separate GLADE manual
8126 @strong{37}. The details of program execution, including program
8127 termination. See 10.2(25).
8130 See separate section on compilation model.
8135 @strong{38}. The semantics of any non-active partitions supported by the
8136 implementation. See 10.2(28).
8139 Passive partitions are supported on targets where shared memory is
8140 provided by the operating system. See the GLADE reference manual for
8146 @strong{39}. The information returned by @code{Exception_Message}. See
8150 Exception message returns the null string unless a specific message has
8151 been passed by the program.
8156 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
8157 declared within an unnamed @code{block_statement}. See 11.4.1(12).
8160 Blocks have implementation defined names of the form @code{B@var{nnn}}
8161 where @var{nnn} is an integer.
8166 @strong{41}. The information returned by
8167 @code{Exception_Information}. See 11.4.1(13).
8170 @code{Exception_Information} returns a string in the following format:
8173 @emph{Exception_Name:} nnnnn
8174 @emph{Message:} mmmmm
8176 @emph{Call stack traceback locations:}
8177 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8185 @code{nnnn} is the fully qualified name of the exception in all upper
8186 case letters. This line is always present.
8189 @code{mmmm} is the message (this line present only if message is non-null)
8192 @code{ppp} is the Process Id value as a decimal integer (this line is
8193 present only if the Process Id is nonzero). Currently we are
8194 not making use of this field.
8197 The Call stack traceback locations line and the following values
8198 are present only if at least one traceback location was recorded.
8199 The values are given in C style format, with lower case letters
8200 for a-f, and only as many digits present as are necessary.
8204 The line terminator sequence at the end of each line, including
8205 the last line is a single @code{LF} character (@code{16#0A#}).
8210 @strong{42}. Implementation-defined check names. See 11.5(27).
8213 The implementation defined check name Alignment_Check controls checking of
8214 address clause values for proper alignment (that is, the address supplied
8215 must be consistent with the alignment of the type).
8217 In addition, a user program can add implementation-defined check names
8218 by means of the pragma Check_Name.
8223 @strong{43}. The interpretation of each aspect of representation. See
8227 See separate section on data representations.
8232 @strong{44}. Any restrictions placed upon representation items. See
8236 See separate section on data representations.
8241 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
8245 Size for an indefinite subtype is the maximum possible size, except that
8246 for the case of a subprogram parameter, the size of the parameter object
8252 @strong{46}. The default external representation for a type tag. See
8256 The default external representation for a type tag is the fully expanded
8257 name of the type in upper case letters.
8262 @strong{47}. What determines whether a compilation unit is the same in
8263 two different partitions. See 13.3(76).
8266 A compilation unit is the same in two different partitions if and only
8267 if it derives from the same source file.
8272 @strong{48}. Implementation-defined components. See 13.5.1(15).
8275 The only implementation defined component is the tag for a tagged type,
8276 which contains a pointer to the dispatching table.
8281 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
8282 ordering. See 13.5.3(5).
8285 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8286 implementation, so no non-default bit ordering is supported. The default
8287 bit ordering corresponds to the natural endianness of the target architecture.
8292 @strong{50}. The contents of the visible part of package @code{System}
8293 and its language-defined children. See 13.7(2).
8296 See the definition of these packages in files @file{system.ads} and
8297 @file{s-stoele.ads}.
8302 @strong{51}. The contents of the visible part of package
8303 @code{System.Machine_Code}, and the meaning of
8304 @code{code_statements}. See 13.8(7).
8307 See the definition and documentation in file @file{s-maccod.ads}.
8312 @strong{52}. The effect of unchecked conversion. See 13.9(11).
8315 Unchecked conversion between types of the same size
8316 results in an uninterpreted transmission of the bits from one type
8317 to the other. If the types are of unequal sizes, then in the case of
8318 discrete types, a shorter source is first zero or sign extended as
8319 necessary, and a shorter target is simply truncated on the left.
8320 For all non-discrete types, the source is first copied if necessary
8321 to ensure that the alignment requirements of the target are met, then
8322 a pointer is constructed to the source value, and the result is obtained
8323 by dereferencing this pointer after converting it to be a pointer to the
8324 target type. Unchecked conversions where the target subtype is an
8325 unconstrained array are not permitted. If the target alignment is
8326 greater than the source alignment, then a copy of the result is
8327 made with appropriate alignment
8332 @strong{53}. The manner of choosing a storage pool for an access type
8333 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
8336 There are 3 different standard pools used by the compiler when
8337 @code{Storage_Pool} is not specified depending whether the type is local
8338 to a subprogram or defined at the library level and whether
8339 @code{Storage_Size}is specified or not. See documentation in the runtime
8340 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8341 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8342 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8348 @strong{54}. Whether or not the implementation provides user-accessible
8349 names for the standard pool type(s). See 13.11(17).
8353 See documentation in the sources of the run time mentioned in paragraph
8354 @strong{53} . All these pools are accessible by means of @code{with}'ing
8360 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
8363 @code{Storage_Size} is measured in storage units, and refers to the
8364 total space available for an access type collection, or to the primary
8365 stack space for a task.
8370 @strong{56}. Implementation-defined aspects of storage pools. See
8374 See documentation in the sources of the run time mentioned in paragraph
8375 @strong{53} for details on GNAT-defined aspects of storage pools.
8380 @strong{57}. The set of restrictions allowed in a pragma
8381 @code{Restrictions}. See 13.12(7).
8384 All RM defined Restriction identifiers are implemented. The following
8385 additional restriction identifiers are provided. There are two separate
8386 lists of implementation dependent restriction identifiers. The first
8387 set requires consistency throughout a partition (in other words, if the
8388 restriction identifier is used for any compilation unit in the partition,
8389 then all compilation units in the partition must obey the restriction.
8393 @item Simple_Barriers
8394 @findex Simple_Barriers
8395 This restriction ensures at compile time that barriers in entry declarations
8396 for protected types are restricted to either static boolean expressions or
8397 references to simple boolean variables defined in the private part of the
8398 protected type. No other form of entry barriers is permitted. This is one
8399 of the restrictions of the Ravenscar profile for limited tasking (see also
8400 pragma @code{Profile (Ravenscar)}).
8402 @item Max_Entry_Queue_Length => Expr
8403 @findex Max_Entry_Queue_Length
8404 This restriction is a declaration that any protected entry compiled in
8405 the scope of the restriction has at most the specified number of
8406 tasks waiting on the entry
8407 at any one time, and so no queue is required. This restriction is not
8408 checked at compile time. A program execution is erroneous if an attempt
8409 is made to queue more than the specified number of tasks on such an entry.
8413 This restriction ensures at compile time that there is no implicit or
8414 explicit dependence on the package @code{Ada.Calendar}.
8416 @item No_Default_Initialization
8417 @findex No_Default_Initialization
8419 This restriction prohibits any instance of default initialization of variables.
8420 The binder implements a consistency rule which prevents any unit compiled
8421 without the restriction from with'ing a unit with the restriction (this allows
8422 the generation of initialization procedures to be skipped, since you can be
8423 sure that no call is ever generated to an initialization procedure in a unit
8424 with the restriction active). If used in conjunction with Initialize_Scalars or
8425 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8426 without a specific initializer (including the case of OUT scalar parameters).
8428 @item No_Direct_Boolean_Operators
8429 @findex No_Direct_Boolean_Operators
8430 This restriction ensures that no logical (and/or/xor) or comparison
8431 operators are used on operands of type Boolean (or any type derived
8432 from Boolean). This is intended for use in safety critical programs
8433 where the certification protocol requires the use of short-circuit
8434 (and then, or else) forms for all composite boolean operations.
8436 @item No_Dispatching_Calls
8437 @findex No_Dispatching_Calls
8438 This restriction ensures at compile time that the code generated by the
8439 compiler involves no dispatching calls. The use of this restriction allows the
8440 safe use of record extensions, classwide membership tests and other classwide
8441 features not involving implicit dispatching. This restriction ensures that
8442 the code contains no indirect calls through a dispatching mechanism. Note that
8443 this includes internally-generated calls created by the compiler, for example
8444 in the implementation of class-wide objects assignments. The
8445 membership test is allowed in the presence of this restriction, because its
8446 implementation requires no dispatching.
8447 This restriction is comparable to the official Ada restriction
8448 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8449 all classwide constructs that do not imply dispatching.
8450 The following example indicates constructs that violate this restriction.
8454 type T is tagged record
8457 procedure P (X : T);
8459 type DT is new T with record
8460 More_Data : Natural;
8462 procedure Q (X : DT);
8466 procedure Example is
8467 procedure Test (O : T'Class) is
8468 N : Natural := O'Size;-- Error: Dispatching call
8469 C : T'Class := O; -- Error: implicit Dispatching Call
8471 if O in DT'Class then -- OK : Membership test
8472 Q (DT (O)); -- OK : Type conversion plus direct call
8474 P (O); -- Error: Dispatching call
8480 P (Obj); -- OK : Direct call
8481 P (T (Obj)); -- OK : Type conversion plus direct call
8482 P (T'Class (Obj)); -- Error: Dispatching call
8484 Test (Obj); -- OK : Type conversion
8486 if Obj in T'Class then -- OK : Membership test
8492 @item No_Dynamic_Attachment
8493 @findex No_Dynamic_Attachment
8494 This restriction ensures that there is no call to any of the operations
8495 defined in package Ada.Interrupts.
8497 @item No_Enumeration_Maps
8498 @findex No_Enumeration_Maps
8499 This restriction ensures at compile time that no operations requiring
8500 enumeration maps are used (that is Image and Value attributes applied
8501 to enumeration types).
8503 @item No_Entry_Calls_In_Elaboration_Code
8504 @findex No_Entry_Calls_In_Elaboration_Code
8505 This restriction ensures at compile time that no task or protected entry
8506 calls are made during elaboration code. As a result of the use of this
8507 restriction, the compiler can assume that no code past an accept statement
8508 in a task can be executed at elaboration time.
8510 @item No_Exception_Handlers
8511 @findex No_Exception_Handlers
8512 This restriction ensures at compile time that there are no explicit
8513 exception handlers. It also indicates that no exception propagation will
8514 be provided. In this mode, exceptions may be raised but will result in
8515 an immediate call to the last chance handler, a routine that the user
8516 must define with the following profile:
8518 @smallexample @c ada
8519 procedure Last_Chance_Handler
8520 (Source_Location : System.Address; Line : Integer);
8521 pragma Export (C, Last_Chance_Handler,
8522 "__gnat_last_chance_handler");
8525 The parameter is a C null-terminated string representing a message to be
8526 associated with the exception (typically the source location of the raise
8527 statement generated by the compiler). The Line parameter when nonzero
8528 represents the line number in the source program where the raise occurs.
8530 @item No_Exception_Propagation
8531 @findex No_Exception_Propagation
8532 This restriction guarantees that exceptions are never propagated to an outer
8533 subprogram scope). The only case in which an exception may be raised is when
8534 the handler is statically in the same subprogram, so that the effect of a raise
8535 is essentially like a goto statement. Any other raise statement (implicit or
8536 explicit) will be considered unhandled. Exception handlers are allowed, but may
8537 not contain an exception occurrence identifier (exception choice). In addition
8538 use of the package GNAT.Current_Exception is not permitted, and reraise
8539 statements (raise with no operand) are not permitted.
8541 @item No_Exception_Registration
8542 @findex No_Exception_Registration
8543 This restriction ensures at compile time that no stream operations for
8544 types Exception_Id or Exception_Occurrence are used. This also makes it
8545 impossible to pass exceptions to or from a partition with this restriction
8546 in a distributed environment. If this exception is active, then the generated
8547 code is simplified by omitting the otherwise-required global registration
8548 of exceptions when they are declared.
8550 @item No_Implicit_Conditionals
8551 @findex No_Implicit_Conditionals
8552 This restriction ensures that the generated code does not contain any
8553 implicit conditionals, either by modifying the generated code where possible,
8554 or by rejecting any construct that would otherwise generate an implicit
8555 conditional. Note that this check does not include run time constraint
8556 checks, which on some targets may generate implicit conditionals as
8557 well. To control the latter, constraint checks can be suppressed in the
8558 normal manner. Constructs generating implicit conditionals include comparisons
8559 of composite objects and the Max/Min attributes.
8561 @item No_Implicit_Dynamic_Code
8562 @findex No_Implicit_Dynamic_Code
8564 This restriction prevents the compiler from building ``trampolines''.
8565 This is a structure that is built on the stack and contains dynamic
8566 code to be executed at run time. On some targets, a trampoline is
8567 built for the following features: @code{Access},
8568 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8569 nested task bodies; primitive operations of nested tagged types.
8570 Trampolines do not work on machines that prevent execution of stack
8571 data. For example, on windows systems, enabling DEP (data execution
8572 protection) will cause trampolines to raise an exception.
8573 Trampolines are also quite slow at run time.
8575 On many targets, trampolines have been largely eliminated. Look at the
8576 version of system.ads for your target --- if it has
8577 Always_Compatible_Rep equal to False, then trampolines are largely
8578 eliminated. In particular, a trampoline is built for the following
8579 features: @code{Address} of a nested subprogram;
8580 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8581 but only if pragma Favor_Top_Level applies, or the access type has a
8582 foreign-language convention; primitive operations of nested tagged
8585 @item No_Implicit_Loops
8586 @findex No_Implicit_Loops
8587 This restriction ensures that the generated code does not contain any
8588 implicit @code{for} loops, either by modifying
8589 the generated code where possible,
8590 or by rejecting any construct that would otherwise generate an implicit
8591 @code{for} loop. If this restriction is active, it is possible to build
8592 large array aggregates with all static components without generating an
8593 intermediate temporary, and without generating a loop to initialize individual
8594 components. Otherwise, a loop is created for arrays larger than about 5000
8597 @item No_Initialize_Scalars
8598 @findex No_Initialize_Scalars
8599 This restriction ensures that no unit in the partition is compiled with
8600 pragma Initialize_Scalars. This allows the generation of more efficient
8601 code, and in particular eliminates dummy null initialization routines that
8602 are otherwise generated for some record and array types.
8604 @item No_Local_Protected_Objects
8605 @findex No_Local_Protected_Objects
8606 This restriction ensures at compile time that protected objects are
8607 only declared at the library level.
8609 @item No_Protected_Type_Allocators
8610 @findex No_Protected_Type_Allocators
8611 This restriction ensures at compile time that there are no allocator
8612 expressions that attempt to allocate protected objects.
8614 @item No_Secondary_Stack
8615 @findex No_Secondary_Stack
8616 This restriction ensures at compile time that the generated code does not
8617 contain any reference to the secondary stack. The secondary stack is used
8618 to implement functions returning unconstrained objects (arrays or records)
8621 @item No_Select_Statements
8622 @findex No_Select_Statements
8623 This restriction ensures at compile time no select statements of any kind
8624 are permitted, that is the keyword @code{select} may not appear.
8625 This is one of the restrictions of the Ravenscar
8626 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8628 @item No_Standard_Storage_Pools
8629 @findex No_Standard_Storage_Pools
8630 This restriction ensures at compile time that no access types
8631 use the standard default storage pool. Any access type declared must
8632 have an explicit Storage_Pool attribute defined specifying a
8633 user-defined storage pool.
8637 This restriction ensures at compile/bind time that there are no
8638 stream objects created and no use of stream attributes.
8639 This restriction does not forbid dependences on the package
8640 @code{Ada.Streams}. So it is permissible to with
8641 @code{Ada.Streams} (or another package that does so itself)
8642 as long as no actual stream objects are created and no
8643 stream attributes are used.
8645 Note that the use of restriction allows optimization of tagged types,
8646 since they do not need to worry about dispatching stream operations.
8647 To take maximum advantage of this space-saving optimization, any
8648 unit declaring a tagged type should be compiled with the restriction,
8649 though this is not required.
8651 @item No_Task_Attributes_Package
8652 @findex No_Task_Attributes_Package
8653 This restriction ensures at compile time that there are no implicit or
8654 explicit dependencies on the package @code{Ada.Task_Attributes}.
8656 @item No_Task_Termination
8657 @findex No_Task_Termination
8658 This restriction ensures at compile time that no terminate alternatives
8659 appear in any task body.
8663 This restriction prevents the declaration of tasks or task types throughout
8664 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
8665 except that violations are caught at compile time and cause an error message
8666 to be output either by the compiler or binder.
8668 @item Static_Priorities
8669 @findex Static_Priorities
8670 This restriction ensures at compile time that all priority expressions
8671 are static, and that there are no dependencies on the package
8672 @code{Ada.Dynamic_Priorities}.
8674 @item Static_Storage_Size
8675 @findex Static_Storage_Size
8676 This restriction ensures at compile time that any expression appearing
8677 in a Storage_Size pragma or attribute definition clause is static.
8682 The second set of implementation dependent restriction identifiers
8683 does not require partition-wide consistency.
8684 The restriction may be enforced for a single
8685 compilation unit without any effect on any of the
8686 other compilation units in the partition.
8690 @item No_Elaboration_Code
8691 @findex No_Elaboration_Code
8692 This restriction ensures at compile time that no elaboration code is
8693 generated. Note that this is not the same condition as is enforced
8694 by pragma @code{Preelaborate}. There are cases in which pragma
8695 @code{Preelaborate} still permits code to be generated (e.g.@: code
8696 to initialize a large array to all zeroes), and there are cases of units
8697 which do not meet the requirements for pragma @code{Preelaborate},
8698 but for which no elaboration code is generated. Generally, it is
8699 the case that preelaborable units will meet the restrictions, with
8700 the exception of large aggregates initialized with an others_clause,
8701 and exception declarations (which generate calls to a run-time
8702 registry procedure). This restriction is enforced on
8703 a unit by unit basis, it need not be obeyed consistently
8704 throughout a partition.
8706 In the case of aggregates with others, if the aggregate has a dynamic
8707 size, there is no way to eliminate the elaboration code (such dynamic
8708 bounds would be incompatible with @code{Preelaborate} in any case). If
8709 the bounds are static, then use of this restriction actually modifies
8710 the code choice of the compiler to avoid generating a loop, and instead
8711 generate the aggregate statically if possible, no matter how many times
8712 the data for the others clause must be repeatedly generated.
8714 It is not possible to precisely document
8715 the constructs which are compatible with this restriction, since,
8716 unlike most other restrictions, this is not a restriction on the
8717 source code, but a restriction on the generated object code. For
8718 example, if the source contains a declaration:
8721 Val : constant Integer := X;
8725 where X is not a static constant, it may be possible, depending
8726 on complex optimization circuitry, for the compiler to figure
8727 out the value of X at compile time, in which case this initialization
8728 can be done by the loader, and requires no initialization code. It
8729 is not possible to document the precise conditions under which the
8730 optimizer can figure this out.
8732 Note that this the implementation of this restriction requires full
8733 code generation. If it is used in conjunction with "semantics only"
8734 checking, then some cases of violations may be missed.
8736 @item No_Entry_Queue
8737 @findex No_Entry_Queue
8738 This restriction is a declaration that any protected entry compiled in
8739 the scope of the restriction has at most one task waiting on the entry
8740 at any one time, and so no queue is required. This restriction is not
8741 checked at compile time. A program execution is erroneous if an attempt
8742 is made to queue a second task on such an entry.
8744 @item No_Implementation_Attributes
8745 @findex No_Implementation_Attributes
8746 This restriction checks at compile time that no GNAT-defined attributes
8747 are present. With this restriction, the only attributes that can be used
8748 are those defined in the Ada Reference Manual.
8750 @item No_Implementation_Pragmas
8751 @findex No_Implementation_Pragmas
8752 This restriction checks at compile time that no GNAT-defined pragmas
8753 are present. With this restriction, the only pragmas that can be used
8754 are those defined in the Ada Reference Manual.
8756 @item No_Implementation_Restrictions
8757 @findex No_Implementation_Restrictions
8758 This restriction checks at compile time that no GNAT-defined restriction
8759 identifiers (other than @code{No_Implementation_Restrictions} itself)
8760 are present. With this restriction, the only other restriction identifiers
8761 that can be used are those defined in the Ada Reference Manual.
8763 @item No_Wide_Characters
8764 @findex No_Wide_Characters
8765 This restriction ensures at compile time that no uses of the types
8766 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8768 appear, and that no wide or wide wide string or character literals
8769 appear in the program (that is literals representing characters not in
8770 type @code{Character}.
8777 @strong{58}. The consequences of violating limitations on
8778 @code{Restrictions} pragmas. See 13.12(9).
8781 Restrictions that can be checked at compile time result in illegalities
8782 if violated. Currently there are no other consequences of violating
8788 @strong{59}. The representation used by the @code{Read} and
8789 @code{Write} attributes of elementary types in terms of stream
8790 elements. See 13.13.2(9).
8793 The representation is the in-memory representation of the base type of
8794 the type, using the number of bits corresponding to the
8795 @code{@var{type}'Size} value, and the natural ordering of the machine.
8800 @strong{60}. The names and characteristics of the numeric subtypes
8801 declared in the visible part of package @code{Standard}. See A.1(3).
8804 See items describing the integer and floating-point types supported.
8809 @strong{61}. The accuracy actually achieved by the elementary
8810 functions. See A.5.1(1).
8813 The elementary functions correspond to the functions available in the C
8814 library. Only fast math mode is implemented.
8819 @strong{62}. The sign of a zero result from some of the operators or
8820 functions in @code{Numerics.Generic_Elementary_Functions}, when
8821 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
8824 The sign of zeroes follows the requirements of the IEEE 754 standard on
8830 @strong{63}. The value of
8831 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
8834 Maximum image width is 649, see library file @file{a-numran.ads}.
8839 @strong{64}. The value of
8840 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
8843 Maximum image width is 80, see library file @file{a-nudira.ads}.
8848 @strong{65}. The algorithms for random number generation. See
8852 The algorithm is documented in the source files @file{a-numran.ads} and
8853 @file{a-numran.adb}.
8858 @strong{66}. The string representation of a random number generator's
8859 state. See A.5.2(38).
8862 See the documentation contained in the file @file{a-numran.adb}.
8867 @strong{67}. The minimum time interval between calls to the
8868 time-dependent Reset procedure that are guaranteed to initiate different
8869 random number sequences. See A.5.2(45).
8872 The minimum period between reset calls to guarantee distinct series of
8873 random numbers is one microsecond.
8878 @strong{68}. The values of the @code{Model_Mantissa},
8879 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8880 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8881 Annex is not supported. See A.5.3(72).
8884 See the source file @file{ttypef.ads} for the values of all numeric
8890 @strong{69}. Any implementation-defined characteristics of the
8891 input-output packages. See A.7(14).
8894 There are no special implementation defined characteristics for these
8900 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
8904 All type representations are contiguous, and the @code{Buffer_Size} is
8905 the value of @code{@var{type}'Size} rounded up to the next storage unit
8911 @strong{71}. External files for standard input, standard output, and
8912 standard error See A.10(5).
8915 These files are mapped onto the files provided by the C streams
8916 libraries. See source file @file{i-cstrea.ads} for further details.
8921 @strong{72}. The accuracy of the value produced by @code{Put}. See
8925 If more digits are requested in the output than are represented by the
8926 precision of the value, zeroes are output in the corresponding least
8927 significant digit positions.
8932 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
8933 @code{Command_Name}. See A.15(1).
8936 These are mapped onto the @code{argv} and @code{argc} parameters of the
8937 main program in the natural manner.
8942 @strong{74}. Implementation-defined convention names. See B.1(11).
8945 The following convention names are supported
8953 Synonym for Assembler
8955 Synonym for Assembler
8958 @item C_Pass_By_Copy
8959 Allowed only for record types, like C, but also notes that record
8960 is to be passed by copy rather than reference.
8963 @item C_Plus_Plus (or CPP)
8966 Treated the same as C
8968 Treated the same as C
8972 For support of pragma @code{Import} with convention Intrinsic, see
8973 separate section on Intrinsic Subprograms.
8975 Stdcall (used for Windows implementations only). This convention correspond
8976 to the WINAPI (previously called Pascal convention) C/C++ convention under
8977 Windows. A function with this convention cleans the stack before exit.
8983 Stubbed is a special convention used to indicate that the body of the
8984 subprogram will be entirely ignored. Any call to the subprogram
8985 is converted into a raise of the @code{Program_Error} exception. If a
8986 pragma @code{Import} specifies convention @code{stubbed} then no body need
8987 be present at all. This convention is useful during development for the
8988 inclusion of subprograms whose body has not yet been written.
8992 In addition, all otherwise unrecognized convention names are also
8993 treated as being synonymous with convention C@. In all implementations
8994 except for VMS, use of such other names results in a warning. In VMS
8995 implementations, these names are accepted silently.
9000 @strong{75}. The meaning of link names. See B.1(36).
9003 Link names are the actual names used by the linker.
9008 @strong{76}. The manner of choosing link names when neither the link
9009 name nor the address of an imported or exported entity is specified. See
9013 The default linker name is that which would be assigned by the relevant
9014 external language, interpreting the Ada name as being in all lower case
9020 @strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37).
9023 The string passed to @code{Linker_Options} is presented uninterpreted as
9024 an argument to the link command, unless it contains ASCII.NUL characters.
9025 NUL characters if they appear act as argument separators, so for example
9027 @smallexample @c ada
9028 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9032 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9033 linker. The order of linker options is preserved for a given unit. The final
9034 list of options passed to the linker is in reverse order of the elaboration
9035 order. For example, linker options for a body always appear before the options
9036 from the corresponding package spec.
9041 @strong{78}. The contents of the visible part of package
9042 @code{Interfaces} and its language-defined descendants. See B.2(1).
9045 See files with prefix @file{i-} in the distributed library.
9050 @strong{79}. Implementation-defined children of package
9051 @code{Interfaces}. The contents of the visible part of package
9052 @code{Interfaces}. See B.2(11).
9055 See files with prefix @file{i-} in the distributed library.
9060 @strong{80}. The types @code{Floating}, @code{Long_Floating},
9061 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9062 @code{COBOL_Character}; and the initialization of the variables
9063 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9064 @code{Interfaces.COBOL}. See B.4(50).
9071 (Floating) Long_Float
9076 @item Decimal_Element
9078 @item COBOL_Character
9083 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9088 @strong{81}. Support for access to machine instructions. See C.1(1).
9091 See documentation in file @file{s-maccod.ads} in the distributed library.
9096 @strong{82}. Implementation-defined aspects of access to machine
9097 operations. See C.1(9).
9100 See documentation in file @file{s-maccod.ads} in the distributed library.
9105 @strong{83}. Implementation-defined aspects of interrupts. See C.3(2).
9108 Interrupts are mapped to signals or conditions as appropriate. See
9110 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9111 on the interrupts supported on a particular target.
9116 @strong{84}. Implementation-defined aspects of pre-elaboration. See
9120 GNAT does not permit a partition to be restarted without reloading,
9121 except under control of the debugger.
9126 @strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7).
9129 Pragma @code{Discard_Names} causes names of enumeration literals to
9130 be suppressed. In the presence of this pragma, the Image attribute
9131 provides the image of the Pos of the literal, and Value accepts
9137 @strong{86}. The result of the @code{Task_Identification.Image}
9138 attribute. See C.7.1(7).
9141 The result of this attribute is a string that identifies
9142 the object or component that denotes a given task. If a variable @code{Var}
9143 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9145 is the hexadecimal representation of the virtual address of the corresponding
9146 task control block. If the variable is an array of tasks, the image of each
9147 task will have the form of an indexed component indicating the position of a
9148 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9149 component of a record, the image of the task will have the form of a selected
9150 component. These rules are fully recursive, so that the image of a task that
9151 is a subcomponent of a composite object corresponds to the expression that
9152 designates this task.
9154 If a task is created by an allocator, its image depends on the context. If the
9155 allocator is part of an object declaration, the rules described above are used
9156 to construct its image, and this image is not affected by subsequent
9157 assignments. If the allocator appears within an expression, the image
9158 includes only the name of the task type.
9160 If the configuration pragma Discard_Names is present, or if the restriction
9161 No_Implicit_Heap_Allocation is in effect, the image reduces to
9162 the numeric suffix, that is to say the hexadecimal representation of the
9163 virtual address of the control block of the task.
9167 @strong{87}. The value of @code{Current_Task} when in a protected entry
9168 or interrupt handler. See C.7.1(17).
9171 Protected entries or interrupt handlers can be executed by any
9172 convenient thread, so the value of @code{Current_Task} is undefined.
9177 @strong{88}. The effect of calling @code{Current_Task} from an entry
9178 body or interrupt handler. See C.7.1(19).
9181 The effect of calling @code{Current_Task} from an entry body or
9182 interrupt handler is to return the identification of the task currently
9188 @strong{89}. Implementation-defined aspects of
9189 @code{Task_Attributes}. See C.7.2(19).
9192 There are no implementation-defined aspects of @code{Task_Attributes}.
9197 @strong{90}. Values of all @code{Metrics}. See D(2).
9200 The metrics information for GNAT depends on the performance of the
9201 underlying operating system. The sources of the run-time for tasking
9202 implementation, together with the output from @option{-gnatG} can be
9203 used to determine the exact sequence of operating systems calls made
9204 to implement various tasking constructs. Together with appropriate
9205 information on the performance of the underlying operating system,
9206 on the exact target in use, this information can be used to determine
9207 the required metrics.
9212 @strong{91}. The declarations of @code{Any_Priority} and
9213 @code{Priority}. See D.1(11).
9216 See declarations in file @file{system.ads}.
9221 @strong{92}. Implementation-defined execution resources. See D.1(15).
9224 There are no implementation-defined execution resources.
9229 @strong{93}. Whether, on a multiprocessor, a task that is waiting for
9230 access to a protected object keeps its processor busy. See D.2.1(3).
9233 On a multi-processor, a task that is waiting for access to a protected
9234 object does not keep its processor busy.
9239 @strong{94}. The affect of implementation defined execution resources
9240 on task dispatching. See D.2.1(9).
9245 Tasks map to IRIX threads, and the dispatching policy is as defined by
9246 the IRIX implementation of threads.
9248 Tasks map to threads in the threads package used by GNAT@. Where possible
9249 and appropriate, these threads correspond to native threads of the
9250 underlying operating system.
9255 @strong{95}. Implementation-defined @code{policy_identifiers} allowed
9256 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
9259 There are no implementation-defined policy-identifiers allowed in this
9265 @strong{96}. Implementation-defined aspects of priority inversion. See
9269 Execution of a task cannot be preempted by the implementation processing
9270 of delay expirations for lower priority tasks.
9275 @strong{97}. Implementation defined task dispatching. See D.2.2(18).
9280 Tasks map to IRIX threads, and the dispatching policy is as defined by
9281 the IRIX implementation of threads.
9283 The policy is the same as that of the underlying threads implementation.
9288 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
9289 in a pragma @code{Locking_Policy}. See D.3(4).
9292 The only implementation defined policy permitted in GNAT is
9293 @code{Inheritance_Locking}. On targets that support this policy, locking
9294 is implemented by inheritance, i.e.@: the task owning the lock operates
9295 at a priority equal to the highest priority of any task currently
9296 requesting the lock.
9301 @strong{99}. Default ceiling priorities. See D.3(10).
9304 The ceiling priority of protected objects of the type
9305 @code{System.Interrupt_Priority'Last} as described in the Ada
9306 Reference Manual D.3(10),
9311 @strong{100}. The ceiling of any protected object used internally by
9312 the implementation. See D.3(16).
9315 The ceiling priority of internal protected objects is
9316 @code{System.Priority'Last}.
9321 @strong{101}. Implementation-defined queuing policies. See D.4(1).
9324 There are no implementation-defined queuing policies.
9329 @strong{102}. On a multiprocessor, any conditions that cause the
9330 completion of an aborted construct to be delayed later than what is
9331 specified for a single processor. See D.6(3).
9334 The semantics for abort on a multi-processor is the same as on a single
9335 processor, there are no further delays.
9340 @strong{103}. Any operations that implicitly require heap storage
9341 allocation. See D.7(8).
9344 The only operation that implicitly requires heap storage allocation is
9350 @strong{104}. Implementation-defined aspects of pragma
9351 @code{Restrictions}. See D.7(20).
9354 There are no such implementation-defined aspects.
9359 @strong{105}. Implementation-defined aspects of package
9360 @code{Real_Time}. See D.8(17).
9363 There are no implementation defined aspects of package @code{Real_Time}.
9368 @strong{106}. Implementation-defined aspects of
9369 @code{delay_statements}. See D.9(8).
9372 Any difference greater than one microsecond will cause the task to be
9373 delayed (see D.9(7)).
9378 @strong{107}. The upper bound on the duration of interrupt blocking
9379 caused by the implementation. See D.12(5).
9382 The upper bound is determined by the underlying operating system. In
9383 no cases is it more than 10 milliseconds.
9388 @strong{108}. The means for creating and executing distributed
9392 The GLADE package provides a utility GNATDIST for creating and executing
9393 distributed programs. See the GLADE reference manual for further details.
9398 @strong{109}. Any events that can result in a partition becoming
9399 inaccessible. See E.1(7).
9402 See the GLADE reference manual for full details on such events.
9407 @strong{110}. The scheduling policies, treatment of priorities, and
9408 management of shared resources between partitions in certain cases. See
9412 See the GLADE reference manual for full details on these aspects of
9413 multi-partition execution.
9418 @strong{111}. Events that cause the version of a compilation unit to
9422 Editing the source file of a compilation unit, or the source files of
9423 any units on which it is dependent in a significant way cause the version
9424 to change. No other actions cause the version number to change. All changes
9425 are significant except those which affect only layout, capitalization or
9431 @strong{112}. Whether the execution of the remote subprogram is
9432 immediately aborted as a result of cancellation. See E.4(13).
9435 See the GLADE reference manual for details on the effect of abort in
9436 a distributed application.
9441 @strong{113}. Implementation-defined aspects of the PCS@. See E.5(25).
9444 See the GLADE reference manual for a full description of all implementation
9445 defined aspects of the PCS@.
9450 @strong{114}. Implementation-defined interfaces in the PCS@. See
9454 See the GLADE reference manual for a full description of all
9455 implementation defined interfaces.
9460 @strong{115}. The values of named numbers in the package
9461 @code{Decimal}. See F.2(7).
9473 @item Max_Decimal_Digits
9480 @strong{116}. The value of @code{Max_Picture_Length} in the package
9481 @code{Text_IO.Editing}. See F.3.3(16).
9489 @strong{117}. The value of @code{Max_Picture_Length} in the package
9490 @code{Wide_Text_IO.Editing}. See F.3.4(5).
9498 @strong{118}. The accuracy actually achieved by the complex elementary
9499 functions and by other complex arithmetic operations. See G.1(1).
9502 Standard library functions are used for the complex arithmetic
9503 operations. Only fast math mode is currently supported.
9508 @strong{119}. The sign of a zero result (or a component thereof) from
9509 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9510 @code{Real'Signed_Zeros} is True. See G.1.1(53).
9513 The signs of zero values are as recommended by the relevant
9514 implementation advice.
9519 @strong{120}. The sign of a zero result (or a component thereof) from
9520 any operator or function in
9521 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9522 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
9525 The signs of zero values are as recommended by the relevant
9526 implementation advice.
9531 @strong{121}. Whether the strict mode or the relaxed mode is the
9532 default. See G.2(2).
9535 The strict mode is the default. There is no separate relaxed mode. GNAT
9536 provides a highly efficient implementation of strict mode.
9541 @strong{122}. The result interval in certain cases of fixed-to-float
9542 conversion. See G.2.1(10).
9545 For cases where the result interval is implementation dependent, the
9546 accuracy is that provided by performing all operations in 64-bit IEEE
9547 floating-point format.
9552 @strong{123}. The result of a floating point arithmetic operation in
9553 overflow situations, when the @code{Machine_Overflows} attribute of the
9554 result type is @code{False}. See G.2.1(13).
9557 Infinite and NaN values are produced as dictated by the IEEE
9558 floating-point standard.
9560 Note that on machines that are not fully compliant with the IEEE
9561 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9562 must be used for achieving IEEE confirming behavior (although at the cost
9563 of a significant performance penalty), so infinite and NaN values are
9569 @strong{124}. The result interval for division (or exponentiation by a
9570 negative exponent), when the floating point hardware implements division
9571 as multiplication by a reciprocal. See G.2.1(16).
9574 Not relevant, division is IEEE exact.
9579 @strong{125}. The definition of close result set, which determines the
9580 accuracy of certain fixed point multiplications and divisions. See
9584 Operations in the close result set are performed using IEEE long format
9585 floating-point arithmetic. The input operands are converted to
9586 floating-point, the operation is done in floating-point, and the result
9587 is converted to the target type.
9592 @strong{126}. Conditions on a @code{universal_real} operand of a fixed
9593 point multiplication or division for which the result shall be in the
9594 perfect result set. See G.2.3(22).
9597 The result is only defined to be in the perfect result set if the result
9598 can be computed by a single scaling operation involving a scale factor
9599 representable in 64-bits.
9604 @strong{127}. The result of a fixed point arithmetic operation in
9605 overflow situations, when the @code{Machine_Overflows} attribute of the
9606 result type is @code{False}. See G.2.3(27).
9609 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9615 @strong{128}. The result of an elementary function reference in
9616 overflow situations, when the @code{Machine_Overflows} attribute of the
9617 result type is @code{False}. See G.2.4(4).
9620 IEEE infinite and Nan values are produced as appropriate.
9625 @strong{129}. The value of the angle threshold, within which certain
9626 elementary functions, complex arithmetic operations, and complex
9627 elementary functions yield results conforming to a maximum relative
9628 error bound. See G.2.4(10).
9631 Information on this subject is not yet available.
9636 @strong{130}. The accuracy of certain elementary functions for
9637 parameters beyond the angle threshold. See G.2.4(10).
9640 Information on this subject is not yet available.
9645 @strong{131}. The result of a complex arithmetic operation or complex
9646 elementary function reference in overflow situations, when the
9647 @code{Machine_Overflows} attribute of the corresponding real type is
9648 @code{False}. See G.2.6(5).
9651 IEEE infinite and Nan values are produced as appropriate.
9656 @strong{132}. The accuracy of certain complex arithmetic operations and
9657 certain complex elementary functions for parameters (or components
9658 thereof) beyond the angle threshold. See G.2.6(8).
9661 Information on those subjects is not yet available.
9666 @strong{133}. Information regarding bounded errors and erroneous
9667 execution. See H.2(1).
9670 Information on this subject is not yet available.
9675 @strong{134}. Implementation-defined aspects of pragma
9676 @code{Inspection_Point}. See H.3.2(8).
9679 Pragma @code{Inspection_Point} ensures that the variable is live and can
9680 be examined by the debugger at the inspection point.
9685 @strong{135}. Implementation-defined aspects of pragma
9686 @code{Restrictions}. See H.4(25).
9689 There are no implementation-defined aspects of pragma @code{Restrictions}. The
9690 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9691 generated code. Checks must suppressed by use of pragma @code{Suppress}.
9696 @strong{136}. Any restrictions on pragma @code{Restrictions}. See
9700 There are no restrictions on pragma @code{Restrictions}.
9702 @node Intrinsic Subprograms
9703 @chapter Intrinsic Subprograms
9704 @cindex Intrinsic Subprograms
9707 * Intrinsic Operators::
9708 * Enclosing_Entity::
9709 * Exception_Information::
9710 * Exception_Message::
9718 * Shift_Right_Arithmetic::
9723 GNAT allows a user application program to write the declaration:
9725 @smallexample @c ada
9726 pragma Import (Intrinsic, name);
9730 providing that the name corresponds to one of the implemented intrinsic
9731 subprograms in GNAT, and that the parameter profile of the referenced
9732 subprogram meets the requirements. This chapter describes the set of
9733 implemented intrinsic subprograms, and the requirements on parameter profiles.
9734 Note that no body is supplied; as with other uses of pragma Import, the
9735 body is supplied elsewhere (in this case by the compiler itself). Note
9736 that any use of this feature is potentially non-portable, since the
9737 Ada standard does not require Ada compilers to implement this feature.
9739 @node Intrinsic Operators
9740 @section Intrinsic Operators
9741 @cindex Intrinsic operator
9744 All the predefined numeric operators in package Standard
9745 in @code{pragma Import (Intrinsic,..)}
9746 declarations. In the binary operator case, the operands must have the same
9747 size. The operand or operands must also be appropriate for
9748 the operator. For example, for addition, the operands must
9749 both be floating-point or both be fixed-point, and the
9750 right operand for @code{"**"} must have a root type of
9751 @code{Standard.Integer'Base}.
9752 You can use an intrinsic operator declaration as in the following example:
9754 @smallexample @c ada
9755 type Int1 is new Integer;
9756 type Int2 is new Integer;
9758 function "+" (X1 : Int1; X2 : Int2) return Int1;
9759 function "+" (X1 : Int1; X2 : Int2) return Int2;
9760 pragma Import (Intrinsic, "+");
9764 This declaration would permit ``mixed mode'' arithmetic on items
9765 of the differing types @code{Int1} and @code{Int2}.
9766 It is also possible to specify such operators for private types, if the
9767 full views are appropriate arithmetic types.
9769 @node Enclosing_Entity
9770 @section Enclosing_Entity
9771 @cindex Enclosing_Entity
9773 This intrinsic subprogram is used in the implementation of the
9774 library routine @code{GNAT.Source_Info}. The only useful use of the
9775 intrinsic import in this case is the one in this unit, so an
9776 application program should simply call the function
9777 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9778 the current subprogram, package, task, entry, or protected subprogram.
9780 @node Exception_Information
9781 @section Exception_Information
9782 @cindex Exception_Information'
9784 This intrinsic subprogram is used in the implementation of the
9785 library routine @code{GNAT.Current_Exception}. The only useful
9786 use of the intrinsic import in this case is the one in this unit,
9787 so an application program should simply call the function
9788 @code{GNAT.Current_Exception.Exception_Information} to obtain
9789 the exception information associated with the current exception.
9791 @node Exception_Message
9792 @section Exception_Message
9793 @cindex Exception_Message
9795 This intrinsic subprogram is used in the implementation of the
9796 library routine @code{GNAT.Current_Exception}. The only useful
9797 use of the intrinsic import in this case is the one in this unit,
9798 so an application program should simply call the function
9799 @code{GNAT.Current_Exception.Exception_Message} to obtain
9800 the message associated with the current exception.
9802 @node Exception_Name
9803 @section Exception_Name
9804 @cindex Exception_Name
9806 This intrinsic subprogram is used in the implementation of the
9807 library routine @code{GNAT.Current_Exception}. The only useful
9808 use of the intrinsic import in this case is the one in this unit,
9809 so an application program should simply call the function
9810 @code{GNAT.Current_Exception.Exception_Name} to obtain
9811 the name of the current exception.
9817 This intrinsic subprogram is used in the implementation of the
9818 library routine @code{GNAT.Source_Info}. The only useful use of the
9819 intrinsic import in this case is the one in this unit, so an
9820 application program should simply call the function
9821 @code{GNAT.Source_Info.File} to obtain the name of the current
9828 This intrinsic subprogram is used in the implementation of the
9829 library routine @code{GNAT.Source_Info}. The only useful use of the
9830 intrinsic import in this case is the one in this unit, so an
9831 application program should simply call the function
9832 @code{GNAT.Source_Info.Line} to obtain the number of the current
9836 @section Rotate_Left
9839 In standard Ada, the @code{Rotate_Left} function is available only
9840 for the predefined modular types in package @code{Interfaces}. However, in
9841 GNAT it is possible to define a Rotate_Left function for a user
9842 defined modular type or any signed integer type as in this example:
9844 @smallexample @c ada
9846 (Value : My_Modular_Type;
9848 return My_Modular_Type;
9852 The requirements are that the profile be exactly as in the example
9853 above. The only modifications allowed are in the formal parameter
9854 names, and in the type of @code{Value} and the return type, which
9855 must be the same, and must be either a signed integer type, or
9856 a modular integer type with a binary modulus, and the size must
9857 be 8. 16, 32 or 64 bits.
9860 @section Rotate_Right
9861 @cindex Rotate_Right
9863 A @code{Rotate_Right} function can be defined for any user defined
9864 binary modular integer type, or signed integer type, as described
9865 above for @code{Rotate_Left}.
9871 A @code{Shift_Left} function can be defined for any user defined
9872 binary modular integer type, or signed integer type, as described
9873 above for @code{Rotate_Left}.
9876 @section Shift_Right
9879 A @code{Shift_Right} function can be defined for any user defined
9880 binary modular integer type, or signed integer type, as described
9881 above for @code{Rotate_Left}.
9883 @node Shift_Right_Arithmetic
9884 @section Shift_Right_Arithmetic
9885 @cindex Shift_Right_Arithmetic
9887 A @code{Shift_Right_Arithmetic} function can be defined for any user
9888 defined binary modular integer type, or signed integer type, as described
9889 above for @code{Rotate_Left}.
9891 @node Source_Location
9892 @section Source_Location
9893 @cindex Source_Location
9895 This intrinsic subprogram is used in the implementation of the
9896 library routine @code{GNAT.Source_Info}. The only useful use of the
9897 intrinsic import in this case is the one in this unit, so an
9898 application program should simply call the function
9899 @code{GNAT.Source_Info.Source_Location} to obtain the current
9900 source file location.
9902 @node Representation Clauses and Pragmas
9903 @chapter Representation Clauses and Pragmas
9904 @cindex Representation Clauses
9907 * Alignment Clauses::
9909 * Storage_Size Clauses::
9910 * Size of Variant Record Objects::
9911 * Biased Representation ::
9912 * Value_Size and Object_Size Clauses::
9913 * Component_Size Clauses::
9914 * Bit_Order Clauses::
9915 * Effect of Bit_Order on Byte Ordering::
9916 * Pragma Pack for Arrays::
9917 * Pragma Pack for Records::
9918 * Record Representation Clauses::
9919 * Enumeration Clauses::
9921 * Effect of Convention on Representation::
9922 * Determining the Representations chosen by GNAT::
9926 @cindex Representation Clause
9927 @cindex Representation Pragma
9928 @cindex Pragma, representation
9929 This section describes the representation clauses accepted by GNAT, and
9930 their effect on the representation of corresponding data objects.
9932 GNAT fully implements Annex C (Systems Programming). This means that all
9933 the implementation advice sections in chapter 13 are fully implemented.
9934 However, these sections only require a minimal level of support for
9935 representation clauses. GNAT provides much more extensive capabilities,
9936 and this section describes the additional capabilities provided.
9938 @node Alignment Clauses
9939 @section Alignment Clauses
9940 @cindex Alignment Clause
9943 GNAT requires that all alignment clauses specify a power of 2, and all
9944 default alignments are always a power of 2. The default alignment
9945 values are as follows:
9948 @item @emph{Primitive Types}.
9949 For primitive types, the alignment is the minimum of the actual size of
9950 objects of the type divided by @code{Storage_Unit},
9951 and the maximum alignment supported by the target.
9952 (This maximum alignment is given by the GNAT-specific attribute
9953 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9954 @cindex @code{Maximum_Alignment} attribute
9955 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9956 default alignment will be 8 on any target that supports alignments
9957 this large, but on some targets, the maximum alignment may be smaller
9958 than 8, in which case objects of type @code{Long_Float} will be maximally
9961 @item @emph{Arrays}.
9962 For arrays, the alignment is equal to the alignment of the component type
9963 for the normal case where no packing or component size is given. If the
9964 array is packed, and the packing is effective (see separate section on
9965 packed arrays), then the alignment will be one for long packed arrays,
9966 or arrays whose length is not known at compile time. For short packed
9967 arrays, which are handled internally as modular types, the alignment
9968 will be as described for primitive types, e.g.@: a packed array of length
9969 31 bits will have an object size of four bytes, and an alignment of 4.
9971 @item @emph{Records}.
9972 For the normal non-packed case, the alignment of a record is equal to
9973 the maximum alignment of any of its components. For tagged records, this
9974 includes the implicit access type used for the tag. If a pragma @code{Pack}
9975 is used and all components are packable (see separate section on pragma
9976 @code{Pack}), then the resulting alignment is 1, unless the layout of the
9977 record makes it profitable to increase it.
9979 A special case is when:
9982 the size of the record is given explicitly, or a
9983 full record representation clause is given, and
9985 the size of the record is 2, 4, or 8 bytes.
9988 In this case, an alignment is chosen to match the
9989 size of the record. For example, if we have:
9991 @smallexample @c ada
9992 type Small is record
9995 for Small'Size use 16;
9999 then the default alignment of the record type @code{Small} is 2, not 1. This
10000 leads to more efficient code when the record is treated as a unit, and also
10001 allows the type to specified as @code{Atomic} on architectures requiring
10007 An alignment clause may specify a larger alignment than the default value
10008 up to some maximum value dependent on the target (obtainable by using the
10009 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
10010 a smaller alignment than the default value for enumeration, integer and
10011 fixed point types, as well as for record types, for example
10013 @smallexample @c ada
10018 for V'alignment use 1;
10022 @cindex Alignment, default
10023 The default alignment for the type @code{V} is 4, as a result of the
10024 Integer field in the record, but it is permissible, as shown, to
10025 override the default alignment of the record with a smaller value.
10028 @section Size Clauses
10029 @cindex Size Clause
10032 The default size for a type @code{T} is obtainable through the
10033 language-defined attribute @code{T'Size} and also through the
10034 equivalent GNAT-defined attribute @code{T'Value_Size}.
10035 For objects of type @code{T}, GNAT will generally increase the type size
10036 so that the object size (obtainable through the GNAT-defined attribute
10037 @code{T'Object_Size})
10038 is a multiple of @code{T'Alignment * Storage_Unit}.
10041 @smallexample @c ada
10042 type Smallint is range 1 .. 6;
10051 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10052 as specified by the RM rules,
10053 but objects of this type will have a size of 8
10054 (@code{Smallint'Object_Size} = 8),
10055 since objects by default occupy an integral number
10056 of storage units. On some targets, notably older
10057 versions of the Digital Alpha, the size of stand
10058 alone objects of this type may be 32, reflecting
10059 the inability of the hardware to do byte load/stores.
10061 Similarly, the size of type @code{Rec} is 40 bits
10062 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10063 the alignment is 4, so objects of this type will have
10064 their size increased to 64 bits so that it is a multiple
10065 of the alignment (in bits). This decision is
10066 in accordance with the specific Implementation Advice in RM 13.3(43):
10069 A @code{Size} clause should be supported for an object if the specified
10070 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10071 to a size in storage elements that is a multiple of the object's
10072 @code{Alignment} (if the @code{Alignment} is nonzero).
10076 An explicit size clause may be used to override the default size by
10077 increasing it. For example, if we have:
10079 @smallexample @c ada
10080 type My_Boolean is new Boolean;
10081 for My_Boolean'Size use 32;
10085 then values of this type will always be 32 bits long. In the case of
10086 discrete types, the size can be increased up to 64 bits, with the effect
10087 that the entire specified field is used to hold the value, sign- or
10088 zero-extended as appropriate. If more than 64 bits is specified, then
10089 padding space is allocated after the value, and a warning is issued that
10090 there are unused bits.
10092 Similarly the size of records and arrays may be increased, and the effect
10093 is to add padding bits after the value. This also causes a warning message
10096 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
10097 Size in bits, this corresponds to an object of size 256 megabytes (minus
10098 one). This limitation is true on all targets. The reason for this
10099 limitation is that it improves the quality of the code in many cases
10100 if it is known that a Size value can be accommodated in an object of
10103 @node Storage_Size Clauses
10104 @section Storage_Size Clauses
10105 @cindex Storage_Size Clause
10108 For tasks, the @code{Storage_Size} clause specifies the amount of space
10109 to be allocated for the task stack. This cannot be extended, and if the
10110 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10111 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
10112 or a @code{Storage_Size} pragma in the task definition to set the
10113 appropriate required size. A useful technique is to include in every
10114 task definition a pragma of the form:
10116 @smallexample @c ada
10117 pragma Storage_Size (Default_Stack_Size);
10121 Then @code{Default_Stack_Size} can be defined in a global package, and
10122 modified as required. Any tasks requiring stack sizes different from the
10123 default can have an appropriate alternative reference in the pragma.
10125 You can also use the @option{-d} binder switch to modify the default stack
10128 For access types, the @code{Storage_Size} clause specifies the maximum
10129 space available for allocation of objects of the type. If this space is
10130 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10131 In the case where the access type is declared local to a subprogram, the
10132 use of a @code{Storage_Size} clause triggers automatic use of a special
10133 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10134 space for the pool is automatically reclaimed on exit from the scope in
10135 which the type is declared.
10137 A special case recognized by the compiler is the specification of a
10138 @code{Storage_Size} of zero for an access type. This means that no
10139 items can be allocated from the pool, and this is recognized at compile
10140 time, and all the overhead normally associated with maintaining a fixed
10141 size storage pool is eliminated. Consider the following example:
10143 @smallexample @c ada
10145 type R is array (Natural) of Character;
10146 type P is access all R;
10147 for P'Storage_Size use 0;
10148 -- Above access type intended only for interfacing purposes
10152 procedure g (m : P);
10153 pragma Import (C, g);
10164 As indicated in this example, these dummy storage pools are often useful in
10165 connection with interfacing where no object will ever be allocated. If you
10166 compile the above example, you get the warning:
10169 p.adb:16:09: warning: allocation from empty storage pool
10170 p.adb:16:09: warning: Storage_Error will be raised at run time
10174 Of course in practice, there will not be any explicit allocators in the
10175 case of such an access declaration.
10177 @node Size of Variant Record Objects
10178 @section Size of Variant Record Objects
10179 @cindex Size, variant record objects
10180 @cindex Variant record objects, size
10183 In the case of variant record objects, there is a question whether Size gives
10184 information about a particular variant, or the maximum size required
10185 for any variant. Consider the following program
10187 @smallexample @c ada
10188 with Text_IO; use Text_IO;
10190 type R1 (A : Boolean := False) is record
10192 when True => X : Character;
10193 when False => null;
10201 Put_Line (Integer'Image (V1'Size));
10202 Put_Line (Integer'Image (V2'Size));
10207 Here we are dealing with a variant record, where the True variant
10208 requires 16 bits, and the False variant requires 8 bits.
10209 In the above example, both V1 and V2 contain the False variant,
10210 which is only 8 bits long. However, the result of running the
10219 The reason for the difference here is that the discriminant value of
10220 V1 is fixed, and will always be False. It is not possible to assign
10221 a True variant value to V1, therefore 8 bits is sufficient. On the
10222 other hand, in the case of V2, the initial discriminant value is
10223 False (from the default), but it is possible to assign a True
10224 variant value to V2, therefore 16 bits must be allocated for V2
10225 in the general case, even fewer bits may be needed at any particular
10226 point during the program execution.
10228 As can be seen from the output of this program, the @code{'Size}
10229 attribute applied to such an object in GNAT gives the actual allocated
10230 size of the variable, which is the largest size of any of the variants.
10231 The Ada Reference Manual is not completely clear on what choice should
10232 be made here, but the GNAT behavior seems most consistent with the
10233 language in the RM@.
10235 In some cases, it may be desirable to obtain the size of the current
10236 variant, rather than the size of the largest variant. This can be
10237 achieved in GNAT by making use of the fact that in the case of a
10238 subprogram parameter, GNAT does indeed return the size of the current
10239 variant (because a subprogram has no way of knowing how much space
10240 is actually allocated for the actual).
10242 Consider the following modified version of the above program:
10244 @smallexample @c ada
10245 with Text_IO; use Text_IO;
10247 type R1 (A : Boolean := False) is record
10249 when True => X : Character;
10250 when False => null;
10256 function Size (V : R1) return Integer is
10262 Put_Line (Integer'Image (V2'Size));
10263 Put_Line (Integer'IMage (Size (V2)));
10265 Put_Line (Integer'Image (V2'Size));
10266 Put_Line (Integer'IMage (Size (V2)));
10271 The output from this program is
10281 Here we see that while the @code{'Size} attribute always returns
10282 the maximum size, regardless of the current variant value, the
10283 @code{Size} function does indeed return the size of the current
10286 @node Biased Representation
10287 @section Biased Representation
10288 @cindex Size for biased representation
10289 @cindex Biased representation
10292 In the case of scalars with a range starting at other than zero, it is
10293 possible in some cases to specify a size smaller than the default minimum
10294 value, and in such cases, GNAT uses an unsigned biased representation,
10295 in which zero is used to represent the lower bound, and successive values
10296 represent successive values of the type.
10298 For example, suppose we have the declaration:
10300 @smallexample @c ada
10301 type Small is range -7 .. -4;
10302 for Small'Size use 2;
10306 Although the default size of type @code{Small} is 4, the @code{Size}
10307 clause is accepted by GNAT and results in the following representation
10311 -7 is represented as 2#00#
10312 -6 is represented as 2#01#
10313 -5 is represented as 2#10#
10314 -4 is represented as 2#11#
10318 Biased representation is only used if the specified @code{Size} clause
10319 cannot be accepted in any other manner. These reduced sizes that force
10320 biased representation can be used for all discrete types except for
10321 enumeration types for which a representation clause is given.
10323 @node Value_Size and Object_Size Clauses
10324 @section Value_Size and Object_Size Clauses
10326 @findex Object_Size
10327 @cindex Size, of objects
10330 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10331 number of bits required to hold values of type @code{T}.
10332 Although this interpretation was allowed in Ada 83, it was not required,
10333 and this requirement in practice can cause some significant difficulties.
10334 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10335 However, in Ada 95 and Ada 2005,
10336 @code{Natural'Size} is
10337 typically 31. This means that code may change in behavior when moving
10338 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
10340 @smallexample @c ada
10341 type Rec is record;
10347 at 0 range 0 .. Natural'Size - 1;
10348 at 0 range Natural'Size .. 2 * Natural'Size - 1;
10353 In the above code, since the typical size of @code{Natural} objects
10354 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10355 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10356 there are cases where the fact that the object size can exceed the
10357 size of the type causes surprises.
10359 To help get around this problem GNAT provides two implementation
10360 defined attributes, @code{Value_Size} and @code{Object_Size}. When
10361 applied to a type, these attributes yield the size of the type
10362 (corresponding to the RM defined size attribute), and the size of
10363 objects of the type respectively.
10365 The @code{Object_Size} is used for determining the default size of
10366 objects and components. This size value can be referred to using the
10367 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
10368 the basis of the determination of the size. The backend is free to
10369 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10370 character might be stored in 32 bits on a machine with no efficient
10371 byte access instructions such as the Alpha.
10373 The default rules for the value of @code{Object_Size} for
10374 discrete types are as follows:
10378 The @code{Object_Size} for base subtypes reflect the natural hardware
10379 size in bits (run the compiler with @option{-gnatS} to find those values
10380 for numeric types). Enumeration types and fixed-point base subtypes have
10381 8, 16, 32 or 64 bits for this size, depending on the range of values
10385 The @code{Object_Size} of a subtype is the same as the
10386 @code{Object_Size} of
10387 the type from which it is obtained.
10390 The @code{Object_Size} of a derived base type is copied from the parent
10391 base type, and the @code{Object_Size} of a derived first subtype is copied
10392 from the parent first subtype.
10396 The @code{Value_Size} attribute
10397 is the (minimum) number of bits required to store a value
10399 This value is used to determine how tightly to pack
10400 records or arrays with components of this type, and also affects
10401 the semantics of unchecked conversion (unchecked conversions where
10402 the @code{Value_Size} values differ generate a warning, and are potentially
10405 The default rules for the value of @code{Value_Size} are as follows:
10409 The @code{Value_Size} for a base subtype is the minimum number of bits
10410 required to store all values of the type (including the sign bit
10411 only if negative values are possible).
10414 If a subtype statically matches the first subtype of a given type, then it has
10415 by default the same @code{Value_Size} as the first subtype. This is a
10416 consequence of RM 13.1(14) (``if two subtypes statically match,
10417 then their subtype-specific aspects are the same''.)
10420 All other subtypes have a @code{Value_Size} corresponding to the minimum
10421 number of bits required to store all values of the subtype. For
10422 dynamic bounds, it is assumed that the value can range down or up
10423 to the corresponding bound of the ancestor
10427 The RM defined attribute @code{Size} corresponds to the
10428 @code{Value_Size} attribute.
10430 The @code{Size} attribute may be defined for a first-named subtype. This sets
10431 the @code{Value_Size} of
10432 the first-named subtype to the given value, and the
10433 @code{Object_Size} of this first-named subtype to the given value padded up
10434 to an appropriate boundary. It is a consequence of the default rules
10435 above that this @code{Object_Size} will apply to all further subtypes. On the
10436 other hand, @code{Value_Size} is affected only for the first subtype, any
10437 dynamic subtypes obtained from it directly, and any statically matching
10438 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
10440 @code{Value_Size} and
10441 @code{Object_Size} may be explicitly set for any subtype using
10442 an attribute definition clause. Note that the use of these attributes
10443 can cause the RM 13.1(14) rule to be violated. If two access types
10444 reference aliased objects whose subtypes have differing @code{Object_Size}
10445 values as a result of explicit attribute definition clauses, then it
10446 is erroneous to convert from one access subtype to the other.
10448 At the implementation level, Esize stores the Object_Size and the
10449 RM_Size field stores the @code{Value_Size} (and hence the value of the
10450 @code{Size} attribute,
10451 which, as noted above, is equivalent to @code{Value_Size}).
10453 To get a feel for the difference, consider the following examples (note
10454 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10457 Object_Size Value_Size
10459 type x1 is range 0 .. 5; 8 3
10461 type x2 is range 0 .. 5;
10462 for x2'size use 12; 16 12
10464 subtype x3 is x2 range 0 .. 3; 16 2
10466 subtype x4 is x2'base range 0 .. 10; 8 4
10468 subtype x5 is x2 range 0 .. dynamic; 16 3*
10470 subtype x6 is x2'base range 0 .. dynamic; 8 3*
10475 Note: the entries marked ``3*'' are not actually specified by the Ada
10476 Reference Manual, but it seems in the spirit of the RM rules to allocate
10477 the minimum number of bits (here 3, given the range for @code{x2})
10478 known to be large enough to hold the given range of values.
10480 So far, so good, but GNAT has to obey the RM rules, so the question is
10481 under what conditions must the RM @code{Size} be used.
10482 The following is a list
10483 of the occasions on which the RM @code{Size} must be used:
10487 Component size for packed arrays or records
10490 Value of the attribute @code{Size} for a type
10493 Warning about sizes not matching for unchecked conversion
10497 For record types, the @code{Object_Size} is always a multiple of the
10498 alignment of the type (this is true for all types). In some cases the
10499 @code{Value_Size} can be smaller. Consider:
10509 On a typical 32-bit architecture, the X component will be four bytes, and
10510 require four-byte alignment, and the Y component will be one byte. In this
10511 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10512 required to store a value of this type, and for example, it is permissible
10513 to have a component of type R in an outer array whose component size is
10514 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10515 since it must be rounded up so that this value is a multiple of the
10516 alignment (4 bytes = 32 bits).
10519 For all other types, the @code{Object_Size}
10520 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10521 Only @code{Size} may be specified for such types.
10523 @node Component_Size Clauses
10524 @section Component_Size Clauses
10525 @cindex Component_Size Clause
10528 Normally, the value specified in a component size clause must be consistent
10529 with the subtype of the array component with regard to size and alignment.
10530 In other words, the value specified must be at least equal to the size
10531 of this subtype, and must be a multiple of the alignment value.
10533 In addition, component size clauses are allowed which cause the array
10534 to be packed, by specifying a smaller value. A first case is for
10535 component size values in the range 1 through 63. The value specified
10536 must not be smaller than the Size of the subtype. GNAT will accurately
10537 honor all packing requests in this range. For example, if we have:
10539 @smallexample @c ada
10540 type r is array (1 .. 8) of Natural;
10541 for r'Component_Size use 31;
10545 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10546 Of course access to the components of such an array is considerably
10547 less efficient than if the natural component size of 32 is used.
10548 A second case is when the subtype of the component is a record type
10549 padded because of its default alignment. For example, if we have:
10551 @smallexample @c ada
10558 type a is array (1 .. 8) of r;
10559 for a'Component_Size use 72;
10563 then the resulting array has a length of 72 bytes, instead of 96 bytes
10564 if the alignment of the record (4) was obeyed.
10566 Note that there is no point in giving both a component size clause
10567 and a pragma Pack for the same array type. if such duplicate
10568 clauses are given, the pragma Pack will be ignored.
10570 @node Bit_Order Clauses
10571 @section Bit_Order Clauses
10572 @cindex Bit_Order Clause
10573 @cindex bit ordering
10574 @cindex ordering, of bits
10577 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10578 attribute. The specification may either correspond to the default bit
10579 order for the target, in which case the specification has no effect and
10580 places no additional restrictions, or it may be for the non-standard
10581 setting (that is the opposite of the default).
10583 In the case where the non-standard value is specified, the effect is
10584 to renumber bits within each byte, but the ordering of bytes is not
10585 affected. There are certain
10586 restrictions placed on component clauses as follows:
10590 @item Components fitting within a single storage unit.
10592 These are unrestricted, and the effect is merely to renumber bits. For
10593 example if we are on a little-endian machine with @code{Low_Order_First}
10594 being the default, then the following two declarations have exactly
10597 @smallexample @c ada
10600 B : Integer range 1 .. 120;
10604 A at 0 range 0 .. 0;
10605 B at 0 range 1 .. 7;
10610 B : Integer range 1 .. 120;
10613 for R2'Bit_Order use High_Order_First;
10616 A at 0 range 7 .. 7;
10617 B at 0 range 0 .. 6;
10622 The useful application here is to write the second declaration with the
10623 @code{Bit_Order} attribute definition clause, and know that it will be treated
10624 the same, regardless of whether the target is little-endian or big-endian.
10626 @item Components occupying an integral number of bytes.
10628 These are components that exactly fit in two or more bytes. Such component
10629 declarations are allowed, but have no effect, since it is important to realize
10630 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10631 In particular, the following attempt at getting an endian-independent integer
10634 @smallexample @c ada
10639 for R2'Bit_Order use High_Order_First;
10642 A at 0 range 0 .. 31;
10647 This declaration will result in a little-endian integer on a
10648 little-endian machine, and a big-endian integer on a big-endian machine.
10649 If byte flipping is required for interoperability between big- and
10650 little-endian machines, this must be explicitly programmed. This capability
10651 is not provided by @code{Bit_Order}.
10653 @item Components that are positioned across byte boundaries
10655 but do not occupy an integral number of bytes. Given that bytes are not
10656 reordered, such fields would occupy a non-contiguous sequence of bits
10657 in memory, requiring non-trivial code to reassemble. They are for this
10658 reason not permitted, and any component clause specifying such a layout
10659 will be flagged as illegal by GNAT@.
10664 Since the misconception that Bit_Order automatically deals with all
10665 endian-related incompatibilities is a common one, the specification of
10666 a component field that is an integral number of bytes will always
10667 generate a warning. This warning may be suppressed using @code{pragma
10668 Warnings (Off)} if desired. The following section contains additional
10669 details regarding the issue of byte ordering.
10671 @node Effect of Bit_Order on Byte Ordering
10672 @section Effect of Bit_Order on Byte Ordering
10673 @cindex byte ordering
10674 @cindex ordering, of bytes
10677 In this section we will review the effect of the @code{Bit_Order} attribute
10678 definition clause on byte ordering. Briefly, it has no effect at all, but
10679 a detailed example will be helpful. Before giving this
10680 example, let us review the precise
10681 definition of the effect of defining @code{Bit_Order}. The effect of a
10682 non-standard bit order is described in section 15.5.3 of the Ada
10686 2 A bit ordering is a method of interpreting the meaning of
10687 the storage place attributes.
10691 To understand the precise definition of storage place attributes in
10692 this context, we visit section 13.5.1 of the manual:
10695 13 A record_representation_clause (without the mod_clause)
10696 specifies the layout. The storage place attributes (see 13.5.2)
10697 are taken from the values of the position, first_bit, and last_bit
10698 expressions after normalizing those values so that first_bit is
10699 less than Storage_Unit.
10703 The critical point here is that storage places are taken from
10704 the values after normalization, not before. So the @code{Bit_Order}
10705 interpretation applies to normalized values. The interpretation
10706 is described in the later part of the 15.5.3 paragraph:
10709 2 A bit ordering is a method of interpreting the meaning of
10710 the storage place attributes. High_Order_First (known in the
10711 vernacular as ``big endian'') means that the first bit of a
10712 storage element (bit 0) is the most significant bit (interpreting
10713 the sequence of bits that represent a component as an unsigned
10714 integer value). Low_Order_First (known in the vernacular as
10715 ``little endian'') means the opposite: the first bit is the
10720 Note that the numbering is with respect to the bits of a storage
10721 unit. In other words, the specification affects only the numbering
10722 of bits within a single storage unit.
10724 We can make the effect clearer by giving an example.
10726 Suppose that we have an external device which presents two bytes, the first
10727 byte presented, which is the first (low addressed byte) of the two byte
10728 record is called Master, and the second byte is called Slave.
10730 The left most (most significant bit is called Control for each byte, and
10731 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10732 (least significant) bit.
10734 On a big-endian machine, we can write the following representation clause
10736 @smallexample @c ada
10737 type Data is record
10738 Master_Control : Bit;
10746 Slave_Control : Bit;
10756 for Data use record
10757 Master_Control at 0 range 0 .. 0;
10758 Master_V1 at 0 range 1 .. 1;
10759 Master_V2 at 0 range 2 .. 2;
10760 Master_V3 at 0 range 3 .. 3;
10761 Master_V4 at 0 range 4 .. 4;
10762 Master_V5 at 0 range 5 .. 5;
10763 Master_V6 at 0 range 6 .. 6;
10764 Master_V7 at 0 range 7 .. 7;
10765 Slave_Control at 1 range 0 .. 0;
10766 Slave_V1 at 1 range 1 .. 1;
10767 Slave_V2 at 1 range 2 .. 2;
10768 Slave_V3 at 1 range 3 .. 3;
10769 Slave_V4 at 1 range 4 .. 4;
10770 Slave_V5 at 1 range 5 .. 5;
10771 Slave_V6 at 1 range 6 .. 6;
10772 Slave_V7 at 1 range 7 .. 7;
10777 Now if we move this to a little endian machine, then the bit ordering within
10778 the byte is backwards, so we have to rewrite the record rep clause as:
10780 @smallexample @c ada
10781 for Data use record
10782 Master_Control at 0 range 7 .. 7;
10783 Master_V1 at 0 range 6 .. 6;
10784 Master_V2 at 0 range 5 .. 5;
10785 Master_V3 at 0 range 4 .. 4;
10786 Master_V4 at 0 range 3 .. 3;
10787 Master_V5 at 0 range 2 .. 2;
10788 Master_V6 at 0 range 1 .. 1;
10789 Master_V7 at 0 range 0 .. 0;
10790 Slave_Control at 1 range 7 .. 7;
10791 Slave_V1 at 1 range 6 .. 6;
10792 Slave_V2 at 1 range 5 .. 5;
10793 Slave_V3 at 1 range 4 .. 4;
10794 Slave_V4 at 1 range 3 .. 3;
10795 Slave_V5 at 1 range 2 .. 2;
10796 Slave_V6 at 1 range 1 .. 1;
10797 Slave_V7 at 1 range 0 .. 0;
10802 It is a nuisance to have to rewrite the clause, especially if
10803 the code has to be maintained on both machines. However,
10804 this is a case that we can handle with the
10805 @code{Bit_Order} attribute if it is implemented.
10806 Note that the implementation is not required on byte addressed
10807 machines, but it is indeed implemented in GNAT.
10808 This means that we can simply use the
10809 first record clause, together with the declaration
10811 @smallexample @c ada
10812 for Data'Bit_Order use High_Order_First;
10816 and the effect is what is desired, namely the layout is exactly the same,
10817 independent of whether the code is compiled on a big-endian or little-endian
10820 The important point to understand is that byte ordering is not affected.
10821 A @code{Bit_Order} attribute definition never affects which byte a field
10822 ends up in, only where it ends up in that byte.
10823 To make this clear, let us rewrite the record rep clause of the previous
10826 @smallexample @c ada
10827 for Data'Bit_Order use High_Order_First;
10828 for Data use record
10829 Master_Control at 0 range 0 .. 0;
10830 Master_V1 at 0 range 1 .. 1;
10831 Master_V2 at 0 range 2 .. 2;
10832 Master_V3 at 0 range 3 .. 3;
10833 Master_V4 at 0 range 4 .. 4;
10834 Master_V5 at 0 range 5 .. 5;
10835 Master_V6 at 0 range 6 .. 6;
10836 Master_V7 at 0 range 7 .. 7;
10837 Slave_Control at 0 range 8 .. 8;
10838 Slave_V1 at 0 range 9 .. 9;
10839 Slave_V2 at 0 range 10 .. 10;
10840 Slave_V3 at 0 range 11 .. 11;
10841 Slave_V4 at 0 range 12 .. 12;
10842 Slave_V5 at 0 range 13 .. 13;
10843 Slave_V6 at 0 range 14 .. 14;
10844 Slave_V7 at 0 range 15 .. 15;
10849 This is exactly equivalent to saying (a repeat of the first example):
10851 @smallexample @c ada
10852 for Data'Bit_Order use High_Order_First;
10853 for Data use record
10854 Master_Control at 0 range 0 .. 0;
10855 Master_V1 at 0 range 1 .. 1;
10856 Master_V2 at 0 range 2 .. 2;
10857 Master_V3 at 0 range 3 .. 3;
10858 Master_V4 at 0 range 4 .. 4;
10859 Master_V5 at 0 range 5 .. 5;
10860 Master_V6 at 0 range 6 .. 6;
10861 Master_V7 at 0 range 7 .. 7;
10862 Slave_Control at 1 range 0 .. 0;
10863 Slave_V1 at 1 range 1 .. 1;
10864 Slave_V2 at 1 range 2 .. 2;
10865 Slave_V3 at 1 range 3 .. 3;
10866 Slave_V4 at 1 range 4 .. 4;
10867 Slave_V5 at 1 range 5 .. 5;
10868 Slave_V6 at 1 range 6 .. 6;
10869 Slave_V7 at 1 range 7 .. 7;
10874 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10875 field. The storage place attributes are obtained by normalizing the
10876 values given so that the @code{First_Bit} value is less than 8. After
10877 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10878 we specified in the other case.
10880 Now one might expect that the @code{Bit_Order} attribute might affect
10881 bit numbering within the entire record component (two bytes in this
10882 case, thus affecting which byte fields end up in), but that is not
10883 the way this feature is defined, it only affects numbering of bits,
10884 not which byte they end up in.
10886 Consequently it never makes sense to specify a starting bit number
10887 greater than 7 (for a byte addressable field) if an attribute
10888 definition for @code{Bit_Order} has been given, and indeed it
10889 may be actively confusing to specify such a value, so the compiler
10890 generates a warning for such usage.
10892 If you do need to control byte ordering then appropriate conditional
10893 values must be used. If in our example, the slave byte came first on
10894 some machines we might write:
10896 @smallexample @c ada
10897 Master_Byte_First constant Boolean := @dots{};
10899 Master_Byte : constant Natural :=
10900 1 - Boolean'Pos (Master_Byte_First);
10901 Slave_Byte : constant Natural :=
10902 Boolean'Pos (Master_Byte_First);
10904 for Data'Bit_Order use High_Order_First;
10905 for Data use record
10906 Master_Control at Master_Byte range 0 .. 0;
10907 Master_V1 at Master_Byte range 1 .. 1;
10908 Master_V2 at Master_Byte range 2 .. 2;
10909 Master_V3 at Master_Byte range 3 .. 3;
10910 Master_V4 at Master_Byte range 4 .. 4;
10911 Master_V5 at Master_Byte range 5 .. 5;
10912 Master_V6 at Master_Byte range 6 .. 6;
10913 Master_V7 at Master_Byte range 7 .. 7;
10914 Slave_Control at Slave_Byte range 0 .. 0;
10915 Slave_V1 at Slave_Byte range 1 .. 1;
10916 Slave_V2 at Slave_Byte range 2 .. 2;
10917 Slave_V3 at Slave_Byte range 3 .. 3;
10918 Slave_V4 at Slave_Byte range 4 .. 4;
10919 Slave_V5 at Slave_Byte range 5 .. 5;
10920 Slave_V6 at Slave_Byte range 6 .. 6;
10921 Slave_V7 at Slave_Byte range 7 .. 7;
10926 Now to switch between machines, all that is necessary is
10927 to set the boolean constant @code{Master_Byte_First} in
10928 an appropriate manner.
10930 @node Pragma Pack for Arrays
10931 @section Pragma Pack for Arrays
10932 @cindex Pragma Pack (for arrays)
10935 Pragma @code{Pack} applied to an array has no effect unless the component type
10936 is packable. For a component type to be packable, it must be one of the
10943 Any type whose size is specified with a size clause
10945 Any packed array type with a static size
10947 Any record type padded because of its default alignment
10951 For all these cases, if the component subtype size is in the range
10952 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10953 component size were specified giving the component subtype size.
10954 For example if we have:
10956 @smallexample @c ada
10957 type r is range 0 .. 17;
10959 type ar is array (1 .. 8) of r;
10964 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10965 and the size of the array @code{ar} will be exactly 40 bits.
10967 Note that in some cases this rather fierce approach to packing can produce
10968 unexpected effects. For example, in Ada 95 and Ada 2005,
10969 subtype @code{Natural} typically has a size of 31, meaning that if you
10970 pack an array of @code{Natural}, you get 31-bit
10971 close packing, which saves a few bits, but results in far less efficient
10972 access. Since many other Ada compilers will ignore such a packing request,
10973 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10974 might not be what is intended. You can easily remove this warning by
10975 using an explicit @code{Component_Size} setting instead, which never generates
10976 a warning, since the intention of the programmer is clear in this case.
10978 GNAT treats packed arrays in one of two ways. If the size of the array is
10979 known at compile time and is less than 64 bits, then internally the array
10980 is represented as a single modular type, of exactly the appropriate number
10981 of bits. If the length is greater than 63 bits, or is not known at compile
10982 time, then the packed array is represented as an array of bytes, and the
10983 length is always a multiple of 8 bits.
10985 Note that to represent a packed array as a modular type, the alignment must
10986 be suitable for the modular type involved. For example, on typical machines
10987 a 32-bit packed array will be represented by a 32-bit modular integer with
10988 an alignment of four bytes. If you explicitly override the default alignment
10989 with an alignment clause that is too small, the modular representation
10990 cannot be used. For example, consider the following set of declarations:
10992 @smallexample @c ada
10993 type R is range 1 .. 3;
10994 type S is array (1 .. 31) of R;
10995 for S'Component_Size use 2;
10997 for S'Alignment use 1;
11001 If the alignment clause were not present, then a 62-bit modular
11002 representation would be chosen (typically with an alignment of 4 or 8
11003 bytes depending on the target). But the default alignment is overridden
11004 with the explicit alignment clause. This means that the modular
11005 representation cannot be used, and instead the array of bytes
11006 representation must be used, meaning that the length must be a multiple
11007 of 8. Thus the above set of declarations will result in a diagnostic
11008 rejecting the size clause and noting that the minimum size allowed is 64.
11010 @cindex Pragma Pack (for type Natural)
11011 @cindex Pragma Pack warning
11013 One special case that is worth noting occurs when the base type of the
11014 component size is 8/16/32 and the subtype is one bit less. Notably this
11015 occurs with subtype @code{Natural}. Consider:
11017 @smallexample @c ada
11018 type Arr is array (1 .. 32) of Natural;
11023 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
11024 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
11025 Ada 83 compilers did not attempt 31 bit packing.
11027 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
11028 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
11029 substantial unintended performance penalty when porting legacy Ada 83 code.
11030 To help prevent this, GNAT generates a warning in such cases. If you really
11031 want 31 bit packing in a case like this, you can set the component size
11034 @smallexample @c ada
11035 type Arr is array (1 .. 32) of Natural;
11036 for Arr'Component_Size use 31;
11040 Here 31-bit packing is achieved as required, and no warning is generated,
11041 since in this case the programmer intention is clear.
11043 @node Pragma Pack for Records
11044 @section Pragma Pack for Records
11045 @cindex Pragma Pack (for records)
11048 Pragma @code{Pack} applied to a record will pack the components to reduce
11049 wasted space from alignment gaps and by reducing the amount of space
11050 taken by components. We distinguish between @emph{packable} components and
11051 @emph{non-packable} components.
11052 Components of the following types are considered packable:
11055 All primitive types are packable.
11058 Small packed arrays, whose size does not exceed 64 bits, and where the
11059 size is statically known at compile time, are represented internally
11060 as modular integers, and so they are also packable.
11065 All packable components occupy the exact number of bits corresponding to
11066 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11067 can start on an arbitrary bit boundary.
11069 All other types are non-packable, they occupy an integral number of
11071 are placed at a boundary corresponding to their alignment requirements.
11073 For example, consider the record
11075 @smallexample @c ada
11076 type Rb1 is array (1 .. 13) of Boolean;
11079 type Rb2 is array (1 .. 65) of Boolean;
11094 The representation for the record x2 is as follows:
11096 @smallexample @c ada
11097 for x2'Size use 224;
11099 l1 at 0 range 0 .. 0;
11100 l2 at 0 range 1 .. 64;
11101 l3 at 12 range 0 .. 31;
11102 l4 at 16 range 0 .. 0;
11103 l5 at 16 range 1 .. 13;
11104 l6 at 18 range 0 .. 71;
11109 Studying this example, we see that the packable fields @code{l1}
11111 of length equal to their sizes, and placed at specific bit boundaries (and
11112 not byte boundaries) to
11113 eliminate padding. But @code{l3} is of a non-packable float type, so
11114 it is on the next appropriate alignment boundary.
11116 The next two fields are fully packable, so @code{l4} and @code{l5} are
11117 minimally packed with no gaps. However, type @code{Rb2} is a packed
11118 array that is longer than 64 bits, so it is itself non-packable. Thus
11119 the @code{l6} field is aligned to the next byte boundary, and takes an
11120 integral number of bytes, i.e.@: 72 bits.
11122 @node Record Representation Clauses
11123 @section Record Representation Clauses
11124 @cindex Record Representation Clause
11127 Record representation clauses may be given for all record types, including
11128 types obtained by record extension. Component clauses are allowed for any
11129 static component. The restrictions on component clauses depend on the type
11132 @cindex Component Clause
11133 For all components of an elementary type, the only restriction on component
11134 clauses is that the size must be at least the 'Size value of the type
11135 (actually the Value_Size). There are no restrictions due to alignment,
11136 and such components may freely cross storage boundaries.
11138 Packed arrays with a size up to and including 64 bits are represented
11139 internally using a modular type with the appropriate number of bits, and
11140 thus the same lack of restriction applies. For example, if you declare:
11142 @smallexample @c ada
11143 type R is array (1 .. 49) of Boolean;
11149 then a component clause for a component of type R may start on any
11150 specified bit boundary, and may specify a value of 49 bits or greater.
11152 For packed bit arrays that are longer than 64 bits, there are two
11153 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11154 including the important case of single bits or boolean values, then
11155 there are no limitations on placement of such components, and they
11156 may start and end at arbitrary bit boundaries.
11158 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11159 an array of this type longer than 64 bits must always be placed on
11160 on a storage unit (byte) boundary and occupy an integral number
11161 of storage units (bytes). Any component clause that does not
11162 meet this requirement will be rejected.
11164 Any aliased component, or component of an aliased type, must
11165 have its normal alignment and size. A component clause that
11166 does not meet this requirement will be rejected.
11168 The tag field of a tagged type always occupies an address sized field at
11169 the start of the record. No component clause may attempt to overlay this
11170 tag. When a tagged type appears as a component, the tag field must have
11173 In the case of a record extension T1, of a type T, no component clause applied
11174 to the type T1 can specify a storage location that would overlap the first
11175 T'Size bytes of the record.
11177 For all other component types, including non-bit-packed arrays,
11178 the component can be placed at an arbitrary bit boundary,
11179 so for example, the following is permitted:
11181 @smallexample @c ada
11182 type R is array (1 .. 10) of Boolean;
11191 G at 0 range 0 .. 0;
11192 H at 0 range 1 .. 1;
11193 L at 0 range 2 .. 81;
11194 R at 0 range 82 .. 161;
11199 Note: the above rules apply to recent releases of GNAT 5.
11200 In GNAT 3, there are more severe restrictions on larger components.
11201 For non-primitive types, including packed arrays with a size greater than
11202 64 bits, component clauses must respect the alignment requirement of the
11203 type, in particular, always starting on a byte boundary, and the length
11204 must be a multiple of the storage unit.
11206 @node Enumeration Clauses
11207 @section Enumeration Clauses
11209 The only restriction on enumeration clauses is that the range of values
11210 must be representable. For the signed case, if one or more of the
11211 representation values are negative, all values must be in the range:
11213 @smallexample @c ada
11214 System.Min_Int .. System.Max_Int
11218 For the unsigned case, where all values are nonnegative, the values must
11221 @smallexample @c ada
11222 0 .. System.Max_Binary_Modulus;
11226 A @emph{confirming} representation clause is one in which the values range
11227 from 0 in sequence, i.e.@: a clause that confirms the default representation
11228 for an enumeration type.
11229 Such a confirming representation
11230 is permitted by these rules, and is specially recognized by the compiler so
11231 that no extra overhead results from the use of such a clause.
11233 If an array has an index type which is an enumeration type to which an
11234 enumeration clause has been applied, then the array is stored in a compact
11235 manner. Consider the declarations:
11237 @smallexample @c ada
11238 type r is (A, B, C);
11239 for r use (A => 1, B => 5, C => 10);
11240 type t is array (r) of Character;
11244 The array type t corresponds to a vector with exactly three elements and
11245 has a default size equal to @code{3*Character'Size}. This ensures efficient
11246 use of space, but means that accesses to elements of the array will incur
11247 the overhead of converting representation values to the corresponding
11248 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11250 @node Address Clauses
11251 @section Address Clauses
11252 @cindex Address Clause
11254 The reference manual allows a general restriction on representation clauses,
11255 as found in RM 13.1(22):
11258 An implementation need not support representation
11259 items containing nonstatic expressions, except that
11260 an implementation should support a representation item
11261 for a given entity if each nonstatic expression in the
11262 representation item is a name that statically denotes
11263 a constant declared before the entity.
11267 In practice this is applicable only to address clauses, since this is the
11268 only case in which a non-static expression is permitted by the syntax. As
11269 the AARM notes in sections 13.1 (22.a-22.h):
11272 22.a Reason: This is to avoid the following sort of thing:
11274 22.b X : Integer := F(@dots{});
11275 Y : Address := G(@dots{});
11276 for X'Address use Y;
11278 22.c In the above, we have to evaluate the
11279 initialization expression for X before we
11280 know where to put the result. This seems
11281 like an unreasonable implementation burden.
11283 22.d The above code should instead be written
11286 22.e Y : constant Address := G(@dots{});
11287 X : Integer := F(@dots{});
11288 for X'Address use Y;
11290 22.f This allows the expression ``Y'' to be safely
11291 evaluated before X is created.
11293 22.g The constant could be a formal parameter of mode in.
11295 22.h An implementation can support other nonstatic
11296 expressions if it wants to. Expressions of type
11297 Address are hardly ever static, but their value
11298 might be known at compile time anyway in many
11303 GNAT does indeed permit many additional cases of non-static expressions. In
11304 particular, if the type involved is elementary there are no restrictions
11305 (since in this case, holding a temporary copy of the initialization value,
11306 if one is present, is inexpensive). In addition, if there is no implicit or
11307 explicit initialization, then there are no restrictions. GNAT will reject
11308 only the case where all three of these conditions hold:
11313 The type of the item is non-elementary (e.g.@: a record or array).
11316 There is explicit or implicit initialization required for the object.
11317 Note that access values are always implicitly initialized, and also
11318 in GNAT, certain bit-packed arrays (those having a dynamic length or
11319 a length greater than 64) will also be implicitly initialized to zero.
11322 The address value is non-static. Here GNAT is more permissive than the
11323 RM, and allows the address value to be the address of a previously declared
11324 stand-alone variable, as long as it does not itself have an address clause.
11326 @smallexample @c ada
11327 Anchor : Some_Initialized_Type;
11328 Overlay : Some_Initialized_Type;
11329 for Overlay'Address use Anchor'Address;
11333 However, the prefix of the address clause cannot be an array component, or
11334 a component of a discriminated record.
11339 As noted above in section 22.h, address values are typically non-static. In
11340 particular the To_Address function, even if applied to a literal value, is
11341 a non-static function call. To avoid this minor annoyance, GNAT provides
11342 the implementation defined attribute 'To_Address. The following two
11343 expressions have identical values:
11347 @smallexample @c ada
11348 To_Address (16#1234_0000#)
11349 System'To_Address (16#1234_0000#);
11353 except that the second form is considered to be a static expression, and
11354 thus when used as an address clause value is always permitted.
11357 Additionally, GNAT treats as static an address clause that is an
11358 unchecked_conversion of a static integer value. This simplifies the porting
11359 of legacy code, and provides a portable equivalent to the GNAT attribute
11362 Another issue with address clauses is the interaction with alignment
11363 requirements. When an address clause is given for an object, the address
11364 value must be consistent with the alignment of the object (which is usually
11365 the same as the alignment of the type of the object). If an address clause
11366 is given that specifies an inappropriately aligned address value, then the
11367 program execution is erroneous.
11369 Since this source of erroneous behavior can have unfortunate effects, GNAT
11370 checks (at compile time if possible, generating a warning, or at execution
11371 time with a run-time check) that the alignment is appropriate. If the
11372 run-time check fails, then @code{Program_Error} is raised. This run-time
11373 check is suppressed if range checks are suppressed, or if the special GNAT
11374 check Alignment_Check is suppressed, or if
11375 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11377 Finally, GNAT does not permit overlaying of objects of controlled types or
11378 composite types containing a controlled component. In most cases, the compiler
11379 can detect an attempt at such overlays and will generate a warning at compile
11380 time and a Program_Error exception at run time.
11383 An address clause cannot be given for an exported object. More
11384 understandably the real restriction is that objects with an address
11385 clause cannot be exported. This is because such variables are not
11386 defined by the Ada program, so there is no external object to export.
11389 It is permissible to give an address clause and a pragma Import for the
11390 same object. In this case, the variable is not really defined by the
11391 Ada program, so there is no external symbol to be linked. The link name
11392 and the external name are ignored in this case. The reason that we allow this
11393 combination is that it provides a useful idiom to avoid unwanted
11394 initializations on objects with address clauses.
11396 When an address clause is given for an object that has implicit or
11397 explicit initialization, then by default initialization takes place. This
11398 means that the effect of the object declaration is to overwrite the
11399 memory at the specified address. This is almost always not what the
11400 programmer wants, so GNAT will output a warning:
11410 for Ext'Address use System'To_Address (16#1234_1234#);
11412 >>> warning: implicit initialization of "Ext" may
11413 modify overlaid storage
11414 >>> warning: use pragma Import for "Ext" to suppress
11415 initialization (RM B(24))
11421 As indicated by the warning message, the solution is to use a (dummy) pragma
11422 Import to suppress this initialization. The pragma tell the compiler that the
11423 object is declared and initialized elsewhere. The following package compiles
11424 without warnings (and the initialization is suppressed):
11426 @smallexample @c ada
11434 for Ext'Address use System'To_Address (16#1234_1234#);
11435 pragma Import (Ada, Ext);
11440 A final issue with address clauses involves their use for overlaying
11441 variables, as in the following example:
11442 @cindex Overlaying of objects
11444 @smallexample @c ada
11447 for B'Address use A'Address;
11451 or alternatively, using the form recommended by the RM:
11453 @smallexample @c ada
11455 Addr : constant Address := A'Address;
11457 for B'Address use Addr;
11461 In both of these cases, @code{A}
11462 and @code{B} become aliased to one another via the
11463 address clause. This use of address clauses to overlay
11464 variables, achieving an effect similar to unchecked
11465 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11466 the effect is implementation defined. Furthermore, the
11467 Ada RM specifically recommends that in a situation
11468 like this, @code{B} should be subject to the following
11469 implementation advice (RM 13.3(19)):
11472 19 If the Address of an object is specified, or it is imported
11473 or exported, then the implementation should not perform
11474 optimizations based on assumptions of no aliases.
11478 GNAT follows this recommendation, and goes further by also applying
11479 this recommendation to the overlaid variable (@code{A}
11480 in the above example) in this case. This means that the overlay
11481 works "as expected", in that a modification to one of the variables
11482 will affect the value of the other.
11484 @node Effect of Convention on Representation
11485 @section Effect of Convention on Representation
11486 @cindex Convention, effect on representation
11489 Normally the specification of a foreign language convention for a type or
11490 an object has no effect on the chosen representation. In particular, the
11491 representation chosen for data in GNAT generally meets the standard system
11492 conventions, and for example records are laid out in a manner that is
11493 consistent with C@. This means that specifying convention C (for example)
11496 There are four exceptions to this general rule:
11500 @item Convention Fortran and array subtypes
11501 If pragma Convention Fortran is specified for an array subtype, then in
11502 accordance with the implementation advice in section 3.6.2(11) of the
11503 Ada Reference Manual, the array will be stored in a Fortran-compatible
11504 column-major manner, instead of the normal default row-major order.
11506 @item Convention C and enumeration types
11507 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11508 to accommodate all values of the type. For example, for the enumeration
11511 @smallexample @c ada
11512 type Color is (Red, Green, Blue);
11516 8 bits is sufficient to store all values of the type, so by default, objects
11517 of type @code{Color} will be represented using 8 bits. However, normal C
11518 convention is to use 32 bits for all enum values in C, since enum values
11519 are essentially of type int. If pragma @code{Convention C} is specified for an
11520 Ada enumeration type, then the size is modified as necessary (usually to
11521 32 bits) to be consistent with the C convention for enum values.
11523 Note that this treatment applies only to types. If Convention C is given for
11524 an enumeration object, where the enumeration type is not Convention C, then
11525 Object_Size bits are allocated. For example, for a normal enumeration type,
11526 with less than 256 elements, only 8 bits will be allocated for the object.
11527 Since this may be a surprise in terms of what C expects, GNAT will issue a
11528 warning in this situation. The warning can be suppressed by giving an explicit
11529 size clause specifying the desired size.
11531 @item Convention C/Fortran and Boolean types
11532 In C, the usual convention for boolean values, that is values used for
11533 conditions, is that zero represents false, and nonzero values represent
11534 true. In Ada, the normal convention is that two specific values, typically
11535 0/1, are used to represent false/true respectively.
11537 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11538 value represents true).
11540 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11541 C or Fortran convention for a derived Boolean, as in the following example:
11543 @smallexample @c ada
11544 type C_Switch is new Boolean;
11545 pragma Convention (C, C_Switch);
11549 then the GNAT generated code will treat any nonzero value as true. For truth
11550 values generated by GNAT, the conventional value 1 will be used for True, but
11551 when one of these values is read, any nonzero value is treated as True.
11553 @item Access types on OpenVMS
11554 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11555 arrays) are 64-bits long. An exception to this rule is for the case of
11556 C-convention access types where there is no explicit size clause present (or
11557 inherited for derived types). In this case, GNAT chooses to make these
11558 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11559 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11563 @node Determining the Representations chosen by GNAT
11564 @section Determining the Representations chosen by GNAT
11565 @cindex Representation, determination of
11566 @cindex @option{-gnatR} switch
11569 Although the descriptions in this section are intended to be complete, it is
11570 often easier to simply experiment to see what GNAT accepts and what the
11571 effect is on the layout of types and objects.
11573 As required by the Ada RM, if a representation clause is not accepted, then
11574 it must be rejected as illegal by the compiler. However, when a
11575 representation clause or pragma is accepted, there can still be questions
11576 of what the compiler actually does. For example, if a partial record
11577 representation clause specifies the location of some components and not
11578 others, then where are the non-specified components placed? Or if pragma
11579 @code{Pack} is used on a record, then exactly where are the resulting
11580 fields placed? The section on pragma @code{Pack} in this chapter can be
11581 used to answer the second question, but it is often easier to just see
11582 what the compiler does.
11584 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
11585 with this option, then the compiler will output information on the actual
11586 representations chosen, in a format similar to source representation
11587 clauses. For example, if we compile the package:
11589 @smallexample @c ada
11591 type r (x : boolean) is tagged record
11593 when True => S : String (1 .. 100);
11594 when False => null;
11598 type r2 is new r (false) with record
11603 y2 at 16 range 0 .. 31;
11610 type x1 is array (1 .. 10) of x;
11611 for x1'component_size use 11;
11613 type ia is access integer;
11615 type Rb1 is array (1 .. 13) of Boolean;
11618 type Rb2 is array (1 .. 65) of Boolean;
11634 using the switch @option{-gnatR} we obtain the following output:
11637 Representation information for unit q
11638 -------------------------------------
11641 for r'Alignment use 4;
11643 x at 4 range 0 .. 7;
11644 _tag at 0 range 0 .. 31;
11645 s at 5 range 0 .. 799;
11648 for r2'Size use 160;
11649 for r2'Alignment use 4;
11651 x at 4 range 0 .. 7;
11652 _tag at 0 range 0 .. 31;
11653 _parent at 0 range 0 .. 63;
11654 y2 at 16 range 0 .. 31;
11658 for x'Alignment use 1;
11660 y at 0 range 0 .. 7;
11663 for x1'Size use 112;
11664 for x1'Alignment use 1;
11665 for x1'Component_Size use 11;
11667 for rb1'Size use 13;
11668 for rb1'Alignment use 2;
11669 for rb1'Component_Size use 1;
11671 for rb2'Size use 72;
11672 for rb2'Alignment use 1;
11673 for rb2'Component_Size use 1;
11675 for x2'Size use 224;
11676 for x2'Alignment use 4;
11678 l1 at 0 range 0 .. 0;
11679 l2 at 0 range 1 .. 64;
11680 l3 at 12 range 0 .. 31;
11681 l4 at 16 range 0 .. 0;
11682 l5 at 16 range 1 .. 13;
11683 l6 at 18 range 0 .. 71;
11688 The Size values are actually the Object_Size, i.e.@: the default size that
11689 will be allocated for objects of the type.
11690 The ?? size for type r indicates that we have a variant record, and the
11691 actual size of objects will depend on the discriminant value.
11693 The Alignment values show the actual alignment chosen by the compiler
11694 for each record or array type.
11696 The record representation clause for type r shows where all fields
11697 are placed, including the compiler generated tag field (whose location
11698 cannot be controlled by the programmer).
11700 The record representation clause for the type extension r2 shows all the
11701 fields present, including the parent field, which is a copy of the fields
11702 of the parent type of r2, i.e.@: r1.
11704 The component size and size clauses for types rb1 and rb2 show
11705 the exact effect of pragma @code{Pack} on these arrays, and the record
11706 representation clause for type x2 shows how pragma @code{Pack} affects
11709 In some cases, it may be useful to cut and paste the representation clauses
11710 generated by the compiler into the original source to fix and guarantee
11711 the actual representation to be used.
11713 @node Standard Library Routines
11714 @chapter Standard Library Routines
11717 The Ada Reference Manual contains in Annex A a full description of an
11718 extensive set of standard library routines that can be used in any Ada
11719 program, and which must be provided by all Ada compilers. They are
11720 analogous to the standard C library used by C programs.
11722 GNAT implements all of the facilities described in annex A, and for most
11723 purposes the description in the Ada Reference Manual, or appropriate Ada
11724 text book, will be sufficient for making use of these facilities.
11726 In the case of the input-output facilities,
11727 @xref{The Implementation of Standard I/O},
11728 gives details on exactly how GNAT interfaces to the
11729 file system. For the remaining packages, the Ada Reference Manual
11730 should be sufficient. The following is a list of the packages included,
11731 together with a brief description of the functionality that is provided.
11733 For completeness, references are included to other predefined library
11734 routines defined in other sections of the Ada Reference Manual (these are
11735 cross-indexed from Annex A).
11739 This is a parent package for all the standard library packages. It is
11740 usually included implicitly in your program, and itself contains no
11741 useful data or routines.
11743 @item Ada.Calendar (9.6)
11744 @code{Calendar} provides time of day access, and routines for
11745 manipulating times and durations.
11747 @item Ada.Characters (A.3.1)
11748 This is a dummy parent package that contains no useful entities
11750 @item Ada.Characters.Handling (A.3.2)
11751 This package provides some basic character handling capabilities,
11752 including classification functions for classes of characters (e.g.@: test
11753 for letters, or digits).
11755 @item Ada.Characters.Latin_1 (A.3.3)
11756 This package includes a complete set of definitions of the characters
11757 that appear in type CHARACTER@. It is useful for writing programs that
11758 will run in international environments. For example, if you want an
11759 upper case E with an acute accent in a string, it is often better to use
11760 the definition of @code{UC_E_Acute} in this package. Then your program
11761 will print in an understandable manner even if your environment does not
11762 support these extended characters.
11764 @item Ada.Command_Line (A.15)
11765 This package provides access to the command line parameters and the name
11766 of the current program (analogous to the use of @code{argc} and @code{argv}
11767 in C), and also allows the exit status for the program to be set in a
11768 system-independent manner.
11770 @item Ada.Decimal (F.2)
11771 This package provides constants describing the range of decimal numbers
11772 implemented, and also a decimal divide routine (analogous to the COBOL
11773 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11775 @item Ada.Direct_IO (A.8.4)
11776 This package provides input-output using a model of a set of records of
11777 fixed-length, containing an arbitrary definite Ada type, indexed by an
11778 integer record number.
11780 @item Ada.Dynamic_Priorities (D.5)
11781 This package allows the priorities of a task to be adjusted dynamically
11782 as the task is running.
11784 @item Ada.Exceptions (11.4.1)
11785 This package provides additional information on exceptions, and also
11786 contains facilities for treating exceptions as data objects, and raising
11787 exceptions with associated messages.
11789 @item Ada.Finalization (7.6)
11790 This package contains the declarations and subprograms to support the
11791 use of controlled types, providing for automatic initialization and
11792 finalization (analogous to the constructors and destructors of C++)
11794 @item Ada.Interrupts (C.3.2)
11795 This package provides facilities for interfacing to interrupts, which
11796 includes the set of signals or conditions that can be raised and
11797 recognized as interrupts.
11799 @item Ada.Interrupts.Names (C.3.2)
11800 This package provides the set of interrupt names (actually signal
11801 or condition names) that can be handled by GNAT@.
11803 @item Ada.IO_Exceptions (A.13)
11804 This package defines the set of exceptions that can be raised by use of
11805 the standard IO packages.
11808 This package contains some standard constants and exceptions used
11809 throughout the numerics packages. Note that the constants pi and e are
11810 defined here, and it is better to use these definitions than rolling
11813 @item Ada.Numerics.Complex_Elementary_Functions
11814 Provides the implementation of standard elementary functions (such as
11815 log and trigonometric functions) operating on complex numbers using the
11816 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11817 created by the package @code{Numerics.Complex_Types}.
11819 @item Ada.Numerics.Complex_Types
11820 This is a predefined instantiation of
11821 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11822 build the type @code{Complex} and @code{Imaginary}.
11824 @item Ada.Numerics.Discrete_Random
11825 This package provides a random number generator suitable for generating
11826 random integer values from a specified range.
11828 @item Ada.Numerics.Float_Random
11829 This package provides a random number generator suitable for generating
11830 uniformly distributed floating point values.
11832 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11833 This is a generic version of the package that provides the
11834 implementation of standard elementary functions (such as log and
11835 trigonometric functions) for an arbitrary complex type.
11837 The following predefined instantiations of this package are provided:
11841 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11843 @code{Ada.Numerics.Complex_Elementary_Functions}
11845 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
11848 @item Ada.Numerics.Generic_Complex_Types
11849 This is a generic package that allows the creation of complex types,
11850 with associated complex arithmetic operations.
11852 The following predefined instantiations of this package exist
11855 @code{Ada.Numerics.Short_Complex_Complex_Types}
11857 @code{Ada.Numerics.Complex_Complex_Types}
11859 @code{Ada.Numerics.Long_Complex_Complex_Types}
11862 @item Ada.Numerics.Generic_Elementary_Functions
11863 This is a generic package that provides the implementation of standard
11864 elementary functions (such as log an trigonometric functions) for an
11865 arbitrary float type.
11867 The following predefined instantiations of this package exist
11871 @code{Ada.Numerics.Short_Elementary_Functions}
11873 @code{Ada.Numerics.Elementary_Functions}
11875 @code{Ada.Numerics.Long_Elementary_Functions}
11878 @item Ada.Real_Time (D.8)
11879 This package provides facilities similar to those of @code{Calendar}, but
11880 operating with a finer clock suitable for real time control. Note that
11881 annex D requires that there be no backward clock jumps, and GNAT generally
11882 guarantees this behavior, but of course if the external clock on which
11883 the GNAT runtime depends is deliberately reset by some external event,
11884 then such a backward jump may occur.
11886 @item Ada.Sequential_IO (A.8.1)
11887 This package provides input-output facilities for sequential files,
11888 which can contain a sequence of values of a single type, which can be
11889 any Ada type, including indefinite (unconstrained) types.
11891 @item Ada.Storage_IO (A.9)
11892 This package provides a facility for mapping arbitrary Ada types to and
11893 from a storage buffer. It is primarily intended for the creation of new
11896 @item Ada.Streams (13.13.1)
11897 This is a generic package that provides the basic support for the
11898 concept of streams as used by the stream attributes (@code{Input},
11899 @code{Output}, @code{Read} and @code{Write}).
11901 @item Ada.Streams.Stream_IO (A.12.1)
11902 This package is a specialization of the type @code{Streams} defined in
11903 package @code{Streams} together with a set of operations providing
11904 Stream_IO capability. The Stream_IO model permits both random and
11905 sequential access to a file which can contain an arbitrary set of values
11906 of one or more Ada types.
11908 @item Ada.Strings (A.4.1)
11909 This package provides some basic constants used by the string handling
11912 @item Ada.Strings.Bounded (A.4.4)
11913 This package provides facilities for handling variable length
11914 strings. The bounded model requires a maximum length. It is thus
11915 somewhat more limited than the unbounded model, but avoids the use of
11916 dynamic allocation or finalization.
11918 @item Ada.Strings.Fixed (A.4.3)
11919 This package provides facilities for handling fixed length strings.
11921 @item Ada.Strings.Maps (A.4.2)
11922 This package provides facilities for handling character mappings and
11923 arbitrarily defined subsets of characters. For instance it is useful in
11924 defining specialized translation tables.
11926 @item Ada.Strings.Maps.Constants (A.4.6)
11927 This package provides a standard set of predefined mappings and
11928 predefined character sets. For example, the standard upper to lower case
11929 conversion table is found in this package. Note that upper to lower case
11930 conversion is non-trivial if you want to take the entire set of
11931 characters, including extended characters like E with an acute accent,
11932 into account. You should use the mappings in this package (rather than
11933 adding 32 yourself) to do case mappings.
11935 @item Ada.Strings.Unbounded (A.4.5)
11936 This package provides facilities for handling variable length
11937 strings. The unbounded model allows arbitrary length strings, but
11938 requires the use of dynamic allocation and finalization.
11940 @item Ada.Strings.Wide_Bounded (A.4.7)
11941 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11942 @itemx Ada.Strings.Wide_Maps (A.4.7)
11943 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11944 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11945 These packages provide analogous capabilities to the corresponding
11946 packages without @samp{Wide_} in the name, but operate with the types
11947 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11948 and @code{Character}.
11950 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11951 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11952 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11953 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11954 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11955 These packages provide analogous capabilities to the corresponding
11956 packages without @samp{Wide_} in the name, but operate with the types
11957 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11958 of @code{String} and @code{Character}.
11960 @item Ada.Synchronous_Task_Control (D.10)
11961 This package provides some standard facilities for controlling task
11962 communication in a synchronous manner.
11965 This package contains definitions for manipulation of the tags of tagged
11968 @item Ada.Task_Attributes
11969 This package provides the capability of associating arbitrary
11970 task-specific data with separate tasks.
11973 This package provides basic text input-output capabilities for
11974 character, string and numeric data. The subpackages of this
11975 package are listed next.
11977 @item Ada.Text_IO.Decimal_IO
11978 Provides input-output facilities for decimal fixed-point types
11980 @item Ada.Text_IO.Enumeration_IO
11981 Provides input-output facilities for enumeration types.
11983 @item Ada.Text_IO.Fixed_IO
11984 Provides input-output facilities for ordinary fixed-point types.
11986 @item Ada.Text_IO.Float_IO
11987 Provides input-output facilities for float types. The following
11988 predefined instantiations of this generic package are available:
11992 @code{Short_Float_Text_IO}
11994 @code{Float_Text_IO}
11996 @code{Long_Float_Text_IO}
11999 @item Ada.Text_IO.Integer_IO
12000 Provides input-output facilities for integer types. The following
12001 predefined instantiations of this generic package are available:
12004 @item Short_Short_Integer
12005 @code{Ada.Short_Short_Integer_Text_IO}
12006 @item Short_Integer
12007 @code{Ada.Short_Integer_Text_IO}
12009 @code{Ada.Integer_Text_IO}
12011 @code{Ada.Long_Integer_Text_IO}
12012 @item Long_Long_Integer
12013 @code{Ada.Long_Long_Integer_Text_IO}
12016 @item Ada.Text_IO.Modular_IO
12017 Provides input-output facilities for modular (unsigned) types
12019 @item Ada.Text_IO.Complex_IO (G.1.3)
12020 This package provides basic text input-output capabilities for complex
12023 @item Ada.Text_IO.Editing (F.3.3)
12024 This package contains routines for edited output, analogous to the use
12025 of pictures in COBOL@. The picture formats used by this package are a
12026 close copy of the facility in COBOL@.
12028 @item Ada.Text_IO.Text_Streams (A.12.2)
12029 This package provides a facility that allows Text_IO files to be treated
12030 as streams, so that the stream attributes can be used for writing
12031 arbitrary data, including binary data, to Text_IO files.
12033 @item Ada.Unchecked_Conversion (13.9)
12034 This generic package allows arbitrary conversion from one type to
12035 another of the same size, providing for breaking the type safety in
12036 special circumstances.
12038 If the types have the same Size (more accurately the same Value_Size),
12039 then the effect is simply to transfer the bits from the source to the
12040 target type without any modification. This usage is well defined, and
12041 for simple types whose representation is typically the same across
12042 all implementations, gives a portable method of performing such
12045 If the types do not have the same size, then the result is implementation
12046 defined, and thus may be non-portable. The following describes how GNAT
12047 handles such unchecked conversion cases.
12049 If the types are of different sizes, and are both discrete types, then
12050 the effect is of a normal type conversion without any constraint checking.
12051 In particular if the result type has a larger size, the result will be
12052 zero or sign extended. If the result type has a smaller size, the result
12053 will be truncated by ignoring high order bits.
12055 If the types are of different sizes, and are not both discrete types,
12056 then the conversion works as though pointers were created to the source
12057 and target, and the pointer value is converted. The effect is that bits
12058 are copied from successive low order storage units and bits of the source
12059 up to the length of the target type.
12061 A warning is issued if the lengths differ, since the effect in this
12062 case is implementation dependent, and the above behavior may not match
12063 that of some other compiler.
12065 A pointer to one type may be converted to a pointer to another type using
12066 unchecked conversion. The only case in which the effect is undefined is
12067 when one or both pointers are pointers to unconstrained array types. In
12068 this case, the bounds information may get incorrectly transferred, and in
12069 particular, GNAT uses double size pointers for such types, and it is
12070 meaningless to convert between such pointer types. GNAT will issue a
12071 warning if the alignment of the target designated type is more strict
12072 than the alignment of the source designated type (since the result may
12073 be unaligned in this case).
12075 A pointer other than a pointer to an unconstrained array type may be
12076 converted to and from System.Address. Such usage is common in Ada 83
12077 programs, but note that Ada.Address_To_Access_Conversions is the
12078 preferred method of performing such conversions in Ada 95 and Ada 2005.
12080 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12081 used in conjunction with pointers to unconstrained objects, since
12082 the bounds information cannot be handled correctly in this case.
12084 @item Ada.Unchecked_Deallocation (13.11.2)
12085 This generic package allows explicit freeing of storage previously
12086 allocated by use of an allocator.
12088 @item Ada.Wide_Text_IO (A.11)
12089 This package is similar to @code{Ada.Text_IO}, except that the external
12090 file supports wide character representations, and the internal types are
12091 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12092 and @code{String}. It contains generic subpackages listed next.
12094 @item Ada.Wide_Text_IO.Decimal_IO
12095 Provides input-output facilities for decimal fixed-point types
12097 @item Ada.Wide_Text_IO.Enumeration_IO
12098 Provides input-output facilities for enumeration types.
12100 @item Ada.Wide_Text_IO.Fixed_IO
12101 Provides input-output facilities for ordinary fixed-point types.
12103 @item Ada.Wide_Text_IO.Float_IO
12104 Provides input-output facilities for float types. The following
12105 predefined instantiations of this generic package are available:
12109 @code{Short_Float_Wide_Text_IO}
12111 @code{Float_Wide_Text_IO}
12113 @code{Long_Float_Wide_Text_IO}
12116 @item Ada.Wide_Text_IO.Integer_IO
12117 Provides input-output facilities for integer types. The following
12118 predefined instantiations of this generic package are available:
12121 @item Short_Short_Integer
12122 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12123 @item Short_Integer
12124 @code{Ada.Short_Integer_Wide_Text_IO}
12126 @code{Ada.Integer_Wide_Text_IO}
12128 @code{Ada.Long_Integer_Wide_Text_IO}
12129 @item Long_Long_Integer
12130 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12133 @item Ada.Wide_Text_IO.Modular_IO
12134 Provides input-output facilities for modular (unsigned) types
12136 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12137 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12138 external file supports wide character representations.
12140 @item Ada.Wide_Text_IO.Editing (F.3.4)
12141 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12142 types are @code{Wide_Character} and @code{Wide_String} instead of
12143 @code{Character} and @code{String}.
12145 @item Ada.Wide_Text_IO.Streams (A.12.3)
12146 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12147 types are @code{Wide_Character} and @code{Wide_String} instead of
12148 @code{Character} and @code{String}.
12150 @item Ada.Wide_Wide_Text_IO (A.11)
12151 This package is similar to @code{Ada.Text_IO}, except that the external
12152 file supports wide character representations, and the internal types are
12153 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12154 and @code{String}. It contains generic subpackages listed next.
12156 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12157 Provides input-output facilities for decimal fixed-point types
12159 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12160 Provides input-output facilities for enumeration types.
12162 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12163 Provides input-output facilities for ordinary fixed-point types.
12165 @item Ada.Wide_Wide_Text_IO.Float_IO
12166 Provides input-output facilities for float types. The following
12167 predefined instantiations of this generic package are available:
12171 @code{Short_Float_Wide_Wide_Text_IO}
12173 @code{Float_Wide_Wide_Text_IO}
12175 @code{Long_Float_Wide_Wide_Text_IO}
12178 @item Ada.Wide_Wide_Text_IO.Integer_IO
12179 Provides input-output facilities for integer types. The following
12180 predefined instantiations of this generic package are available:
12183 @item Short_Short_Integer
12184 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12185 @item Short_Integer
12186 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12188 @code{Ada.Integer_Wide_Wide_Text_IO}
12190 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12191 @item Long_Long_Integer
12192 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12195 @item Ada.Wide_Wide_Text_IO.Modular_IO
12196 Provides input-output facilities for modular (unsigned) types
12198 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12199 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12200 external file supports wide character representations.
12202 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12203 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12204 types are @code{Wide_Character} and @code{Wide_String} instead of
12205 @code{Character} and @code{String}.
12207 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12208 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12209 types are @code{Wide_Character} and @code{Wide_String} instead of
12210 @code{Character} and @code{String}.
12215 @node The Implementation of Standard I/O
12216 @chapter The Implementation of Standard I/O
12219 GNAT implements all the required input-output facilities described in
12220 A.6 through A.14. These sections of the Ada Reference Manual describe the
12221 required behavior of these packages from the Ada point of view, and if
12222 you are writing a portable Ada program that does not need to know the
12223 exact manner in which Ada maps to the outside world when it comes to
12224 reading or writing external files, then you do not need to read this
12225 chapter. As long as your files are all regular files (not pipes or
12226 devices), and as long as you write and read the files only from Ada, the
12227 description in the Ada Reference Manual is sufficient.
12229 However, if you want to do input-output to pipes or other devices, such
12230 as the keyboard or screen, or if the files you are dealing with are
12231 either generated by some other language, or to be read by some other
12232 language, then you need to know more about the details of how the GNAT
12233 implementation of these input-output facilities behaves.
12235 In this chapter we give a detailed description of exactly how GNAT
12236 interfaces to the file system. As always, the sources of the system are
12237 available to you for answering questions at an even more detailed level,
12238 but for most purposes the information in this chapter will suffice.
12240 Another reason that you may need to know more about how input-output is
12241 implemented arises when you have a program written in mixed languages
12242 where, for example, files are shared between the C and Ada sections of
12243 the same program. GNAT provides some additional facilities, in the form
12244 of additional child library packages, that facilitate this sharing, and
12245 these additional facilities are also described in this chapter.
12248 * Standard I/O Packages::
12254 * Wide_Wide_Text_IO::
12256 * Text Translation::
12258 * Filenames encoding::
12260 * Operations on C Streams::
12261 * Interfacing to C Streams::
12264 @node Standard I/O Packages
12265 @section Standard I/O Packages
12268 The Standard I/O packages described in Annex A for
12274 Ada.Text_IO.Complex_IO
12276 Ada.Text_IO.Text_Streams
12280 Ada.Wide_Text_IO.Complex_IO
12282 Ada.Wide_Text_IO.Text_Streams
12284 Ada.Wide_Wide_Text_IO
12286 Ada.Wide_Wide_Text_IO.Complex_IO
12288 Ada.Wide_Wide_Text_IO.Text_Streams
12298 are implemented using the C
12299 library streams facility; where
12303 All files are opened using @code{fopen}.
12305 All input/output operations use @code{fread}/@code{fwrite}.
12309 There is no internal buffering of any kind at the Ada library level. The only
12310 buffering is that provided at the system level in the implementation of the
12311 library routines that support streams. This facilitates shared use of these
12312 streams by mixed language programs. Note though that system level buffering is
12313 explicitly enabled at elaboration of the standard I/O packages and that can
12314 have an impact on mixed language programs, in particular those using I/O before
12315 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12316 the Ada elaboration routine before performing any I/O or when impractical,
12317 flush the common I/O streams and in particular Standard_Output before
12318 elaborating the Ada code.
12321 @section FORM Strings
12324 The format of a FORM string in GNAT is:
12327 "keyword=value,keyword=value,@dots{},keyword=value"
12331 where letters may be in upper or lower case, and there are no spaces
12332 between values. The order of the entries is not important. Currently
12333 the following keywords defined.
12336 TEXT_TRANSLATION=[YES|NO]
12338 WCEM=[n|h|u|s|e|8|b]
12339 ENCODING=[UTF8|8BITS]
12343 The use of these parameters is described later in this section.
12349 Direct_IO can only be instantiated for definite types. This is a
12350 restriction of the Ada language, which means that the records are fixed
12351 length (the length being determined by @code{@var{type}'Size}, rounded
12352 up to the next storage unit boundary if necessary).
12354 The records of a Direct_IO file are simply written to the file in index
12355 sequence, with the first record starting at offset zero, and subsequent
12356 records following. There is no control information of any kind. For
12357 example, if 32-bit integers are being written, each record takes
12358 4-bytes, so the record at index @var{K} starts at offset
12359 (@var{K}@minus{}1)*4.
12361 There is no limit on the size of Direct_IO files, they are expanded as
12362 necessary to accommodate whatever records are written to the file.
12364 @node Sequential_IO
12365 @section Sequential_IO
12368 Sequential_IO may be instantiated with either a definite (constrained)
12369 or indefinite (unconstrained) type.
12371 For the definite type case, the elements written to the file are simply
12372 the memory images of the data values with no control information of any
12373 kind. The resulting file should be read using the same type, no validity
12374 checking is performed on input.
12376 For the indefinite type case, the elements written consist of two
12377 parts. First is the size of the data item, written as the memory image
12378 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12379 the data value. The resulting file can only be read using the same
12380 (unconstrained) type. Normal assignment checks are performed on these
12381 read operations, and if these checks fail, @code{Data_Error} is
12382 raised. In particular, in the array case, the lengths must match, and in
12383 the variant record case, if the variable for a particular read operation
12384 is constrained, the discriminants must match.
12386 Note that it is not possible to use Sequential_IO to write variable
12387 length array items, and then read the data back into different length
12388 arrays. For example, the following will raise @code{Data_Error}:
12390 @smallexample @c ada
12391 package IO is new Sequential_IO (String);
12396 IO.Write (F, "hello!")
12397 IO.Reset (F, Mode=>In_File);
12404 On some Ada implementations, this will print @code{hell}, but the program is
12405 clearly incorrect, since there is only one element in the file, and that
12406 element is the string @code{hello!}.
12408 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12409 using Stream_IO, and this is the preferred mechanism. In particular, the
12410 above program fragment rewritten to use Stream_IO will work correctly.
12416 Text_IO files consist of a stream of characters containing the following
12417 special control characters:
12420 LF (line feed, 16#0A#) Line Mark
12421 FF (form feed, 16#0C#) Page Mark
12425 A canonical Text_IO file is defined as one in which the following
12426 conditions are met:
12430 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12434 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12435 end of a page and consequently can appear only immediately following a
12436 @code{LF} (line mark) character.
12439 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12440 (line mark, page mark). In the former case, the page mark is implicitly
12441 assumed to be present.
12445 A file written using Text_IO will be in canonical form provided that no
12446 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12447 or @code{Put_Line}. There will be no @code{FF} character at the end of
12448 the file unless an explicit @code{New_Page} operation was performed
12449 before closing the file.
12451 A canonical Text_IO file that is a regular file (i.e., not a device or a
12452 pipe) can be read using any of the routines in Text_IO@. The
12453 semantics in this case will be exactly as defined in the Ada Reference
12454 Manual, and all the routines in Text_IO are fully implemented.
12456 A text file that does not meet the requirements for a canonical Text_IO
12457 file has one of the following:
12461 The file contains @code{FF} characters not immediately following a
12462 @code{LF} character.
12465 The file contains @code{LF} or @code{FF} characters written by
12466 @code{Put} or @code{Put_Line}, which are not logically considered to be
12467 line marks or page marks.
12470 The file ends in a character other than @code{LF} or @code{FF},
12471 i.e.@: there is no explicit line mark or page mark at the end of the file.
12475 Text_IO can be used to read such non-standard text files but subprograms
12476 to do with line or page numbers do not have defined meanings. In
12477 particular, a @code{FF} character that does not follow a @code{LF}
12478 character may or may not be treated as a page mark from the point of
12479 view of page and line numbering. Every @code{LF} character is considered
12480 to end a line, and there is an implied @code{LF} character at the end of
12484 * Text_IO Stream Pointer Positioning::
12485 * Text_IO Reading and Writing Non-Regular Files::
12487 * Treating Text_IO Files as Streams::
12488 * Text_IO Extensions::
12489 * Text_IO Facilities for Unbounded Strings::
12492 @node Text_IO Stream Pointer Positioning
12493 @subsection Stream Pointer Positioning
12496 @code{Ada.Text_IO} has a definition of current position for a file that
12497 is being read. No internal buffering occurs in Text_IO, and usually the
12498 physical position in the stream used to implement the file corresponds
12499 to this logical position defined by Text_IO@. There are two exceptions:
12503 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12504 is positioned past the @code{LF} (line mark) that precedes the page
12505 mark. Text_IO maintains an internal flag so that subsequent read
12506 operations properly handle the logical position which is unchanged by
12507 the @code{End_Of_Page} call.
12510 After a call to @code{End_Of_File} that returns @code{True}, if the
12511 Text_IO file was positioned before the line mark at the end of file
12512 before the call, then the logical position is unchanged, but the stream
12513 is physically positioned right at the end of file (past the line mark,
12514 and past a possible page mark following the line mark. Again Text_IO
12515 maintains internal flags so that subsequent read operations properly
12516 handle the logical position.
12520 These discrepancies have no effect on the observable behavior of
12521 Text_IO, but if a single Ada stream is shared between a C program and
12522 Ada program, or shared (using @samp{shared=yes} in the form string)
12523 between two Ada files, then the difference may be observable in some
12526 @node Text_IO Reading and Writing Non-Regular Files
12527 @subsection Reading and Writing Non-Regular Files
12530 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
12531 can be used for reading and writing. Writing is not affected and the
12532 sequence of characters output is identical to the normal file case, but
12533 for reading, the behavior of Text_IO is modified to avoid undesirable
12534 look-ahead as follows:
12536 An input file that is not a regular file is considered to have no page
12537 marks. Any @code{Ascii.FF} characters (the character normally used for a
12538 page mark) appearing in the file are considered to be data
12539 characters. In particular:
12543 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12544 following a line mark. If a page mark appears, it will be treated as a
12548 This avoids the need to wait for an extra character to be typed or
12549 entered from the pipe to complete one of these operations.
12552 @code{End_Of_Page} always returns @code{False}
12555 @code{End_Of_File} will return @code{False} if there is a page mark at
12556 the end of the file.
12560 Output to non-regular files is the same as for regular files. Page marks
12561 may be written to non-regular files using @code{New_Page}, but as noted
12562 above they will not be treated as page marks on input if the output is
12563 piped to another Ada program.
12565 Another important discrepancy when reading non-regular files is that the end
12566 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
12567 pressing the @key{EOT} key,
12569 is signaled once (i.e.@: the test @code{End_Of_File}
12570 will yield @code{True}, or a read will
12571 raise @code{End_Error}), but then reading can resume
12572 to read data past that end of
12573 file indication, until another end of file indication is entered.
12575 @node Get_Immediate
12576 @subsection Get_Immediate
12577 @cindex Get_Immediate
12580 Get_Immediate returns the next character (including control characters)
12581 from the input file. In particular, Get_Immediate will return LF or FF
12582 characters used as line marks or page marks. Such operations leave the
12583 file positioned past the control character, and it is thus not treated
12584 as having its normal function. This means that page, line and column
12585 counts after this kind of Get_Immediate call are set as though the mark
12586 did not occur. In the case where a Get_Immediate leaves the file
12587 positioned between the line mark and page mark (which is not normally
12588 possible), it is undefined whether the FF character will be treated as a
12591 @node Treating Text_IO Files as Streams
12592 @subsection Treating Text_IO Files as Streams
12593 @cindex Stream files
12596 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12597 as a stream. Data written to a Text_IO file in this stream mode is
12598 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
12599 16#0C# (@code{FF}), the resulting file may have non-standard
12600 format. Similarly if read operations are used to read from a Text_IO
12601 file treated as a stream, then @code{LF} and @code{FF} characters may be
12602 skipped and the effect is similar to that described above for
12603 @code{Get_Immediate}.
12605 @node Text_IO Extensions
12606 @subsection Text_IO Extensions
12607 @cindex Text_IO extensions
12610 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12611 to the standard @code{Text_IO} package:
12614 @item function File_Exists (Name : String) return Boolean;
12615 Determines if a file of the given name exists.
12617 @item function Get_Line return String;
12618 Reads a string from the standard input file. The value returned is exactly
12619 the length of the line that was read.
12621 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12622 Similar, except that the parameter File specifies the file from which
12623 the string is to be read.
12627 @node Text_IO Facilities for Unbounded Strings
12628 @subsection Text_IO Facilities for Unbounded Strings
12629 @cindex Text_IO for unbounded strings
12630 @cindex Unbounded_String, Text_IO operations
12633 The package @code{Ada.Strings.Unbounded.Text_IO}
12634 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12635 subprograms useful for Text_IO operations on unbounded strings:
12639 @item function Get_Line (File : File_Type) return Unbounded_String;
12640 Reads a line from the specified file
12641 and returns the result as an unbounded string.
12643 @item procedure Put (File : File_Type; U : Unbounded_String);
12644 Writes the value of the given unbounded string to the specified file
12645 Similar to the effect of
12646 @code{Put (To_String (U))} except that an extra copy is avoided.
12648 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12649 Writes the value of the given unbounded string to the specified file,
12650 followed by a @code{New_Line}.
12651 Similar to the effect of @code{Put_Line (To_String (U))} except
12652 that an extra copy is avoided.
12656 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12657 and is optional. If the parameter is omitted, then the standard input or
12658 output file is referenced as appropriate.
12660 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12661 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12662 @code{Wide_Text_IO} functionality for unbounded wide strings.
12664 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12665 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12666 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12669 @section Wide_Text_IO
12672 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12673 both input and output files may contain special sequences that represent
12674 wide character values. The encoding scheme for a given file may be
12675 specified using a FORM parameter:
12682 as part of the FORM string (WCEM = wide character encoding method),
12683 where @var{x} is one of the following characters
12689 Upper half encoding
12701 The encoding methods match those that
12702 can be used in a source
12703 program, but there is no requirement that the encoding method used for
12704 the source program be the same as the encoding method used for files,
12705 and different files may use different encoding methods.
12707 The default encoding method for the standard files, and for opened files
12708 for which no WCEM parameter is given in the FORM string matches the
12709 wide character encoding specified for the main program (the default
12710 being brackets encoding if no coding method was specified with -gnatW).
12714 In this encoding, a wide character is represented by a five character
12722 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12723 characters (using upper case letters) of the wide character code. For
12724 example, ESC A345 is used to represent the wide character with code
12725 16#A345#. This scheme is compatible with use of the full
12726 @code{Wide_Character} set.
12728 @item Upper Half Coding
12729 The wide character with encoding 16#abcd#, where the upper bit is on
12730 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12731 16#cd#. The second byte may never be a format control character, but is
12732 not required to be in the upper half. This method can be also used for
12733 shift-JIS or EUC where the internal coding matches the external coding.
12735 @item Shift JIS Coding
12736 A wide character is represented by a two character sequence 16#ab# and
12737 16#cd#, with the restrictions described for upper half encoding as
12738 described above. The internal character code is the corresponding JIS
12739 character according to the standard algorithm for Shift-JIS
12740 conversion. Only characters defined in the JIS code set table can be
12741 used with this encoding method.
12744 A wide character is represented by a two character sequence 16#ab# and
12745 16#cd#, with both characters being in the upper half. The internal
12746 character code is the corresponding JIS character according to the EUC
12747 encoding algorithm. Only characters defined in the JIS code set table
12748 can be used with this encoding method.
12751 A wide character is represented using
12752 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12753 10646-1/Am.2. Depending on the character value, the representation
12754 is a one, two, or three byte sequence:
12757 16#0000#-16#007f#: 2#0xxxxxxx#
12758 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12759 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12763 where the @var{xxx} bits correspond to the left-padded bits of the
12764 16-bit character value. Note that all lower half ASCII characters
12765 are represented as ASCII bytes and all upper half characters and
12766 other wide characters are represented as sequences of upper-half
12767 (The full UTF-8 scheme allows for encoding 31-bit characters as
12768 6-byte sequences, but in this implementation, all UTF-8 sequences
12769 of four or more bytes length will raise a Constraint_Error, as
12770 will all invalid UTF-8 sequences.)
12772 @item Brackets Coding
12773 In this encoding, a wide character is represented by the following eight
12774 character sequence:
12781 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12782 characters (using uppercase letters) of the wide character code. For
12783 example, @code{["A345"]} is used to represent the wide character with code
12785 This scheme is compatible with use of the full Wide_Character set.
12786 On input, brackets coding can also be used for upper half characters,
12787 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12788 is only used for wide characters with a code greater than @code{16#FF#}.
12790 Note that brackets coding is not normally used in the context of
12791 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12792 a portable way of encoding source files. In the context of Wide_Text_IO
12793 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12794 any instance of the left bracket character other than to encode wide
12795 character values using the brackets encoding method. In practice it is
12796 expected that some standard wide character encoding method such
12797 as UTF-8 will be used for text input output.
12799 If brackets notation is used, then any occurrence of a left bracket
12800 in the input file which is not the start of a valid wide character
12801 sequence will cause Constraint_Error to be raised. It is possible to
12802 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12803 input will interpret this as a left bracket.
12805 However, when a left bracket is output, it will be output as a left bracket
12806 and not as ["5B"]. We make this decision because for normal use of
12807 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12808 brackets. For example, if we write:
12811 Put_Line ("Start of output [first run]");
12815 we really do not want to have the left bracket in this message clobbered so
12816 that the output reads:
12819 Start of output ["5B"]first run]
12823 In practice brackets encoding is reasonably useful for normal Put_Line use
12824 since we won't get confused between left brackets and wide character
12825 sequences in the output. But for input, or when files are written out
12826 and read back in, it really makes better sense to use one of the standard
12827 encoding methods such as UTF-8.
12832 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12833 not all wide character
12834 values can be represented. An attempt to output a character that cannot
12835 be represented using the encoding scheme for the file causes
12836 Constraint_Error to be raised. An invalid wide character sequence on
12837 input also causes Constraint_Error to be raised.
12840 * Wide_Text_IO Stream Pointer Positioning::
12841 * Wide_Text_IO Reading and Writing Non-Regular Files::
12844 @node Wide_Text_IO Stream Pointer Positioning
12845 @subsection Stream Pointer Positioning
12848 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12849 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12852 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12853 normal lower ASCII set (i.e.@: a character in the range:
12855 @smallexample @c ada
12856 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12860 then although the logical position of the file pointer is unchanged by
12861 the @code{Look_Ahead} call, the stream is physically positioned past the
12862 wide character sequence. Again this is to avoid the need for buffering
12863 or backup, and all @code{Wide_Text_IO} routines check the internal
12864 indication that this situation has occurred so that this is not visible
12865 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
12866 can be observed if the wide text file shares a stream with another file.
12868 @node Wide_Text_IO Reading and Writing Non-Regular Files
12869 @subsection Reading and Writing Non-Regular Files
12872 As in the case of Text_IO, when a non-regular file is read, it is
12873 assumed that the file contains no page marks (any form characters are
12874 treated as data characters), and @code{End_Of_Page} always returns
12875 @code{False}. Similarly, the end of file indication is not sticky, so
12876 it is possible to read beyond an end of file.
12878 @node Wide_Wide_Text_IO
12879 @section Wide_Wide_Text_IO
12882 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12883 both input and output files may contain special sequences that represent
12884 wide wide character values. The encoding scheme for a given file may be
12885 specified using a FORM parameter:
12892 as part of the FORM string (WCEM = wide character encoding method),
12893 where @var{x} is one of the following characters
12899 Upper half encoding
12911 The encoding methods match those that
12912 can be used in a source
12913 program, but there is no requirement that the encoding method used for
12914 the source program be the same as the encoding method used for files,
12915 and different files may use different encoding methods.
12917 The default encoding method for the standard files, and for opened files
12918 for which no WCEM parameter is given in the FORM string matches the
12919 wide character encoding specified for the main program (the default
12920 being brackets encoding if no coding method was specified with -gnatW).
12925 A wide character is represented using
12926 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12927 10646-1/Am.2. Depending on the character value, the representation
12928 is a one, two, three, or four byte sequence:
12931 16#000000#-16#00007f#: 2#0xxxxxxx#
12932 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12933 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12934 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12938 where the @var{xxx} bits correspond to the left-padded bits of the
12939 21-bit character value. Note that all lower half ASCII characters
12940 are represented as ASCII bytes and all upper half characters and
12941 other wide characters are represented as sequences of upper-half
12944 @item Brackets Coding
12945 In this encoding, a wide wide character is represented by the following eight
12946 character sequence if is in wide character range
12952 and by the following ten character sequence if not
12955 [ " a b c d e f " ]
12959 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12960 are the four or six hexadecimal
12961 characters (using uppercase letters) of the wide wide character code. For
12962 example, @code{["01A345"]} is used to represent the wide wide character
12963 with code @code{16#01A345#}.
12965 This scheme is compatible with use of the full Wide_Wide_Character set.
12966 On input, brackets coding can also be used for upper half characters,
12967 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12968 is only used for wide characters with a code greater than @code{16#FF#}.
12973 If is also possible to use the other Wide_Character encoding methods,
12974 such as Shift-JIS, but the other schemes cannot support the full range
12975 of wide wide characters.
12976 An attempt to output a character that cannot
12977 be represented using the encoding scheme for the file causes
12978 Constraint_Error to be raised. An invalid wide character sequence on
12979 input also causes Constraint_Error to be raised.
12982 * Wide_Wide_Text_IO Stream Pointer Positioning::
12983 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12986 @node Wide_Wide_Text_IO Stream Pointer Positioning
12987 @subsection Stream Pointer Positioning
12990 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12991 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12994 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12995 normal lower ASCII set (i.e.@: a character in the range:
12997 @smallexample @c ada
12998 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
13002 then although the logical position of the file pointer is unchanged by
13003 the @code{Look_Ahead} call, the stream is physically positioned past the
13004 wide character sequence. Again this is to avoid the need for buffering
13005 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
13006 indication that this situation has occurred so that this is not visible
13007 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
13008 can be observed if the wide text file shares a stream with another file.
13010 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
13011 @subsection Reading and Writing Non-Regular Files
13014 As in the case of Text_IO, when a non-regular file is read, it is
13015 assumed that the file contains no page marks (any form characters are
13016 treated as data characters), and @code{End_Of_Page} always returns
13017 @code{False}. Similarly, the end of file indication is not sticky, so
13018 it is possible to read beyond an end of file.
13024 A stream file is a sequence of bytes, where individual elements are
13025 written to the file as described in the Ada Reference Manual. The type
13026 @code{Stream_Element} is simply a byte. There are two ways to read or
13027 write a stream file.
13031 The operations @code{Read} and @code{Write} directly read or write a
13032 sequence of stream elements with no control information.
13035 The stream attributes applied to a stream file transfer data in the
13036 manner described for stream attributes.
13039 @node Text Translation
13040 @section Text Translation
13043 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13044 passed to Text_IO.Create and Text_IO.Open:
13045 @samp{Text_Translation=@var{Yes}} is the default, which means to
13046 translate LF to/from CR/LF on Windows systems.
13047 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13048 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13049 may be used to create Unix-style files on
13050 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13054 @section Shared Files
13057 Section A.14 of the Ada Reference Manual allows implementations to
13058 provide a wide variety of behavior if an attempt is made to access the
13059 same external file with two or more internal files.
13061 To provide a full range of functionality, while at the same time
13062 minimizing the problems of portability caused by this implementation
13063 dependence, GNAT handles file sharing as follows:
13067 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13068 to open two or more files with the same full name is considered an error
13069 and is not supported. The exception @code{Use_Error} will be
13070 raised. Note that a file that is not explicitly closed by the program
13071 remains open until the program terminates.
13074 If the form parameter @samp{shared=no} appears in the form string, the
13075 file can be opened or created with its own separate stream identifier,
13076 regardless of whether other files sharing the same external file are
13077 opened. The exact effect depends on how the C stream routines handle
13078 multiple accesses to the same external files using separate streams.
13081 If the form parameter @samp{shared=yes} appears in the form string for
13082 each of two or more files opened using the same full name, the same
13083 stream is shared between these files, and the semantics are as described
13084 in Ada Reference Manual, Section A.14.
13088 When a program that opens multiple files with the same name is ported
13089 from another Ada compiler to GNAT, the effect will be that
13090 @code{Use_Error} is raised.
13092 The documentation of the original compiler and the documentation of the
13093 program should then be examined to determine if file sharing was
13094 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13095 and @code{Create} calls as required.
13097 When a program is ported from GNAT to some other Ada compiler, no
13098 special attention is required unless the @samp{shared=@var{xxx}} form
13099 parameter is used in the program. In this case, you must examine the
13100 documentation of the new compiler to see if it supports the required
13101 file sharing semantics, and form strings modified appropriately. Of
13102 course it may be the case that the program cannot be ported if the
13103 target compiler does not support the required functionality. The best
13104 approach in writing portable code is to avoid file sharing (and hence
13105 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13108 One common use of file sharing in Ada 83 is the use of instantiations of
13109 Sequential_IO on the same file with different types, to achieve
13110 heterogeneous input-output. Although this approach will work in GNAT if
13111 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13112 for this purpose (using the stream attributes)
13114 @node Filenames encoding
13115 @section Filenames encoding
13118 An encoding form parameter can be used to specify the filename
13119 encoding @samp{encoding=@var{xxx}}.
13123 If the form parameter @samp{encoding=utf8} appears in the form string, the
13124 filename must be encoded in UTF-8.
13127 If the form parameter @samp{encoding=8bits} appears in the form
13128 string, the filename must be a standard 8bits string.
13131 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13132 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13133 variable. And if not set @samp{utf8} is assumed.
13137 The current system Windows ANSI code page.
13142 This encoding form parameter is only supported on the Windows
13143 platform. On the other Operating Systems the run-time is supporting
13147 @section Open Modes
13150 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13151 using the mode shown in the following table:
13154 @center @code{Open} and @code{Create} Call Modes
13156 @b{OPEN } @b{CREATE}
13157 Append_File "r+" "w+"
13159 Out_File (Direct_IO) "r+" "w"
13160 Out_File (all other cases) "w" "w"
13161 Inout_File "r+" "w+"
13165 If text file translation is required, then either @samp{b} or @samp{t}
13166 is added to the mode, depending on the setting of Text. Text file
13167 translation refers to the mapping of CR/LF sequences in an external file
13168 to LF characters internally. This mapping only occurs in DOS and
13169 DOS-like systems, and is not relevant to other systems.
13171 A special case occurs with Stream_IO@. As shown in the above table, the
13172 file is initially opened in @samp{r} or @samp{w} mode for the
13173 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
13174 subsequently requires switching from reading to writing or vice-versa,
13175 then the file is reopened in @samp{r+} mode to permit the required operation.
13177 @node Operations on C Streams
13178 @section Operations on C Streams
13179 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13180 access to the C library functions for operations on C streams:
13182 @smallexample @c adanocomment
13183 package Interfaces.C_Streams is
13184 -- Note: the reason we do not use the types that are in
13185 -- Interfaces.C is that we want to avoid dragging in the
13186 -- code in this unit if possible.
13187 subtype chars is System.Address;
13188 -- Pointer to null-terminated array of characters
13189 subtype FILEs is System.Address;
13190 -- Corresponds to the C type FILE*
13191 subtype voids is System.Address;
13192 -- Corresponds to the C type void*
13193 subtype int is Integer;
13194 subtype long is Long_Integer;
13195 -- Note: the above types are subtypes deliberately, and it
13196 -- is part of this spec that the above correspondences are
13197 -- guaranteed. This means that it is legitimate to, for
13198 -- example, use Integer instead of int. We provide these
13199 -- synonyms for clarity, but in some cases it may be
13200 -- convenient to use the underlying types (for example to
13201 -- avoid an unnecessary dependency of a spec on the spec
13203 type size_t is mod 2 ** Standard'Address_Size;
13204 NULL_Stream : constant FILEs;
13205 -- Value returned (NULL in C) to indicate an
13206 -- fdopen/fopen/tmpfile error
13207 ----------------------------------
13208 -- Constants Defined in stdio.h --
13209 ----------------------------------
13210 EOF : constant int;
13211 -- Used by a number of routines to indicate error or
13213 IOFBF : constant int;
13214 IOLBF : constant int;
13215 IONBF : constant int;
13216 -- Used to indicate buffering mode for setvbuf call
13217 SEEK_CUR : constant int;
13218 SEEK_END : constant int;
13219 SEEK_SET : constant int;
13220 -- Used to indicate origin for fseek call
13221 function stdin return FILEs;
13222 function stdout return FILEs;
13223 function stderr return FILEs;
13224 -- Streams associated with standard files
13225 --------------------------
13226 -- Standard C functions --
13227 --------------------------
13228 -- The functions selected below are ones that are
13229 -- available in DOS, OS/2, UNIX and Xenix (but not
13230 -- necessarily in ANSI C). These are very thin interfaces
13231 -- which copy exactly the C headers. For more
13232 -- documentation on these functions, see the Microsoft C
13233 -- "Run-Time Library Reference" (Microsoft Press, 1990,
13234 -- ISBN 1-55615-225-6), which includes useful information
13235 -- on system compatibility.
13236 procedure clearerr (stream : FILEs);
13237 function fclose (stream : FILEs) return int;
13238 function fdopen (handle : int; mode : chars) return FILEs;
13239 function feof (stream : FILEs) return int;
13240 function ferror (stream : FILEs) return int;
13241 function fflush (stream : FILEs) return int;
13242 function fgetc (stream : FILEs) return int;
13243 function fgets (strng : chars; n : int; stream : FILEs)
13245 function fileno (stream : FILEs) return int;
13246 function fopen (filename : chars; Mode : chars)
13248 -- Note: to maintain target independence, use
13249 -- text_translation_required, a boolean variable defined in
13250 -- a-sysdep.c to deal with the target dependent text
13251 -- translation requirement. If this variable is set,
13252 -- then b/t should be appended to the standard mode
13253 -- argument to set the text translation mode off or on
13255 function fputc (C : int; stream : FILEs) return int;
13256 function fputs (Strng : chars; Stream : FILEs) return int;
13273 function ftell (stream : FILEs) return long;
13280 function isatty (handle : int) return int;
13281 procedure mktemp (template : chars);
13282 -- The return value (which is just a pointer to template)
13284 procedure rewind (stream : FILEs);
13285 function rmtmp return int;
13293 function tmpfile return FILEs;
13294 function ungetc (c : int; stream : FILEs) return int;
13295 function unlink (filename : chars) return int;
13296 ---------------------
13297 -- Extra functions --
13298 ---------------------
13299 -- These functions supply slightly thicker bindings than
13300 -- those above. They are derived from functions in the
13301 -- C Run-Time Library, but may do a bit more work than
13302 -- just directly calling one of the Library functions.
13303 function is_regular_file (handle : int) return int;
13304 -- Tests if given handle is for a regular file (result 1)
13305 -- or for a non-regular file (pipe or device, result 0).
13306 ---------------------------------
13307 -- Control of Text/Binary Mode --
13308 ---------------------------------
13309 -- If text_translation_required is true, then the following
13310 -- functions may be used to dynamically switch a file from
13311 -- binary to text mode or vice versa. These functions have
13312 -- no effect if text_translation_required is false (i.e.@: in
13313 -- normal UNIX mode). Use fileno to get a stream handle.
13314 procedure set_binary_mode (handle : int);
13315 procedure set_text_mode (handle : int);
13316 ----------------------------
13317 -- Full Path Name support --
13318 ----------------------------
13319 procedure full_name (nam : chars; buffer : chars);
13320 -- Given a NUL terminated string representing a file
13321 -- name, returns in buffer a NUL terminated string
13322 -- representing the full path name for the file name.
13323 -- On systems where it is relevant the drive is also
13324 -- part of the full path name. It is the responsibility
13325 -- of the caller to pass an actual parameter for buffer
13326 -- that is big enough for any full path name. Use
13327 -- max_path_len given below as the size of buffer.
13328 max_path_len : integer;
13329 -- Maximum length of an allowable full path name on the
13330 -- system, including a terminating NUL character.
13331 end Interfaces.C_Streams;
13334 @node Interfacing to C Streams
13335 @section Interfacing to C Streams
13338 The packages in this section permit interfacing Ada files to C Stream
13341 @smallexample @c ada
13342 with Interfaces.C_Streams;
13343 package Ada.Sequential_IO.C_Streams is
13344 function C_Stream (F : File_Type)
13345 return Interfaces.C_Streams.FILEs;
13347 (File : in out File_Type;
13348 Mode : in File_Mode;
13349 C_Stream : in Interfaces.C_Streams.FILEs;
13350 Form : in String := "");
13351 end Ada.Sequential_IO.C_Streams;
13353 with Interfaces.C_Streams;
13354 package Ada.Direct_IO.C_Streams is
13355 function C_Stream (F : File_Type)
13356 return Interfaces.C_Streams.FILEs;
13358 (File : in out File_Type;
13359 Mode : in File_Mode;
13360 C_Stream : in Interfaces.C_Streams.FILEs;
13361 Form : in String := "");
13362 end Ada.Direct_IO.C_Streams;
13364 with Interfaces.C_Streams;
13365 package Ada.Text_IO.C_Streams is
13366 function C_Stream (F : File_Type)
13367 return Interfaces.C_Streams.FILEs;
13369 (File : in out File_Type;
13370 Mode : in File_Mode;
13371 C_Stream : in Interfaces.C_Streams.FILEs;
13372 Form : in String := "");
13373 end Ada.Text_IO.C_Streams;
13375 with Interfaces.C_Streams;
13376 package Ada.Wide_Text_IO.C_Streams is
13377 function C_Stream (F : File_Type)
13378 return Interfaces.C_Streams.FILEs;
13380 (File : in out File_Type;
13381 Mode : in File_Mode;
13382 C_Stream : in Interfaces.C_Streams.FILEs;
13383 Form : in String := "");
13384 end Ada.Wide_Text_IO.C_Streams;
13386 with Interfaces.C_Streams;
13387 package Ada.Wide_Wide_Text_IO.C_Streams is
13388 function C_Stream (F : File_Type)
13389 return Interfaces.C_Streams.FILEs;
13391 (File : in out File_Type;
13392 Mode : in File_Mode;
13393 C_Stream : in Interfaces.C_Streams.FILEs;
13394 Form : in String := "");
13395 end Ada.Wide_Wide_Text_IO.C_Streams;
13397 with Interfaces.C_Streams;
13398 package Ada.Stream_IO.C_Streams is
13399 function C_Stream (F : File_Type)
13400 return Interfaces.C_Streams.FILEs;
13402 (File : in out File_Type;
13403 Mode : in File_Mode;
13404 C_Stream : in Interfaces.C_Streams.FILEs;
13405 Form : in String := "");
13406 end Ada.Stream_IO.C_Streams;
13410 In each of these six packages, the @code{C_Stream} function obtains the
13411 @code{FILE} pointer from a currently opened Ada file. It is then
13412 possible to use the @code{Interfaces.C_Streams} package to operate on
13413 this stream, or the stream can be passed to a C program which can
13414 operate on it directly. Of course the program is responsible for
13415 ensuring that only appropriate sequences of operations are executed.
13417 One particular use of relevance to an Ada program is that the
13418 @code{setvbuf} function can be used to control the buffering of the
13419 stream used by an Ada file. In the absence of such a call the standard
13420 default buffering is used.
13422 The @code{Open} procedures in these packages open a file giving an
13423 existing C Stream instead of a file name. Typically this stream is
13424 imported from a C program, allowing an Ada file to operate on an
13427 @node The GNAT Library
13428 @chapter The GNAT Library
13431 The GNAT library contains a number of general and special purpose packages.
13432 It represents functionality that the GNAT developers have found useful, and
13433 which is made available to GNAT users. The packages described here are fully
13434 supported, and upwards compatibility will be maintained in future releases,
13435 so you can use these facilities with the confidence that the same functionality
13436 will be available in future releases.
13438 The chapter here simply gives a brief summary of the facilities available.
13439 The full documentation is found in the spec file for the package. The full
13440 sources of these library packages, including both spec and body, are provided
13441 with all GNAT releases. For example, to find out the full specifications of
13442 the SPITBOL pattern matching capability, including a full tutorial and
13443 extensive examples, look in the @file{g-spipat.ads} file in the library.
13445 For each entry here, the package name (as it would appear in a @code{with}
13446 clause) is given, followed by the name of the corresponding spec file in
13447 parentheses. The packages are children in four hierarchies, @code{Ada},
13448 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13449 GNAT-specific hierarchy.
13451 Note that an application program should only use packages in one of these
13452 four hierarchies if the package is defined in the Ada Reference Manual,
13453 or is listed in this section of the GNAT Programmers Reference Manual.
13454 All other units should be considered internal implementation units and
13455 should not be directly @code{with}'ed by application code. The use of
13456 a @code{with} statement that references one of these internal implementation
13457 units makes an application potentially dependent on changes in versions
13458 of GNAT, and will generate a warning message.
13461 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13462 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13463 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13464 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13465 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13466 * Ada.Command_Line.Environment (a-colien.ads)::
13467 * Ada.Command_Line.Remove (a-colire.ads)::
13468 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13469 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13470 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13471 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13472 * Ada.Exceptions.Traceback (a-exctra.ads)::
13473 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13474 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13475 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13476 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13477 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13478 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13479 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13480 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13481 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13482 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13483 * GNAT.Altivec (g-altive.ads)::
13484 * GNAT.Altivec.Conversions (g-altcon.ads)::
13485 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13486 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13487 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13488 * GNAT.Array_Split (g-arrspl.ads)::
13489 * GNAT.AWK (g-awk.ads)::
13490 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13491 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13492 * GNAT.Bubble_Sort (g-bubsor.ads)::
13493 * GNAT.Bubble_Sort_A (g-busora.ads)::
13494 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13495 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13496 * GNAT.Byte_Swapping (g-bytswa.ads)::
13497 * GNAT.Calendar (g-calend.ads)::
13498 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13499 * GNAT.Case_Util (g-casuti.ads)::
13500 * GNAT.CGI (g-cgi.ads)::
13501 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13502 * GNAT.CGI.Debug (g-cgideb.ads)::
13503 * GNAT.Command_Line (g-comlin.ads)::
13504 * GNAT.Compiler_Version (g-comver.ads)::
13505 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13506 * GNAT.CRC32 (g-crc32.ads)::
13507 * GNAT.Current_Exception (g-curexc.ads)::
13508 * GNAT.Debug_Pools (g-debpoo.ads)::
13509 * GNAT.Debug_Utilities (g-debuti.ads)::
13510 * GNAT.Decode_String (g-decstr.ads)::
13511 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13512 * GNAT.Directory_Operations (g-dirope.ads)::
13513 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13514 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13515 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13516 * GNAT.Encode_String (g-encstr.ads)::
13517 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13518 * GNAT.Exception_Actions (g-excact.ads)::
13519 * GNAT.Exception_Traces (g-exctra.ads)::
13520 * GNAT.Exceptions (g-except.ads)::
13521 * GNAT.Expect (g-expect.ads)::
13522 * GNAT.Float_Control (g-flocon.ads)::
13523 * GNAT.Heap_Sort (g-heasor.ads)::
13524 * GNAT.Heap_Sort_A (g-hesora.ads)::
13525 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13526 * GNAT.HTable (g-htable.ads)::
13527 * GNAT.IO (g-io.ads)::
13528 * GNAT.IO_Aux (g-io_aux.ads)::
13529 * GNAT.Lock_Files (g-locfil.ads)::
13530 * GNAT.MD5 (g-md5.ads)::
13531 * GNAT.Memory_Dump (g-memdum.ads)::
13532 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13533 * GNAT.OS_Lib (g-os_lib.ads)::
13534 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13535 * GNAT.Random_Numbers (g-rannum.ads)::
13536 * GNAT.Regexp (g-regexp.ads)::
13537 * GNAT.Registry (g-regist.ads)::
13538 * GNAT.Regpat (g-regpat.ads)::
13539 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13540 * GNAT.Semaphores (g-semaph.ads)::
13541 * GNAT.Serial_Communications (g-sercom.ads)::
13542 * GNAT.SHA1 (g-sha1.ads)::
13543 * GNAT.Signals (g-signal.ads)::
13544 * GNAT.Sockets (g-socket.ads)::
13545 * GNAT.Source_Info (g-souinf.ads)::
13546 * GNAT.Spelling_Checker (g-speche.ads)::
13547 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13548 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13549 * GNAT.Spitbol (g-spitbo.ads)::
13550 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13551 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13552 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13553 * GNAT.Strings (g-string.ads)::
13554 * GNAT.String_Split (g-strspl.ads)::
13555 * GNAT.Table (g-table.ads)::
13556 * GNAT.Task_Lock (g-tasloc.ads)::
13557 * GNAT.Threads (g-thread.ads)::
13558 * GNAT.Time_Stamp (g-timsta.ads)::
13559 * GNAT.Traceback (g-traceb.ads)::
13560 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13561 * GNAT.UTF_32 (g-utf_32.ads)::
13562 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13563 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13564 * GNAT.Wide_String_Split (g-wistsp.ads)::
13565 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13566 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13567 * Interfaces.C.Extensions (i-cexten.ads)::
13568 * Interfaces.C.Streams (i-cstrea.ads)::
13569 * Interfaces.CPP (i-cpp.ads)::
13570 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13571 * Interfaces.VxWorks (i-vxwork.ads)::
13572 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13573 * System.Address_Image (s-addima.ads)::
13574 * System.Assertions (s-assert.ads)::
13575 * System.Memory (s-memory.ads)::
13576 * System.Partition_Interface (s-parint.ads)::
13577 * System.Pool_Global (s-pooglo.ads)::
13578 * System.Pool_Local (s-pooloc.ads)::
13579 * System.Restrictions (s-restri.ads)::
13580 * System.Rident (s-rident.ads)::
13581 * System.Task_Info (s-tasinf.ads)::
13582 * System.Wch_Cnv (s-wchcnv.ads)::
13583 * System.Wch_Con (s-wchcon.ads)::
13586 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13587 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13588 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13589 @cindex Latin_9 constants for Character
13592 This child of @code{Ada.Characters}
13593 provides a set of definitions corresponding to those in the
13594 RM-defined package @code{Ada.Characters.Latin_1} but with the
13595 few modifications required for @code{Latin-9}
13596 The provision of such a package
13597 is specifically authorized by the Ada Reference Manual
13600 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13601 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13602 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13603 @cindex Latin_1 constants for Wide_Character
13606 This child of @code{Ada.Characters}
13607 provides a set of definitions corresponding to those in the
13608 RM-defined package @code{Ada.Characters.Latin_1} but with the
13609 types of the constants being @code{Wide_Character}
13610 instead of @code{Character}. The provision of such a package
13611 is specifically authorized by the Ada Reference Manual
13614 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13615 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13616 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13617 @cindex Latin_9 constants for Wide_Character
13620 This child of @code{Ada.Characters}
13621 provides a set of definitions corresponding to those in the
13622 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13623 types of the constants being @code{Wide_Character}
13624 instead of @code{Character}. The provision of such a package
13625 is specifically authorized by the Ada Reference Manual
13628 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13629 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13630 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13631 @cindex Latin_1 constants for Wide_Wide_Character
13634 This child of @code{Ada.Characters}
13635 provides a set of definitions corresponding to those in the
13636 RM-defined package @code{Ada.Characters.Latin_1} but with the
13637 types of the constants being @code{Wide_Wide_Character}
13638 instead of @code{Character}. The provision of such a package
13639 is specifically authorized by the Ada Reference Manual
13642 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13643 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13644 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13645 @cindex Latin_9 constants for Wide_Wide_Character
13648 This child of @code{Ada.Characters}
13649 provides a set of definitions corresponding to those in the
13650 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13651 types of the constants being @code{Wide_Wide_Character}
13652 instead of @code{Character}. The provision of such a package
13653 is specifically authorized by the Ada Reference Manual
13656 @node Ada.Command_Line.Environment (a-colien.ads)
13657 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13658 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13659 @cindex Environment entries
13662 This child of @code{Ada.Command_Line}
13663 provides a mechanism for obtaining environment values on systems
13664 where this concept makes sense.
13666 @node Ada.Command_Line.Remove (a-colire.ads)
13667 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13668 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13669 @cindex Removing command line arguments
13670 @cindex Command line, argument removal
13673 This child of @code{Ada.Command_Line}
13674 provides a mechanism for logically removing
13675 arguments from the argument list. Once removed, an argument is not visible
13676 to further calls on the subprograms in @code{Ada.Command_Line} will not
13677 see the removed argument.
13679 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13680 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13681 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13682 @cindex Response file for command line
13683 @cindex Command line, response file
13684 @cindex Command line, handling long command lines
13687 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13688 getting command line arguments from a text file, called a "response file".
13689 Using a response file allow passing a set of arguments to an executable longer
13690 than the maximum allowed by the system on the command line.
13692 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13693 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13694 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13695 @cindex C Streams, Interfacing with Direct_IO
13698 This package provides subprograms that allow interfacing between
13699 C streams and @code{Direct_IO}. The stream identifier can be
13700 extracted from a file opened on the Ada side, and an Ada file
13701 can be constructed from a stream opened on the C side.
13703 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13704 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13705 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13706 @cindex Null_Occurrence, testing for
13709 This child subprogram provides a way of testing for the null
13710 exception occurrence (@code{Null_Occurrence}) without raising
13713 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13714 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13715 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13716 @cindex Null_Occurrence, testing for
13719 This child subprogram is used for handling otherwise unhandled
13720 exceptions (hence the name last chance), and perform clean ups before
13721 terminating the program. Note that this subprogram never returns.
13723 @node Ada.Exceptions.Traceback (a-exctra.ads)
13724 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13725 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13726 @cindex Traceback for Exception Occurrence
13729 This child package provides the subprogram (@code{Tracebacks}) to
13730 give a traceback array of addresses based on an exception
13733 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13734 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13735 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13736 @cindex C Streams, Interfacing with Sequential_IO
13739 This package provides subprograms that allow interfacing between
13740 C streams and @code{Sequential_IO}. The stream identifier can be
13741 extracted from a file opened on the Ada side, and an Ada file
13742 can be constructed from a stream opened on the C side.
13744 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13745 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13746 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13747 @cindex C Streams, Interfacing with Stream_IO
13750 This package provides subprograms that allow interfacing between
13751 C streams and @code{Stream_IO}. The stream identifier can be
13752 extracted from a file opened on the Ada side, and an Ada file
13753 can be constructed from a stream opened on the C side.
13755 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13756 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13757 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13758 @cindex @code{Unbounded_String}, IO support
13759 @cindex @code{Text_IO}, extensions for unbounded strings
13762 This package provides subprograms for Text_IO for unbounded
13763 strings, avoiding the necessity for an intermediate operation
13764 with ordinary strings.
13766 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13767 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13768 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13769 @cindex @code{Unbounded_Wide_String}, IO support
13770 @cindex @code{Text_IO}, extensions for unbounded wide strings
13773 This package provides subprograms for Text_IO for unbounded
13774 wide strings, avoiding the necessity for an intermediate operation
13775 with ordinary wide strings.
13777 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13778 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13779 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13780 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13781 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13784 This package provides subprograms for Text_IO for unbounded
13785 wide wide strings, avoiding the necessity for an intermediate operation
13786 with ordinary wide wide strings.
13788 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13789 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13790 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13791 @cindex C Streams, Interfacing with @code{Text_IO}
13794 This package provides subprograms that allow interfacing between
13795 C streams and @code{Text_IO}. The stream identifier can be
13796 extracted from a file opened on the Ada side, and an Ada file
13797 can be constructed from a stream opened on the C side.
13799 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
13800 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13801 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13802 @cindex Unicode categorization, Wide_Character
13805 This package provides subprograms that allow categorization of
13806 Wide_Character values according to Unicode categories.
13808 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13809 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13810 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13811 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13814 This package provides subprograms that allow interfacing between
13815 C streams and @code{Wide_Text_IO}. The stream identifier can be
13816 extracted from a file opened on the Ada side, and an Ada file
13817 can be constructed from a stream opened on the C side.
13819 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13820 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13821 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13822 @cindex Unicode categorization, Wide_Wide_Character
13825 This package provides subprograms that allow categorization of
13826 Wide_Wide_Character values according to Unicode categories.
13828 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13829 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13830 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13831 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13834 This package provides subprograms that allow interfacing between
13835 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
13836 extracted from a file opened on the Ada side, and an Ada file
13837 can be constructed from a stream opened on the C side.
13839 @node GNAT.Altivec (g-altive.ads)
13840 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13841 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13845 This is the root package of the GNAT AltiVec binding. It provides
13846 definitions of constants and types common to all the versions of the
13849 @node GNAT.Altivec.Conversions (g-altcon.ads)
13850 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13851 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13855 This package provides the Vector/View conversion routines.
13857 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13858 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13859 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13863 This package exposes the Ada interface to the AltiVec operations on
13864 vector objects. A soft emulation is included by default in the GNAT
13865 library. The hard binding is provided as a separate package. This unit
13866 is common to both bindings.
13868 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13869 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13870 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13874 This package exposes the various vector types part of the Ada binding
13875 to AltiVec facilities.
13877 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13878 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13879 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13883 This package provides public 'View' data types from/to which private
13884 vector representations can be converted via
13885 GNAT.Altivec.Conversions. This allows convenient access to individual
13886 vector elements and provides a simple way to initialize vector
13889 @node GNAT.Array_Split (g-arrspl.ads)
13890 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13891 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13892 @cindex Array splitter
13895 Useful array-manipulation routines: given a set of separators, split
13896 an array wherever the separators appear, and provide direct access
13897 to the resulting slices.
13899 @node GNAT.AWK (g-awk.ads)
13900 @section @code{GNAT.AWK} (@file{g-awk.ads})
13901 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13906 Provides AWK-like parsing functions, with an easy interface for parsing one
13907 or more files containing formatted data. The file is viewed as a database
13908 where each record is a line and a field is a data element in this line.
13910 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13911 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13912 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13914 @cindex Bounded Buffers
13917 Provides a concurrent generic bounded buffer abstraction. Instances are
13918 useful directly or as parts of the implementations of other abstractions,
13921 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13922 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13923 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13928 Provides a thread-safe asynchronous intertask mailbox communication facility.
13930 @node GNAT.Bubble_Sort (g-bubsor.ads)
13931 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13932 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13934 @cindex Bubble sort
13937 Provides a general implementation of bubble sort usable for sorting arbitrary
13938 data items. Exchange and comparison procedures are provided by passing
13939 access-to-procedure values.
13941 @node GNAT.Bubble_Sort_A (g-busora.ads)
13942 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13943 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13945 @cindex Bubble sort
13948 Provides a general implementation of bubble sort usable for sorting arbitrary
13949 data items. Move and comparison procedures are provided by passing
13950 access-to-procedure values. This is an older version, retained for
13951 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13953 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13954 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13955 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13957 @cindex Bubble sort
13960 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13961 are provided as generic parameters, this improves efficiency, especially
13962 if the procedures can be inlined, at the expense of duplicating code for
13963 multiple instantiations.
13965 @node GNAT.Byte_Order_Mark (g-byorma.ads)
13966 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13967 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13968 @cindex UTF-8 representation
13969 @cindex Wide characte representations
13972 Provides a routine which given a string, reads the start of the string to
13973 see whether it is one of the standard byte order marks (BOM's) which signal
13974 the encoding of the string. The routine includes detection of special XML
13975 sequences for various UCS input formats.
13977 @node GNAT.Byte_Swapping (g-bytswa.ads)
13978 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13979 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13980 @cindex Byte swapping
13984 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13985 Machine-specific implementations are available in some cases.
13987 @node GNAT.Calendar (g-calend.ads)
13988 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13989 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13990 @cindex @code{Calendar}
13993 Extends the facilities provided by @code{Ada.Calendar} to include handling
13994 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13995 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
13996 C @code{timeval} format.
13998 @node GNAT.Calendar.Time_IO (g-catiio.ads)
13999 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14000 @cindex @code{Calendar}
14002 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14004 @node GNAT.CRC32 (g-crc32.ads)
14005 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
14006 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
14008 @cindex Cyclic Redundancy Check
14011 This package implements the CRC-32 algorithm. For a full description
14012 of this algorithm see
14013 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
14014 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
14015 Aug.@: 1988. Sarwate, D.V@.
14017 @node GNAT.Case_Util (g-casuti.ads)
14018 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
14019 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
14020 @cindex Casing utilities
14021 @cindex Character handling (@code{GNAT.Case_Util})
14024 A set of simple routines for handling upper and lower casing of strings
14025 without the overhead of the full casing tables
14026 in @code{Ada.Characters.Handling}.
14028 @node GNAT.CGI (g-cgi.ads)
14029 @section @code{GNAT.CGI} (@file{g-cgi.ads})
14030 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
14031 @cindex CGI (Common Gateway Interface)
14034 This is a package for interfacing a GNAT program with a Web server via the
14035 Common Gateway Interface (CGI)@. Basically this package parses the CGI
14036 parameters, which are a set of key/value pairs sent by the Web server. It
14037 builds a table whose index is the key and provides some services to deal
14040 @node GNAT.CGI.Cookie (g-cgicoo.ads)
14041 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14042 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14043 @cindex CGI (Common Gateway Interface) cookie support
14044 @cindex Cookie support in CGI
14047 This is a package to interface a GNAT program with a Web server via the
14048 Common Gateway Interface (CGI). It exports services to deal with Web
14049 cookies (piece of information kept in the Web client software).
14051 @node GNAT.CGI.Debug (g-cgideb.ads)
14052 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14053 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14054 @cindex CGI (Common Gateway Interface) debugging
14057 This is a package to help debugging CGI (Common Gateway Interface)
14058 programs written in Ada.
14060 @node GNAT.Command_Line (g-comlin.ads)
14061 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14062 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14063 @cindex Command line
14066 Provides a high level interface to @code{Ada.Command_Line} facilities,
14067 including the ability to scan for named switches with optional parameters
14068 and expand file names using wild card notations.
14070 @node GNAT.Compiler_Version (g-comver.ads)
14071 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14072 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14073 @cindex Compiler Version
14074 @cindex Version, of compiler
14077 Provides a routine for obtaining the version of the compiler used to
14078 compile the program. More accurately this is the version of the binder
14079 used to bind the program (this will normally be the same as the version
14080 of the compiler if a consistent tool set is used to compile all units
14083 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14084 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14085 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14089 Provides a simple interface to handle Ctrl-C keyboard events.
14091 @node GNAT.Current_Exception (g-curexc.ads)
14092 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14093 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14094 @cindex Current exception
14095 @cindex Exception retrieval
14098 Provides access to information on the current exception that has been raised
14099 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14100 specification syntax.
14101 This is particularly useful in simulating typical facilities for
14102 obtaining information about exceptions provided by Ada 83 compilers.
14104 @node GNAT.Debug_Pools (g-debpoo.ads)
14105 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14106 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14108 @cindex Debug pools
14109 @cindex Memory corruption debugging
14112 Provide a debugging storage pools that helps tracking memory corruption
14113 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14114 @value{EDITION} User's Guide}.
14116 @node GNAT.Debug_Utilities (g-debuti.ads)
14117 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14118 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14122 Provides a few useful utilities for debugging purposes, including conversion
14123 to and from string images of address values. Supports both C and Ada formats
14124 for hexadecimal literals.
14126 @node GNAT.Decode_String (g-decstr.ads)
14127 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14128 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14129 @cindex Decoding strings
14130 @cindex String decoding
14131 @cindex Wide character encoding
14136 A generic package providing routines for decoding wide character and wide wide
14137 character strings encoded as sequences of 8-bit characters using a specified
14138 encoding method. Includes validation routines, and also routines for stepping
14139 to next or previous encoded character in an encoded string.
14140 Useful in conjunction with Unicode character coding. Note there is a
14141 preinstantiation for UTF-8. See next entry.
14143 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14144 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14145 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14146 @cindex Decoding strings
14147 @cindex Decoding UTF-8 strings
14148 @cindex UTF-8 string decoding
14149 @cindex Wide character decoding
14154 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14156 @node GNAT.Directory_Operations (g-dirope.ads)
14157 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14158 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14159 @cindex Directory operations
14162 Provides a set of routines for manipulating directories, including changing
14163 the current directory, making new directories, and scanning the files in a
14166 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14167 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14168 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14169 @cindex Directory operations iteration
14172 A child unit of GNAT.Directory_Operations providing additional operations
14173 for iterating through directories.
14175 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14176 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14177 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14178 @cindex Hash tables
14181 A generic implementation of hash tables that can be used to hash arbitrary
14182 data. Provided in two forms, a simple form with built in hash functions,
14183 and a more complex form in which the hash function is supplied.
14186 This package provides a facility similar to that of @code{GNAT.HTable},
14187 except that this package declares a type that can be used to define
14188 dynamic instances of the hash table, while an instantiation of
14189 @code{GNAT.HTable} creates a single instance of the hash table.
14191 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14192 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14193 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14194 @cindex Table implementation
14195 @cindex Arrays, extendable
14198 A generic package providing a single dimension array abstraction where the
14199 length of the array can be dynamically modified.
14202 This package provides a facility similar to that of @code{GNAT.Table},
14203 except that this package declares a type that can be used to define
14204 dynamic instances of the table, while an instantiation of
14205 @code{GNAT.Table} creates a single instance of the table type.
14207 @node GNAT.Encode_String (g-encstr.ads)
14208 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14209 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14210 @cindex Encoding strings
14211 @cindex String encoding
14212 @cindex Wide character encoding
14217 A generic package providing routines for encoding wide character and wide
14218 wide character strings as sequences of 8-bit characters using a specified
14219 encoding method. Useful in conjunction with Unicode character coding.
14220 Note there is a preinstantiation for UTF-8. See next entry.
14222 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14223 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14224 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14225 @cindex Encoding strings
14226 @cindex Encoding UTF-8 strings
14227 @cindex UTF-8 string encoding
14228 @cindex Wide character encoding
14233 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14235 @node GNAT.Exception_Actions (g-excact.ads)
14236 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14237 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14238 @cindex Exception actions
14241 Provides callbacks when an exception is raised. Callbacks can be registered
14242 for specific exceptions, or when any exception is raised. This
14243 can be used for instance to force a core dump to ease debugging.
14245 @node GNAT.Exception_Traces (g-exctra.ads)
14246 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14247 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14248 @cindex Exception traces
14252 Provides an interface allowing to control automatic output upon exception
14255 @node GNAT.Exceptions (g-except.ads)
14256 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14257 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14258 @cindex Exceptions, Pure
14259 @cindex Pure packages, exceptions
14262 Normally it is not possible to raise an exception with
14263 a message from a subprogram in a pure package, since the
14264 necessary types and subprograms are in @code{Ada.Exceptions}
14265 which is not a pure unit. @code{GNAT.Exceptions} provides a
14266 facility for getting around this limitation for a few
14267 predefined exceptions, and for example allow raising
14268 @code{Constraint_Error} with a message from a pure subprogram.
14270 @node GNAT.Expect (g-expect.ads)
14271 @section @code{GNAT.Expect} (@file{g-expect.ads})
14272 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14275 Provides a set of subprograms similar to what is available
14276 with the standard Tcl Expect tool.
14277 It allows you to easily spawn and communicate with an external process.
14278 You can send commands or inputs to the process, and compare the output
14279 with some expected regular expression. Currently @code{GNAT.Expect}
14280 is implemented on all native GNAT ports except for OpenVMS@.
14281 It is not implemented for cross ports, and in particular is not
14282 implemented for VxWorks or LynxOS@.
14284 @node GNAT.Float_Control (g-flocon.ads)
14285 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14286 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14287 @cindex Floating-Point Processor
14290 Provides an interface for resetting the floating-point processor into the
14291 mode required for correct semantic operation in Ada. Some third party
14292 library calls may cause this mode to be modified, and the Reset procedure
14293 in this package can be used to reestablish the required mode.
14295 @node GNAT.Heap_Sort (g-heasor.ads)
14296 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14297 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14301 Provides a general implementation of heap sort usable for sorting arbitrary
14302 data items. Exchange and comparison procedures are provided by passing
14303 access-to-procedure values. The algorithm used is a modified heap sort
14304 that performs approximately N*log(N) comparisons in the worst case.
14306 @node GNAT.Heap_Sort_A (g-hesora.ads)
14307 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14308 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14312 Provides a general implementation of heap sort usable for sorting arbitrary
14313 data items. Move and comparison procedures are provided by passing
14314 access-to-procedure values. The algorithm used is a modified heap sort
14315 that performs approximately N*log(N) comparisons in the worst case.
14316 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14317 interface, but may be slightly more efficient.
14319 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14320 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14321 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14325 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14326 are provided as generic parameters, this improves efficiency, especially
14327 if the procedures can be inlined, at the expense of duplicating code for
14328 multiple instantiations.
14330 @node GNAT.HTable (g-htable.ads)
14331 @section @code{GNAT.HTable} (@file{g-htable.ads})
14332 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14333 @cindex Hash tables
14336 A generic implementation of hash tables that can be used to hash arbitrary
14337 data. Provides two approaches, one a simple static approach, and the other
14338 allowing arbitrary dynamic hash tables.
14340 @node GNAT.IO (g-io.ads)
14341 @section @code{GNAT.IO} (@file{g-io.ads})
14342 @cindex @code{GNAT.IO} (@file{g-io.ads})
14344 @cindex Input/Output facilities
14347 A simple preelaborable input-output package that provides a subset of
14348 simple Text_IO functions for reading characters and strings from
14349 Standard_Input, and writing characters, strings and integers to either
14350 Standard_Output or Standard_Error.
14352 @node GNAT.IO_Aux (g-io_aux.ads)
14353 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14354 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14356 @cindex Input/Output facilities
14358 Provides some auxiliary functions for use with Text_IO, including a test
14359 for whether a file exists, and functions for reading a line of text.
14361 @node GNAT.Lock_Files (g-locfil.ads)
14362 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14363 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14364 @cindex File locking
14365 @cindex Locking using files
14368 Provides a general interface for using files as locks. Can be used for
14369 providing program level synchronization.
14371 @node GNAT.MD5 (g-md5.ads)
14372 @section @code{GNAT.MD5} (@file{g-md5.ads})
14373 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14374 @cindex Message Digest MD5
14377 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14379 @node GNAT.Memory_Dump (g-memdum.ads)
14380 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14381 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14382 @cindex Dump Memory
14385 Provides a convenient routine for dumping raw memory to either the
14386 standard output or standard error files. Uses GNAT.IO for actual
14389 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14390 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14391 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14392 @cindex Exception, obtaining most recent
14395 Provides access to the most recently raised exception. Can be used for
14396 various logging purposes, including duplicating functionality of some
14397 Ada 83 implementation dependent extensions.
14399 @node GNAT.OS_Lib (g-os_lib.ads)
14400 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14401 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14402 @cindex Operating System interface
14403 @cindex Spawn capability
14406 Provides a range of target independent operating system interface functions,
14407 including time/date management, file operations, subprocess management,
14408 including a portable spawn procedure, and access to environment variables
14409 and error return codes.
14411 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14412 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14413 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14414 @cindex Hash functions
14417 Provides a generator of static minimal perfect hash functions. No
14418 collisions occur and each item can be retrieved from the table in one
14419 probe (perfect property). The hash table size corresponds to the exact
14420 size of the key set and no larger (minimal property). The key set has to
14421 be know in advance (static property). The hash functions are also order
14422 preserving. If w2 is inserted after w1 in the generator, their
14423 hashcode are in the same order. These hashing functions are very
14424 convenient for use with realtime applications.
14426 @node GNAT.Random_Numbers (g-rannum.ads)
14427 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14428 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14429 @cindex Random number generation
14432 Provides random number capabilities which extend those available in the
14433 standard Ada library and are more convenient to use.
14435 @node GNAT.Regexp (g-regexp.ads)
14436 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14437 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14438 @cindex Regular expressions
14439 @cindex Pattern matching
14442 A simple implementation of regular expressions, using a subset of regular
14443 expression syntax copied from familiar Unix style utilities. This is the
14444 simples of the three pattern matching packages provided, and is particularly
14445 suitable for ``file globbing'' applications.
14447 @node GNAT.Registry (g-regist.ads)
14448 @section @code{GNAT.Registry} (@file{g-regist.ads})
14449 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14450 @cindex Windows Registry
14453 This is a high level binding to the Windows registry. It is possible to
14454 do simple things like reading a key value, creating a new key. For full
14455 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14456 package provided with the Win32Ada binding
14458 @node GNAT.Regpat (g-regpat.ads)
14459 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14460 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14461 @cindex Regular expressions
14462 @cindex Pattern matching
14465 A complete implementation of Unix-style regular expression matching, copied
14466 from the original V7 style regular expression library written in C by
14467 Henry Spencer (and binary compatible with this C library).
14469 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14470 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14471 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14472 @cindex Secondary Stack Info
14475 Provide the capability to query the high water mark of the current task's
14478 @node GNAT.Semaphores (g-semaph.ads)
14479 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14480 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14484 Provides classic counting and binary semaphores using protected types.
14486 @node GNAT.Serial_Communications (g-sercom.ads)
14487 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14488 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14489 @cindex Serial_Communications
14492 Provides a simple interface to send and receive data over a serial
14493 port. This is only supported on GNU/Linux and Windows.
14495 @node GNAT.SHA1 (g-sha1.ads)
14496 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14497 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14498 @cindex Secure Hash Algorithm SHA-1
14501 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
14503 @node GNAT.Signals (g-signal.ads)
14504 @section @code{GNAT.Signals} (@file{g-signal.ads})
14505 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14509 Provides the ability to manipulate the blocked status of signals on supported
14512 @node GNAT.Sockets (g-socket.ads)
14513 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14514 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14518 A high level and portable interface to develop sockets based applications.
14519 This package is based on the sockets thin binding found in
14520 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14521 on all native GNAT ports except for OpenVMS@. It is not implemented
14522 for the LynxOS@ cross port.
14524 @node GNAT.Source_Info (g-souinf.ads)
14525 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14526 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14527 @cindex Source Information
14530 Provides subprograms that give access to source code information known at
14531 compile time, such as the current file name and line number.
14533 @node GNAT.Spelling_Checker (g-speche.ads)
14534 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14535 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14536 @cindex Spell checking
14539 Provides a function for determining whether one string is a plausible
14540 near misspelling of another string.
14542 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14543 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14544 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14545 @cindex Spell checking
14548 Provides a generic function that can be instantiated with a string type for
14549 determining whether one string is a plausible near misspelling of another
14552 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14553 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14554 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14555 @cindex SPITBOL pattern matching
14556 @cindex Pattern matching
14559 A complete implementation of SNOBOL4 style pattern matching. This is the
14560 most elaborate of the pattern matching packages provided. It fully duplicates
14561 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14562 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14564 @node GNAT.Spitbol (g-spitbo.ads)
14565 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14566 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14567 @cindex SPITBOL interface
14570 The top level package of the collection of SPITBOL-style functionality, this
14571 package provides basic SNOBOL4 string manipulation functions, such as
14572 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14573 useful for constructing arbitrary mappings from strings in the style of
14574 the SNOBOL4 TABLE function.
14576 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14577 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14578 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14579 @cindex Sets of strings
14580 @cindex SPITBOL Tables
14583 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14584 for type @code{Standard.Boolean}, giving an implementation of sets of
14587 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14588 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14589 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14590 @cindex Integer maps
14592 @cindex SPITBOL Tables
14595 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14596 for type @code{Standard.Integer}, giving an implementation of maps
14597 from string to integer values.
14599 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14600 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14601 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14602 @cindex String maps
14604 @cindex SPITBOL Tables
14607 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14608 a variable length string type, giving an implementation of general
14609 maps from strings to strings.
14611 @node GNAT.Strings (g-string.ads)
14612 @section @code{GNAT.Strings} (@file{g-string.ads})
14613 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14616 Common String access types and related subprograms. Basically it
14617 defines a string access and an array of string access types.
14619 @node GNAT.String_Split (g-strspl.ads)
14620 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14621 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14622 @cindex String splitter
14625 Useful string manipulation routines: given a set of separators, split
14626 a string wherever the separators appear, and provide direct access
14627 to the resulting slices. This package is instantiated from
14628 @code{GNAT.Array_Split}.
14630 @node GNAT.Table (g-table.ads)
14631 @section @code{GNAT.Table} (@file{g-table.ads})
14632 @cindex @code{GNAT.Table} (@file{g-table.ads})
14633 @cindex Table implementation
14634 @cindex Arrays, extendable
14637 A generic package providing a single dimension array abstraction where the
14638 length of the array can be dynamically modified.
14641 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14642 except that this package declares a single instance of the table type,
14643 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14644 used to define dynamic instances of the table.
14646 @node GNAT.Task_Lock (g-tasloc.ads)
14647 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14648 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14649 @cindex Task synchronization
14650 @cindex Task locking
14654 A very simple facility for locking and unlocking sections of code using a
14655 single global task lock. Appropriate for use in situations where contention
14656 between tasks is very rarely expected.
14658 @node GNAT.Time_Stamp (g-timsta.ads)
14659 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14660 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14662 @cindex Current time
14665 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14666 represents the current date and time in ISO 8601 format. This is a very simple
14667 routine with minimal code and there are no dependencies on any other unit.
14669 @node GNAT.Threads (g-thread.ads)
14670 @section @code{GNAT.Threads} (@file{g-thread.ads})
14671 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14672 @cindex Foreign threads
14673 @cindex Threads, foreign
14676 Provides facilities for dealing with foreign threads which need to be known
14677 by the GNAT run-time system. Consult the documentation of this package for
14678 further details if your program has threads that are created by a non-Ada
14679 environment which then accesses Ada code.
14681 @node GNAT.Traceback (g-traceb.ads)
14682 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14683 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14684 @cindex Trace back facilities
14687 Provides a facility for obtaining non-symbolic traceback information, useful
14688 in various debugging situations.
14690 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14691 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14692 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14693 @cindex Trace back facilities
14695 @node GNAT.UTF_32 (g-utf_32.ads)
14696 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14697 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14698 @cindex Wide character codes
14701 This is a package intended to be used in conjunction with the
14702 @code{Wide_Character} type in Ada 95 and the
14703 @code{Wide_Wide_Character} type in Ada 2005 (available
14704 in @code{GNAT} in Ada 2005 mode). This package contains
14705 Unicode categorization routines, as well as lexical
14706 categorization routines corresponding to the Ada 2005
14707 lexical rules for identifiers and strings, and also a
14708 lower case to upper case fold routine corresponding to
14709 the Ada 2005 rules for identifier equivalence.
14711 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14712 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14713 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14714 @cindex Spell checking
14717 Provides a function for determining whether one wide wide string is a plausible
14718 near misspelling of another wide wide string, where the strings are represented
14719 using the UTF_32_String type defined in System.Wch_Cnv.
14721 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14722 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14723 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14724 @cindex Spell checking
14727 Provides a function for determining whether one wide string is a plausible
14728 near misspelling of another wide string.
14730 @node GNAT.Wide_String_Split (g-wistsp.ads)
14731 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14732 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14733 @cindex Wide_String splitter
14736 Useful wide string manipulation routines: given a set of separators, split
14737 a wide string wherever the separators appear, and provide direct access
14738 to the resulting slices. This package is instantiated from
14739 @code{GNAT.Array_Split}.
14741 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14742 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14743 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14744 @cindex Spell checking
14747 Provides a function for determining whether one wide wide string is a plausible
14748 near misspelling of another wide wide string.
14750 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14751 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14752 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14753 @cindex Wide_Wide_String splitter
14756 Useful wide wide string manipulation routines: given a set of separators, split
14757 a wide wide string wherever the separators appear, and provide direct access
14758 to the resulting slices. This package is instantiated from
14759 @code{GNAT.Array_Split}.
14761 @node Interfaces.C.Extensions (i-cexten.ads)
14762 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14763 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14766 This package contains additional C-related definitions, intended
14767 for use with either manually or automatically generated bindings
14770 @node Interfaces.C.Streams (i-cstrea.ads)
14771 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14772 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14773 @cindex C streams, interfacing
14776 This package is a binding for the most commonly used operations
14779 @node Interfaces.CPP (i-cpp.ads)
14780 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
14781 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14782 @cindex C++ interfacing
14783 @cindex Interfacing, to C++
14786 This package provides facilities for use in interfacing to C++. It
14787 is primarily intended to be used in connection with automated tools
14788 for the generation of C++ interfaces.
14790 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14791 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14792 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14793 @cindex IBM Packed Format
14794 @cindex Packed Decimal
14797 This package provides a set of routines for conversions to and
14798 from a packed decimal format compatible with that used on IBM
14801 @node Interfaces.VxWorks (i-vxwork.ads)
14802 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14803 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14804 @cindex Interfacing to VxWorks
14805 @cindex VxWorks, interfacing
14808 This package provides a limited binding to the VxWorks API.
14809 In particular, it interfaces with the
14810 VxWorks hardware interrupt facilities.
14812 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14813 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14814 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14815 @cindex Interfacing to VxWorks' I/O
14816 @cindex VxWorks, I/O interfacing
14817 @cindex VxWorks, Get_Immediate
14818 @cindex Get_Immediate, VxWorks
14821 This package provides a binding to the ioctl (IO/Control)
14822 function of VxWorks, defining a set of option values and
14823 function codes. A particular use of this package is
14824 to enable the use of Get_Immediate under VxWorks.
14826 @node System.Address_Image (s-addima.ads)
14827 @section @code{System.Address_Image} (@file{s-addima.ads})
14828 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14829 @cindex Address image
14830 @cindex Image, of an address
14833 This function provides a useful debugging
14834 function that gives an (implementation dependent)
14835 string which identifies an address.
14837 @node System.Assertions (s-assert.ads)
14838 @section @code{System.Assertions} (@file{s-assert.ads})
14839 @cindex @code{System.Assertions} (@file{s-assert.ads})
14841 @cindex Assert_Failure, exception
14844 This package provides the declaration of the exception raised
14845 by an run-time assertion failure, as well as the routine that
14846 is used internally to raise this assertion.
14848 @node System.Memory (s-memory.ads)
14849 @section @code{System.Memory} (@file{s-memory.ads})
14850 @cindex @code{System.Memory} (@file{s-memory.ads})
14851 @cindex Memory allocation
14854 This package provides the interface to the low level routines used
14855 by the generated code for allocation and freeing storage for the
14856 default storage pool (analogous to the C routines malloc and free.
14857 It also provides a reallocation interface analogous to the C routine
14858 realloc. The body of this unit may be modified to provide alternative
14859 allocation mechanisms for the default pool, and in addition, direct
14860 calls to this unit may be made for low level allocation uses (for
14861 example see the body of @code{GNAT.Tables}).
14863 @node System.Partition_Interface (s-parint.ads)
14864 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14865 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14866 @cindex Partition interfacing functions
14869 This package provides facilities for partition interfacing. It
14870 is used primarily in a distribution context when using Annex E
14873 @node System.Pool_Global (s-pooglo.ads)
14874 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
14875 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
14876 @cindex Storage pool, global
14877 @cindex Global storage pool
14880 This package provides a storage pool that is equivalent to the default
14881 storage pool used for access types for which no pool is specifically
14882 declared. It uses malloc/free to allocate/free and does not attempt to
14883 do any automatic reclamation.
14885 @node System.Pool_Local (s-pooloc.ads)
14886 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
14887 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
14888 @cindex Storage pool, local
14889 @cindex Local storage pool
14892 This package provides a storage pool that is intended for use with locally
14893 defined access types. It uses malloc/free for allocate/free, and maintains
14894 a list of allocated blocks, so that all storage allocated for the pool can
14895 be freed automatically when the pool is finalized.
14897 @node System.Restrictions (s-restri.ads)
14898 @section @code{System.Restrictions} (@file{s-restri.ads})
14899 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14900 @cindex Run-time restrictions access
14903 This package provides facilities for accessing at run time
14904 the status of restrictions specified at compile time for
14905 the partition. Information is available both with regard
14906 to actual restrictions specified, and with regard to
14907 compiler determined information on which restrictions
14908 are violated by one or more packages in the partition.
14910 @node System.Rident (s-rident.ads)
14911 @section @code{System.Rident} (@file{s-rident.ads})
14912 @cindex @code{System.Rident} (@file{s-rident.ads})
14913 @cindex Restrictions definitions
14916 This package provides definitions of the restrictions
14917 identifiers supported by GNAT, and also the format of
14918 the restrictions provided in package System.Restrictions.
14919 It is not normally necessary to @code{with} this generic package
14920 since the necessary instantiation is included in
14921 package System.Restrictions.
14923 @node System.Task_Info (s-tasinf.ads)
14924 @section @code{System.Task_Info} (@file{s-tasinf.ads})
14925 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
14926 @cindex Task_Info pragma
14929 This package provides target dependent functionality that is used
14930 to support the @code{Task_Info} pragma
14932 @node System.Wch_Cnv (s-wchcnv.ads)
14933 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14934 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14935 @cindex Wide Character, Representation
14936 @cindex Wide String, Conversion
14937 @cindex Representation of wide characters
14940 This package provides routines for converting between
14941 wide and wide wide characters and a representation as a value of type
14942 @code{Standard.String}, using a specified wide character
14943 encoding method. It uses definitions in
14944 package @code{System.Wch_Con}.
14946 @node System.Wch_Con (s-wchcon.ads)
14947 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
14948 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
14951 This package provides definitions and descriptions of
14952 the various methods used for encoding wide characters
14953 in ordinary strings. These definitions are used by
14954 the package @code{System.Wch_Cnv}.
14956 @node Interfacing to Other Languages
14957 @chapter Interfacing to Other Languages
14959 The facilities in annex B of the Ada Reference Manual are fully
14960 implemented in GNAT, and in addition, a full interface to C++ is
14964 * Interfacing to C::
14965 * Interfacing to C++::
14966 * Interfacing to COBOL::
14967 * Interfacing to Fortran::
14968 * Interfacing to non-GNAT Ada code::
14971 @node Interfacing to C
14972 @section Interfacing to C
14975 Interfacing to C with GNAT can use one of two approaches:
14979 The types in the package @code{Interfaces.C} may be used.
14981 Standard Ada types may be used directly. This may be less portable to
14982 other compilers, but will work on all GNAT compilers, which guarantee
14983 correspondence between the C and Ada types.
14987 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
14988 effect, since this is the default. The following table shows the
14989 correspondence between Ada scalar types and the corresponding C types.
14994 @item Short_Integer
14996 @item Short_Short_Integer
15000 @item Long_Long_Integer
15008 @item Long_Long_Float
15009 This is the longest floating-point type supported by the hardware.
15013 Additionally, there are the following general correspondences between Ada
15017 Ada enumeration types map to C enumeration types directly if pragma
15018 @code{Convention C} is specified, which causes them to have int
15019 length. Without pragma @code{Convention C}, Ada enumeration types map to
15020 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
15021 @code{int}, respectively) depending on the number of values passed.
15022 This is the only case in which pragma @code{Convention C} affects the
15023 representation of an Ada type.
15026 Ada access types map to C pointers, except for the case of pointers to
15027 unconstrained types in Ada, which have no direct C equivalent.
15030 Ada arrays map directly to C arrays.
15033 Ada records map directly to C structures.
15036 Packed Ada records map to C structures where all members are bit fields
15037 of the length corresponding to the @code{@var{type}'Size} value in Ada.
15040 @node Interfacing to C++
15041 @section Interfacing to C++
15044 The interface to C++ makes use of the following pragmas, which are
15045 primarily intended to be constructed automatically using a binding generator
15046 tool, although it is possible to construct them by hand. No suitable binding
15047 generator tool is supplied with GNAT though.
15049 Using these pragmas it is possible to achieve complete
15050 inter-operability between Ada tagged types and C++ class definitions.
15051 See @ref{Implementation Defined Pragmas}, for more details.
15054 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15055 The argument denotes an entity in the current declarative region that is
15056 declared as a tagged or untagged record type. It indicates that the type
15057 corresponds to an externally declared C++ class type, and is to be laid
15058 out the same way that C++ would lay out the type.
15060 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15061 for backward compatibility but its functionality is available
15062 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15064 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15065 This pragma identifies an imported function (imported in the usual way
15066 with pragma @code{Import}) as corresponding to a C++ constructor.
15069 @node Interfacing to COBOL
15070 @section Interfacing to COBOL
15073 Interfacing to COBOL is achieved as described in section B.4 of
15074 the Ada Reference Manual.
15076 @node Interfacing to Fortran
15077 @section Interfacing to Fortran
15080 Interfacing to Fortran is achieved as described in section B.5 of the
15081 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
15082 multi-dimensional array causes the array to be stored in column-major
15083 order as required for convenient interface to Fortran.
15085 @node Interfacing to non-GNAT Ada code
15086 @section Interfacing to non-GNAT Ada code
15088 It is possible to specify the convention @code{Ada} in a pragma
15089 @code{Import} or pragma @code{Export}. However this refers to
15090 the calling conventions used by GNAT, which may or may not be
15091 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15092 compiler to allow interoperation.
15094 If arguments types are kept simple, and if the foreign compiler generally
15095 follows system calling conventions, then it may be possible to integrate
15096 files compiled by other Ada compilers, provided that the elaboration
15097 issues are adequately addressed (for example by eliminating the
15098 need for any load time elaboration).
15100 In particular, GNAT running on VMS is designed to
15101 be highly compatible with the DEC Ada 83 compiler, so this is one
15102 case in which it is possible to import foreign units of this type,
15103 provided that the data items passed are restricted to simple scalar
15104 values or simple record types without variants, or simple array
15105 types with fixed bounds.
15107 @node Specialized Needs Annexes
15108 @chapter Specialized Needs Annexes
15111 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15112 required in all implementations. However, as described in this chapter,
15113 GNAT implements all of these annexes:
15116 @item Systems Programming (Annex C)
15117 The Systems Programming Annex is fully implemented.
15119 @item Real-Time Systems (Annex D)
15120 The Real-Time Systems Annex is fully implemented.
15122 @item Distributed Systems (Annex E)
15123 Stub generation is fully implemented in the GNAT compiler. In addition,
15124 a complete compatible PCS is available as part of the GLADE system,
15125 a separate product. When the two
15126 products are used in conjunction, this annex is fully implemented.
15128 @item Information Systems (Annex F)
15129 The Information Systems annex is fully implemented.
15131 @item Numerics (Annex G)
15132 The Numerics Annex is fully implemented.
15134 @item Safety and Security / High-Integrity Systems (Annex H)
15135 The Safety and Security Annex (termed the High-Integrity Systems Annex
15136 in Ada 2005) is fully implemented.
15139 @node Implementation of Specific Ada Features
15140 @chapter Implementation of Specific Ada Features
15143 This chapter describes the GNAT implementation of several Ada language
15147 * Machine Code Insertions::
15148 * GNAT Implementation of Tasking::
15149 * GNAT Implementation of Shared Passive Packages::
15150 * Code Generation for Array Aggregates::
15151 * The Size of Discriminated Records with Default Discriminants::
15152 * Strict Conformance to the Ada Reference Manual::
15155 @node Machine Code Insertions
15156 @section Machine Code Insertions
15157 @cindex Machine Code insertions
15160 Package @code{Machine_Code} provides machine code support as described
15161 in the Ada Reference Manual in two separate forms:
15164 Machine code statements, consisting of qualified expressions that
15165 fit the requirements of RM section 13.8.
15167 An intrinsic callable procedure, providing an alternative mechanism of
15168 including machine instructions in a subprogram.
15172 The two features are similar, and both are closely related to the mechanism
15173 provided by the asm instruction in the GNU C compiler. Full understanding
15174 and use of the facilities in this package requires understanding the asm
15175 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15176 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15178 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15179 semantic restrictions and effects as described below. Both are provided so
15180 that the procedure call can be used as a statement, and the function call
15181 can be used to form a code_statement.
15183 The first example given in the GCC documentation is the C @code{asm}
15186 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15190 The equivalent can be written for GNAT as:
15192 @smallexample @c ada
15193 Asm ("fsinx %1 %0",
15194 My_Float'Asm_Output ("=f", result),
15195 My_Float'Asm_Input ("f", angle));
15199 The first argument to @code{Asm} is the assembler template, and is
15200 identical to what is used in GNU C@. This string must be a static
15201 expression. The second argument is the output operand list. It is
15202 either a single @code{Asm_Output} attribute reference, or a list of such
15203 references enclosed in parentheses (technically an array aggregate of
15206 The @code{Asm_Output} attribute denotes a function that takes two
15207 parameters. The first is a string, the second is the name of a variable
15208 of the type designated by the attribute prefix. The first (string)
15209 argument is required to be a static expression and designates the
15210 constraint for the parameter (e.g.@: what kind of register is
15211 required). The second argument is the variable to be updated with the
15212 result. The possible values for constraint are the same as those used in
15213 the RTL, and are dependent on the configuration file used to build the
15214 GCC back end. If there are no output operands, then this argument may
15215 either be omitted, or explicitly given as @code{No_Output_Operands}.
15217 The second argument of @code{@var{my_float}'Asm_Output} functions as
15218 though it were an @code{out} parameter, which is a little curious, but
15219 all names have the form of expressions, so there is no syntactic
15220 irregularity, even though normally functions would not be permitted
15221 @code{out} parameters. The third argument is the list of input
15222 operands. It is either a single @code{Asm_Input} attribute reference, or
15223 a list of such references enclosed in parentheses (technically an array
15224 aggregate of such references).
15226 The @code{Asm_Input} attribute denotes a function that takes two
15227 parameters. The first is a string, the second is an expression of the
15228 type designated by the prefix. The first (string) argument is required
15229 to be a static expression, and is the constraint for the parameter,
15230 (e.g.@: what kind of register is required). The second argument is the
15231 value to be used as the input argument. The possible values for the
15232 constant are the same as those used in the RTL, and are dependent on
15233 the configuration file used to built the GCC back end.
15235 If there are no input operands, this argument may either be omitted, or
15236 explicitly given as @code{No_Input_Operands}. The fourth argument, not
15237 present in the above example, is a list of register names, called the
15238 @dfn{clobber} argument. This argument, if given, must be a static string
15239 expression, and is a space or comma separated list of names of registers
15240 that must be considered destroyed as a result of the @code{Asm} call. If
15241 this argument is the null string (the default value), then the code
15242 generator assumes that no additional registers are destroyed.
15244 The fifth argument, not present in the above example, called the
15245 @dfn{volatile} argument, is by default @code{False}. It can be set to
15246 the literal value @code{True} to indicate to the code generator that all
15247 optimizations with respect to the instruction specified should be
15248 suppressed, and that in particular, for an instruction that has outputs,
15249 the instruction will still be generated, even if none of the outputs are
15250 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15251 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15252 Generally it is strongly advisable to use Volatile for any ASM statement
15253 that is missing either input or output operands, or when two or more ASM
15254 statements appear in sequence, to avoid unwanted optimizations. A warning
15255 is generated if this advice is not followed.
15257 The @code{Asm} subprograms may be used in two ways. First the procedure
15258 forms can be used anywhere a procedure call would be valid, and
15259 correspond to what the RM calls ``intrinsic'' routines. Such calls can
15260 be used to intersperse machine instructions with other Ada statements.
15261 Second, the function forms, which return a dummy value of the limited
15262 private type @code{Asm_Insn}, can be used in code statements, and indeed
15263 this is the only context where such calls are allowed. Code statements
15264 appear as aggregates of the form:
15266 @smallexample @c ada
15267 Asm_Insn'(Asm (@dots{}));
15268 Asm_Insn'(Asm_Volatile (@dots{}));
15272 In accordance with RM rules, such code statements are allowed only
15273 within subprograms whose entire body consists of such statements. It is
15274 not permissible to intermix such statements with other Ada statements.
15276 Typically the form using intrinsic procedure calls is more convenient
15277 and more flexible. The code statement form is provided to meet the RM
15278 suggestion that such a facility should be made available. The following
15279 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15280 is used, the arguments may be given in arbitrary order, following the
15281 normal rules for use of positional and named arguments)
15285 [Template =>] static_string_EXPRESSION
15286 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
15287 [,[Inputs =>] INPUT_OPERAND_LIST ]
15288 [,[Clobber =>] static_string_EXPRESSION ]
15289 [,[Volatile =>] static_boolean_EXPRESSION] )
15291 OUTPUT_OPERAND_LIST ::=
15292 [PREFIX.]No_Output_Operands
15293 | OUTPUT_OPERAND_ATTRIBUTE
15294 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15296 OUTPUT_OPERAND_ATTRIBUTE ::=
15297 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15299 INPUT_OPERAND_LIST ::=
15300 [PREFIX.]No_Input_Operands
15301 | INPUT_OPERAND_ATTRIBUTE
15302 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15304 INPUT_OPERAND_ATTRIBUTE ::=
15305 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15309 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15310 are declared in the package @code{Machine_Code} and must be referenced
15311 according to normal visibility rules. In particular if there is no
15312 @code{use} clause for this package, then appropriate package name
15313 qualification is required.
15315 @node GNAT Implementation of Tasking
15316 @section GNAT Implementation of Tasking
15319 This chapter outlines the basic GNAT approach to tasking (in particular,
15320 a multi-layered library for portability) and discusses issues related
15321 to compliance with the Real-Time Systems Annex.
15324 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15325 * Ensuring Compliance with the Real-Time Annex::
15328 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15329 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15332 GNAT's run-time support comprises two layers:
15335 @item GNARL (GNAT Run-time Layer)
15336 @item GNULL (GNAT Low-level Library)
15340 In GNAT, Ada's tasking services rely on a platform and OS independent
15341 layer known as GNARL@. This code is responsible for implementing the
15342 correct semantics of Ada's task creation, rendezvous, protected
15345 GNARL decomposes Ada's tasking semantics into simpler lower level
15346 operations such as create a thread, set the priority of a thread,
15347 yield, create a lock, lock/unlock, etc. The spec for these low-level
15348 operations constitutes GNULLI, the GNULL Interface. This interface is
15349 directly inspired from the POSIX real-time API@.
15351 If the underlying executive or OS implements the POSIX standard
15352 faithfully, the GNULL Interface maps as is to the services offered by
15353 the underlying kernel. Otherwise, some target dependent glue code maps
15354 the services offered by the underlying kernel to the semantics expected
15357 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
15358 key point is that each Ada task is mapped on a thread in the underlying
15359 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
15361 In addition Ada task priorities map onto the underlying thread priorities.
15362 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15366 The underlying scheduler is used to schedule the Ada tasks. This
15367 makes Ada tasks as efficient as kernel threads from a scheduling
15371 Interaction with code written in C containing threads is eased
15372 since at the lowest level Ada tasks and C threads map onto the same
15373 underlying kernel concept.
15376 When an Ada task is blocked during I/O the remaining Ada tasks are
15380 On multiprocessor systems Ada tasks can execute in parallel.
15384 Some threads libraries offer a mechanism to fork a new process, with the
15385 child process duplicating the threads from the parent.
15387 support this functionality when the parent contains more than one task.
15388 @cindex Forking a new process
15390 @node Ensuring Compliance with the Real-Time Annex
15391 @subsection Ensuring Compliance with the Real-Time Annex
15392 @cindex Real-Time Systems Annex compliance
15395 Although mapping Ada tasks onto
15396 the underlying threads has significant advantages, it does create some
15397 complications when it comes to respecting the scheduling semantics
15398 specified in the real-time annex (Annex D).
15400 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15401 scheduling policy states:
15404 @emph{When the active priority of a ready task that is not running
15405 changes, or the setting of its base priority takes effect, the
15406 task is removed from the ready queue for its old active priority
15407 and is added at the tail of the ready queue for its new active
15408 priority, except in the case where the active priority is lowered
15409 due to the loss of inherited priority, in which case the task is
15410 added at the head of the ready queue for its new active priority.}
15414 While most kernels do put tasks at the end of the priority queue when
15415 a task changes its priority, (which respects the main
15416 FIFO_Within_Priorities requirement), almost none keep a thread at the
15417 beginning of its priority queue when its priority drops from the loss
15418 of inherited priority.
15420 As a result most vendors have provided incomplete Annex D implementations.
15422 The GNAT run-time, has a nice cooperative solution to this problem
15423 which ensures that accurate FIFO_Within_Priorities semantics are
15426 The principle is as follows. When an Ada task T is about to start
15427 running, it checks whether some other Ada task R with the same
15428 priority as T has been suspended due to the loss of priority
15429 inheritance. If this is the case, T yields and is placed at the end of
15430 its priority queue. When R arrives at the front of the queue it
15433 Note that this simple scheme preserves the relative order of the tasks
15434 that were ready to execute in the priority queue where R has been
15437 @node GNAT Implementation of Shared Passive Packages
15438 @section GNAT Implementation of Shared Passive Packages
15439 @cindex Shared passive packages
15442 GNAT fully implements the pragma @code{Shared_Passive} for
15443 @cindex pragma @code{Shared_Passive}
15444 the purpose of designating shared passive packages.
15445 This allows the use of passive partitions in the
15446 context described in the Ada Reference Manual; i.e., for communication
15447 between separate partitions of a distributed application using the
15448 features in Annex E.
15450 @cindex Distribution Systems Annex
15452 However, the implementation approach used by GNAT provides for more
15453 extensive usage as follows:
15456 @item Communication between separate programs
15458 This allows separate programs to access the data in passive
15459 partitions, using protected objects for synchronization where
15460 needed. The only requirement is that the two programs have a
15461 common shared file system. It is even possible for programs
15462 running on different machines with different architectures
15463 (e.g.@: different endianness) to communicate via the data in
15464 a passive partition.
15466 @item Persistence between program runs
15468 The data in a passive package can persist from one run of a
15469 program to another, so that a later program sees the final
15470 values stored by a previous run of the same program.
15475 The implementation approach used is to store the data in files. A
15476 separate stream file is created for each object in the package, and
15477 an access to an object causes the corresponding file to be read or
15480 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15481 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15482 set to the directory to be used for these files.
15483 The files in this directory
15484 have names that correspond to their fully qualified names. For
15485 example, if we have the package
15487 @smallexample @c ada
15489 pragma Shared_Passive (X);
15496 and the environment variable is set to @code{/stemp/}, then the files created
15497 will have the names:
15505 These files are created when a value is initially written to the object, and
15506 the files are retained until manually deleted. This provides the persistence
15507 semantics. If no file exists, it means that no partition has assigned a value
15508 to the variable; in this case the initial value declared in the package
15509 will be used. This model ensures that there are no issues in synchronizing
15510 the elaboration process, since elaboration of passive packages elaborates the
15511 initial values, but does not create the files.
15513 The files are written using normal @code{Stream_IO} access.
15514 If you want to be able
15515 to communicate between programs or partitions running on different
15516 architectures, then you should use the XDR versions of the stream attribute
15517 routines, since these are architecture independent.
15519 If active synchronization is required for access to the variables in the
15520 shared passive package, then as described in the Ada Reference Manual, the
15521 package may contain protected objects used for this purpose. In this case
15522 a lock file (whose name is @file{___lock} (three underscores)
15523 is created in the shared memory directory.
15524 @cindex @file{___lock} file (for shared passive packages)
15525 This is used to provide the required locking
15526 semantics for proper protected object synchronization.
15528 As of January 2003, GNAT supports shared passive packages on all platforms
15529 except for OpenVMS.
15531 @node Code Generation for Array Aggregates
15532 @section Code Generation for Array Aggregates
15535 * Static constant aggregates with static bounds::
15536 * Constant aggregates with unconstrained nominal types::
15537 * Aggregates with static bounds::
15538 * Aggregates with non-static bounds::
15539 * Aggregates in assignment statements::
15543 Aggregates have a rich syntax and allow the user to specify the values of
15544 complex data structures by means of a single construct. As a result, the
15545 code generated for aggregates can be quite complex and involve loops, case
15546 statements and multiple assignments. In the simplest cases, however, the
15547 compiler will recognize aggregates whose components and constraints are
15548 fully static, and in those cases the compiler will generate little or no
15549 executable code. The following is an outline of the code that GNAT generates
15550 for various aggregate constructs. For further details, you will find it
15551 useful to examine the output produced by the -gnatG flag to see the expanded
15552 source that is input to the code generator. You may also want to examine
15553 the assembly code generated at various levels of optimization.
15555 The code generated for aggregates depends on the context, the component values,
15556 and the type. In the context of an object declaration the code generated is
15557 generally simpler than in the case of an assignment. As a general rule, static
15558 component values and static subtypes also lead to simpler code.
15560 @node Static constant aggregates with static bounds
15561 @subsection Static constant aggregates with static bounds
15564 For the declarations:
15565 @smallexample @c ada
15566 type One_Dim is array (1..10) of integer;
15567 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15571 GNAT generates no executable code: the constant ar0 is placed in static memory.
15572 The same is true for constant aggregates with named associations:
15574 @smallexample @c ada
15575 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15576 Cr3 : constant One_Dim := (others => 7777);
15580 The same is true for multidimensional constant arrays such as:
15582 @smallexample @c ada
15583 type two_dim is array (1..3, 1..3) of integer;
15584 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15588 The same is true for arrays of one-dimensional arrays: the following are
15591 @smallexample @c ada
15592 type ar1b is array (1..3) of boolean;
15593 type ar_ar is array (1..3) of ar1b;
15594 None : constant ar1b := (others => false); -- fully static
15595 None2 : constant ar_ar := (1..3 => None); -- fully static
15599 However, for multidimensional aggregates with named associations, GNAT will
15600 generate assignments and loops, even if all associations are static. The
15601 following two declarations generate a loop for the first dimension, and
15602 individual component assignments for the second dimension:
15604 @smallexample @c ada
15605 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15606 Zero2: constant two_dim := (others => (others => 0));
15609 @node Constant aggregates with unconstrained nominal types
15610 @subsection Constant aggregates with unconstrained nominal types
15613 In such cases the aggregate itself establishes the subtype, so that
15614 associations with @code{others} cannot be used. GNAT determines the
15615 bounds for the actual subtype of the aggregate, and allocates the
15616 aggregate statically as well. No code is generated for the following:
15618 @smallexample @c ada
15619 type One_Unc is array (natural range <>) of integer;
15620 Cr_Unc : constant One_Unc := (12,24,36);
15623 @node Aggregates with static bounds
15624 @subsection Aggregates with static bounds
15627 In all previous examples the aggregate was the initial (and immutable) value
15628 of a constant. If the aggregate initializes a variable, then code is generated
15629 for it as a combination of individual assignments and loops over the target
15630 object. The declarations
15632 @smallexample @c ada
15633 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15634 Cr_Var2 : One_Dim := (others > -1);
15638 generate the equivalent of
15640 @smallexample @c ada
15646 for I in Cr_Var2'range loop
15651 @node Aggregates with non-static bounds
15652 @subsection Aggregates with non-static bounds
15655 If the bounds of the aggregate are not statically compatible with the bounds
15656 of the nominal subtype of the target, then constraint checks have to be
15657 generated on the bounds. For a multidimensional array, constraint checks may
15658 have to be applied to sub-arrays individually, if they do not have statically
15659 compatible subtypes.
15661 @node Aggregates in assignment statements
15662 @subsection Aggregates in assignment statements
15665 In general, aggregate assignment requires the construction of a temporary,
15666 and a copy from the temporary to the target of the assignment. This is because
15667 it is not always possible to convert the assignment into a series of individual
15668 component assignments. For example, consider the simple case:
15670 @smallexample @c ada
15675 This cannot be converted into:
15677 @smallexample @c ada
15683 So the aggregate has to be built first in a separate location, and then
15684 copied into the target. GNAT recognizes simple cases where this intermediate
15685 step is not required, and the assignments can be performed in place, directly
15686 into the target. The following sufficient criteria are applied:
15690 The bounds of the aggregate are static, and the associations are static.
15692 The components of the aggregate are static constants, names of
15693 simple variables that are not renamings, or expressions not involving
15694 indexed components whose operands obey these rules.
15698 If any of these conditions are violated, the aggregate will be built in
15699 a temporary (created either by the front-end or the code generator) and then
15700 that temporary will be copied onto the target.
15703 @node The Size of Discriminated Records with Default Discriminants
15704 @section The Size of Discriminated Records with Default Discriminants
15707 If a discriminated type @code{T} has discriminants with default values, it is
15708 possible to declare an object of this type without providing an explicit
15711 @smallexample @c ada
15713 type Size is range 1..100;
15715 type Rec (D : Size := 15) is record
15716 Name : String (1..D);
15724 Such an object is said to be @emph{unconstrained}.
15725 The discriminant of the object
15726 can be modified by a full assignment to the object, as long as it preserves the
15727 relation between the value of the discriminant, and the value of the components
15730 @smallexample @c ada
15732 Word := (3, "yes");
15734 Word := (5, "maybe");
15736 Word := (5, "no"); -- raises Constraint_Error
15741 In order to support this behavior efficiently, an unconstrained object is
15742 given the maximum size that any value of the type requires. In the case
15743 above, @code{Word} has storage for the discriminant and for
15744 a @code{String} of length 100.
15745 It is important to note that unconstrained objects do not require dynamic
15746 allocation. It would be an improper implementation to place on the heap those
15747 components whose size depends on discriminants. (This improper implementation
15748 was used by some Ada83 compilers, where the @code{Name} component above
15750 been stored as a pointer to a dynamic string). Following the principle that
15751 dynamic storage management should never be introduced implicitly,
15752 an Ada compiler should reserve the full size for an unconstrained declared
15753 object, and place it on the stack.
15755 This maximum size approach
15756 has been a source of surprise to some users, who expect the default
15757 values of the discriminants to determine the size reserved for an
15758 unconstrained object: ``If the default is 15, why should the object occupy
15760 The answer, of course, is that the discriminant may be later modified,
15761 and its full range of values must be taken into account. This is why the
15766 type Rec (D : Positive := 15) is record
15767 Name : String (1..D);
15775 is flagged by the compiler with a warning:
15776 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15777 because the required size includes @code{Positive'Last}
15778 bytes. As the first example indicates, the proper approach is to declare an
15779 index type of ``reasonable'' range so that unconstrained objects are not too
15782 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15783 created in the heap by means of an allocator, then it is @emph{not}
15785 it is constrained by the default values of the discriminants, and those values
15786 cannot be modified by full assignment. This is because in the presence of
15787 aliasing all views of the object (which may be manipulated by different tasks,
15788 say) must be consistent, so it is imperative that the object, once created,
15791 @node Strict Conformance to the Ada Reference Manual
15792 @section Strict Conformance to the Ada Reference Manual
15795 The dynamic semantics defined by the Ada Reference Manual impose a set of
15796 run-time checks to be generated. By default, the GNAT compiler will insert many
15797 run-time checks into the compiled code, including most of those required by the
15798 Ada Reference Manual. However, there are three checks that are not enabled
15799 in the default mode for efficiency reasons: arithmetic overflow checking for
15800 integer operations (including division by zero), checks for access before
15801 elaboration on subprogram calls, and stack overflow checking (most operating
15802 systems do not perform this check by default).
15804 Strict conformance to the Ada Reference Manual can be achieved by adding
15805 three compiler options for overflow checking for integer operations
15806 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15807 calls and generic instantiations (@option{-gnatE}), and stack overflow
15808 checking (@option{-fstack-check}).
15810 Note that the result of a floating point arithmetic operation in overflow and
15811 invalid situations, when the @code{Machine_Overflows} attribute of the result
15812 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15813 case for machines compliant with the IEEE floating-point standard, but on
15814 machines that are not fully compliant with this standard, such as Alpha, the
15815 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15816 behavior (although at the cost of a significant performance penalty), so
15817 infinite and and NaN values are properly generated.
15820 @node Project File Reference
15821 @chapter Project File Reference
15824 This chapter describes the syntax and semantics of project files.
15825 Project files specify the options to be used when building a system.
15826 Project files can specify global settings for all tools,
15827 as well as tool-specific settings.
15828 @xref{Examples of Project Files,,, gnat_ugn, @value{EDITION} User's Guide},
15829 for examples of use.
15833 * Lexical Elements::
15835 * Empty declarations::
15836 * Typed string declarations::
15840 * Project Attributes::
15841 * Attribute References::
15842 * External Values::
15843 * Case Construction::
15845 * Package Renamings::
15847 * Project Extensions::
15848 * Project File Elaboration::
15851 @node Reserved Words
15852 @section Reserved Words
15855 All Ada reserved words are reserved in project files, and cannot be used
15856 as variable names or project names. In addition, the following are
15857 also reserved in project files:
15860 @item @code{extends}
15862 @item @code{external}
15864 @item @code{project}
15868 @node Lexical Elements
15869 @section Lexical Elements
15872 Rules for identifiers are the same as in Ada. Identifiers
15873 are case-insensitive. Strings are case sensitive, except where noted.
15874 Comments have the same form as in Ada.
15884 simple_name @{. simple_name@}
15888 @section Declarations
15891 Declarations introduce new entities that denote types, variables, attributes,
15892 and packages. Some declarations can only appear immediately within a project
15893 declaration. Others can appear within a project or within a package.
15897 declarative_item ::=
15898 simple_declarative_item |
15899 typed_string_declaration |
15900 package_declaration
15902 simple_declarative_item ::=
15903 variable_declaration |
15904 typed_variable_declaration |
15905 attribute_declaration |
15906 case_construction |
15910 @node Empty declarations
15911 @section Empty declarations
15914 empty_declaration ::=
15918 An empty declaration is allowed anywhere a declaration is allowed.
15921 @node Typed string declarations
15922 @section Typed string declarations
15925 Typed strings are sequences of string literals. Typed strings are the only
15926 named types in project files. They are used in case constructions, where they
15927 provide support for conditional attribute definitions.
15931 typed_string_declaration ::=
15932 @b{type} <typed_string_>_simple_name @b{is}
15933 ( string_literal @{, string_literal@} );
15937 A typed string declaration can only appear immediately within a project
15940 All the string literals in a typed string declaration must be distinct.
15946 Variables denote values, and appear as constituents of expressions.
15949 typed_variable_declaration ::=
15950 <typed_variable_>simple_name : <typed_string_>name := string_expression ;
15952 variable_declaration ::=
15953 <variable_>simple_name := expression;
15957 The elaboration of a variable declaration introduces the variable and
15958 assigns to it the value of the expression. The name of the variable is
15959 available after the assignment symbol.
15962 A typed_variable can only be declare once.
15965 a non-typed variable can be declared multiple times.
15968 Before the completion of its first declaration, the value of variable
15969 is the null string.
15972 @section Expressions
15975 An expression is a formula that defines a computation or retrieval of a value.
15976 In a project file the value of an expression is either a string or a list
15977 of strings. A string value in an expression is either a literal, the current
15978 value of a variable, an external value, an attribute reference, or a
15979 concatenation operation.
15992 attribute_reference
15998 ( <string_>expression @{ , <string_>expression @} )
16001 @subsection Concatenation
16003 The following concatenation functions are defined:
16005 @smallexample @c ada
16006 function "&" (X : String; Y : String) return String;
16007 function "&" (X : String_List; Y : String) return String_List;
16008 function "&" (X : String_List; Y : String_List) return String_List;
16012 @section Attributes
16015 An attribute declaration defines a property of a project or package. This
16016 property can later be queried by means of an attribute reference.
16017 Attribute values are strings or string lists.
16019 Some attributes are associative arrays. These attributes are mappings whose
16020 domain is a set of strings. These attributes are declared one association
16021 at a time, by specifying a point in the domain and the corresponding image
16022 of the attribute. They may also be declared as a full associative array,
16023 getting the same associations as the corresponding attribute in an imported
16024 or extended project.
16026 Attributes that are not associative arrays are called simple attributes.
16030 attribute_declaration ::=
16031 full_associative_array_declaration |
16032 @b{for} attribute_designator @b{use} expression ;
16034 full_associative_array_declaration ::=
16035 @b{for} <associative_array_attribute_>simple_name @b{use}
16036 <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
16038 attribute_designator ::=
16039 <simple_attribute_>simple_name |
16040 <associative_array_attribute_>simple_name ( string_literal )
16044 Some attributes are project-specific, and can only appear immediately within
16045 a project declaration. Others are package-specific, and can only appear within
16046 the proper package.
16048 The expression in an attribute definition must be a string or a string_list.
16049 The string literal appearing in the attribute_designator of an associative
16050 array attribute is case-insensitive.
16052 @node Project Attributes
16053 @section Project Attributes
16056 The following attributes apply to a project. All of them are simple
16061 Expression must be a path name. The attribute defines the
16062 directory in which the object files created by the build are to be placed. If
16063 not specified, object files are placed in the project directory.
16066 Expression must be a path name. The attribute defines the
16067 directory in which the executables created by the build are to be placed.
16068 If not specified, executables are placed in the object directory.
16071 Expression must be a list of path names. The attribute
16072 defines the directories in which the source files for the project are to be
16073 found. If not specified, source files are found in the project directory.
16074 If a string in the list ends with "/**", then the directory that precedes
16075 "/**" and all of its subdirectories (recursively) are included in the list
16076 of source directories.
16078 @item Excluded_Source_Dirs
16079 Expression must be a list of strings. Each entry designates a directory that
16080 is not to be included in the list of source directories of the project.
16081 This is normally used when there are strings ending with "/**" in the value
16082 of attribute Source_Dirs.
16085 Expression must be a list of file names. The attribute
16086 defines the individual files, in the project directory, which are to be used
16087 as sources for the project. File names are path_names that contain no directory
16088 information. If the project has no sources the attribute must be declared
16089 explicitly with an empty list.
16091 @item Excluded_Source_Files (Locally_Removed_Files)
16092 Expression must be a list of strings that are legal file names.
16093 Each file name must designate a source that would normally be a source file
16094 in the source directories of the project or, if the project file is an
16095 extending project file, inherited by the current project file. It cannot
16096 designate an immediate source that is not inherited. Each of the source files
16097 in the list are not considered to be sources of the project file: they are not
16098 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
16099 Excluded_Source_Files is preferred.
16101 @item Source_List_File
16102 Expression must a single path name. The attribute
16103 defines a text file that contains a list of source file names to be used
16104 as sources for the project
16107 Expression must be a path name. The attribute defines the
16108 directory in which a library is to be built. The directory must exist, must
16109 be distinct from the project's object directory, and must be writable.
16112 Expression must be a string that is a legal file name,
16113 without extension. The attribute defines a string that is used to generate
16114 the name of the library to be built by the project.
16117 Argument must be a string value that must be one of the
16118 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
16119 string is case-insensitive. If this attribute is not specified, the library is
16120 a static library. Otherwise, the library may be dynamic or relocatable. This
16121 distinction is operating-system dependent.
16123 @item Library_Version
16124 Expression must be a string value whose interpretation
16125 is platform dependent. On UNIX, it is used only for dynamic/relocatable
16126 libraries as the internal name of the library (the @code{"soname"}). If the
16127 library file name (built from the @code{Library_Name}) is different from the
16128 @code{Library_Version}, then the library file will be a symbolic link to the
16129 actual file whose name will be @code{Library_Version}.
16131 @item Library_Interface
16132 Expression must be a string list. Each element of the string list
16133 must designate a unit of the project.
16134 If this attribute is present in a Library Project File, then the project
16135 file is a Stand-alone Library_Project_File.
16137 @item Library_Auto_Init
16138 Expression must be a single string "true" or "false", case-insensitive.
16139 If this attribute is present in a Stand-alone Library Project File,
16140 it indicates if initialization is automatic when the dynamic library
16143 @item Library_Options
16144 Expression must be a string list. Indicates additional switches that
16145 are to be used when building a shared library.
16148 Expression must be a single string. Designates an alternative to "gcc"
16149 for building shared libraries.
16151 @item Library_Src_Dir
16152 Expression must be a path name. The attribute defines the
16153 directory in which the sources of the interfaces of a Stand-alone Library will
16154 be copied. The directory must exist, must be distinct from the project's
16155 object directory and source directories of all projects in the project tree,
16156 and must be writable.
16158 @item Library_Src_Dir
16159 Expression must be a path name. The attribute defines the
16160 directory in which the ALI files of a Library will
16161 be copied. The directory must exist, must be distinct from the project's
16162 object directory and source directories of all projects in the project tree,
16163 and must be writable.
16165 @item Library_Symbol_File
16166 Expression must be a single string. Its value is the single file name of a
16167 symbol file to be created when building a stand-alone library when the
16168 symbol policy is either "compliant", "controlled" or "restricted",
16169 on platforms that support symbol control, such as VMS. When symbol policy
16170 is "direct", then a file with this name must exist in the object directory.
16172 @item Library_Reference_Symbol_File
16173 Expression must be a single string. Its value is the path name of a
16174 reference symbol file that is read when the symbol policy is either
16175 "compliant" or "controlled", on platforms that support symbol control,
16176 such as VMS, when building a stand-alone library. The path may be an absolute
16177 path or a path relative to the project directory.
16179 @item Library_Symbol_Policy
16180 Expression must be a single string. Its case-insensitive value can only be
16181 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
16183 This attribute is not taken into account on all platforms. It controls the
16184 policy for exported symbols and, on some platforms (like VMS) that have the
16185 notions of major and minor IDs built in the library files, it controls
16186 the setting of these IDs.
16188 "autonomous" or "default": exported symbols are not controlled.
16190 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
16191 it is equivalent to policy "autonomous". If there are exported symbols in
16192 the reference symbol file that are not in the object files of the interfaces,
16193 the major ID of the library is increased. If there are symbols in the
16194 object files of the interfaces that are not in the reference symbol file,
16195 these symbols are put at the end of the list in the newly created symbol file
16196 and the minor ID is increased.
16198 "controlled": the attribute Library_Reference_Symbol_File must be defined.
16199 The library will fail to build if the exported symbols in the object files of
16200 the interfaces do not match exactly the symbol in the symbol file.
16202 "restricted": The attribute Library_Symbol_File must be defined. The library
16203 will fail to build if there are symbols in the symbol file that are not in
16204 the exported symbols of the object files of the interfaces. Additional symbols
16205 in the object files are not added to the symbol file.
16207 "direct": The attribute Library_Symbol_File must be defined and must designate
16208 an existing file in the object directory. This symbol file is passed directly
16209 to the underlying linker without any symbol processing.
16212 Expression must be a list of strings that are legal file names.
16213 These file names designate existing compilation units in the source directory
16214 that are legal main subprograms.
16216 When a project file is elaborated, as part of the execution of a gnatmake
16217 command, one or several executables are built and placed in the Exec_Dir.
16218 If the gnatmake command does not include explicit file names, the executables
16219 that are built correspond to the files specified by this attribute.
16221 @item Externally_Built
16222 Expression must be a single string. Its value must be either "true" of "false",
16223 case-insensitive. The default is "false". When the value of this attribute is
16224 "true", no attempt is made to compile the sources or to build the library,
16225 when the project is a library project.
16227 @item Main_Language
16228 This is a simple attribute. Its value is a string that specifies the
16229 language of the main program.
16232 Expression must be a string list. Each string designates
16233 a programming language that is known to GNAT. The strings are case-insensitive.
16237 @node Attribute References
16238 @section Attribute References
16241 Attribute references are used to retrieve the value of previously defined
16242 attribute for a package or project.
16245 attribute_reference ::=
16246 attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
16248 attribute_prefix ::=
16250 <project_simple_name | package_identifier |
16251 <project_>simple_name . package_identifier
16255 If an attribute has not been specified for a given package or project, its
16256 value is the null string or the empty list.
16258 @node External Values
16259 @section External Values
16262 An external value is an expression whose value is obtained from the command
16263 that invoked the processing of the current project file (typically a
16269 @b{external} ( string_literal [, string_literal] )
16273 The first string_literal is the string to be used on the command line or
16274 in the environment to specify the external value. The second string_literal,
16275 if present, is the default to use if there is no specification for this
16276 external value either on the command line or in the environment.
16278 @node Case Construction
16279 @section Case Construction
16282 A case construction supports attribute and variable declarations that depend
16283 on the value of a previously declared variable.
16287 case_construction ::=
16288 @b{case} <typed_variable_>name @b{is}
16293 @b{when} discrete_choice_list =>
16294 @{case_construction |
16295 attribute_declaration |
16296 variable_declaration |
16297 empty_declaration@}
16299 discrete_choice_list ::=
16300 string_literal @{| string_literal@} |
16305 Inside a case construction, variable declarations must be for variables that
16306 have already been declared before the case construction.
16308 All choices in a choice list must be distinct. The choice lists of two
16309 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
16310 alternatives do not need to include all values of the type. An @code{others}
16311 choice must appear last in the list of alternatives.
16317 A package provides a grouping of variable declarations and attribute
16318 declarations to be used when invoking various GNAT tools. The name of
16319 the package indicates the tool(s) to which it applies.
16323 package_declaration ::=
16324 package_spec | package_renaming
16327 @b{package} package_identifier @b{is}
16328 @{simple_declarative_item@}
16329 @b{end} package_identifier ;
16331 package_identifier ::=
16332 @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
16333 @code{Linker} | @code{Finder} | @code{Cross_Reference} |
16334 @code{gnatls} | @code{IDE} | @code{Pretty_Printer}
16337 @subsection Package Naming
16340 The attributes of a @code{Naming} package specifies the naming conventions
16341 that apply to the source files in a project. When invoking other GNAT tools,
16342 they will use the sources in the source directories that satisfy these
16343 naming conventions.
16345 The following attributes apply to a @code{Naming} package:
16349 This is a simple attribute whose value is a string. Legal values of this
16350 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
16351 These strings are themselves case insensitive.
16354 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
16356 @item Dot_Replacement
16357 This is a simple attribute whose string value satisfies the following
16361 @item It must not be empty
16362 @item It cannot start or end with an alphanumeric character
16363 @item It cannot be a single underscore
16364 @item It cannot start with an underscore followed by an alphanumeric
16365 @item It cannot contain a dot @code{'.'} if longer than one character
16369 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
16372 This is an associative array attribute, defined on language names,
16373 whose image is a string that must satisfy the following
16377 @item It must not be empty
16378 @item It cannot start with an alphanumeric character
16379 @item It cannot start with an underscore followed by an alphanumeric character
16383 For Ada, the attribute denotes the suffix used in file names that contain
16384 library unit declarations, that is to say units that are package and
16385 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
16386 specified, then the default is @code{".ads"}.
16388 For C and C++, the attribute denotes the suffix used in file names that
16389 contain prototypes.
16392 This is an associative array attribute defined on language names,
16393 whose image is a string that must satisfy the following
16397 @item It must not be empty
16398 @item It cannot start with an alphanumeric character
16399 @item It cannot start with an underscore followed by an alphanumeric character
16400 @item It cannot be a suffix of @code{Spec_Suffix}
16404 For Ada, the attribute denotes the suffix used in file names that contain
16405 library bodies, that is to say units that are package and subprogram bodies.
16406 If @code{Body_Suffix ("Ada")} is not specified, then the default is
16409 For C and C++, the attribute denotes the suffix used in file names that contain
16412 @item Separate_Suffix
16413 This is a simple attribute whose value satisfies the same conditions as
16414 @code{Body_Suffix}.
16416 This attribute is specific to Ada. It denotes the suffix used in file names
16417 that contain separate bodies. If it is not specified, then it defaults to same
16418 value as @code{Body_Suffix ("Ada")}.
16421 This is an associative array attribute, specific to Ada, defined over
16422 compilation unit names. The image is a string that is the name of the file
16423 that contains that library unit. The file name is case sensitive if the
16424 conventions of the host operating system require it.
16427 This is an associative array attribute, specific to Ada, defined over
16428 compilation unit names. The image is a string that is the name of the file
16429 that contains the library unit body for the named unit. The file name is case
16430 sensitive if the conventions of the host operating system require it.
16432 @item Specification_Exceptions
16433 This is an associative array attribute defined on language names,
16434 whose value is a list of strings.
16436 This attribute is not significant for Ada.
16438 For C and C++, each string in the list denotes the name of a file that
16439 contains prototypes, but whose suffix is not necessarily the
16440 @code{Spec_Suffix} for the language.
16442 @item Implementation_Exceptions
16443 This is an associative array attribute defined on language names,
16444 whose value is a list of strings.
16446 This attribute is not significant for Ada.
16448 For C and C++, each string in the list denotes the name of a file that
16449 contains source code, but whose suffix is not necessarily the
16450 @code{Body_Suffix} for the language.
16453 The following attributes of package @code{Naming} are obsolescent. They are
16454 kept as synonyms of other attributes for compatibility with previous versions
16455 of the Project Manager.
16458 @item Specification_Suffix
16459 This is a synonym of @code{Spec_Suffix}.
16461 @item Implementation_Suffix
16462 This is a synonym of @code{Body_Suffix}.
16464 @item Specification
16465 This is a synonym of @code{Spec}.
16467 @item Implementation
16468 This is a synonym of @code{Body}.
16471 @subsection package Compiler
16474 The attributes of the @code{Compiler} package specify the compilation options
16475 to be used by the underlying compiler.
16478 @item Default_Switches
16479 This is an associative array attribute. Its
16480 domain is a set of language names. Its range is a string list that
16481 specifies the compilation options to be used when compiling a component
16482 written in that language, for which no file-specific switches have been
16486 This is an associative array attribute. Its domain is
16487 a set of file names. Its range is a string list that specifies the
16488 compilation options to be used when compiling the named file. If a file
16489 is not specified in the Switches attribute, it is compiled with the
16490 options specified by Default_Switches of its language, if defined.
16492 @item Local_Configuration_Pragmas.
16493 This is a simple attribute, whose
16494 value is a path name that designates a file containing configuration pragmas
16495 to be used for all invocations of the compiler for immediate sources of the
16499 @subsection package Builder
16502 The attributes of package @code{Builder} specify the compilation, binding, and
16503 linking options to be used when building an executable for a project. The
16504 following attributes apply to package @code{Builder}:
16507 @item Default_Switches
16508 This is an associative array attribute. Its
16509 domain is a set of language names. Its range is a string list that
16510 specifies options to be used when building a main
16511 written in that language, for which no file-specific switches have been
16515 This is an associative array attribute. Its domain is
16516 a set of file names. Its range is a string list that specifies
16517 options to be used when building the named main file. If a main file
16518 is not specified in the Switches attribute, it is built with the
16519 options specified by Default_Switches of its language, if defined.
16521 @item Global_Configuration_Pragmas
16522 This is a simple attribute, whose
16523 value is a path name that designates a file that contains configuration pragmas
16524 to be used in every build of an executable. If both local and global
16525 configuration pragmas are specified, a compilation makes use of both sets.
16529 This is an associative array attribute. Its domain is
16530 a set of main source file names. Its range is a simple string that specifies
16531 the executable file name to be used when linking the specified main source.
16532 If a main source is not specified in the Executable attribute, the executable
16533 file name is deducted from the main source file name.
16534 This attribute has no effect if its value is the empty string.
16536 @item Executable_Suffix
16537 This is a simple attribute whose value is the suffix to be added to
16538 the executables that don't have an attribute Executable specified.
16541 @subsection package Gnatls
16544 The attributes of package @code{Gnatls} specify the tool options to be used
16545 when invoking the library browser @command{gnatls}.
16546 The following attributes apply to package @code{Gnatls}:
16550 This is a single attribute with a string list value. Each nonempty string
16551 in the list is an option when invoking @code{gnatls}.
16554 @subsection package Binder
16557 The attributes of package @code{Binder} specify the options to be used
16558 when invoking the binder in the construction of an executable.
16559 The following attributes apply to package @code{Binder}:
16562 @item Default_Switches
16563 This is an associative array attribute. Its
16564 domain is a set of language names. Its range is a string list that
16565 specifies options to be used when binding a main
16566 written in that language, for which no file-specific switches have been
16570 This is an associative array attribute. Its domain is
16571 a set of file names. Its range is a string list that specifies
16572 options to be used when binding the named main file. If a main file
16573 is not specified in the Switches attribute, it is bound with the
16574 options specified by Default_Switches of its language, if defined.
16577 @subsection package Linker
16580 The attributes of package @code{Linker} specify the options to be used when
16581 invoking the linker in the construction of an executable.
16582 The following attributes apply to package @code{Linker}:
16585 @item Default_Switches
16586 This is an associative array attribute. Its
16587 domain is a set of language names. Its range is a string list that
16588 specifies options to be used when linking a main
16589 written in that language, for which no file-specific switches have been
16593 This is an associative array attribute. Its domain is
16594 a set of file names. Its range is a string list that specifies
16595 options to be used when linking the named main file. If a main file
16596 is not specified in the Switches attribute, it is linked with the
16597 options specified by Default_Switches of its language, if defined.
16599 @item Linker_Options
16600 This is a string list attribute. Its value specifies additional options that
16601 be given to the linker when linking an executable. This attribute is not
16602 used in the main project, only in projects imported directly or indirectly.
16606 @subsection package Cross_Reference
16609 The attributes of package @code{Cross_Reference} specify the tool options
16611 when invoking the library tool @command{gnatxref}.
16612 The following attributes apply to package @code{Cross_Reference}:
16615 @item Default_Switches
16616 This is an associative array attribute. Its
16617 domain is a set of language names. Its range is a string list that
16618 specifies options to be used when calling @command{gnatxref} on a source
16619 written in that language, for which no file-specific switches have been
16623 This is an associative array attribute. Its domain is
16624 a set of file names. Its range is a string list that specifies
16625 options to be used when calling @command{gnatxref} on the named main source.
16626 If a source is not specified in the Switches attribute, @command{gnatxref} will
16627 be called with the options specified by Default_Switches of its language,
16631 @subsection package Finder
16634 The attributes of package @code{Finder} specify the tool options to be used
16635 when invoking the search tool @command{gnatfind}.
16636 The following attributes apply to package @code{Finder}:
16639 @item Default_Switches
16640 This is an associative array attribute. Its
16641 domain is a set of language names. Its range is a string list that
16642 specifies options to be used when calling @command{gnatfind} on a source
16643 written in that language, for which no file-specific switches have been
16647 This is an associative array attribute. Its domain is
16648 a set of file names. Its range is a string list that specifies
16649 options to be used when calling @command{gnatfind} on the named main source.
16650 If a source is not specified in the Switches attribute, @command{gnatfind} will
16651 be called with the options specified by Default_Switches of its language,
16655 @subsection package Pretty_Printer
16658 The attributes of package @code{Pretty_Printer}
16659 specify the tool options to be used
16660 when invoking the formatting tool @command{gnatpp}.
16661 The following attributes apply to package @code{Pretty_Printer}:
16664 @item Default_switches
16665 This is an associative array attribute. Its
16666 domain is a set of language names. Its range is a string list that
16667 specifies options to be used when calling @command{gnatpp} on a source
16668 written in that language, for which no file-specific switches have been
16672 This is an associative array attribute. Its domain is
16673 a set of file names. Its range is a string list that specifies
16674 options to be used when calling @command{gnatpp} on the named main source.
16675 If a source is not specified in the Switches attribute, @command{gnatpp} will
16676 be called with the options specified by Default_Switches of its language,
16680 @subsection package gnatstub
16683 The attributes of package @code{gnatstub}
16684 specify the tool options to be used
16685 when invoking the tool @command{gnatstub}.
16686 The following attributes apply to package @code{gnatstub}:
16689 @item Default_switches
16690 This is an associative array attribute. Its
16691 domain is a set of language names. Its range is a string list that
16692 specifies options to be used when calling @command{gnatstub} on a source
16693 written in that language, for which no file-specific switches have been
16697 This is an associative array attribute. Its domain is
16698 a set of file names. Its range is a string list that specifies
16699 options to be used when calling @command{gnatstub} on the named main source.
16700 If a source is not specified in the Switches attribute, @command{gnatpp} will
16701 be called with the options specified by Default_Switches of its language,
16705 @subsection package Eliminate
16708 The attributes of package @code{Eliminate}
16709 specify the tool options to be used
16710 when invoking the tool @command{gnatelim}.
16711 The following attributes apply to package @code{Eliminate}:
16714 @item Default_switches
16715 This is an associative array attribute. Its
16716 domain is a set of language names. Its range is a string list that
16717 specifies options to be used when calling @command{gnatelim} on a source
16718 written in that language, for which no file-specific switches have been
16722 This is an associative array attribute. Its domain is
16723 a set of file names. Its range is a string list that specifies
16724 options to be used when calling @command{gnatelim} on the named main source.
16725 If a source is not specified in the Switches attribute, @command{gnatelim} will
16726 be called with the options specified by Default_Switches of its language,
16730 @subsection package Metrics
16733 The attributes of package @code{Metrics}
16734 specify the tool options to be used
16735 when invoking the tool @command{gnatmetric}.
16736 The following attributes apply to package @code{Metrics}:
16739 @item Default_switches
16740 This is an associative array attribute. Its
16741 domain is a set of language names. Its range is a string list that
16742 specifies options to be used when calling @command{gnatmetric} on a source
16743 written in that language, for which no file-specific switches have been
16747 This is an associative array attribute. Its domain is
16748 a set of file names. Its range is a string list that specifies
16749 options to be used when calling @command{gnatmetric} on the named main source.
16750 If a source is not specified in the Switches attribute, @command{gnatmetric}
16751 will be called with the options specified by Default_Switches of its language,
16755 @subsection package IDE
16758 The attributes of package @code{IDE} specify the options to be used when using
16759 an Integrated Development Environment such as @command{GPS}.
16763 This is a simple attribute. Its value is a string that designates the remote
16764 host in a cross-compilation environment, to be used for remote compilation and
16765 debugging. This field should not be specified when running on the local
16769 This is a simple attribute. Its value is a string that specifies the
16770 name of IP address of the embedded target in a cross-compilation environment,
16771 on which the program should execute.
16773 @item Communication_Protocol
16774 This is a simple string attribute. Its value is the name of the protocol
16775 to use to communicate with the target in a cross-compilation environment,
16776 e.g.@: @code{"wtx"} or @code{"vxworks"}.
16778 @item Compiler_Command
16779 This is an associative array attribute, whose domain is a language name. Its
16780 value is string that denotes the command to be used to invoke the compiler.
16781 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16782 gnatmake, in particular in the handling of switches.
16784 @item Debugger_Command
16785 This is simple attribute, Its value is a string that specifies the name of
16786 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16788 @item Default_Switches
16789 This is an associative array attribute. Its indexes are the name of the
16790 external tools that the GNAT Programming System (GPS) is supporting. Its
16791 value is a list of switches to use when invoking that tool.
16794 This is a simple attribute. Its value is a string that specifies the name
16795 of the @command{gnatls} utility to be used to retrieve information about the
16796 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16799 This is a simple attribute. Its value is a string used to specify the
16800 Version Control System (VCS) to be used for this project, e.g.@: CVS, RCS
16801 ClearCase or Perforce.
16803 @item VCS_File_Check
16804 This is a simple attribute. Its value is a string that specifies the
16805 command used by the VCS to check the validity of a file, either
16806 when the user explicitly asks for a check, or as a sanity check before
16807 doing the check-in.
16809 @item VCS_Log_Check
16810 This is a simple attribute. Its value is a string that specifies
16811 the command used by the VCS to check the validity of a log file.
16813 @item VCS_Repository_Root
16814 The VCS repository root path. This is used to create tags or branches
16815 of the repository. For subversion the value should be the @code{URL}
16816 as specified to check-out the working copy of the repository.
16818 @item VCS_Patch_Root
16819 The local root directory to use for building patch file. All patch chunks
16820 will be relative to this path. The root project directory is used if
16821 this value is not defined.
16825 @node Package Renamings
16826 @section Package Renamings
16829 A package can be defined by a renaming declaration. The new package renames
16830 a package declared in a different project file, and has the same attributes
16831 as the package it renames.
16834 package_renaming ::==
16835 @b{package} package_identifier @b{renames}
16836 <project_>simple_name.package_identifier ;
16840 The package_identifier of the renamed package must be the same as the
16841 package_identifier. The project whose name is the prefix of the renamed
16842 package must contain a package declaration with this name. This project
16843 must appear in the context_clause of the enclosing project declaration,
16844 or be the parent project of the enclosing child project.
16850 A project file specifies a set of rules for constructing a software system.
16851 A project file can be self-contained, or depend on other project files.
16852 Dependencies are expressed through a context clause that names other projects.
16858 context_clause project_declaration
16860 project_declaration ::=
16861 simple_project_declaration | project_extension
16863 simple_project_declaration ::=
16864 @b{project} <project_>simple_name @b{is}
16865 @{declarative_item@}
16866 @b{end} <project_>simple_name;
16872 [@b{limited}] @b{with} path_name @{ , path_name @} ;
16879 A path name denotes a project file. A path name can be absolute or relative.
16880 An absolute path name includes a sequence of directories, in the syntax of
16881 the host operating system, that identifies uniquely the project file in the
16882 file system. A relative path name identifies the project file, relative
16883 to the directory that contains the current project, or relative to a
16884 directory listed in the environment variable ADA_PROJECT_PATH.
16885 Path names are case sensitive if file names in the host operating system
16886 are case sensitive.
16888 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16889 directory names separated by colons (semicolons on Windows).
16891 A given project name can appear only once in a context_clause.
16893 It is illegal for a project imported by a context clause to refer, directly
16894 or indirectly, to the project in which this context clause appears (the
16895 dependency graph cannot contain cycles), except when one of the with_clause
16896 in the cycle is a @code{limited with}.
16898 @node Project Extensions
16899 @section Project Extensions
16902 A project extension introduces a new project, which inherits the declarations
16903 of another project.
16907 project_extension ::=
16908 @b{project} <project_>simple_name @b{extends} path_name @b{is}
16909 @{declarative_item@}
16910 @b{end} <project_>simple_name;
16914 The project extension declares a child project. The child project inherits
16915 all the declarations and all the files of the parent project, These inherited
16916 declaration can be overridden in the child project, by means of suitable
16919 @node Project File Elaboration
16920 @section Project File Elaboration
16923 A project file is processed as part of the invocation of a gnat tool that
16924 uses the project option. Elaboration of the process file consists in the
16925 sequential elaboration of all its declarations. The computed values of
16926 attributes and variables in the project are then used to establish the
16927 environment in which the gnat tool will execute.
16929 @node Obsolescent Features
16930 @chapter Obsolescent Features
16933 This chapter describes features that are provided by GNAT, but are
16934 considered obsolescent since there are preferred ways of achieving
16935 the same effect. These features are provided solely for historical
16936 compatibility purposes.
16939 * pragma No_Run_Time::
16940 * pragma Ravenscar::
16941 * pragma Restricted_Run_Time::
16944 @node pragma No_Run_Time
16945 @section pragma No_Run_Time
16947 The pragma @code{No_Run_Time} is used to achieve an affect similar
16948 to the use of the "Zero Foot Print" configurable run time, but without
16949 requiring a specially configured run time. The result of using this
16950 pragma, which must be used for all units in a partition, is to restrict
16951 the use of any language features requiring run-time support code. The
16952 preferred usage is to use an appropriately configured run-time that
16953 includes just those features that are to be made accessible.
16955 @node pragma Ravenscar
16956 @section pragma Ravenscar
16958 The pragma @code{Ravenscar} has exactly the same effect as pragma
16959 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16960 is part of the new Ada 2005 standard.
16962 @node pragma Restricted_Run_Time
16963 @section pragma Restricted_Run_Time
16965 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16966 pragma @code{Profile (Restricted)}. The latter usage is
16967 preferred since the Ada 2005 pragma @code{Profile} is intended for
16968 this kind of implementation dependent addition.
16971 @c GNU Free Documentation License
16973 @node Index,,GNU Free Documentation License, Top