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
226 * Default_Bit_Order::
236 * Has_Access_Values::
237 * Has_Discriminants::
244 * Max_Interrupt_Priority::
246 * Maximum_Alignment::
251 * Passed_By_Reference::
264 * Unconstrained_Array::
265 * Universal_Literal_String::
266 * Unrestricted_Access::
272 The Implementation of Standard I/O
274 * Standard I/O Packages::
280 * Wide_Wide_Text_IO::
284 * Filenames encoding::
286 * Operations on C Streams::
287 * Interfacing to C Streams::
291 * Ada.Characters.Latin_9 (a-chlat9.ads)::
292 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
293 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
294 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
295 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
296 * Ada.Command_Line.Environment (a-colien.ads)::
297 * Ada.Command_Line.Remove (a-colire.ads)::
298 * Ada.Command_Line.Response_File (a-clrefi.ads)::
299 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
300 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
301 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
302 * Ada.Exceptions.Traceback (a-exctra.ads)::
303 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
304 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
305 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
306 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
307 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
308 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
309 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
310 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
311 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
312 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
313 * GNAT.Altivec (g-altive.ads)::
314 * GNAT.Altivec.Conversions (g-altcon.ads)::
315 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
316 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
317 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
318 * GNAT.Array_Split (g-arrspl.ads)::
319 * GNAT.AWK (g-awk.ads)::
320 * GNAT.Bounded_Buffers (g-boubuf.ads)::
321 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
322 * GNAT.Bubble_Sort (g-bubsor.ads)::
323 * GNAT.Bubble_Sort_A (g-busora.ads)::
324 * GNAT.Bubble_Sort_G (g-busorg.ads)::
325 * GNAT.Byte_Order_Mark (g-byorma.ads)::
326 * GNAT.Byte_Swapping (g-bytswa.ads)::
327 * GNAT.Calendar (g-calend.ads)::
328 * GNAT.Calendar.Time_IO (g-catiio.ads)::
329 * GNAT.Case_Util (g-casuti.ads)::
330 * GNAT.CGI (g-cgi.ads)::
331 * GNAT.CGI.Cookie (g-cgicoo.ads)::
332 * GNAT.CGI.Debug (g-cgideb.ads)::
333 * GNAT.Command_Line (g-comlin.ads)::
334 * GNAT.Compiler_Version (g-comver.ads)::
335 * GNAT.Ctrl_C (g-ctrl_c.ads)::
336 * GNAT.CRC32 (g-crc32.ads)::
337 * GNAT.Current_Exception (g-curexc.ads)::
338 * GNAT.Debug_Pools (g-debpoo.ads)::
339 * GNAT.Debug_Utilities (g-debuti.ads)::
340 * GNAT.Decode_String (g-decstr.ads)::
341 * GNAT.Decode_UTF8_String (g-deutst.ads)::
342 * GNAT.Directory_Operations (g-dirope.ads)::
343 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
344 * GNAT.Dynamic_HTables (g-dynhta.ads)::
345 * GNAT.Dynamic_Tables (g-dyntab.ads)::
346 * GNAT.Encode_String (g-encstr.ads)::
347 * GNAT.Encode_UTF8_String (g-enutst.ads)::
348 * GNAT.Exception_Actions (g-excact.ads)::
349 * GNAT.Exception_Traces (g-exctra.ads)::
350 * GNAT.Exceptions (g-except.ads)::
351 * GNAT.Expect (g-expect.ads)::
352 * GNAT.Float_Control (g-flocon.ads)::
353 * GNAT.Heap_Sort (g-heasor.ads)::
354 * GNAT.Heap_Sort_A (g-hesora.ads)::
355 * GNAT.Heap_Sort_G (g-hesorg.ads)::
356 * GNAT.HTable (g-htable.ads)::
357 * GNAT.IO (g-io.ads)::
358 * GNAT.IO_Aux (g-io_aux.ads)::
359 * GNAT.Lock_Files (g-locfil.ads)::
360 * GNAT.MD5 (g-md5.ads)::
361 * GNAT.Memory_Dump (g-memdum.ads)::
362 * GNAT.Most_Recent_Exception (g-moreex.ads)::
363 * GNAT.OS_Lib (g-os_lib.ads)::
364 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
365 * GNAT.Random_Numbers (g-rannum.ads)::
366 * GNAT.Regexp (g-regexp.ads)::
367 * GNAT.Registry (g-regist.ads)::
368 * GNAT.Regpat (g-regpat.ads)::
369 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
370 * GNAT.Semaphores (g-semaph.ads)::
371 * GNAT.Serial_Communications (g-sercom.ads)::
372 * GNAT.SHA1 (g-sha1.ads)::
373 * GNAT.Signals (g-signal.ads)::
374 * GNAT.Sockets (g-socket.ads)::
375 * GNAT.Source_Info (g-souinf.ads)::
376 * GNAT.Spelling_Checker (g-speche.ads)::
377 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
378 * GNAT.Spitbol.Patterns (g-spipat.ads)::
379 * GNAT.Spitbol (g-spitbo.ads)::
380 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
381 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
382 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
383 * GNAT.Strings (g-string.ads)::
384 * GNAT.String_Split (g-strspl.ads)::
385 * GNAT.Table (g-table.ads)::
386 * GNAT.Task_Lock (g-tasloc.ads)::
387 * GNAT.Threads (g-thread.ads)::
388 * GNAT.Time_Stamp (g-timsta.ads)::
389 * GNAT.Traceback (g-traceb.ads)::
390 * GNAT.Traceback.Symbolic (g-trasym.ads)::
391 * GNAT.UTF_32 (g-utf_32.ads)::
392 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
393 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
394 * GNAT.Wide_String_Split (g-wistsp.ads)::
395 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
396 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
397 * Interfaces.C.Extensions (i-cexten.ads)::
398 * Interfaces.C.Streams (i-cstrea.ads)::
399 * Interfaces.CPP (i-cpp.ads)::
400 * Interfaces.Packed_Decimal (i-pacdec.ads)::
401 * Interfaces.VxWorks (i-vxwork.ads)::
402 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
403 * System.Address_Image (s-addima.ads)::
404 * System.Assertions (s-assert.ads)::
405 * System.Memory (s-memory.ads)::
406 * System.Partition_Interface (s-parint.ads)::
407 * System.Pool_Global (s-pooglo.ads)::
408 * System.Pool_Local (s-pooloc.ads)::
409 * System.Restrictions (s-restri.ads)::
410 * System.Rident (s-rident.ads)::
411 * System.Task_Info (s-tasinf.ads)::
412 * System.Wch_Cnv (s-wchcnv.ads)::
413 * System.Wch_Con (s-wchcon.ads)::
417 * Text_IO Stream Pointer Positioning::
418 * Text_IO Reading and Writing Non-Regular Files::
420 * Treating Text_IO Files as Streams::
421 * Text_IO Extensions::
422 * Text_IO Facilities for Unbounded Strings::
426 * Wide_Text_IO Stream Pointer Positioning::
427 * Wide_Text_IO Reading and Writing Non-Regular Files::
431 * Wide_Wide_Text_IO Stream Pointer Positioning::
432 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
434 Interfacing to Other Languages
437 * Interfacing to C++::
438 * Interfacing to COBOL::
439 * Interfacing to Fortran::
440 * Interfacing to non-GNAT Ada code::
442 Specialized Needs Annexes
444 Implementation of Specific Ada Features
445 * Machine Code Insertions::
446 * GNAT Implementation of Tasking::
447 * GNAT Implementation of Shared Passive Packages::
448 * Code Generation for Array Aggregates::
449 * The Size of Discriminated Records with Default Discriminants::
450 * Strict Conformance to the Ada Reference Manual::
452 Project File Reference
456 GNU Free Documentation License
463 @node About This Guide
464 @unnumbered About This Guide
467 This manual contains useful information in writing programs using the
468 @value{EDITION} compiler. It includes information on implementation dependent
469 characteristics of @value{EDITION}, including all the information required by
470 Annex M of the Ada language standard.
472 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
473 Ada 83 compatibility mode.
474 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
475 but you can override with a compiler switch
476 to explicitly specify the language version.
477 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
478 @value{EDITION} User's Guide}, for details on these switches.)
479 Throughout this manual, references to ``Ada'' without a year suffix
480 apply to both the Ada 95 and Ada 2005 versions of the language.
482 Ada is designed to be highly portable.
483 In general, a program will have the same effect even when compiled by
484 different compilers on different platforms.
485 However, since Ada is designed to be used in a
486 wide variety of applications, it also contains a number of system
487 dependent features to be used in interfacing to the external world.
488 @cindex Implementation-dependent features
491 Note: Any program that makes use of implementation-dependent features
492 may be non-portable. You should follow good programming practice and
493 isolate and clearly document any sections of your program that make use
494 of these features in a non-portable manner.
497 For ease of exposition, ``GNAT Pro'' will be referred to simply as
498 ``GNAT'' in the remainder of this document.
502 * What This Reference Manual Contains::
504 * Related Information::
507 @node What This Reference Manual Contains
508 @unnumberedsec What This Reference Manual Contains
511 This reference manual contains the following chapters:
515 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
516 pragmas, which can be used to extend and enhance the functionality of the
520 @ref{Implementation Defined Attributes}, lists GNAT
521 implementation-dependent attributes which can be used to extend and
522 enhance the functionality of the compiler.
525 @ref{Implementation Advice}, provides information on generally
526 desirable behavior which are not requirements that all compilers must
527 follow since it cannot be provided on all systems, or which may be
528 undesirable on some systems.
531 @ref{Implementation Defined Characteristics}, provides a guide to
532 minimizing implementation dependent features.
535 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
536 implemented by GNAT, and how they can be imported into user
537 application programs.
540 @ref{Representation Clauses and Pragmas}, describes in detail the
541 way that GNAT represents data, and in particular the exact set
542 of representation clauses and pragmas that is accepted.
545 @ref{Standard Library Routines}, provides a listing of packages and a
546 brief description of the functionality that is provided by Ada's
547 extensive set of standard library routines as implemented by GNAT@.
550 @ref{The Implementation of Standard I/O}, details how the GNAT
551 implementation of the input-output facilities.
554 @ref{The GNAT Library}, is a catalog of packages that complement
555 the Ada predefined library.
558 @ref{Interfacing to Other Languages}, describes how programs
559 written in Ada using GNAT can be interfaced to other programming
562 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
563 of the specialized needs annexes.
566 @ref{Implementation of Specific Ada Features}, discusses issues related
567 to GNAT's implementation of machine code insertions, tasking, and several
571 @ref{Project File Reference}, presents the syntax and semantics
575 @ref{Obsolescent Features} documents implementation dependent features,
576 including pragmas and attributes, which are considered obsolescent, since
577 there are other preferred ways of achieving the same results. These
578 obsolescent forms are retained for backwards compatibility.
582 @cindex Ada 95 Language Reference Manual
583 @cindex Ada 2005 Language Reference Manual
585 This reference manual assumes a basic familiarity with the Ada 95 language, as
586 described in the International Standard ANSI/ISO/IEC-8652:1995,
588 It does not require knowledge of the new features introduced by Ada 2005,
589 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
591 Both reference manuals are included in the GNAT documentation
595 @unnumberedsec Conventions
596 @cindex Conventions, typographical
597 @cindex Typographical conventions
600 Following are examples of the typographical and graphic conventions used
605 @code{Functions}, @code{utility program names}, @code{standard names},
612 @file{File names}, @samp{button names}, and @samp{field names}.
615 @code{Variables}, @env{environment variables}, and @var{metasyntactic
622 [optional information or parameters]
625 Examples are described by text
627 and then shown this way.
632 Commands that are entered by the user are preceded in this manual by the
633 characters @samp{$ } (dollar sign followed by space). If your system uses this
634 sequence as a prompt, then the commands will appear exactly as you see them
635 in the manual. If your system uses some other prompt, then the command will
636 appear with the @samp{$} replaced by whatever prompt character you are using.
638 @node Related Information
639 @unnumberedsec Related Information
641 See the following documents for further information on GNAT:
645 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
646 @value{EDITION} User's Guide}, which provides information on how to use the
647 GNAT compiler system.
650 @cite{Ada 95 Reference Manual}, which contains all reference
651 material for the Ada 95 programming language.
654 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
655 of the Ada 95 standard. The annotations describe
656 detailed aspects of the design decision, and in particular contain useful
657 sections on Ada 83 compatibility.
660 @cite{Ada 2005 Reference Manual}, which contains all reference
661 material for the Ada 2005 programming language.
664 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
665 of the Ada 2005 standard. The annotations describe
666 detailed aspects of the design decision, and in particular contain useful
667 sections on Ada 83 and Ada 95 compatibility.
670 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
671 which contains specific information on compatibility between GNAT and
675 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
676 describes in detail the pragmas and attributes provided by the DEC Ada 83
681 @node Implementation Defined Pragmas
682 @chapter Implementation Defined Pragmas
685 Ada defines a set of pragmas that can be used to supply additional
686 information to the compiler. These language defined pragmas are
687 implemented in GNAT and work as described in the Ada Reference Manual.
689 In addition, Ada allows implementations to define additional pragmas
690 whose meaning is defined by the implementation. GNAT provides a number
691 of these implementation-defined pragmas, which can be used to extend
692 and enhance the functionality of the compiler. This section of the GNAT
693 Reference Manual describes these additional pragmas.
695 Note that any program using these pragmas might not be portable to other
696 compilers (although GNAT implements this set of pragmas on all
697 platforms). Therefore if portability to other compilers is an important
698 consideration, the use of these pragmas should be minimized.
701 * Pragma Abort_Defer::
708 * Pragma Assume_No_Invalid_Values::
710 * Pragma C_Pass_By_Copy::
712 * Pragma Check_Name::
713 * Pragma Check_Policy::
715 * Pragma Common_Object::
716 * Pragma Compile_Time_Error::
717 * Pragma Compile_Time_Warning::
718 * Pragma Complete_Representation::
719 * Pragma Complex_Representation::
720 * Pragma Component_Alignment::
721 * Pragma Convention_Identifier::
723 * Pragma CPP_Constructor::
724 * Pragma CPP_Virtual::
725 * Pragma CPP_Vtable::
727 * Pragma Debug_Policy::
728 * Pragma Detect_Blocking::
729 * Pragma Elaboration_Checks::
731 * Pragma Export_Exception::
732 * Pragma Export_Function::
733 * Pragma Export_Object::
734 * Pragma Export_Procedure::
735 * Pragma Export_Value::
736 * Pragma Export_Valued_Procedure::
737 * Pragma Extend_System::
739 * Pragma External_Name_Casing::
741 * Pragma Favor_Top_Level::
742 * Pragma Finalize_Storage_Only::
743 * Pragma Float_Representation::
745 * Pragma Implemented_By_Entry::
746 * Pragma Implicit_Packing::
747 * Pragma Import_Exception::
748 * Pragma Import_Function::
749 * Pragma Import_Object::
750 * Pragma Import_Procedure::
751 * Pragma Import_Valued_Procedure::
752 * Pragma Initialize_Scalars::
753 * Pragma Inline_Always::
754 * Pragma Inline_Generic::
756 * Pragma Interface_Name::
757 * Pragma Interrupt_Handler::
758 * Pragma Interrupt_State::
759 * Pragma Keep_Names::
762 * Pragma Linker_Alias::
763 * Pragma Linker_Constructor::
764 * Pragma Linker_Destructor::
765 * Pragma Linker_Section::
766 * Pragma Long_Float::
767 * Pragma Machine_Attribute::
769 * Pragma Main_Storage::
772 * Pragma No_Strict_Aliasing::
773 * Pragma Normalize_Scalars::
774 * Pragma Obsolescent::
775 * Pragma Optimize_Alignment::
777 * Pragma Persistent_BSS::
779 * Pragma Postcondition::
780 * Pragma Precondition::
781 * Pragma Profile (Ravenscar)::
782 * Pragma Profile (Restricted)::
783 * Pragma Psect_Object::
784 * Pragma Pure_Function::
785 * Pragma Restriction_Warnings::
787 * Pragma Source_File_Name::
788 * Pragma Source_File_Name_Project::
789 * Pragma Source_Reference::
790 * Pragma Stream_Convert::
791 * Pragma Style_Checks::
794 * Pragma Suppress_All::
795 * Pragma Suppress_Exception_Locations::
796 * Pragma Suppress_Initialization::
799 * Pragma Task_Storage::
800 * Pragma Thread_Local_Storage::
801 * Pragma Time_Slice::
803 * Pragma Unchecked_Union::
804 * Pragma Unimplemented_Unit::
805 * Pragma Universal_Aliasing ::
806 * Pragma Universal_Data::
807 * Pragma Unmodified::
808 * Pragma Unreferenced::
809 * Pragma Unreferenced_Objects::
810 * Pragma Unreserve_All_Interrupts::
811 * Pragma Unsuppress::
812 * Pragma Use_VADS_Size::
813 * Pragma Validity_Checks::
816 * Pragma Weak_External::
817 * Pragma Wide_Character_Encoding::
820 @node Pragma Abort_Defer
821 @unnumberedsec Pragma Abort_Defer
823 @cindex Deferring aborts
831 This pragma must appear at the start of the statement sequence of a
832 handled sequence of statements (right after the @code{begin}). It has
833 the effect of deferring aborts for the sequence of statements (but not
834 for the declarations or handlers, if any, associated with this statement
838 @unnumberedsec Pragma Ada_83
847 A configuration pragma that establishes Ada 83 mode for the unit to
848 which it applies, regardless of the mode set by the command line
849 switches. In Ada 83 mode, GNAT attempts to be as compatible with
850 the syntax and semantics of Ada 83, as defined in the original Ada
851 83 Reference Manual as possible. In particular, the keywords added by Ada 95
852 and Ada 2005 are not recognized, optional package bodies are allowed,
853 and generics may name types with unknown discriminants without using
854 the @code{(<>)} notation. In addition, some but not all of the additional
855 restrictions of Ada 83 are enforced.
857 Ada 83 mode is intended for two purposes. Firstly, it allows existing
858 Ada 83 code to be compiled and adapted to GNAT with less effort.
859 Secondly, it aids in keeping code backwards compatible with Ada 83.
860 However, there is no guarantee that code that is processed correctly
861 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
862 83 compiler, since GNAT does not enforce all the additional checks
866 @unnumberedsec Pragma Ada_95
875 A configuration pragma that establishes Ada 95 mode for the unit to which
876 it applies, regardless of the mode set by the command line switches.
877 This mode is set automatically for the @code{Ada} and @code{System}
878 packages and their children, so you need not specify it in these
879 contexts. This pragma is useful when writing a reusable component that
880 itself uses Ada 95 features, but which is intended to be usable from
881 either Ada 83 or Ada 95 programs.
884 @unnumberedsec Pragma Ada_05
893 A configuration pragma that establishes Ada 2005 mode for the unit to which
894 it applies, regardless of the mode set by the command line switches.
895 This mode is set automatically for the @code{Ada} and @code{System}
896 packages and their children, so you need not specify it in these
897 contexts. This pragma is useful when writing a reusable component that
898 itself uses Ada 2005 features, but which is intended to be usable from
899 either Ada 83 or Ada 95 programs.
901 @node Pragma Ada_2005
902 @unnumberedsec Pragma Ada_2005
911 This configuration pragma is a synonym for pragma Ada_05 and has the
912 same syntax and effect.
914 @node Pragma Annotate
915 @unnumberedsec Pragma Annotate
920 pragma Annotate (IDENTIFIER @{, ARG@});
922 ARG ::= NAME | EXPRESSION
926 This pragma is used to annotate programs. @var{identifier} identifies
927 the type of annotation. GNAT verifies that it is an identifier, but does
928 not otherwise analyze it. The @var{arg} argument
929 can be either a string literal or an
930 expression. String literals are assumed to be of type
931 @code{Standard.String}. Names of entities are simply analyzed as entity
932 names. All other expressions are analyzed as expressions, and must be
935 The analyzed pragma is retained in the tree, but not otherwise processed
936 by any part of the GNAT compiler. This pragma is intended for use by
937 external tools, including ASIS@.
940 @unnumberedsec Pragma Assert
947 [, string_EXPRESSION]);
951 The effect of this pragma depends on whether the corresponding command
952 line switch is set to activate assertions. The pragma expands into code
953 equivalent to the following:
956 if assertions-enabled then
957 if not boolean_EXPRESSION then
958 System.Assertions.Raise_Assert_Failure
965 The string argument, if given, is the message that will be associated
966 with the exception occurrence if the exception is raised. If no second
967 argument is given, the default message is @samp{@var{file}:@var{nnn}},
968 where @var{file} is the name of the source file containing the assert,
969 and @var{nnn} is the line number of the assert. A pragma is not a
970 statement, so if a statement sequence contains nothing but a pragma
971 assert, then a null statement is required in addition, as in:
976 pragma Assert (K > 3, "Bad value for K");
982 Note that, as with the @code{if} statement to which it is equivalent, the
983 type of the expression is either @code{Standard.Boolean}, or any type derived
984 from this standard type.
986 If assertions are disabled (switch @option{-gnata} not used), then there
987 is no run-time effect (and in particular, any side effects from the
988 expression will not occur at run time). (The expression is still
989 analyzed at compile time, and may cause types to be frozen if they are
990 mentioned here for the first time).
992 If assertions are enabled, then the given expression is tested, and if
993 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
994 which results in the raising of @code{Assert_Failure} with the given message.
996 You should generally avoid side effects in the expression arguments of
997 this pragma, because these side effects will turn on and off with the
998 setting of the assertions mode, resulting in assertions that have an
999 effect on the program. However, the expressions are analyzed for
1000 semantic correctness whether or not assertions are enabled, so turning
1001 assertions on and off cannot affect the legality of a program.
1003 @node Pragma Assume_No_Invalid_Values
1004 @unnumberedsec Pragma Assume_No_Invalid_Values
1005 @findex Assume_No_Invalid_Values
1006 @cindex Invalid representations
1007 @cindex Invalid values
1010 @smallexample @c ada
1011 pragma Assume_No_Invalid_Values (On | Off);
1015 This is a configuration pragma that controls the assumptions made by the
1016 compiler about the occurrence of invalid representations (invalid values)
1019 The default behavior (corresponding to an Off argument for this pragma), is
1020 to assume that values may in general be invalid unless the compiler can
1021 prove they are valid. Consider the following example:
1023 @smallexample @c ada
1024 V1 : Integer range 1 .. 10;
1025 V2 : Integer range 11 .. 20;
1027 for J in V2 .. V1 loop
1033 if V1 and V2 have valid values, then the loop is known at compile
1034 time not to execute since the lower bound must be greater than the
1035 upper bound. However in default mode, no such assumption is made,
1036 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1037 is given, the compiler will assume that any occurrence of a variable
1038 other than in an explicit @code{'Valid} test always has a valid
1039 value, and the loop above will be optimized away.
1041 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1042 you know your code is free of uninitialized variables and other
1043 possible sources of invalid representations, and may result in
1044 more efficient code. A program that accesses an invalid representation
1045 with this pragma in effect is erroneous, so no guarantees can be made
1048 It is peculiar though permissible to use this pragma in conjunction
1049 with validity checking (-gnatVa). In such cases, accessing invalid
1050 values will generally give an exception, though formally the program
1051 is erroneous so there are no guarantees that this will always be the
1052 case, and it is recommended that these two options not be used together.
1054 @node Pragma Ast_Entry
1055 @unnumberedsec Pragma Ast_Entry
1060 @smallexample @c ada
1061 pragma AST_Entry (entry_IDENTIFIER);
1065 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1066 argument is the simple name of a single entry; at most one @code{AST_Entry}
1067 pragma is allowed for any given entry. This pragma must be used in
1068 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1069 the entry declaration and in the same task type specification or single task
1070 as the entry to which it applies. This pragma specifies that the given entry
1071 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1072 resulting from an OpenVMS system service call. The pragma does not affect
1073 normal use of the entry. For further details on this pragma, see the
1074 DEC Ada Language Reference Manual, section 9.12a.
1076 @node Pragma C_Pass_By_Copy
1077 @unnumberedsec Pragma C_Pass_By_Copy
1078 @cindex Passing by copy
1079 @findex C_Pass_By_Copy
1082 @smallexample @c ada
1083 pragma C_Pass_By_Copy
1084 ([Max_Size =>] static_integer_EXPRESSION);
1088 Normally the default mechanism for passing C convention records to C
1089 convention subprograms is to pass them by reference, as suggested by RM
1090 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1091 this default, by requiring that record formal parameters be passed by
1092 copy if all of the following conditions are met:
1096 The size of the record type does not exceed the value specified for
1099 The record type has @code{Convention C}.
1101 The formal parameter has this record type, and the subprogram has a
1102 foreign (non-Ada) convention.
1106 If these conditions are met the argument is passed by copy, i.e.@: in a
1107 manner consistent with what C expects if the corresponding formal in the
1108 C prototype is a struct (rather than a pointer to a struct).
1110 You can also pass records by copy by specifying the convention
1111 @code{C_Pass_By_Copy} for the record type, or by using the extended
1112 @code{Import} and @code{Export} pragmas, which allow specification of
1113 passing mechanisms on a parameter by parameter basis.
1116 @unnumberedsec Pragma Check
1118 @cindex Named assertions
1122 @smallexample @c ada
1124 [Name =>] Identifier,
1125 [Check =>] Boolean_EXPRESSION
1126 [, [Message =>] string_EXPRESSION] );
1130 This pragma is similar to the predefined pragma @code{Assert} except that an
1131 extra identifier argument is present. In conjunction with pragma
1132 @code{Check_Policy}, this can be used to define groups of assertions that can
1133 be independently controlled. The identifier @code{Assertion} is special, it
1134 refers to the normal set of pragma @code{Assert} statements. The identifiers
1135 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1136 names, so these three names would normally not be used directly in a pragma
1139 Checks introduced by this pragma are normally deactivated by default. They can
1140 be activated either by the command line option @option{-gnata}, which turns on
1141 all checks, or individually controlled using pragma @code{Check_Policy}.
1143 @node Pragma Check_Name
1144 @unnumberedsec Pragma Check_Name
1145 @cindex Defining check names
1146 @cindex Check names, defining
1150 @smallexample @c ada
1151 pragma Check_Name (check_name_IDENTIFIER);
1155 This is a configuration pragma that defines a new implementation
1156 defined check name (unless IDENTIFIER matches one of the predefined
1157 check names, in which case the pragma has no effect). Check names
1158 are global to a partition, so if two or more configuration pragmas
1159 are present in a partition mentioning the same name, only one new
1160 check name is introduced.
1162 An implementation defined check name introduced with this pragma may
1163 be used in only three contexts: @code{pragma Suppress},
1164 @code{pragma Unsuppress},
1165 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1166 any of these three cases, the check name must be visible. A check
1167 name is visible if it is in the configuration pragmas applying to
1168 the current unit, or if it appears at the start of any unit that
1169 is part of the dependency set of the current unit (e.g., units that
1170 are mentioned in @code{with} clauses).
1172 @node Pragma Check_Policy
1173 @unnumberedsec Pragma Check_Policy
1174 @cindex Controlling assertions
1175 @cindex Assertions, control
1176 @cindex Check pragma control
1177 @cindex Named assertions
1181 @smallexample @c ada
1183 ([Name =>] Identifier,
1184 [Policy =>] POLICY_IDENTIFIER);
1186 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1190 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1191 except that it controls sets of named assertions introduced using the
1192 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1193 @code{Assertion_Policy}) can be used within a declarative part, in which case
1194 it controls the status to the end of the corresponding construct (in a manner
1195 identical to pragma @code{Suppress)}.
1197 The identifier given as the first argument corresponds to a name used in
1198 associated @code{Check} pragmas. For example, if the pragma:
1200 @smallexample @c ada
1201 pragma Check_Policy (Critical_Error, Off);
1205 is given, then subsequent @code{Check} pragmas whose first argument is also
1206 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1207 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1208 @code{Check_Policy} with this identifier is similar to the normal
1209 @code{Assertion_Policy} pragma except that it can appear within a
1212 The special identifiers @code{Precondition} and @code{Postcondition} control
1213 the status of preconditions and postconditions. If a @code{Precondition} pragma
1214 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1215 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1216 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1219 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1220 to turn on corresponding checks. The default for a set of checks for which no
1221 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1222 @option{-gnata} is given, which turns on all checks by default.
1224 The check policy settings @code{Check} and @code{Ignore} are also recognized
1225 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1226 compatibility with the standard @code{Assertion_Policy} pragma.
1228 @node Pragma Comment
1229 @unnumberedsec Pragma Comment
1234 @smallexample @c ada
1235 pragma Comment (static_string_EXPRESSION);
1239 This is almost identical in effect to pragma @code{Ident}. It allows the
1240 placement of a comment into the object file and hence into the
1241 executable file if the operating system permits such usage. The
1242 difference is that @code{Comment}, unlike @code{Ident}, has
1243 no limitations on placement of the pragma (it can be placed
1244 anywhere in the main source unit), and if more than one pragma
1245 is used, all comments are retained.
1247 @node Pragma Common_Object
1248 @unnumberedsec Pragma Common_Object
1249 @findex Common_Object
1253 @smallexample @c ada
1254 pragma Common_Object (
1255 [Internal =>] LOCAL_NAME
1256 [, [External =>] EXTERNAL_SYMBOL]
1257 [, [Size =>] EXTERNAL_SYMBOL] );
1261 | static_string_EXPRESSION
1265 This pragma enables the shared use of variables stored in overlaid
1266 linker areas corresponding to the use of @code{COMMON}
1267 in Fortran. The single
1268 object @var{LOCAL_NAME} is assigned to the area designated by
1269 the @var{External} argument.
1270 You may define a record to correspond to a series
1271 of fields. The @var{Size} argument
1272 is syntax checked in GNAT, but otherwise ignored.
1274 @code{Common_Object} is not supported on all platforms. If no
1275 support is available, then the code generator will issue a message
1276 indicating that the necessary attribute for implementation of this
1277 pragma is not available.
1279 @node Pragma Compile_Time_Error
1280 @unnumberedsec Pragma Compile_Time_Error
1281 @findex Compile_Time_Error
1285 @smallexample @c ada
1286 pragma Compile_Time_Error
1287 (boolean_EXPRESSION, static_string_EXPRESSION);
1291 This pragma can be used to generate additional compile time
1293 is particularly useful in generics, where errors can be issued for
1294 specific problematic instantiations. The first parameter is a boolean
1295 expression. The pragma is effective only if the value of this expression
1296 is known at compile time, and has the value True. The set of expressions
1297 whose values are known at compile time includes all static boolean
1298 expressions, and also other values which the compiler can determine
1299 at compile time (e.g., the size of a record type set by an explicit
1300 size representation clause, or the value of a variable which was
1301 initialized to a constant and is known not to have been modified).
1302 If these conditions are met, an error message is generated using
1303 the value given as the second argument. This string value may contain
1304 embedded ASCII.LF characters to break the message into multiple lines.
1306 @node Pragma Compile_Time_Warning
1307 @unnumberedsec Pragma Compile_Time_Warning
1308 @findex Compile_Time_Warning
1312 @smallexample @c ada
1313 pragma Compile_Time_Warning
1314 (boolean_EXPRESSION, static_string_EXPRESSION);
1318 Same as pragma Compile_Time_Error, except a warning is issued instead
1319 of an error message. Note that if this pragma is used in a package that
1320 is with'ed by a client, the client will get the warning even though it
1321 is issued by a with'ed package (normally warnings in with'ed units are
1322 suppressed, but this is a special exception to that rule).
1324 One typical use is within a generic where compile time known characteristics
1325 of formal parameters are tested, and warnings given appropriately. Another use
1326 with a first parameter of True is to warn a client about use of a package,
1327 for example that it is not fully implemented.
1329 @node Pragma Complete_Representation
1330 @unnumberedsec Pragma Complete_Representation
1331 @findex Complete_Representation
1335 @smallexample @c ada
1336 pragma Complete_Representation;
1340 This pragma must appear immediately within a record representation
1341 clause. Typical placements are before the first component clause
1342 or after the last component clause. The effect is to give an error
1343 message if any component is missing a component clause. This pragma
1344 may be used to ensure that a record representation clause is
1345 complete, and that this invariant is maintained if fields are
1346 added to the record in the future.
1348 @node Pragma Complex_Representation
1349 @unnumberedsec Pragma Complex_Representation
1350 @findex Complex_Representation
1354 @smallexample @c ada
1355 pragma Complex_Representation
1356 ([Entity =>] LOCAL_NAME);
1360 The @var{Entity} argument must be the name of a record type which has
1361 two fields of the same floating-point type. The effect of this pragma is
1362 to force gcc to use the special internal complex representation form for
1363 this record, which may be more efficient. Note that this may result in
1364 the code for this type not conforming to standard ABI (application
1365 binary interface) requirements for the handling of record types. For
1366 example, in some environments, there is a requirement for passing
1367 records by pointer, and the use of this pragma may result in passing
1368 this type in floating-point registers.
1370 @node Pragma Component_Alignment
1371 @unnumberedsec Pragma Component_Alignment
1372 @cindex Alignments of components
1373 @findex Component_Alignment
1377 @smallexample @c ada
1378 pragma Component_Alignment (
1379 [Form =>] ALIGNMENT_CHOICE
1380 [, [Name =>] type_LOCAL_NAME]);
1382 ALIGNMENT_CHOICE ::=
1390 Specifies the alignment of components in array or record types.
1391 The meaning of the @var{Form} argument is as follows:
1394 @findex Component_Size
1395 @item Component_Size
1396 Aligns scalar components and subcomponents of the array or record type
1397 on boundaries appropriate to their inherent size (naturally
1398 aligned). For example, 1-byte components are aligned on byte boundaries,
1399 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1400 integer components are aligned on 4-byte boundaries and so on. These
1401 alignment rules correspond to the normal rules for C compilers on all
1402 machines except the VAX@.
1404 @findex Component_Size_4
1405 @item Component_Size_4
1406 Naturally aligns components with a size of four or fewer
1407 bytes. Components that are larger than 4 bytes are placed on the next
1410 @findex Storage_Unit
1412 Specifies that array or record components are byte aligned, i.e.@:
1413 aligned on boundaries determined by the value of the constant
1414 @code{System.Storage_Unit}.
1418 Specifies that array or record components are aligned on default
1419 boundaries, appropriate to the underlying hardware or operating system or
1420 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1421 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1422 the @code{Default} choice is the same as @code{Component_Size} (natural
1427 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1428 refer to a local record or array type, and the specified alignment
1429 choice applies to the specified type. The use of
1430 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1431 @code{Component_Alignment} pragma to be ignored. The use of
1432 @code{Component_Alignment} together with a record representation clause
1433 is only effective for fields not specified by the representation clause.
1435 If the @code{Name} parameter is absent, the pragma can be used as either
1436 a configuration pragma, in which case it applies to one or more units in
1437 accordance with the normal rules for configuration pragmas, or it can be
1438 used within a declarative part, in which case it applies to types that
1439 are declared within this declarative part, or within any nested scope
1440 within this declarative part. In either case it specifies the alignment
1441 to be applied to any record or array type which has otherwise standard
1444 If the alignment for a record or array type is not specified (using
1445 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1446 clause), the GNAT uses the default alignment as described previously.
1448 @node Pragma Convention_Identifier
1449 @unnumberedsec Pragma Convention_Identifier
1450 @findex Convention_Identifier
1451 @cindex Conventions, synonyms
1455 @smallexample @c ada
1456 pragma Convention_Identifier (
1457 [Name =>] IDENTIFIER,
1458 [Convention =>] convention_IDENTIFIER);
1462 This pragma provides a mechanism for supplying synonyms for existing
1463 convention identifiers. The @code{Name} identifier can subsequently
1464 be used as a synonym for the given convention in other pragmas (including
1465 for example pragma @code{Import} or another @code{Convention_Identifier}
1466 pragma). As an example of the use of this, suppose you had legacy code
1467 which used Fortran77 as the identifier for Fortran. Then the pragma:
1469 @smallexample @c ada
1470 pragma Convention_Identifier (Fortran77, Fortran);
1474 would allow the use of the convention identifier @code{Fortran77} in
1475 subsequent code, avoiding the need to modify the sources. As another
1476 example, you could use this to parametrize convention requirements
1477 according to systems. Suppose you needed to use @code{Stdcall} on
1478 windows systems, and @code{C} on some other system, then you could
1479 define a convention identifier @code{Library} and use a single
1480 @code{Convention_Identifier} pragma to specify which convention
1481 would be used system-wide.
1483 @node Pragma CPP_Class
1484 @unnumberedsec Pragma CPP_Class
1486 @cindex Interfacing with C++
1490 @smallexample @c ada
1491 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1495 The argument denotes an entity in the current declarative region that is
1496 declared as a tagged record type. It indicates that the type corresponds
1497 to an externally declared C++ class type, and is to be laid out the same
1498 way that C++ would lay out the type.
1500 Types for which @code{CPP_Class} is specified do not have assignment or
1501 equality operators defined (such operations can be imported or declared
1502 as subprograms as required). Initialization is allowed only by constructor
1503 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1504 limited if not explicitly declared as limited or derived from a limited
1505 type, and a warning is issued in that case.
1507 Pragma @code{CPP_Class} is intended primarily for automatic generation
1508 using an automatic binding generator tool.
1509 See @ref{Interfacing to C++} for related information.
1511 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1512 for backward compatibility but its functionality is available
1513 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1515 @node Pragma CPP_Constructor
1516 @unnumberedsec Pragma CPP_Constructor
1517 @cindex Interfacing with C++
1518 @findex CPP_Constructor
1522 @smallexample @c ada
1523 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1524 [, [External_Name =>] static_string_EXPRESSION ]
1525 [, [Link_Name =>] static_string_EXPRESSION ]);
1529 This pragma identifies an imported function (imported in the usual way
1530 with pragma @code{Import}) as corresponding to a C++ constructor. If
1531 @code{External_Name} and @code{Link_Name} are not specified then the
1532 @code{Entity} argument is a name that must have been previously mentioned
1533 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1534 must be of one of the following forms:
1538 @code{function @var{Fname} return @var{T}'Class}
1541 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1545 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1547 The first form is the default constructor, used when an object of type
1548 @var{T} is created on the Ada side with no explicit constructor. Other
1549 constructors (including the copy constructor, which is simply a special
1550 case of the second form in which the one and only argument is of type
1551 @var{T}), can only appear in two contexts:
1555 On the right side of an initialization of an object of type @var{T}.
1557 In an extension aggregate for an object of a type derived from @var{T}.
1561 Although the constructor is described as a function that returns a value
1562 on the Ada side, it is typically a procedure with an extra implicit
1563 argument (the object being initialized) at the implementation
1564 level. GNAT issues the appropriate call, whatever it is, to get the
1565 object properly initialized.
1567 In the case of derived objects, you may use one of two possible forms
1568 for declaring and creating an object:
1571 @item @code{New_Object : Derived_T}
1572 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1576 In the first case the default constructor is called and extension fields
1577 if any are initialized according to the default initialization
1578 expressions in the Ada declaration. In the second case, the given
1579 constructor is called and the extension aggregate indicates the explicit
1580 values of the extension fields.
1582 If no constructors are imported, it is impossible to create any objects
1583 on the Ada side. If no default constructor is imported, only the
1584 initialization forms using an explicit call to a constructor are
1587 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1588 using an automatic binding generator tool.
1589 See @ref{Interfacing to C++} for more related information.
1591 @node Pragma CPP_Virtual
1592 @unnumberedsec Pragma CPP_Virtual
1593 @cindex Interfacing to C++
1596 This pragma is now obsolete has has no effect because GNAT generates
1597 the same object layout than the G++ compiler.
1599 See @ref{Interfacing to C++} for related information.
1601 @node Pragma CPP_Vtable
1602 @unnumberedsec Pragma CPP_Vtable
1603 @cindex Interfacing with C++
1606 This pragma is now obsolete has has no effect because GNAT generates
1607 the same object layout than the G++ compiler.
1609 See @ref{Interfacing to C++} for related information.
1612 @unnumberedsec Pragma Debug
1617 @smallexample @c ada
1618 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1620 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1622 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1626 The procedure call argument has the syntactic form of an expression, meeting
1627 the syntactic requirements for pragmas.
1629 If debug pragmas are not enabled or if the condition is present and evaluates
1630 to False, this pragma has no effect. If debug pragmas are enabled, the
1631 semantics of the pragma is exactly equivalent to the procedure call statement
1632 corresponding to the argument with a terminating semicolon. Pragmas are
1633 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1634 intersperse calls to debug procedures in the middle of declarations. Debug
1635 pragmas can be enabled either by use of the command line switch @option{-gnata}
1636 or by use of the configuration pragma @code{Debug_Policy}.
1638 @node Pragma Debug_Policy
1639 @unnumberedsec Pragma Debug_Policy
1640 @findex Debug_Policy
1644 @smallexample @c ada
1645 pragma Debug_Policy (CHECK | IGNORE);
1649 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1650 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1651 This pragma overrides the effect of the @option{-gnata} switch on the
1654 @node Pragma Detect_Blocking
1655 @unnumberedsec Pragma Detect_Blocking
1656 @findex Detect_Blocking
1660 @smallexample @c ada
1661 pragma Detect_Blocking;
1665 This is a configuration pragma that forces the detection of potentially
1666 blocking operations within a protected operation, and to raise Program_Error
1669 @node Pragma Elaboration_Checks
1670 @unnumberedsec Pragma Elaboration_Checks
1671 @cindex Elaboration control
1672 @findex Elaboration_Checks
1676 @smallexample @c ada
1677 pragma Elaboration_Checks (Dynamic | Static);
1681 This is a configuration pragma that provides control over the
1682 elaboration model used by the compilation affected by the
1683 pragma. If the parameter is @code{Dynamic},
1684 then the dynamic elaboration
1685 model described in the Ada Reference Manual is used, as though
1686 the @option{-gnatE} switch had been specified on the command
1687 line. If the parameter is @code{Static}, then the default GNAT static
1688 model is used. This configuration pragma overrides the setting
1689 of the command line. For full details on the elaboration models
1690 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1691 gnat_ugn, @value{EDITION} User's Guide}.
1693 @node Pragma Eliminate
1694 @unnumberedsec Pragma Eliminate
1695 @cindex Elimination of unused subprograms
1700 @smallexample @c ada
1702 [Unit_Name =>] IDENTIFIER |
1703 SELECTED_COMPONENT);
1706 [Unit_Name =>] IDENTIFIER |
1708 [Entity =>] IDENTIFIER |
1709 SELECTED_COMPONENT |
1711 [,OVERLOADING_RESOLUTION]);
1713 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1716 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1719 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1721 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1722 Result_Type => result_SUBTYPE_NAME]
1724 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1725 SUBTYPE_NAME ::= STRING_VALUE
1727 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1728 SOURCE_TRACE ::= STRING_VALUE
1730 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1734 This pragma indicates that the given entity is not used outside the
1735 compilation unit it is defined in. The entity must be an explicitly declared
1736 subprogram; this includes generic subprogram instances and
1737 subprograms declared in generic package instances.
1739 If the entity to be eliminated is a library level subprogram, then
1740 the first form of pragma @code{Eliminate} is used with only a single argument.
1741 In this form, the @code{Unit_Name} argument specifies the name of the
1742 library level unit to be eliminated.
1744 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1745 are required. If item is an entity of a library package, then the first
1746 argument specifies the unit name, and the second argument specifies
1747 the particular entity. If the second argument is in string form, it must
1748 correspond to the internal manner in which GNAT stores entity names (see
1749 compilation unit Namet in the compiler sources for details).
1751 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1752 to distinguish between overloaded subprograms. If a pragma does not contain
1753 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1754 subprograms denoted by the first two parameters.
1756 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1757 to be eliminated in a manner similar to that used for the extended
1758 @code{Import} and @code{Export} pragmas, except that the subtype names are
1759 always given as strings. At the moment, this form of distinguishing
1760 overloaded subprograms is implemented only partially, so we do not recommend
1761 using it for practical subprogram elimination.
1763 Note that in case of a parameterless procedure its profile is represented
1764 as @code{Parameter_Types => ("")}
1766 Alternatively, the @code{Source_Location} parameter is used to specify
1767 which overloaded alternative is to be eliminated by pointing to the
1768 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1769 source text. The string literal (or concatenation of string literals)
1770 given as SOURCE_TRACE must have the following format:
1772 @smallexample @c ada
1773 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1778 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1779 FILE_NAME ::= STRING_LITERAL
1780 LINE_NUMBER ::= DIGIT @{DIGIT@}
1783 SOURCE_TRACE should be the short name of the source file (with no directory
1784 information), and LINE_NUMBER is supposed to point to the line where the
1785 defining name of the subprogram is located.
1787 For the subprograms that are not a part of generic instantiations, only one
1788 SOURCE_LOCATION is used. If a subprogram is declared in a package
1789 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1790 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1791 second one denotes the declaration of the corresponding subprogram in the
1792 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1793 in case of nested instantiations.
1795 The effect of the pragma is to allow the compiler to eliminate
1796 the code or data associated with the named entity. Any reference to
1797 an eliminated entity outside the compilation unit it is defined in,
1798 causes a compile time or link time error.
1800 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1801 in a system independent manner, with unused entities eliminated, without
1802 the requirement of modifying the source text. Normally the required set
1803 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1804 tool. Elimination of unused entities local to a compilation unit is
1805 automatic, without requiring the use of pragma @code{Eliminate}.
1807 Note that the reason this pragma takes string literals where names might
1808 be expected is that a pragma @code{Eliminate} can appear in a context where the
1809 relevant names are not visible.
1811 Note that any change in the source files that includes removing, splitting of
1812 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1815 It is legal to use pragma Eliminate where the referenced entity is a
1816 dispatching operation, but it is not clear what this would mean, since
1817 in general the call does not know which entity is actually being called.
1818 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1820 @node Pragma Export_Exception
1821 @unnumberedsec Pragma Export_Exception
1823 @findex Export_Exception
1827 @smallexample @c ada
1828 pragma Export_Exception (
1829 [Internal =>] LOCAL_NAME
1830 [, [External =>] EXTERNAL_SYMBOL]
1831 [, [Form =>] Ada | VMS]
1832 [, [Code =>] static_integer_EXPRESSION]);
1836 | static_string_EXPRESSION
1840 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1841 causes the specified exception to be propagated outside of the Ada program,
1842 so that it can be handled by programs written in other OpenVMS languages.
1843 This pragma establishes an external name for an Ada exception and makes the
1844 name available to the OpenVMS Linker as a global symbol. For further details
1845 on this pragma, see the
1846 DEC Ada Language Reference Manual, section 13.9a3.2.
1848 @node Pragma Export_Function
1849 @unnumberedsec Pragma Export_Function
1850 @cindex Argument passing mechanisms
1851 @findex Export_Function
1856 @smallexample @c ada
1857 pragma Export_Function (
1858 [Internal =>] LOCAL_NAME
1859 [, [External =>] EXTERNAL_SYMBOL]
1860 [, [Parameter_Types =>] PARAMETER_TYPES]
1861 [, [Result_Type =>] result_SUBTYPE_MARK]
1862 [, [Mechanism =>] MECHANISM]
1863 [, [Result_Mechanism =>] MECHANISM_NAME]);
1867 | static_string_EXPRESSION
1872 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1876 | subtype_Name ' Access
1880 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1882 MECHANISM_ASSOCIATION ::=
1883 [formal_parameter_NAME =>] MECHANISM_NAME
1888 | Descriptor [([Class =>] CLASS_NAME)]
1889 | Short_Descriptor [([Class =>] CLASS_NAME)]
1891 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1895 Use this pragma to make a function externally callable and optionally
1896 provide information on mechanisms to be used for passing parameter and
1897 result values. We recommend, for the purposes of improving portability,
1898 this pragma always be used in conjunction with a separate pragma
1899 @code{Export}, which must precede the pragma @code{Export_Function}.
1900 GNAT does not require a separate pragma @code{Export}, but if none is
1901 present, @code{Convention Ada} is assumed, which is usually
1902 not what is wanted, so it is usually appropriate to use this
1903 pragma in conjunction with a @code{Export} or @code{Convention}
1904 pragma that specifies the desired foreign convention.
1905 Pragma @code{Export_Function}
1906 (and @code{Export}, if present) must appear in the same declarative
1907 region as the function to which they apply.
1909 @var{internal_name} must uniquely designate the function to which the
1910 pragma applies. If more than one function name exists of this name in
1911 the declarative part you must use the @code{Parameter_Types} and
1912 @code{Result_Type} parameters is mandatory to achieve the required
1913 unique designation. @var{subtype_mark}s in these parameters must
1914 exactly match the subtypes in the corresponding function specification,
1915 using positional notation to match parameters with subtype marks.
1916 The form with an @code{'Access} attribute can be used to match an
1917 anonymous access parameter.
1920 @cindex Passing by descriptor
1921 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1922 The default behavior for Export_Function is to accept either 64bit or
1923 32bit descriptors unless short_descriptor is specified, then only 32bit
1924 descriptors are accepted.
1926 @cindex Suppressing external name
1927 Special treatment is given if the EXTERNAL is an explicit null
1928 string or a static string expressions that evaluates to the null
1929 string. In this case, no external name is generated. This form
1930 still allows the specification of parameter mechanisms.
1932 @node Pragma Export_Object
1933 @unnumberedsec Pragma Export_Object
1934 @findex Export_Object
1938 @smallexample @c ada
1939 pragma Export_Object
1940 [Internal =>] LOCAL_NAME
1941 [, [External =>] EXTERNAL_SYMBOL]
1942 [, [Size =>] EXTERNAL_SYMBOL]
1946 | static_string_EXPRESSION
1950 This pragma designates an object as exported, and apart from the
1951 extended rules for external symbols, is identical in effect to the use of
1952 the normal @code{Export} pragma applied to an object. You may use a
1953 separate Export pragma (and you probably should from the point of view
1954 of portability), but it is not required. @var{Size} is syntax checked,
1955 but otherwise ignored by GNAT@.
1957 @node Pragma Export_Procedure
1958 @unnumberedsec Pragma Export_Procedure
1959 @findex Export_Procedure
1963 @smallexample @c ada
1964 pragma Export_Procedure (
1965 [Internal =>] LOCAL_NAME
1966 [, [External =>] EXTERNAL_SYMBOL]
1967 [, [Parameter_Types =>] PARAMETER_TYPES]
1968 [, [Mechanism =>] MECHANISM]);
1972 | static_string_EXPRESSION
1977 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1981 | subtype_Name ' Access
1985 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1987 MECHANISM_ASSOCIATION ::=
1988 [formal_parameter_NAME =>] MECHANISM_NAME
1993 | Descriptor [([Class =>] CLASS_NAME)]
1994 | Short_Descriptor [([Class =>] CLASS_NAME)]
1996 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2000 This pragma is identical to @code{Export_Function} except that it
2001 applies to a procedure rather than a function and the parameters
2002 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2003 GNAT does not require a separate pragma @code{Export}, but if none is
2004 present, @code{Convention Ada} is assumed, which is usually
2005 not what is wanted, so it is usually appropriate to use this
2006 pragma in conjunction with a @code{Export} or @code{Convention}
2007 pragma that specifies the desired foreign convention.
2010 @cindex Passing by descriptor
2011 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2012 The default behavior for Export_Procedure is to accept either 64bit or
2013 32bit descriptors unless short_descriptor is specified, then only 32bit
2014 descriptors are accepted.
2016 @cindex Suppressing external name
2017 Special treatment is given if the EXTERNAL is an explicit null
2018 string or a static string expressions that evaluates to the null
2019 string. In this case, no external name is generated. This form
2020 still allows the specification of parameter mechanisms.
2022 @node Pragma Export_Value
2023 @unnumberedsec Pragma Export_Value
2024 @findex Export_Value
2028 @smallexample @c ada
2029 pragma Export_Value (
2030 [Value =>] static_integer_EXPRESSION,
2031 [Link_Name =>] static_string_EXPRESSION);
2035 This pragma serves to export a static integer value for external use.
2036 The first argument specifies the value to be exported. The Link_Name
2037 argument specifies the symbolic name to be associated with the integer
2038 value. This pragma is useful for defining a named static value in Ada
2039 that can be referenced in assembly language units to be linked with
2040 the application. This pragma is currently supported only for the
2041 AAMP target and is ignored for other targets.
2043 @node Pragma Export_Valued_Procedure
2044 @unnumberedsec Pragma Export_Valued_Procedure
2045 @findex Export_Valued_Procedure
2049 @smallexample @c ada
2050 pragma Export_Valued_Procedure (
2051 [Internal =>] LOCAL_NAME
2052 [, [External =>] EXTERNAL_SYMBOL]
2053 [, [Parameter_Types =>] PARAMETER_TYPES]
2054 [, [Mechanism =>] MECHANISM]);
2058 | static_string_EXPRESSION
2063 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2067 | subtype_Name ' Access
2071 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2073 MECHANISM_ASSOCIATION ::=
2074 [formal_parameter_NAME =>] MECHANISM_NAME
2079 | Descriptor [([Class =>] CLASS_NAME)]
2080 | Short_Descriptor [([Class =>] CLASS_NAME)]
2082 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2086 This pragma is identical to @code{Export_Procedure} except that the
2087 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2088 mode @code{OUT}, and externally the subprogram is treated as a function
2089 with this parameter as the result of the function. GNAT provides for
2090 this capability to allow the use of @code{OUT} and @code{IN OUT}
2091 parameters in interfacing to external functions (which are not permitted
2093 GNAT does not require a separate pragma @code{Export}, but if none is
2094 present, @code{Convention Ada} is assumed, which is almost certainly
2095 not what is wanted since the whole point of this pragma is to interface
2096 with foreign language functions, so it is usually appropriate to use this
2097 pragma in conjunction with a @code{Export} or @code{Convention}
2098 pragma that specifies the desired foreign convention.
2101 @cindex Passing by descriptor
2102 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2103 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2104 32bit descriptors unless short_descriptor is specified, then only 32bit
2105 descriptors are accepted.
2107 @cindex Suppressing external name
2108 Special treatment is given if the EXTERNAL is an explicit null
2109 string or a static string expressions that evaluates to the null
2110 string. In this case, no external name is generated. This form
2111 still allows the specification of parameter mechanisms.
2113 @node Pragma Extend_System
2114 @unnumberedsec Pragma Extend_System
2115 @cindex @code{system}, extending
2117 @findex Extend_System
2121 @smallexample @c ada
2122 pragma Extend_System ([Name =>] IDENTIFIER);
2126 This pragma is used to provide backwards compatibility with other
2127 implementations that extend the facilities of package @code{System}. In
2128 GNAT, @code{System} contains only the definitions that are present in
2129 the Ada RM@. However, other implementations, notably the DEC Ada 83
2130 implementation, provide many extensions to package @code{System}.
2132 For each such implementation accommodated by this pragma, GNAT provides a
2133 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2134 implementation, which provides the required additional definitions. You
2135 can use this package in two ways. You can @code{with} it in the normal
2136 way and access entities either by selection or using a @code{use}
2137 clause. In this case no special processing is required.
2139 However, if existing code contains references such as
2140 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2141 definitions provided in package @code{System}, you may use this pragma
2142 to extend visibility in @code{System} in a non-standard way that
2143 provides greater compatibility with the existing code. Pragma
2144 @code{Extend_System} is a configuration pragma whose single argument is
2145 the name of the package containing the extended definition
2146 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2147 control of this pragma will be processed using special visibility
2148 processing that looks in package @code{System.Aux_@var{xxx}} where
2149 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2150 package @code{System}, but not found in package @code{System}.
2152 You can use this pragma either to access a predefined @code{System}
2153 extension supplied with the compiler, for example @code{Aux_DEC} or
2154 you can construct your own extension unit following the above
2155 definition. Note that such a package is a child of @code{System}
2156 and thus is considered part of the implementation. To compile
2157 it you will have to use the appropriate switch for compiling
2158 system units. @xref{Top, @value{EDITION} User's Guide, About This
2159 Guide,, gnat_ugn, @value{EDITION} User's Guide}, for details.
2161 @node Pragma External
2162 @unnumberedsec Pragma External
2167 @smallexample @c ada
2169 [ Convention =>] convention_IDENTIFIER,
2170 [ Entity =>] LOCAL_NAME
2171 [, [External_Name =>] static_string_EXPRESSION ]
2172 [, [Link_Name =>] static_string_EXPRESSION ]);
2176 This pragma is identical in syntax and semantics to pragma
2177 @code{Export} as defined in the Ada Reference Manual. It is
2178 provided for compatibility with some Ada 83 compilers that
2179 used this pragma for exactly the same purposes as pragma
2180 @code{Export} before the latter was standardized.
2182 @node Pragma External_Name_Casing
2183 @unnumberedsec Pragma External_Name_Casing
2184 @cindex Dec Ada 83 casing compatibility
2185 @cindex External Names, casing
2186 @cindex Casing of External names
2187 @findex External_Name_Casing
2191 @smallexample @c ada
2192 pragma External_Name_Casing (
2193 Uppercase | Lowercase
2194 [, Uppercase | Lowercase | As_Is]);
2198 This pragma provides control over the casing of external names associated
2199 with Import and Export pragmas. There are two cases to consider:
2202 @item Implicit external names
2203 Implicit external names are derived from identifiers. The most common case
2204 arises when a standard Ada Import or Export pragma is used with only two
2207 @smallexample @c ada
2208 pragma Import (C, C_Routine);
2212 Since Ada is a case-insensitive language, the spelling of the identifier in
2213 the Ada source program does not provide any information on the desired
2214 casing of the external name, and so a convention is needed. In GNAT the
2215 default treatment is that such names are converted to all lower case
2216 letters. This corresponds to the normal C style in many environments.
2217 The first argument of pragma @code{External_Name_Casing} can be used to
2218 control this treatment. If @code{Uppercase} is specified, then the name
2219 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2220 then the normal default of all lower case letters will be used.
2222 This same implicit treatment is also used in the case of extended DEC Ada 83
2223 compatible Import and Export pragmas where an external name is explicitly
2224 specified using an identifier rather than a string.
2226 @item Explicit external names
2227 Explicit external names are given as string literals. The most common case
2228 arises when a standard Ada Import or Export pragma is used with three
2231 @smallexample @c ada
2232 pragma Import (C, C_Routine, "C_routine");
2236 In this case, the string literal normally provides the exact casing required
2237 for the external name. The second argument of pragma
2238 @code{External_Name_Casing} may be used to modify this behavior.
2239 If @code{Uppercase} is specified, then the name
2240 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2241 then the name will be forced to all lowercase letters. A specification of
2242 @code{As_Is} provides the normal default behavior in which the casing is
2243 taken from the string provided.
2247 This pragma may appear anywhere that a pragma is valid. In particular, it
2248 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2249 case it applies to all subsequent compilations, or it can be used as a program
2250 unit pragma, in which case it only applies to the current unit, or it can
2251 be used more locally to control individual Import/Export pragmas.
2253 It is primarily intended for use with OpenVMS systems, where many
2254 compilers convert all symbols to upper case by default. For interfacing to
2255 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2258 @smallexample @c ada
2259 pragma External_Name_Casing (Uppercase, Uppercase);
2263 to enforce the upper casing of all external symbols.
2265 @node Pragma Fast_Math
2266 @unnumberedsec Pragma Fast_Math
2271 @smallexample @c ada
2276 This is a configuration pragma which activates a mode in which speed is
2277 considered more important for floating-point operations than absolutely
2278 accurate adherence to the requirements of the standard. Currently the
2279 following operations are affected:
2282 @item Complex Multiplication
2283 The normal simple formula for complex multiplication can result in intermediate
2284 overflows for numbers near the end of the range. The Ada standard requires that
2285 this situation be detected and corrected by scaling, but in Fast_Math mode such
2286 cases will simply result in overflow. Note that to take advantage of this you
2287 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2288 under control of the pragma, rather than use the preinstantiated versions.
2291 @node Pragma Favor_Top_Level
2292 @unnumberedsec Pragma Favor_Top_Level
2293 @findex Favor_Top_Level
2297 @smallexample @c ada
2298 pragma Favor_Top_Level (type_NAME);
2302 The named type must be an access-to-subprogram type. This pragma is an
2303 efficiency hint to the compiler, regarding the use of 'Access or
2304 'Unrestricted_Access on nested (non-library-level) subprograms. The
2305 pragma means that nested subprograms are not used with this type, or
2306 are rare, so that the generated code should be efficient in the
2307 top-level case. When this pragma is used, dynamically generated
2308 trampolines may be used on some targets for nested subprograms.
2309 See also the No_Implicit_Dynamic_Code restriction.
2311 @node Pragma Finalize_Storage_Only
2312 @unnumberedsec Pragma Finalize_Storage_Only
2313 @findex Finalize_Storage_Only
2317 @smallexample @c ada
2318 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2322 This pragma allows the compiler not to emit a Finalize call for objects
2323 defined at the library level. This is mostly useful for types where
2324 finalization is only used to deal with storage reclamation since in most
2325 environments it is not necessary to reclaim memory just before terminating
2326 execution, hence the name.
2328 @node Pragma Float_Representation
2329 @unnumberedsec Pragma Float_Representation
2331 @findex Float_Representation
2335 @smallexample @c ada
2336 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2338 FLOAT_REP ::= VAX_Float | IEEE_Float
2342 In the one argument form, this pragma is a configuration pragma which
2343 allows control over the internal representation chosen for the predefined
2344 floating point types declared in the packages @code{Standard} and
2345 @code{System}. On all systems other than OpenVMS, the argument must
2346 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2347 argument may be @code{VAX_Float} to specify the use of the VAX float
2348 format for the floating-point types in Standard. This requires that
2349 the standard runtime libraries be recompiled. @xref{The GNAT Run-Time
2350 Library Builder gnatlbr,,, gnat_ugn, @value{EDITION} User's Guide
2351 OpenVMS}, for a description of the @code{GNAT LIBRARY} command.
2353 The two argument form specifies the representation to be used for
2354 the specified floating-point type. On all systems other than OpenVMS,
2356 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2357 argument may be @code{VAX_Float} to specify the use of the VAX float
2362 For digits values up to 6, F float format will be used.
2364 For digits values from 7 to 9, G float format will be used.
2366 For digits values from 10 to 15, F float format will be used.
2368 Digits values above 15 are not allowed.
2372 @unnumberedsec Pragma Ident
2377 @smallexample @c ada
2378 pragma Ident (static_string_EXPRESSION);
2382 This pragma provides a string identification in the generated object file,
2383 if the system supports the concept of this kind of identification string.
2384 This pragma is allowed only in the outermost declarative part or
2385 declarative items of a compilation unit. If more than one @code{Ident}
2386 pragma is given, only the last one processed is effective.
2388 On OpenVMS systems, the effect of the pragma is identical to the effect of
2389 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2390 maximum allowed length is 31 characters, so if it is important to
2391 maintain compatibility with this compiler, you should obey this length
2394 @node Pragma Implemented_By_Entry
2395 @unnumberedsec Pragma Implemented_By_Entry
2396 @findex Implemented_By_Entry
2400 @smallexample @c ada
2401 pragma Implemented_By_Entry (LOCAL_NAME);
2405 This is a representation pragma which applies to protected, synchronized and
2406 task interface primitives. If the pragma is applied to primitive operation Op
2407 of interface Iface, it is illegal to override Op in a type that implements
2408 Iface, with anything other than an entry.
2410 @smallexample @c ada
2411 type Iface is protected interface;
2412 procedure Do_Something (Object : in out Iface) is abstract;
2413 pragma Implemented_By_Entry (Do_Something);
2415 protected type P is new Iface with
2416 procedure Do_Something; -- Illegal
2419 task type T is new Iface with
2420 entry Do_Something; -- Legal
2425 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2426 is intended to be used in conjunction with dispatching requeue statements as
2427 described in AI05-0030. Should the ARG decide on an official name and syntax,
2428 this pragma will become language-defined rather than GNAT-specific.
2430 @node Pragma Implicit_Packing
2431 @unnumberedsec Pragma Implicit_Packing
2432 @findex Implicit_Packing
2436 @smallexample @c ada
2437 pragma Implicit_Packing;
2441 This is a configuration pragma that requests implicit packing for packed
2442 arrays for which a size clause is given but no explicit pragma Pack or
2443 specification of Component_Size is present. Consider this example:
2445 @smallexample @c ada
2446 type R is array (0 .. 7) of Boolean;
2451 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2452 does not change the layout of a composite object. So the Size clause in the
2453 above example is normally rejected, since the default layout of the array uses
2454 8-bit components, and thus the array requires a minimum of 64 bits.
2456 If this declaration is compiled in a region of code covered by an occurrence
2457 of the configuration pragma Implicit_Packing, then the Size clause in this
2458 and similar examples will cause implicit packing and thus be accepted. For
2459 this implicit packing to occur, the type in question must be an array of small
2460 components whose size is known at compile time, and the Size clause must
2461 specify the exact size that corresponds to the length of the array multiplied
2462 by the size in bits of the component type.
2463 @cindex Array packing
2465 @node Pragma Import_Exception
2466 @unnumberedsec Pragma Import_Exception
2468 @findex Import_Exception
2472 @smallexample @c ada
2473 pragma Import_Exception (
2474 [Internal =>] LOCAL_NAME
2475 [, [External =>] EXTERNAL_SYMBOL]
2476 [, [Form =>] Ada | VMS]
2477 [, [Code =>] static_integer_EXPRESSION]);
2481 | static_string_EXPRESSION
2485 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2486 It allows OpenVMS conditions (for example, from OpenVMS system services or
2487 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2488 The pragma specifies that the exception associated with an exception
2489 declaration in an Ada program be defined externally (in non-Ada code).
2490 For further details on this pragma, see the
2491 DEC Ada Language Reference Manual, section 13.9a.3.1.
2493 @node Pragma Import_Function
2494 @unnumberedsec Pragma Import_Function
2495 @findex Import_Function
2499 @smallexample @c ada
2500 pragma Import_Function (
2501 [Internal =>] LOCAL_NAME,
2502 [, [External =>] EXTERNAL_SYMBOL]
2503 [, [Parameter_Types =>] PARAMETER_TYPES]
2504 [, [Result_Type =>] SUBTYPE_MARK]
2505 [, [Mechanism =>] MECHANISM]
2506 [, [Result_Mechanism =>] MECHANISM_NAME]
2507 [, [First_Optional_Parameter =>] IDENTIFIER]);
2511 | static_string_EXPRESSION
2515 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2519 | subtype_Name ' Access
2523 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2525 MECHANISM_ASSOCIATION ::=
2526 [formal_parameter_NAME =>] MECHANISM_NAME
2531 | Descriptor [([Class =>] CLASS_NAME)]
2532 | Short_Descriptor [([Class =>] CLASS_NAME)]
2534 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2538 This pragma is used in conjunction with a pragma @code{Import} to
2539 specify additional information for an imported function. The pragma
2540 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2541 @code{Import_Function} pragma and both must appear in the same
2542 declarative part as the function specification.
2544 The @var{Internal} argument must uniquely designate
2545 the function to which the
2546 pragma applies. If more than one function name exists of this name in
2547 the declarative part you must use the @code{Parameter_Types} and
2548 @var{Result_Type} parameters to achieve the required unique
2549 designation. Subtype marks in these parameters must exactly match the
2550 subtypes in the corresponding function specification, using positional
2551 notation to match parameters with subtype marks.
2552 The form with an @code{'Access} attribute can be used to match an
2553 anonymous access parameter.
2555 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2556 parameters to specify passing mechanisms for the
2557 parameters and result. If you specify a single mechanism name, it
2558 applies to all parameters. Otherwise you may specify a mechanism on a
2559 parameter by parameter basis using either positional or named
2560 notation. If the mechanism is not specified, the default mechanism
2564 @cindex Passing by descriptor
2565 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2566 The default behavior for Import_Function is to pass a 64bit descriptor
2567 unless short_descriptor is specified, then a 32bit descriptor is passed.
2569 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2570 It specifies that the designated parameter and all following parameters
2571 are optional, meaning that they are not passed at the generated code
2572 level (this is distinct from the notion of optional parameters in Ada
2573 where the parameters are passed anyway with the designated optional
2574 parameters). All optional parameters must be of mode @code{IN} and have
2575 default parameter values that are either known at compile time
2576 expressions, or uses of the @code{'Null_Parameter} attribute.
2578 @node Pragma Import_Object
2579 @unnumberedsec Pragma Import_Object
2580 @findex Import_Object
2584 @smallexample @c ada
2585 pragma Import_Object
2586 [Internal =>] LOCAL_NAME
2587 [, [External =>] EXTERNAL_SYMBOL]
2588 [, [Size =>] EXTERNAL_SYMBOL]);
2592 | static_string_EXPRESSION
2596 This pragma designates an object as imported, and apart from the
2597 extended rules for external symbols, is identical in effect to the use of
2598 the normal @code{Import} pragma applied to an object. Unlike the
2599 subprogram case, you need not use a separate @code{Import} pragma,
2600 although you may do so (and probably should do so from a portability
2601 point of view). @var{size} is syntax checked, but otherwise ignored by
2604 @node Pragma Import_Procedure
2605 @unnumberedsec Pragma Import_Procedure
2606 @findex Import_Procedure
2610 @smallexample @c ada
2611 pragma Import_Procedure (
2612 [Internal =>] LOCAL_NAME
2613 [, [External =>] EXTERNAL_SYMBOL]
2614 [, [Parameter_Types =>] PARAMETER_TYPES]
2615 [, [Mechanism =>] MECHANISM]
2616 [, [First_Optional_Parameter =>] IDENTIFIER]);
2620 | static_string_EXPRESSION
2624 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2628 | subtype_Name ' Access
2632 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2634 MECHANISM_ASSOCIATION ::=
2635 [formal_parameter_NAME =>] MECHANISM_NAME
2640 | Descriptor [([Class =>] CLASS_NAME)]
2641 | Short_Descriptor [([Class =>] CLASS_NAME)]
2643 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2647 This pragma is identical to @code{Import_Function} except that it
2648 applies to a procedure rather than a function and the parameters
2649 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2651 @node Pragma Import_Valued_Procedure
2652 @unnumberedsec Pragma Import_Valued_Procedure
2653 @findex Import_Valued_Procedure
2657 @smallexample @c ada
2658 pragma Import_Valued_Procedure (
2659 [Internal =>] LOCAL_NAME
2660 [, [External =>] EXTERNAL_SYMBOL]
2661 [, [Parameter_Types =>] PARAMETER_TYPES]
2662 [, [Mechanism =>] MECHANISM]
2663 [, [First_Optional_Parameter =>] IDENTIFIER]);
2667 | static_string_EXPRESSION
2671 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2675 | subtype_Name ' Access
2679 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2681 MECHANISM_ASSOCIATION ::=
2682 [formal_parameter_NAME =>] MECHANISM_NAME
2687 | Descriptor [([Class =>] CLASS_NAME)]
2688 | Short_Descriptor [([Class =>] CLASS_NAME)]
2690 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2694 This pragma is identical to @code{Import_Procedure} except that the
2695 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2696 mode @code{OUT}, and externally the subprogram is treated as a function
2697 with this parameter as the result of the function. The purpose of this
2698 capability is to allow the use of @code{OUT} and @code{IN OUT}
2699 parameters in interfacing to external functions (which are not permitted
2700 in Ada functions). You may optionally use the @code{Mechanism}
2701 parameters to specify passing mechanisms for the parameters.
2702 If you specify a single mechanism name, it applies to all parameters.
2703 Otherwise you may specify a mechanism on a parameter by parameter
2704 basis using either positional or named notation. If the mechanism is not
2705 specified, the default mechanism is used.
2707 Note that it is important to use this pragma in conjunction with a separate
2708 pragma Import that specifies the desired convention, since otherwise the
2709 default convention is Ada, which is almost certainly not what is required.
2711 @node Pragma Initialize_Scalars
2712 @unnumberedsec Pragma Initialize_Scalars
2713 @findex Initialize_Scalars
2714 @cindex debugging with Initialize_Scalars
2718 @smallexample @c ada
2719 pragma Initialize_Scalars;
2723 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2724 two important differences. First, there is no requirement for the pragma
2725 to be used uniformly in all units of a partition, in particular, it is fine
2726 to use this just for some or all of the application units of a partition,
2727 without needing to recompile the run-time library.
2729 In the case where some units are compiled with the pragma, and some without,
2730 then a declaration of a variable where the type is defined in package
2731 Standard or is locally declared will always be subject to initialization,
2732 as will any declaration of a scalar variable. For composite variables,
2733 whether the variable is initialized may also depend on whether the package
2734 in which the type of the variable is declared is compiled with the pragma.
2736 The other important difference is that you can control the value used
2737 for initializing scalar objects. At bind time, you can select several
2738 options for initialization. You can
2739 initialize with invalid values (similar to Normalize_Scalars, though for
2740 Initialize_Scalars it is not always possible to determine the invalid
2741 values in complex cases like signed component fields with non-standard
2742 sizes). You can also initialize with high or
2743 low values, or with a specified bit pattern. See the users guide for binder
2744 options for specifying these cases.
2746 This means that you can compile a program, and then without having to
2747 recompile the program, you can run it with different values being used
2748 for initializing otherwise uninitialized values, to test if your program
2749 behavior depends on the choice. Of course the behavior should not change,
2750 and if it does, then most likely you have an erroneous reference to an
2751 uninitialized value.
2753 It is even possible to change the value at execution time eliminating even
2754 the need to rebind with a different switch using an environment variable.
2755 See the GNAT users guide for details.
2757 Note that pragma @code{Initialize_Scalars} is particularly useful in
2758 conjunction with the enhanced validity checking that is now provided
2759 in GNAT, which checks for invalid values under more conditions.
2760 Using this feature (see description of the @option{-gnatV} flag in the
2761 users guide) in conjunction with pragma @code{Initialize_Scalars}
2762 provides a powerful new tool to assist in the detection of problems
2763 caused by uninitialized variables.
2765 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2766 effect on the generated code. This may cause your code to be
2767 substantially larger. It may also cause an increase in the amount
2768 of stack required, so it is probably a good idea to turn on stack
2769 checking (see description of stack checking in the GNAT users guide)
2770 when using this pragma.
2772 @node Pragma Inline_Always
2773 @unnumberedsec Pragma Inline_Always
2774 @findex Inline_Always
2778 @smallexample @c ada
2779 pragma Inline_Always (NAME [, NAME]);
2783 Similar to pragma @code{Inline} except that inlining is not subject to
2784 the use of option @option{-gnatn} and the inlining happens regardless of
2785 whether this option is used.
2787 @node Pragma Inline_Generic
2788 @unnumberedsec Pragma Inline_Generic
2789 @findex Inline_Generic
2793 @smallexample @c ada
2794 pragma Inline_Generic (generic_package_NAME);
2798 This is implemented for compatibility with DEC Ada 83 and is recognized,
2799 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2800 by default when using GNAT@.
2802 @node Pragma Interface
2803 @unnumberedsec Pragma Interface
2808 @smallexample @c ada
2810 [Convention =>] convention_identifier,
2811 [Entity =>] local_NAME
2812 [, [External_Name =>] static_string_expression]
2813 [, [Link_Name =>] static_string_expression]);
2817 This pragma is identical in syntax and semantics to
2818 the standard Ada pragma @code{Import}. It is provided for compatibility
2819 with Ada 83. The definition is upwards compatible both with pragma
2820 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2821 with some extended implementations of this pragma in certain Ada 83
2824 @node Pragma Interface_Name
2825 @unnumberedsec Pragma Interface_Name
2826 @findex Interface_Name
2830 @smallexample @c ada
2831 pragma Interface_Name (
2832 [Entity =>] LOCAL_NAME
2833 [, [External_Name =>] static_string_EXPRESSION]
2834 [, [Link_Name =>] static_string_EXPRESSION]);
2838 This pragma provides an alternative way of specifying the interface name
2839 for an interfaced subprogram, and is provided for compatibility with Ada
2840 83 compilers that use the pragma for this purpose. You must provide at
2841 least one of @var{External_Name} or @var{Link_Name}.
2843 @node Pragma Interrupt_Handler
2844 @unnumberedsec Pragma Interrupt_Handler
2845 @findex Interrupt_Handler
2849 @smallexample @c ada
2850 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2854 This program unit pragma is supported for parameterless protected procedures
2855 as described in Annex C of the Ada Reference Manual. On the AAMP target
2856 the pragma can also be specified for nonprotected parameterless procedures
2857 that are declared at the library level (which includes procedures
2858 declared at the top level of a library package). In the case of AAMP,
2859 when this pragma is applied to a nonprotected procedure, the instruction
2860 @code{IERET} is generated for returns from the procedure, enabling
2861 maskable interrupts, in place of the normal return instruction.
2863 @node Pragma Interrupt_State
2864 @unnumberedsec Pragma Interrupt_State
2865 @findex Interrupt_State
2869 @smallexample @c ada
2870 pragma Interrupt_State
2872 [State =>] SYSTEM | RUNTIME | USER);
2876 Normally certain interrupts are reserved to the implementation. Any attempt
2877 to attach an interrupt causes Program_Error to be raised, as described in
2878 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
2879 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
2880 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2881 interrupt execution. Additionally, signals such as @code{SIGSEGV},
2882 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2883 Ada exceptions, or used to implement run-time functions such as the
2884 @code{abort} statement and stack overflow checking.
2886 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2887 such uses of interrupts. It subsumes the functionality of pragma
2888 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
2889 available on OS/2, Windows or VMS. On all other platforms than VxWorks,
2890 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2891 and may be used to mark interrupts required by the board support package
2894 Interrupts can be in one of three states:
2898 The interrupt is reserved (no Ada handler can be installed), and the
2899 Ada run-time may not install a handler. As a result you are guaranteed
2900 standard system default action if this interrupt is raised.
2904 The interrupt is reserved (no Ada handler can be installed). The run time
2905 is allowed to install a handler for internal control purposes, but is
2906 not required to do so.
2910 The interrupt is unreserved. The user may install a handler to provide
2915 These states are the allowed values of the @code{State} parameter of the
2916 pragma. The @code{Name} parameter is a value of the type
2917 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
2918 @code{Ada.Interrupts.Names}.
2920 This is a configuration pragma, and the binder will check that there
2921 are no inconsistencies between different units in a partition in how a
2922 given interrupt is specified. It may appear anywhere a pragma is legal.
2924 The effect is to move the interrupt to the specified state.
2926 By declaring interrupts to be SYSTEM, you guarantee the standard system
2927 action, such as a core dump.
2929 By declaring interrupts to be USER, you guarantee that you can install
2932 Note that certain signals on many operating systems cannot be caught and
2933 handled by applications. In such cases, the pragma is ignored. See the
2934 operating system documentation, or the value of the array @code{Reserved}
2935 declared in the spec of package @code{System.OS_Interface}.
2937 Overriding the default state of signals used by the Ada runtime may interfere
2938 with an application's runtime behavior in the cases of the synchronous signals,
2939 and in the case of the signal used to implement the @code{abort} statement.
2941 @node Pragma Keep_Names
2942 @unnumberedsec Pragma Keep_Names
2947 @smallexample @c ada
2948 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2952 The @var{LOCAL_NAME} argument
2953 must refer to an enumeration first subtype
2954 in the current declarative part. The effect is to retain the enumeration
2955 literal names for use by @code{Image} and @code{Value} even if a global
2956 @code{Discard_Names} pragma applies. This is useful when you want to
2957 generally suppress enumeration literal names and for example you therefore
2958 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2959 want to retain the names for specific enumeration types.
2961 @node Pragma License
2962 @unnumberedsec Pragma License
2964 @cindex License checking
2968 @smallexample @c ada
2969 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2973 This pragma is provided to allow automated checking for appropriate license
2974 conditions with respect to the standard and modified GPL@. A pragma
2975 @code{License}, which is a configuration pragma that typically appears at
2976 the start of a source file or in a separate @file{gnat.adc} file, specifies
2977 the licensing conditions of a unit as follows:
2981 This is used for a unit that can be freely used with no license restrictions.
2982 Examples of such units are public domain units, and units from the Ada
2986 This is used for a unit that is licensed under the unmodified GPL, and which
2987 therefore cannot be @code{with}'ed by a restricted unit.
2990 This is used for a unit licensed under the GNAT modified GPL that includes
2991 a special exception paragraph that specifically permits the inclusion of
2992 the unit in programs without requiring the entire program to be released
2996 This is used for a unit that is restricted in that it is not permitted to
2997 depend on units that are licensed under the GPL@. Typical examples are
2998 proprietary code that is to be released under more restrictive license
2999 conditions. Note that restricted units are permitted to @code{with} units
3000 which are licensed under the modified GPL (this is the whole point of the
3006 Normally a unit with no @code{License} pragma is considered to have an
3007 unknown license, and no checking is done. However, standard GNAT headers
3008 are recognized, and license information is derived from them as follows.
3012 A GNAT license header starts with a line containing 78 hyphens. The following
3013 comment text is searched for the appearance of any of the following strings.
3015 If the string ``GNU General Public License'' is found, then the unit is assumed
3016 to have GPL license, unless the string ``As a special exception'' follows, in
3017 which case the license is assumed to be modified GPL@.
3019 If one of the strings
3020 ``This specification is adapted from the Ada Semantic Interface'' or
3021 ``This specification is derived from the Ada Reference Manual'' is found
3022 then the unit is assumed to be unrestricted.
3026 These default actions means that a program with a restricted license pragma
3027 will automatically get warnings if a GPL unit is inappropriately
3028 @code{with}'ed. For example, the program:
3030 @smallexample @c ada
3033 procedure Secret_Stuff is
3039 if compiled with pragma @code{License} (@code{Restricted}) in a
3040 @file{gnat.adc} file will generate the warning:
3045 >>> license of withed unit "Sem_Ch3" is incompatible
3047 2. with GNAT.Sockets;
3048 3. procedure Secret_Stuff is
3052 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3053 compiler and is licensed under the
3054 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3055 run time, and is therefore licensed under the modified GPL@.
3057 @node Pragma Link_With
3058 @unnumberedsec Pragma Link_With
3063 @smallexample @c ada
3064 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3068 This pragma is provided for compatibility with certain Ada 83 compilers.
3069 It has exactly the same effect as pragma @code{Linker_Options} except
3070 that spaces occurring within one of the string expressions are treated
3071 as separators. For example, in the following case:
3073 @smallexample @c ada
3074 pragma Link_With ("-labc -ldef");
3078 results in passing the strings @code{-labc} and @code{-ldef} as two
3079 separate arguments to the linker. In addition pragma Link_With allows
3080 multiple arguments, with the same effect as successive pragmas.
3082 @node Pragma Linker_Alias
3083 @unnumberedsec Pragma Linker_Alias
3084 @findex Linker_Alias
3088 @smallexample @c ada
3089 pragma Linker_Alias (
3090 [Entity =>] LOCAL_NAME,
3091 [Target =>] static_string_EXPRESSION);
3095 @var{LOCAL_NAME} must refer to an object that is declared at the library
3096 level. This pragma establishes the given entity as a linker alias for the
3097 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3098 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3099 @var{static_string_EXPRESSION} in the object file, that is to say no space
3100 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3101 to the same address as @var{static_string_EXPRESSION} by the linker.
3103 The actual linker name for the target must be used (e.g.@: the fully
3104 encoded name with qualification in Ada, or the mangled name in C++),
3105 or it must be declared using the C convention with @code{pragma Import}
3106 or @code{pragma Export}.
3108 Not all target machines support this pragma. On some of them it is accepted
3109 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3111 @smallexample @c ada
3112 -- Example of the use of pragma Linker_Alias
3116 pragma Export (C, i);
3118 new_name_for_i : Integer;
3119 pragma Linker_Alias (new_name_for_i, "i");
3123 @node Pragma Linker_Constructor
3124 @unnumberedsec Pragma Linker_Constructor
3125 @findex Linker_Constructor
3129 @smallexample @c ada
3130 pragma Linker_Constructor (procedure_LOCAL_NAME);
3134 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3135 is declared at the library level. A procedure to which this pragma is
3136 applied will be treated as an initialization routine by the linker.
3137 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3138 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3139 of the executable is called (or immediately after the shared library is
3140 loaded if the procedure is linked in a shared library), in particular
3141 before the Ada run-time environment is set up.
3143 Because of these specific contexts, the set of operations such a procedure
3144 can perform is very limited and the type of objects it can manipulate is
3145 essentially restricted to the elementary types. In particular, it must only
3146 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3148 This pragma is used by GNAT to implement auto-initialization of shared Stand
3149 Alone Libraries, which provides a related capability without the restrictions
3150 listed above. Where possible, the use of Stand Alone Libraries is preferable
3151 to the use of this pragma.
3153 @node Pragma Linker_Destructor
3154 @unnumberedsec Pragma Linker_Destructor
3155 @findex Linker_Destructor
3159 @smallexample @c ada
3160 pragma Linker_Destructor (procedure_LOCAL_NAME);
3164 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3165 is declared at the library level. A procedure to which this pragma is
3166 applied will be treated as a finalization routine by the linker.
3167 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3168 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3169 of the executable has exited (or immediately before the shared library
3170 is unloaded if the procedure is linked in a shared library), in particular
3171 after the Ada run-time environment is shut down.
3173 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3174 because of these specific contexts.
3176 @node Pragma Linker_Section
3177 @unnumberedsec Pragma Linker_Section
3178 @findex Linker_Section
3182 @smallexample @c ada
3183 pragma Linker_Section (
3184 [Entity =>] LOCAL_NAME,
3185 [Section =>] static_string_EXPRESSION);
3189 @var{LOCAL_NAME} must refer to an object that is declared at the library
3190 level. This pragma specifies the name of the linker section for the given
3191 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3192 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3193 section of the executable (assuming the linker doesn't rename the section).
3195 The compiler normally places library-level objects in standard sections
3196 depending on their type: procedures and functions generally go in the
3197 @code{.text} section, initialized variables in the @code{.data} section
3198 and uninitialized variables in the @code{.bss} section.
3200 Other, special sections may exist on given target machines to map special
3201 hardware, for example I/O ports or flash memory. This pragma is a means to
3202 defer the final layout of the executable to the linker, thus fully working
3203 at the symbolic level with the compiler.
3205 Some file formats do not support arbitrary sections so not all target
3206 machines support this pragma. The use of this pragma may cause a program
3207 execution to be erroneous if it is used to place an entity into an
3208 inappropriate section (e.g.@: a modified variable into the @code{.text}
3209 section). See also @code{pragma Persistent_BSS}.
3211 @smallexample @c ada
3212 -- Example of the use of pragma Linker_Section
3216 pragma Volatile (Port_A);
3217 pragma Linker_Section (Port_A, ".bss.port_a");
3220 pragma Volatile (Port_B);
3221 pragma Linker_Section (Port_B, ".bss.port_b");
3225 @node Pragma Long_Float
3226 @unnumberedsec Pragma Long_Float
3232 @smallexample @c ada
3233 pragma Long_Float (FLOAT_FORMAT);
3235 FLOAT_FORMAT ::= D_Float | G_Float
3239 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3240 It allows control over the internal representation chosen for the predefined
3241 type @code{Long_Float} and for floating point type representations with
3242 @code{digits} specified in the range 7 through 15.
3243 For further details on this pragma, see the
3244 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3245 this pragma, the standard runtime libraries must be recompiled.
3246 @xref{The GNAT Run-Time Library Builder gnatlbr,,, gnat_ugn,
3247 @value{EDITION} User's Guide OpenVMS}, for a description of the
3248 @code{GNAT LIBRARY} command.
3250 @node Pragma Machine_Attribute
3251 @unnumberedsec Pragma Machine_Attribute
3252 @findex Machine_Attribute
3256 @smallexample @c ada
3257 pragma Machine_Attribute (
3258 [Entity =>] LOCAL_NAME,
3259 [Attribute_Name =>] static_string_EXPRESSION
3260 [, [Info =>] static_string_EXPRESSION] );
3264 Machine-dependent attributes can be specified for types and/or
3265 declarations. This pragma is semantically equivalent to
3266 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3267 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3268 in GNU C, where @code{@var{attribute_name}} is recognized by the
3269 target macro @code{TARGET_ATTRIBUTE_TABLE} which is defined for each
3270 machine. The optional parameter @var{info} is transformed into an
3271 identifier, which may make this pragma unusable for some attributes
3272 (parameter of some attributes must be a number or a string).
3273 @xref{Target Attributes,, Defining target-specific uses of
3274 @code{__attribute__}, gccint, GNU Compiler Colletion (GCC) Internals},
3275 further information. It is not possible to specify
3276 attributes defined by other languages, only attributes defined by the
3277 machine the code is intended to run on.
3280 @unnumberedsec Pragma Main
3286 @smallexample @c ada
3288 (MAIN_OPTION [, MAIN_OPTION]);
3291 [Stack_Size =>] static_integer_EXPRESSION
3292 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3293 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3297 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3298 no effect in GNAT, other than being syntax checked.
3300 @node Pragma Main_Storage
3301 @unnumberedsec Pragma Main_Storage
3303 @findex Main_Storage
3307 @smallexample @c ada
3309 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3311 MAIN_STORAGE_OPTION ::=
3312 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3313 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3317 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3318 no effect in GNAT, other than being syntax checked. Note that the pragma
3319 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3321 @node Pragma No_Body
3322 @unnumberedsec Pragma No_Body
3327 @smallexample @c ada
3332 There are a number of cases in which a package spec does not require a body,
3333 and in fact a body is not permitted. GNAT will not permit the spec to be
3334 compiled if there is a body around. The pragma No_Body allows you to provide
3335 a body file, even in a case where no body is allowed. The body file must
3336 contain only comments and a single No_Body pragma. This is recognized by
3337 the compiler as indicating that no body is logically present.
3339 This is particularly useful during maintenance when a package is modified in
3340 such a way that a body needed before is no longer needed. The provision of a
3341 dummy body with a No_Body pragma ensures that there is no interference from
3342 earlier versions of the package body.
3344 @node Pragma No_Return
3345 @unnumberedsec Pragma No_Return
3350 @smallexample @c ada
3351 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3355 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3356 declarations in the current declarative part. A procedure to which this
3357 pragma is applied may not contain any explicit @code{return} statements.
3358 In addition, if the procedure contains any implicit returns from falling
3359 off the end of a statement sequence, then execution of that implicit
3360 return will cause Program_Error to be raised.
3362 One use of this pragma is to identify procedures whose only purpose is to raise
3363 an exception. Another use of this pragma is to suppress incorrect warnings
3364 about missing returns in functions, where the last statement of a function
3365 statement sequence is a call to such a procedure.
3367 Note that in Ada 2005 mode, this pragma is part of the language, and is
3368 identical in effect to the pragma as implemented in Ada 95 mode.
3370 @node Pragma No_Strict_Aliasing
3371 @unnumberedsec Pragma No_Strict_Aliasing
3372 @findex No_Strict_Aliasing
3376 @smallexample @c ada
3377 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3381 @var{type_LOCAL_NAME} must refer to an access type
3382 declaration in the current declarative part. The effect is to inhibit
3383 strict aliasing optimization for the given type. The form with no
3384 arguments is a configuration pragma which applies to all access types
3385 declared in units to which the pragma applies. For a detailed
3386 description of the strict aliasing optimization, and the situations
3387 in which it must be suppressed, see @ref{Optimization and Strict
3388 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3390 @node Pragma Normalize_Scalars
3391 @unnumberedsec Pragma Normalize_Scalars
3392 @findex Normalize_Scalars
3396 @smallexample @c ada
3397 pragma Normalize_Scalars;
3401 This is a language defined pragma which is fully implemented in GNAT@. The
3402 effect is to cause all scalar objects that are not otherwise initialized
3403 to be initialized. The initial values are implementation dependent and
3407 @item Standard.Character
3409 Objects whose root type is Standard.Character are initialized to
3410 Character'Last unless the subtype range excludes NUL (in which case
3411 NUL is used). This choice will always generate an invalid value if
3414 @item Standard.Wide_Character
3416 Objects whose root type is Standard.Wide_Character are initialized to
3417 Wide_Character'Last unless the subtype range excludes NUL (in which case
3418 NUL is used). This choice will always generate an invalid value if
3421 @item Standard.Wide_Wide_Character
3423 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3424 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3425 which case NUL is used). This choice will always generate an invalid value if
3430 Objects of an integer type are treated differently depending on whether
3431 negative values are present in the subtype. If no negative values are
3432 present, then all one bits is used as the initial value except in the
3433 special case where zero is excluded from the subtype, in which case
3434 all zero bits are used. This choice will always generate an invalid
3435 value if one exists.
3437 For subtypes with negative values present, the largest negative number
3438 is used, except in the unusual case where this largest negative number
3439 is in the subtype, and the largest positive number is not, in which case
3440 the largest positive value is used. This choice will always generate
3441 an invalid value if one exists.
3443 @item Floating-Point Types
3444 Objects of all floating-point types are initialized to all 1-bits. For
3445 standard IEEE format, this corresponds to a NaN (not a number) which is
3446 indeed an invalid value.
3448 @item Fixed-Point Types
3449 Objects of all fixed-point types are treated as described above for integers,
3450 with the rules applying to the underlying integer value used to represent
3451 the fixed-point value.
3454 Objects of a modular type are initialized to all one bits, except in
3455 the special case where zero is excluded from the subtype, in which
3456 case all zero bits are used. This choice will always generate an
3457 invalid value if one exists.
3459 @item Enumeration types
3460 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3461 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3462 whose Pos value is zero, in which case a code of zero is used. This choice
3463 will always generate an invalid value if one exists.
3467 @node Pragma Obsolescent
3468 @unnumberedsec Pragma Obsolescent
3473 @smallexample @c ada
3476 pragma Obsolescent (
3477 [Message =>] static_string_EXPRESSION
3478 [,[Version =>] Ada_05]]);
3480 pragma Obsolescent (
3482 [,[Message =>] static_string_EXPRESSION
3483 [,[Version =>] Ada_05]] );
3487 This pragma can occur immediately following a declaration of an entity,
3488 including the case of a record component. If no Entity argument is present,
3489 then this declaration is the one to which the pragma applies. If an Entity
3490 parameter is present, it must either match the name of the entity in this
3491 declaration, or alternatively, the pragma can immediately follow an enumeration
3492 type declaration, where the Entity argument names one of the enumeration
3495 This pragma is used to indicate that the named entity
3496 is considered obsolescent and should not be used. Typically this is
3497 used when an API must be modified by eventually removing or modifying
3498 existing subprograms or other entities. The pragma can be used at an
3499 intermediate stage when the entity is still present, but will be
3502 The effect of this pragma is to output a warning message on a reference to
3503 an entity thus marked that the subprogram is obsolescent if the appropriate
3504 warning option in the compiler is activated. If the Message parameter is
3505 present, then a second warning message is given containing this text. In
3506 addition, a reference to the eneity is considered to be a violation of pragma
3507 Restrictions (No_Obsolescent_Features).
3509 This pragma can also be used as a program unit pragma for a package,
3510 in which case the entity name is the name of the package, and the
3511 pragma indicates that the entire package is considered
3512 obsolescent. In this case a client @code{with}'ing such a package
3513 violates the restriction, and the @code{with} statement is
3514 flagged with warnings if the warning option is set.
3516 If the Version parameter is present (which must be exactly
3517 the identifier Ada_05, no other argument is allowed), then the
3518 indication of obsolescence applies only when compiling in Ada 2005
3519 mode. This is primarily intended for dealing with the situations
3520 in the predefined library where subprograms or packages
3521 have become defined as obsolescent in Ada 2005
3522 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3524 The following examples show typical uses of this pragma:
3526 @smallexample @c ada
3528 pragma Obsolescent (p, Message => "use pp instead of p");
3533 pragma Obsolescent ("use q2new instead");
3535 type R is new integer;
3538 Message => "use RR in Ada 2005",
3548 type E is (a, bc, 'd', quack);
3549 pragma Obsolescent (Entity => bc)
3550 pragma Obsolescent (Entity => 'd')
3553 (a, b : character) return character;
3554 pragma Obsolescent (Entity => "+");
3559 Note that, as for all pragmas, if you use a pragma argument identifier,
3560 then all subsequent parameters must also use a pragma argument identifier.
3561 So if you specify "Entity =>" for the Entity argument, and a Message
3562 argument is present, it must be preceded by "Message =>".
3564 @node Pragma Optimize_Alignment
3565 @unnumberedsec Pragma Optimize_Alignment
3566 @findex Optimize_Alignment
3567 @cindex Alignment, default settings
3571 @smallexample @c ada
3572 pragma Optimize_Alignment (TIME | SPACE | OFF);
3576 This is a configuration pragma which affects the choice of default alignments
3577 for types where no alignment is explicitly specified. There is a time/space
3578 trade-off in the selection of these values. Large alignments result in more
3579 efficient code, at the expense of larger data space, since sizes have to be
3580 increased to match these alignments. Smaller alignments save space, but the
3581 access code is slower. The normal choice of default alignments (which is what
3582 you get if you do not use this pragma, or if you use an argument of OFF),
3583 tries to balance these two requirements.
3585 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3586 First any packed record is given an alignment of 1. Second, if a size is given
3587 for the type, then the alignment is chosen to avoid increasing this size. For
3590 @smallexample @c ada
3600 In the default mode, this type gets an alignment of 4, so that access to the
3601 Integer field X are efficient. But this means that objects of the type end up
3602 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3603 allowed to be bigger than the size of the type, but it can waste space if for
3604 example fields of type R appear in an enclosing record. If the above type is
3605 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3607 Specifying TIME causes larger default alignments to be chosen in the case of
3608 small types with sizes that are not a power of 2. For example, consider:
3610 @smallexample @c ada
3622 The default alignment for this record is normally 1, but if this type is
3623 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3624 to 4, which wastes space for objects of the type, since they are now 4 bytes
3625 long, but results in more efficient access when the whole record is referenced.
3627 As noted above, this is a configuration pragma, and there is a requirement
3628 that all units in a partition be compiled with a consistent setting of the
3629 optimization setting. This would normally be achieved by use of a configuration
3630 pragma file containing the appropriate setting. The exception to this rule is
3631 that units with an explicit configuration pragma in the same file as the source
3632 unit are excluded from the consistency check, as are all predefined units. The
3633 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3634 pragma appears at the start of the file.
3636 @node Pragma Passive
3637 @unnumberedsec Pragma Passive
3642 @smallexample @c ada
3643 pragma Passive [(Semaphore | No)];
3647 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3648 compatibility with DEC Ada 83 implementations, where it is used within a
3649 task definition to request that a task be made passive. If the argument
3650 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3651 treats the pragma as an assertion that the containing task is passive
3652 and that optimization of context switch with this task is permitted and
3653 desired. If the argument @code{No} is present, the task must not be
3654 optimized. GNAT does not attempt to optimize any tasks in this manner
3655 (since protected objects are available in place of passive tasks).
3657 @node Pragma Persistent_BSS
3658 @unnumberedsec Pragma Persistent_BSS
3659 @findex Persistent_BSS
3663 @smallexample @c ada
3664 pragma Persistent_BSS [(LOCAL_NAME)]
3668 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3669 section. On some targets the linker and loader provide for special
3670 treatment of this section, allowing a program to be reloaded without
3671 affecting the contents of this data (hence the name persistent).
3673 There are two forms of usage. If an argument is given, it must be the
3674 local name of a library level object, with no explicit initialization
3675 and whose type is potentially persistent. If no argument is given, then
3676 the pragma is a configuration pragma, and applies to all library level
3677 objects with no explicit initialization of potentially persistent types.
3679 A potentially persistent type is a scalar type, or a non-tagged,
3680 non-discriminated record, all of whose components have no explicit
3681 initialization and are themselves of a potentially persistent type,
3682 or an array, all of whose constraints are static, and whose component
3683 type is potentially persistent.
3685 If this pragma is used on a target where this feature is not supported,
3686 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3688 @node Pragma Polling
3689 @unnumberedsec Pragma Polling
3694 @smallexample @c ada
3695 pragma Polling (ON | OFF);
3699 This pragma controls the generation of polling code. This is normally off.
3700 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3701 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3702 runtime library, and can be found in file @file{a-excpol.adb}.
3704 Pragma @code{Polling} can appear as a configuration pragma (for example it
3705 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3706 can be used in the statement or declaration sequence to control polling
3709 A call to the polling routine is generated at the start of every loop and
3710 at the start of every subprogram call. This guarantees that the @code{Poll}
3711 routine is called frequently, and places an upper bound (determined by
3712 the complexity of the code) on the period between two @code{Poll} calls.
3714 The primary purpose of the polling interface is to enable asynchronous
3715 aborts on targets that cannot otherwise support it (for example Windows
3716 NT), but it may be used for any other purpose requiring periodic polling.
3717 The standard version is null, and can be replaced by a user program. This
3718 will require re-compilation of the @code{Ada.Exceptions} package that can
3719 be found in files @file{a-except.ads} and @file{a-except.adb}.
3721 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3722 distribution) is used to enable the asynchronous abort capability on
3723 targets that do not normally support the capability. The version of
3724 @code{Poll} in this file makes a call to the appropriate runtime routine
3725 to test for an abort condition.
3727 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3728 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3731 @node Pragma Postcondition
3732 @unnumberedsec Pragma Postcondition
3733 @cindex Postconditions
3734 @cindex Checks, postconditions
3735 @findex Postconditions
3739 @smallexample @c ada
3740 pragma Postcondition (
3741 [Check =>] Boolean_Expression
3742 [,[Message =>] String_Expression]);
3746 The @code{Postcondition} pragma allows specification of automatic
3747 postcondition checks for subprograms. These checks are similar to
3748 assertions, but are automatically inserted just prior to the return
3749 statements of the subprogram with which they are associated (including
3750 implicit returns at the end of procedure bodies and associated
3751 exception handlers).
3753 In addition, the boolean expression which is the condition which
3754 must be true may contain references to function'Result in the case
3755 of a function to refer to the returned value.
3757 @code{Postcondition} pragmas may appear either immediate following the
3758 (separate) declaration of a subprogram, or at the start of the
3759 declarations of a subprogram body. Only other pragmas may intervene
3760 (that is appear between the subprogram declaration and its
3761 postconditions, or appear before the postcondition in the
3762 declaration sequence in a subprogram body). In the case of a
3763 postcondition appearing after a subprogram declaration, the
3764 formal arguments of the subprogram are visible, and can be
3765 referenced in the postcondition expressions.
3767 The postconditions are collected and automatically tested just
3768 before any return (implicit or explicit) in the subprogram body.
3769 A postcondition is only recognized if postconditions are active
3770 at the time the pragma is encountered. The compiler switch @option{gnata}
3771 turns on all postconditions by default, and pragma @code{Check_Policy}
3772 with an identifier of @code{Postcondition} can also be used to
3773 control whether postconditions are active.
3775 The general approach is that postconditions are placed in the spec
3776 if they represent functional aspects which make sense to the client.
3777 For example we might have:
3779 @smallexample @c ada
3780 function Direction return Integer;
3781 pragma Postcondition
3782 (Direction'Result = +1
3784 Direction'Result = -1);
3788 which serves to document that the result must be +1 or -1, and
3789 will test that this is the case at run time if postcondition
3792 Postconditions within the subprogram body can be used to
3793 check that some internal aspect of the implementation,
3794 not visible to the client, is operating as expected.
3795 For instance if a square root routine keeps an internal
3796 counter of the number of times it is called, then we
3797 might have the following postcondition:
3799 @smallexample @c ada
3800 Sqrt_Calls : Natural := 0;
3802 function Sqrt (Arg : Float) return Float is
3803 pragma Postcondition
3804 (Sqrt_Calls = Sqrt_Calls'Old + 1);
3810 As this example, shows, the use of the @code{Old} attribute
3811 is often useful in postconditions to refer to the state on
3812 entry to the subprogram.
3814 Note that postconditions are only checked on normal returns
3815 from the subprogram. If an abnormal return results from
3816 raising an exception, then the postconditions are not checked.
3818 If a postcondition fails, then the exception
3819 @code{System.Assertions.Assert_Failure} is raised. If
3820 a message argument was supplied, then the given string
3821 will be used as the exception message. If no message
3822 argument was supplied, then the default message has
3823 the form "Postcondition failed at file:line". The
3824 exception is raised in the context of the subprogram
3825 body, so it is possible to catch postcondition failures
3826 within the subprogram body itself.
3828 Within a package spec, normal visibility rules
3829 in Ada would prevent forward references within a
3830 postcondition pragma to functions defined later in
3831 the same package. This would introduce undesirable
3832 ordering constraints. To avoid this problem, all
3833 postcondition pragmas are analyzed at the end of
3834 the package spec, allowing forward references.
3836 The following example shows that this even allows
3837 mutually recursive postconditions as in:
3839 @smallexample @c ada
3840 package Parity_Functions is
3841 function Odd (X : Natural) return Boolean;
3842 pragma Postcondition
3846 (x /= 0 and then Even (X - 1))));
3848 function Even (X : Natural) return Boolean;
3849 pragma Postcondition
3853 (x /= 1 and then Odd (X - 1))));
3855 end Parity_Functions;
3859 There are no restrictions on the complexity or form of
3860 conditions used within @code{Postcondition} pragmas.
3861 The following example shows that it is even possible
3862 to verify performance behavior.
3864 @smallexample @c ada
3867 Performance : constant Float;
3868 -- Performance constant set by implementation
3869 -- to match target architecture behavior.
3871 procedure Treesort (Arg : String);
3872 -- Sorts characters of argument using N*logN sort
3873 pragma Postcondition
3874 (Float (Clock - Clock'Old) <=
3875 Float (Arg'Length) *
3876 log (Float (Arg'Length)) *
3882 Note: postcondition pragmas associated with subprograms that are
3883 marked as Inline_Always, or those marked as Inline with front-end
3884 inlining (-gnatN option set) are accepted and legality-checked
3885 by the compiler, but are ignored at run-time even if postcondition
3886 checking is enabled.
3888 @node Pragma Precondition
3889 @unnumberedsec Pragma Precondition
3890 @cindex Preconditions
3891 @cindex Checks, preconditions
3892 @findex Preconditions
3896 @smallexample @c ada
3897 pragma Precondition (
3898 [Check =>] Boolean_Expression
3899 [,[Message =>] String_Expression]);
3903 The @code{Precondition} pragma is similar to @code{Postcondition}
3904 except that the corresponding checks take place immediately upon
3905 entry to the subprogram, and if a precondition fails, the exception
3906 is raised in the context of the caller, and the attribute 'Result
3907 cannot be used within the precondition expression.
3909 Otherwise, the placement and visibility rules are identical to those
3910 described for postconditions. The following is an example of use
3911 within a package spec:
3913 @smallexample @c ada
3914 package Math_Functions is
3916 function Sqrt (Arg : Float) return Float;
3917 pragma Precondition (Arg >= 0.0)
3923 @code{Precondition} pragmas may appear either immediate following the
3924 (separate) declaration of a subprogram, or at the start of the
3925 declarations of a subprogram body. Only other pragmas may intervene
3926 (that is appear between the subprogram declaration and its
3927 postconditions, or appear before the postcondition in the
3928 declaration sequence in a subprogram body).
3930 Note: postcondition pragmas associated with subprograms that are
3931 marked as Inline_Always, or those marked as Inline with front-end
3932 inlining (-gnatN option set) are accepted and legality-checked
3933 by the compiler, but are ignored at run-time even if postcondition
3934 checking is enabled.
3938 @node Pragma Profile (Ravenscar)
3939 @unnumberedsec Pragma Profile (Ravenscar)
3944 @smallexample @c ada
3945 pragma Profile (Ravenscar);
3949 A configuration pragma that establishes the following set of configuration
3953 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3954 [RM D.2.2] Tasks are dispatched following a preemptive
3955 priority-ordered scheduling policy.
3957 @item Locking_Policy (Ceiling_Locking)
3958 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3959 the ceiling priority of the corresponding protected object.
3961 @c @item Detect_Blocking
3962 @c This pragma forces the detection of potentially blocking operations within a
3963 @c protected operation, and to raise Program_Error if that happens.
3967 plus the following set of restrictions:
3970 @item Max_Entry_Queue_Length = 1
3971 Defines the maximum number of calls that are queued on a (protected) entry.
3972 Note that this restrictions is checked at run time. Violation of this
3973 restriction results in the raising of Program_Error exception at the point of
3974 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3975 always 1 and hence no task can be queued on a protected entry.
3977 @item Max_Protected_Entries = 1
3978 [RM D.7] Specifies the maximum number of entries per protected type. The
3979 bounds of every entry family of a protected unit shall be static, or shall be
3980 defined by a discriminant of a subtype whose corresponding bound is static.
3981 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3983 @item Max_Task_Entries = 0
3984 [RM D.7] Specifies the maximum number of entries
3985 per task. The bounds of every entry family
3986 of a task unit shall be static, or shall be
3987 defined by a discriminant of a subtype whose
3988 corresponding bound is static. A value of zero
3989 indicates that no rendezvous are possible. For
3990 the Profile (Ravenscar), the value of Max_Task_Entries is always
3993 @item No_Abort_Statements
3994 [RM D.7] There are no abort_statements, and there are
3995 no calls to Task_Identification.Abort_Task.
3997 @item No_Asynchronous_Control
3998 There are no semantic dependences on the package
3999 Asynchronous_Task_Control.
4002 There are no semantic dependencies on the package Ada.Calendar.
4004 @item No_Dynamic_Attachment
4005 There is no call to any of the operations defined in package Ada.Interrupts
4006 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
4007 Detach_Handler, and Reference).
4009 @item No_Dynamic_Priorities
4010 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
4012 @item No_Implicit_Heap_Allocations
4013 [RM D.7] No constructs are allowed to cause implicit heap allocation.
4015 @item No_Local_Protected_Objects
4016 Protected objects and access types that designate
4017 such objects shall be declared only at library level.
4019 @item No_Local_Timing_Events
4020 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4021 declared at the library level.
4023 @item No_Protected_Type_Allocators
4024 There are no allocators for protected types or
4025 types containing protected subcomponents.
4027 @item No_Relative_Delay
4028 There are no delay_relative statements.
4030 @item No_Requeue_Statements
4031 Requeue statements are not allowed.
4033 @item No_Select_Statements
4034 There are no select_statements.
4036 @item No_Specific_Termination_Handlers
4037 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4038 or to Ada.Task_Termination.Specific_Handler.
4040 @item No_Task_Allocators
4041 [RM D.7] There are no allocators for task types
4042 or types containing task subcomponents.
4044 @item No_Task_Attributes_Package
4045 There are no semantic dependencies on the Ada.Task_Attributes package.
4047 @item No_Task_Hierarchy
4048 [RM D.7] All (non-environment) tasks depend
4049 directly on the environment task of the partition.
4051 @item No_Task_Termination
4052 Tasks which terminate are erroneous.
4054 @item No_Unchecked_Conversion
4055 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
4057 @item No_Unchecked_Deallocation
4058 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
4060 @item Simple_Barriers
4061 Entry barrier condition expressions shall be either static
4062 boolean expressions or boolean objects which are declared in
4063 the protected type which contains the entry.
4067 This set of configuration pragmas and restrictions correspond to the
4068 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4069 published by the @cite{International Real-Time Ada Workshop}, 1997,
4070 and whose most recent description is available at
4071 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4073 The original definition of the profile was revised at subsequent IRTAW
4074 meetings. It has been included in the ISO
4075 @cite{Guide for the Use of the Ada Programming Language in High
4076 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4077 the next revision of the standard. The formal definition given by
4078 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4079 AI-305) available at
4080 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
4081 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
4084 The above set is a superset of the restrictions provided by pragma
4085 @code{Profile (Restricted)}, it includes six additional restrictions
4086 (@code{Simple_Barriers}, @code{No_Select_Statements},
4087 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4088 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4089 that pragma @code{Profile (Ravenscar)}, like the pragma
4090 @code{Profile (Restricted)},
4091 automatically causes the use of a simplified,
4092 more efficient version of the tasking run-time system.
4094 @node Pragma Profile (Restricted)
4095 @unnumberedsec Pragma Profile (Restricted)
4096 @findex Restricted Run Time
4100 @smallexample @c ada
4101 pragma Profile (Restricted);
4105 A configuration pragma that establishes the following set of restrictions:
4108 @item No_Abort_Statements
4109 @item No_Entry_Queue
4110 @item No_Task_Hierarchy
4111 @item No_Task_Allocators
4112 @item No_Dynamic_Priorities
4113 @item No_Terminate_Alternatives
4114 @item No_Dynamic_Attachment
4115 @item No_Protected_Type_Allocators
4116 @item No_Local_Protected_Objects
4117 @item No_Requeue_Statements
4118 @item No_Task_Attributes_Package
4119 @item Max_Asynchronous_Select_Nesting = 0
4120 @item Max_Task_Entries = 0
4121 @item Max_Protected_Entries = 1
4122 @item Max_Select_Alternatives = 0
4126 This set of restrictions causes the automatic selection of a simplified
4127 version of the run time that provides improved performance for the
4128 limited set of tasking functionality permitted by this set of restrictions.
4130 @node Pragma Psect_Object
4131 @unnumberedsec Pragma Psect_Object
4132 @findex Psect_Object
4136 @smallexample @c ada
4137 pragma Psect_Object (
4138 [Internal =>] LOCAL_NAME,
4139 [, [External =>] EXTERNAL_SYMBOL]
4140 [, [Size =>] EXTERNAL_SYMBOL]);
4144 | static_string_EXPRESSION
4148 This pragma is identical in effect to pragma @code{Common_Object}.
4150 @node Pragma Pure_Function
4151 @unnumberedsec Pragma Pure_Function
4152 @findex Pure_Function
4156 @smallexample @c ada
4157 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4161 This pragma appears in the same declarative part as a function
4162 declaration (or a set of function declarations if more than one
4163 overloaded declaration exists, in which case the pragma applies
4164 to all entities). It specifies that the function @code{Entity} is
4165 to be considered pure for the purposes of code generation. This means
4166 that the compiler can assume that there are no side effects, and
4167 in particular that two calls with identical arguments produce the
4168 same result. It also means that the function can be used in an
4171 Note that, quite deliberately, there are no static checks to try
4172 to ensure that this promise is met, so @code{Pure_Function} can be used
4173 with functions that are conceptually pure, even if they do modify
4174 global variables. For example, a square root function that is
4175 instrumented to count the number of times it is called is still
4176 conceptually pure, and can still be optimized, even though it
4177 modifies a global variable (the count). Memo functions are another
4178 example (where a table of previous calls is kept and consulted to
4179 avoid re-computation).
4182 Note: Most functions in a @code{Pure} package are automatically pure, and
4183 there is no need to use pragma @code{Pure_Function} for such functions. One
4184 exception is any function that has at least one formal of type
4185 @code{System.Address} or a type derived from it. Such functions are not
4186 considered pure by default, since the compiler assumes that the
4187 @code{Address} parameter may be functioning as a pointer and that the
4188 referenced data may change even if the address value does not.
4189 Similarly, imported functions are not considered to be pure by default,
4190 since there is no way of checking that they are in fact pure. The use
4191 of pragma @code{Pure_Function} for such a function will override these default
4192 assumption, and cause the compiler to treat a designated subprogram as pure
4195 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4196 applies to the underlying renamed function. This can be used to
4197 disambiguate cases of overloading where some but not all functions
4198 in a set of overloaded functions are to be designated as pure.
4200 If pragma @code{Pure_Function} is applied to a library level function, the
4201 function is also considered pure from an optimization point of view, but the
4202 unit is not a Pure unit in the categorization sense. So for example, a function
4203 thus marked is free to @code{with} non-pure units.
4205 @node Pragma Restriction_Warnings
4206 @unnumberedsec Pragma Restriction_Warnings
4207 @findex Restriction_Warnings
4211 @smallexample @c ada
4212 pragma Restriction_Warnings
4213 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4217 This pragma allows a series of restriction identifiers to be
4218 specified (the list of allowed identifiers is the same as for
4219 pragma @code{Restrictions}). For each of these identifiers
4220 the compiler checks for violations of the restriction, but
4221 generates a warning message rather than an error message
4222 if the restriction is violated.
4225 @unnumberedsec Pragma Shared
4229 This pragma is provided for compatibility with Ada 83. The syntax and
4230 semantics are identical to pragma Atomic.
4232 @node Pragma Source_File_Name
4233 @unnumberedsec Pragma Source_File_Name
4234 @findex Source_File_Name
4238 @smallexample @c ada
4239 pragma Source_File_Name (
4240 [Unit_Name =>] unit_NAME,
4241 Spec_File_Name => STRING_LITERAL);
4243 pragma Source_File_Name (
4244 [Unit_Name =>] unit_NAME,
4245 Body_File_Name => STRING_LITERAL);
4249 Use this to override the normal naming convention. It is a configuration
4250 pragma, and so has the usual applicability of configuration pragmas
4251 (i.e.@: it applies to either an entire partition, or to all units in a
4252 compilation, or to a single unit, depending on how it is used.
4253 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4254 the second argument is required, and indicates whether this is the file
4255 name for the spec or for the body.
4257 Another form of the @code{Source_File_Name} pragma allows
4258 the specification of patterns defining alternative file naming schemes
4259 to apply to all files.
4261 @smallexample @c ada
4262 pragma Source_File_Name
4263 ( [Spec_File_Name =>] STRING_LITERAL
4264 [,[Casing =>] CASING_SPEC]
4265 [,[Dot_Replacement =>] STRING_LITERAL]);
4267 pragma Source_File_Name
4268 ( [Body_File_Name =>] STRING_LITERAL
4269 [,[Casing =>] CASING_SPEC]
4270 [,[Dot_Replacement =>] STRING_LITERAL]);
4272 pragma Source_File_Name
4273 ( [Subunit_File_Name =>] STRING_LITERAL
4274 [,[Casing =>] CASING_SPEC]
4275 [,[Dot_Replacement =>] STRING_LITERAL]);
4277 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4281 The first argument is a pattern that contains a single asterisk indicating
4282 the point at which the unit name is to be inserted in the pattern string
4283 to form the file name. The second argument is optional. If present it
4284 specifies the casing of the unit name in the resulting file name string.
4285 The default is lower case. Finally the third argument allows for systematic
4286 replacement of any dots in the unit name by the specified string literal.
4288 A pragma Source_File_Name cannot appear after a
4289 @ref{Pragma Source_File_Name_Project}.
4291 For more details on the use of the @code{Source_File_Name} pragma,
4292 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4293 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4296 @node Pragma Source_File_Name_Project
4297 @unnumberedsec Pragma Source_File_Name_Project
4298 @findex Source_File_Name_Project
4301 This pragma has the same syntax and semantics as pragma Source_File_Name.
4302 It is only allowed as a stand alone configuration pragma.
4303 It cannot appear after a @ref{Pragma Source_File_Name}, and
4304 most importantly, once pragma Source_File_Name_Project appears,
4305 no further Source_File_Name pragmas are allowed.
4307 The intention is that Source_File_Name_Project pragmas are always
4308 generated by the Project Manager in a manner consistent with the naming
4309 specified in a project file, and when naming is controlled in this manner,
4310 it is not permissible to attempt to modify this naming scheme using
4311 Source_File_Name pragmas (which would not be known to the project manager).
4313 @node Pragma Source_Reference
4314 @unnumberedsec Pragma Source_Reference
4315 @findex Source_Reference
4319 @smallexample @c ada
4320 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4324 This pragma must appear as the first line of a source file.
4325 @var{integer_literal} is the logical line number of the line following
4326 the pragma line (for use in error messages and debugging
4327 information). @var{string_literal} is a static string constant that
4328 specifies the file name to be used in error messages and debugging
4329 information. This is most notably used for the output of @code{gnatchop}
4330 with the @option{-r} switch, to make sure that the original unchopped
4331 source file is the one referred to.
4333 The second argument must be a string literal, it cannot be a static
4334 string expression other than a string literal. This is because its value
4335 is needed for error messages issued by all phases of the compiler.
4337 @node Pragma Stream_Convert
4338 @unnumberedsec Pragma Stream_Convert
4339 @findex Stream_Convert
4343 @smallexample @c ada
4344 pragma Stream_Convert (
4345 [Entity =>] type_LOCAL_NAME,
4346 [Read =>] function_NAME,
4347 [Write =>] function_NAME);
4351 This pragma provides an efficient way of providing stream functions for
4352 types defined in packages. Not only is it simpler to use than declaring
4353 the necessary functions with attribute representation clauses, but more
4354 significantly, it allows the declaration to made in such a way that the
4355 stream packages are not loaded unless they are needed. The use of
4356 the Stream_Convert pragma adds no overhead at all, unless the stream
4357 attributes are actually used on the designated type.
4359 The first argument specifies the type for which stream functions are
4360 provided. The second parameter provides a function used to read values
4361 of this type. It must name a function whose argument type may be any
4362 subtype, and whose returned type must be the type given as the first
4363 argument to the pragma.
4365 The meaning of the @var{Read}
4366 parameter is that if a stream attribute directly
4367 or indirectly specifies reading of the type given as the first parameter,
4368 then a value of the type given as the argument to the Read function is
4369 read from the stream, and then the Read function is used to convert this
4370 to the required target type.
4372 Similarly the @var{Write} parameter specifies how to treat write attributes
4373 that directly or indirectly apply to the type given as the first parameter.
4374 It must have an input parameter of the type specified by the first parameter,
4375 and the return type must be the same as the input type of the Read function.
4376 The effect is to first call the Write function to convert to the given stream
4377 type, and then write the result type to the stream.
4379 The Read and Write functions must not be overloaded subprograms. If necessary
4380 renamings can be supplied to meet this requirement.
4381 The usage of this attribute is best illustrated by a simple example, taken
4382 from the GNAT implementation of package Ada.Strings.Unbounded:
4384 @smallexample @c ada
4385 function To_Unbounded (S : String)
4386 return Unbounded_String
4387 renames To_Unbounded_String;
4389 pragma Stream_Convert
4390 (Unbounded_String, To_Unbounded, To_String);
4394 The specifications of the referenced functions, as given in the Ada
4395 Reference Manual are:
4397 @smallexample @c ada
4398 function To_Unbounded_String (Source : String)
4399 return Unbounded_String;
4401 function To_String (Source : Unbounded_String)
4406 The effect is that if the value of an unbounded string is written to a
4407 stream, then the representation of the item in the stream is in the same
4408 format used for @code{Standard.String}, and this same representation is
4409 expected when a value of this type is read from the stream.
4411 @node Pragma Style_Checks
4412 @unnumberedsec Pragma Style_Checks
4413 @findex Style_Checks
4417 @smallexample @c ada
4418 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4419 On | Off [, LOCAL_NAME]);
4423 This pragma is used in conjunction with compiler switches to control the
4424 built in style checking provided by GNAT@. The compiler switches, if set,
4425 provide an initial setting for the switches, and this pragma may be used
4426 to modify these settings, or the settings may be provided entirely by
4427 the use of the pragma. This pragma can be used anywhere that a pragma
4428 is legal, including use as a configuration pragma (including use in
4429 the @file{gnat.adc} file).
4431 The form with a string literal specifies which style options are to be
4432 activated. These are additive, so they apply in addition to any previously
4433 set style check options. The codes for the options are the same as those
4434 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4435 For example the following two methods can be used to enable
4440 @smallexample @c ada
4441 pragma Style_Checks ("l");
4446 gcc -c -gnatyl @dots{}
4451 The form ALL_CHECKS activates all standard checks (its use is equivalent
4452 to the use of the @code{gnaty} switch with no options. @xref{Top,
4453 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4454 @value{EDITION} User's Guide}, for details.
4456 The forms with @code{Off} and @code{On}
4457 can be used to temporarily disable style checks
4458 as shown in the following example:
4460 @smallexample @c ada
4464 pragma Style_Checks ("k"); -- requires keywords in lower case
4465 pragma Style_Checks (Off); -- turn off style checks
4466 NULL; -- this will not generate an error message
4467 pragma Style_Checks (On); -- turn style checks back on
4468 NULL; -- this will generate an error message
4472 Finally the two argument form is allowed only if the first argument is
4473 @code{On} or @code{Off}. The effect is to turn of semantic style checks
4474 for the specified entity, as shown in the following example:
4476 @smallexample @c ada
4480 pragma Style_Checks ("r"); -- require consistency of identifier casing
4482 Rf1 : Integer := ARG; -- incorrect, wrong case
4483 pragma Style_Checks (Off, Arg);
4484 Rf2 : Integer := ARG; -- OK, no error
4487 @node Pragma Subtitle
4488 @unnumberedsec Pragma Subtitle
4493 @smallexample @c ada
4494 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4498 This pragma is recognized for compatibility with other Ada compilers
4499 but is ignored by GNAT@.
4501 @node Pragma Suppress
4502 @unnumberedsec Pragma Suppress
4507 @smallexample @c ada
4508 pragma Suppress (Identifier [, [On =>] Name]);
4512 This is a standard pragma, and supports all the check names required in
4513 the RM. It is included here because GNAT recognizes one additional check
4514 name: @code{Alignment_Check} which can be used to suppress alignment checks
4515 on addresses used in address clauses. Such checks can also be suppressed
4516 by suppressing range checks, but the specific use of @code{Alignment_Check}
4517 allows suppression of alignment checks without suppressing other range checks.
4519 Note that pragma Suppress gives the compiler permission to omit
4520 checks, but does not require the compiler to omit checks. The compiler
4521 will generate checks if they are essentially free, even when they are
4522 suppressed. In particular, if the compiler can prove that a certain
4523 check will necessarily fail, it will generate code to do an
4524 unconditional ``raise'', even if checks are suppressed. The compiler
4527 Of course, run-time checks are omitted whenever the compiler can prove
4528 that they will not fail, whether or not checks are suppressed.
4530 @node Pragma Suppress_All
4531 @unnumberedsec Pragma Suppress_All
4532 @findex Suppress_All
4536 @smallexample @c ada
4537 pragma Suppress_All;
4541 This pragma can only appear immediately following a compilation
4542 unit. The effect is to apply @code{Suppress (All_Checks)} to the unit
4543 which it follows. This pragma is implemented for compatibility with DEC
4544 Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal
4545 configuration pragma is the preferred usage in GNAT@.
4547 @node Pragma Suppress_Exception_Locations
4548 @unnumberedsec Pragma Suppress_Exception_Locations
4549 @findex Suppress_Exception_Locations
4553 @smallexample @c ada
4554 pragma Suppress_Exception_Locations;
4558 In normal mode, a raise statement for an exception by default generates
4559 an exception message giving the file name and line number for the location
4560 of the raise. This is useful for debugging and logging purposes, but this
4561 entails extra space for the strings for the messages. The configuration
4562 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4563 generation of these strings, with the result that space is saved, but the
4564 exception message for such raises is null. This configuration pragma may
4565 appear in a global configuration pragma file, or in a specific unit as
4566 usual. It is not required that this pragma be used consistently within
4567 a partition, so it is fine to have some units within a partition compiled
4568 with this pragma and others compiled in normal mode without it.
4570 @node Pragma Suppress_Initialization
4571 @unnumberedsec Pragma Suppress_Initialization
4572 @findex Suppress_Initialization
4573 @cindex Suppressing initialization
4574 @cindex Initialization, suppression of
4578 @smallexample @c ada
4579 pragma Suppress_Initialization ([Entity =>] type_Name);
4583 This pragma suppresses any implicit or explicit initialization
4584 associated with the given type name for all variables of this type.
4586 @node Pragma Task_Info
4587 @unnumberedsec Pragma Task_Info
4592 @smallexample @c ada
4593 pragma Task_Info (EXPRESSION);
4597 This pragma appears within a task definition (like pragma
4598 @code{Priority}) and applies to the task in which it appears. The
4599 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4600 The @code{Task_Info} pragma provides system dependent control over
4601 aspects of tasking implementation, for example, the ability to map
4602 tasks to specific processors. For details on the facilities available
4603 for the version of GNAT that you are using, see the documentation
4604 in the spec of package System.Task_Info in the runtime
4607 @node Pragma Task_Name
4608 @unnumberedsec Pragma Task_Name
4613 @smallexample @c ada
4614 pragma Task_Name (string_EXPRESSION);
4618 This pragma appears within a task definition (like pragma
4619 @code{Priority}) and applies to the task in which it appears. The
4620 argument must be of type String, and provides a name to be used for
4621 the task instance when the task is created. Note that this expression
4622 is not required to be static, and in particular, it can contain
4623 references to task discriminants. This facility can be used to
4624 provide different names for different tasks as they are created,
4625 as illustrated in the example below.
4627 The task name is recorded internally in the run-time structures
4628 and is accessible to tools like the debugger. In addition the
4629 routine @code{Ada.Task_Identification.Image} will return this
4630 string, with a unique task address appended.
4632 @smallexample @c ada
4633 -- Example of the use of pragma Task_Name
4635 with Ada.Task_Identification;
4636 use Ada.Task_Identification;
4637 with Text_IO; use Text_IO;
4640 type Astring is access String;
4642 task type Task_Typ (Name : access String) is
4643 pragma Task_Name (Name.all);
4646 task body Task_Typ is
4647 Nam : constant String := Image (Current_Task);
4649 Put_Line ("-->" & Nam (1 .. 14) & "<--");
4652 type Ptr_Task is access Task_Typ;
4653 Task_Var : Ptr_Task;
4657 new Task_Typ (new String'("This is task 1"));
4659 new Task_Typ (new String'("This is task 2"));
4663 @node Pragma Task_Storage
4664 @unnumberedsec Pragma Task_Storage
4665 @findex Task_Storage
4668 @smallexample @c ada
4669 pragma Task_Storage (
4670 [Task_Type =>] LOCAL_NAME,
4671 [Top_Guard =>] static_integer_EXPRESSION);
4675 This pragma specifies the length of the guard area for tasks. The guard
4676 area is an additional storage area allocated to a task. A value of zero
4677 means that either no guard area is created or a minimal guard area is
4678 created, depending on the target. This pragma can appear anywhere a
4679 @code{Storage_Size} attribute definition clause is allowed for a task
4682 @node Pragma Thread_Local_Storage
4683 @unnumberedsec Pragma Thread_Local_Storage
4684 @findex Thread_Local_Storage
4685 @cindex Task specific storage
4686 @cindex TLS (Thread Local Storage)
4689 @smallexample @c ada
4690 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
4694 This pragma specifies that the specified entity, which must be
4695 a variable declared in a library level package, is to be marked as
4696 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
4697 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
4698 (and hence each Ada task) to see a distinct copy of the variable.
4700 The variable may not have default initialization, and if there is
4701 an explicit initialization, it must be either @code{null} for an
4702 access variable, or a static expression for a scalar variable.
4703 This provides a low level mechanism similar to that provided by
4704 the @code{Ada.Task_Attributes} package, but much more efficient
4705 and is also useful in writing interface code that will interact
4706 with foreign threads.
4708 If this pragma is used on a system where @code{TLS} is not supported,
4709 then an error message will be generated and the program will be rejected.
4711 @node Pragma Time_Slice
4712 @unnumberedsec Pragma Time_Slice
4717 @smallexample @c ada
4718 pragma Time_Slice (static_duration_EXPRESSION);
4722 For implementations of GNAT on operating systems where it is possible
4723 to supply a time slice value, this pragma may be used for this purpose.
4724 It is ignored if it is used in a system that does not allow this control,
4725 or if it appears in other than the main program unit.
4727 Note that the effect of this pragma is identical to the effect of the
4728 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4731 @unnumberedsec Pragma Title
4736 @smallexample @c ada
4737 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4740 [Title =>] STRING_LITERAL,
4741 | [Subtitle =>] STRING_LITERAL
4745 Syntax checked but otherwise ignored by GNAT@. This is a listing control
4746 pragma used in DEC Ada 83 implementations to provide a title and/or
4747 subtitle for the program listing. The program listing generated by GNAT
4748 does not have titles or subtitles.
4750 Unlike other pragmas, the full flexibility of named notation is allowed
4751 for this pragma, i.e.@: the parameters may be given in any order if named
4752 notation is used, and named and positional notation can be mixed
4753 following the normal rules for procedure calls in Ada.
4755 @node Pragma Unchecked_Union
4756 @unnumberedsec Pragma Unchecked_Union
4758 @findex Unchecked_Union
4762 @smallexample @c ada
4763 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4767 This pragma is used to specify a representation of a record type that is
4768 equivalent to a C union. It was introduced as a GNAT implementation defined
4769 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4770 pragma, making it language defined, and GNAT fully implements this extended
4771 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4772 details, consult the Ada 2005 Reference Manual, section B.3.3.
4774 @node Pragma Unimplemented_Unit
4775 @unnumberedsec Pragma Unimplemented_Unit
4776 @findex Unimplemented_Unit
4780 @smallexample @c ada
4781 pragma Unimplemented_Unit;
4785 If this pragma occurs in a unit that is processed by the compiler, GNAT
4786 aborts with the message @samp{@var{xxx} not implemented}, where
4787 @var{xxx} is the name of the current compilation unit. This pragma is
4788 intended to allow the compiler to handle unimplemented library units in
4791 The abort only happens if code is being generated. Thus you can use
4792 specs of unimplemented packages in syntax or semantic checking mode.
4794 @node Pragma Universal_Aliasing
4795 @unnumberedsec Pragma Universal_Aliasing
4796 @findex Universal_Aliasing
4800 @smallexample @c ada
4801 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4805 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4806 declarative part. The effect is to inhibit strict type-based aliasing
4807 optimization for the given type. In other words, the effect is as though
4808 access types designating this type were subject to pragma No_Strict_Aliasing.
4809 For a detailed description of the strict aliasing optimization, and the
4810 situations in which it must be suppressed, @xref{Optimization and Strict
4811 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4813 @node Pragma Universal_Data
4814 @unnumberedsec Pragma Universal_Data
4815 @findex Universal_Data
4819 @smallexample @c ada
4820 pragma Universal_Data [(library_unit_Name)];
4824 This pragma is supported only for the AAMP target and is ignored for
4825 other targets. The pragma specifies that all library-level objects
4826 (Counter 0 data) associated with the library unit are to be accessed
4827 and updated using universal addressing (24-bit addresses for AAMP5)
4828 rather than the default of 16-bit Data Environment (DENV) addressing.
4829 Use of this pragma will generally result in less efficient code for
4830 references to global data associated with the library unit, but
4831 allows such data to be located anywhere in memory. This pragma is
4832 a library unit pragma, but can also be used as a configuration pragma
4833 (including use in the @file{gnat.adc} file). The functionality
4834 of this pragma is also available by applying the -univ switch on the
4835 compilations of units where universal addressing of the data is desired.
4837 @node Pragma Unmodified
4838 @unnumberedsec Pragma Unmodified
4840 @cindex Warnings, unmodified
4844 @smallexample @c ada
4845 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4849 This pragma signals that the assignable entities (variables,
4850 @code{out} parameters, @code{in out} parameters) whose names are listed are
4851 deliberately not assigned in the current source unit. This
4852 suppresses warnings about the
4853 entities being referenced but not assigned, and in addition a warning will be
4854 generated if one of these entities is in fact assigned in the
4855 same unit as the pragma (or in the corresponding body, or one
4858 This is particularly useful for clearly signaling that a particular
4859 parameter is not modified, even though the spec suggests that it might
4862 @node Pragma Unreferenced
4863 @unnumberedsec Pragma Unreferenced
4864 @findex Unreferenced
4865 @cindex Warnings, unreferenced
4869 @smallexample @c ada
4870 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4871 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4875 This pragma signals that the entities whose names are listed are
4876 deliberately not referenced in the current source unit. This
4877 suppresses warnings about the
4878 entities being unreferenced, and in addition a warning will be
4879 generated if one of these entities is in fact referenced in the
4880 same unit as the pragma (or in the corresponding body, or one
4883 This is particularly useful for clearly signaling that a particular
4884 parameter is not referenced in some particular subprogram implementation
4885 and that this is deliberate. It can also be useful in the case of
4886 objects declared only for their initialization or finalization side
4889 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4890 current scope, then the entity most recently declared is the one to which
4891 the pragma applies. Note that in the case of accept formals, the pragma
4892 Unreferenced may appear immediately after the keyword @code{do} which
4893 allows the indication of whether or not accept formals are referenced
4894 or not to be given individually for each accept statement.
4896 The left hand side of an assignment does not count as a reference for the
4897 purpose of this pragma. Thus it is fine to assign to an entity for which
4898 pragma Unreferenced is given.
4900 Note that if a warning is desired for all calls to a given subprogram,
4901 regardless of whether they occur in the same unit as the subprogram
4902 declaration, then this pragma should not be used (calls from another
4903 unit would not be flagged); pragma Obsolescent can be used instead
4904 for this purpose, see @xref{Pragma Obsolescent}.
4906 The second form of pragma @code{Unreferenced} is used within a context
4907 clause. In this case the arguments must be unit names of units previously
4908 mentioned in @code{with} clauses (similar to the usage of pragma
4909 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4910 units and unreferenced entities within these units.
4912 @node Pragma Unreferenced_Objects
4913 @unnumberedsec Pragma Unreferenced_Objects
4914 @findex Unreferenced_Objects
4915 @cindex Warnings, unreferenced
4919 @smallexample @c ada
4920 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4924 This pragma signals that for the types or subtypes whose names are
4925 listed, objects which are declared with one of these types or subtypes may
4926 not be referenced, and if no references appear, no warnings are given.
4928 This is particularly useful for objects which are declared solely for their
4929 initialization and finalization effect. Such variables are sometimes referred
4930 to as RAII variables (Resource Acquisition Is Initialization). Using this
4931 pragma on the relevant type (most typically a limited controlled type), the
4932 compiler will automatically suppress unwanted warnings about these variables
4933 not being referenced.
4935 @node Pragma Unreserve_All_Interrupts
4936 @unnumberedsec Pragma Unreserve_All_Interrupts
4937 @findex Unreserve_All_Interrupts
4941 @smallexample @c ada
4942 pragma Unreserve_All_Interrupts;
4946 Normally certain interrupts are reserved to the implementation. Any attempt
4947 to attach an interrupt causes Program_Error to be raised, as described in
4948 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
4949 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
4950 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4951 interrupt execution.
4953 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4954 a program, then all such interrupts are unreserved. This allows the
4955 program to handle these interrupts, but disables their standard
4956 functions. For example, if this pragma is used, then pressing
4957 @kbd{Ctrl-C} will not automatically interrupt execution. However,
4958 a program can then handle the @code{SIGINT} interrupt as it chooses.
4960 For a full list of the interrupts handled in a specific implementation,
4961 see the source code for the spec of @code{Ada.Interrupts.Names} in
4962 file @file{a-intnam.ads}. This is a target dependent file that contains the
4963 list of interrupts recognized for a given target. The documentation in
4964 this file also specifies what interrupts are affected by the use of
4965 the @code{Unreserve_All_Interrupts} pragma.
4967 For a more general facility for controlling what interrupts can be
4968 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4969 of the @code{Unreserve_All_Interrupts} pragma.
4971 @node Pragma Unsuppress
4972 @unnumberedsec Pragma Unsuppress
4977 @smallexample @c ada
4978 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4982 This pragma undoes the effect of a previous pragma @code{Suppress}. If
4983 there is no corresponding pragma @code{Suppress} in effect, it has no
4984 effect. The range of the effect is the same as for pragma
4985 @code{Suppress}. The meaning of the arguments is identical to that used
4986 in pragma @code{Suppress}.
4988 One important application is to ensure that checks are on in cases where
4989 code depends on the checks for its correct functioning, so that the code
4990 will compile correctly even if the compiler switches are set to suppress
4993 @node Pragma Use_VADS_Size
4994 @unnumberedsec Pragma Use_VADS_Size
4995 @cindex @code{Size}, VADS compatibility
4996 @findex Use_VADS_Size
5000 @smallexample @c ada
5001 pragma Use_VADS_Size;
5005 This is a configuration pragma. In a unit to which it applies, any use
5006 of the 'Size attribute is automatically interpreted as a use of the
5007 'VADS_Size attribute. Note that this may result in incorrect semantic
5008 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
5009 the handling of existing code which depends on the interpretation of Size
5010 as implemented in the VADS compiler. See description of the VADS_Size
5011 attribute for further details.
5013 @node Pragma Validity_Checks
5014 @unnumberedsec Pragma Validity_Checks
5015 @findex Validity_Checks
5019 @smallexample @c ada
5020 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5024 This pragma is used in conjunction with compiler switches to control the
5025 built-in validity checking provided by GNAT@. The compiler switches, if set
5026 provide an initial setting for the switches, and this pragma may be used
5027 to modify these settings, or the settings may be provided entirely by
5028 the use of the pragma. This pragma can be used anywhere that a pragma
5029 is legal, including use as a configuration pragma (including use in
5030 the @file{gnat.adc} file).
5032 The form with a string literal specifies which validity options are to be
5033 activated. The validity checks are first set to include only the default
5034 reference manual settings, and then a string of letters in the string
5035 specifies the exact set of options required. The form of this string
5036 is exactly as described for the @option{-gnatVx} compiler switch (see the
5037 GNAT users guide for details). For example the following two methods
5038 can be used to enable validity checking for mode @code{in} and
5039 @code{in out} subprogram parameters:
5043 @smallexample @c ada
5044 pragma Validity_Checks ("im");
5049 gcc -c -gnatVim @dots{}
5054 The form ALL_CHECKS activates all standard checks (its use is equivalent
5055 to the use of the @code{gnatva} switch.
5057 The forms with @code{Off} and @code{On}
5058 can be used to temporarily disable validity checks
5059 as shown in the following example:
5061 @smallexample @c ada
5065 pragma Validity_Checks ("c"); -- validity checks for copies
5066 pragma Validity_Checks (Off); -- turn off validity checks
5067 A := B; -- B will not be validity checked
5068 pragma Validity_Checks (On); -- turn validity checks back on
5069 A := C; -- C will be validity checked
5072 @node Pragma Volatile
5073 @unnumberedsec Pragma Volatile
5078 @smallexample @c ada
5079 pragma Volatile (LOCAL_NAME);
5083 This pragma is defined by the Ada Reference Manual, and the GNAT
5084 implementation is fully conformant with this definition. The reason it
5085 is mentioned in this section is that a pragma of the same name was supplied
5086 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
5087 implementation of pragma Volatile is upwards compatible with the
5088 implementation in DEC Ada 83.
5090 @node Pragma Warnings
5091 @unnumberedsec Pragma Warnings
5096 @smallexample @c ada
5097 pragma Warnings (On | Off);
5098 pragma Warnings (On | Off, LOCAL_NAME);
5099 pragma Warnings (static_string_EXPRESSION);
5100 pragma Warnings (On | Off, static_string_EXPRESSION);
5104 Normally warnings are enabled, with the output being controlled by
5105 the command line switch. Warnings (@code{Off}) turns off generation of
5106 warnings until a Warnings (@code{On}) is encountered or the end of the
5107 current unit. If generation of warnings is turned off using this
5108 pragma, then no warning messages are output, regardless of the
5109 setting of the command line switches.
5111 The form with a single argument may be used as a configuration pragma.
5113 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5114 the specified entity. This suppression is effective from the point where
5115 it occurs till the end of the extended scope of the variable (similar to
5116 the scope of @code{Suppress}).
5118 The form with a single static_string_EXPRESSION argument provides more precise
5119 control over which warnings are active. The string is a list of letters
5120 specifying which warnings are to be activated and which deactivated. The
5121 code for these letters is the same as the string used in the command
5122 line switch controlling warnings. The following is a brief summary. For
5123 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5127 a turn on all optional warnings (except d h l .o)
5128 A turn off all optional warnings
5129 .a* turn on warnings for failing assertions
5130 .A turn off warnings for failing assertions
5131 b turn on warnings for bad fixed value (not multiple of small)
5132 B* turn off warnings for bad fixed value (not multiple of small)
5133 c turn on warnings for constant conditional
5134 C* turn off warnings for constant conditional
5135 .c turn on warnings for unrepped components
5136 .C* turn off warnings for unrepped components
5137 d turn on warnings for implicit dereference
5138 D* turn off warnings for implicit dereference
5139 e treat all warnings as errors
5140 f turn on warnings for unreferenced formal
5141 F* turn off warnings for unreferenced formal
5142 g* turn on warnings for unrecognized pragma
5143 G turn off warnings for unrecognized pragma
5144 h turn on warnings for hiding variable
5145 H* turn off warnings for hiding variable
5146 i* turn on warnings for implementation unit
5147 I turn off warnings for implementation unit
5148 j turn on warnings for obsolescent (annex J) feature
5149 J* turn off warnings for obsolescent (annex J) feature
5150 k turn on warnings on constant variable
5151 K* turn off warnings on constant variable
5152 l turn on warnings for missing elaboration pragma
5153 L* turn off warnings for missing elaboration pragma
5154 m turn on warnings for variable assigned but not read
5155 M* turn off warnings for variable assigned but not read
5156 n* normal warning mode (cancels -gnatws/-gnatwe)
5157 o* turn on warnings for address clause overlay
5158 O turn off warnings for address clause overlay
5159 .o turn on warnings for out parameters assigned but not read
5160 .O* turn off warnings for out parameters assigned but not read
5161 p turn on warnings for ineffective pragma Inline in frontend
5162 P* turn off warnings for ineffective pragma Inline in frontend
5163 q* turn on warnings for questionable missing parentheses
5164 Q turn off warnings for questionable missing parentheses
5165 r turn on warnings for redundant construct
5166 R* turn off warnings for redundant construct
5167 .r turn on warnings for object renaming function
5168 .R* turn off warnings for object renaming function
5169 s suppress all warnings
5170 t turn on warnings for tracking deleted code
5171 T* turn off warnings for tracking deleted code
5172 u turn on warnings for unused entity
5173 U* turn off warnings for unused entity
5174 v* turn on warnings for unassigned variable
5175 V turn off warnings for unassigned variable
5176 w* turn on warnings for wrong low bound assumption
5177 W turn off warnings for wrong low bound assumption
5178 x* turn on warnings for export/import
5179 X turn off warnings for export/import
5180 .x turn on warnings for non-local exceptions
5181 .X* turn off warnings for non-local exceptions
5182 y* turn on warnings for Ada 2005 incompatibility
5183 Y turn off warnings for Ada 2005 incompatibility
5184 z* turn on convention/size/align warnings for unchecked conversion
5185 Z turn off convention/size/align warnings for unchecked conversion
5186 * indicates default in above list
5190 The specified warnings will be in effect until the end of the program
5191 or another pragma Warnings is encountered. The effect of the pragma is
5192 cumulative. Initially the set of warnings is the standard default set
5193 as possibly modified by compiler switches. Then each pragma Warning
5194 modifies this set of warnings as specified. This form of the pragma may
5195 also be used as a configuration pragma.
5197 The fourth form, with an On|Off parameter and a string, is used to
5198 control individual messages, based on their text. The string argument
5199 is a pattern that is used to match against the text of individual
5200 warning messages (not including the initial "warning: " tag).
5202 The pattern may contain asterisks, which match zero or more characters in
5203 the message. For example, you can use
5204 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5205 message @code{warning: 960 bits of "a" unused}. No other regular
5206 expression notations are permitted. All characters other than asterisk in
5207 these three specific cases are treated as literal characters in the match.
5209 There are two ways to use this pragma. The OFF form can be used as a
5210 configuration pragma. The effect is to suppress all warnings (if any)
5211 that match the pattern string throughout the compilation.
5213 The second usage is to suppress a warning locally, and in this case, two
5214 pragmas must appear in sequence:
5216 @smallexample @c ada
5217 pragma Warnings (Off, Pattern);
5218 @dots{} code where given warning is to be suppressed
5219 pragma Warnings (On, Pattern);
5223 In this usage, the pattern string must match in the Off and On pragmas,
5224 and at least one matching warning must be suppressed.
5226 @node Pragma Weak_External
5227 @unnumberedsec Pragma Weak_External
5228 @findex Weak_External
5232 @smallexample @c ada
5233 pragma Weak_External ([Entity =>] LOCAL_NAME);
5237 @var{LOCAL_NAME} must refer to an object that is declared at the library
5238 level. This pragma specifies that the given entity should be marked as a
5239 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5240 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5241 of a regular symbol, that is to say a symbol that does not have to be
5242 resolved by the linker if used in conjunction with a pragma Import.
5244 When a weak symbol is not resolved by the linker, its address is set to
5245 zero. This is useful in writing interfaces to external modules that may
5246 or may not be linked in the final executable, for example depending on
5247 configuration settings.
5249 If a program references at run time an entity to which this pragma has been
5250 applied, and the corresponding symbol was not resolved at link time, then
5251 the execution of the program is erroneous. It is not erroneous to take the
5252 Address of such an entity, for example to guard potential references,
5253 as shown in the example below.
5255 Some file formats do not support weak symbols so not all target machines
5256 support this pragma.
5258 @smallexample @c ada
5259 -- Example of the use of pragma Weak_External
5261 package External_Module is
5263 pragma Import (C, key);
5264 pragma Weak_External (key);
5265 function Present return boolean;
5266 end External_Module;
5268 with System; use System;
5269 package body External_Module is
5270 function Present return boolean is
5272 return key'Address /= System.Null_Address;
5274 end External_Module;
5277 @node Pragma Wide_Character_Encoding
5278 @unnumberedsec Pragma Wide_Character_Encoding
5279 @findex Wide_Character_Encoding
5283 @smallexample @c ada
5284 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5288 This pragma specifies the wide character encoding to be used in program
5289 source text appearing subsequently. It is a configuration pragma, but may
5290 also be used at any point that a pragma is allowed, and it is permissible
5291 to have more than one such pragma in a file, allowing multiple encodings
5292 to appear within the same file.
5294 The argument can be an identifier or a character literal. In the identifier
5295 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5296 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5297 case it is correspondingly one of the characters @samp{h}, @samp{u},
5298 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5300 Note that when the pragma is used within a file, it affects only the
5301 encoding within that file, and does not affect withed units, specs,
5304 @node Implementation Defined Attributes
5305 @chapter Implementation Defined Attributes
5306 Ada defines (throughout the Ada reference manual,
5307 summarized in Annex K),
5308 a set of attributes that provide useful additional functionality in all
5309 areas of the language. These language defined attributes are implemented
5310 in GNAT and work as described in the Ada Reference Manual.
5312 In addition, Ada allows implementations to define additional
5313 attributes whose meaning is defined by the implementation. GNAT provides
5314 a number of these implementation-dependent attributes which can be used
5315 to extend and enhance the functionality of the compiler. This section of
5316 the GNAT reference manual describes these additional attributes.
5318 Note that any program using these attributes may not be portable to
5319 other compilers (although GNAT implements this set of attributes on all
5320 platforms). Therefore if portability to other compilers is an important
5321 consideration, you should minimize the use of these attributes.
5332 * Default_Bit_Order::
5342 * Has_Access_Values::
5343 * Has_Discriminants::
5350 * Max_Interrupt_Priority::
5352 * Maximum_Alignment::
5357 * Passed_By_Reference::
5370 * Unconstrained_Array::
5371 * Universal_Literal_String::
5372 * Unrestricted_Access::
5380 @unnumberedsec Abort_Signal
5381 @findex Abort_Signal
5383 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5384 prefix) provides the entity for the special exception used to signal
5385 task abort or asynchronous transfer of control. Normally this attribute
5386 should only be used in the tasking runtime (it is highly peculiar, and
5387 completely outside the normal semantics of Ada, for a user program to
5388 intercept the abort exception).
5391 @unnumberedsec Address_Size
5392 @cindex Size of @code{Address}
5393 @findex Address_Size
5395 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5396 prefix) is a static constant giving the number of bits in an
5397 @code{Address}. It is the same value as System.Address'Size,
5398 but has the advantage of being static, while a direct
5399 reference to System.Address'Size is non-static because Address
5403 @unnumberedsec Asm_Input
5406 The @code{Asm_Input} attribute denotes a function that takes two
5407 parameters. The first is a string, the second is an expression of the
5408 type designated by the prefix. The first (string) argument is required
5409 to be a static expression, and is the constraint for the parameter,
5410 (e.g.@: what kind of register is required). The second argument is the
5411 value to be used as the input argument. The possible values for the
5412 constant are the same as those used in the RTL, and are dependent on
5413 the configuration file used to built the GCC back end.
5414 @ref{Machine Code Insertions}
5417 @unnumberedsec Asm_Output
5420 The @code{Asm_Output} attribute denotes a function that takes two
5421 parameters. The first is a string, the second is the name of a variable
5422 of the type designated by the attribute prefix. The first (string)
5423 argument is required to be a static expression and designates the
5424 constraint for the parameter (e.g.@: what kind of register is
5425 required). The second argument is the variable to be updated with the
5426 result. The possible values for constraint are the same as those used in
5427 the RTL, and are dependent on the configuration file used to build the
5428 GCC back end. If there are no output operands, then this argument may
5429 either be omitted, or explicitly given as @code{No_Output_Operands}.
5430 @ref{Machine Code Insertions}
5433 @unnumberedsec AST_Entry
5437 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
5438 the name of an entry, it yields a value of the predefined type AST_Handler
5439 (declared in the predefined package System, as extended by the use of
5440 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
5441 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
5442 Language Reference Manual}, section 9.12a.
5447 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5448 offset within the storage unit (byte) that contains the first bit of
5449 storage allocated for the object. The value of this attribute is of the
5450 type @code{Universal_Integer}, and is always a non-negative number not
5451 exceeding the value of @code{System.Storage_Unit}.
5453 For an object that is a variable or a constant allocated in a register,
5454 the value is zero. (The use of this attribute does not force the
5455 allocation of a variable to memory).
5457 For an object that is a formal parameter, this attribute applies
5458 to either the matching actual parameter or to a copy of the
5459 matching actual parameter.
5461 For an access object the value is zero. Note that
5462 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5463 designated object. Similarly for a record component
5464 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5465 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5466 are subject to index checks.
5468 This attribute is designed to be compatible with the DEC Ada 83 definition
5469 and implementation of the @code{Bit} attribute.
5472 @unnumberedsec Bit_Position
5473 @findex Bit_Position
5475 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5476 of the fields of the record type, yields the bit
5477 offset within the record contains the first bit of
5478 storage allocated for the object. The value of this attribute is of the
5479 type @code{Universal_Integer}. The value depends only on the field
5480 @var{C} and is independent of the alignment of
5481 the containing record @var{R}.
5484 @unnumberedsec Code_Address
5485 @findex Code_Address
5486 @cindex Subprogram address
5487 @cindex Address of subprogram code
5490 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5491 intended effect seems to be to provide
5492 an address value which can be used to call the subprogram by means of
5493 an address clause as in the following example:
5495 @smallexample @c ada
5496 procedure K is @dots{}
5499 for L'Address use K'Address;
5500 pragma Import (Ada, L);
5504 A call to @code{L} is then expected to result in a call to @code{K}@.
5505 In Ada 83, where there were no access-to-subprogram values, this was
5506 a common work-around for getting the effect of an indirect call.
5507 GNAT implements the above use of @code{Address} and the technique
5508 illustrated by the example code works correctly.
5510 However, for some purposes, it is useful to have the address of the start
5511 of the generated code for the subprogram. On some architectures, this is
5512 not necessarily the same as the @code{Address} value described above.
5513 For example, the @code{Address} value may reference a subprogram
5514 descriptor rather than the subprogram itself.
5516 The @code{'Code_Address} attribute, which can only be applied to
5517 subprogram entities, always returns the address of the start of the
5518 generated code of the specified subprogram, which may or may not be
5519 the same value as is returned by the corresponding @code{'Address}
5522 @node Default_Bit_Order
5523 @unnumberedsec Default_Bit_Order
5525 @cindex Little endian
5526 @findex Default_Bit_Order
5528 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5529 permissible prefix), provides the value @code{System.Default_Bit_Order}
5530 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5531 @code{Low_Order_First}). This is used to construct the definition of
5532 @code{Default_Bit_Order} in package @code{System}.
5535 @unnumberedsec Elaborated
5538 The prefix of the @code{'Elaborated} attribute must be a unit name. The
5539 value is a Boolean which indicates whether or not the given unit has been
5540 elaborated. This attribute is primarily intended for internal use by the
5541 generated code for dynamic elaboration checking, but it can also be used
5542 in user programs. The value will always be True once elaboration of all
5543 units has been completed. An exception is for units which need no
5544 elaboration, the value is always False for such units.
5547 @unnumberedsec Elab_Body
5550 This attribute can only be applied to a program unit name. It returns
5551 the entity for the corresponding elaboration procedure for elaborating
5552 the body of the referenced unit. This is used in the main generated
5553 elaboration procedure by the binder and is not normally used in any
5554 other context. However, there may be specialized situations in which it
5555 is useful to be able to call this elaboration procedure from Ada code,
5556 e.g.@: if it is necessary to do selective re-elaboration to fix some
5560 @unnumberedsec Elab_Spec
5563 This attribute can only be applied to a program unit name. It returns
5564 the entity for the corresponding elaboration procedure for elaborating
5565 the spec of the referenced unit. This is used in the main
5566 generated elaboration procedure by the binder and is not normally used
5567 in any other context. However, there may be specialized situations in
5568 which it is useful to be able to call this elaboration procedure from
5569 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5574 @cindex Ada 83 attributes
5577 The @code{Emax} attribute is provided for compatibility with Ada 83. See
5578 the Ada 83 reference manual for an exact description of the semantics of
5582 @unnumberedsec Enabled
5585 The @code{Enabled} attribute allows an application program to check at compile
5586 time to see if the designated check is currently enabled. The prefix is a
5587 simple identifier, referencing any predefined check name (other than
5588 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5589 no argument is given for the attribute, the check is for the general state
5590 of the check, if an argument is given, then it is an entity name, and the
5591 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5592 given naming the entity (if not, then the argument is ignored).
5594 Note that instantiations inherit the check status at the point of the
5595 instantiation, so a useful idiom is to have a library package that
5596 introduces a check name with @code{pragma Check_Name}, and then contains
5597 generic packages or subprograms which use the @code{Enabled} attribute
5598 to see if the check is enabled. A user of this package can then issue
5599 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5600 the package or subprogram, controlling whether the check will be present.
5603 @unnumberedsec Enum_Rep
5604 @cindex Representation of enums
5607 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5608 function with the following spec:
5610 @smallexample @c ada
5611 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5612 return @i{Universal_Integer};
5616 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5617 enumeration type or to a non-overloaded enumeration
5618 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
5619 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5620 enumeration literal or object.
5622 The function returns the representation value for the given enumeration
5623 value. This will be equal to value of the @code{Pos} attribute in the
5624 absence of an enumeration representation clause. This is a static
5625 attribute (i.e.@: the result is static if the argument is static).
5627 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5628 in which case it simply returns the integer value. The reason for this
5629 is to allow it to be used for @code{(<>)} discrete formal arguments in
5630 a generic unit that can be instantiated with either enumeration types
5631 or integer types. Note that if @code{Enum_Rep} is used on a modular
5632 type whose upper bound exceeds the upper bound of the largest signed
5633 integer type, and the argument is a variable, so that the universal
5634 integer calculation is done at run time, then the call to @code{Enum_Rep}
5635 may raise @code{Constraint_Error}.
5638 @unnumberedsec Enum_Val
5639 @cindex Representation of enums
5642 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5643 function with the following spec:
5645 @smallexample @c ada
5646 function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5647 return @var{S}'Base};
5651 The function returns the enumeration value whose representation matches the
5652 argument, or raises Constraint_Error if no enumeration literal of the type
5653 has the matching value.
5654 This will be equal to value of the @code{Val} attribute in the
5655 absence of an enumeration representation clause. This is a static
5656 attribute (i.e.@: the result is static if the argument is static).
5659 @unnumberedsec Epsilon
5660 @cindex Ada 83 attributes
5663 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
5664 the Ada 83 reference manual for an exact description of the semantics of
5668 @unnumberedsec Fixed_Value
5671 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5672 function with the following specification:
5674 @smallexample @c ada
5675 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5680 The value returned is the fixed-point value @var{V} such that
5682 @smallexample @c ada
5683 @var{V} = Arg * @var{S}'Small
5687 The effect is thus similar to first converting the argument to the
5688 integer type used to represent @var{S}, and then doing an unchecked
5689 conversion to the fixed-point type. The difference is
5690 that there are full range checks, to ensure that the result is in range.
5691 This attribute is primarily intended for use in implementation of the
5692 input-output functions for fixed-point values.
5694 @node Has_Access_Values
5695 @unnumberedsec Has_Access_Values
5696 @cindex Access values, testing for
5697 @findex Has_Access_Values
5699 The prefix of the @code{Has_Access_Values} attribute is a type. The result
5700 is a Boolean value which is True if the is an access type, or is a composite
5701 type with a component (at any nesting depth) that is an access type, and is
5703 The intended use of this attribute is in conjunction with generic
5704 definitions. If the attribute is applied to a generic private type, it
5705 indicates whether or not the corresponding actual type has access values.
5707 @node Has_Discriminants
5708 @unnumberedsec Has_Discriminants
5709 @cindex Discriminants, testing for
5710 @findex Has_Discriminants
5712 The prefix of the @code{Has_Discriminants} attribute is a type. The result
5713 is a Boolean value which is True if the type has discriminants, and False
5714 otherwise. The intended use of this attribute is in conjunction with generic
5715 definitions. If the attribute is applied to a generic private type, it
5716 indicates whether or not the corresponding actual type has discriminants.
5722 The @code{Img} attribute differs from @code{Image} in that it may be
5723 applied to objects as well as types, in which case it gives the
5724 @code{Image} for the subtype of the object. This is convenient for
5727 @smallexample @c ada
5728 Put_Line ("X = " & X'Img);
5732 has the same meaning as the more verbose:
5734 @smallexample @c ada
5735 Put_Line ("X = " & @var{T}'Image (X));
5739 where @var{T} is the (sub)type of the object @code{X}.
5742 @unnumberedsec Integer_Value
5743 @findex Integer_Value
5745 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5746 function with the following spec:
5748 @smallexample @c ada
5749 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5754 The value returned is the integer value @var{V}, such that
5756 @smallexample @c ada
5757 Arg = @var{V} * @var{T}'Small
5761 where @var{T} is the type of @code{Arg}.
5762 The effect is thus similar to first doing an unchecked conversion from
5763 the fixed-point type to its corresponding implementation type, and then
5764 converting the result to the target integer type. The difference is
5765 that there are full range checks, to ensure that the result is in range.
5766 This attribute is primarily intended for use in implementation of the
5767 standard input-output functions for fixed-point values.
5770 @unnumberedsec Invalid_Value
5771 @findex Invalid_Value
5773 For every scalar type S, S'Invalid_Value returns an undefined value of the
5774 type. If possible this value is an invalid representation for the type. The
5775 value returned is identical to the value used to initialize an otherwise
5776 uninitialized value of the type if pragma Initialize_Scalars is used,
5777 including the ability to modify the value with the binder -Sxx flag and
5778 relevant environment variables at run time.
5781 @unnumberedsec Large
5782 @cindex Ada 83 attributes
5785 The @code{Large} attribute is provided for compatibility with Ada 83. See
5786 the Ada 83 reference manual for an exact description of the semantics of
5790 @unnumberedsec Machine_Size
5791 @findex Machine_Size
5793 This attribute is identical to the @code{Object_Size} attribute. It is
5794 provided for compatibility with the DEC Ada 83 attribute of this name.
5797 @unnumberedsec Mantissa
5798 @cindex Ada 83 attributes
5801 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
5802 the Ada 83 reference manual for an exact description of the semantics of
5805 @node Max_Interrupt_Priority
5806 @unnumberedsec Max_Interrupt_Priority
5807 @cindex Interrupt priority, maximum
5808 @findex Max_Interrupt_Priority
5810 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5811 permissible prefix), provides the same value as
5812 @code{System.Max_Interrupt_Priority}.
5815 @unnumberedsec Max_Priority
5816 @cindex Priority, maximum
5817 @findex Max_Priority
5819 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5820 prefix) provides the same value as @code{System.Max_Priority}.
5822 @node Maximum_Alignment
5823 @unnumberedsec Maximum_Alignment
5824 @cindex Alignment, maximum
5825 @findex Maximum_Alignment
5827 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5828 permissible prefix) provides the maximum useful alignment value for the
5829 target. This is a static value that can be used to specify the alignment
5830 for an object, guaranteeing that it is properly aligned in all
5833 @node Mechanism_Code
5834 @unnumberedsec Mechanism_Code
5835 @cindex Return values, passing mechanism
5836 @cindex Parameters, passing mechanism
5837 @findex Mechanism_Code
5839 @code{@var{function}'Mechanism_Code} yields an integer code for the
5840 mechanism used for the result of function, and
5841 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5842 used for formal parameter number @var{n} (a static integer value with 1
5843 meaning the first parameter) of @var{subprogram}. The code returned is:
5851 by descriptor (default descriptor class)
5853 by descriptor (UBS: unaligned bit string)
5855 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5857 by descriptor (UBA: unaligned bit array)
5859 by descriptor (S: string, also scalar access type parameter)
5861 by descriptor (SB: string with arbitrary bounds)
5863 by descriptor (A: contiguous array)
5865 by descriptor (NCA: non-contiguous array)
5869 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5872 @node Null_Parameter
5873 @unnumberedsec Null_Parameter
5874 @cindex Zero address, passing
5875 @findex Null_Parameter
5877 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5878 type or subtype @var{T} allocated at machine address zero. The attribute
5879 is allowed only as the default expression of a formal parameter, or as
5880 an actual expression of a subprogram call. In either case, the
5881 subprogram must be imported.
5883 The identity of the object is represented by the address zero in the
5884 argument list, independent of the passing mechanism (explicit or
5887 This capability is needed to specify that a zero address should be
5888 passed for a record or other composite object passed by reference.
5889 There is no way of indicating this without the @code{Null_Parameter}
5893 @unnumberedsec Object_Size
5894 @cindex Size, used for objects
5897 The size of an object is not necessarily the same as the size of the type
5898 of an object. This is because by default object sizes are increased to be
5899 a multiple of the alignment of the object. For example,
5900 @code{Natural'Size} is
5901 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5902 Similarly, a record containing an integer and a character:
5904 @smallexample @c ada
5912 will have a size of 40 (that is @code{Rec'Size} will be 40. The
5913 alignment will be 4, because of the
5914 integer field, and so the default size of record objects for this type
5915 will be 64 (8 bytes).
5919 @cindex Capturing Old values
5920 @cindex Postconditions
5922 The attribute Prefix'Old can be used within a
5923 subprogram to refer to the value of the prefix on entry. So for
5924 example if you have an argument of a record type X called Arg1,
5925 you can refer to Arg1.Field'Old which yields the value of
5926 Arg1.Field on entry. The implementation simply involves generating
5927 an object declaration which captures the value on entry. Any
5928 prefix is allowed except one of a limited type (since limited
5929 types cannot be copied to capture their values) or a local variable
5930 (since it does not exist at subprogram entry time).
5932 The following example shows the use of 'Old to implement
5933 a test of a postcondition:
5935 @smallexample @c ada
5946 package body Old_Pkg is
5947 Count : Natural := 0;
5951 ... code manipulating the value of Count
5953 pragma Assert (Count = Count'Old + 1);
5959 Note that it is allowed to apply 'Old to a constant entity, but this will
5960 result in a warning, since the old and new values will always be the same.
5962 @node Passed_By_Reference
5963 @unnumberedsec Passed_By_Reference
5964 @cindex Parameters, when passed by reference
5965 @findex Passed_By_Reference
5967 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5968 a value of type @code{Boolean} value that is @code{True} if the type is
5969 normally passed by reference and @code{False} if the type is normally
5970 passed by copy in calls. For scalar types, the result is always @code{False}
5971 and is static. For non-scalar types, the result is non-static.
5974 @unnumberedsec Pool_Address
5975 @cindex Parameters, when passed by reference
5976 @findex Pool_Address
5978 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
5979 of X within its storage pool. This is the same as
5980 @code{@var{X}'Address}, except that for an unconstrained array whose
5981 bounds are allocated just before the first component,
5982 @code{@var{X}'Pool_Address} returns the address of those bounds,
5983 whereas @code{@var{X}'Address} returns the address of the first
5986 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
5987 the object is allocated'', which could be a user-defined storage pool,
5988 the global heap, on the stack, or in a static memory area. For an
5989 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
5990 what is passed to @code{Allocate} and returned from @code{Deallocate}.
5993 @unnumberedsec Range_Length
5994 @findex Range_Length
5996 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5997 the number of values represented by the subtype (zero for a null
5998 range). The result is static for static subtypes. @code{Range_Length}
5999 applied to the index subtype of a one dimensional array always gives the
6000 same result as @code{Range} applied to the array itself.
6003 @unnumberedsec Safe_Emax
6004 @cindex Ada 83 attributes
6007 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
6008 the Ada 83 reference manual for an exact description of the semantics of
6012 @unnumberedsec Safe_Large
6013 @cindex Ada 83 attributes
6016 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
6017 the Ada 83 reference manual for an exact description of the semantics of
6021 @unnumberedsec Small
6022 @cindex Ada 83 attributes
6025 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6027 GNAT also allows this attribute to be applied to floating-point types
6028 for compatibility with Ada 83. See
6029 the Ada 83 reference manual for an exact description of the semantics of
6030 this attribute when applied to floating-point types.
6033 @unnumberedsec Storage_Unit
6034 @findex Storage_Unit
6036 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6037 prefix) provides the same value as @code{System.Storage_Unit}.
6040 @unnumberedsec Stub_Type
6043 The GNAT implementation of remote access-to-classwide types is
6044 organized as described in AARM section E.4 (20.t): a value of an RACW type
6045 (designating a remote object) is represented as a normal access
6046 value, pointing to a "stub" object which in turn contains the
6047 necessary information to contact the designated remote object. A
6048 call on any dispatching operation of such a stub object does the
6049 remote call, if necessary, using the information in the stub object
6050 to locate the target partition, etc.
6052 For a prefix @code{T} that denotes a remote access-to-classwide type,
6053 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6055 By construction, the layout of @code{T'Stub_Type} is identical to that of
6056 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6057 unit @code{System.Partition_Interface}. Use of this attribute will create
6058 an implicit dependency on this unit.
6061 @unnumberedsec Target_Name
6064 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6065 prefix) provides a static string value that identifies the target
6066 for the current compilation. For GCC implementations, this is the
6067 standard gcc target name without the terminating slash (for
6068 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6074 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6075 provides the same value as @code{System.Tick},
6078 @unnumberedsec To_Address
6081 The @code{System'To_Address}
6082 (@code{System} is the only permissible prefix)
6083 denotes a function identical to
6084 @code{System.Storage_Elements.To_Address} except that
6085 it is a static attribute. This means that if its argument is
6086 a static expression, then the result of the attribute is a
6087 static expression. The result is that such an expression can be
6088 used in contexts (e.g.@: preelaborable packages) which require a
6089 static expression and where the function call could not be used
6090 (since the function call is always non-static, even if its
6091 argument is static).
6094 @unnumberedsec Type_Class
6097 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6098 the value of the type class for the full type of @var{type}. If
6099 @var{type} is a generic formal type, the value is the value for the
6100 corresponding actual subtype. The value of this attribute is of type
6101 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6103 @smallexample @c ada
6105 (Type_Class_Enumeration,
6107 Type_Class_Fixed_Point,
6108 Type_Class_Floating_Point,
6113 Type_Class_Address);
6117 Protected types yield the value @code{Type_Class_Task}, which thus
6118 applies to all concurrent types. This attribute is designed to
6119 be compatible with the DEC Ada 83 attribute of the same name.
6122 @unnumberedsec UET_Address
6125 The @code{UET_Address} attribute can only be used for a prefix which
6126 denotes a library package. It yields the address of the unit exception
6127 table when zero cost exception handling is used. This attribute is
6128 intended only for use within the GNAT implementation. See the unit
6129 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6130 for details on how this attribute is used in the implementation.
6132 @node Unconstrained_Array
6133 @unnumberedsec Unconstrained_Array
6134 @findex Unconstrained_Array
6136 The @code{Unconstrained_Array} attribute can be used with a prefix that
6137 denotes any type or subtype. It is a static attribute that yields
6138 @code{True} if the prefix designates an unconstrained array,
6139 and @code{False} otherwise. In a generic instance, the result is
6140 still static, and yields the result of applying this test to the
6143 @node Universal_Literal_String
6144 @unnumberedsec Universal_Literal_String
6145 @cindex Named numbers, representation of
6146 @findex Universal_Literal_String
6148 The prefix of @code{Universal_Literal_String} must be a named
6149 number. The static result is the string consisting of the characters of
6150 the number as defined in the original source. This allows the user
6151 program to access the actual text of named numbers without intermediate
6152 conversions and without the need to enclose the strings in quotes (which
6153 would preclude their use as numbers). This is used internally for the
6154 construction of values of the floating-point attributes from the file
6155 @file{ttypef.ads}, but may also be used by user programs.
6157 For example, the following program prints the first 50 digits of pi:
6159 @smallexample @c ada
6160 with Text_IO; use Text_IO;
6164 Put (Ada.Numerics.Pi'Universal_Literal_String);
6168 @node Unrestricted_Access
6169 @unnumberedsec Unrestricted_Access
6170 @cindex @code{Access}, unrestricted
6171 @findex Unrestricted_Access
6173 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6174 except that all accessibility and aliased view checks are omitted. This
6175 is a user-beware attribute. It is similar to
6176 @code{Address}, for which it is a desirable replacement where the value
6177 desired is an access type. In other words, its effect is identical to
6178 first applying the @code{Address} attribute and then doing an unchecked
6179 conversion to a desired access type. In GNAT, but not necessarily in
6180 other implementations, the use of static chains for inner level
6181 subprograms means that @code{Unrestricted_Access} applied to a
6182 subprogram yields a value that can be called as long as the subprogram
6183 is in scope (normal Ada accessibility rules restrict this usage).
6185 It is possible to use @code{Unrestricted_Access} for any type, but care
6186 must be exercised if it is used to create pointers to unconstrained
6187 objects. In this case, the resulting pointer has the same scope as the
6188 context of the attribute, and may not be returned to some enclosing
6189 scope. For instance, a function cannot use @code{Unrestricted_Access}
6190 to create a unconstrained pointer and then return that value to the
6194 @unnumberedsec VADS_Size
6195 @cindex @code{Size}, VADS compatibility
6198 The @code{'VADS_Size} attribute is intended to make it easier to port
6199 legacy code which relies on the semantics of @code{'Size} as implemented
6200 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
6201 same semantic interpretation. In particular, @code{'VADS_Size} applied
6202 to a predefined or other primitive type with no Size clause yields the
6203 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6204 typical machines). In addition @code{'VADS_Size} applied to an object
6205 gives the result that would be obtained by applying the attribute to
6206 the corresponding type.
6209 @unnumberedsec Value_Size
6210 @cindex @code{Size}, setting for not-first subtype
6212 @code{@var{type}'Value_Size} is the number of bits required to represent
6213 a value of the given subtype. It is the same as @code{@var{type}'Size},
6214 but, unlike @code{Size}, may be set for non-first subtypes.
6217 @unnumberedsec Wchar_T_Size
6218 @findex Wchar_T_Size
6219 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6220 prefix) provides the size in bits of the C @code{wchar_t} type
6221 primarily for constructing the definition of this type in
6222 package @code{Interfaces.C}.
6225 @unnumberedsec Word_Size
6227 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6228 prefix) provides the value @code{System.Word_Size}.
6230 @c ------------------------
6231 @node Implementation Advice
6232 @chapter Implementation Advice
6234 The main text of the Ada Reference Manual describes the required
6235 behavior of all Ada compilers, and the GNAT compiler conforms to
6238 In addition, there are sections throughout the Ada Reference Manual headed
6239 by the phrase ``Implementation advice''. These sections are not normative,
6240 i.e., they do not specify requirements that all compilers must
6241 follow. Rather they provide advice on generally desirable behavior. You
6242 may wonder why they are not requirements. The most typical answer is
6243 that they describe behavior that seems generally desirable, but cannot
6244 be provided on all systems, or which may be undesirable on some systems.
6246 As far as practical, GNAT follows the implementation advice sections in
6247 the Ada Reference Manual. This chapter contains a table giving the
6248 reference manual section number, paragraph number and several keywords
6249 for each advice. Each entry consists of the text of the advice followed
6250 by the GNAT interpretation of this advice. Most often, this simply says
6251 ``followed'', which means that GNAT follows the advice. However, in a
6252 number of cases, GNAT deliberately deviates from this advice, in which
6253 case the text describes what GNAT does and why.
6255 @cindex Error detection
6256 @unnumberedsec 1.1.3(20): Error Detection
6259 If an implementation detects the use of an unsupported Specialized Needs
6260 Annex feature at run time, it should raise @code{Program_Error} if
6263 Not relevant. All specialized needs annex features are either supported,
6264 or diagnosed at compile time.
6267 @unnumberedsec 1.1.3(31): Child Units
6270 If an implementation wishes to provide implementation-defined
6271 extensions to the functionality of a language-defined library unit, it
6272 should normally do so by adding children to the library unit.
6276 @cindex Bounded errors
6277 @unnumberedsec 1.1.5(12): Bounded Errors
6280 If an implementation detects a bounded error or erroneous
6281 execution, it should raise @code{Program_Error}.
6283 Followed in all cases in which the implementation detects a bounded
6284 error or erroneous execution. Not all such situations are detected at
6288 @unnumberedsec 2.8(16): Pragmas
6291 Normally, implementation-defined pragmas should have no semantic effect
6292 for error-free programs; that is, if the implementation-defined pragmas
6293 are removed from a working program, the program should still be legal,
6294 and should still have the same semantics.
6296 The following implementation defined pragmas are exceptions to this
6308 @item CPP_Constructor
6312 @item Interface_Name
6314 @item Machine_Attribute
6316 @item Unimplemented_Unit
6318 @item Unchecked_Union
6323 In each of the above cases, it is essential to the purpose of the pragma
6324 that this advice not be followed. For details see the separate section
6325 on implementation defined pragmas.
6327 @unnumberedsec 2.8(17-19): Pragmas
6330 Normally, an implementation should not define pragmas that can
6331 make an illegal program legal, except as follows:
6335 A pragma used to complete a declaration, such as a pragma @code{Import};
6339 A pragma used to configure the environment by adding, removing, or
6340 replacing @code{library_items}.
6342 See response to paragraph 16 of this same section.
6344 @cindex Character Sets
6345 @cindex Alternative Character Sets
6346 @unnumberedsec 3.5.2(5): Alternative Character Sets
6349 If an implementation supports a mode with alternative interpretations
6350 for @code{Character} and @code{Wide_Character}, the set of graphic
6351 characters of @code{Character} should nevertheless remain a proper
6352 subset of the set of graphic characters of @code{Wide_Character}. Any
6353 character set ``localizations'' should be reflected in the results of
6354 the subprograms defined in the language-defined package
6355 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
6356 an alternative interpretation of @code{Character}, the implementation should
6357 also support a corresponding change in what is a legal
6358 @code{identifier_letter}.
6360 Not all wide character modes follow this advice, in particular the JIS
6361 and IEC modes reflect standard usage in Japan, and in these encoding,
6362 the upper half of the Latin-1 set is not part of the wide-character
6363 subset, since the most significant bit is used for wide character
6364 encoding. However, this only applies to the external forms. Internally
6365 there is no such restriction.
6367 @cindex Integer types
6368 @unnumberedsec 3.5.4(28): Integer Types
6372 An implementation should support @code{Long_Integer} in addition to
6373 @code{Integer} if the target machine supports 32-bit (or longer)
6374 arithmetic. No other named integer subtypes are recommended for package
6375 @code{Standard}. Instead, appropriate named integer subtypes should be
6376 provided in the library package @code{Interfaces} (see B.2).
6378 @code{Long_Integer} is supported. Other standard integer types are supported
6379 so this advice is not fully followed. These types
6380 are supported for convenient interface to C, and so that all hardware
6381 types of the machine are easily available.
6382 @unnumberedsec 3.5.4(29): Integer Types
6386 An implementation for a two's complement machine should support
6387 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
6388 implementation should support a non-binary modules up to @code{Integer'Last}.
6392 @cindex Enumeration values
6393 @unnumberedsec 3.5.5(8): Enumeration Values
6396 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6397 subtype, if the value of the operand does not correspond to the internal
6398 code for any enumeration literal of its type (perhaps due to an
6399 un-initialized variable), then the implementation should raise
6400 @code{Program_Error}. This is particularly important for enumeration
6401 types with noncontiguous internal codes specified by an
6402 enumeration_representation_clause.
6407 @unnumberedsec 3.5.7(17): Float Types
6410 An implementation should support @code{Long_Float} in addition to
6411 @code{Float} if the target machine supports 11 or more digits of
6412 precision. No other named floating point subtypes are recommended for
6413 package @code{Standard}. Instead, appropriate named floating point subtypes
6414 should be provided in the library package @code{Interfaces} (see B.2).
6416 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
6417 former provides improved compatibility with other implementations
6418 supporting this type. The latter corresponds to the highest precision
6419 floating-point type supported by the hardware. On most machines, this
6420 will be the same as @code{Long_Float}, but on some machines, it will
6421 correspond to the IEEE extended form. The notable case is all ia32
6422 (x86) implementations, where @code{Long_Long_Float} corresponds to
6423 the 80-bit extended precision format supported in hardware on this
6424 processor. Note that the 128-bit format on SPARC is not supported,
6425 since this is a software rather than a hardware format.
6427 @cindex Multidimensional arrays
6428 @cindex Arrays, multidimensional
6429 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6432 An implementation should normally represent multidimensional arrays in
6433 row-major order, consistent with the notation used for multidimensional
6434 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
6435 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6436 column-major order should be used instead (see B.5, ``Interfacing with
6441 @findex Duration'Small
6442 @unnumberedsec 9.6(30-31): Duration'Small
6445 Whenever possible in an implementation, the value of @code{Duration'Small}
6446 should be no greater than 100 microseconds.
6448 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
6452 The time base for @code{delay_relative_statements} should be monotonic;
6453 it need not be the same time base as used for @code{Calendar.Clock}.
6457 @unnumberedsec 10.2.1(12): Consistent Representation
6460 In an implementation, a type declared in a pre-elaborated package should
6461 have the same representation in every elaboration of a given version of
6462 the package, whether the elaborations occur in distinct executions of
6463 the same program, or in executions of distinct programs or partitions
6464 that include the given version.
6466 Followed, except in the case of tagged types. Tagged types involve
6467 implicit pointers to a local copy of a dispatch table, and these pointers
6468 have representations which thus depend on a particular elaboration of the
6469 package. It is not easy to see how it would be possible to follow this
6470 advice without severely impacting efficiency of execution.
6472 @cindex Exception information
6473 @unnumberedsec 11.4.1(19): Exception Information
6476 @code{Exception_Message} by default and @code{Exception_Information}
6477 should produce information useful for
6478 debugging. @code{Exception_Message} should be short, about one
6479 line. @code{Exception_Information} can be long. @code{Exception_Message}
6480 should not include the
6481 @code{Exception_Name}. @code{Exception_Information} should include both
6482 the @code{Exception_Name} and the @code{Exception_Message}.
6484 Followed. For each exception that doesn't have a specified
6485 @code{Exception_Message}, the compiler generates one containing the location
6486 of the raise statement. This location has the form ``file:line'', where
6487 file is the short file name (without path information) and line is the line
6488 number in the file. Note that in the case of the Zero Cost Exception
6489 mechanism, these messages become redundant with the Exception_Information that
6490 contains a full backtrace of the calling sequence, so they are disabled.
6491 To disable explicitly the generation of the source location message, use the
6492 Pragma @code{Discard_Names}.
6494 @cindex Suppression of checks
6495 @cindex Checks, suppression of
6496 @unnumberedsec 11.5(28): Suppression of Checks
6499 The implementation should minimize the code executed for checks that
6500 have been suppressed.
6504 @cindex Representation clauses
6505 @unnumberedsec 13.1 (21-24): Representation Clauses
6508 The recommended level of support for all representation items is
6509 qualified as follows:
6513 An implementation need not support representation items containing
6514 non-static expressions, except that an implementation should support a
6515 representation item for a given entity if each non-static expression in
6516 the representation item is a name that statically denotes a constant
6517 declared before the entity.
6519 Followed. In fact, GNAT goes beyond the recommended level of support
6520 by allowing nonstatic expressions in some representation clauses even
6521 without the need to declare constants initialized with the values of
6525 @smallexample @c ada
6528 for Y'Address use X'Address;>>
6534 An implementation need not support a specification for the @code{Size}
6535 for a given composite subtype, nor the size or storage place for an
6536 object (including a component) of a given composite subtype, unless the
6537 constraints on the subtype and its composite subcomponents (if any) are
6538 all static constraints.
6540 Followed. Size Clauses are not permitted on non-static components, as
6545 An aliased component, or a component whose type is by-reference, should
6546 always be allocated at an addressable location.
6550 @cindex Packed types
6551 @unnumberedsec 13.2(6-8): Packed Types
6554 If a type is packed, then the implementation should try to minimize
6555 storage allocated to objects of the type, possibly at the expense of
6556 speed of accessing components, subject to reasonable complexity in
6557 addressing calculations.
6561 The recommended level of support pragma @code{Pack} is:
6563 For a packed record type, the components should be packed as tightly as
6564 possible subject to the Sizes of the component subtypes, and subject to
6565 any @code{record_representation_clause} that applies to the type; the
6566 implementation may, but need not, reorder components or cross aligned
6567 word boundaries to improve the packing. A component whose @code{Size} is
6568 greater than the word size may be allocated an integral number of words.
6570 Followed. Tight packing of arrays is supported for all component sizes
6571 up to 64-bits. If the array component size is 1 (that is to say, if
6572 the component is a boolean type or an enumeration type with two values)
6573 then values of the type are implicitly initialized to zero. This
6574 happens both for objects of the packed type, and for objects that have a
6575 subcomponent of the packed type.
6579 An implementation should support Address clauses for imported
6583 @cindex @code{Address} clauses
6584 @unnumberedsec 13.3(14-19): Address Clauses
6588 For an array @var{X}, @code{@var{X}'Address} should point at the first
6589 component of the array, and not at the array bounds.
6595 The recommended level of support for the @code{Address} attribute is:
6597 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6598 object that is aliased or of a by-reference type, or is an entity whose
6599 @code{Address} has been specified.
6601 Followed. A valid address will be produced even if none of those
6602 conditions have been met. If necessary, the object is forced into
6603 memory to ensure the address is valid.
6607 An implementation should support @code{Address} clauses for imported
6614 Objects (including subcomponents) that are aliased or of a by-reference
6615 type should be allocated on storage element boundaries.
6621 If the @code{Address} of an object is specified, or it is imported or exported,
6622 then the implementation should not perform optimizations based on
6623 assumptions of no aliases.
6627 @cindex @code{Alignment} clauses
6628 @unnumberedsec 13.3(29-35): Alignment Clauses
6631 The recommended level of support for the @code{Alignment} attribute for
6634 An implementation should support specified Alignments that are factors
6635 and multiples of the number of storage elements per word, subject to the
6642 An implementation need not support specified @code{Alignment}s for
6643 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6644 loaded and stored by available machine instructions.
6650 An implementation need not support specified @code{Alignment}s that are
6651 greater than the maximum @code{Alignment} the implementation ever returns by
6658 The recommended level of support for the @code{Alignment} attribute for
6661 Same as above, for subtypes, but in addition:
6667 For stand-alone library-level objects of statically constrained
6668 subtypes, the implementation should support all @code{Alignment}s
6669 supported by the target linker. For example, page alignment is likely to
6670 be supported for such objects, but not for subtypes.
6674 @cindex @code{Size} clauses
6675 @unnumberedsec 13.3(42-43): Size Clauses
6678 The recommended level of support for the @code{Size} attribute of
6681 A @code{Size} clause should be supported for an object if the specified
6682 @code{Size} is at least as large as its subtype's @code{Size}, and
6683 corresponds to a size in storage elements that is a multiple of the
6684 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6688 @unnumberedsec 13.3(50-56): Size Clauses
6691 If the @code{Size} of a subtype is specified, and allows for efficient
6692 independent addressability (see 9.10) on the target architecture, then
6693 the @code{Size} of the following objects of the subtype should equal the
6694 @code{Size} of the subtype:
6696 Aliased objects (including components).
6702 @code{Size} clause on a composite subtype should not affect the
6703 internal layout of components.
6705 Followed. But note that this can be overridden by use of the implementation
6706 pragma Implicit_Packing in the case of packed arrays.
6710 The recommended level of support for the @code{Size} attribute of subtypes is:
6714 The @code{Size} (if not specified) of a static discrete or fixed point
6715 subtype should be the number of bits needed to represent each value
6716 belonging to the subtype using an unbiased representation, leaving space
6717 for a sign bit only if the subtype contains negative values. If such a
6718 subtype is a first subtype, then an implementation should support a
6719 specified @code{Size} for it that reflects this representation.
6725 For a subtype implemented with levels of indirection, the @code{Size}
6726 should include the size of the pointers, but not the size of what they
6731 @cindex @code{Component_Size} clauses
6732 @unnumberedsec 13.3(71-73): Component Size Clauses
6735 The recommended level of support for the @code{Component_Size}
6740 An implementation need not support specified @code{Component_Sizes} that are
6741 less than the @code{Size} of the component subtype.
6747 An implementation should support specified @code{Component_Size}s that
6748 are factors and multiples of the word size. For such
6749 @code{Component_Size}s, the array should contain no gaps between
6750 components. For other @code{Component_Size}s (if supported), the array
6751 should contain no gaps between components when packing is also
6752 specified; the implementation should forbid this combination in cases
6753 where it cannot support a no-gaps representation.
6757 @cindex Enumeration representation clauses
6758 @cindex Representation clauses, enumeration
6759 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6762 The recommended level of support for enumeration representation clauses
6765 An implementation need not support enumeration representation clauses
6766 for boolean types, but should at minimum support the internal codes in
6767 the range @code{System.Min_Int.System.Max_Int}.
6771 @cindex Record representation clauses
6772 @cindex Representation clauses, records
6773 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6776 The recommended level of support for
6777 @*@code{record_representation_clauses} is:
6779 An implementation should support storage places that can be extracted
6780 with a load, mask, shift sequence of machine code, and set with a load,
6781 shift, mask, store sequence, given the available machine instructions
6788 A storage place should be supported if its size is equal to the
6789 @code{Size} of the component subtype, and it starts and ends on a
6790 boundary that obeys the @code{Alignment} of the component subtype.
6796 If the default bit ordering applies to the declaration of a given type,
6797 then for a component whose subtype's @code{Size} is less than the word
6798 size, any storage place that does not cross an aligned word boundary
6799 should be supported.
6805 An implementation may reserve a storage place for the tag field of a
6806 tagged type, and disallow other components from overlapping that place.
6808 Followed. The storage place for the tag field is the beginning of the tagged
6809 record, and its size is Address'Size. GNAT will reject an explicit component
6810 clause for the tag field.
6814 An implementation need not support a @code{component_clause} for a
6815 component of an extension part if the storage place is not after the
6816 storage places of all components of the parent type, whether or not
6817 those storage places had been specified.
6819 Followed. The above advice on record representation clauses is followed,
6820 and all mentioned features are implemented.
6822 @cindex Storage place attributes
6823 @unnumberedsec 13.5.2(5): Storage Place Attributes
6826 If a component is represented using some form of pointer (such as an
6827 offset) to the actual data of the component, and this data is contiguous
6828 with the rest of the object, then the storage place attributes should
6829 reflect the place of the actual data, not the pointer. If a component is
6830 allocated discontinuously from the rest of the object, then a warning
6831 should be generated upon reference to one of its storage place
6834 Followed. There are no such components in GNAT@.
6836 @cindex Bit ordering
6837 @unnumberedsec 13.5.3(7-8): Bit Ordering
6840 The recommended level of support for the non-default bit ordering is:
6844 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6845 should support the non-default bit ordering in addition to the default
6848 Followed. Word size does not equal storage size in this implementation.
6849 Thus non-default bit ordering is not supported.
6851 @cindex @code{Address}, as private type
6852 @unnumberedsec 13.7(37): Address as Private
6855 @code{Address} should be of a private type.
6859 @cindex Operations, on @code{Address}
6860 @cindex @code{Address}, operations of
6861 @unnumberedsec 13.7.1(16): Address Operations
6864 Operations in @code{System} and its children should reflect the target
6865 environment semantics as closely as is reasonable. For example, on most
6866 machines, it makes sense for address arithmetic to ``wrap around''.
6867 Operations that do not make sense should raise @code{Program_Error}.
6869 Followed. Address arithmetic is modular arithmetic that wraps around. No
6870 operation raises @code{Program_Error}, since all operations make sense.
6872 @cindex Unchecked conversion
6873 @unnumberedsec 13.9(14-17): Unchecked Conversion
6876 The @code{Size} of an array object should not include its bounds; hence,
6877 the bounds should not be part of the converted data.
6883 The implementation should not generate unnecessary run-time checks to
6884 ensure that the representation of @var{S} is a representation of the
6885 target type. It should take advantage of the permission to return by
6886 reference when possible. Restrictions on unchecked conversions should be
6887 avoided unless required by the target environment.
6889 Followed. There are no restrictions on unchecked conversion. A warning is
6890 generated if the source and target types do not have the same size since
6891 the semantics in this case may be target dependent.
6895 The recommended level of support for unchecked conversions is:
6899 Unchecked conversions should be supported and should be reversible in
6900 the cases where this clause defines the result. To enable meaningful use
6901 of unchecked conversion, a contiguous representation should be used for
6902 elementary subtypes, for statically constrained array subtypes whose
6903 component subtype is one of the subtypes described in this paragraph,
6904 and for record subtypes without discriminants whose component subtypes
6905 are described in this paragraph.
6909 @cindex Heap usage, implicit
6910 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6913 An implementation should document any cases in which it dynamically
6914 allocates heap storage for a purpose other than the evaluation of an
6917 Followed, the only other points at which heap storage is dynamically
6918 allocated are as follows:
6922 At initial elaboration time, to allocate dynamically sized global
6926 To allocate space for a task when a task is created.
6929 To extend the secondary stack dynamically when needed. The secondary
6930 stack is used for returning variable length results.
6935 A default (implementation-provided) storage pool for an
6936 access-to-constant type should not have overhead to support deallocation of
6943 A storage pool for an anonymous access type should be created at the
6944 point of an allocator for the type, and be reclaimed when the designated
6945 object becomes inaccessible.
6949 @cindex Unchecked deallocation
6950 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6953 For a standard storage pool, @code{Free} should actually reclaim the
6958 @cindex Stream oriented attributes
6959 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6962 If a stream element is the same size as a storage element, then the
6963 normal in-memory representation should be used by @code{Read} and
6964 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
6965 should use the smallest number of stream elements needed to represent
6966 all values in the base range of the scalar type.
6969 Followed. By default, GNAT uses the interpretation suggested by AI-195,
6970 which specifies using the size of the first subtype.
6971 However, such an implementation is based on direct binary
6972 representations and is therefore target- and endianness-dependent.
6973 To address this issue, GNAT also supplies an alternate implementation
6974 of the stream attributes @code{Read} and @code{Write},
6975 which uses the target-independent XDR standard representation
6977 @cindex XDR representation
6978 @cindex @code{Read} attribute
6979 @cindex @code{Write} attribute
6980 @cindex Stream oriented attributes
6981 The XDR implementation is provided as an alternative body of the
6982 @code{System.Stream_Attributes} package, in the file
6983 @file{s-strxdr.adb} in the GNAT library.
6984 There is no @file{s-strxdr.ads} file.
6985 In order to install the XDR implementation, do the following:
6987 @item Replace the default implementation of the
6988 @code{System.Stream_Attributes} package with the XDR implementation.
6989 For example on a Unix platform issue the commands:
6991 $ mv s-stratt.adb s-strold.adb
6992 $ mv s-strxdr.adb s-stratt.adb
6996 Rebuild the GNAT run-time library as documented in
6997 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7000 @unnumberedsec A.1(52): Names of Predefined Numeric Types
7003 If an implementation provides additional named predefined integer types,
7004 then the names should end with @samp{Integer} as in
7005 @samp{Long_Integer}. If an implementation provides additional named
7006 predefined floating point types, then the names should end with
7007 @samp{Float} as in @samp{Long_Float}.
7011 @findex Ada.Characters.Handling
7012 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7015 If an implementation provides a localized definition of @code{Character}
7016 or @code{Wide_Character}, then the effects of the subprograms in
7017 @code{Characters.Handling} should reflect the localizations. See also
7020 Followed. GNAT provides no such localized definitions.
7022 @cindex Bounded-length strings
7023 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7026 Bounded string objects should not be implemented by implicit pointers
7027 and dynamic allocation.
7029 Followed. No implicit pointers or dynamic allocation are used.
7031 @cindex Random number generation
7032 @unnumberedsec A.5.2(46-47): Random Number Generation
7035 Any storage associated with an object of type @code{Generator} should be
7036 reclaimed on exit from the scope of the object.
7042 If the generator period is sufficiently long in relation to the number
7043 of distinct initiator values, then each possible value of
7044 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7045 random numbers that does not, in a practical sense, overlap the sequence
7046 initiated by any other value. If this is not possible, then the mapping
7047 between initiator values and generator states should be a rapidly
7048 varying function of the initiator value.
7050 Followed. The generator period is sufficiently long for the first
7051 condition here to hold true.
7053 @findex Get_Immediate
7054 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7057 The @code{Get_Immediate} procedures should be implemented with
7058 unbuffered input. For a device such as a keyboard, input should be
7059 @dfn{available} if a key has already been typed, whereas for a disk
7060 file, input should always be available except at end of file. For a file
7061 associated with a keyboard-like device, any line-editing features of the
7062 underlying operating system should be disabled during the execution of
7063 @code{Get_Immediate}.
7065 Followed on all targets except VxWorks. For VxWorks, there is no way to
7066 provide this functionality that does not result in the input buffer being
7067 flushed before the @code{Get_Immediate} call. A special unit
7068 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7072 @unnumberedsec B.1(39-41): Pragma @code{Export}
7075 If an implementation supports pragma @code{Export} to a given language,
7076 then it should also allow the main subprogram to be written in that
7077 language. It should support some mechanism for invoking the elaboration
7078 of the Ada library units included in the system, and for invoking the
7079 finalization of the environment task. On typical systems, the
7080 recommended mechanism is to provide two subprograms whose link names are
7081 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
7082 elaboration code for library units. @code{adafinal} should contain the
7083 finalization code. These subprograms should have no effect the second
7084 and subsequent time they are called.
7090 Automatic elaboration of pre-elaborated packages should be
7091 provided when pragma @code{Export} is supported.
7093 Followed when the main program is in Ada. If the main program is in a
7094 foreign language, then
7095 @code{adainit} must be called to elaborate pre-elaborated
7100 For each supported convention @var{L} other than @code{Intrinsic}, an
7101 implementation should support @code{Import} and @code{Export} pragmas
7102 for objects of @var{L}-compatible types and for subprograms, and pragma
7103 @code{Convention} for @var{L}-eligible types and for subprograms,
7104 presuming the other language has corresponding features. Pragma
7105 @code{Convention} need not be supported for scalar types.
7109 @cindex Package @code{Interfaces}
7111 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7114 For each implementation-defined convention identifier, there should be a
7115 child package of package Interfaces with the corresponding name. This
7116 package should contain any declarations that would be useful for
7117 interfacing to the language (implementation) represented by the
7118 convention. Any declarations useful for interfacing to any language on
7119 the given hardware architecture should be provided directly in
7122 Followed. An additional package not defined
7123 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7124 for interfacing to C++.
7128 An implementation supporting an interface to C, COBOL, or Fortran should
7129 provide the corresponding package or packages described in the following
7132 Followed. GNAT provides all the packages described in this section.
7134 @cindex C, interfacing with
7135 @unnumberedsec B.3(63-71): Interfacing with C
7138 An implementation should support the following interface correspondences
7145 An Ada procedure corresponds to a void-returning C function.
7151 An Ada function corresponds to a non-void C function.
7157 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7164 An Ada @code{in} parameter of an access-to-object type with designated
7165 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7166 where @var{t} is the C type corresponding to the Ada type @var{T}.
7172 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7173 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7174 argument to a C function, where @var{t} is the C type corresponding to
7175 the Ada type @var{T}. In the case of an elementary @code{out} or
7176 @code{in out} parameter, a pointer to a temporary copy is used to
7177 preserve by-copy semantics.
7183 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7184 @code{@var{t}*} argument to a C function, where @var{t} is the C
7185 structure corresponding to the Ada type @var{T}.
7187 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
7188 pragma, or Convention, or by explicitly specifying the mechanism for a given
7189 call using an extended import or export pragma.
7193 An Ada parameter of an array type with component type @var{T}, of any
7194 mode, is passed as a @code{@var{t}*} argument to a C function, where
7195 @var{t} is the C type corresponding to the Ada type @var{T}.
7201 An Ada parameter of an access-to-subprogram type is passed as a pointer
7202 to a C function whose prototype corresponds to the designated
7203 subprogram's specification.
7207 @cindex COBOL, interfacing with
7208 @unnumberedsec B.4(95-98): Interfacing with COBOL
7211 An Ada implementation should support the following interface
7212 correspondences between Ada and COBOL@.
7218 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7219 the COBOL type corresponding to @var{T}.
7225 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7226 the corresponding COBOL type.
7232 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7233 COBOL type corresponding to the Ada parameter type; for scalars, a local
7234 copy is used if necessary to ensure by-copy semantics.
7238 @cindex Fortran, interfacing with
7239 @unnumberedsec B.5(22-26): Interfacing with Fortran
7242 An Ada implementation should support the following interface
7243 correspondences between Ada and Fortran:
7249 An Ada procedure corresponds to a Fortran subroutine.
7255 An Ada function corresponds to a Fortran function.
7261 An Ada parameter of an elementary, array, or record type @var{T} is
7262 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7263 the Fortran type corresponding to the Ada type @var{T}, and where the
7264 INTENT attribute of the corresponding dummy argument matches the Ada
7265 formal parameter mode; the Fortran implementation's parameter passing
7266 conventions are used. For elementary types, a local copy is used if
7267 necessary to ensure by-copy semantics.
7273 An Ada parameter of an access-to-subprogram type is passed as a
7274 reference to a Fortran procedure whose interface corresponds to the
7275 designated subprogram's specification.
7279 @cindex Machine operations
7280 @unnumberedsec C.1(3-5): Access to Machine Operations
7283 The machine code or intrinsic support should allow access to all
7284 operations normally available to assembly language programmers for the
7285 target environment, including privileged instructions, if any.
7291 The interfacing pragmas (see Annex B) should support interface to
7292 assembler; the default assembler should be associated with the
7293 convention identifier @code{Assembler}.
7299 If an entity is exported to assembly language, then the implementation
7300 should allocate it at an addressable location, and should ensure that it
7301 is retained by the linking process, even if not otherwise referenced
7302 from the Ada code. The implementation should assume that any call to a
7303 machine code or assembler subprogram is allowed to read or update every
7304 object that is specified as exported.
7308 @unnumberedsec C.1(10-16): Access to Machine Operations
7311 The implementation should ensure that little or no overhead is
7312 associated with calling intrinsic and machine-code subprograms.
7314 Followed for both intrinsics and machine-code subprograms.
7318 It is recommended that intrinsic subprograms be provided for convenient
7319 access to any machine operations that provide special capabilities or
7320 efficiency and that are not otherwise available through the language
7323 Followed. A full set of machine operation intrinsic subprograms is provided.
7327 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7328 swap, decrement and test, enqueue/dequeue.
7330 Followed on any target supporting such operations.
7334 Standard numeric functions---e.g.@:, sin, log.
7336 Followed on any target supporting such operations.
7340 String manipulation operations---e.g.@:, translate and test.
7342 Followed on any target supporting such operations.
7346 Vector operations---e.g.@:, compare vector against thresholds.
7348 Followed on any target supporting such operations.
7352 Direct operations on I/O ports.
7354 Followed on any target supporting such operations.
7356 @cindex Interrupt support
7357 @unnumberedsec C.3(28): Interrupt Support
7360 If the @code{Ceiling_Locking} policy is not in effect, the
7361 implementation should provide means for the application to specify which
7362 interrupts are to be blocked during protected actions, if the underlying
7363 system allows for a finer-grain control of interrupt blocking.
7365 Followed. The underlying system does not allow for finer-grain control
7366 of interrupt blocking.
7368 @cindex Protected procedure handlers
7369 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7372 Whenever possible, the implementation should allow interrupt handlers to
7373 be called directly by the hardware.
7377 This is never possible under IRIX, so this is followed by default.
7379 Followed on any target where the underlying operating system permits
7384 Whenever practical, violations of any
7385 implementation-defined restrictions should be detected before run time.
7387 Followed. Compile time warnings are given when possible.
7389 @cindex Package @code{Interrupts}
7391 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7395 If implementation-defined forms of interrupt handler procedures are
7396 supported, such as protected procedures with parameters, then for each
7397 such form of a handler, a type analogous to @code{Parameterless_Handler}
7398 should be specified in a child package of @code{Interrupts}, with the
7399 same operations as in the predefined package Interrupts.
7403 @cindex Pre-elaboration requirements
7404 @unnumberedsec C.4(14): Pre-elaboration Requirements
7407 It is recommended that pre-elaborated packages be implemented in such a
7408 way that there should be little or no code executed at run time for the
7409 elaboration of entities not already covered by the Implementation
7412 Followed. Executable code is generated in some cases, e.g.@: loops
7413 to initialize large arrays.
7415 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7419 If the pragma applies to an entity, then the implementation should
7420 reduce the amount of storage used for storing names associated with that
7425 @cindex Package @code{Task_Attributes}
7426 @findex Task_Attributes
7427 @unnumberedsec C.7.2(30): The Package Task_Attributes
7430 Some implementations are targeted to domains in which memory use at run
7431 time must be completely deterministic. For such implementations, it is
7432 recommended that the storage for task attributes will be pre-allocated
7433 statically and not from the heap. This can be accomplished by either
7434 placing restrictions on the number and the size of the task's
7435 attributes, or by using the pre-allocated storage for the first @var{N}
7436 attribute objects, and the heap for the others. In the latter case,
7437 @var{N} should be documented.
7439 Not followed. This implementation is not targeted to such a domain.
7441 @cindex Locking Policies
7442 @unnumberedsec D.3(17): Locking Policies
7446 The implementation should use names that end with @samp{_Locking} for
7447 locking policies defined by the implementation.
7449 Followed. A single implementation-defined locking policy is defined,
7450 whose name (@code{Inheritance_Locking}) follows this suggestion.
7452 @cindex Entry queuing policies
7453 @unnumberedsec D.4(16): Entry Queuing Policies
7456 Names that end with @samp{_Queuing} should be used
7457 for all implementation-defined queuing policies.
7459 Followed. No such implementation-defined queuing policies exist.
7461 @cindex Preemptive abort
7462 @unnumberedsec D.6(9-10): Preemptive Abort
7465 Even though the @code{abort_statement} is included in the list of
7466 potentially blocking operations (see 9.5.1), it is recommended that this
7467 statement be implemented in a way that never requires the task executing
7468 the @code{abort_statement} to block.
7474 On a multi-processor, the delay associated with aborting a task on
7475 another processor should be bounded; the implementation should use
7476 periodic polling, if necessary, to achieve this.
7480 @cindex Tasking restrictions
7481 @unnumberedsec D.7(21): Tasking Restrictions
7484 When feasible, the implementation should take advantage of the specified
7485 restrictions to produce a more efficient implementation.
7487 GNAT currently takes advantage of these restrictions by providing an optimized
7488 run time when the Ravenscar profile and the GNAT restricted run time set
7489 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
7490 pragma @code{Profile (Restricted)} for more details.
7492 @cindex Time, monotonic
7493 @unnumberedsec D.8(47-49): Monotonic Time
7496 When appropriate, implementations should provide configuration
7497 mechanisms to change the value of @code{Tick}.
7499 Such configuration mechanisms are not appropriate to this implementation
7500 and are thus not supported.
7504 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7505 be implemented as transformations of the same time base.
7511 It is recommended that the @dfn{best} time base which exists in
7512 the underlying system be available to the application through
7513 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
7517 @cindex Partition communication subsystem
7519 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7522 Whenever possible, the PCS on the called partition should allow for
7523 multiple tasks to call the RPC-receiver with different messages and
7524 should allow them to block until the corresponding subprogram body
7527 Followed by GLADE, a separately supplied PCS that can be used with
7532 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7533 should raise @code{Storage_Error} if it runs out of space trying to
7534 write the @code{Item} into the stream.
7536 Followed by GLADE, a separately supplied PCS that can be used with
7539 @cindex COBOL support
7540 @unnumberedsec F(7): COBOL Support
7543 If COBOL (respectively, C) is widely supported in the target
7544 environment, implementations supporting the Information Systems Annex
7545 should provide the child package @code{Interfaces.COBOL} (respectively,
7546 @code{Interfaces.C}) specified in Annex B and should support a
7547 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7548 pragmas (see Annex B), thus allowing Ada programs to interface with
7549 programs written in that language.
7553 @cindex Decimal radix support
7554 @unnumberedsec F.1(2): Decimal Radix Support
7557 Packed decimal should be used as the internal representation for objects
7558 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7560 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
7564 @unnumberedsec G: Numerics
7567 If Fortran (respectively, C) is widely supported in the target
7568 environment, implementations supporting the Numerics Annex
7569 should provide the child package @code{Interfaces.Fortran} (respectively,
7570 @code{Interfaces.C}) specified in Annex B and should support a
7571 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7572 pragmas (see Annex B), thus allowing Ada programs to interface with
7573 programs written in that language.
7577 @cindex Complex types
7578 @unnumberedsec G.1.1(56-58): Complex Types
7581 Because the usual mathematical meaning of multiplication of a complex
7582 operand and a real operand is that of the scaling of both components of
7583 the former by the latter, an implementation should not perform this
7584 operation by first promoting the real operand to complex type and then
7585 performing a full complex multiplication. In systems that, in the
7586 future, support an Ada binding to IEC 559:1989, the latter technique
7587 will not generate the required result when one of the components of the
7588 complex operand is infinite. (Explicit multiplication of the infinite
7589 component by the zero component obtained during promotion yields a NaN
7590 that propagates into the final result.) Analogous advice applies in the
7591 case of multiplication of a complex operand and a pure-imaginary
7592 operand, and in the case of division of a complex operand by a real or
7593 pure-imaginary operand.
7599 Similarly, because the usual mathematical meaning of addition of a
7600 complex operand and a real operand is that the imaginary operand remains
7601 unchanged, an implementation should not perform this operation by first
7602 promoting the real operand to complex type and then performing a full
7603 complex addition. In implementations in which the @code{Signed_Zeros}
7604 attribute of the component type is @code{True} (and which therefore
7605 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7606 predefined arithmetic operations), the latter technique will not
7607 generate the required result when the imaginary component of the complex
7608 operand is a negatively signed zero. (Explicit addition of the negative
7609 zero to the zero obtained during promotion yields a positive zero.)
7610 Analogous advice applies in the case of addition of a complex operand
7611 and a pure-imaginary operand, and in the case of subtraction of a
7612 complex operand and a real or pure-imaginary operand.
7618 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7619 attempt to provide a rational treatment of the signs of zero results and
7620 result components. As one example, the result of the @code{Argument}
7621 function should have the sign of the imaginary component of the
7622 parameter @code{X} when the point represented by that parameter lies on
7623 the positive real axis; as another, the sign of the imaginary component
7624 of the @code{Compose_From_Polar} function should be the same as
7625 (respectively, the opposite of) that of the @code{Argument} parameter when that
7626 parameter has a value of zero and the @code{Modulus} parameter has a
7627 nonnegative (respectively, negative) value.
7631 @cindex Complex elementary functions
7632 @unnumberedsec G.1.2(49): Complex Elementary Functions
7635 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7636 @code{True} should attempt to provide a rational treatment of the signs
7637 of zero results and result components. For example, many of the complex
7638 elementary functions have components that are odd functions of one of
7639 the parameter components; in these cases, the result component should
7640 have the sign of the parameter component at the origin. Other complex
7641 elementary functions have zero components whose sign is opposite that of
7642 a parameter component at the origin, or is always positive or always
7647 @cindex Accuracy requirements
7648 @unnumberedsec G.2.4(19): Accuracy Requirements
7651 The versions of the forward trigonometric functions without a
7652 @code{Cycle} parameter should not be implemented by calling the
7653 corresponding version with a @code{Cycle} parameter of
7654 @code{2.0*Numerics.Pi}, since this will not provide the required
7655 accuracy in some portions of the domain. For the same reason, the
7656 version of @code{Log} without a @code{Base} parameter should not be
7657 implemented by calling the corresponding version with a @code{Base}
7658 parameter of @code{Numerics.e}.
7662 @cindex Complex arithmetic accuracy
7663 @cindex Accuracy, complex arithmetic
7664 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7668 The version of the @code{Compose_From_Polar} function without a
7669 @code{Cycle} parameter should not be implemented by calling the
7670 corresponding version with a @code{Cycle} parameter of
7671 @code{2.0*Numerics.Pi}, since this will not provide the required
7672 accuracy in some portions of the domain.
7676 @c -----------------------------------------
7677 @node Implementation Defined Characteristics
7678 @chapter Implementation Defined Characteristics
7681 In addition to the implementation dependent pragmas and attributes, and
7682 the implementation advice, there are a number of other Ada features
7683 that are potentially implementation dependent. These are mentioned
7684 throughout the Ada Reference Manual, and are summarized in annex M@.
7686 A requirement for conforming Ada compilers is that they provide
7687 documentation describing how the implementation deals with each of these
7688 issues. In this chapter, you will find each point in annex M listed
7689 followed by a description in italic font of how GNAT
7693 implementation on IRIX 5.3 operating system or greater
7695 handles the implementation dependence.
7697 You can use this chapter as a guide to minimizing implementation
7698 dependent features in your programs if portability to other compilers
7699 and other operating systems is an important consideration. The numbers
7700 in each section below correspond to the paragraph number in the Ada
7706 @strong{2}. Whether or not each recommendation given in Implementation
7707 Advice is followed. See 1.1.2(37).
7710 @xref{Implementation Advice}.
7715 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
7718 The complexity of programs that can be processed is limited only by the
7719 total amount of available virtual memory, and disk space for the
7720 generated object files.
7725 @strong{4}. Variations from the standard that are impractical to avoid
7726 given the implementation's execution environment. See 1.1.3(6).
7729 There are no variations from the standard.
7734 @strong{5}. Which @code{code_statement}s cause external
7735 interactions. See 1.1.3(10).
7738 Any @code{code_statement} can potentially cause external interactions.
7743 @strong{6}. The coded representation for the text of an Ada
7744 program. See 2.1(4).
7747 See separate section on source representation.
7752 @strong{7}. The control functions allowed in comments. See 2.1(14).
7755 See separate section on source representation.
7760 @strong{8}. The representation for an end of line. See 2.2(2).
7763 See separate section on source representation.
7768 @strong{9}. Maximum supported line length and lexical element
7769 length. See 2.2(15).
7772 The maximum line length is 255 characters and the maximum length of a
7773 lexical element is also 255 characters.
7778 @strong{10}. Implementation defined pragmas. See 2.8(14).
7782 @xref{Implementation Defined Pragmas}.
7787 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
7790 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7791 parameter, checks that the optimization flag is set, and aborts if it is
7797 @strong{12}. The sequence of characters of the value returned by
7798 @code{@var{S}'Image} when some of the graphic characters of
7799 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
7803 The sequence of characters is as defined by the wide character encoding
7804 method used for the source. See section on source representation for
7810 @strong{13}. The predefined integer types declared in
7811 @code{Standard}. See 3.5.4(25).
7815 @item Short_Short_Integer
7818 (Short) 16 bit signed
7822 64 bit signed (Alpha OpenVMS only)
7823 32 bit signed (all other targets)
7824 @item Long_Long_Integer
7831 @strong{14}. Any nonstandard integer types and the operators defined
7832 for them. See 3.5.4(26).
7835 There are no nonstandard integer types.
7840 @strong{15}. Any nonstandard real types and the operators defined for
7844 There are no nonstandard real types.
7849 @strong{16}. What combinations of requested decimal precision and range
7850 are supported for floating point types. See 3.5.7(7).
7853 The precision and range is as defined by the IEEE standard.
7858 @strong{17}. The predefined floating point types declared in
7859 @code{Standard}. See 3.5.7(16).
7866 (Short) 32 bit IEEE short
7869 @item Long_Long_Float
7870 64 bit IEEE long (80 bit IEEE long on x86 processors)
7876 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
7879 @code{Fine_Delta} is 2**(@minus{}63)
7884 @strong{19}. What combinations of small, range, and digits are
7885 supported for fixed point types. See 3.5.9(10).
7888 Any combinations are permitted that do not result in a small less than
7889 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7890 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7891 is 64 bits (true of all architectures except ia32), then the output from
7892 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
7893 is because floating-point conversions are used to convert fixed point.
7898 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
7899 within an unnamed @code{block_statement}. See 3.9(10).
7902 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7903 decimal integer are allocated.
7908 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
7911 @xref{Implementation Defined Attributes}.
7916 @strong{22}. Any implementation-defined time types. See 9.6(6).
7919 There are no implementation-defined time types.
7924 @strong{23}. The time base associated with relative delays.
7927 See 9.6(20). The time base used is that provided by the C library
7928 function @code{gettimeofday}.
7933 @strong{24}. The time base of the type @code{Calendar.Time}. See
7937 The time base used is that provided by the C library function
7938 @code{gettimeofday}.
7943 @strong{25}. The time zone used for package @code{Calendar}
7944 operations. See 9.6(24).
7947 The time zone used by package @code{Calendar} is the current system time zone
7948 setting for local time, as accessed by the C library function
7954 @strong{26}. Any limit on @code{delay_until_statements} of
7955 @code{select_statements}. See 9.6(29).
7958 There are no such limits.
7963 @strong{27}. Whether or not two non-overlapping parts of a composite
7964 object are independently addressable, in the case where packing, record
7965 layout, or @code{Component_Size} is specified for the object. See
7969 Separate components are independently addressable if they do not share
7970 overlapping storage units.
7975 @strong{28}. The representation for a compilation. See 10.1(2).
7978 A compilation is represented by a sequence of files presented to the
7979 compiler in a single invocation of the @command{gcc} command.
7984 @strong{29}. Any restrictions on compilations that contain multiple
7985 compilation_units. See 10.1(4).
7988 No single file can contain more than one compilation unit, but any
7989 sequence of files can be presented to the compiler as a single
7995 @strong{30}. The mechanisms for creating an environment and for adding
7996 and replacing compilation units. See 10.1.4(3).
7999 See separate section on compilation model.
8004 @strong{31}. The manner of explicitly assigning library units to a
8005 partition. See 10.2(2).
8008 If a unit contains an Ada main program, then the Ada units for the partition
8009 are determined by recursive application of the rules in the Ada Reference
8010 Manual section 10.2(2-6). In other words, the Ada units will be those that
8011 are needed by the main program, and then this definition of need is applied
8012 recursively to those units, and the partition contains the transitive
8013 closure determined by this relationship. In short, all the necessary units
8014 are included, with no need to explicitly specify the list. If additional
8015 units are required, e.g.@: by foreign language units, then all units must be
8016 mentioned in the context clause of one of the needed Ada units.
8018 If the partition contains no main program, or if the main program is in
8019 a language other than Ada, then GNAT
8020 provides the binder options @option{-z} and @option{-n} respectively, and in
8021 this case a list of units can be explicitly supplied to the binder for
8022 inclusion in the partition (all units needed by these units will also
8023 be included automatically). For full details on the use of these
8024 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8025 @value{EDITION} User's Guide}.
8030 @strong{32}. The implementation-defined means, if any, of specifying
8031 which compilation units are needed by a given compilation unit. See
8035 The units needed by a given compilation unit are as defined in
8036 the Ada Reference Manual section 10.2(2-6). There are no
8037 implementation-defined pragmas or other implementation-defined
8038 means for specifying needed units.
8043 @strong{33}. The manner of designating the main subprogram of a
8044 partition. See 10.2(7).
8047 The main program is designated by providing the name of the
8048 corresponding @file{ALI} file as the input parameter to the binder.
8053 @strong{34}. The order of elaboration of @code{library_items}. See
8057 The first constraint on ordering is that it meets the requirements of
8058 Chapter 10 of the Ada Reference Manual. This still leaves some
8059 implementation dependent choices, which are resolved by first
8060 elaborating bodies as early as possible (i.e., in preference to specs
8061 where there is a choice), and second by evaluating the immediate with
8062 clauses of a unit to determine the probably best choice, and
8063 third by elaborating in alphabetical order of unit names
8064 where a choice still remains.
8069 @strong{35}. Parameter passing and function return for the main
8070 subprogram. See 10.2(21).
8073 The main program has no parameters. It may be a procedure, or a function
8074 returning an integer type. In the latter case, the returned integer
8075 value is the return code of the program (overriding any value that
8076 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8081 @strong{36}. The mechanisms for building and running partitions. See
8085 GNAT itself supports programs with only a single partition. The GNATDIST
8086 tool provided with the GLADE package (which also includes an implementation
8087 of the PCS) provides a completely flexible method for building and running
8088 programs consisting of multiple partitions. See the separate GLADE manual
8094 @strong{37}. The details of program execution, including program
8095 termination. See 10.2(25).
8098 See separate section on compilation model.
8103 @strong{38}. The semantics of any non-active partitions supported by the
8104 implementation. See 10.2(28).
8107 Passive partitions are supported on targets where shared memory is
8108 provided by the operating system. See the GLADE reference manual for
8114 @strong{39}. The information returned by @code{Exception_Message}. See
8118 Exception message returns the null string unless a specific message has
8119 been passed by the program.
8124 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
8125 declared within an unnamed @code{block_statement}. See 11.4.1(12).
8128 Blocks have implementation defined names of the form @code{B@var{nnn}}
8129 where @var{nnn} is an integer.
8134 @strong{41}. The information returned by
8135 @code{Exception_Information}. See 11.4.1(13).
8138 @code{Exception_Information} returns a string in the following format:
8141 @emph{Exception_Name:} nnnnn
8142 @emph{Message:} mmmmm
8144 @emph{Call stack traceback locations:}
8145 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8153 @code{nnnn} is the fully qualified name of the exception in all upper
8154 case letters. This line is always present.
8157 @code{mmmm} is the message (this line present only if message is non-null)
8160 @code{ppp} is the Process Id value as a decimal integer (this line is
8161 present only if the Process Id is nonzero). Currently we are
8162 not making use of this field.
8165 The Call stack traceback locations line and the following values
8166 are present only if at least one traceback location was recorded.
8167 The values are given in C style format, with lower case letters
8168 for a-f, and only as many digits present as are necessary.
8172 The line terminator sequence at the end of each line, including
8173 the last line is a single @code{LF} character (@code{16#0A#}).
8178 @strong{42}. Implementation-defined check names. See 11.5(27).
8181 The implementation defined check name Alignment_Check controls checking of
8182 address clause values for proper alignment (that is, the address supplied
8183 must be consistent with the alignment of the type).
8185 In addition, a user program can add implementation-defined check names
8186 by means of the pragma Check_Name.
8191 @strong{43}. The interpretation of each aspect of representation. See
8195 See separate section on data representations.
8200 @strong{44}. Any restrictions placed upon representation items. See
8204 See separate section on data representations.
8209 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
8213 Size for an indefinite subtype is the maximum possible size, except that
8214 for the case of a subprogram parameter, the size of the parameter object
8220 @strong{46}. The default external representation for a type tag. See
8224 The default external representation for a type tag is the fully expanded
8225 name of the type in upper case letters.
8230 @strong{47}. What determines whether a compilation unit is the same in
8231 two different partitions. See 13.3(76).
8234 A compilation unit is the same in two different partitions if and only
8235 if it derives from the same source file.
8240 @strong{48}. Implementation-defined components. See 13.5.1(15).
8243 The only implementation defined component is the tag for a tagged type,
8244 which contains a pointer to the dispatching table.
8249 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
8250 ordering. See 13.5.3(5).
8253 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8254 implementation, so no non-default bit ordering is supported. The default
8255 bit ordering corresponds to the natural endianness of the target architecture.
8260 @strong{50}. The contents of the visible part of package @code{System}
8261 and its language-defined children. See 13.7(2).
8264 See the definition of these packages in files @file{system.ads} and
8265 @file{s-stoele.ads}.
8270 @strong{51}. The contents of the visible part of package
8271 @code{System.Machine_Code}, and the meaning of
8272 @code{code_statements}. See 13.8(7).
8275 See the definition and documentation in file @file{s-maccod.ads}.
8280 @strong{52}. The effect of unchecked conversion. See 13.9(11).
8283 Unchecked conversion between types of the same size
8284 results in an uninterpreted transmission of the bits from one type
8285 to the other. If the types are of unequal sizes, then in the case of
8286 discrete types, a shorter source is first zero or sign extended as
8287 necessary, and a shorter target is simply truncated on the left.
8288 For all non-discrete types, the source is first copied if necessary
8289 to ensure that the alignment requirements of the target are met, then
8290 a pointer is constructed to the source value, and the result is obtained
8291 by dereferencing this pointer after converting it to be a pointer to the
8292 target type. Unchecked conversions where the target subtype is an
8293 unconstrained array are not permitted. If the target alignment is
8294 greater than the source alignment, then a copy of the result is
8295 made with appropriate alignment
8300 @strong{53}. The manner of choosing a storage pool for an access type
8301 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
8304 There are 3 different standard pools used by the compiler when
8305 @code{Storage_Pool} is not specified depending whether the type is local
8306 to a subprogram or defined at the library level and whether
8307 @code{Storage_Size}is specified or not. See documentation in the runtime
8308 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8309 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8310 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8316 @strong{54}. Whether or not the implementation provides user-accessible
8317 names for the standard pool type(s). See 13.11(17).
8321 See documentation in the sources of the run time mentioned in paragraph
8322 @strong{53} . All these pools are accessible by means of @code{with}'ing
8328 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
8331 @code{Storage_Size} is measured in storage units, and refers to the
8332 total space available for an access type collection, or to the primary
8333 stack space for a task.
8338 @strong{56}. Implementation-defined aspects of storage pools. See
8342 See documentation in the sources of the run time mentioned in paragraph
8343 @strong{53} for details on GNAT-defined aspects of storage pools.
8348 @strong{57}. The set of restrictions allowed in a pragma
8349 @code{Restrictions}. See 13.12(7).
8352 All RM defined Restriction identifiers are implemented. The following
8353 additional restriction identifiers are provided. There are two separate
8354 lists of implementation dependent restriction identifiers. The first
8355 set requires consistency throughout a partition (in other words, if the
8356 restriction identifier is used for any compilation unit in the partition,
8357 then all compilation units in the partition must obey the restriction.
8361 @item Simple_Barriers
8362 @findex Simple_Barriers
8363 This restriction ensures at compile time that barriers in entry declarations
8364 for protected types are restricted to either static boolean expressions or
8365 references to simple boolean variables defined in the private part of the
8366 protected type. No other form of entry barriers is permitted. This is one
8367 of the restrictions of the Ravenscar profile for limited tasking (see also
8368 pragma @code{Profile (Ravenscar)}).
8370 @item Max_Entry_Queue_Length => Expr
8371 @findex Max_Entry_Queue_Length
8372 This restriction is a declaration that any protected entry compiled in
8373 the scope of the restriction has at most the specified number of
8374 tasks waiting on the entry
8375 at any one time, and so no queue is required. This restriction is not
8376 checked at compile time. A program execution is erroneous if an attempt
8377 is made to queue more than the specified number of tasks on such an entry.
8381 This restriction ensures at compile time that there is no implicit or
8382 explicit dependence on the package @code{Ada.Calendar}.
8384 @item No_Default_Initialization
8385 @findex No_Default_Initialization
8387 This restriction prohibits any instance of default initialization of variables.
8388 The binder implements a consistency rule which prevents any unit compiled
8389 without the restriction from with'ing a unit with the restriction (this allows
8390 the generation of initialization procedures to be skipped, since you can be
8391 sure that no call is ever generated to an initialization procedure in a unit
8392 with the restriction active). If used in conjunction with Initialize_Scalars or
8393 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8394 without a specific initializer (including the case of OUT scalar parameters).
8396 @item No_Direct_Boolean_Operators
8397 @findex No_Direct_Boolean_Operators
8398 This restriction ensures that no logical (and/or/xor) or comparison
8399 operators are used on operands of type Boolean (or any type derived
8400 from Boolean). This is intended for use in safety critical programs
8401 where the certification protocol requires the use of short-circuit
8402 (and then, or else) forms for all composite boolean operations.
8404 @item No_Dispatching_Calls
8405 @findex No_Dispatching_Calls
8406 This restriction ensures at compile time that the code generated by the
8407 compiler involves no dispatching calls. The use of this restriction allows the
8408 safe use of record extensions, classwide membership tests and other classwide
8409 features not involving implicit dispatching. This restriction ensures that
8410 the code contains no indirect calls through a dispatching mechanism. Note that
8411 this includes internally-generated calls created by the compiler, for example
8412 in the implementation of class-wide objects assignments. The
8413 membership test is allowed in the presence of this restriction, because its
8414 implementation requires no dispatching.
8415 This restriction is comparable to the official Ada restriction
8416 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8417 all classwide constructs that do not imply dispatching.
8418 The following example indicates constructs that violate this restriction.
8422 type T is tagged record
8425 procedure P (X : T);
8427 type DT is new T with record
8428 More_Data : Natural;
8430 procedure Q (X : DT);
8434 procedure Example is
8435 procedure Test (O : T'Class) is
8436 N : Natural := O'Size;-- Error: Dispatching call
8437 C : T'Class := O; -- Error: implicit Dispatching Call
8439 if O in DT'Class then -- OK : Membership test
8440 Q (DT (O)); -- OK : Type conversion plus direct call
8442 P (O); -- Error: Dispatching call
8448 P (Obj); -- OK : Direct call
8449 P (T (Obj)); -- OK : Type conversion plus direct call
8450 P (T'Class (Obj)); -- Error: Dispatching call
8452 Test (Obj); -- OK : Type conversion
8454 if Obj in T'Class then -- OK : Membership test
8460 @item No_Dynamic_Attachment
8461 @findex No_Dynamic_Attachment
8462 This restriction ensures that there is no call to any of the operations
8463 defined in package Ada.Interrupts.
8465 @item No_Enumeration_Maps
8466 @findex No_Enumeration_Maps
8467 This restriction ensures at compile time that no operations requiring
8468 enumeration maps are used (that is Image and Value attributes applied
8469 to enumeration types).
8471 @item No_Entry_Calls_In_Elaboration_Code
8472 @findex No_Entry_Calls_In_Elaboration_Code
8473 This restriction ensures at compile time that no task or protected entry
8474 calls are made during elaboration code. As a result of the use of this
8475 restriction, the compiler can assume that no code past an accept statement
8476 in a task can be executed at elaboration time.
8478 @item No_Exception_Handlers
8479 @findex No_Exception_Handlers
8480 This restriction ensures at compile time that there are no explicit
8481 exception handlers. It also indicates that no exception propagation will
8482 be provided. In this mode, exceptions may be raised but will result in
8483 an immediate call to the last chance handler, a routine that the user
8484 must define with the following profile:
8486 @smallexample @c ada
8487 procedure Last_Chance_Handler
8488 (Source_Location : System.Address; Line : Integer);
8489 pragma Export (C, Last_Chance_Handler,
8490 "__gnat_last_chance_handler");
8493 The parameter is a C null-terminated string representing a message to be
8494 associated with the exception (typically the source location of the raise
8495 statement generated by the compiler). The Line parameter when nonzero
8496 represents the line number in the source program where the raise occurs.
8498 @item No_Exception_Propagation
8499 @findex No_Exception_Propagation
8500 This restriction guarantees that exceptions are never propagated to an outer
8501 subprogram scope). The only case in which an exception may be raised is when
8502 the handler is statically in the same subprogram, so that the effect of a raise
8503 is essentially like a goto statement. Any other raise statement (implicit or
8504 explicit) will be considered unhandled. Exception handlers are allowed, but may
8505 not contain an exception occurrence identifier (exception choice). In addition
8506 use of the package GNAT.Current_Exception is not permitted, and reraise
8507 statements (raise with no operand) are not permitted.
8509 @item No_Exception_Registration
8510 @findex No_Exception_Registration
8511 This restriction ensures at compile time that no stream operations for
8512 types Exception_Id or Exception_Occurrence are used. This also makes it
8513 impossible to pass exceptions to or from a partition with this restriction
8514 in a distributed environment. If this exception is active, then the generated
8515 code is simplified by omitting the otherwise-required global registration
8516 of exceptions when they are declared.
8518 @item No_Implicit_Conditionals
8519 @findex No_Implicit_Conditionals
8520 This restriction ensures that the generated code does not contain any
8521 implicit conditionals, either by modifying the generated code where possible,
8522 or by rejecting any construct that would otherwise generate an implicit
8523 conditional. Note that this check does not include run time constraint
8524 checks, which on some targets may generate implicit conditionals as
8525 well. To control the latter, constraint checks can be suppressed in the
8526 normal manner. Constructs generating implicit conditionals include comparisons
8527 of composite objects and the Max/Min attributes.
8529 @item No_Implicit_Dynamic_Code
8530 @findex No_Implicit_Dynamic_Code
8532 This restriction prevents the compiler from building ``trampolines''.
8533 This is a structure that is built on the stack and contains dynamic
8534 code to be executed at run time. On some targets, a trampoline is
8535 built for the following features: @code{Access},
8536 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8537 nested task bodies; primitive operations of nested tagged types.
8538 Trampolines do not work on machines that prevent execution of stack
8539 data. For example, on windows systems, enabling DEP (data execution
8540 protection) will cause trampolines to raise an exception.
8541 Trampolines are also quite slow at run time.
8543 On many targets, trampolines have been largely eliminated. Look at the
8544 version of system.ads for your target --- if it has
8545 Always_Compatible_Rep equal to False, then trampolines are largely
8546 eliminated. In particular, a trampoline is built for the following
8547 features: @code{Address} of a nested subprogram;
8548 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8549 but only if pragma Favor_Top_Level applies, or the access type has a
8550 foreign-language convention; primitive operations of nested tagged
8553 @item No_Implicit_Loops
8554 @findex No_Implicit_Loops
8555 This restriction ensures that the generated code does not contain any
8556 implicit @code{for} loops, either by modifying
8557 the generated code where possible,
8558 or by rejecting any construct that would otherwise generate an implicit
8559 @code{for} loop. If this restriction is active, it is possible to build
8560 large array aggregates with all static components without generating an
8561 intermediate temporary, and without generating a loop to initialize individual
8562 components. Otherwise, a loop is created for arrays larger than about 5000
8565 @item No_Initialize_Scalars
8566 @findex No_Initialize_Scalars
8567 This restriction ensures that no unit in the partition is compiled with
8568 pragma Initialize_Scalars. This allows the generation of more efficient
8569 code, and in particular eliminates dummy null initialization routines that
8570 are otherwise generated for some record and array types.
8572 @item No_Local_Protected_Objects
8573 @findex No_Local_Protected_Objects
8574 This restriction ensures at compile time that protected objects are
8575 only declared at the library level.
8577 @item No_Protected_Type_Allocators
8578 @findex No_Protected_Type_Allocators
8579 This restriction ensures at compile time that there are no allocator
8580 expressions that attempt to allocate protected objects.
8582 @item No_Secondary_Stack
8583 @findex No_Secondary_Stack
8584 This restriction ensures at compile time that the generated code does not
8585 contain any reference to the secondary stack. The secondary stack is used
8586 to implement functions returning unconstrained objects (arrays or records)
8589 @item No_Select_Statements
8590 @findex No_Select_Statements
8591 This restriction ensures at compile time no select statements of any kind
8592 are permitted, that is the keyword @code{select} may not appear.
8593 This is one of the restrictions of the Ravenscar
8594 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8596 @item No_Standard_Storage_Pools
8597 @findex No_Standard_Storage_Pools
8598 This restriction ensures at compile time that no access types
8599 use the standard default storage pool. Any access type declared must
8600 have an explicit Storage_Pool attribute defined specifying a
8601 user-defined storage pool.
8605 This restriction ensures at compile/bind time that there are no
8606 stream objects created and no use of stream attributes.
8607 This restriction does not forbid dependences on the package
8608 @code{Ada.Streams}. So it is permissible to with
8609 @code{Ada.Streams} (or another package that does so itself)
8610 as long as no actual stream objects are created and no
8611 stream attributes are used.
8613 Note that the use of restriction allows optimization of tagged types,
8614 since they do not need to worry about dispatching stream operations.
8615 To take maximum advantage of this space-saving optimization, any
8616 unit declaring a tagged type should be compiled with the restriction,
8617 though this is not required.
8619 @item No_Task_Attributes_Package
8620 @findex No_Task_Attributes_Package
8621 This restriction ensures at compile time that there are no implicit or
8622 explicit dependencies on the package @code{Ada.Task_Attributes}.
8624 @item No_Task_Termination
8625 @findex No_Task_Termination
8626 This restriction ensures at compile time that no terminate alternatives
8627 appear in any task body.
8631 This restriction prevents the declaration of tasks or task types throughout
8632 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
8633 except that violations are caught at compile time and cause an error message
8634 to be output either by the compiler or binder.
8636 @item Static_Priorities
8637 @findex Static_Priorities
8638 This restriction ensures at compile time that all priority expressions
8639 are static, and that there are no dependencies on the package
8640 @code{Ada.Dynamic_Priorities}.
8642 @item Static_Storage_Size
8643 @findex Static_Storage_Size
8644 This restriction ensures at compile time that any expression appearing
8645 in a Storage_Size pragma or attribute definition clause is static.
8650 The second set of implementation dependent restriction identifiers
8651 does not require partition-wide consistency.
8652 The restriction may be enforced for a single
8653 compilation unit without any effect on any of the
8654 other compilation units in the partition.
8658 @item No_Elaboration_Code
8659 @findex No_Elaboration_Code
8660 This restriction ensures at compile time that no elaboration code is
8661 generated. Note that this is not the same condition as is enforced
8662 by pragma @code{Preelaborate}. There are cases in which pragma
8663 @code{Preelaborate} still permits code to be generated (e.g.@: code
8664 to initialize a large array to all zeroes), and there are cases of units
8665 which do not meet the requirements for pragma @code{Preelaborate},
8666 but for which no elaboration code is generated. Generally, it is
8667 the case that preelaborable units will meet the restrictions, with
8668 the exception of large aggregates initialized with an others_clause,
8669 and exception declarations (which generate calls to a run-time
8670 registry procedure). This restriction is enforced on
8671 a unit by unit basis, it need not be obeyed consistently
8672 throughout a partition.
8674 In the case of aggregates with others, if the aggregate has a dynamic
8675 size, there is no way to eliminate the elaboration code (such dynamic
8676 bounds would be incompatible with @code{Preelaborate} in any case). If
8677 the bounds are static, then use of this restriction actually modifies
8678 the code choice of the compiler to avoid generating a loop, and instead
8679 generate the aggregate statically if possible, no matter how many times
8680 the data for the others clause must be repeatedly generated.
8682 It is not possible to precisely document
8683 the constructs which are compatible with this restriction, since,
8684 unlike most other restrictions, this is not a restriction on the
8685 source code, but a restriction on the generated object code. For
8686 example, if the source contains a declaration:
8689 Val : constant Integer := X;
8693 where X is not a static constant, it may be possible, depending
8694 on complex optimization circuitry, for the compiler to figure
8695 out the value of X at compile time, in which case this initialization
8696 can be done by the loader, and requires no initialization code. It
8697 is not possible to document the precise conditions under which the
8698 optimizer can figure this out.
8700 Note that this the implementation of this restriction requires full
8701 code generation. If it is used in conjunction with "semantics only"
8702 checking, then some cases of violations may be missed.
8704 @item No_Entry_Queue
8705 @findex No_Entry_Queue
8706 This restriction is a declaration that any protected entry compiled in
8707 the scope of the restriction has at most one task waiting on the entry
8708 at any one time, and so no queue is required. This restriction is not
8709 checked at compile time. A program execution is erroneous if an attempt
8710 is made to queue a second task on such an entry.
8712 @item No_Implementation_Attributes
8713 @findex No_Implementation_Attributes
8714 This restriction checks at compile time that no GNAT-defined attributes
8715 are present. With this restriction, the only attributes that can be used
8716 are those defined in the Ada Reference Manual.
8718 @item No_Implementation_Pragmas
8719 @findex No_Implementation_Pragmas
8720 This restriction checks at compile time that no GNAT-defined pragmas
8721 are present. With this restriction, the only pragmas that can be used
8722 are those defined in the Ada Reference Manual.
8724 @item No_Implementation_Restrictions
8725 @findex No_Implementation_Restrictions
8726 This restriction checks at compile time that no GNAT-defined restriction
8727 identifiers (other than @code{No_Implementation_Restrictions} itself)
8728 are present. With this restriction, the only other restriction identifiers
8729 that can be used are those defined in the Ada Reference Manual.
8731 @item No_Wide_Characters
8732 @findex No_Wide_Characters
8733 This restriction ensures at compile time that no uses of the types
8734 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8736 appear, and that no wide or wide wide string or character literals
8737 appear in the program (that is literals representing characters not in
8738 type @code{Character}.
8745 @strong{58}. The consequences of violating limitations on
8746 @code{Restrictions} pragmas. See 13.12(9).
8749 Restrictions that can be checked at compile time result in illegalities
8750 if violated. Currently there are no other consequences of violating
8756 @strong{59}. The representation used by the @code{Read} and
8757 @code{Write} attributes of elementary types in terms of stream
8758 elements. See 13.13.2(9).
8761 The representation is the in-memory representation of the base type of
8762 the type, using the number of bits corresponding to the
8763 @code{@var{type}'Size} value, and the natural ordering of the machine.
8768 @strong{60}. The names and characteristics of the numeric subtypes
8769 declared in the visible part of package @code{Standard}. See A.1(3).
8772 See items describing the integer and floating-point types supported.
8777 @strong{61}. The accuracy actually achieved by the elementary
8778 functions. See A.5.1(1).
8781 The elementary functions correspond to the functions available in the C
8782 library. Only fast math mode is implemented.
8787 @strong{62}. The sign of a zero result from some of the operators or
8788 functions in @code{Numerics.Generic_Elementary_Functions}, when
8789 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
8792 The sign of zeroes follows the requirements of the IEEE 754 standard on
8798 @strong{63}. The value of
8799 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
8802 Maximum image width is 649, see library file @file{a-numran.ads}.
8807 @strong{64}. The value of
8808 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
8811 Maximum image width is 80, see library file @file{a-nudira.ads}.
8816 @strong{65}. The algorithms for random number generation. See
8820 The algorithm is documented in the source files @file{a-numran.ads} and
8821 @file{a-numran.adb}.
8826 @strong{66}. The string representation of a random number generator's
8827 state. See A.5.2(38).
8830 See the documentation contained in the file @file{a-numran.adb}.
8835 @strong{67}. The minimum time interval between calls to the
8836 time-dependent Reset procedure that are guaranteed to initiate different
8837 random number sequences. See A.5.2(45).
8840 The minimum period between reset calls to guarantee distinct series of
8841 random numbers is one microsecond.
8846 @strong{68}. The values of the @code{Model_Mantissa},
8847 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8848 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8849 Annex is not supported. See A.5.3(72).
8852 See the source file @file{ttypef.ads} for the values of all numeric
8858 @strong{69}. Any implementation-defined characteristics of the
8859 input-output packages. See A.7(14).
8862 There are no special implementation defined characteristics for these
8868 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
8872 All type representations are contiguous, and the @code{Buffer_Size} is
8873 the value of @code{@var{type}'Size} rounded up to the next storage unit
8879 @strong{71}. External files for standard input, standard output, and
8880 standard error See A.10(5).
8883 These files are mapped onto the files provided by the C streams
8884 libraries. See source file @file{i-cstrea.ads} for further details.
8889 @strong{72}. The accuracy of the value produced by @code{Put}. See
8893 If more digits are requested in the output than are represented by the
8894 precision of the value, zeroes are output in the corresponding least
8895 significant digit positions.
8900 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
8901 @code{Command_Name}. See A.15(1).
8904 These are mapped onto the @code{argv} and @code{argc} parameters of the
8905 main program in the natural manner.
8910 @strong{74}. Implementation-defined convention names. See B.1(11).
8913 The following convention names are supported
8921 Synonym for Assembler
8923 Synonym for Assembler
8926 @item C_Pass_By_Copy
8927 Allowed only for record types, like C, but also notes that record
8928 is to be passed by copy rather than reference.
8931 @item C_Plus_Plus (or CPP)
8934 Treated the same as C
8936 Treated the same as C
8940 For support of pragma @code{Import} with convention Intrinsic, see
8941 separate section on Intrinsic Subprograms.
8943 Stdcall (used for Windows implementations only). This convention correspond
8944 to the WINAPI (previously called Pascal convention) C/C++ convention under
8945 Windows. A function with this convention cleans the stack before exit.
8951 Stubbed is a special convention used to indicate that the body of the
8952 subprogram will be entirely ignored. Any call to the subprogram
8953 is converted into a raise of the @code{Program_Error} exception. If a
8954 pragma @code{Import} specifies convention @code{stubbed} then no body need
8955 be present at all. This convention is useful during development for the
8956 inclusion of subprograms whose body has not yet been written.
8960 In addition, all otherwise unrecognized convention names are also
8961 treated as being synonymous with convention C@. In all implementations
8962 except for VMS, use of such other names results in a warning. In VMS
8963 implementations, these names are accepted silently.
8968 @strong{75}. The meaning of link names. See B.1(36).
8971 Link names are the actual names used by the linker.
8976 @strong{76}. The manner of choosing link names when neither the link
8977 name nor the address of an imported or exported entity is specified. See
8981 The default linker name is that which would be assigned by the relevant
8982 external language, interpreting the Ada name as being in all lower case
8988 @strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37).
8991 The string passed to @code{Linker_Options} is presented uninterpreted as
8992 an argument to the link command, unless it contains ASCII.NUL characters.
8993 NUL characters if they appear act as argument separators, so for example
8995 @smallexample @c ada
8996 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9000 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9001 linker. The order of linker options is preserved for a given unit. The final
9002 list of options passed to the linker is in reverse order of the elaboration
9003 order. For example, linker options for a body always appear before the options
9004 from the corresponding package spec.
9009 @strong{78}. The contents of the visible part of package
9010 @code{Interfaces} and its language-defined descendants. See B.2(1).
9013 See files with prefix @file{i-} in the distributed library.
9018 @strong{79}. Implementation-defined children of package
9019 @code{Interfaces}. The contents of the visible part of package
9020 @code{Interfaces}. See B.2(11).
9023 See files with prefix @file{i-} in the distributed library.
9028 @strong{80}. The types @code{Floating}, @code{Long_Floating},
9029 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9030 @code{COBOL_Character}; and the initialization of the variables
9031 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9032 @code{Interfaces.COBOL}. See B.4(50).
9039 (Floating) Long_Float
9044 @item Decimal_Element
9046 @item COBOL_Character
9051 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9056 @strong{81}. Support for access to machine instructions. See C.1(1).
9059 See documentation in file @file{s-maccod.ads} in the distributed library.
9064 @strong{82}. Implementation-defined aspects of access to machine
9065 operations. See C.1(9).
9068 See documentation in file @file{s-maccod.ads} in the distributed library.
9073 @strong{83}. Implementation-defined aspects of interrupts. See C.3(2).
9076 Interrupts are mapped to signals or conditions as appropriate. See
9078 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9079 on the interrupts supported on a particular target.
9084 @strong{84}. Implementation-defined aspects of pre-elaboration. See
9088 GNAT does not permit a partition to be restarted without reloading,
9089 except under control of the debugger.
9094 @strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7).
9097 Pragma @code{Discard_Names} causes names of enumeration literals to
9098 be suppressed. In the presence of this pragma, the Image attribute
9099 provides the image of the Pos of the literal, and Value accepts
9105 @strong{86}. The result of the @code{Task_Identification.Image}
9106 attribute. See C.7.1(7).
9109 The result of this attribute is a string that identifies
9110 the object or component that denotes a given task. If a variable @code{Var}
9111 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9113 is the hexadecimal representation of the virtual address of the corresponding
9114 task control block. If the variable is an array of tasks, the image of each
9115 task will have the form of an indexed component indicating the position of a
9116 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9117 component of a record, the image of the task will have the form of a selected
9118 component. These rules are fully recursive, so that the image of a task that
9119 is a subcomponent of a composite object corresponds to the expression that
9120 designates this task.
9122 If a task is created by an allocator, its image depends on the context. If the
9123 allocator is part of an object declaration, the rules described above are used
9124 to construct its image, and this image is not affected by subsequent
9125 assignments. If the allocator appears within an expression, the image
9126 includes only the name of the task type.
9128 If the configuration pragma Discard_Names is present, or if the restriction
9129 No_Implicit_Heap_Allocation is in effect, the image reduces to
9130 the numeric suffix, that is to say the hexadecimal representation of the
9131 virtual address of the control block of the task.
9135 @strong{87}. The value of @code{Current_Task} when in a protected entry
9136 or interrupt handler. See C.7.1(17).
9139 Protected entries or interrupt handlers can be executed by any
9140 convenient thread, so the value of @code{Current_Task} is undefined.
9145 @strong{88}. The effect of calling @code{Current_Task} from an entry
9146 body or interrupt handler. See C.7.1(19).
9149 The effect of calling @code{Current_Task} from an entry body or
9150 interrupt handler is to return the identification of the task currently
9156 @strong{89}. Implementation-defined aspects of
9157 @code{Task_Attributes}. See C.7.2(19).
9160 There are no implementation-defined aspects of @code{Task_Attributes}.
9165 @strong{90}. Values of all @code{Metrics}. See D(2).
9168 The metrics information for GNAT depends on the performance of the
9169 underlying operating system. The sources of the run-time for tasking
9170 implementation, together with the output from @option{-gnatG} can be
9171 used to determine the exact sequence of operating systems calls made
9172 to implement various tasking constructs. Together with appropriate
9173 information on the performance of the underlying operating system,
9174 on the exact target in use, this information can be used to determine
9175 the required metrics.
9180 @strong{91}. The declarations of @code{Any_Priority} and
9181 @code{Priority}. See D.1(11).
9184 See declarations in file @file{system.ads}.
9189 @strong{92}. Implementation-defined execution resources. See D.1(15).
9192 There are no implementation-defined execution resources.
9197 @strong{93}. Whether, on a multiprocessor, a task that is waiting for
9198 access to a protected object keeps its processor busy. See D.2.1(3).
9201 On a multi-processor, a task that is waiting for access to a protected
9202 object does not keep its processor busy.
9207 @strong{94}. The affect of implementation defined execution resources
9208 on task dispatching. See D.2.1(9).
9213 Tasks map to IRIX threads, and the dispatching policy is as defined by
9214 the IRIX implementation of threads.
9216 Tasks map to threads in the threads package used by GNAT@. Where possible
9217 and appropriate, these threads correspond to native threads of the
9218 underlying operating system.
9223 @strong{95}. Implementation-defined @code{policy_identifiers} allowed
9224 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
9227 There are no implementation-defined policy-identifiers allowed in this
9233 @strong{96}. Implementation-defined aspects of priority inversion. See
9237 Execution of a task cannot be preempted by the implementation processing
9238 of delay expirations for lower priority tasks.
9243 @strong{97}. Implementation defined task dispatching. See D.2.2(18).
9248 Tasks map to IRIX threads, and the dispatching policy is as defined by
9249 the IRIX implementation of threads.
9251 The policy is the same as that of the underlying threads implementation.
9256 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
9257 in a pragma @code{Locking_Policy}. See D.3(4).
9260 The only implementation defined policy permitted in GNAT is
9261 @code{Inheritance_Locking}. On targets that support this policy, locking
9262 is implemented by inheritance, i.e.@: the task owning the lock operates
9263 at a priority equal to the highest priority of any task currently
9264 requesting the lock.
9269 @strong{99}. Default ceiling priorities. See D.3(10).
9272 The ceiling priority of protected objects of the type
9273 @code{System.Interrupt_Priority'Last} as described in the Ada
9274 Reference Manual D.3(10),
9279 @strong{100}. The ceiling of any protected object used internally by
9280 the implementation. See D.3(16).
9283 The ceiling priority of internal protected objects is
9284 @code{System.Priority'Last}.
9289 @strong{101}. Implementation-defined queuing policies. See D.4(1).
9292 There are no implementation-defined queuing policies.
9297 @strong{102}. On a multiprocessor, any conditions that cause the
9298 completion of an aborted construct to be delayed later than what is
9299 specified for a single processor. See D.6(3).
9302 The semantics for abort on a multi-processor is the same as on a single
9303 processor, there are no further delays.
9308 @strong{103}. Any operations that implicitly require heap storage
9309 allocation. See D.7(8).
9312 The only operation that implicitly requires heap storage allocation is
9318 @strong{104}. Implementation-defined aspects of pragma
9319 @code{Restrictions}. See D.7(20).
9322 There are no such implementation-defined aspects.
9327 @strong{105}. Implementation-defined aspects of package
9328 @code{Real_Time}. See D.8(17).
9331 There are no implementation defined aspects of package @code{Real_Time}.
9336 @strong{106}. Implementation-defined aspects of
9337 @code{delay_statements}. See D.9(8).
9340 Any difference greater than one microsecond will cause the task to be
9341 delayed (see D.9(7)).
9346 @strong{107}. The upper bound on the duration of interrupt blocking
9347 caused by the implementation. See D.12(5).
9350 The upper bound is determined by the underlying operating system. In
9351 no cases is it more than 10 milliseconds.
9356 @strong{108}. The means for creating and executing distributed
9360 The GLADE package provides a utility GNATDIST for creating and executing
9361 distributed programs. See the GLADE reference manual for further details.
9366 @strong{109}. Any events that can result in a partition becoming
9367 inaccessible. See E.1(7).
9370 See the GLADE reference manual for full details on such events.
9375 @strong{110}. The scheduling policies, treatment of priorities, and
9376 management of shared resources between partitions in certain cases. See
9380 See the GLADE reference manual for full details on these aspects of
9381 multi-partition execution.
9386 @strong{111}. Events that cause the version of a compilation unit to
9390 Editing the source file of a compilation unit, or the source files of
9391 any units on which it is dependent in a significant way cause the version
9392 to change. No other actions cause the version number to change. All changes
9393 are significant except those which affect only layout, capitalization or
9399 @strong{112}. Whether the execution of the remote subprogram is
9400 immediately aborted as a result of cancellation. See E.4(13).
9403 See the GLADE reference manual for details on the effect of abort in
9404 a distributed application.
9409 @strong{113}. Implementation-defined aspects of the PCS@. See E.5(25).
9412 See the GLADE reference manual for a full description of all implementation
9413 defined aspects of the PCS@.
9418 @strong{114}. Implementation-defined interfaces in the PCS@. See
9422 See the GLADE reference manual for a full description of all
9423 implementation defined interfaces.
9428 @strong{115}. The values of named numbers in the package
9429 @code{Decimal}. See F.2(7).
9441 @item Max_Decimal_Digits
9448 @strong{116}. The value of @code{Max_Picture_Length} in the package
9449 @code{Text_IO.Editing}. See F.3.3(16).
9457 @strong{117}. The value of @code{Max_Picture_Length} in the package
9458 @code{Wide_Text_IO.Editing}. See F.3.4(5).
9466 @strong{118}. The accuracy actually achieved by the complex elementary
9467 functions and by other complex arithmetic operations. See G.1(1).
9470 Standard library functions are used for the complex arithmetic
9471 operations. Only fast math mode is currently supported.
9476 @strong{119}. The sign of a zero result (or a component thereof) from
9477 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9478 @code{Real'Signed_Zeros} is True. See G.1.1(53).
9481 The signs of zero values are as recommended by the relevant
9482 implementation advice.
9487 @strong{120}. The sign of a zero result (or a component thereof) from
9488 any operator or function in
9489 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9490 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
9493 The signs of zero values are as recommended by the relevant
9494 implementation advice.
9499 @strong{121}. Whether the strict mode or the relaxed mode is the
9500 default. See G.2(2).
9503 The strict mode is the default. There is no separate relaxed mode. GNAT
9504 provides a highly efficient implementation of strict mode.
9509 @strong{122}. The result interval in certain cases of fixed-to-float
9510 conversion. See G.2.1(10).
9513 For cases where the result interval is implementation dependent, the
9514 accuracy is that provided by performing all operations in 64-bit IEEE
9515 floating-point format.
9520 @strong{123}. The result of a floating point arithmetic operation in
9521 overflow situations, when the @code{Machine_Overflows} attribute of the
9522 result type is @code{False}. See G.2.1(13).
9525 Infinite and NaN values are produced as dictated by the IEEE
9526 floating-point standard.
9528 Note that on machines that are not fully compliant with the IEEE
9529 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9530 must be used for achieving IEEE confirming behavior (although at the cost
9531 of a significant performance penalty), so infinite and NaN values are
9537 @strong{124}. The result interval for division (or exponentiation by a
9538 negative exponent), when the floating point hardware implements division
9539 as multiplication by a reciprocal. See G.2.1(16).
9542 Not relevant, division is IEEE exact.
9547 @strong{125}. The definition of close result set, which determines the
9548 accuracy of certain fixed point multiplications and divisions. See
9552 Operations in the close result set are performed using IEEE long format
9553 floating-point arithmetic. The input operands are converted to
9554 floating-point, the operation is done in floating-point, and the result
9555 is converted to the target type.
9560 @strong{126}. Conditions on a @code{universal_real} operand of a fixed
9561 point multiplication or division for which the result shall be in the
9562 perfect result set. See G.2.3(22).
9565 The result is only defined to be in the perfect result set if the result
9566 can be computed by a single scaling operation involving a scale factor
9567 representable in 64-bits.
9572 @strong{127}. The result of a fixed point arithmetic operation in
9573 overflow situations, when the @code{Machine_Overflows} attribute of the
9574 result type is @code{False}. See G.2.3(27).
9577 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9583 @strong{128}. The result of an elementary function reference in
9584 overflow situations, when the @code{Machine_Overflows} attribute of the
9585 result type is @code{False}. See G.2.4(4).
9588 IEEE infinite and Nan values are produced as appropriate.
9593 @strong{129}. The value of the angle threshold, within which certain
9594 elementary functions, complex arithmetic operations, and complex
9595 elementary functions yield results conforming to a maximum relative
9596 error bound. See G.2.4(10).
9599 Information on this subject is not yet available.
9604 @strong{130}. The accuracy of certain elementary functions for
9605 parameters beyond the angle threshold. See G.2.4(10).
9608 Information on this subject is not yet available.
9613 @strong{131}. The result of a complex arithmetic operation or complex
9614 elementary function reference in overflow situations, when the
9615 @code{Machine_Overflows} attribute of the corresponding real type is
9616 @code{False}. See G.2.6(5).
9619 IEEE infinite and Nan values are produced as appropriate.
9624 @strong{132}. The accuracy of certain complex arithmetic operations and
9625 certain complex elementary functions for parameters (or components
9626 thereof) beyond the angle threshold. See G.2.6(8).
9629 Information on those subjects is not yet available.
9634 @strong{133}. Information regarding bounded errors and erroneous
9635 execution. See H.2(1).
9638 Information on this subject is not yet available.
9643 @strong{134}. Implementation-defined aspects of pragma
9644 @code{Inspection_Point}. See H.3.2(8).
9647 Pragma @code{Inspection_Point} ensures that the variable is live and can
9648 be examined by the debugger at the inspection point.
9653 @strong{135}. Implementation-defined aspects of pragma
9654 @code{Restrictions}. See H.4(25).
9657 There are no implementation-defined aspects of pragma @code{Restrictions}. The
9658 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9659 generated code. Checks must suppressed by use of pragma @code{Suppress}.
9664 @strong{136}. Any restrictions on pragma @code{Restrictions}. See
9668 There are no restrictions on pragma @code{Restrictions}.
9670 @node Intrinsic Subprograms
9671 @chapter Intrinsic Subprograms
9672 @cindex Intrinsic Subprograms
9675 * Intrinsic Operators::
9676 * Enclosing_Entity::
9677 * Exception_Information::
9678 * Exception_Message::
9686 * Shift_Right_Arithmetic::
9691 GNAT allows a user application program to write the declaration:
9693 @smallexample @c ada
9694 pragma Import (Intrinsic, name);
9698 providing that the name corresponds to one of the implemented intrinsic
9699 subprograms in GNAT, and that the parameter profile of the referenced
9700 subprogram meets the requirements. This chapter describes the set of
9701 implemented intrinsic subprograms, and the requirements on parameter profiles.
9702 Note that no body is supplied; as with other uses of pragma Import, the
9703 body is supplied elsewhere (in this case by the compiler itself). Note
9704 that any use of this feature is potentially non-portable, since the
9705 Ada standard does not require Ada compilers to implement this feature.
9707 @node Intrinsic Operators
9708 @section Intrinsic Operators
9709 @cindex Intrinsic operator
9712 All the predefined numeric operators in package Standard
9713 in @code{pragma Import (Intrinsic,..)}
9714 declarations. In the binary operator case, the operands must have the same
9715 size. The operand or operands must also be appropriate for
9716 the operator. For example, for addition, the operands must
9717 both be floating-point or both be fixed-point, and the
9718 right operand for @code{"**"} must have a root type of
9719 @code{Standard.Integer'Base}.
9720 You can use an intrinsic operator declaration as in the following example:
9722 @smallexample @c ada
9723 type Int1 is new Integer;
9724 type Int2 is new Integer;
9726 function "+" (X1 : Int1; X2 : Int2) return Int1;
9727 function "+" (X1 : Int1; X2 : Int2) return Int2;
9728 pragma Import (Intrinsic, "+");
9732 This declaration would permit ``mixed mode'' arithmetic on items
9733 of the differing types @code{Int1} and @code{Int2}.
9734 It is also possible to specify such operators for private types, if the
9735 full views are appropriate arithmetic types.
9737 @node Enclosing_Entity
9738 @section Enclosing_Entity
9739 @cindex Enclosing_Entity
9741 This intrinsic subprogram is used in the implementation of the
9742 library routine @code{GNAT.Source_Info}. The only useful use of the
9743 intrinsic import in this case is the one in this unit, so an
9744 application program should simply call the function
9745 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9746 the current subprogram, package, task, entry, or protected subprogram.
9748 @node Exception_Information
9749 @section Exception_Information
9750 @cindex Exception_Information'
9752 This intrinsic subprogram is used in the implementation of the
9753 library routine @code{GNAT.Current_Exception}. The only useful
9754 use of the intrinsic import in this case is the one in this unit,
9755 so an application program should simply call the function
9756 @code{GNAT.Current_Exception.Exception_Information} to obtain
9757 the exception information associated with the current exception.
9759 @node Exception_Message
9760 @section Exception_Message
9761 @cindex Exception_Message
9763 This intrinsic subprogram is used in the implementation of the
9764 library routine @code{GNAT.Current_Exception}. The only useful
9765 use of the intrinsic import in this case is the one in this unit,
9766 so an application program should simply call the function
9767 @code{GNAT.Current_Exception.Exception_Message} to obtain
9768 the message associated with the current exception.
9770 @node Exception_Name
9771 @section Exception_Name
9772 @cindex Exception_Name
9774 This intrinsic subprogram is used in the implementation of the
9775 library routine @code{GNAT.Current_Exception}. The only useful
9776 use of the intrinsic import in this case is the one in this unit,
9777 so an application program should simply call the function
9778 @code{GNAT.Current_Exception.Exception_Name} to obtain
9779 the name of the current exception.
9785 This intrinsic subprogram is used in the implementation of the
9786 library routine @code{GNAT.Source_Info}. The only useful use of the
9787 intrinsic import in this case is the one in this unit, so an
9788 application program should simply call the function
9789 @code{GNAT.Source_Info.File} to obtain the name of the current
9796 This intrinsic subprogram is used in the implementation of the
9797 library routine @code{GNAT.Source_Info}. The only useful use of the
9798 intrinsic import in this case is the one in this unit, so an
9799 application program should simply call the function
9800 @code{GNAT.Source_Info.Line} to obtain the number of the current
9804 @section Rotate_Left
9807 In standard Ada, the @code{Rotate_Left} function is available only
9808 for the predefined modular types in package @code{Interfaces}. However, in
9809 GNAT it is possible to define a Rotate_Left function for a user
9810 defined modular type or any signed integer type as in this example:
9812 @smallexample @c ada
9814 (Value : My_Modular_Type;
9816 return My_Modular_Type;
9820 The requirements are that the profile be exactly as in the example
9821 above. The only modifications allowed are in the formal parameter
9822 names, and in the type of @code{Value} and the return type, which
9823 must be the same, and must be either a signed integer type, or
9824 a modular integer type with a binary modulus, and the size must
9825 be 8. 16, 32 or 64 bits.
9828 @section Rotate_Right
9829 @cindex Rotate_Right
9831 A @code{Rotate_Right} function can be defined for any user defined
9832 binary modular integer type, or signed integer type, as described
9833 above for @code{Rotate_Left}.
9839 A @code{Shift_Left} function can be defined for any user defined
9840 binary modular integer type, or signed integer type, as described
9841 above for @code{Rotate_Left}.
9844 @section Shift_Right
9847 A @code{Shift_Right} function can be defined for any user defined
9848 binary modular integer type, or signed integer type, as described
9849 above for @code{Rotate_Left}.
9851 @node Shift_Right_Arithmetic
9852 @section Shift_Right_Arithmetic
9853 @cindex Shift_Right_Arithmetic
9855 A @code{Shift_Right_Arithmetic} function can be defined for any user
9856 defined binary modular integer type, or signed integer type, as described
9857 above for @code{Rotate_Left}.
9859 @node Source_Location
9860 @section Source_Location
9861 @cindex Source_Location
9863 This intrinsic subprogram is used in the implementation of the
9864 library routine @code{GNAT.Source_Info}. The only useful use of the
9865 intrinsic import in this case is the one in this unit, so an
9866 application program should simply call the function
9867 @code{GNAT.Source_Info.Source_Location} to obtain the current
9868 source file location.
9870 @node Representation Clauses and Pragmas
9871 @chapter Representation Clauses and Pragmas
9872 @cindex Representation Clauses
9875 * Alignment Clauses::
9877 * Storage_Size Clauses::
9878 * Size of Variant Record Objects::
9879 * Biased Representation ::
9880 * Value_Size and Object_Size Clauses::
9881 * Component_Size Clauses::
9882 * Bit_Order Clauses::
9883 * Effect of Bit_Order on Byte Ordering::
9884 * Pragma Pack for Arrays::
9885 * Pragma Pack for Records::
9886 * Record Representation Clauses::
9887 * Enumeration Clauses::
9889 * Effect of Convention on Representation::
9890 * Determining the Representations chosen by GNAT::
9894 @cindex Representation Clause
9895 @cindex Representation Pragma
9896 @cindex Pragma, representation
9897 This section describes the representation clauses accepted by GNAT, and
9898 their effect on the representation of corresponding data objects.
9900 GNAT fully implements Annex C (Systems Programming). This means that all
9901 the implementation advice sections in chapter 13 are fully implemented.
9902 However, these sections only require a minimal level of support for
9903 representation clauses. GNAT provides much more extensive capabilities,
9904 and this section describes the additional capabilities provided.
9906 @node Alignment Clauses
9907 @section Alignment Clauses
9908 @cindex Alignment Clause
9911 GNAT requires that all alignment clauses specify a power of 2, and all
9912 default alignments are always a power of 2. The default alignment
9913 values are as follows:
9916 @item @emph{Primitive Types}.
9917 For primitive types, the alignment is the minimum of the actual size of
9918 objects of the type divided by @code{Storage_Unit},
9919 and the maximum alignment supported by the target.
9920 (This maximum alignment is given by the GNAT-specific attribute
9921 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9922 @cindex @code{Maximum_Alignment} attribute
9923 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9924 default alignment will be 8 on any target that supports alignments
9925 this large, but on some targets, the maximum alignment may be smaller
9926 than 8, in which case objects of type @code{Long_Float} will be maximally
9929 @item @emph{Arrays}.
9930 For arrays, the alignment is equal to the alignment of the component type
9931 for the normal case where no packing or component size is given. If the
9932 array is packed, and the packing is effective (see separate section on
9933 packed arrays), then the alignment will be one for long packed arrays,
9934 or arrays whose length is not known at compile time. For short packed
9935 arrays, which are handled internally as modular types, the alignment
9936 will be as described for primitive types, e.g.@: a packed array of length
9937 31 bits will have an object size of four bytes, and an alignment of 4.
9939 @item @emph{Records}.
9940 For the normal non-packed case, the alignment of a record is equal to
9941 the maximum alignment of any of its components. For tagged records, this
9942 includes the implicit access type used for the tag. If a pragma @code{Pack}
9943 is used and all components are packable (see separate section on pragma
9944 @code{Pack}), then the resulting alignment is 1, unless the layout of the
9945 record makes it profitable to increase it.
9947 A special case is when:
9950 the size of the record is given explicitly, or a
9951 full record representation clause is given, and
9953 the size of the record is 2, 4, or 8 bytes.
9956 In this case, an alignment is chosen to match the
9957 size of the record. For example, if we have:
9959 @smallexample @c ada
9960 type Small is record
9963 for Small'Size use 16;
9967 then the default alignment of the record type @code{Small} is 2, not 1. This
9968 leads to more efficient code when the record is treated as a unit, and also
9969 allows the type to specified as @code{Atomic} on architectures requiring
9975 An alignment clause may specify a larger alignment than the default value
9976 up to some maximum value dependent on the target (obtainable by using the
9977 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
9978 a smaller alignment than the default value for enumeration, integer and
9979 fixed point types, as well as for record types, for example
9981 @smallexample @c ada
9986 for V'alignment use 1;
9990 @cindex Alignment, default
9991 The default alignment for the type @code{V} is 4, as a result of the
9992 Integer field in the record, but it is permissible, as shown, to
9993 override the default alignment of the record with a smaller value.
9996 @section Size Clauses
10000 The default size for a type @code{T} is obtainable through the
10001 language-defined attribute @code{T'Size} and also through the
10002 equivalent GNAT-defined attribute @code{T'Value_Size}.
10003 For objects of type @code{T}, GNAT will generally increase the type size
10004 so that the object size (obtainable through the GNAT-defined attribute
10005 @code{T'Object_Size})
10006 is a multiple of @code{T'Alignment * Storage_Unit}.
10009 @smallexample @c ada
10010 type Smallint is range 1 .. 6;
10019 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10020 as specified by the RM rules,
10021 but objects of this type will have a size of 8
10022 (@code{Smallint'Object_Size} = 8),
10023 since objects by default occupy an integral number
10024 of storage units. On some targets, notably older
10025 versions of the Digital Alpha, the size of stand
10026 alone objects of this type may be 32, reflecting
10027 the inability of the hardware to do byte load/stores.
10029 Similarly, the size of type @code{Rec} is 40 bits
10030 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10031 the alignment is 4, so objects of this type will have
10032 their size increased to 64 bits so that it is a multiple
10033 of the alignment (in bits). This decision is
10034 in accordance with the specific Implementation Advice in RM 13.3(43):
10037 A @code{Size} clause should be supported for an object if the specified
10038 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10039 to a size in storage elements that is a multiple of the object's
10040 @code{Alignment} (if the @code{Alignment} is nonzero).
10044 An explicit size clause may be used to override the default size by
10045 increasing it. For example, if we have:
10047 @smallexample @c ada
10048 type My_Boolean is new Boolean;
10049 for My_Boolean'Size use 32;
10053 then values of this type will always be 32 bits long. In the case of
10054 discrete types, the size can be increased up to 64 bits, with the effect
10055 that the entire specified field is used to hold the value, sign- or
10056 zero-extended as appropriate. If more than 64 bits is specified, then
10057 padding space is allocated after the value, and a warning is issued that
10058 there are unused bits.
10060 Similarly the size of records and arrays may be increased, and the effect
10061 is to add padding bits after the value. This also causes a warning message
10064 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
10065 Size in bits, this corresponds to an object of size 256 megabytes (minus
10066 one). This limitation is true on all targets. The reason for this
10067 limitation is that it improves the quality of the code in many cases
10068 if it is known that a Size value can be accommodated in an object of
10071 @node Storage_Size Clauses
10072 @section Storage_Size Clauses
10073 @cindex Storage_Size Clause
10076 For tasks, the @code{Storage_Size} clause specifies the amount of space
10077 to be allocated for the task stack. This cannot be extended, and if the
10078 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10079 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
10080 or a @code{Storage_Size} pragma in the task definition to set the
10081 appropriate required size. A useful technique is to include in every
10082 task definition a pragma of the form:
10084 @smallexample @c ada
10085 pragma Storage_Size (Default_Stack_Size);
10089 Then @code{Default_Stack_Size} can be defined in a global package, and
10090 modified as required. Any tasks requiring stack sizes different from the
10091 default can have an appropriate alternative reference in the pragma.
10093 You can also use the @option{-d} binder switch to modify the default stack
10096 For access types, the @code{Storage_Size} clause specifies the maximum
10097 space available for allocation of objects of the type. If this space is
10098 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10099 In the case where the access type is declared local to a subprogram, the
10100 use of a @code{Storage_Size} clause triggers automatic use of a special
10101 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10102 space for the pool is automatically reclaimed on exit from the scope in
10103 which the type is declared.
10105 A special case recognized by the compiler is the specification of a
10106 @code{Storage_Size} of zero for an access type. This means that no
10107 items can be allocated from the pool, and this is recognized at compile
10108 time, and all the overhead normally associated with maintaining a fixed
10109 size storage pool is eliminated. Consider the following example:
10111 @smallexample @c ada
10113 type R is array (Natural) of Character;
10114 type P is access all R;
10115 for P'Storage_Size use 0;
10116 -- Above access type intended only for interfacing purposes
10120 procedure g (m : P);
10121 pragma Import (C, g);
10132 As indicated in this example, these dummy storage pools are often useful in
10133 connection with interfacing where no object will ever be allocated. If you
10134 compile the above example, you get the warning:
10137 p.adb:16:09: warning: allocation from empty storage pool
10138 p.adb:16:09: warning: Storage_Error will be raised at run time
10142 Of course in practice, there will not be any explicit allocators in the
10143 case of such an access declaration.
10145 @node Size of Variant Record Objects
10146 @section Size of Variant Record Objects
10147 @cindex Size, variant record objects
10148 @cindex Variant record objects, size
10151 In the case of variant record objects, there is a question whether Size gives
10152 information about a particular variant, or the maximum size required
10153 for any variant. Consider the following program
10155 @smallexample @c ada
10156 with Text_IO; use Text_IO;
10158 type R1 (A : Boolean := False) is record
10160 when True => X : Character;
10161 when False => null;
10169 Put_Line (Integer'Image (V1'Size));
10170 Put_Line (Integer'Image (V2'Size));
10175 Here we are dealing with a variant record, where the True variant
10176 requires 16 bits, and the False variant requires 8 bits.
10177 In the above example, both V1 and V2 contain the False variant,
10178 which is only 8 bits long. However, the result of running the
10187 The reason for the difference here is that the discriminant value of
10188 V1 is fixed, and will always be False. It is not possible to assign
10189 a True variant value to V1, therefore 8 bits is sufficient. On the
10190 other hand, in the case of V2, the initial discriminant value is
10191 False (from the default), but it is possible to assign a True
10192 variant value to V2, therefore 16 bits must be allocated for V2
10193 in the general case, even fewer bits may be needed at any particular
10194 point during the program execution.
10196 As can be seen from the output of this program, the @code{'Size}
10197 attribute applied to such an object in GNAT gives the actual allocated
10198 size of the variable, which is the largest size of any of the variants.
10199 The Ada Reference Manual is not completely clear on what choice should
10200 be made here, but the GNAT behavior seems most consistent with the
10201 language in the RM@.
10203 In some cases, it may be desirable to obtain the size of the current
10204 variant, rather than the size of the largest variant. This can be
10205 achieved in GNAT by making use of the fact that in the case of a
10206 subprogram parameter, GNAT does indeed return the size of the current
10207 variant (because a subprogram has no way of knowing how much space
10208 is actually allocated for the actual).
10210 Consider the following modified version of the above program:
10212 @smallexample @c ada
10213 with Text_IO; use Text_IO;
10215 type R1 (A : Boolean := False) is record
10217 when True => X : Character;
10218 when False => null;
10224 function Size (V : R1) return Integer is
10230 Put_Line (Integer'Image (V2'Size));
10231 Put_Line (Integer'IMage (Size (V2)));
10233 Put_Line (Integer'Image (V2'Size));
10234 Put_Line (Integer'IMage (Size (V2)));
10239 The output from this program is
10249 Here we see that while the @code{'Size} attribute always returns
10250 the maximum size, regardless of the current variant value, the
10251 @code{Size} function does indeed return the size of the current
10254 @node Biased Representation
10255 @section Biased Representation
10256 @cindex Size for biased representation
10257 @cindex Biased representation
10260 In the case of scalars with a range starting at other than zero, it is
10261 possible in some cases to specify a size smaller than the default minimum
10262 value, and in such cases, GNAT uses an unsigned biased representation,
10263 in which zero is used to represent the lower bound, and successive values
10264 represent successive values of the type.
10266 For example, suppose we have the declaration:
10268 @smallexample @c ada
10269 type Small is range -7 .. -4;
10270 for Small'Size use 2;
10274 Although the default size of type @code{Small} is 4, the @code{Size}
10275 clause is accepted by GNAT and results in the following representation
10279 -7 is represented as 2#00#
10280 -6 is represented as 2#01#
10281 -5 is represented as 2#10#
10282 -4 is represented as 2#11#
10286 Biased representation is only used if the specified @code{Size} clause
10287 cannot be accepted in any other manner. These reduced sizes that force
10288 biased representation can be used for all discrete types except for
10289 enumeration types for which a representation clause is given.
10291 @node Value_Size and Object_Size Clauses
10292 @section Value_Size and Object_Size Clauses
10294 @findex Object_Size
10295 @cindex Size, of objects
10298 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10299 number of bits required to hold values of type @code{T}.
10300 Although this interpretation was allowed in Ada 83, it was not required,
10301 and this requirement in practice can cause some significant difficulties.
10302 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10303 However, in Ada 95 and Ada 2005,
10304 @code{Natural'Size} is
10305 typically 31. This means that code may change in behavior when moving
10306 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
10308 @smallexample @c ada
10309 type Rec is record;
10315 at 0 range 0 .. Natural'Size - 1;
10316 at 0 range Natural'Size .. 2 * Natural'Size - 1;
10321 In the above code, since the typical size of @code{Natural} objects
10322 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10323 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10324 there are cases where the fact that the object size can exceed the
10325 size of the type causes surprises.
10327 To help get around this problem GNAT provides two implementation
10328 defined attributes, @code{Value_Size} and @code{Object_Size}. When
10329 applied to a type, these attributes yield the size of the type
10330 (corresponding to the RM defined size attribute), and the size of
10331 objects of the type respectively.
10333 The @code{Object_Size} is used for determining the default size of
10334 objects and components. This size value can be referred to using the
10335 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
10336 the basis of the determination of the size. The backend is free to
10337 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10338 character might be stored in 32 bits on a machine with no efficient
10339 byte access instructions such as the Alpha.
10341 The default rules for the value of @code{Object_Size} for
10342 discrete types are as follows:
10346 The @code{Object_Size} for base subtypes reflect the natural hardware
10347 size in bits (run the compiler with @option{-gnatS} to find those values
10348 for numeric types). Enumeration types and fixed-point base subtypes have
10349 8, 16, 32 or 64 bits for this size, depending on the range of values
10353 The @code{Object_Size} of a subtype is the same as the
10354 @code{Object_Size} of
10355 the type from which it is obtained.
10358 The @code{Object_Size} of a derived base type is copied from the parent
10359 base type, and the @code{Object_Size} of a derived first subtype is copied
10360 from the parent first subtype.
10364 The @code{Value_Size} attribute
10365 is the (minimum) number of bits required to store a value
10367 This value is used to determine how tightly to pack
10368 records or arrays with components of this type, and also affects
10369 the semantics of unchecked conversion (unchecked conversions where
10370 the @code{Value_Size} values differ generate a warning, and are potentially
10373 The default rules for the value of @code{Value_Size} are as follows:
10377 The @code{Value_Size} for a base subtype is the minimum number of bits
10378 required to store all values of the type (including the sign bit
10379 only if negative values are possible).
10382 If a subtype statically matches the first subtype of a given type, then it has
10383 by default the same @code{Value_Size} as the first subtype. This is a
10384 consequence of RM 13.1(14) (``if two subtypes statically match,
10385 then their subtype-specific aspects are the same''.)
10388 All other subtypes have a @code{Value_Size} corresponding to the minimum
10389 number of bits required to store all values of the subtype. For
10390 dynamic bounds, it is assumed that the value can range down or up
10391 to the corresponding bound of the ancestor
10395 The RM defined attribute @code{Size} corresponds to the
10396 @code{Value_Size} attribute.
10398 The @code{Size} attribute may be defined for a first-named subtype. This sets
10399 the @code{Value_Size} of
10400 the first-named subtype to the given value, and the
10401 @code{Object_Size} of this first-named subtype to the given value padded up
10402 to an appropriate boundary. It is a consequence of the default rules
10403 above that this @code{Object_Size} will apply to all further subtypes. On the
10404 other hand, @code{Value_Size} is affected only for the first subtype, any
10405 dynamic subtypes obtained from it directly, and any statically matching
10406 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
10408 @code{Value_Size} and
10409 @code{Object_Size} may be explicitly set for any subtype using
10410 an attribute definition clause. Note that the use of these attributes
10411 can cause the RM 13.1(14) rule to be violated. If two access types
10412 reference aliased objects whose subtypes have differing @code{Object_Size}
10413 values as a result of explicit attribute definition clauses, then it
10414 is erroneous to convert from one access subtype to the other.
10416 At the implementation level, Esize stores the Object_Size and the
10417 RM_Size field stores the @code{Value_Size} (and hence the value of the
10418 @code{Size} attribute,
10419 which, as noted above, is equivalent to @code{Value_Size}).
10421 To get a feel for the difference, consider the following examples (note
10422 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10425 Object_Size Value_Size
10427 type x1 is range 0 .. 5; 8 3
10429 type x2 is range 0 .. 5;
10430 for x2'size use 12; 16 12
10432 subtype x3 is x2 range 0 .. 3; 16 2
10434 subtype x4 is x2'base range 0 .. 10; 8 4
10436 subtype x5 is x2 range 0 .. dynamic; 16 3*
10438 subtype x6 is x2'base range 0 .. dynamic; 8 3*
10443 Note: the entries marked ``3*'' are not actually specified by the Ada
10444 Reference Manual, but it seems in the spirit of the RM rules to allocate
10445 the minimum number of bits (here 3, given the range for @code{x2})
10446 known to be large enough to hold the given range of values.
10448 So far, so good, but GNAT has to obey the RM rules, so the question is
10449 under what conditions must the RM @code{Size} be used.
10450 The following is a list
10451 of the occasions on which the RM @code{Size} must be used:
10455 Component size for packed arrays or records
10458 Value of the attribute @code{Size} for a type
10461 Warning about sizes not matching for unchecked conversion
10465 For record types, the @code{Object_Size} is always a multiple of the
10466 alignment of the type (this is true for all types). In some cases the
10467 @code{Value_Size} can be smaller. Consider:
10477 On a typical 32-bit architecture, the X component will be four bytes, and
10478 require four-byte alignment, and the Y component will be one byte. In this
10479 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10480 required to store a value of this type, and for example, it is permissible
10481 to have a component of type R in an outer array whose component size is
10482 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10483 since it must be rounded up so that this value is a multiple of the
10484 alignment (4 bytes = 32 bits).
10487 For all other types, the @code{Object_Size}
10488 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10489 Only @code{Size} may be specified for such types.
10491 @node Component_Size Clauses
10492 @section Component_Size Clauses
10493 @cindex Component_Size Clause
10496 Normally, the value specified in a component size clause must be consistent
10497 with the subtype of the array component with regard to size and alignment.
10498 In other words, the value specified must be at least equal to the size
10499 of this subtype, and must be a multiple of the alignment value.
10501 In addition, component size clauses are allowed which cause the array
10502 to be packed, by specifying a smaller value. A first case is for
10503 component size values in the range 1 through 63. The value specified
10504 must not be smaller than the Size of the subtype. GNAT will accurately
10505 honor all packing requests in this range. For example, if we have:
10507 @smallexample @c ada
10508 type r is array (1 .. 8) of Natural;
10509 for r'Component_Size use 31;
10513 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10514 Of course access to the components of such an array is considerably
10515 less efficient than if the natural component size of 32 is used.
10516 A second case is when the subtype of the component is a record type
10517 padded because of its default alignment. For example, if we have:
10519 @smallexample @c ada
10526 type a is array (1 .. 8) of r;
10527 for a'Component_Size use 72;
10531 then the resulting array has a length of 72 bytes, instead of 96 bytes
10532 if the alignment of the record (4) was obeyed.
10534 Note that there is no point in giving both a component size clause
10535 and a pragma Pack for the same array type. if such duplicate
10536 clauses are given, the pragma Pack will be ignored.
10538 @node Bit_Order Clauses
10539 @section Bit_Order Clauses
10540 @cindex Bit_Order Clause
10541 @cindex bit ordering
10542 @cindex ordering, of bits
10545 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10546 attribute. The specification may either correspond to the default bit
10547 order for the target, in which case the specification has no effect and
10548 places no additional restrictions, or it may be for the non-standard
10549 setting (that is the opposite of the default).
10551 In the case where the non-standard value is specified, the effect is
10552 to renumber bits within each byte, but the ordering of bytes is not
10553 affected. There are certain
10554 restrictions placed on component clauses as follows:
10558 @item Components fitting within a single storage unit.
10560 These are unrestricted, and the effect is merely to renumber bits. For
10561 example if we are on a little-endian machine with @code{Low_Order_First}
10562 being the default, then the following two declarations have exactly
10565 @smallexample @c ada
10568 B : Integer range 1 .. 120;
10572 A at 0 range 0 .. 0;
10573 B at 0 range 1 .. 7;
10578 B : Integer range 1 .. 120;
10581 for R2'Bit_Order use High_Order_First;
10584 A at 0 range 7 .. 7;
10585 B at 0 range 0 .. 6;
10590 The useful application here is to write the second declaration with the
10591 @code{Bit_Order} attribute definition clause, and know that it will be treated
10592 the same, regardless of whether the target is little-endian or big-endian.
10594 @item Components occupying an integral number of bytes.
10596 These are components that exactly fit in two or more bytes. Such component
10597 declarations are allowed, but have no effect, since it is important to realize
10598 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10599 In particular, the following attempt at getting an endian-independent integer
10602 @smallexample @c ada
10607 for R2'Bit_Order use High_Order_First;
10610 A at 0 range 0 .. 31;
10615 This declaration will result in a little-endian integer on a
10616 little-endian machine, and a big-endian integer on a big-endian machine.
10617 If byte flipping is required for interoperability between big- and
10618 little-endian machines, this must be explicitly programmed. This capability
10619 is not provided by @code{Bit_Order}.
10621 @item Components that are positioned across byte boundaries
10623 but do not occupy an integral number of bytes. Given that bytes are not
10624 reordered, such fields would occupy a non-contiguous sequence of bits
10625 in memory, requiring non-trivial code to reassemble. They are for this
10626 reason not permitted, and any component clause specifying such a layout
10627 will be flagged as illegal by GNAT@.
10632 Since the misconception that Bit_Order automatically deals with all
10633 endian-related incompatibilities is a common one, the specification of
10634 a component field that is an integral number of bytes will always
10635 generate a warning. This warning may be suppressed using @code{pragma
10636 Warnings (Off)} if desired. The following section contains additional
10637 details regarding the issue of byte ordering.
10639 @node Effect of Bit_Order on Byte Ordering
10640 @section Effect of Bit_Order on Byte Ordering
10641 @cindex byte ordering
10642 @cindex ordering, of bytes
10645 In this section we will review the effect of the @code{Bit_Order} attribute
10646 definition clause on byte ordering. Briefly, it has no effect at all, but
10647 a detailed example will be helpful. Before giving this
10648 example, let us review the precise
10649 definition of the effect of defining @code{Bit_Order}. The effect of a
10650 non-standard bit order is described in section 15.5.3 of the Ada
10654 2 A bit ordering is a method of interpreting the meaning of
10655 the storage place attributes.
10659 To understand the precise definition of storage place attributes in
10660 this context, we visit section 13.5.1 of the manual:
10663 13 A record_representation_clause (without the mod_clause)
10664 specifies the layout. The storage place attributes (see 13.5.2)
10665 are taken from the values of the position, first_bit, and last_bit
10666 expressions after normalizing those values so that first_bit is
10667 less than Storage_Unit.
10671 The critical point here is that storage places are taken from
10672 the values after normalization, not before. So the @code{Bit_Order}
10673 interpretation applies to normalized values. The interpretation
10674 is described in the later part of the 15.5.3 paragraph:
10677 2 A bit ordering is a method of interpreting the meaning of
10678 the storage place attributes. High_Order_First (known in the
10679 vernacular as ``big endian'') means that the first bit of a
10680 storage element (bit 0) is the most significant bit (interpreting
10681 the sequence of bits that represent a component as an unsigned
10682 integer value). Low_Order_First (known in the vernacular as
10683 ``little endian'') means the opposite: the first bit is the
10688 Note that the numbering is with respect to the bits of a storage
10689 unit. In other words, the specification affects only the numbering
10690 of bits within a single storage unit.
10692 We can make the effect clearer by giving an example.
10694 Suppose that we have an external device which presents two bytes, the first
10695 byte presented, which is the first (low addressed byte) of the two byte
10696 record is called Master, and the second byte is called Slave.
10698 The left most (most significant bit is called Control for each byte, and
10699 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10700 (least significant) bit.
10702 On a big-endian machine, we can write the following representation clause
10704 @smallexample @c ada
10705 type Data is record
10706 Master_Control : Bit;
10714 Slave_Control : Bit;
10724 for Data use record
10725 Master_Control at 0 range 0 .. 0;
10726 Master_V1 at 0 range 1 .. 1;
10727 Master_V2 at 0 range 2 .. 2;
10728 Master_V3 at 0 range 3 .. 3;
10729 Master_V4 at 0 range 4 .. 4;
10730 Master_V5 at 0 range 5 .. 5;
10731 Master_V6 at 0 range 6 .. 6;
10732 Master_V7 at 0 range 7 .. 7;
10733 Slave_Control at 1 range 0 .. 0;
10734 Slave_V1 at 1 range 1 .. 1;
10735 Slave_V2 at 1 range 2 .. 2;
10736 Slave_V3 at 1 range 3 .. 3;
10737 Slave_V4 at 1 range 4 .. 4;
10738 Slave_V5 at 1 range 5 .. 5;
10739 Slave_V6 at 1 range 6 .. 6;
10740 Slave_V7 at 1 range 7 .. 7;
10745 Now if we move this to a little endian machine, then the bit ordering within
10746 the byte is backwards, so we have to rewrite the record rep clause as:
10748 @smallexample @c ada
10749 for Data use record
10750 Master_Control at 0 range 7 .. 7;
10751 Master_V1 at 0 range 6 .. 6;
10752 Master_V2 at 0 range 5 .. 5;
10753 Master_V3 at 0 range 4 .. 4;
10754 Master_V4 at 0 range 3 .. 3;
10755 Master_V5 at 0 range 2 .. 2;
10756 Master_V6 at 0 range 1 .. 1;
10757 Master_V7 at 0 range 0 .. 0;
10758 Slave_Control at 1 range 7 .. 7;
10759 Slave_V1 at 1 range 6 .. 6;
10760 Slave_V2 at 1 range 5 .. 5;
10761 Slave_V3 at 1 range 4 .. 4;
10762 Slave_V4 at 1 range 3 .. 3;
10763 Slave_V5 at 1 range 2 .. 2;
10764 Slave_V6 at 1 range 1 .. 1;
10765 Slave_V7 at 1 range 0 .. 0;
10770 It is a nuisance to have to rewrite the clause, especially if
10771 the code has to be maintained on both machines. However,
10772 this is a case that we can handle with the
10773 @code{Bit_Order} attribute if it is implemented.
10774 Note that the implementation is not required on byte addressed
10775 machines, but it is indeed implemented in GNAT.
10776 This means that we can simply use the
10777 first record clause, together with the declaration
10779 @smallexample @c ada
10780 for Data'Bit_Order use High_Order_First;
10784 and the effect is what is desired, namely the layout is exactly the same,
10785 independent of whether the code is compiled on a big-endian or little-endian
10788 The important point to understand is that byte ordering is not affected.
10789 A @code{Bit_Order} attribute definition never affects which byte a field
10790 ends up in, only where it ends up in that byte.
10791 To make this clear, let us rewrite the record rep clause of the previous
10794 @smallexample @c ada
10795 for Data'Bit_Order use High_Order_First;
10796 for Data use record
10797 Master_Control at 0 range 0 .. 0;
10798 Master_V1 at 0 range 1 .. 1;
10799 Master_V2 at 0 range 2 .. 2;
10800 Master_V3 at 0 range 3 .. 3;
10801 Master_V4 at 0 range 4 .. 4;
10802 Master_V5 at 0 range 5 .. 5;
10803 Master_V6 at 0 range 6 .. 6;
10804 Master_V7 at 0 range 7 .. 7;
10805 Slave_Control at 0 range 8 .. 8;
10806 Slave_V1 at 0 range 9 .. 9;
10807 Slave_V2 at 0 range 10 .. 10;
10808 Slave_V3 at 0 range 11 .. 11;
10809 Slave_V4 at 0 range 12 .. 12;
10810 Slave_V5 at 0 range 13 .. 13;
10811 Slave_V6 at 0 range 14 .. 14;
10812 Slave_V7 at 0 range 15 .. 15;
10817 This is exactly equivalent to saying (a repeat of the first example):
10819 @smallexample @c ada
10820 for Data'Bit_Order use High_Order_First;
10821 for Data use record
10822 Master_Control at 0 range 0 .. 0;
10823 Master_V1 at 0 range 1 .. 1;
10824 Master_V2 at 0 range 2 .. 2;
10825 Master_V3 at 0 range 3 .. 3;
10826 Master_V4 at 0 range 4 .. 4;
10827 Master_V5 at 0 range 5 .. 5;
10828 Master_V6 at 0 range 6 .. 6;
10829 Master_V7 at 0 range 7 .. 7;
10830 Slave_Control at 1 range 0 .. 0;
10831 Slave_V1 at 1 range 1 .. 1;
10832 Slave_V2 at 1 range 2 .. 2;
10833 Slave_V3 at 1 range 3 .. 3;
10834 Slave_V4 at 1 range 4 .. 4;
10835 Slave_V5 at 1 range 5 .. 5;
10836 Slave_V6 at 1 range 6 .. 6;
10837 Slave_V7 at 1 range 7 .. 7;
10842 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10843 field. The storage place attributes are obtained by normalizing the
10844 values given so that the @code{First_Bit} value is less than 8. After
10845 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10846 we specified in the other case.
10848 Now one might expect that the @code{Bit_Order} attribute might affect
10849 bit numbering within the entire record component (two bytes in this
10850 case, thus affecting which byte fields end up in), but that is not
10851 the way this feature is defined, it only affects numbering of bits,
10852 not which byte they end up in.
10854 Consequently it never makes sense to specify a starting bit number
10855 greater than 7 (for a byte addressable field) if an attribute
10856 definition for @code{Bit_Order} has been given, and indeed it
10857 may be actively confusing to specify such a value, so the compiler
10858 generates a warning for such usage.
10860 If you do need to control byte ordering then appropriate conditional
10861 values must be used. If in our example, the slave byte came first on
10862 some machines we might write:
10864 @smallexample @c ada
10865 Master_Byte_First constant Boolean := @dots{};
10867 Master_Byte : constant Natural :=
10868 1 - Boolean'Pos (Master_Byte_First);
10869 Slave_Byte : constant Natural :=
10870 Boolean'Pos (Master_Byte_First);
10872 for Data'Bit_Order use High_Order_First;
10873 for Data use record
10874 Master_Control at Master_Byte range 0 .. 0;
10875 Master_V1 at Master_Byte range 1 .. 1;
10876 Master_V2 at Master_Byte range 2 .. 2;
10877 Master_V3 at Master_Byte range 3 .. 3;
10878 Master_V4 at Master_Byte range 4 .. 4;
10879 Master_V5 at Master_Byte range 5 .. 5;
10880 Master_V6 at Master_Byte range 6 .. 6;
10881 Master_V7 at Master_Byte range 7 .. 7;
10882 Slave_Control at Slave_Byte range 0 .. 0;
10883 Slave_V1 at Slave_Byte range 1 .. 1;
10884 Slave_V2 at Slave_Byte range 2 .. 2;
10885 Slave_V3 at Slave_Byte range 3 .. 3;
10886 Slave_V4 at Slave_Byte range 4 .. 4;
10887 Slave_V5 at Slave_Byte range 5 .. 5;
10888 Slave_V6 at Slave_Byte range 6 .. 6;
10889 Slave_V7 at Slave_Byte range 7 .. 7;
10894 Now to switch between machines, all that is necessary is
10895 to set the boolean constant @code{Master_Byte_First} in
10896 an appropriate manner.
10898 @node Pragma Pack for Arrays
10899 @section Pragma Pack for Arrays
10900 @cindex Pragma Pack (for arrays)
10903 Pragma @code{Pack} applied to an array has no effect unless the component type
10904 is packable. For a component type to be packable, it must be one of the
10911 Any type whose size is specified with a size clause
10913 Any packed array type with a static size
10915 Any record type padded because of its default alignment
10919 For all these cases, if the component subtype size is in the range
10920 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10921 component size were specified giving the component subtype size.
10922 For example if we have:
10924 @smallexample @c ada
10925 type r is range 0 .. 17;
10927 type ar is array (1 .. 8) of r;
10932 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10933 and the size of the array @code{ar} will be exactly 40 bits.
10935 Note that in some cases this rather fierce approach to packing can produce
10936 unexpected effects. For example, in Ada 95 and Ada 2005,
10937 subtype @code{Natural} typically has a size of 31, meaning that if you
10938 pack an array of @code{Natural}, you get 31-bit
10939 close packing, which saves a few bits, but results in far less efficient
10940 access. Since many other Ada compilers will ignore such a packing request,
10941 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10942 might not be what is intended. You can easily remove this warning by
10943 using an explicit @code{Component_Size} setting instead, which never generates
10944 a warning, since the intention of the programmer is clear in this case.
10946 GNAT treats packed arrays in one of two ways. If the size of the array is
10947 known at compile time and is less than 64 bits, then internally the array
10948 is represented as a single modular type, of exactly the appropriate number
10949 of bits. If the length is greater than 63 bits, or is not known at compile
10950 time, then the packed array is represented as an array of bytes, and the
10951 length is always a multiple of 8 bits.
10953 Note that to represent a packed array as a modular type, the alignment must
10954 be suitable for the modular type involved. For example, on typical machines
10955 a 32-bit packed array will be represented by a 32-bit modular integer with
10956 an alignment of four bytes. If you explicitly override the default alignment
10957 with an alignment clause that is too small, the modular representation
10958 cannot be used. For example, consider the following set of declarations:
10960 @smallexample @c ada
10961 type R is range 1 .. 3;
10962 type S is array (1 .. 31) of R;
10963 for S'Component_Size use 2;
10965 for S'Alignment use 1;
10969 If the alignment clause were not present, then a 62-bit modular
10970 representation would be chosen (typically with an alignment of 4 or 8
10971 bytes depending on the target). But the default alignment is overridden
10972 with the explicit alignment clause. This means that the modular
10973 representation cannot be used, and instead the array of bytes
10974 representation must be used, meaning that the length must be a multiple
10975 of 8. Thus the above set of declarations will result in a diagnostic
10976 rejecting the size clause and noting that the minimum size allowed is 64.
10978 @cindex Pragma Pack (for type Natural)
10979 @cindex Pragma Pack warning
10981 One special case that is worth noting occurs when the base type of the
10982 component size is 8/16/32 and the subtype is one bit less. Notably this
10983 occurs with subtype @code{Natural}. Consider:
10985 @smallexample @c ada
10986 type Arr is array (1 .. 32) of Natural;
10991 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10992 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10993 Ada 83 compilers did not attempt 31 bit packing.
10995 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
10996 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
10997 substantial unintended performance penalty when porting legacy Ada 83 code.
10998 To help prevent this, GNAT generates a warning in such cases. If you really
10999 want 31 bit packing in a case like this, you can set the component size
11002 @smallexample @c ada
11003 type Arr is array (1 .. 32) of Natural;
11004 for Arr'Component_Size use 31;
11008 Here 31-bit packing is achieved as required, and no warning is generated,
11009 since in this case the programmer intention is clear.
11011 @node Pragma Pack for Records
11012 @section Pragma Pack for Records
11013 @cindex Pragma Pack (for records)
11016 Pragma @code{Pack} applied to a record will pack the components to reduce
11017 wasted space from alignment gaps and by reducing the amount of space
11018 taken by components. We distinguish between @emph{packable} components and
11019 @emph{non-packable} components.
11020 Components of the following types are considered packable:
11023 All primitive types are packable.
11026 Small packed arrays, whose size does not exceed 64 bits, and where the
11027 size is statically known at compile time, are represented internally
11028 as modular integers, and so they are also packable.
11033 All packable components occupy the exact number of bits corresponding to
11034 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11035 can start on an arbitrary bit boundary.
11037 All other types are non-packable, they occupy an integral number of
11039 are placed at a boundary corresponding to their alignment requirements.
11041 For example, consider the record
11043 @smallexample @c ada
11044 type Rb1 is array (1 .. 13) of Boolean;
11047 type Rb2 is array (1 .. 65) of Boolean;
11062 The representation for the record x2 is as follows:
11064 @smallexample @c ada
11065 for x2'Size use 224;
11067 l1 at 0 range 0 .. 0;
11068 l2 at 0 range 1 .. 64;
11069 l3 at 12 range 0 .. 31;
11070 l4 at 16 range 0 .. 0;
11071 l5 at 16 range 1 .. 13;
11072 l6 at 18 range 0 .. 71;
11077 Studying this example, we see that the packable fields @code{l1}
11079 of length equal to their sizes, and placed at specific bit boundaries (and
11080 not byte boundaries) to
11081 eliminate padding. But @code{l3} is of a non-packable float type, so
11082 it is on the next appropriate alignment boundary.
11084 The next two fields are fully packable, so @code{l4} and @code{l5} are
11085 minimally packed with no gaps. However, type @code{Rb2} is a packed
11086 array that is longer than 64 bits, so it is itself non-packable. Thus
11087 the @code{l6} field is aligned to the next byte boundary, and takes an
11088 integral number of bytes, i.e.@: 72 bits.
11090 @node Record Representation Clauses
11091 @section Record Representation Clauses
11092 @cindex Record Representation Clause
11095 Record representation clauses may be given for all record types, including
11096 types obtained by record extension. Component clauses are allowed for any
11097 static component. The restrictions on component clauses depend on the type
11100 @cindex Component Clause
11101 For all components of an elementary type, the only restriction on component
11102 clauses is that the size must be at least the 'Size value of the type
11103 (actually the Value_Size). There are no restrictions due to alignment,
11104 and such components may freely cross storage boundaries.
11106 Packed arrays with a size up to and including 64 bits are represented
11107 internally using a modular type with the appropriate number of bits, and
11108 thus the same lack of restriction applies. For example, if you declare:
11110 @smallexample @c ada
11111 type R is array (1 .. 49) of Boolean;
11117 then a component clause for a component of type R may start on any
11118 specified bit boundary, and may specify a value of 49 bits or greater.
11120 For packed bit arrays that are longer than 64 bits, there are two
11121 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11122 including the important case of single bits or boolean values, then
11123 there are no limitations on placement of such components, and they
11124 may start and end at arbitrary bit boundaries.
11126 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11127 an array of this type longer than 64 bits must always be placed on
11128 on a storage unit (byte) boundary and occupy an integral number
11129 of storage units (bytes). Any component clause that does not
11130 meet this requirement will be rejected.
11132 Any aliased component, or component of an aliased type, must
11133 have its normal alignment and size. A component clause that
11134 does not meet this requirement will be rejected.
11136 The tag field of a tagged type always occupies an address sized field at
11137 the start of the record. No component clause may attempt to overlay this
11138 tag. When a tagged type appears as a component, the tag field must have
11141 In the case of a record extension T1, of a type T, no component clause applied
11142 to the type T1 can specify a storage location that would overlap the first
11143 T'Size bytes of the record.
11145 For all other component types, including non-bit-packed arrays,
11146 the component can be placed at an arbitrary bit boundary,
11147 so for example, the following is permitted:
11149 @smallexample @c ada
11150 type R is array (1 .. 10) of Boolean;
11159 G at 0 range 0 .. 0;
11160 H at 0 range 1 .. 1;
11161 L at 0 range 2 .. 81;
11162 R at 0 range 82 .. 161;
11167 Note: the above rules apply to recent releases of GNAT 5.
11168 In GNAT 3, there are more severe restrictions on larger components.
11169 For non-primitive types, including packed arrays with a size greater than
11170 64 bits, component clauses must respect the alignment requirement of the
11171 type, in particular, always starting on a byte boundary, and the length
11172 must be a multiple of the storage unit.
11174 @node Enumeration Clauses
11175 @section Enumeration Clauses
11177 The only restriction on enumeration clauses is that the range of values
11178 must be representable. For the signed case, if one or more of the
11179 representation values are negative, all values must be in the range:
11181 @smallexample @c ada
11182 System.Min_Int .. System.Max_Int
11186 For the unsigned case, where all values are nonnegative, the values must
11189 @smallexample @c ada
11190 0 .. System.Max_Binary_Modulus;
11194 A @emph{confirming} representation clause is one in which the values range
11195 from 0 in sequence, i.e.@: a clause that confirms the default representation
11196 for an enumeration type.
11197 Such a confirming representation
11198 is permitted by these rules, and is specially recognized by the compiler so
11199 that no extra overhead results from the use of such a clause.
11201 If an array has an index type which is an enumeration type to which an
11202 enumeration clause has been applied, then the array is stored in a compact
11203 manner. Consider the declarations:
11205 @smallexample @c ada
11206 type r is (A, B, C);
11207 for r use (A => 1, B => 5, C => 10);
11208 type t is array (r) of Character;
11212 The array type t corresponds to a vector with exactly three elements and
11213 has a default size equal to @code{3*Character'Size}. This ensures efficient
11214 use of space, but means that accesses to elements of the array will incur
11215 the overhead of converting representation values to the corresponding
11216 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11218 @node Address Clauses
11219 @section Address Clauses
11220 @cindex Address Clause
11222 The reference manual allows a general restriction on representation clauses,
11223 as found in RM 13.1(22):
11226 An implementation need not support representation
11227 items containing nonstatic expressions, except that
11228 an implementation should support a representation item
11229 for a given entity if each nonstatic expression in the
11230 representation item is a name that statically denotes
11231 a constant declared before the entity.
11235 In practice this is applicable only to address clauses, since this is the
11236 only case in which a non-static expression is permitted by the syntax. As
11237 the AARM notes in sections 13.1 (22.a-22.h):
11240 22.a Reason: This is to avoid the following sort of thing:
11242 22.b X : Integer := F(@dots{});
11243 Y : Address := G(@dots{});
11244 for X'Address use Y;
11246 22.c In the above, we have to evaluate the
11247 initialization expression for X before we
11248 know where to put the result. This seems
11249 like an unreasonable implementation burden.
11251 22.d The above code should instead be written
11254 22.e Y : constant Address := G(@dots{});
11255 X : Integer := F(@dots{});
11256 for X'Address use Y;
11258 22.f This allows the expression ``Y'' to be safely
11259 evaluated before X is created.
11261 22.g The constant could be a formal parameter of mode in.
11263 22.h An implementation can support other nonstatic
11264 expressions if it wants to. Expressions of type
11265 Address are hardly ever static, but their value
11266 might be known at compile time anyway in many
11271 GNAT does indeed permit many additional cases of non-static expressions. In
11272 particular, if the type involved is elementary there are no restrictions
11273 (since in this case, holding a temporary copy of the initialization value,
11274 if one is present, is inexpensive). In addition, if there is no implicit or
11275 explicit initialization, then there are no restrictions. GNAT will reject
11276 only the case where all three of these conditions hold:
11281 The type of the item is non-elementary (e.g.@: a record or array).
11284 There is explicit or implicit initialization required for the object.
11285 Note that access values are always implicitly initialized, and also
11286 in GNAT, certain bit-packed arrays (those having a dynamic length or
11287 a length greater than 64) will also be implicitly initialized to zero.
11290 The address value is non-static. Here GNAT is more permissive than the
11291 RM, and allows the address value to be the address of a previously declared
11292 stand-alone variable, as long as it does not itself have an address clause.
11294 @smallexample @c ada
11295 Anchor : Some_Initialized_Type;
11296 Overlay : Some_Initialized_Type;
11297 for Overlay'Address use Anchor'Address;
11301 However, the prefix of the address clause cannot be an array component, or
11302 a component of a discriminated record.
11307 As noted above in section 22.h, address values are typically non-static. In
11308 particular the To_Address function, even if applied to a literal value, is
11309 a non-static function call. To avoid this minor annoyance, GNAT provides
11310 the implementation defined attribute 'To_Address. The following two
11311 expressions have identical values:
11315 @smallexample @c ada
11316 To_Address (16#1234_0000#)
11317 System'To_Address (16#1234_0000#);
11321 except that the second form is considered to be a static expression, and
11322 thus when used as an address clause value is always permitted.
11325 Additionally, GNAT treats as static an address clause that is an
11326 unchecked_conversion of a static integer value. This simplifies the porting
11327 of legacy code, and provides a portable equivalent to the GNAT attribute
11330 Another issue with address clauses is the interaction with alignment
11331 requirements. When an address clause is given for an object, the address
11332 value must be consistent with the alignment of the object (which is usually
11333 the same as the alignment of the type of the object). If an address clause
11334 is given that specifies an inappropriately aligned address value, then the
11335 program execution is erroneous.
11337 Since this source of erroneous behavior can have unfortunate effects, GNAT
11338 checks (at compile time if possible, generating a warning, or at execution
11339 time with a run-time check) that the alignment is appropriate. If the
11340 run-time check fails, then @code{Program_Error} is raised. This run-time
11341 check is suppressed if range checks are suppressed, or if the special GNAT
11342 check Alignment_Check is suppressed, or if
11343 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11345 Finally, GNAT does not permit overlaying of objects of controlled types or
11346 composite types containing a controlled component. In most cases, the compiler
11347 can detect an attempt at such overlays and will generate a warning at compile
11348 time and a Program_Error exception at run time.
11351 An address clause cannot be given for an exported object. More
11352 understandably the real restriction is that objects with an address
11353 clause cannot be exported. This is because such variables are not
11354 defined by the Ada program, so there is no external object to export.
11357 It is permissible to give an address clause and a pragma Import for the
11358 same object. In this case, the variable is not really defined by the
11359 Ada program, so there is no external symbol to be linked. The link name
11360 and the external name are ignored in this case. The reason that we allow this
11361 combination is that it provides a useful idiom to avoid unwanted
11362 initializations on objects with address clauses.
11364 When an address clause is given for an object that has implicit or
11365 explicit initialization, then by default initialization takes place. This
11366 means that the effect of the object declaration is to overwrite the
11367 memory at the specified address. This is almost always not what the
11368 programmer wants, so GNAT will output a warning:
11378 for Ext'Address use System'To_Address (16#1234_1234#);
11380 >>> warning: implicit initialization of "Ext" may
11381 modify overlaid storage
11382 >>> warning: use pragma Import for "Ext" to suppress
11383 initialization (RM B(24))
11389 As indicated by the warning message, the solution is to use a (dummy) pragma
11390 Import to suppress this initialization. The pragma tell the compiler that the
11391 object is declared and initialized elsewhere. The following package compiles
11392 without warnings (and the initialization is suppressed):
11394 @smallexample @c ada
11402 for Ext'Address use System'To_Address (16#1234_1234#);
11403 pragma Import (Ada, Ext);
11408 A final issue with address clauses involves their use for overlaying
11409 variables, as in the following example:
11410 @cindex Overlaying of objects
11412 @smallexample @c ada
11415 for B'Address use A'Address;
11419 or alternatively, using the form recommended by the RM:
11421 @smallexample @c ada
11423 Addr : constant Address := A'Address;
11425 for B'Address use Addr;
11429 In both of these cases, @code{A}
11430 and @code{B} become aliased to one another via the
11431 address clause. This use of address clauses to overlay
11432 variables, achieving an effect similar to unchecked
11433 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11434 the effect is implementation defined. Furthermore, the
11435 Ada RM specifically recommends that in a situation
11436 like this, @code{B} should be subject to the following
11437 implementation advice (RM 13.3(19)):
11440 19 If the Address of an object is specified, or it is imported
11441 or exported, then the implementation should not perform
11442 optimizations based on assumptions of no aliases.
11446 GNAT follows this recommendation, and goes further by also applying
11447 this recommendation to the overlaid variable (@code{A}
11448 in the above example) in this case. This means that the overlay
11449 works "as expected", in that a modification to one of the variables
11450 will affect the value of the other.
11452 @node Effect of Convention on Representation
11453 @section Effect of Convention on Representation
11454 @cindex Convention, effect on representation
11457 Normally the specification of a foreign language convention for a type or
11458 an object has no effect on the chosen representation. In particular, the
11459 representation chosen for data in GNAT generally meets the standard system
11460 conventions, and for example records are laid out in a manner that is
11461 consistent with C@. This means that specifying convention C (for example)
11464 There are four exceptions to this general rule:
11468 @item Convention Fortran and array subtypes
11469 If pragma Convention Fortran is specified for an array subtype, then in
11470 accordance with the implementation advice in section 3.6.2(11) of the
11471 Ada Reference Manual, the array will be stored in a Fortran-compatible
11472 column-major manner, instead of the normal default row-major order.
11474 @item Convention C and enumeration types
11475 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11476 to accommodate all values of the type. For example, for the enumeration
11479 @smallexample @c ada
11480 type Color is (Red, Green, Blue);
11484 8 bits is sufficient to store all values of the type, so by default, objects
11485 of type @code{Color} will be represented using 8 bits. However, normal C
11486 convention is to use 32 bits for all enum values in C, since enum values
11487 are essentially of type int. If pragma @code{Convention C} is specified for an
11488 Ada enumeration type, then the size is modified as necessary (usually to
11489 32 bits) to be consistent with the C convention for enum values.
11491 Note that this treatment applies only to types. If Convention C is given for
11492 an enumeration object, where the enumeration type is not Convention C, then
11493 Object_Size bits are allocated. For example, for a normal enumeration type,
11494 with less than 256 elements, only 8 bits will be allocated for the object.
11495 Since this may be a surprise in terms of what C expects, GNAT will issue a
11496 warning in this situation. The warning can be suppressed by giving an explicit
11497 size clause specifying the desired size.
11499 @item Convention C/Fortran and Boolean types
11500 In C, the usual convention for boolean values, that is values used for
11501 conditions, is that zero represents false, and nonzero values represent
11502 true. In Ada, the normal convention is that two specific values, typically
11503 0/1, are used to represent false/true respectively.
11505 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11506 value represents true).
11508 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11509 C or Fortran convention for a derived Boolean, as in the following example:
11511 @smallexample @c ada
11512 type C_Switch is new Boolean;
11513 pragma Convention (C, C_Switch);
11517 then the GNAT generated code will treat any nonzero value as true. For truth
11518 values generated by GNAT, the conventional value 1 will be used for True, but
11519 when one of these values is read, any nonzero value is treated as True.
11521 @item Access types on OpenVMS
11522 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11523 arrays) are 64-bits long. An exception to this rule is for the case of
11524 C-convention access types where there is no explicit size clause present (or
11525 inherited for derived types). In this case, GNAT chooses to make these
11526 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11527 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11531 @node Determining the Representations chosen by GNAT
11532 @section Determining the Representations chosen by GNAT
11533 @cindex Representation, determination of
11534 @cindex @option{-gnatR} switch
11537 Although the descriptions in this section are intended to be complete, it is
11538 often easier to simply experiment to see what GNAT accepts and what the
11539 effect is on the layout of types and objects.
11541 As required by the Ada RM, if a representation clause is not accepted, then
11542 it must be rejected as illegal by the compiler. However, when a
11543 representation clause or pragma is accepted, there can still be questions
11544 of what the compiler actually does. For example, if a partial record
11545 representation clause specifies the location of some components and not
11546 others, then where are the non-specified components placed? Or if pragma
11547 @code{Pack} is used on a record, then exactly where are the resulting
11548 fields placed? The section on pragma @code{Pack} in this chapter can be
11549 used to answer the second question, but it is often easier to just see
11550 what the compiler does.
11552 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
11553 with this option, then the compiler will output information on the actual
11554 representations chosen, in a format similar to source representation
11555 clauses. For example, if we compile the package:
11557 @smallexample @c ada
11559 type r (x : boolean) is tagged record
11561 when True => S : String (1 .. 100);
11562 when False => null;
11566 type r2 is new r (false) with record
11571 y2 at 16 range 0 .. 31;
11578 type x1 is array (1 .. 10) of x;
11579 for x1'component_size use 11;
11581 type ia is access integer;
11583 type Rb1 is array (1 .. 13) of Boolean;
11586 type Rb2 is array (1 .. 65) of Boolean;
11602 using the switch @option{-gnatR} we obtain the following output:
11605 Representation information for unit q
11606 -------------------------------------
11609 for r'Alignment use 4;
11611 x at 4 range 0 .. 7;
11612 _tag at 0 range 0 .. 31;
11613 s at 5 range 0 .. 799;
11616 for r2'Size use 160;
11617 for r2'Alignment use 4;
11619 x at 4 range 0 .. 7;
11620 _tag at 0 range 0 .. 31;
11621 _parent at 0 range 0 .. 63;
11622 y2 at 16 range 0 .. 31;
11626 for x'Alignment use 1;
11628 y at 0 range 0 .. 7;
11631 for x1'Size use 112;
11632 for x1'Alignment use 1;
11633 for x1'Component_Size use 11;
11635 for rb1'Size use 13;
11636 for rb1'Alignment use 2;
11637 for rb1'Component_Size use 1;
11639 for rb2'Size use 72;
11640 for rb2'Alignment use 1;
11641 for rb2'Component_Size use 1;
11643 for x2'Size use 224;
11644 for x2'Alignment use 4;
11646 l1 at 0 range 0 .. 0;
11647 l2 at 0 range 1 .. 64;
11648 l3 at 12 range 0 .. 31;
11649 l4 at 16 range 0 .. 0;
11650 l5 at 16 range 1 .. 13;
11651 l6 at 18 range 0 .. 71;
11656 The Size values are actually the Object_Size, i.e.@: the default size that
11657 will be allocated for objects of the type.
11658 The ?? size for type r indicates that we have a variant record, and the
11659 actual size of objects will depend on the discriminant value.
11661 The Alignment values show the actual alignment chosen by the compiler
11662 for each record or array type.
11664 The record representation clause for type r shows where all fields
11665 are placed, including the compiler generated tag field (whose location
11666 cannot be controlled by the programmer).
11668 The record representation clause for the type extension r2 shows all the
11669 fields present, including the parent field, which is a copy of the fields
11670 of the parent type of r2, i.e.@: r1.
11672 The component size and size clauses for types rb1 and rb2 show
11673 the exact effect of pragma @code{Pack} on these arrays, and the record
11674 representation clause for type x2 shows how pragma @code{Pack} affects
11677 In some cases, it may be useful to cut and paste the representation clauses
11678 generated by the compiler into the original source to fix and guarantee
11679 the actual representation to be used.
11681 @node Standard Library Routines
11682 @chapter Standard Library Routines
11685 The Ada Reference Manual contains in Annex A a full description of an
11686 extensive set of standard library routines that can be used in any Ada
11687 program, and which must be provided by all Ada compilers. They are
11688 analogous to the standard C library used by C programs.
11690 GNAT implements all of the facilities described in annex A, and for most
11691 purposes the description in the Ada Reference Manual, or appropriate Ada
11692 text book, will be sufficient for making use of these facilities.
11694 In the case of the input-output facilities,
11695 @xref{The Implementation of Standard I/O},
11696 gives details on exactly how GNAT interfaces to the
11697 file system. For the remaining packages, the Ada Reference Manual
11698 should be sufficient. The following is a list of the packages included,
11699 together with a brief description of the functionality that is provided.
11701 For completeness, references are included to other predefined library
11702 routines defined in other sections of the Ada Reference Manual (these are
11703 cross-indexed from Annex A).
11707 This is a parent package for all the standard library packages. It is
11708 usually included implicitly in your program, and itself contains no
11709 useful data or routines.
11711 @item Ada.Calendar (9.6)
11712 @code{Calendar} provides time of day access, and routines for
11713 manipulating times and durations.
11715 @item Ada.Characters (A.3.1)
11716 This is a dummy parent package that contains no useful entities
11718 @item Ada.Characters.Handling (A.3.2)
11719 This package provides some basic character handling capabilities,
11720 including classification functions for classes of characters (e.g.@: test
11721 for letters, or digits).
11723 @item Ada.Characters.Latin_1 (A.3.3)
11724 This package includes a complete set of definitions of the characters
11725 that appear in type CHARACTER@. It is useful for writing programs that
11726 will run in international environments. For example, if you want an
11727 upper case E with an acute accent in a string, it is often better to use
11728 the definition of @code{UC_E_Acute} in this package. Then your program
11729 will print in an understandable manner even if your environment does not
11730 support these extended characters.
11732 @item Ada.Command_Line (A.15)
11733 This package provides access to the command line parameters and the name
11734 of the current program (analogous to the use of @code{argc} and @code{argv}
11735 in C), and also allows the exit status for the program to be set in a
11736 system-independent manner.
11738 @item Ada.Decimal (F.2)
11739 This package provides constants describing the range of decimal numbers
11740 implemented, and also a decimal divide routine (analogous to the COBOL
11741 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11743 @item Ada.Direct_IO (A.8.4)
11744 This package provides input-output using a model of a set of records of
11745 fixed-length, containing an arbitrary definite Ada type, indexed by an
11746 integer record number.
11748 @item Ada.Dynamic_Priorities (D.5)
11749 This package allows the priorities of a task to be adjusted dynamically
11750 as the task is running.
11752 @item Ada.Exceptions (11.4.1)
11753 This package provides additional information on exceptions, and also
11754 contains facilities for treating exceptions as data objects, and raising
11755 exceptions with associated messages.
11757 @item Ada.Finalization (7.6)
11758 This package contains the declarations and subprograms to support the
11759 use of controlled types, providing for automatic initialization and
11760 finalization (analogous to the constructors and destructors of C++)
11762 @item Ada.Interrupts (C.3.2)
11763 This package provides facilities for interfacing to interrupts, which
11764 includes the set of signals or conditions that can be raised and
11765 recognized as interrupts.
11767 @item Ada.Interrupts.Names (C.3.2)
11768 This package provides the set of interrupt names (actually signal
11769 or condition names) that can be handled by GNAT@.
11771 @item Ada.IO_Exceptions (A.13)
11772 This package defines the set of exceptions that can be raised by use of
11773 the standard IO packages.
11776 This package contains some standard constants and exceptions used
11777 throughout the numerics packages. Note that the constants pi and e are
11778 defined here, and it is better to use these definitions than rolling
11781 @item Ada.Numerics.Complex_Elementary_Functions
11782 Provides the implementation of standard elementary functions (such as
11783 log and trigonometric functions) operating on complex numbers using the
11784 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11785 created by the package @code{Numerics.Complex_Types}.
11787 @item Ada.Numerics.Complex_Types
11788 This is a predefined instantiation of
11789 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11790 build the type @code{Complex} and @code{Imaginary}.
11792 @item Ada.Numerics.Discrete_Random
11793 This package provides a random number generator suitable for generating
11794 random integer values from a specified range.
11796 @item Ada.Numerics.Float_Random
11797 This package provides a random number generator suitable for generating
11798 uniformly distributed floating point values.
11800 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11801 This is a generic version of the package that provides the
11802 implementation of standard elementary functions (such as log and
11803 trigonometric functions) for an arbitrary complex type.
11805 The following predefined instantiations of this package are provided:
11809 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11811 @code{Ada.Numerics.Complex_Elementary_Functions}
11813 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
11816 @item Ada.Numerics.Generic_Complex_Types
11817 This is a generic package that allows the creation of complex types,
11818 with associated complex arithmetic operations.
11820 The following predefined instantiations of this package exist
11823 @code{Ada.Numerics.Short_Complex_Complex_Types}
11825 @code{Ada.Numerics.Complex_Complex_Types}
11827 @code{Ada.Numerics.Long_Complex_Complex_Types}
11830 @item Ada.Numerics.Generic_Elementary_Functions
11831 This is a generic package that provides the implementation of standard
11832 elementary functions (such as log an trigonometric functions) for an
11833 arbitrary float type.
11835 The following predefined instantiations of this package exist
11839 @code{Ada.Numerics.Short_Elementary_Functions}
11841 @code{Ada.Numerics.Elementary_Functions}
11843 @code{Ada.Numerics.Long_Elementary_Functions}
11846 @item Ada.Real_Time (D.8)
11847 This package provides facilities similar to those of @code{Calendar}, but
11848 operating with a finer clock suitable for real time control. Note that
11849 annex D requires that there be no backward clock jumps, and GNAT generally
11850 guarantees this behavior, but of course if the external clock on which
11851 the GNAT runtime depends is deliberately reset by some external event,
11852 then such a backward jump may occur.
11854 @item Ada.Sequential_IO (A.8.1)
11855 This package provides input-output facilities for sequential files,
11856 which can contain a sequence of values of a single type, which can be
11857 any Ada type, including indefinite (unconstrained) types.
11859 @item Ada.Storage_IO (A.9)
11860 This package provides a facility for mapping arbitrary Ada types to and
11861 from a storage buffer. It is primarily intended for the creation of new
11864 @item Ada.Streams (13.13.1)
11865 This is a generic package that provides the basic support for the
11866 concept of streams as used by the stream attributes (@code{Input},
11867 @code{Output}, @code{Read} and @code{Write}).
11869 @item Ada.Streams.Stream_IO (A.12.1)
11870 This package is a specialization of the type @code{Streams} defined in
11871 package @code{Streams} together with a set of operations providing
11872 Stream_IO capability. The Stream_IO model permits both random and
11873 sequential access to a file which can contain an arbitrary set of values
11874 of one or more Ada types.
11876 @item Ada.Strings (A.4.1)
11877 This package provides some basic constants used by the string handling
11880 @item Ada.Strings.Bounded (A.4.4)
11881 This package provides facilities for handling variable length
11882 strings. The bounded model requires a maximum length. It is thus
11883 somewhat more limited than the unbounded model, but avoids the use of
11884 dynamic allocation or finalization.
11886 @item Ada.Strings.Fixed (A.4.3)
11887 This package provides facilities for handling fixed length strings.
11889 @item Ada.Strings.Maps (A.4.2)
11890 This package provides facilities for handling character mappings and
11891 arbitrarily defined subsets of characters. For instance it is useful in
11892 defining specialized translation tables.
11894 @item Ada.Strings.Maps.Constants (A.4.6)
11895 This package provides a standard set of predefined mappings and
11896 predefined character sets. For example, the standard upper to lower case
11897 conversion table is found in this package. Note that upper to lower case
11898 conversion is non-trivial if you want to take the entire set of
11899 characters, including extended characters like E with an acute accent,
11900 into account. You should use the mappings in this package (rather than
11901 adding 32 yourself) to do case mappings.
11903 @item Ada.Strings.Unbounded (A.4.5)
11904 This package provides facilities for handling variable length
11905 strings. The unbounded model allows arbitrary length strings, but
11906 requires the use of dynamic allocation and finalization.
11908 @item Ada.Strings.Wide_Bounded (A.4.7)
11909 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11910 @itemx Ada.Strings.Wide_Maps (A.4.7)
11911 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11912 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11913 These packages provide analogous capabilities to the corresponding
11914 packages without @samp{Wide_} in the name, but operate with the types
11915 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11916 and @code{Character}.
11918 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11919 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11920 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11921 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11922 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11923 These packages provide analogous capabilities to the corresponding
11924 packages without @samp{Wide_} in the name, but operate with the types
11925 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11926 of @code{String} and @code{Character}.
11928 @item Ada.Synchronous_Task_Control (D.10)
11929 This package provides some standard facilities for controlling task
11930 communication in a synchronous manner.
11933 This package contains definitions for manipulation of the tags of tagged
11936 @item Ada.Task_Attributes
11937 This package provides the capability of associating arbitrary
11938 task-specific data with separate tasks.
11941 This package provides basic text input-output capabilities for
11942 character, string and numeric data. The subpackages of this
11943 package are listed next.
11945 @item Ada.Text_IO.Decimal_IO
11946 Provides input-output facilities for decimal fixed-point types
11948 @item Ada.Text_IO.Enumeration_IO
11949 Provides input-output facilities for enumeration types.
11951 @item Ada.Text_IO.Fixed_IO
11952 Provides input-output facilities for ordinary fixed-point types.
11954 @item Ada.Text_IO.Float_IO
11955 Provides input-output facilities for float types. The following
11956 predefined instantiations of this generic package are available:
11960 @code{Short_Float_Text_IO}
11962 @code{Float_Text_IO}
11964 @code{Long_Float_Text_IO}
11967 @item Ada.Text_IO.Integer_IO
11968 Provides input-output facilities for integer types. The following
11969 predefined instantiations of this generic package are available:
11972 @item Short_Short_Integer
11973 @code{Ada.Short_Short_Integer_Text_IO}
11974 @item Short_Integer
11975 @code{Ada.Short_Integer_Text_IO}
11977 @code{Ada.Integer_Text_IO}
11979 @code{Ada.Long_Integer_Text_IO}
11980 @item Long_Long_Integer
11981 @code{Ada.Long_Long_Integer_Text_IO}
11984 @item Ada.Text_IO.Modular_IO
11985 Provides input-output facilities for modular (unsigned) types
11987 @item Ada.Text_IO.Complex_IO (G.1.3)
11988 This package provides basic text input-output capabilities for complex
11991 @item Ada.Text_IO.Editing (F.3.3)
11992 This package contains routines for edited output, analogous to the use
11993 of pictures in COBOL@. The picture formats used by this package are a
11994 close copy of the facility in COBOL@.
11996 @item Ada.Text_IO.Text_Streams (A.12.2)
11997 This package provides a facility that allows Text_IO files to be treated
11998 as streams, so that the stream attributes can be used for writing
11999 arbitrary data, including binary data, to Text_IO files.
12001 @item Ada.Unchecked_Conversion (13.9)
12002 This generic package allows arbitrary conversion from one type to
12003 another of the same size, providing for breaking the type safety in
12004 special circumstances.
12006 If the types have the same Size (more accurately the same Value_Size),
12007 then the effect is simply to transfer the bits from the source to the
12008 target type without any modification. This usage is well defined, and
12009 for simple types whose representation is typically the same across
12010 all implementations, gives a portable method of performing such
12013 If the types do not have the same size, then the result is implementation
12014 defined, and thus may be non-portable. The following describes how GNAT
12015 handles such unchecked conversion cases.
12017 If the types are of different sizes, and are both discrete types, then
12018 the effect is of a normal type conversion without any constraint checking.
12019 In particular if the result type has a larger size, the result will be
12020 zero or sign extended. If the result type has a smaller size, the result
12021 will be truncated by ignoring high order bits.
12023 If the types are of different sizes, and are not both discrete types,
12024 then the conversion works as though pointers were created to the source
12025 and target, and the pointer value is converted. The effect is that bits
12026 are copied from successive low order storage units and bits of the source
12027 up to the length of the target type.
12029 A warning is issued if the lengths differ, since the effect in this
12030 case is implementation dependent, and the above behavior may not match
12031 that of some other compiler.
12033 A pointer to one type may be converted to a pointer to another type using
12034 unchecked conversion. The only case in which the effect is undefined is
12035 when one or both pointers are pointers to unconstrained array types. In
12036 this case, the bounds information may get incorrectly transferred, and in
12037 particular, GNAT uses double size pointers for such types, and it is
12038 meaningless to convert between such pointer types. GNAT will issue a
12039 warning if the alignment of the target designated type is more strict
12040 than the alignment of the source designated type (since the result may
12041 be unaligned in this case).
12043 A pointer other than a pointer to an unconstrained array type may be
12044 converted to and from System.Address. Such usage is common in Ada 83
12045 programs, but note that Ada.Address_To_Access_Conversions is the
12046 preferred method of performing such conversions in Ada 95 and Ada 2005.
12048 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12049 used in conjunction with pointers to unconstrained objects, since
12050 the bounds information cannot be handled correctly in this case.
12052 @item Ada.Unchecked_Deallocation (13.11.2)
12053 This generic package allows explicit freeing of storage previously
12054 allocated by use of an allocator.
12056 @item Ada.Wide_Text_IO (A.11)
12057 This package is similar to @code{Ada.Text_IO}, except that the external
12058 file supports wide character representations, and the internal types are
12059 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12060 and @code{String}. It contains generic subpackages listed next.
12062 @item Ada.Wide_Text_IO.Decimal_IO
12063 Provides input-output facilities for decimal fixed-point types
12065 @item Ada.Wide_Text_IO.Enumeration_IO
12066 Provides input-output facilities for enumeration types.
12068 @item Ada.Wide_Text_IO.Fixed_IO
12069 Provides input-output facilities for ordinary fixed-point types.
12071 @item Ada.Wide_Text_IO.Float_IO
12072 Provides input-output facilities for float types. The following
12073 predefined instantiations of this generic package are available:
12077 @code{Short_Float_Wide_Text_IO}
12079 @code{Float_Wide_Text_IO}
12081 @code{Long_Float_Wide_Text_IO}
12084 @item Ada.Wide_Text_IO.Integer_IO
12085 Provides input-output facilities for integer types. The following
12086 predefined instantiations of this generic package are available:
12089 @item Short_Short_Integer
12090 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12091 @item Short_Integer
12092 @code{Ada.Short_Integer_Wide_Text_IO}
12094 @code{Ada.Integer_Wide_Text_IO}
12096 @code{Ada.Long_Integer_Wide_Text_IO}
12097 @item Long_Long_Integer
12098 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12101 @item Ada.Wide_Text_IO.Modular_IO
12102 Provides input-output facilities for modular (unsigned) types
12104 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12105 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12106 external file supports wide character representations.
12108 @item Ada.Wide_Text_IO.Editing (F.3.4)
12109 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12110 types are @code{Wide_Character} and @code{Wide_String} instead of
12111 @code{Character} and @code{String}.
12113 @item Ada.Wide_Text_IO.Streams (A.12.3)
12114 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12115 types are @code{Wide_Character} and @code{Wide_String} instead of
12116 @code{Character} and @code{String}.
12118 @item Ada.Wide_Wide_Text_IO (A.11)
12119 This package is similar to @code{Ada.Text_IO}, except that the external
12120 file supports wide character representations, and the internal types are
12121 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12122 and @code{String}. It contains generic subpackages listed next.
12124 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12125 Provides input-output facilities for decimal fixed-point types
12127 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12128 Provides input-output facilities for enumeration types.
12130 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12131 Provides input-output facilities for ordinary fixed-point types.
12133 @item Ada.Wide_Wide_Text_IO.Float_IO
12134 Provides input-output facilities for float types. The following
12135 predefined instantiations of this generic package are available:
12139 @code{Short_Float_Wide_Wide_Text_IO}
12141 @code{Float_Wide_Wide_Text_IO}
12143 @code{Long_Float_Wide_Wide_Text_IO}
12146 @item Ada.Wide_Wide_Text_IO.Integer_IO
12147 Provides input-output facilities for integer types. The following
12148 predefined instantiations of this generic package are available:
12151 @item Short_Short_Integer
12152 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12153 @item Short_Integer
12154 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12156 @code{Ada.Integer_Wide_Wide_Text_IO}
12158 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12159 @item Long_Long_Integer
12160 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12163 @item Ada.Wide_Wide_Text_IO.Modular_IO
12164 Provides input-output facilities for modular (unsigned) types
12166 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12167 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12168 external file supports wide character representations.
12170 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12171 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12172 types are @code{Wide_Character} and @code{Wide_String} instead of
12173 @code{Character} and @code{String}.
12175 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12176 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12177 types are @code{Wide_Character} and @code{Wide_String} instead of
12178 @code{Character} and @code{String}.
12183 @node The Implementation of Standard I/O
12184 @chapter The Implementation of Standard I/O
12187 GNAT implements all the required input-output facilities described in
12188 A.6 through A.14. These sections of the Ada Reference Manual describe the
12189 required behavior of these packages from the Ada point of view, and if
12190 you are writing a portable Ada program that does not need to know the
12191 exact manner in which Ada maps to the outside world when it comes to
12192 reading or writing external files, then you do not need to read this
12193 chapter. As long as your files are all regular files (not pipes or
12194 devices), and as long as you write and read the files only from Ada, the
12195 description in the Ada Reference Manual is sufficient.
12197 However, if you want to do input-output to pipes or other devices, such
12198 as the keyboard or screen, or if the files you are dealing with are
12199 either generated by some other language, or to be read by some other
12200 language, then you need to know more about the details of how the GNAT
12201 implementation of these input-output facilities behaves.
12203 In this chapter we give a detailed description of exactly how GNAT
12204 interfaces to the file system. As always, the sources of the system are
12205 available to you for answering questions at an even more detailed level,
12206 but for most purposes the information in this chapter will suffice.
12208 Another reason that you may need to know more about how input-output is
12209 implemented arises when you have a program written in mixed languages
12210 where, for example, files are shared between the C and Ada sections of
12211 the same program. GNAT provides some additional facilities, in the form
12212 of additional child library packages, that facilitate this sharing, and
12213 these additional facilities are also described in this chapter.
12216 * Standard I/O Packages::
12222 * Wide_Wide_Text_IO::
12224 * Text Translation::
12226 * Filenames encoding::
12228 * Operations on C Streams::
12229 * Interfacing to C Streams::
12232 @node Standard I/O Packages
12233 @section Standard I/O Packages
12236 The Standard I/O packages described in Annex A for
12242 Ada.Text_IO.Complex_IO
12244 Ada.Text_IO.Text_Streams
12248 Ada.Wide_Text_IO.Complex_IO
12250 Ada.Wide_Text_IO.Text_Streams
12252 Ada.Wide_Wide_Text_IO
12254 Ada.Wide_Wide_Text_IO.Complex_IO
12256 Ada.Wide_Wide_Text_IO.Text_Streams
12266 are implemented using the C
12267 library streams facility; where
12271 All files are opened using @code{fopen}.
12273 All input/output operations use @code{fread}/@code{fwrite}.
12277 There is no internal buffering of any kind at the Ada library level. The only
12278 buffering is that provided at the system level in the implementation of the
12279 library routines that support streams. This facilitates shared use of these
12280 streams by mixed language programs. Note though that system level buffering is
12281 explicitly enabled at elaboration of the standard I/O packages and that can
12282 have an impact on mixed language programs, in particular those using I/O before
12283 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12284 the Ada elaboration routine before performing any I/O or when impractical,
12285 flush the common I/O streams and in particular Standard_Output before
12286 elaborating the Ada code.
12289 @section FORM Strings
12292 The format of a FORM string in GNAT is:
12295 "keyword=value,keyword=value,@dots{},keyword=value"
12299 where letters may be in upper or lower case, and there are no spaces
12300 between values. The order of the entries is not important. Currently
12301 the following keywords defined.
12304 TEXT_TRANSLATION=[YES|NO]
12306 WCEM=[n|h|u|s|e|8|b]
12307 ENCODING=[UTF8|8BITS]
12311 The use of these parameters is described later in this section.
12317 Direct_IO can only be instantiated for definite types. This is a
12318 restriction of the Ada language, which means that the records are fixed
12319 length (the length being determined by @code{@var{type}'Size}, rounded
12320 up to the next storage unit boundary if necessary).
12322 The records of a Direct_IO file are simply written to the file in index
12323 sequence, with the first record starting at offset zero, and subsequent
12324 records following. There is no control information of any kind. For
12325 example, if 32-bit integers are being written, each record takes
12326 4-bytes, so the record at index @var{K} starts at offset
12327 (@var{K}@minus{}1)*4.
12329 There is no limit on the size of Direct_IO files, they are expanded as
12330 necessary to accommodate whatever records are written to the file.
12332 @node Sequential_IO
12333 @section Sequential_IO
12336 Sequential_IO may be instantiated with either a definite (constrained)
12337 or indefinite (unconstrained) type.
12339 For the definite type case, the elements written to the file are simply
12340 the memory images of the data values with no control information of any
12341 kind. The resulting file should be read using the same type, no validity
12342 checking is performed on input.
12344 For the indefinite type case, the elements written consist of two
12345 parts. First is the size of the data item, written as the memory image
12346 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12347 the data value. The resulting file can only be read using the same
12348 (unconstrained) type. Normal assignment checks are performed on these
12349 read operations, and if these checks fail, @code{Data_Error} is
12350 raised. In particular, in the array case, the lengths must match, and in
12351 the variant record case, if the variable for a particular read operation
12352 is constrained, the discriminants must match.
12354 Note that it is not possible to use Sequential_IO to write variable
12355 length array items, and then read the data back into different length
12356 arrays. For example, the following will raise @code{Data_Error}:
12358 @smallexample @c ada
12359 package IO is new Sequential_IO (String);
12364 IO.Write (F, "hello!")
12365 IO.Reset (F, Mode=>In_File);
12372 On some Ada implementations, this will print @code{hell}, but the program is
12373 clearly incorrect, since there is only one element in the file, and that
12374 element is the string @code{hello!}.
12376 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12377 using Stream_IO, and this is the preferred mechanism. In particular, the
12378 above program fragment rewritten to use Stream_IO will work correctly.
12384 Text_IO files consist of a stream of characters containing the following
12385 special control characters:
12388 LF (line feed, 16#0A#) Line Mark
12389 FF (form feed, 16#0C#) Page Mark
12393 A canonical Text_IO file is defined as one in which the following
12394 conditions are met:
12398 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12402 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12403 end of a page and consequently can appear only immediately following a
12404 @code{LF} (line mark) character.
12407 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12408 (line mark, page mark). In the former case, the page mark is implicitly
12409 assumed to be present.
12413 A file written using Text_IO will be in canonical form provided that no
12414 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12415 or @code{Put_Line}. There will be no @code{FF} character at the end of
12416 the file unless an explicit @code{New_Page} operation was performed
12417 before closing the file.
12419 A canonical Text_IO file that is a regular file (i.e., not a device or a
12420 pipe) can be read using any of the routines in Text_IO@. The
12421 semantics in this case will be exactly as defined in the Ada Reference
12422 Manual, and all the routines in Text_IO are fully implemented.
12424 A text file that does not meet the requirements for a canonical Text_IO
12425 file has one of the following:
12429 The file contains @code{FF} characters not immediately following a
12430 @code{LF} character.
12433 The file contains @code{LF} or @code{FF} characters written by
12434 @code{Put} or @code{Put_Line}, which are not logically considered to be
12435 line marks or page marks.
12438 The file ends in a character other than @code{LF} or @code{FF},
12439 i.e.@: there is no explicit line mark or page mark at the end of the file.
12443 Text_IO can be used to read such non-standard text files but subprograms
12444 to do with line or page numbers do not have defined meanings. In
12445 particular, a @code{FF} character that does not follow a @code{LF}
12446 character may or may not be treated as a page mark from the point of
12447 view of page and line numbering. Every @code{LF} character is considered
12448 to end a line, and there is an implied @code{LF} character at the end of
12452 * Text_IO Stream Pointer Positioning::
12453 * Text_IO Reading and Writing Non-Regular Files::
12455 * Treating Text_IO Files as Streams::
12456 * Text_IO Extensions::
12457 * Text_IO Facilities for Unbounded Strings::
12460 @node Text_IO Stream Pointer Positioning
12461 @subsection Stream Pointer Positioning
12464 @code{Ada.Text_IO} has a definition of current position for a file that
12465 is being read. No internal buffering occurs in Text_IO, and usually the
12466 physical position in the stream used to implement the file corresponds
12467 to this logical position defined by Text_IO@. There are two exceptions:
12471 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12472 is positioned past the @code{LF} (line mark) that precedes the page
12473 mark. Text_IO maintains an internal flag so that subsequent read
12474 operations properly handle the logical position which is unchanged by
12475 the @code{End_Of_Page} call.
12478 After a call to @code{End_Of_File} that returns @code{True}, if the
12479 Text_IO file was positioned before the line mark at the end of file
12480 before the call, then the logical position is unchanged, but the stream
12481 is physically positioned right at the end of file (past the line mark,
12482 and past a possible page mark following the line mark. Again Text_IO
12483 maintains internal flags so that subsequent read operations properly
12484 handle the logical position.
12488 These discrepancies have no effect on the observable behavior of
12489 Text_IO, but if a single Ada stream is shared between a C program and
12490 Ada program, or shared (using @samp{shared=yes} in the form string)
12491 between two Ada files, then the difference may be observable in some
12494 @node Text_IO Reading and Writing Non-Regular Files
12495 @subsection Reading and Writing Non-Regular Files
12498 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
12499 can be used for reading and writing. Writing is not affected and the
12500 sequence of characters output is identical to the normal file case, but
12501 for reading, the behavior of Text_IO is modified to avoid undesirable
12502 look-ahead as follows:
12504 An input file that is not a regular file is considered to have no page
12505 marks. Any @code{Ascii.FF} characters (the character normally used for a
12506 page mark) appearing in the file are considered to be data
12507 characters. In particular:
12511 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12512 following a line mark. If a page mark appears, it will be treated as a
12516 This avoids the need to wait for an extra character to be typed or
12517 entered from the pipe to complete one of these operations.
12520 @code{End_Of_Page} always returns @code{False}
12523 @code{End_Of_File} will return @code{False} if there is a page mark at
12524 the end of the file.
12528 Output to non-regular files is the same as for regular files. Page marks
12529 may be written to non-regular files using @code{New_Page}, but as noted
12530 above they will not be treated as page marks on input if the output is
12531 piped to another Ada program.
12533 Another important discrepancy when reading non-regular files is that the end
12534 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
12535 pressing the @key{EOT} key,
12537 is signaled once (i.e.@: the test @code{End_Of_File}
12538 will yield @code{True}, or a read will
12539 raise @code{End_Error}), but then reading can resume
12540 to read data past that end of
12541 file indication, until another end of file indication is entered.
12543 @node Get_Immediate
12544 @subsection Get_Immediate
12545 @cindex Get_Immediate
12548 Get_Immediate returns the next character (including control characters)
12549 from the input file. In particular, Get_Immediate will return LF or FF
12550 characters used as line marks or page marks. Such operations leave the
12551 file positioned past the control character, and it is thus not treated
12552 as having its normal function. This means that page, line and column
12553 counts after this kind of Get_Immediate call are set as though the mark
12554 did not occur. In the case where a Get_Immediate leaves the file
12555 positioned between the line mark and page mark (which is not normally
12556 possible), it is undefined whether the FF character will be treated as a
12559 @node Treating Text_IO Files as Streams
12560 @subsection Treating Text_IO Files as Streams
12561 @cindex Stream files
12564 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12565 as a stream. Data written to a Text_IO file in this stream mode is
12566 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
12567 16#0C# (@code{FF}), the resulting file may have non-standard
12568 format. Similarly if read operations are used to read from a Text_IO
12569 file treated as a stream, then @code{LF} and @code{FF} characters may be
12570 skipped and the effect is similar to that described above for
12571 @code{Get_Immediate}.
12573 @node Text_IO Extensions
12574 @subsection Text_IO Extensions
12575 @cindex Text_IO extensions
12578 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12579 to the standard @code{Text_IO} package:
12582 @item function File_Exists (Name : String) return Boolean;
12583 Determines if a file of the given name exists.
12585 @item function Get_Line return String;
12586 Reads a string from the standard input file. The value returned is exactly
12587 the length of the line that was read.
12589 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12590 Similar, except that the parameter File specifies the file from which
12591 the string is to be read.
12595 @node Text_IO Facilities for Unbounded Strings
12596 @subsection Text_IO Facilities for Unbounded Strings
12597 @cindex Text_IO for unbounded strings
12598 @cindex Unbounded_String, Text_IO operations
12601 The package @code{Ada.Strings.Unbounded.Text_IO}
12602 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12603 subprograms useful for Text_IO operations on unbounded strings:
12607 @item function Get_Line (File : File_Type) return Unbounded_String;
12608 Reads a line from the specified file
12609 and returns the result as an unbounded string.
12611 @item procedure Put (File : File_Type; U : Unbounded_String);
12612 Writes the value of the given unbounded string to the specified file
12613 Similar to the effect of
12614 @code{Put (To_String (U))} except that an extra copy is avoided.
12616 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12617 Writes the value of the given unbounded string to the specified file,
12618 followed by a @code{New_Line}.
12619 Similar to the effect of @code{Put_Line (To_String (U))} except
12620 that an extra copy is avoided.
12624 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12625 and is optional. If the parameter is omitted, then the standard input or
12626 output file is referenced as appropriate.
12628 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12629 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12630 @code{Wide_Text_IO} functionality for unbounded wide strings.
12632 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12633 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12634 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12637 @section Wide_Text_IO
12640 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12641 both input and output files may contain special sequences that represent
12642 wide character values. The encoding scheme for a given file may be
12643 specified using a FORM parameter:
12650 as part of the FORM string (WCEM = wide character encoding method),
12651 where @var{x} is one of the following characters
12657 Upper half encoding
12669 The encoding methods match those that
12670 can be used in a source
12671 program, but there is no requirement that the encoding method used for
12672 the source program be the same as the encoding method used for files,
12673 and different files may use different encoding methods.
12675 The default encoding method for the standard files, and for opened files
12676 for which no WCEM parameter is given in the FORM string matches the
12677 wide character encoding specified for the main program (the default
12678 being brackets encoding if no coding method was specified with -gnatW).
12682 In this encoding, a wide character is represented by a five character
12690 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12691 characters (using upper case letters) of the wide character code. For
12692 example, ESC A345 is used to represent the wide character with code
12693 16#A345#. This scheme is compatible with use of the full
12694 @code{Wide_Character} set.
12696 @item Upper Half Coding
12697 The wide character with encoding 16#abcd#, where the upper bit is on
12698 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12699 16#cd#. The second byte may never be a format control character, but is
12700 not required to be in the upper half. This method can be also used for
12701 shift-JIS or EUC where the internal coding matches the external coding.
12703 @item Shift JIS Coding
12704 A wide character is represented by a two character sequence 16#ab# and
12705 16#cd#, with the restrictions described for upper half encoding as
12706 described above. The internal character code is the corresponding JIS
12707 character according to the standard algorithm for Shift-JIS
12708 conversion. Only characters defined in the JIS code set table can be
12709 used with this encoding method.
12712 A wide character is represented by a two character sequence 16#ab# and
12713 16#cd#, with both characters being in the upper half. The internal
12714 character code is the corresponding JIS character according to the EUC
12715 encoding algorithm. Only characters defined in the JIS code set table
12716 can be used with this encoding method.
12719 A wide character is represented using
12720 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12721 10646-1/Am.2. Depending on the character value, the representation
12722 is a one, two, or three byte sequence:
12725 16#0000#-16#007f#: 2#0xxxxxxx#
12726 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12727 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12731 where the @var{xxx} bits correspond to the left-padded bits of the
12732 16-bit character value. Note that all lower half ASCII characters
12733 are represented as ASCII bytes and all upper half characters and
12734 other wide characters are represented as sequences of upper-half
12735 (The full UTF-8 scheme allows for encoding 31-bit characters as
12736 6-byte sequences, but in this implementation, all UTF-8 sequences
12737 of four or more bytes length will raise a Constraint_Error, as
12738 will all invalid UTF-8 sequences.)
12740 @item Brackets Coding
12741 In this encoding, a wide character is represented by the following eight
12742 character sequence:
12749 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12750 characters (using uppercase letters) of the wide character code. For
12751 example, @code{["A345"]} is used to represent the wide character with code
12753 This scheme is compatible with use of the full Wide_Character set.
12754 On input, brackets coding can also be used for upper half characters,
12755 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12756 is only used for wide characters with a code greater than @code{16#FF#}.
12758 Note that brackets coding is not normally used in the context of
12759 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12760 a portable way of encoding source files. In the context of Wide_Text_IO
12761 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12762 any instance of the left bracket character other than to encode wide
12763 character values using the brackets encoding method. In practice it is
12764 expected that some standard wide character encoding method such
12765 as UTF-8 will be used for text input output.
12767 If brackets notation is used, then any occurrence of a left bracket
12768 in the input file which is not the start of a valid wide character
12769 sequence will cause Constraint_Error to be raised. It is possible to
12770 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12771 input will interpret this as a left bracket.
12773 However, when a left bracket is output, it will be output as a left bracket
12774 and not as ["5B"]. We make this decision because for normal use of
12775 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12776 brackets. For example, if we write:
12779 Put_Line ("Start of output [first run]");
12783 we really do not want to have the left bracket in this message clobbered so
12784 that the output reads:
12787 Start of output ["5B"]first run]
12791 In practice brackets encoding is reasonably useful for normal Put_Line use
12792 since we won't get confused between left brackets and wide character
12793 sequences in the output. But for input, or when files are written out
12794 and read back in, it really makes better sense to use one of the standard
12795 encoding methods such as UTF-8.
12800 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12801 not all wide character
12802 values can be represented. An attempt to output a character that cannot
12803 be represented using the encoding scheme for the file causes
12804 Constraint_Error to be raised. An invalid wide character sequence on
12805 input also causes Constraint_Error to be raised.
12808 * Wide_Text_IO Stream Pointer Positioning::
12809 * Wide_Text_IO Reading and Writing Non-Regular Files::
12812 @node Wide_Text_IO Stream Pointer Positioning
12813 @subsection Stream Pointer Positioning
12816 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12817 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12820 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12821 normal lower ASCII set (i.e.@: a character in the range:
12823 @smallexample @c ada
12824 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12828 then although the logical position of the file pointer is unchanged by
12829 the @code{Look_Ahead} call, the stream is physically positioned past the
12830 wide character sequence. Again this is to avoid the need for buffering
12831 or backup, and all @code{Wide_Text_IO} routines check the internal
12832 indication that this situation has occurred so that this is not visible
12833 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
12834 can be observed if the wide text file shares a stream with another file.
12836 @node Wide_Text_IO Reading and Writing Non-Regular Files
12837 @subsection Reading and Writing Non-Regular Files
12840 As in the case of Text_IO, when a non-regular file is read, it is
12841 assumed that the file contains no page marks (any form characters are
12842 treated as data characters), and @code{End_Of_Page} always returns
12843 @code{False}. Similarly, the end of file indication is not sticky, so
12844 it is possible to read beyond an end of file.
12846 @node Wide_Wide_Text_IO
12847 @section Wide_Wide_Text_IO
12850 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12851 both input and output files may contain special sequences that represent
12852 wide wide character values. The encoding scheme for a given file may be
12853 specified using a FORM parameter:
12860 as part of the FORM string (WCEM = wide character encoding method),
12861 where @var{x} is one of the following characters
12867 Upper half encoding
12879 The encoding methods match those that
12880 can be used in a source
12881 program, but there is no requirement that the encoding method used for
12882 the source program be the same as the encoding method used for files,
12883 and different files may use different encoding methods.
12885 The default encoding method for the standard files, and for opened files
12886 for which no WCEM parameter is given in the FORM string matches the
12887 wide character encoding specified for the main program (the default
12888 being brackets encoding if no coding method was specified with -gnatW).
12893 A wide character is represented using
12894 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12895 10646-1/Am.2. Depending on the character value, the representation
12896 is a one, two, three, or four byte sequence:
12899 16#000000#-16#00007f#: 2#0xxxxxxx#
12900 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12901 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12902 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12906 where the @var{xxx} bits correspond to the left-padded bits of the
12907 21-bit character value. Note that all lower half ASCII characters
12908 are represented as ASCII bytes and all upper half characters and
12909 other wide characters are represented as sequences of upper-half
12912 @item Brackets Coding
12913 In this encoding, a wide wide character is represented by the following eight
12914 character sequence if is in wide character range
12920 and by the following ten character sequence if not
12923 [ " a b c d e f " ]
12927 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12928 are the four or six hexadecimal
12929 characters (using uppercase letters) of the wide wide character code. For
12930 example, @code{["01A345"]} is used to represent the wide wide character
12931 with code @code{16#01A345#}.
12933 This scheme is compatible with use of the full Wide_Wide_Character set.
12934 On input, brackets coding can also be used for upper half characters,
12935 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12936 is only used for wide characters with a code greater than @code{16#FF#}.
12941 If is also possible to use the other Wide_Character encoding methods,
12942 such as Shift-JIS, but the other schemes cannot support the full range
12943 of wide wide characters.
12944 An attempt to output a character that cannot
12945 be represented using the encoding scheme for the file causes
12946 Constraint_Error to be raised. An invalid wide character sequence on
12947 input also causes Constraint_Error to be raised.
12950 * Wide_Wide_Text_IO Stream Pointer Positioning::
12951 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12954 @node Wide_Wide_Text_IO Stream Pointer Positioning
12955 @subsection Stream Pointer Positioning
12958 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12959 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12962 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12963 normal lower ASCII set (i.e.@: a character in the range:
12965 @smallexample @c ada
12966 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12970 then although the logical position of the file pointer is unchanged by
12971 the @code{Look_Ahead} call, the stream is physically positioned past the
12972 wide character sequence. Again this is to avoid the need for buffering
12973 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
12974 indication that this situation has occurred so that this is not visible
12975 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
12976 can be observed if the wide text file shares a stream with another file.
12978 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
12979 @subsection Reading and Writing Non-Regular Files
12982 As in the case of Text_IO, when a non-regular file is read, it is
12983 assumed that the file contains no page marks (any form characters are
12984 treated as data characters), and @code{End_Of_Page} always returns
12985 @code{False}. Similarly, the end of file indication is not sticky, so
12986 it is possible to read beyond an end of file.
12992 A stream file is a sequence of bytes, where individual elements are
12993 written to the file as described in the Ada Reference Manual. The type
12994 @code{Stream_Element} is simply a byte. There are two ways to read or
12995 write a stream file.
12999 The operations @code{Read} and @code{Write} directly read or write a
13000 sequence of stream elements with no control information.
13003 The stream attributes applied to a stream file transfer data in the
13004 manner described for stream attributes.
13007 @node Text Translation
13008 @section Text Translation
13011 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13012 passed to Text_IO.Create and Text_IO.Open:
13013 @samp{Text_Translation=@var{Yes}} is the default, which means to
13014 translate LF to/from CR/LF on Windows systems.
13015 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13016 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13017 may be used to create Unix-style files on
13018 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13022 @section Shared Files
13025 Section A.14 of the Ada Reference Manual allows implementations to
13026 provide a wide variety of behavior if an attempt is made to access the
13027 same external file with two or more internal files.
13029 To provide a full range of functionality, while at the same time
13030 minimizing the problems of portability caused by this implementation
13031 dependence, GNAT handles file sharing as follows:
13035 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13036 to open two or more files with the same full name is considered an error
13037 and is not supported. The exception @code{Use_Error} will be
13038 raised. Note that a file that is not explicitly closed by the program
13039 remains open until the program terminates.
13042 If the form parameter @samp{shared=no} appears in the form string, the
13043 file can be opened or created with its own separate stream identifier,
13044 regardless of whether other files sharing the same external file are
13045 opened. The exact effect depends on how the C stream routines handle
13046 multiple accesses to the same external files using separate streams.
13049 If the form parameter @samp{shared=yes} appears in the form string for
13050 each of two or more files opened using the same full name, the same
13051 stream is shared between these files, and the semantics are as described
13052 in Ada Reference Manual, Section A.14.
13056 When a program that opens multiple files with the same name is ported
13057 from another Ada compiler to GNAT, the effect will be that
13058 @code{Use_Error} is raised.
13060 The documentation of the original compiler and the documentation of the
13061 program should then be examined to determine if file sharing was
13062 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13063 and @code{Create} calls as required.
13065 When a program is ported from GNAT to some other Ada compiler, no
13066 special attention is required unless the @samp{shared=@var{xxx}} form
13067 parameter is used in the program. In this case, you must examine the
13068 documentation of the new compiler to see if it supports the required
13069 file sharing semantics, and form strings modified appropriately. Of
13070 course it may be the case that the program cannot be ported if the
13071 target compiler does not support the required functionality. The best
13072 approach in writing portable code is to avoid file sharing (and hence
13073 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13076 One common use of file sharing in Ada 83 is the use of instantiations of
13077 Sequential_IO on the same file with different types, to achieve
13078 heterogeneous input-output. Although this approach will work in GNAT if
13079 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13080 for this purpose (using the stream attributes)
13082 @node Filenames encoding
13083 @section Filenames encoding
13086 An encoding form parameter can be used to specify the filename
13087 encoding @samp{encoding=@var{xxx}}.
13091 If the form parameter @samp{encoding=utf8} appears in the form string, the
13092 filename must be encoded in UTF-8.
13095 If the form parameter @samp{encoding=8bits} appears in the form
13096 string, the filename must be a standard 8bits string.
13099 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13100 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13101 variable. And if not set @samp{utf8} is assumed.
13105 The current system Windows ANSI code page.
13110 This encoding form parameter is only supported on the Windows
13111 platform. On the other Operating Systems the run-time is supporting
13115 @section Open Modes
13118 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13119 using the mode shown in the following table:
13122 @center @code{Open} and @code{Create} Call Modes
13124 @b{OPEN } @b{CREATE}
13125 Append_File "r+" "w+"
13127 Out_File (Direct_IO) "r+" "w"
13128 Out_File (all other cases) "w" "w"
13129 Inout_File "r+" "w+"
13133 If text file translation is required, then either @samp{b} or @samp{t}
13134 is added to the mode, depending on the setting of Text. Text file
13135 translation refers to the mapping of CR/LF sequences in an external file
13136 to LF characters internally. This mapping only occurs in DOS and
13137 DOS-like systems, and is not relevant to other systems.
13139 A special case occurs with Stream_IO@. As shown in the above table, the
13140 file is initially opened in @samp{r} or @samp{w} mode for the
13141 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
13142 subsequently requires switching from reading to writing or vice-versa,
13143 then the file is reopened in @samp{r+} mode to permit the required operation.
13145 @node Operations on C Streams
13146 @section Operations on C Streams
13147 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13148 access to the C library functions for operations on C streams:
13150 @smallexample @c adanocomment
13151 package Interfaces.C_Streams is
13152 -- Note: the reason we do not use the types that are in
13153 -- Interfaces.C is that we want to avoid dragging in the
13154 -- code in this unit if possible.
13155 subtype chars is System.Address;
13156 -- Pointer to null-terminated array of characters
13157 subtype FILEs is System.Address;
13158 -- Corresponds to the C type FILE*
13159 subtype voids is System.Address;
13160 -- Corresponds to the C type void*
13161 subtype int is Integer;
13162 subtype long is Long_Integer;
13163 -- Note: the above types are subtypes deliberately, and it
13164 -- is part of this spec that the above correspondences are
13165 -- guaranteed. This means that it is legitimate to, for
13166 -- example, use Integer instead of int. We provide these
13167 -- synonyms for clarity, but in some cases it may be
13168 -- convenient to use the underlying types (for example to
13169 -- avoid an unnecessary dependency of a spec on the spec
13171 type size_t is mod 2 ** Standard'Address_Size;
13172 NULL_Stream : constant FILEs;
13173 -- Value returned (NULL in C) to indicate an
13174 -- fdopen/fopen/tmpfile error
13175 ----------------------------------
13176 -- Constants Defined in stdio.h --
13177 ----------------------------------
13178 EOF : constant int;
13179 -- Used by a number of routines to indicate error or
13181 IOFBF : constant int;
13182 IOLBF : constant int;
13183 IONBF : constant int;
13184 -- Used to indicate buffering mode for setvbuf call
13185 SEEK_CUR : constant int;
13186 SEEK_END : constant int;
13187 SEEK_SET : constant int;
13188 -- Used to indicate origin for fseek call
13189 function stdin return FILEs;
13190 function stdout return FILEs;
13191 function stderr return FILEs;
13192 -- Streams associated with standard files
13193 --------------------------
13194 -- Standard C functions --
13195 --------------------------
13196 -- The functions selected below are ones that are
13197 -- available in DOS, OS/2, UNIX and Xenix (but not
13198 -- necessarily in ANSI C). These are very thin interfaces
13199 -- which copy exactly the C headers. For more
13200 -- documentation on these functions, see the Microsoft C
13201 -- "Run-Time Library Reference" (Microsoft Press, 1990,
13202 -- ISBN 1-55615-225-6), which includes useful information
13203 -- on system compatibility.
13204 procedure clearerr (stream : FILEs);
13205 function fclose (stream : FILEs) return int;
13206 function fdopen (handle : int; mode : chars) return FILEs;
13207 function feof (stream : FILEs) return int;
13208 function ferror (stream : FILEs) return int;
13209 function fflush (stream : FILEs) return int;
13210 function fgetc (stream : FILEs) return int;
13211 function fgets (strng : chars; n : int; stream : FILEs)
13213 function fileno (stream : FILEs) return int;
13214 function fopen (filename : chars; Mode : chars)
13216 -- Note: to maintain target independence, use
13217 -- text_translation_required, a boolean variable defined in
13218 -- a-sysdep.c to deal with the target dependent text
13219 -- translation requirement. If this variable is set,
13220 -- then b/t should be appended to the standard mode
13221 -- argument to set the text translation mode off or on
13223 function fputc (C : int; stream : FILEs) return int;
13224 function fputs (Strng : chars; Stream : FILEs) return int;
13241 function ftell (stream : FILEs) return long;
13248 function isatty (handle : int) return int;
13249 procedure mktemp (template : chars);
13250 -- The return value (which is just a pointer to template)
13252 procedure rewind (stream : FILEs);
13253 function rmtmp return int;
13261 function tmpfile return FILEs;
13262 function ungetc (c : int; stream : FILEs) return int;
13263 function unlink (filename : chars) return int;
13264 ---------------------
13265 -- Extra functions --
13266 ---------------------
13267 -- These functions supply slightly thicker bindings than
13268 -- those above. They are derived from functions in the
13269 -- C Run-Time Library, but may do a bit more work than
13270 -- just directly calling one of the Library functions.
13271 function is_regular_file (handle : int) return int;
13272 -- Tests if given handle is for a regular file (result 1)
13273 -- or for a non-regular file (pipe or device, result 0).
13274 ---------------------------------
13275 -- Control of Text/Binary Mode --
13276 ---------------------------------
13277 -- If text_translation_required is true, then the following
13278 -- functions may be used to dynamically switch a file from
13279 -- binary to text mode or vice versa. These functions have
13280 -- no effect if text_translation_required is false (i.e.@: in
13281 -- normal UNIX mode). Use fileno to get a stream handle.
13282 procedure set_binary_mode (handle : int);
13283 procedure set_text_mode (handle : int);
13284 ----------------------------
13285 -- Full Path Name support --
13286 ----------------------------
13287 procedure full_name (nam : chars; buffer : chars);
13288 -- Given a NUL terminated string representing a file
13289 -- name, returns in buffer a NUL terminated string
13290 -- representing the full path name for the file name.
13291 -- On systems where it is relevant the drive is also
13292 -- part of the full path name. It is the responsibility
13293 -- of the caller to pass an actual parameter for buffer
13294 -- that is big enough for any full path name. Use
13295 -- max_path_len given below as the size of buffer.
13296 max_path_len : integer;
13297 -- Maximum length of an allowable full path name on the
13298 -- system, including a terminating NUL character.
13299 end Interfaces.C_Streams;
13302 @node Interfacing to C Streams
13303 @section Interfacing to C Streams
13306 The packages in this section permit interfacing Ada files to C Stream
13309 @smallexample @c ada
13310 with Interfaces.C_Streams;
13311 package Ada.Sequential_IO.C_Streams is
13312 function C_Stream (F : File_Type)
13313 return Interfaces.C_Streams.FILEs;
13315 (File : in out File_Type;
13316 Mode : in File_Mode;
13317 C_Stream : in Interfaces.C_Streams.FILEs;
13318 Form : in String := "");
13319 end Ada.Sequential_IO.C_Streams;
13321 with Interfaces.C_Streams;
13322 package Ada.Direct_IO.C_Streams is
13323 function C_Stream (F : File_Type)
13324 return Interfaces.C_Streams.FILEs;
13326 (File : in out File_Type;
13327 Mode : in File_Mode;
13328 C_Stream : in Interfaces.C_Streams.FILEs;
13329 Form : in String := "");
13330 end Ada.Direct_IO.C_Streams;
13332 with Interfaces.C_Streams;
13333 package Ada.Text_IO.C_Streams is
13334 function C_Stream (F : File_Type)
13335 return Interfaces.C_Streams.FILEs;
13337 (File : in out File_Type;
13338 Mode : in File_Mode;
13339 C_Stream : in Interfaces.C_Streams.FILEs;
13340 Form : in String := "");
13341 end Ada.Text_IO.C_Streams;
13343 with Interfaces.C_Streams;
13344 package Ada.Wide_Text_IO.C_Streams is
13345 function C_Stream (F : File_Type)
13346 return Interfaces.C_Streams.FILEs;
13348 (File : in out File_Type;
13349 Mode : in File_Mode;
13350 C_Stream : in Interfaces.C_Streams.FILEs;
13351 Form : in String := "");
13352 end Ada.Wide_Text_IO.C_Streams;
13354 with Interfaces.C_Streams;
13355 package Ada.Wide_Wide_Text_IO.C_Streams is
13356 function C_Stream (F : File_Type)
13357 return Interfaces.C_Streams.FILEs;
13359 (File : in out File_Type;
13360 Mode : in File_Mode;
13361 C_Stream : in Interfaces.C_Streams.FILEs;
13362 Form : in String := "");
13363 end Ada.Wide_Wide_Text_IO.C_Streams;
13365 with Interfaces.C_Streams;
13366 package Ada.Stream_IO.C_Streams is
13367 function C_Stream (F : File_Type)
13368 return Interfaces.C_Streams.FILEs;
13370 (File : in out File_Type;
13371 Mode : in File_Mode;
13372 C_Stream : in Interfaces.C_Streams.FILEs;
13373 Form : in String := "");
13374 end Ada.Stream_IO.C_Streams;
13378 In each of these six packages, the @code{C_Stream} function obtains the
13379 @code{FILE} pointer from a currently opened Ada file. It is then
13380 possible to use the @code{Interfaces.C_Streams} package to operate on
13381 this stream, or the stream can be passed to a C program which can
13382 operate on it directly. Of course the program is responsible for
13383 ensuring that only appropriate sequences of operations are executed.
13385 One particular use of relevance to an Ada program is that the
13386 @code{setvbuf} function can be used to control the buffering of the
13387 stream used by an Ada file. In the absence of such a call the standard
13388 default buffering is used.
13390 The @code{Open} procedures in these packages open a file giving an
13391 existing C Stream instead of a file name. Typically this stream is
13392 imported from a C program, allowing an Ada file to operate on an
13395 @node The GNAT Library
13396 @chapter The GNAT Library
13399 The GNAT library contains a number of general and special purpose packages.
13400 It represents functionality that the GNAT developers have found useful, and
13401 which is made available to GNAT users. The packages described here are fully
13402 supported, and upwards compatibility will be maintained in future releases,
13403 so you can use these facilities with the confidence that the same functionality
13404 will be available in future releases.
13406 The chapter here simply gives a brief summary of the facilities available.
13407 The full documentation is found in the spec file for the package. The full
13408 sources of these library packages, including both spec and body, are provided
13409 with all GNAT releases. For example, to find out the full specifications of
13410 the SPITBOL pattern matching capability, including a full tutorial and
13411 extensive examples, look in the @file{g-spipat.ads} file in the library.
13413 For each entry here, the package name (as it would appear in a @code{with}
13414 clause) is given, followed by the name of the corresponding spec file in
13415 parentheses. The packages are children in four hierarchies, @code{Ada},
13416 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13417 GNAT-specific hierarchy.
13419 Note that an application program should only use packages in one of these
13420 four hierarchies if the package is defined in the Ada Reference Manual,
13421 or is listed in this section of the GNAT Programmers Reference Manual.
13422 All other units should be considered internal implementation units and
13423 should not be directly @code{with}'ed by application code. The use of
13424 a @code{with} statement that references one of these internal implementation
13425 units makes an application potentially dependent on changes in versions
13426 of GNAT, and will generate a warning message.
13429 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13430 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13431 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13432 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13433 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13434 * Ada.Command_Line.Environment (a-colien.ads)::
13435 * Ada.Command_Line.Remove (a-colire.ads)::
13436 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13437 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13438 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13439 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13440 * Ada.Exceptions.Traceback (a-exctra.ads)::
13441 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13442 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13443 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13444 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13445 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13446 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13447 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13448 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13449 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13450 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13451 * GNAT.Altivec (g-altive.ads)::
13452 * GNAT.Altivec.Conversions (g-altcon.ads)::
13453 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13454 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13455 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13456 * GNAT.Array_Split (g-arrspl.ads)::
13457 * GNAT.AWK (g-awk.ads)::
13458 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13459 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13460 * GNAT.Bubble_Sort (g-bubsor.ads)::
13461 * GNAT.Bubble_Sort_A (g-busora.ads)::
13462 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13463 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13464 * GNAT.Byte_Swapping (g-bytswa.ads)::
13465 * GNAT.Calendar (g-calend.ads)::
13466 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13467 * GNAT.Case_Util (g-casuti.ads)::
13468 * GNAT.CGI (g-cgi.ads)::
13469 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13470 * GNAT.CGI.Debug (g-cgideb.ads)::
13471 * GNAT.Command_Line (g-comlin.ads)::
13472 * GNAT.Compiler_Version (g-comver.ads)::
13473 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13474 * GNAT.CRC32 (g-crc32.ads)::
13475 * GNAT.Current_Exception (g-curexc.ads)::
13476 * GNAT.Debug_Pools (g-debpoo.ads)::
13477 * GNAT.Debug_Utilities (g-debuti.ads)::
13478 * GNAT.Decode_String (g-decstr.ads)::
13479 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13480 * GNAT.Directory_Operations (g-dirope.ads)::
13481 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13482 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13483 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13484 * GNAT.Encode_String (g-encstr.ads)::
13485 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13486 * GNAT.Exception_Actions (g-excact.ads)::
13487 * GNAT.Exception_Traces (g-exctra.ads)::
13488 * GNAT.Exceptions (g-except.ads)::
13489 * GNAT.Expect (g-expect.ads)::
13490 * GNAT.Float_Control (g-flocon.ads)::
13491 * GNAT.Heap_Sort (g-heasor.ads)::
13492 * GNAT.Heap_Sort_A (g-hesora.ads)::
13493 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13494 * GNAT.HTable (g-htable.ads)::
13495 * GNAT.IO (g-io.ads)::
13496 * GNAT.IO_Aux (g-io_aux.ads)::
13497 * GNAT.Lock_Files (g-locfil.ads)::
13498 * GNAT.MD5 (g-md5.ads)::
13499 * GNAT.Memory_Dump (g-memdum.ads)::
13500 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13501 * GNAT.OS_Lib (g-os_lib.ads)::
13502 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13503 * GNAT.Random_Numbers (g-rannum.ads)::
13504 * GNAT.Regexp (g-regexp.ads)::
13505 * GNAT.Registry (g-regist.ads)::
13506 * GNAT.Regpat (g-regpat.ads)::
13507 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13508 * GNAT.Semaphores (g-semaph.ads)::
13509 * GNAT.Serial_Communications (g-sercom.ads)::
13510 * GNAT.SHA1 (g-sha1.ads)::
13511 * GNAT.Signals (g-signal.ads)::
13512 * GNAT.Sockets (g-socket.ads)::
13513 * GNAT.Source_Info (g-souinf.ads)::
13514 * GNAT.Spelling_Checker (g-speche.ads)::
13515 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13516 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13517 * GNAT.Spitbol (g-spitbo.ads)::
13518 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13519 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13520 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13521 * GNAT.Strings (g-string.ads)::
13522 * GNAT.String_Split (g-strspl.ads)::
13523 * GNAT.Table (g-table.ads)::
13524 * GNAT.Task_Lock (g-tasloc.ads)::
13525 * GNAT.Threads (g-thread.ads)::
13526 * GNAT.Time_Stamp (g-timsta.ads)::
13527 * GNAT.Traceback (g-traceb.ads)::
13528 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13529 * GNAT.UTF_32 (g-utf_32.ads)::
13530 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13531 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13532 * GNAT.Wide_String_Split (g-wistsp.ads)::
13533 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13534 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13535 * Interfaces.C.Extensions (i-cexten.ads)::
13536 * Interfaces.C.Streams (i-cstrea.ads)::
13537 * Interfaces.CPP (i-cpp.ads)::
13538 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13539 * Interfaces.VxWorks (i-vxwork.ads)::
13540 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13541 * System.Address_Image (s-addima.ads)::
13542 * System.Assertions (s-assert.ads)::
13543 * System.Memory (s-memory.ads)::
13544 * System.Partition_Interface (s-parint.ads)::
13545 * System.Pool_Global (s-pooglo.ads)::
13546 * System.Pool_Local (s-pooloc.ads)::
13547 * System.Restrictions (s-restri.ads)::
13548 * System.Rident (s-rident.ads)::
13549 * System.Task_Info (s-tasinf.ads)::
13550 * System.Wch_Cnv (s-wchcnv.ads)::
13551 * System.Wch_Con (s-wchcon.ads)::
13554 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13555 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13556 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13557 @cindex Latin_9 constants for Character
13560 This child of @code{Ada.Characters}
13561 provides a set of definitions corresponding to those in the
13562 RM-defined package @code{Ada.Characters.Latin_1} but with the
13563 few modifications required for @code{Latin-9}
13564 The provision of such a package
13565 is specifically authorized by the Ada Reference Manual
13568 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13569 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13570 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13571 @cindex Latin_1 constants for Wide_Character
13574 This child of @code{Ada.Characters}
13575 provides a set of definitions corresponding to those in the
13576 RM-defined package @code{Ada.Characters.Latin_1} but with the
13577 types of the constants being @code{Wide_Character}
13578 instead of @code{Character}. The provision of such a package
13579 is specifically authorized by the Ada Reference Manual
13582 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13583 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13584 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13585 @cindex Latin_9 constants for Wide_Character
13588 This child of @code{Ada.Characters}
13589 provides a set of definitions corresponding to those in the
13590 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13591 types of the constants being @code{Wide_Character}
13592 instead of @code{Character}. The provision of such a package
13593 is specifically authorized by the Ada Reference Manual
13596 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13597 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13598 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13599 @cindex Latin_1 constants for Wide_Wide_Character
13602 This child of @code{Ada.Characters}
13603 provides a set of definitions corresponding to those in the
13604 RM-defined package @code{Ada.Characters.Latin_1} but with the
13605 types of the constants being @code{Wide_Wide_Character}
13606 instead of @code{Character}. The provision of such a package
13607 is specifically authorized by the Ada Reference Manual
13610 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13611 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13612 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13613 @cindex Latin_9 constants for Wide_Wide_Character
13616 This child of @code{Ada.Characters}
13617 provides a set of definitions corresponding to those in the
13618 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13619 types of the constants being @code{Wide_Wide_Character}
13620 instead of @code{Character}. The provision of such a package
13621 is specifically authorized by the Ada Reference Manual
13624 @node Ada.Command_Line.Environment (a-colien.ads)
13625 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13626 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13627 @cindex Environment entries
13630 This child of @code{Ada.Command_Line}
13631 provides a mechanism for obtaining environment values on systems
13632 where this concept makes sense.
13634 @node Ada.Command_Line.Remove (a-colire.ads)
13635 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13636 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13637 @cindex Removing command line arguments
13638 @cindex Command line, argument removal
13641 This child of @code{Ada.Command_Line}
13642 provides a mechanism for logically removing
13643 arguments from the argument list. Once removed, an argument is not visible
13644 to further calls on the subprograms in @code{Ada.Command_Line} will not
13645 see the removed argument.
13647 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13648 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13649 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13650 @cindex Response file for command line
13651 @cindex Command line, response file
13652 @cindex Command line, handling long command lines
13655 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13656 getting command line arguments from a text file, called a "response file".
13657 Using a response file allow passing a set of arguments to an executable longer
13658 than the maximum allowed by the system on the command line.
13660 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13661 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13662 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13663 @cindex C Streams, Interfacing with Direct_IO
13666 This package provides subprograms that allow interfacing between
13667 C streams and @code{Direct_IO}. The stream identifier can be
13668 extracted from a file opened on the Ada side, and an Ada file
13669 can be constructed from a stream opened on the C side.
13671 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13672 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13673 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13674 @cindex Null_Occurrence, testing for
13677 This child subprogram provides a way of testing for the null
13678 exception occurrence (@code{Null_Occurrence}) without raising
13681 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13682 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13683 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13684 @cindex Null_Occurrence, testing for
13687 This child subprogram is used for handling otherwise unhandled
13688 exceptions (hence the name last chance), and perform clean ups before
13689 terminating the program. Note that this subprogram never returns.
13691 @node Ada.Exceptions.Traceback (a-exctra.ads)
13692 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13693 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13694 @cindex Traceback for Exception Occurrence
13697 This child package provides the subprogram (@code{Tracebacks}) to
13698 give a traceback array of addresses based on an exception
13701 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13702 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13703 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13704 @cindex C Streams, Interfacing with Sequential_IO
13707 This package provides subprograms that allow interfacing between
13708 C streams and @code{Sequential_IO}. The stream identifier can be
13709 extracted from a file opened on the Ada side, and an Ada file
13710 can be constructed from a stream opened on the C side.
13712 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13713 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13714 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13715 @cindex C Streams, Interfacing with Stream_IO
13718 This package provides subprograms that allow interfacing between
13719 C streams and @code{Stream_IO}. The stream identifier can be
13720 extracted from a file opened on the Ada side, and an Ada file
13721 can be constructed from a stream opened on the C side.
13723 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13724 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13725 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13726 @cindex @code{Unbounded_String}, IO support
13727 @cindex @code{Text_IO}, extensions for unbounded strings
13730 This package provides subprograms for Text_IO for unbounded
13731 strings, avoiding the necessity for an intermediate operation
13732 with ordinary strings.
13734 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13735 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13736 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13737 @cindex @code{Unbounded_Wide_String}, IO support
13738 @cindex @code{Text_IO}, extensions for unbounded wide strings
13741 This package provides subprograms for Text_IO for unbounded
13742 wide strings, avoiding the necessity for an intermediate operation
13743 with ordinary wide strings.
13745 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13746 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13747 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13748 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13749 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13752 This package provides subprograms for Text_IO for unbounded
13753 wide wide strings, avoiding the necessity for an intermediate operation
13754 with ordinary wide wide strings.
13756 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13757 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13758 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13759 @cindex C Streams, Interfacing with @code{Text_IO}
13762 This package provides subprograms that allow interfacing between
13763 C streams and @code{Text_IO}. The stream identifier can be
13764 extracted from a file opened on the Ada side, and an Ada file
13765 can be constructed from a stream opened on the C side.
13767 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
13768 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13769 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13770 @cindex Unicode categorization, Wide_Character
13773 This package provides subprograms that allow categorization of
13774 Wide_Character values according to Unicode categories.
13776 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13777 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13778 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13779 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13782 This package provides subprograms that allow interfacing between
13783 C streams and @code{Wide_Text_IO}. The stream identifier can be
13784 extracted from a file opened on the Ada side, and an Ada file
13785 can be constructed from a stream opened on the C side.
13787 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13788 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13789 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13790 @cindex Unicode categorization, Wide_Wide_Character
13793 This package provides subprograms that allow categorization of
13794 Wide_Wide_Character values according to Unicode categories.
13796 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13797 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13798 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13799 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13802 This package provides subprograms that allow interfacing between
13803 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
13804 extracted from a file opened on the Ada side, and an Ada file
13805 can be constructed from a stream opened on the C side.
13807 @node GNAT.Altivec (g-altive.ads)
13808 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13809 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13813 This is the root package of the GNAT AltiVec binding. It provides
13814 definitions of constants and types common to all the versions of the
13817 @node GNAT.Altivec.Conversions (g-altcon.ads)
13818 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13819 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13823 This package provides the Vector/View conversion routines.
13825 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13826 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13827 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13831 This package exposes the Ada interface to the AltiVec operations on
13832 vector objects. A soft emulation is included by default in the GNAT
13833 library. The hard binding is provided as a separate package. This unit
13834 is common to both bindings.
13836 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13837 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13838 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13842 This package exposes the various vector types part of the Ada binding
13843 to AltiVec facilities.
13845 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13846 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13847 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13851 This package provides public 'View' data types from/to which private
13852 vector representations can be converted via
13853 GNAT.Altivec.Conversions. This allows convenient access to individual
13854 vector elements and provides a simple way to initialize vector
13857 @node GNAT.Array_Split (g-arrspl.ads)
13858 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13859 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13860 @cindex Array splitter
13863 Useful array-manipulation routines: given a set of separators, split
13864 an array wherever the separators appear, and provide direct access
13865 to the resulting slices.
13867 @node GNAT.AWK (g-awk.ads)
13868 @section @code{GNAT.AWK} (@file{g-awk.ads})
13869 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13874 Provides AWK-like parsing functions, with an easy interface for parsing one
13875 or more files containing formatted data. The file is viewed as a database
13876 where each record is a line and a field is a data element in this line.
13878 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13879 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13880 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13882 @cindex Bounded Buffers
13885 Provides a concurrent generic bounded buffer abstraction. Instances are
13886 useful directly or as parts of the implementations of other abstractions,
13889 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13890 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13891 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13896 Provides a thread-safe asynchronous intertask mailbox communication facility.
13898 @node GNAT.Bubble_Sort (g-bubsor.ads)
13899 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13900 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13902 @cindex Bubble sort
13905 Provides a general implementation of bubble sort usable for sorting arbitrary
13906 data items. Exchange and comparison procedures are provided by passing
13907 access-to-procedure values.
13909 @node GNAT.Bubble_Sort_A (g-busora.ads)
13910 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13911 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13913 @cindex Bubble sort
13916 Provides a general implementation of bubble sort usable for sorting arbitrary
13917 data items. Move and comparison procedures are provided by passing
13918 access-to-procedure values. This is an older version, retained for
13919 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13921 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13922 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13923 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13925 @cindex Bubble sort
13928 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13929 are provided as generic parameters, this improves efficiency, especially
13930 if the procedures can be inlined, at the expense of duplicating code for
13931 multiple instantiations.
13933 @node GNAT.Byte_Order_Mark (g-byorma.ads)
13934 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13935 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13936 @cindex UTF-8 representation
13937 @cindex Wide characte representations
13940 Provides a routine which given a string, reads the start of the string to
13941 see whether it is one of the standard byte order marks (BOM's) which signal
13942 the encoding of the string. The routine includes detection of special XML
13943 sequences for various UCS input formats.
13945 @node GNAT.Byte_Swapping (g-bytswa.ads)
13946 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13947 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13948 @cindex Byte swapping
13952 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13953 Machine-specific implementations are available in some cases.
13955 @node GNAT.Calendar (g-calend.ads)
13956 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13957 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13958 @cindex @code{Calendar}
13961 Extends the facilities provided by @code{Ada.Calendar} to include handling
13962 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13963 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
13964 C @code{timeval} format.
13966 @node GNAT.Calendar.Time_IO (g-catiio.ads)
13967 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13968 @cindex @code{Calendar}
13970 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13972 @node GNAT.CRC32 (g-crc32.ads)
13973 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
13974 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
13976 @cindex Cyclic Redundancy Check
13979 This package implements the CRC-32 algorithm. For a full description
13980 of this algorithm see
13981 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
13982 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
13983 Aug.@: 1988. Sarwate, D.V@.
13985 @node GNAT.Case_Util (g-casuti.ads)
13986 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
13987 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
13988 @cindex Casing utilities
13989 @cindex Character handling (@code{GNAT.Case_Util})
13992 A set of simple routines for handling upper and lower casing of strings
13993 without the overhead of the full casing tables
13994 in @code{Ada.Characters.Handling}.
13996 @node GNAT.CGI (g-cgi.ads)
13997 @section @code{GNAT.CGI} (@file{g-cgi.ads})
13998 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
13999 @cindex CGI (Common Gateway Interface)
14002 This is a package for interfacing a GNAT program with a Web server via the
14003 Common Gateway Interface (CGI)@. Basically this package parses the CGI
14004 parameters, which are a set of key/value pairs sent by the Web server. It
14005 builds a table whose index is the key and provides some services to deal
14008 @node GNAT.CGI.Cookie (g-cgicoo.ads)
14009 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14010 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14011 @cindex CGI (Common Gateway Interface) cookie support
14012 @cindex Cookie support in CGI
14015 This is a package to interface a GNAT program with a Web server via the
14016 Common Gateway Interface (CGI). It exports services to deal with Web
14017 cookies (piece of information kept in the Web client software).
14019 @node GNAT.CGI.Debug (g-cgideb.ads)
14020 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14021 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14022 @cindex CGI (Common Gateway Interface) debugging
14025 This is a package to help debugging CGI (Common Gateway Interface)
14026 programs written in Ada.
14028 @node GNAT.Command_Line (g-comlin.ads)
14029 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14030 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14031 @cindex Command line
14034 Provides a high level interface to @code{Ada.Command_Line} facilities,
14035 including the ability to scan for named switches with optional parameters
14036 and expand file names using wild card notations.
14038 @node GNAT.Compiler_Version (g-comver.ads)
14039 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14040 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14041 @cindex Compiler Version
14042 @cindex Version, of compiler
14045 Provides a routine for obtaining the version of the compiler used to
14046 compile the program. More accurately this is the version of the binder
14047 used to bind the program (this will normally be the same as the version
14048 of the compiler if a consistent tool set is used to compile all units
14051 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14052 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14053 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14057 Provides a simple interface to handle Ctrl-C keyboard events.
14059 @node GNAT.Current_Exception (g-curexc.ads)
14060 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14061 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14062 @cindex Current exception
14063 @cindex Exception retrieval
14066 Provides access to information on the current exception that has been raised
14067 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14068 specification syntax.
14069 This is particularly useful in simulating typical facilities for
14070 obtaining information about exceptions provided by Ada 83 compilers.
14072 @node GNAT.Debug_Pools (g-debpoo.ads)
14073 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14074 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14076 @cindex Debug pools
14077 @cindex Memory corruption debugging
14080 Provide a debugging storage pools that helps tracking memory corruption
14081 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14082 @value{EDITION} User's Guide}.
14084 @node GNAT.Debug_Utilities (g-debuti.ads)
14085 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14086 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14090 Provides a few useful utilities for debugging purposes, including conversion
14091 to and from string images of address values. Supports both C and Ada formats
14092 for hexadecimal literals.
14094 @node GNAT.Decode_String (g-decstr.ads)
14095 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14096 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14097 @cindex Decoding strings
14098 @cindex String decoding
14099 @cindex Wide character encoding
14104 A generic package providing routines for decoding wide character and wide wide
14105 character strings encoded as sequences of 8-bit characters using a specified
14106 encoding method. Includes validation routines, and also routines for stepping
14107 to next or previous encoded character in an encoded string.
14108 Useful in conjunction with Unicode character coding. Note there is a
14109 preinstantiation for UTF-8. See next entry.
14111 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14112 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14113 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14114 @cindex Decoding strings
14115 @cindex Decoding UTF-8 strings
14116 @cindex UTF-8 string decoding
14117 @cindex Wide character decoding
14122 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14124 @node GNAT.Directory_Operations (g-dirope.ads)
14125 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14126 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14127 @cindex Directory operations
14130 Provides a set of routines for manipulating directories, including changing
14131 the current directory, making new directories, and scanning the files in a
14134 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14135 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14136 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14137 @cindex Directory operations iteration
14140 A child unit of GNAT.Directory_Operations providing additional operations
14141 for iterating through directories.
14143 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14144 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14145 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14146 @cindex Hash tables
14149 A generic implementation of hash tables that can be used to hash arbitrary
14150 data. Provided in two forms, a simple form with built in hash functions,
14151 and a more complex form in which the hash function is supplied.
14154 This package provides a facility similar to that of @code{GNAT.HTable},
14155 except that this package declares a type that can be used to define
14156 dynamic instances of the hash table, while an instantiation of
14157 @code{GNAT.HTable} creates a single instance of the hash table.
14159 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14160 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14161 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14162 @cindex Table implementation
14163 @cindex Arrays, extendable
14166 A generic package providing a single dimension array abstraction where the
14167 length of the array can be dynamically modified.
14170 This package provides a facility similar to that of @code{GNAT.Table},
14171 except that this package declares a type that can be used to define
14172 dynamic instances of the table, while an instantiation of
14173 @code{GNAT.Table} creates a single instance of the table type.
14175 @node GNAT.Encode_String (g-encstr.ads)
14176 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14177 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14178 @cindex Encoding strings
14179 @cindex String encoding
14180 @cindex Wide character encoding
14185 A generic package providing routines for encoding wide character and wide
14186 wide character strings as sequences of 8-bit characters using a specified
14187 encoding method. Useful in conjunction with Unicode character coding.
14188 Note there is a preinstantiation for UTF-8. See next entry.
14190 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14191 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14192 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14193 @cindex Encoding strings
14194 @cindex Encoding UTF-8 strings
14195 @cindex UTF-8 string encoding
14196 @cindex Wide character encoding
14201 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14203 @node GNAT.Exception_Actions (g-excact.ads)
14204 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14205 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14206 @cindex Exception actions
14209 Provides callbacks when an exception is raised. Callbacks can be registered
14210 for specific exceptions, or when any exception is raised. This
14211 can be used for instance to force a core dump to ease debugging.
14213 @node GNAT.Exception_Traces (g-exctra.ads)
14214 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14215 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14216 @cindex Exception traces
14220 Provides an interface allowing to control automatic output upon exception
14223 @node GNAT.Exceptions (g-except.ads)
14224 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14225 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14226 @cindex Exceptions, Pure
14227 @cindex Pure packages, exceptions
14230 Normally it is not possible to raise an exception with
14231 a message from a subprogram in a pure package, since the
14232 necessary types and subprograms are in @code{Ada.Exceptions}
14233 which is not a pure unit. @code{GNAT.Exceptions} provides a
14234 facility for getting around this limitation for a few
14235 predefined exceptions, and for example allow raising
14236 @code{Constraint_Error} with a message from a pure subprogram.
14238 @node GNAT.Expect (g-expect.ads)
14239 @section @code{GNAT.Expect} (@file{g-expect.ads})
14240 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14243 Provides a set of subprograms similar to what is available
14244 with the standard Tcl Expect tool.
14245 It allows you to easily spawn and communicate with an external process.
14246 You can send commands or inputs to the process, and compare the output
14247 with some expected regular expression. Currently @code{GNAT.Expect}
14248 is implemented on all native GNAT ports except for OpenVMS@.
14249 It is not implemented for cross ports, and in particular is not
14250 implemented for VxWorks or LynxOS@.
14252 @node GNAT.Float_Control (g-flocon.ads)
14253 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14254 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14255 @cindex Floating-Point Processor
14258 Provides an interface for resetting the floating-point processor into the
14259 mode required for correct semantic operation in Ada. Some third party
14260 library calls may cause this mode to be modified, and the Reset procedure
14261 in this package can be used to reestablish the required mode.
14263 @node GNAT.Heap_Sort (g-heasor.ads)
14264 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14265 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14269 Provides a general implementation of heap sort usable for sorting arbitrary
14270 data items. Exchange and comparison procedures are provided by passing
14271 access-to-procedure values. The algorithm used is a modified heap sort
14272 that performs approximately N*log(N) comparisons in the worst case.
14274 @node GNAT.Heap_Sort_A (g-hesora.ads)
14275 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14276 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14280 Provides a general implementation of heap sort usable for sorting arbitrary
14281 data items. Move and comparison procedures are provided by passing
14282 access-to-procedure values. The algorithm used is a modified heap sort
14283 that performs approximately N*log(N) comparisons in the worst case.
14284 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14285 interface, but may be slightly more efficient.
14287 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14288 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14289 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14293 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14294 are provided as generic parameters, this improves efficiency, especially
14295 if the procedures can be inlined, at the expense of duplicating code for
14296 multiple instantiations.
14298 @node GNAT.HTable (g-htable.ads)
14299 @section @code{GNAT.HTable} (@file{g-htable.ads})
14300 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14301 @cindex Hash tables
14304 A generic implementation of hash tables that can be used to hash arbitrary
14305 data. Provides two approaches, one a simple static approach, and the other
14306 allowing arbitrary dynamic hash tables.
14308 @node GNAT.IO (g-io.ads)
14309 @section @code{GNAT.IO} (@file{g-io.ads})
14310 @cindex @code{GNAT.IO} (@file{g-io.ads})
14312 @cindex Input/Output facilities
14315 A simple preelaborable input-output package that provides a subset of
14316 simple Text_IO functions for reading characters and strings from
14317 Standard_Input, and writing characters, strings and integers to either
14318 Standard_Output or Standard_Error.
14320 @node GNAT.IO_Aux (g-io_aux.ads)
14321 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14322 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14324 @cindex Input/Output facilities
14326 Provides some auxiliary functions for use with Text_IO, including a test
14327 for whether a file exists, and functions for reading a line of text.
14329 @node GNAT.Lock_Files (g-locfil.ads)
14330 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14331 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14332 @cindex File locking
14333 @cindex Locking using files
14336 Provides a general interface for using files as locks. Can be used for
14337 providing program level synchronization.
14339 @node GNAT.MD5 (g-md5.ads)
14340 @section @code{GNAT.MD5} (@file{g-md5.ads})
14341 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14342 @cindex Message Digest MD5
14345 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14347 @node GNAT.Memory_Dump (g-memdum.ads)
14348 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14349 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14350 @cindex Dump Memory
14353 Provides a convenient routine for dumping raw memory to either the
14354 standard output or standard error files. Uses GNAT.IO for actual
14357 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14358 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14359 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14360 @cindex Exception, obtaining most recent
14363 Provides access to the most recently raised exception. Can be used for
14364 various logging purposes, including duplicating functionality of some
14365 Ada 83 implementation dependent extensions.
14367 @node GNAT.OS_Lib (g-os_lib.ads)
14368 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14369 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14370 @cindex Operating System interface
14371 @cindex Spawn capability
14374 Provides a range of target independent operating system interface functions,
14375 including time/date management, file operations, subprocess management,
14376 including a portable spawn procedure, and access to environment variables
14377 and error return codes.
14379 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14380 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14381 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14382 @cindex Hash functions
14385 Provides a generator of static minimal perfect hash functions. No
14386 collisions occur and each item can be retrieved from the table in one
14387 probe (perfect property). The hash table size corresponds to the exact
14388 size of the key set and no larger (minimal property). The key set has to
14389 be know in advance (static property). The hash functions are also order
14390 preserving. If w2 is inserted after w1 in the generator, their
14391 hashcode are in the same order. These hashing functions are very
14392 convenient for use with realtime applications.
14394 @node GNAT.Random_Numbers (g-rannum.ads)
14395 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14396 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14397 @cindex Random number generation
14400 Provides random number capabilities which extend those available in the
14401 standard Ada library and are more convenient to use.
14403 @node GNAT.Regexp (g-regexp.ads)
14404 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14405 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14406 @cindex Regular expressions
14407 @cindex Pattern matching
14410 A simple implementation of regular expressions, using a subset of regular
14411 expression syntax copied from familiar Unix style utilities. This is the
14412 simples of the three pattern matching packages provided, and is particularly
14413 suitable for ``file globbing'' applications.
14415 @node GNAT.Registry (g-regist.ads)
14416 @section @code{GNAT.Registry} (@file{g-regist.ads})
14417 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14418 @cindex Windows Registry
14421 This is a high level binding to the Windows registry. It is possible to
14422 do simple things like reading a key value, creating a new key. For full
14423 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14424 package provided with the Win32Ada binding
14426 @node GNAT.Regpat (g-regpat.ads)
14427 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14428 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14429 @cindex Regular expressions
14430 @cindex Pattern matching
14433 A complete implementation of Unix-style regular expression matching, copied
14434 from the original V7 style regular expression library written in C by
14435 Henry Spencer (and binary compatible with this C library).
14437 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14438 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14439 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14440 @cindex Secondary Stack Info
14443 Provide the capability to query the high water mark of the current task's
14446 @node GNAT.Semaphores (g-semaph.ads)
14447 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14448 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14452 Provides classic counting and binary semaphores using protected types.
14454 @node GNAT.Serial_Communications (g-sercom.ads)
14455 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14456 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14457 @cindex Serial_Communications
14460 Provides a simple interface to send and receive data over a serial
14461 port. This is only supported on GNU/Linux and Windows.
14463 @node GNAT.SHA1 (g-sha1.ads)
14464 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14465 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14466 @cindex Secure Hash Algorithm SHA-1
14469 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
14471 @node GNAT.Signals (g-signal.ads)
14472 @section @code{GNAT.Signals} (@file{g-signal.ads})
14473 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14477 Provides the ability to manipulate the blocked status of signals on supported
14480 @node GNAT.Sockets (g-socket.ads)
14481 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14482 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14486 A high level and portable interface to develop sockets based applications.
14487 This package is based on the sockets thin binding found in
14488 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14489 on all native GNAT ports except for OpenVMS@. It is not implemented
14490 for the LynxOS@ cross port.
14492 @node GNAT.Source_Info (g-souinf.ads)
14493 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14494 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14495 @cindex Source Information
14498 Provides subprograms that give access to source code information known at
14499 compile time, such as the current file name and line number.
14501 @node GNAT.Spelling_Checker (g-speche.ads)
14502 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14503 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14504 @cindex Spell checking
14507 Provides a function for determining whether one string is a plausible
14508 near misspelling of another string.
14510 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14511 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14512 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14513 @cindex Spell checking
14516 Provides a generic function that can be instantiated with a string type for
14517 determining whether one string is a plausible near misspelling of another
14520 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14521 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14522 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14523 @cindex SPITBOL pattern matching
14524 @cindex Pattern matching
14527 A complete implementation of SNOBOL4 style pattern matching. This is the
14528 most elaborate of the pattern matching packages provided. It fully duplicates
14529 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14530 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14532 @node GNAT.Spitbol (g-spitbo.ads)
14533 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14534 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14535 @cindex SPITBOL interface
14538 The top level package of the collection of SPITBOL-style functionality, this
14539 package provides basic SNOBOL4 string manipulation functions, such as
14540 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14541 useful for constructing arbitrary mappings from strings in the style of
14542 the SNOBOL4 TABLE function.
14544 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14545 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14546 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14547 @cindex Sets of strings
14548 @cindex SPITBOL Tables
14551 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14552 for type @code{Standard.Boolean}, giving an implementation of sets of
14555 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14556 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14557 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14558 @cindex Integer maps
14560 @cindex SPITBOL Tables
14563 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14564 for type @code{Standard.Integer}, giving an implementation of maps
14565 from string to integer values.
14567 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14568 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14569 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14570 @cindex String maps
14572 @cindex SPITBOL Tables
14575 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14576 a variable length string type, giving an implementation of general
14577 maps from strings to strings.
14579 @node GNAT.Strings (g-string.ads)
14580 @section @code{GNAT.Strings} (@file{g-string.ads})
14581 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14584 Common String access types and related subprograms. Basically it
14585 defines a string access and an array of string access types.
14587 @node GNAT.String_Split (g-strspl.ads)
14588 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14589 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14590 @cindex String splitter
14593 Useful string manipulation routines: given a set of separators, split
14594 a string wherever the separators appear, and provide direct access
14595 to the resulting slices. This package is instantiated from
14596 @code{GNAT.Array_Split}.
14598 @node GNAT.Table (g-table.ads)
14599 @section @code{GNAT.Table} (@file{g-table.ads})
14600 @cindex @code{GNAT.Table} (@file{g-table.ads})
14601 @cindex Table implementation
14602 @cindex Arrays, extendable
14605 A generic package providing a single dimension array abstraction where the
14606 length of the array can be dynamically modified.
14609 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14610 except that this package declares a single instance of the table type,
14611 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14612 used to define dynamic instances of the table.
14614 @node GNAT.Task_Lock (g-tasloc.ads)
14615 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14616 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14617 @cindex Task synchronization
14618 @cindex Task locking
14622 A very simple facility for locking and unlocking sections of code using a
14623 single global task lock. Appropriate for use in situations where contention
14624 between tasks is very rarely expected.
14626 @node GNAT.Time_Stamp (g-timsta.ads)
14627 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14628 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14630 @cindex Current time
14633 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14634 represents the current date and time in ISO 8601 format. This is a very simple
14635 routine with minimal code and there are no dependencies on any other unit.
14637 @node GNAT.Threads (g-thread.ads)
14638 @section @code{GNAT.Threads} (@file{g-thread.ads})
14639 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14640 @cindex Foreign threads
14641 @cindex Threads, foreign
14644 Provides facilities for dealing with foreign threads which need to be known
14645 by the GNAT run-time system. Consult the documentation of this package for
14646 further details if your program has threads that are created by a non-Ada
14647 environment which then accesses Ada code.
14649 @node GNAT.Traceback (g-traceb.ads)
14650 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14651 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14652 @cindex Trace back facilities
14655 Provides a facility for obtaining non-symbolic traceback information, useful
14656 in various debugging situations.
14658 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14659 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14660 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14661 @cindex Trace back facilities
14663 @node GNAT.UTF_32 (g-utf_32.ads)
14664 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14665 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14666 @cindex Wide character codes
14669 This is a package intended to be used in conjunction with the
14670 @code{Wide_Character} type in Ada 95 and the
14671 @code{Wide_Wide_Character} type in Ada 2005 (available
14672 in @code{GNAT} in Ada 2005 mode). This package contains
14673 Unicode categorization routines, as well as lexical
14674 categorization routines corresponding to the Ada 2005
14675 lexical rules for identifiers and strings, and also a
14676 lower case to upper case fold routine corresponding to
14677 the Ada 2005 rules for identifier equivalence.
14679 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14680 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14681 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14682 @cindex Spell checking
14685 Provides a function for determining whether one wide wide string is a plausible
14686 near misspelling of another wide wide string, where the strings are represented
14687 using the UTF_32_String type defined in System.Wch_Cnv.
14689 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14690 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14691 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14692 @cindex Spell checking
14695 Provides a function for determining whether one wide string is a plausible
14696 near misspelling of another wide string.
14698 @node GNAT.Wide_String_Split (g-wistsp.ads)
14699 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14700 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14701 @cindex Wide_String splitter
14704 Useful wide string manipulation routines: given a set of separators, split
14705 a wide string wherever the separators appear, and provide direct access
14706 to the resulting slices. This package is instantiated from
14707 @code{GNAT.Array_Split}.
14709 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14710 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14711 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14712 @cindex Spell checking
14715 Provides a function for determining whether one wide wide string is a plausible
14716 near misspelling of another wide wide string.
14718 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14719 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14720 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14721 @cindex Wide_Wide_String splitter
14724 Useful wide wide string manipulation routines: given a set of separators, split
14725 a wide wide string wherever the separators appear, and provide direct access
14726 to the resulting slices. This package is instantiated from
14727 @code{GNAT.Array_Split}.
14729 @node Interfaces.C.Extensions (i-cexten.ads)
14730 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14731 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14734 This package contains additional C-related definitions, intended
14735 for use with either manually or automatically generated bindings
14738 @node Interfaces.C.Streams (i-cstrea.ads)
14739 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14740 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14741 @cindex C streams, interfacing
14744 This package is a binding for the most commonly used operations
14747 @node Interfaces.CPP (i-cpp.ads)
14748 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
14749 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14750 @cindex C++ interfacing
14751 @cindex Interfacing, to C++
14754 This package provides facilities for use in interfacing to C++. It
14755 is primarily intended to be used in connection with automated tools
14756 for the generation of C++ interfaces.
14758 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14759 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14760 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14761 @cindex IBM Packed Format
14762 @cindex Packed Decimal
14765 This package provides a set of routines for conversions to and
14766 from a packed decimal format compatible with that used on IBM
14769 @node Interfaces.VxWorks (i-vxwork.ads)
14770 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14771 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14772 @cindex Interfacing to VxWorks
14773 @cindex VxWorks, interfacing
14776 This package provides a limited binding to the VxWorks API.
14777 In particular, it interfaces with the
14778 VxWorks hardware interrupt facilities.
14780 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14781 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14782 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14783 @cindex Interfacing to VxWorks' I/O
14784 @cindex VxWorks, I/O interfacing
14785 @cindex VxWorks, Get_Immediate
14786 @cindex Get_Immediate, VxWorks
14789 This package provides a binding to the ioctl (IO/Control)
14790 function of VxWorks, defining a set of option values and
14791 function codes. A particular use of this package is
14792 to enable the use of Get_Immediate under VxWorks.
14794 @node System.Address_Image (s-addima.ads)
14795 @section @code{System.Address_Image} (@file{s-addima.ads})
14796 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14797 @cindex Address image
14798 @cindex Image, of an address
14801 This function provides a useful debugging
14802 function that gives an (implementation dependent)
14803 string which identifies an address.
14805 @node System.Assertions (s-assert.ads)
14806 @section @code{System.Assertions} (@file{s-assert.ads})
14807 @cindex @code{System.Assertions} (@file{s-assert.ads})
14809 @cindex Assert_Failure, exception
14812 This package provides the declaration of the exception raised
14813 by an run-time assertion failure, as well as the routine that
14814 is used internally to raise this assertion.
14816 @node System.Memory (s-memory.ads)
14817 @section @code{System.Memory} (@file{s-memory.ads})
14818 @cindex @code{System.Memory} (@file{s-memory.ads})
14819 @cindex Memory allocation
14822 This package provides the interface to the low level routines used
14823 by the generated code for allocation and freeing storage for the
14824 default storage pool (analogous to the C routines malloc and free.
14825 It also provides a reallocation interface analogous to the C routine
14826 realloc. The body of this unit may be modified to provide alternative
14827 allocation mechanisms for the default pool, and in addition, direct
14828 calls to this unit may be made for low level allocation uses (for
14829 example see the body of @code{GNAT.Tables}).
14831 @node System.Partition_Interface (s-parint.ads)
14832 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14833 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14834 @cindex Partition interfacing functions
14837 This package provides facilities for partition interfacing. It
14838 is used primarily in a distribution context when using Annex E
14841 @node System.Pool_Global (s-pooglo.ads)
14842 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
14843 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
14844 @cindex Storage pool, global
14845 @cindex Global storage pool
14848 This package provides a storage pool that is equivalent to the default
14849 storage pool used for access types for which no pool is specifically
14850 declared. It uses malloc/free to allocate/free and does not attempt to
14851 do any automatic reclamation.
14853 @node System.Pool_Local (s-pooloc.ads)
14854 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
14855 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
14856 @cindex Storage pool, local
14857 @cindex Local storage pool
14860 This package provides a storage pool that is intended for use with locally
14861 defined access types. It uses malloc/free for allocate/free, and maintains
14862 a list of allocated blocks, so that all storage allocated for the pool can
14863 be freed automatically when the pool is finalized.
14865 @node System.Restrictions (s-restri.ads)
14866 @section @code{System.Restrictions} (@file{s-restri.ads})
14867 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14868 @cindex Run-time restrictions access
14871 This package provides facilities for accessing at run time
14872 the status of restrictions specified at compile time for
14873 the partition. Information is available both with regard
14874 to actual restrictions specified, and with regard to
14875 compiler determined information on which restrictions
14876 are violated by one or more packages in the partition.
14878 @node System.Rident (s-rident.ads)
14879 @section @code{System.Rident} (@file{s-rident.ads})
14880 @cindex @code{System.Rident} (@file{s-rident.ads})
14881 @cindex Restrictions definitions
14884 This package provides definitions of the restrictions
14885 identifiers supported by GNAT, and also the format of
14886 the restrictions provided in package System.Restrictions.
14887 It is not normally necessary to @code{with} this generic package
14888 since the necessary instantiation is included in
14889 package System.Restrictions.
14891 @node System.Task_Info (s-tasinf.ads)
14892 @section @code{System.Task_Info} (@file{s-tasinf.ads})
14893 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
14894 @cindex Task_Info pragma
14897 This package provides target dependent functionality that is used
14898 to support the @code{Task_Info} pragma
14900 @node System.Wch_Cnv (s-wchcnv.ads)
14901 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14902 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14903 @cindex Wide Character, Representation
14904 @cindex Wide String, Conversion
14905 @cindex Representation of wide characters
14908 This package provides routines for converting between
14909 wide and wide wide characters and a representation as a value of type
14910 @code{Standard.String}, using a specified wide character
14911 encoding method. It uses definitions in
14912 package @code{System.Wch_Con}.
14914 @node System.Wch_Con (s-wchcon.ads)
14915 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
14916 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
14919 This package provides definitions and descriptions of
14920 the various methods used for encoding wide characters
14921 in ordinary strings. These definitions are used by
14922 the package @code{System.Wch_Cnv}.
14924 @node Interfacing to Other Languages
14925 @chapter Interfacing to Other Languages
14927 The facilities in annex B of the Ada Reference Manual are fully
14928 implemented in GNAT, and in addition, a full interface to C++ is
14932 * Interfacing to C::
14933 * Interfacing to C++::
14934 * Interfacing to COBOL::
14935 * Interfacing to Fortran::
14936 * Interfacing to non-GNAT Ada code::
14939 @node Interfacing to C
14940 @section Interfacing to C
14943 Interfacing to C with GNAT can use one of two approaches:
14947 The types in the package @code{Interfaces.C} may be used.
14949 Standard Ada types may be used directly. This may be less portable to
14950 other compilers, but will work on all GNAT compilers, which guarantee
14951 correspondence between the C and Ada types.
14955 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
14956 effect, since this is the default. The following table shows the
14957 correspondence between Ada scalar types and the corresponding C types.
14962 @item Short_Integer
14964 @item Short_Short_Integer
14968 @item Long_Long_Integer
14976 @item Long_Long_Float
14977 This is the longest floating-point type supported by the hardware.
14981 Additionally, there are the following general correspondences between Ada
14985 Ada enumeration types map to C enumeration types directly if pragma
14986 @code{Convention C} is specified, which causes them to have int
14987 length. Without pragma @code{Convention C}, Ada enumeration types map to
14988 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
14989 @code{int}, respectively) depending on the number of values passed.
14990 This is the only case in which pragma @code{Convention C} affects the
14991 representation of an Ada type.
14994 Ada access types map to C pointers, except for the case of pointers to
14995 unconstrained types in Ada, which have no direct C equivalent.
14998 Ada arrays map directly to C arrays.
15001 Ada records map directly to C structures.
15004 Packed Ada records map to C structures where all members are bit fields
15005 of the length corresponding to the @code{@var{type}'Size} value in Ada.
15008 @node Interfacing to C++
15009 @section Interfacing to C++
15012 The interface to C++ makes use of the following pragmas, which are
15013 primarily intended to be constructed automatically using a binding generator
15014 tool, although it is possible to construct them by hand. No suitable binding
15015 generator tool is supplied with GNAT though.
15017 Using these pragmas it is possible to achieve complete
15018 inter-operability between Ada tagged types and C++ class definitions.
15019 See @ref{Implementation Defined Pragmas}, for more details.
15022 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15023 The argument denotes an entity in the current declarative region that is
15024 declared as a tagged or untagged record type. It indicates that the type
15025 corresponds to an externally declared C++ class type, and is to be laid
15026 out the same way that C++ would lay out the type.
15028 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15029 for backward compatibility but its functionality is available
15030 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15032 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15033 This pragma identifies an imported function (imported in the usual way
15034 with pragma @code{Import}) as corresponding to a C++ constructor.
15037 @node Interfacing to COBOL
15038 @section Interfacing to COBOL
15041 Interfacing to COBOL is achieved as described in section B.4 of
15042 the Ada Reference Manual.
15044 @node Interfacing to Fortran
15045 @section Interfacing to Fortran
15048 Interfacing to Fortran is achieved as described in section B.5 of the
15049 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
15050 multi-dimensional array causes the array to be stored in column-major
15051 order as required for convenient interface to Fortran.
15053 @node Interfacing to non-GNAT Ada code
15054 @section Interfacing to non-GNAT Ada code
15056 It is possible to specify the convention @code{Ada} in a pragma
15057 @code{Import} or pragma @code{Export}. However this refers to
15058 the calling conventions used by GNAT, which may or may not be
15059 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15060 compiler to allow interoperation.
15062 If arguments types are kept simple, and if the foreign compiler generally
15063 follows system calling conventions, then it may be possible to integrate
15064 files compiled by other Ada compilers, provided that the elaboration
15065 issues are adequately addressed (for example by eliminating the
15066 need for any load time elaboration).
15068 In particular, GNAT running on VMS is designed to
15069 be highly compatible with the DEC Ada 83 compiler, so this is one
15070 case in which it is possible to import foreign units of this type,
15071 provided that the data items passed are restricted to simple scalar
15072 values or simple record types without variants, or simple array
15073 types with fixed bounds.
15075 @node Specialized Needs Annexes
15076 @chapter Specialized Needs Annexes
15079 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15080 required in all implementations. However, as described in this chapter,
15081 GNAT implements all of these annexes:
15084 @item Systems Programming (Annex C)
15085 The Systems Programming Annex is fully implemented.
15087 @item Real-Time Systems (Annex D)
15088 The Real-Time Systems Annex is fully implemented.
15090 @item Distributed Systems (Annex E)
15091 Stub generation is fully implemented in the GNAT compiler. In addition,
15092 a complete compatible PCS is available as part of the GLADE system,
15093 a separate product. When the two
15094 products are used in conjunction, this annex is fully implemented.
15096 @item Information Systems (Annex F)
15097 The Information Systems annex is fully implemented.
15099 @item Numerics (Annex G)
15100 The Numerics Annex is fully implemented.
15102 @item Safety and Security / High-Integrity Systems (Annex H)
15103 The Safety and Security Annex (termed the High-Integrity Systems Annex
15104 in Ada 2005) is fully implemented.
15107 @node Implementation of Specific Ada Features
15108 @chapter Implementation of Specific Ada Features
15111 This chapter describes the GNAT implementation of several Ada language
15115 * Machine Code Insertions::
15116 * GNAT Implementation of Tasking::
15117 * GNAT Implementation of Shared Passive Packages::
15118 * Code Generation for Array Aggregates::
15119 * The Size of Discriminated Records with Default Discriminants::
15120 * Strict Conformance to the Ada Reference Manual::
15123 @node Machine Code Insertions
15124 @section Machine Code Insertions
15125 @cindex Machine Code insertions
15128 Package @code{Machine_Code} provides machine code support as described
15129 in the Ada Reference Manual in two separate forms:
15132 Machine code statements, consisting of qualified expressions that
15133 fit the requirements of RM section 13.8.
15135 An intrinsic callable procedure, providing an alternative mechanism of
15136 including machine instructions in a subprogram.
15140 The two features are similar, and both are closely related to the mechanism
15141 provided by the asm instruction in the GNU C compiler. Full understanding
15142 and use of the facilities in this package requires understanding the asm
15143 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15144 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15146 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15147 semantic restrictions and effects as described below. Both are provided so
15148 that the procedure call can be used as a statement, and the function call
15149 can be used to form a code_statement.
15151 The first example given in the GCC documentation is the C @code{asm}
15154 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15158 The equivalent can be written for GNAT as:
15160 @smallexample @c ada
15161 Asm ("fsinx %1 %0",
15162 My_Float'Asm_Output ("=f", result),
15163 My_Float'Asm_Input ("f", angle));
15167 The first argument to @code{Asm} is the assembler template, and is
15168 identical to what is used in GNU C@. This string must be a static
15169 expression. The second argument is the output operand list. It is
15170 either a single @code{Asm_Output} attribute reference, or a list of such
15171 references enclosed in parentheses (technically an array aggregate of
15174 The @code{Asm_Output} attribute denotes a function that takes two
15175 parameters. The first is a string, the second is the name of a variable
15176 of the type designated by the attribute prefix. The first (string)
15177 argument is required to be a static expression and designates the
15178 constraint for the parameter (e.g.@: what kind of register is
15179 required). The second argument is the variable to be updated with the
15180 result. The possible values for constraint are the same as those used in
15181 the RTL, and are dependent on the configuration file used to build the
15182 GCC back end. If there are no output operands, then this argument may
15183 either be omitted, or explicitly given as @code{No_Output_Operands}.
15185 The second argument of @code{@var{my_float}'Asm_Output} functions as
15186 though it were an @code{out} parameter, which is a little curious, but
15187 all names have the form of expressions, so there is no syntactic
15188 irregularity, even though normally functions would not be permitted
15189 @code{out} parameters. The third argument is the list of input
15190 operands. It is either a single @code{Asm_Input} attribute reference, or
15191 a list of such references enclosed in parentheses (technically an array
15192 aggregate of such references).
15194 The @code{Asm_Input} attribute denotes a function that takes two
15195 parameters. The first is a string, the second is an expression of the
15196 type designated by the prefix. The first (string) argument is required
15197 to be a static expression, and is the constraint for the parameter,
15198 (e.g.@: what kind of register is required). The second argument is the
15199 value to be used as the input argument. The possible values for the
15200 constant are the same as those used in the RTL, and are dependent on
15201 the configuration file used to built the GCC back end.
15203 If there are no input operands, this argument may either be omitted, or
15204 explicitly given as @code{No_Input_Operands}. The fourth argument, not
15205 present in the above example, is a list of register names, called the
15206 @dfn{clobber} argument. This argument, if given, must be a static string
15207 expression, and is a space or comma separated list of names of registers
15208 that must be considered destroyed as a result of the @code{Asm} call. If
15209 this argument is the null string (the default value), then the code
15210 generator assumes that no additional registers are destroyed.
15212 The fifth argument, not present in the above example, called the
15213 @dfn{volatile} argument, is by default @code{False}. It can be set to
15214 the literal value @code{True} to indicate to the code generator that all
15215 optimizations with respect to the instruction specified should be
15216 suppressed, and that in particular, for an instruction that has outputs,
15217 the instruction will still be generated, even if none of the outputs are
15218 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15219 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15220 Generally it is strongly advisable to use Volatile for any ASM statement
15221 that is missing either input or output operands, or when two or more ASM
15222 statements appear in sequence, to avoid unwanted optimizations. A warning
15223 is generated if this advice is not followed.
15225 The @code{Asm} subprograms may be used in two ways. First the procedure
15226 forms can be used anywhere a procedure call would be valid, and
15227 correspond to what the RM calls ``intrinsic'' routines. Such calls can
15228 be used to intersperse machine instructions with other Ada statements.
15229 Second, the function forms, which return a dummy value of the limited
15230 private type @code{Asm_Insn}, can be used in code statements, and indeed
15231 this is the only context where such calls are allowed. Code statements
15232 appear as aggregates of the form:
15234 @smallexample @c ada
15235 Asm_Insn'(Asm (@dots{}));
15236 Asm_Insn'(Asm_Volatile (@dots{}));
15240 In accordance with RM rules, such code statements are allowed only
15241 within subprograms whose entire body consists of such statements. It is
15242 not permissible to intermix such statements with other Ada statements.
15244 Typically the form using intrinsic procedure calls is more convenient
15245 and more flexible. The code statement form is provided to meet the RM
15246 suggestion that such a facility should be made available. The following
15247 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15248 is used, the arguments may be given in arbitrary order, following the
15249 normal rules for use of positional and named arguments)
15253 [Template =>] static_string_EXPRESSION
15254 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
15255 [,[Inputs =>] INPUT_OPERAND_LIST ]
15256 [,[Clobber =>] static_string_EXPRESSION ]
15257 [,[Volatile =>] static_boolean_EXPRESSION] )
15259 OUTPUT_OPERAND_LIST ::=
15260 [PREFIX.]No_Output_Operands
15261 | OUTPUT_OPERAND_ATTRIBUTE
15262 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15264 OUTPUT_OPERAND_ATTRIBUTE ::=
15265 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15267 INPUT_OPERAND_LIST ::=
15268 [PREFIX.]No_Input_Operands
15269 | INPUT_OPERAND_ATTRIBUTE
15270 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15272 INPUT_OPERAND_ATTRIBUTE ::=
15273 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15277 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15278 are declared in the package @code{Machine_Code} and must be referenced
15279 according to normal visibility rules. In particular if there is no
15280 @code{use} clause for this package, then appropriate package name
15281 qualification is required.
15283 @node GNAT Implementation of Tasking
15284 @section GNAT Implementation of Tasking
15287 This chapter outlines the basic GNAT approach to tasking (in particular,
15288 a multi-layered library for portability) and discusses issues related
15289 to compliance with the Real-Time Systems Annex.
15292 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15293 * Ensuring Compliance with the Real-Time Annex::
15296 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15297 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15300 GNAT's run-time support comprises two layers:
15303 @item GNARL (GNAT Run-time Layer)
15304 @item GNULL (GNAT Low-level Library)
15308 In GNAT, Ada's tasking services rely on a platform and OS independent
15309 layer known as GNARL@. This code is responsible for implementing the
15310 correct semantics of Ada's task creation, rendezvous, protected
15313 GNARL decomposes Ada's tasking semantics into simpler lower level
15314 operations such as create a thread, set the priority of a thread,
15315 yield, create a lock, lock/unlock, etc. The spec for these low-level
15316 operations constitutes GNULLI, the GNULL Interface. This interface is
15317 directly inspired from the POSIX real-time API@.
15319 If the underlying executive or OS implements the POSIX standard
15320 faithfully, the GNULL Interface maps as is to the services offered by
15321 the underlying kernel. Otherwise, some target dependent glue code maps
15322 the services offered by the underlying kernel to the semantics expected
15325 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
15326 key point is that each Ada task is mapped on a thread in the underlying
15327 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
15329 In addition Ada task priorities map onto the underlying thread priorities.
15330 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15334 The underlying scheduler is used to schedule the Ada tasks. This
15335 makes Ada tasks as efficient as kernel threads from a scheduling
15339 Interaction with code written in C containing threads is eased
15340 since at the lowest level Ada tasks and C threads map onto the same
15341 underlying kernel concept.
15344 When an Ada task is blocked during I/O the remaining Ada tasks are
15348 On multiprocessor systems Ada tasks can execute in parallel.
15352 Some threads libraries offer a mechanism to fork a new process, with the
15353 child process duplicating the threads from the parent.
15355 support this functionality when the parent contains more than one task.
15356 @cindex Forking a new process
15358 @node Ensuring Compliance with the Real-Time Annex
15359 @subsection Ensuring Compliance with the Real-Time Annex
15360 @cindex Real-Time Systems Annex compliance
15363 Although mapping Ada tasks onto
15364 the underlying threads has significant advantages, it does create some
15365 complications when it comes to respecting the scheduling semantics
15366 specified in the real-time annex (Annex D).
15368 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15369 scheduling policy states:
15372 @emph{When the active priority of a ready task that is not running
15373 changes, or the setting of its base priority takes effect, the
15374 task is removed from the ready queue for its old active priority
15375 and is added at the tail of the ready queue for its new active
15376 priority, except in the case where the active priority is lowered
15377 due to the loss of inherited priority, in which case the task is
15378 added at the head of the ready queue for its new active priority.}
15382 While most kernels do put tasks at the end of the priority queue when
15383 a task changes its priority, (which respects the main
15384 FIFO_Within_Priorities requirement), almost none keep a thread at the
15385 beginning of its priority queue when its priority drops from the loss
15386 of inherited priority.
15388 As a result most vendors have provided incomplete Annex D implementations.
15390 The GNAT run-time, has a nice cooperative solution to this problem
15391 which ensures that accurate FIFO_Within_Priorities semantics are
15394 The principle is as follows. When an Ada task T is about to start
15395 running, it checks whether some other Ada task R with the same
15396 priority as T has been suspended due to the loss of priority
15397 inheritance. If this is the case, T yields and is placed at the end of
15398 its priority queue. When R arrives at the front of the queue it
15401 Note that this simple scheme preserves the relative order of the tasks
15402 that were ready to execute in the priority queue where R has been
15405 @node GNAT Implementation of Shared Passive Packages
15406 @section GNAT Implementation of Shared Passive Packages
15407 @cindex Shared passive packages
15410 GNAT fully implements the pragma @code{Shared_Passive} for
15411 @cindex pragma @code{Shared_Passive}
15412 the purpose of designating shared passive packages.
15413 This allows the use of passive partitions in the
15414 context described in the Ada Reference Manual; i.e., for communication
15415 between separate partitions of a distributed application using the
15416 features in Annex E.
15418 @cindex Distribution Systems Annex
15420 However, the implementation approach used by GNAT provides for more
15421 extensive usage as follows:
15424 @item Communication between separate programs
15426 This allows separate programs to access the data in passive
15427 partitions, using protected objects for synchronization where
15428 needed. The only requirement is that the two programs have a
15429 common shared file system. It is even possible for programs
15430 running on different machines with different architectures
15431 (e.g.@: different endianness) to communicate via the data in
15432 a passive partition.
15434 @item Persistence between program runs
15436 The data in a passive package can persist from one run of a
15437 program to another, so that a later program sees the final
15438 values stored by a previous run of the same program.
15443 The implementation approach used is to store the data in files. A
15444 separate stream file is created for each object in the package, and
15445 an access to an object causes the corresponding file to be read or
15448 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15449 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15450 set to the directory to be used for these files.
15451 The files in this directory
15452 have names that correspond to their fully qualified names. For
15453 example, if we have the package
15455 @smallexample @c ada
15457 pragma Shared_Passive (X);
15464 and the environment variable is set to @code{/stemp/}, then the files created
15465 will have the names:
15473 These files are created when a value is initially written to the object, and
15474 the files are retained until manually deleted. This provides the persistence
15475 semantics. If no file exists, it means that no partition has assigned a value
15476 to the variable; in this case the initial value declared in the package
15477 will be used. This model ensures that there are no issues in synchronizing
15478 the elaboration process, since elaboration of passive packages elaborates the
15479 initial values, but does not create the files.
15481 The files are written using normal @code{Stream_IO} access.
15482 If you want to be able
15483 to communicate between programs or partitions running on different
15484 architectures, then you should use the XDR versions of the stream attribute
15485 routines, since these are architecture independent.
15487 If active synchronization is required for access to the variables in the
15488 shared passive package, then as described in the Ada Reference Manual, the
15489 package may contain protected objects used for this purpose. In this case
15490 a lock file (whose name is @file{___lock} (three underscores)
15491 is created in the shared memory directory.
15492 @cindex @file{___lock} file (for shared passive packages)
15493 This is used to provide the required locking
15494 semantics for proper protected object synchronization.
15496 As of January 2003, GNAT supports shared passive packages on all platforms
15497 except for OpenVMS.
15499 @node Code Generation for Array Aggregates
15500 @section Code Generation for Array Aggregates
15503 * Static constant aggregates with static bounds::
15504 * Constant aggregates with unconstrained nominal types::
15505 * Aggregates with static bounds::
15506 * Aggregates with non-static bounds::
15507 * Aggregates in assignment statements::
15511 Aggregates have a rich syntax and allow the user to specify the values of
15512 complex data structures by means of a single construct. As a result, the
15513 code generated for aggregates can be quite complex and involve loops, case
15514 statements and multiple assignments. In the simplest cases, however, the
15515 compiler will recognize aggregates whose components and constraints are
15516 fully static, and in those cases the compiler will generate little or no
15517 executable code. The following is an outline of the code that GNAT generates
15518 for various aggregate constructs. For further details, you will find it
15519 useful to examine the output produced by the -gnatG flag to see the expanded
15520 source that is input to the code generator. You may also want to examine
15521 the assembly code generated at various levels of optimization.
15523 The code generated for aggregates depends on the context, the component values,
15524 and the type. In the context of an object declaration the code generated is
15525 generally simpler than in the case of an assignment. As a general rule, static
15526 component values and static subtypes also lead to simpler code.
15528 @node Static constant aggregates with static bounds
15529 @subsection Static constant aggregates with static bounds
15532 For the declarations:
15533 @smallexample @c ada
15534 type One_Dim is array (1..10) of integer;
15535 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15539 GNAT generates no executable code: the constant ar0 is placed in static memory.
15540 The same is true for constant aggregates with named associations:
15542 @smallexample @c ada
15543 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15544 Cr3 : constant One_Dim := (others => 7777);
15548 The same is true for multidimensional constant arrays such as:
15550 @smallexample @c ada
15551 type two_dim is array (1..3, 1..3) of integer;
15552 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15556 The same is true for arrays of one-dimensional arrays: the following are
15559 @smallexample @c ada
15560 type ar1b is array (1..3) of boolean;
15561 type ar_ar is array (1..3) of ar1b;
15562 None : constant ar1b := (others => false); -- fully static
15563 None2 : constant ar_ar := (1..3 => None); -- fully static
15567 However, for multidimensional aggregates with named associations, GNAT will
15568 generate assignments and loops, even if all associations are static. The
15569 following two declarations generate a loop for the first dimension, and
15570 individual component assignments for the second dimension:
15572 @smallexample @c ada
15573 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15574 Zero2: constant two_dim := (others => (others => 0));
15577 @node Constant aggregates with unconstrained nominal types
15578 @subsection Constant aggregates with unconstrained nominal types
15581 In such cases the aggregate itself establishes the subtype, so that
15582 associations with @code{others} cannot be used. GNAT determines the
15583 bounds for the actual subtype of the aggregate, and allocates the
15584 aggregate statically as well. No code is generated for the following:
15586 @smallexample @c ada
15587 type One_Unc is array (natural range <>) of integer;
15588 Cr_Unc : constant One_Unc := (12,24,36);
15591 @node Aggregates with static bounds
15592 @subsection Aggregates with static bounds
15595 In all previous examples the aggregate was the initial (and immutable) value
15596 of a constant. If the aggregate initializes a variable, then code is generated
15597 for it as a combination of individual assignments and loops over the target
15598 object. The declarations
15600 @smallexample @c ada
15601 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15602 Cr_Var2 : One_Dim := (others > -1);
15606 generate the equivalent of
15608 @smallexample @c ada
15614 for I in Cr_Var2'range loop
15619 @node Aggregates with non-static bounds
15620 @subsection Aggregates with non-static bounds
15623 If the bounds of the aggregate are not statically compatible with the bounds
15624 of the nominal subtype of the target, then constraint checks have to be
15625 generated on the bounds. For a multidimensional array, constraint checks may
15626 have to be applied to sub-arrays individually, if they do not have statically
15627 compatible subtypes.
15629 @node Aggregates in assignment statements
15630 @subsection Aggregates in assignment statements
15633 In general, aggregate assignment requires the construction of a temporary,
15634 and a copy from the temporary to the target of the assignment. This is because
15635 it is not always possible to convert the assignment into a series of individual
15636 component assignments. For example, consider the simple case:
15638 @smallexample @c ada
15643 This cannot be converted into:
15645 @smallexample @c ada
15651 So the aggregate has to be built first in a separate location, and then
15652 copied into the target. GNAT recognizes simple cases where this intermediate
15653 step is not required, and the assignments can be performed in place, directly
15654 into the target. The following sufficient criteria are applied:
15658 The bounds of the aggregate are static, and the associations are static.
15660 The components of the aggregate are static constants, names of
15661 simple variables that are not renamings, or expressions not involving
15662 indexed components whose operands obey these rules.
15666 If any of these conditions are violated, the aggregate will be built in
15667 a temporary (created either by the front-end or the code generator) and then
15668 that temporary will be copied onto the target.
15671 @node The Size of Discriminated Records with Default Discriminants
15672 @section The Size of Discriminated Records with Default Discriminants
15675 If a discriminated type @code{T} has discriminants with default values, it is
15676 possible to declare an object of this type without providing an explicit
15679 @smallexample @c ada
15681 type Size is range 1..100;
15683 type Rec (D : Size := 15) is record
15684 Name : String (1..D);
15692 Such an object is said to be @emph{unconstrained}.
15693 The discriminant of the object
15694 can be modified by a full assignment to the object, as long as it preserves the
15695 relation between the value of the discriminant, and the value of the components
15698 @smallexample @c ada
15700 Word := (3, "yes");
15702 Word := (5, "maybe");
15704 Word := (5, "no"); -- raises Constraint_Error
15709 In order to support this behavior efficiently, an unconstrained object is
15710 given the maximum size that any value of the type requires. In the case
15711 above, @code{Word} has storage for the discriminant and for
15712 a @code{String} of length 100.
15713 It is important to note that unconstrained objects do not require dynamic
15714 allocation. It would be an improper implementation to place on the heap those
15715 components whose size depends on discriminants. (This improper implementation
15716 was used by some Ada83 compilers, where the @code{Name} component above
15718 been stored as a pointer to a dynamic string). Following the principle that
15719 dynamic storage management should never be introduced implicitly,
15720 an Ada compiler should reserve the full size for an unconstrained declared
15721 object, and place it on the stack.
15723 This maximum size approach
15724 has been a source of surprise to some users, who expect the default
15725 values of the discriminants to determine the size reserved for an
15726 unconstrained object: ``If the default is 15, why should the object occupy
15728 The answer, of course, is that the discriminant may be later modified,
15729 and its full range of values must be taken into account. This is why the
15734 type Rec (D : Positive := 15) is record
15735 Name : String (1..D);
15743 is flagged by the compiler with a warning:
15744 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15745 because the required size includes @code{Positive'Last}
15746 bytes. As the first example indicates, the proper approach is to declare an
15747 index type of ``reasonable'' range so that unconstrained objects are not too
15750 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15751 created in the heap by means of an allocator, then it is @emph{not}
15753 it is constrained by the default values of the discriminants, and those values
15754 cannot be modified by full assignment. This is because in the presence of
15755 aliasing all views of the object (which may be manipulated by different tasks,
15756 say) must be consistent, so it is imperative that the object, once created,
15759 @node Strict Conformance to the Ada Reference Manual
15760 @section Strict Conformance to the Ada Reference Manual
15763 The dynamic semantics defined by the Ada Reference Manual impose a set of
15764 run-time checks to be generated. By default, the GNAT compiler will insert many
15765 run-time checks into the compiled code, including most of those required by the
15766 Ada Reference Manual. However, there are three checks that are not enabled
15767 in the default mode for efficiency reasons: arithmetic overflow checking for
15768 integer operations (including division by zero), checks for access before
15769 elaboration on subprogram calls, and stack overflow checking (most operating
15770 systems do not perform this check by default).
15772 Strict conformance to the Ada Reference Manual can be achieved by adding
15773 three compiler options for overflow checking for integer operations
15774 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15775 calls and generic instantiations (@option{-gnatE}), and stack overflow
15776 checking (@option{-fstack-check}).
15778 Note that the result of a floating point arithmetic operation in overflow and
15779 invalid situations, when the @code{Machine_Overflows} attribute of the result
15780 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15781 case for machines compliant with the IEEE floating-point standard, but on
15782 machines that are not fully compliant with this standard, such as Alpha, the
15783 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15784 behavior (although at the cost of a significant performance penalty), so
15785 infinite and and NaN values are properly generated.
15788 @node Project File Reference
15789 @chapter Project File Reference
15792 This chapter describes the syntax and semantics of project files.
15793 Project files specify the options to be used when building a system.
15794 Project files can specify global settings for all tools,
15795 as well as tool-specific settings.
15796 @xref{Examples of Project Files,,, gnat_ugn, @value{EDITION} User's Guide},
15797 for examples of use.
15801 * Lexical Elements::
15803 * Empty declarations::
15804 * Typed string declarations::
15808 * Project Attributes::
15809 * Attribute References::
15810 * External Values::
15811 * Case Construction::
15813 * Package Renamings::
15815 * Project Extensions::
15816 * Project File Elaboration::
15819 @node Reserved Words
15820 @section Reserved Words
15823 All Ada reserved words are reserved in project files, and cannot be used
15824 as variable names or project names. In addition, the following are
15825 also reserved in project files:
15828 @item @code{extends}
15830 @item @code{external}
15832 @item @code{project}
15836 @node Lexical Elements
15837 @section Lexical Elements
15840 Rules for identifiers are the same as in Ada. Identifiers
15841 are case-insensitive. Strings are case sensitive, except where noted.
15842 Comments have the same form as in Ada.
15852 simple_name @{. simple_name@}
15856 @section Declarations
15859 Declarations introduce new entities that denote types, variables, attributes,
15860 and packages. Some declarations can only appear immediately within a project
15861 declaration. Others can appear within a project or within a package.
15865 declarative_item ::=
15866 simple_declarative_item |
15867 typed_string_declaration |
15868 package_declaration
15870 simple_declarative_item ::=
15871 variable_declaration |
15872 typed_variable_declaration |
15873 attribute_declaration |
15874 case_construction |
15878 @node Empty declarations
15879 @section Empty declarations
15882 empty_declaration ::=
15886 An empty declaration is allowed anywhere a declaration is allowed.
15889 @node Typed string declarations
15890 @section Typed string declarations
15893 Typed strings are sequences of string literals. Typed strings are the only
15894 named types in project files. They are used in case constructions, where they
15895 provide support for conditional attribute definitions.
15899 typed_string_declaration ::=
15900 @b{type} <typed_string_>_simple_name @b{is}
15901 ( string_literal @{, string_literal@} );
15905 A typed string declaration can only appear immediately within a project
15908 All the string literals in a typed string declaration must be distinct.
15914 Variables denote values, and appear as constituents of expressions.
15917 typed_variable_declaration ::=
15918 <typed_variable_>simple_name : <typed_string_>name := string_expression ;
15920 variable_declaration ::=
15921 <variable_>simple_name := expression;
15925 The elaboration of a variable declaration introduces the variable and
15926 assigns to it the value of the expression. The name of the variable is
15927 available after the assignment symbol.
15930 A typed_variable can only be declare once.
15933 a non-typed variable can be declared multiple times.
15936 Before the completion of its first declaration, the value of variable
15937 is the null string.
15940 @section Expressions
15943 An expression is a formula that defines a computation or retrieval of a value.
15944 In a project file the value of an expression is either a string or a list
15945 of strings. A string value in an expression is either a literal, the current
15946 value of a variable, an external value, an attribute reference, or a
15947 concatenation operation.
15960 attribute_reference
15966 ( <string_>expression @{ , <string_>expression @} )
15969 @subsection Concatenation
15971 The following concatenation functions are defined:
15973 @smallexample @c ada
15974 function "&" (X : String; Y : String) return String;
15975 function "&" (X : String_List; Y : String) return String_List;
15976 function "&" (X : String_List; Y : String_List) return String_List;
15980 @section Attributes
15983 An attribute declaration defines a property of a project or package. This
15984 property can later be queried by means of an attribute reference.
15985 Attribute values are strings or string lists.
15987 Some attributes are associative arrays. These attributes are mappings whose
15988 domain is a set of strings. These attributes are declared one association
15989 at a time, by specifying a point in the domain and the corresponding image
15990 of the attribute. They may also be declared as a full associative array,
15991 getting the same associations as the corresponding attribute in an imported
15992 or extended project.
15994 Attributes that are not associative arrays are called simple attributes.
15998 attribute_declaration ::=
15999 full_associative_array_declaration |
16000 @b{for} attribute_designator @b{use} expression ;
16002 full_associative_array_declaration ::=
16003 @b{for} <associative_array_attribute_>simple_name @b{use}
16004 <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
16006 attribute_designator ::=
16007 <simple_attribute_>simple_name |
16008 <associative_array_attribute_>simple_name ( string_literal )
16012 Some attributes are project-specific, and can only appear immediately within
16013 a project declaration. Others are package-specific, and can only appear within
16014 the proper package.
16016 The expression in an attribute definition must be a string or a string_list.
16017 The string literal appearing in the attribute_designator of an associative
16018 array attribute is case-insensitive.
16020 @node Project Attributes
16021 @section Project Attributes
16024 The following attributes apply to a project. All of them are simple
16029 Expression must be a path name. The attribute defines the
16030 directory in which the object files created by the build are to be placed. If
16031 not specified, object files are placed in the project directory.
16034 Expression must be a path name. The attribute defines the
16035 directory in which the executables created by the build are to be placed.
16036 If not specified, executables are placed in the object directory.
16039 Expression must be a list of path names. The attribute
16040 defines the directories in which the source files for the project are to be
16041 found. If not specified, source files are found in the project directory.
16042 If a string in the list ends with "/**", then the directory that precedes
16043 "/**" and all of its subdirectories (recursively) are included in the list
16044 of source directories.
16046 @item Excluded_Source_Dirs
16047 Expression must be a list of strings. Each entry designates a directory that
16048 is not to be included in the list of source directories of the project.
16049 This is normally used when there are strings ending with "/**" in the value
16050 of attribute Source_Dirs.
16053 Expression must be a list of file names. The attribute
16054 defines the individual files, in the project directory, which are to be used
16055 as sources for the project. File names are path_names that contain no directory
16056 information. If the project has no sources the attribute must be declared
16057 explicitly with an empty list.
16059 @item Excluded_Source_Files (Locally_Removed_Files)
16060 Expression must be a list of strings that are legal file names.
16061 Each file name must designate a source that would normally be a source file
16062 in the source directories of the project or, if the project file is an
16063 extending project file, inherited by the current project file. It cannot
16064 designate an immediate source that is not inherited. Each of the source files
16065 in the list are not considered to be sources of the project file: they are not
16066 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
16067 Excluded_Source_Files is preferred.
16069 @item Source_List_File
16070 Expression must a single path name. The attribute
16071 defines a text file that contains a list of source file names to be used
16072 as sources for the project
16075 Expression must be a path name. The attribute defines the
16076 directory in which a library is to be built. The directory must exist, must
16077 be distinct from the project's object directory, and must be writable.
16080 Expression must be a string that is a legal file name,
16081 without extension. The attribute defines a string that is used to generate
16082 the name of the library to be built by the project.
16085 Argument must be a string value that must be one of the
16086 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
16087 string is case-insensitive. If this attribute is not specified, the library is
16088 a static library. Otherwise, the library may be dynamic or relocatable. This
16089 distinction is operating-system dependent.
16091 @item Library_Version
16092 Expression must be a string value whose interpretation
16093 is platform dependent. On UNIX, it is used only for dynamic/relocatable
16094 libraries as the internal name of the library (the @code{"soname"}). If the
16095 library file name (built from the @code{Library_Name}) is different from the
16096 @code{Library_Version}, then the library file will be a symbolic link to the
16097 actual file whose name will be @code{Library_Version}.
16099 @item Library_Interface
16100 Expression must be a string list. Each element of the string list
16101 must designate a unit of the project.
16102 If this attribute is present in a Library Project File, then the project
16103 file is a Stand-alone Library_Project_File.
16105 @item Library_Auto_Init
16106 Expression must be a single string "true" or "false", case-insensitive.
16107 If this attribute is present in a Stand-alone Library Project File,
16108 it indicates if initialization is automatic when the dynamic library
16111 @item Library_Options
16112 Expression must be a string list. Indicates additional switches that
16113 are to be used when building a shared library.
16116 Expression must be a single string. Designates an alternative to "gcc"
16117 for building shared libraries.
16119 @item Library_Src_Dir
16120 Expression must be a path name. The attribute defines the
16121 directory in which the sources of the interfaces of a Stand-alone Library will
16122 be copied. The directory must exist, must be distinct from the project's
16123 object directory and source directories of all projects in the project tree,
16124 and must be writable.
16126 @item Library_Src_Dir
16127 Expression must be a path name. The attribute defines the
16128 directory in which the ALI files of a Library will
16129 be copied. The directory must exist, must be distinct from the project's
16130 object directory and source directories of all projects in the project tree,
16131 and must be writable.
16133 @item Library_Symbol_File
16134 Expression must be a single string. Its value is the single file name of a
16135 symbol file to be created when building a stand-alone library when the
16136 symbol policy is either "compliant", "controlled" or "restricted",
16137 on platforms that support symbol control, such as VMS. When symbol policy
16138 is "direct", then a file with this name must exist in the object directory.
16140 @item Library_Reference_Symbol_File
16141 Expression must be a single string. Its value is the path name of a
16142 reference symbol file that is read when the symbol policy is either
16143 "compliant" or "controlled", on platforms that support symbol control,
16144 such as VMS, when building a stand-alone library. The path may be an absolute
16145 path or a path relative to the project directory.
16147 @item Library_Symbol_Policy
16148 Expression must be a single string. Its case-insensitive value can only be
16149 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
16151 This attribute is not taken into account on all platforms. It controls the
16152 policy for exported symbols and, on some platforms (like VMS) that have the
16153 notions of major and minor IDs built in the library files, it controls
16154 the setting of these IDs.
16156 "autonomous" or "default": exported symbols are not controlled.
16158 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
16159 it is equivalent to policy "autonomous". If there are exported symbols in
16160 the reference symbol file that are not in the object files of the interfaces,
16161 the major ID of the library is increased. If there are symbols in the
16162 object files of the interfaces that are not in the reference symbol file,
16163 these symbols are put at the end of the list in the newly created symbol file
16164 and the minor ID is increased.
16166 "controlled": the attribute Library_Reference_Symbol_File must be defined.
16167 The library will fail to build if the exported symbols in the object files of
16168 the interfaces do not match exactly the symbol in the symbol file.
16170 "restricted": The attribute Library_Symbol_File must be defined. The library
16171 will fail to build if there are symbols in the symbol file that are not in
16172 the exported symbols of the object files of the interfaces. Additional symbols
16173 in the object files are not added to the symbol file.
16175 "direct": The attribute Library_Symbol_File must be defined and must designate
16176 an existing file in the object directory. This symbol file is passed directly
16177 to the underlying linker without any symbol processing.
16180 Expression must be a list of strings that are legal file names.
16181 These file names designate existing compilation units in the source directory
16182 that are legal main subprograms.
16184 When a project file is elaborated, as part of the execution of a gnatmake
16185 command, one or several executables are built and placed in the Exec_Dir.
16186 If the gnatmake command does not include explicit file names, the executables
16187 that are built correspond to the files specified by this attribute.
16189 @item Externally_Built
16190 Expression must be a single string. Its value must be either "true" of "false",
16191 case-insensitive. The default is "false". When the value of this attribute is
16192 "true", no attempt is made to compile the sources or to build the library,
16193 when the project is a library project.
16195 @item Main_Language
16196 This is a simple attribute. Its value is a string that specifies the
16197 language of the main program.
16200 Expression must be a string list. Each string designates
16201 a programming language that is known to GNAT. The strings are case-insensitive.
16205 @node Attribute References
16206 @section Attribute References
16209 Attribute references are used to retrieve the value of previously defined
16210 attribute for a package or project.
16213 attribute_reference ::=
16214 attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
16216 attribute_prefix ::=
16218 <project_simple_name | package_identifier |
16219 <project_>simple_name . package_identifier
16223 If an attribute has not been specified for a given package or project, its
16224 value is the null string or the empty list.
16226 @node External Values
16227 @section External Values
16230 An external value is an expression whose value is obtained from the command
16231 that invoked the processing of the current project file (typically a
16237 @b{external} ( string_literal [, string_literal] )
16241 The first string_literal is the string to be used on the command line or
16242 in the environment to specify the external value. The second string_literal,
16243 if present, is the default to use if there is no specification for this
16244 external value either on the command line or in the environment.
16246 @node Case Construction
16247 @section Case Construction
16250 A case construction supports attribute and variable declarations that depend
16251 on the value of a previously declared variable.
16255 case_construction ::=
16256 @b{case} <typed_variable_>name @b{is}
16261 @b{when} discrete_choice_list =>
16262 @{case_construction |
16263 attribute_declaration |
16264 variable_declaration |
16265 empty_declaration@}
16267 discrete_choice_list ::=
16268 string_literal @{| string_literal@} |
16273 Inside a case construction, variable declarations must be for variables that
16274 have already been declared before the case construction.
16276 All choices in a choice list must be distinct. The choice lists of two
16277 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
16278 alternatives do not need to include all values of the type. An @code{others}
16279 choice must appear last in the list of alternatives.
16285 A package provides a grouping of variable declarations and attribute
16286 declarations to be used when invoking various GNAT tools. The name of
16287 the package indicates the tool(s) to which it applies.
16291 package_declaration ::=
16292 package_spec | package_renaming
16295 @b{package} package_identifier @b{is}
16296 @{simple_declarative_item@}
16297 @b{end} package_identifier ;
16299 package_identifier ::=
16300 @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
16301 @code{Linker} | @code{Finder} | @code{Cross_Reference} |
16302 @code{gnatls} | @code{IDE} | @code{Pretty_Printer}
16305 @subsection Package Naming
16308 The attributes of a @code{Naming} package specifies the naming conventions
16309 that apply to the source files in a project. When invoking other GNAT tools,
16310 they will use the sources in the source directories that satisfy these
16311 naming conventions.
16313 The following attributes apply to a @code{Naming} package:
16317 This is a simple attribute whose value is a string. Legal values of this
16318 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
16319 These strings are themselves case insensitive.
16322 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
16324 @item Dot_Replacement
16325 This is a simple attribute whose string value satisfies the following
16329 @item It must not be empty
16330 @item It cannot start or end with an alphanumeric character
16331 @item It cannot be a single underscore
16332 @item It cannot start with an underscore followed by an alphanumeric
16333 @item It cannot contain a dot @code{'.'} if longer than one character
16337 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
16340 This is an associative array attribute, defined on language names,
16341 whose image is a string that must satisfy the following
16345 @item It must not be empty
16346 @item It cannot start with an alphanumeric character
16347 @item It cannot start with an underscore followed by an alphanumeric character
16351 For Ada, the attribute denotes the suffix used in file names that contain
16352 library unit declarations, that is to say units that are package and
16353 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
16354 specified, then the default is @code{".ads"}.
16356 For C and C++, the attribute denotes the suffix used in file names that
16357 contain prototypes.
16360 This is an associative array attribute defined on language names,
16361 whose image is a string that must satisfy the following
16365 @item It must not be empty
16366 @item It cannot start with an alphanumeric character
16367 @item It cannot start with an underscore followed by an alphanumeric character
16368 @item It cannot be a suffix of @code{Spec_Suffix}
16372 For Ada, the attribute denotes the suffix used in file names that contain
16373 library bodies, that is to say units that are package and subprogram bodies.
16374 If @code{Body_Suffix ("Ada")} is not specified, then the default is
16377 For C and C++, the attribute denotes the suffix used in file names that contain
16380 @item Separate_Suffix
16381 This is a simple attribute whose value satisfies the same conditions as
16382 @code{Body_Suffix}.
16384 This attribute is specific to Ada. It denotes the suffix used in file names
16385 that contain separate bodies. If it is not specified, then it defaults to same
16386 value as @code{Body_Suffix ("Ada")}.
16389 This is an associative array attribute, specific to Ada, defined over
16390 compilation unit names. The image is a string that is the name of the file
16391 that contains that library unit. The file name is case sensitive if the
16392 conventions of the host operating system require it.
16395 This is an associative array attribute, specific to Ada, defined over
16396 compilation unit names. The image is a string that is the name of the file
16397 that contains the library unit body for the named unit. The file name is case
16398 sensitive if the conventions of the host operating system require it.
16400 @item Specification_Exceptions
16401 This is an associative array attribute defined on language names,
16402 whose value is a list of strings.
16404 This attribute is not significant for Ada.
16406 For C and C++, each string in the list denotes the name of a file that
16407 contains prototypes, but whose suffix is not necessarily the
16408 @code{Spec_Suffix} for the language.
16410 @item Implementation_Exceptions
16411 This is an associative array attribute defined on language names,
16412 whose value is a list of strings.
16414 This attribute is not significant for Ada.
16416 For C and C++, each string in the list denotes the name of a file that
16417 contains source code, but whose suffix is not necessarily the
16418 @code{Body_Suffix} for the language.
16421 The following attributes of package @code{Naming} are obsolescent. They are
16422 kept as synonyms of other attributes for compatibility with previous versions
16423 of the Project Manager.
16426 @item Specification_Suffix
16427 This is a synonym of @code{Spec_Suffix}.
16429 @item Implementation_Suffix
16430 This is a synonym of @code{Body_Suffix}.
16432 @item Specification
16433 This is a synonym of @code{Spec}.
16435 @item Implementation
16436 This is a synonym of @code{Body}.
16439 @subsection package Compiler
16442 The attributes of the @code{Compiler} package specify the compilation options
16443 to be used by the underlying compiler.
16446 @item Default_Switches
16447 This is an associative array attribute. Its
16448 domain is a set of language names. Its range is a string list that
16449 specifies the compilation options to be used when compiling a component
16450 written in that language, for which no file-specific switches have been
16454 This is an associative array attribute. Its domain is
16455 a set of file names. Its range is a string list that specifies the
16456 compilation options to be used when compiling the named file. If a file
16457 is not specified in the Switches attribute, it is compiled with the
16458 options specified by Default_Switches of its language, if defined.
16460 @item Local_Configuration_Pragmas.
16461 This is a simple attribute, whose
16462 value is a path name that designates a file containing configuration pragmas
16463 to be used for all invocations of the compiler for immediate sources of the
16467 @subsection package Builder
16470 The attributes of package @code{Builder} specify the compilation, binding, and
16471 linking options to be used when building an executable for a project. The
16472 following attributes apply to package @code{Builder}:
16475 @item Default_Switches
16476 This is an associative array attribute. Its
16477 domain is a set of language names. Its range is a string list that
16478 specifies options to be used when building a main
16479 written in that language, for which no file-specific switches have been
16483 This is an associative array attribute. Its domain is
16484 a set of file names. Its range is a string list that specifies
16485 options to be used when building the named main file. If a main file
16486 is not specified in the Switches attribute, it is built with the
16487 options specified by Default_Switches of its language, if defined.
16489 @item Global_Configuration_Pragmas
16490 This is a simple attribute, whose
16491 value is a path name that designates a file that contains configuration pragmas
16492 to be used in every build of an executable. If both local and global
16493 configuration pragmas are specified, a compilation makes use of both sets.
16497 This is an associative array attribute. Its domain is
16498 a set of main source file names. Its range is a simple string that specifies
16499 the executable file name to be used when linking the specified main source.
16500 If a main source is not specified in the Executable attribute, the executable
16501 file name is deducted from the main source file name.
16502 This attribute has no effect if its value is the empty string.
16504 @item Executable_Suffix
16505 This is a simple attribute whose value is the suffix to be added to
16506 the executables that don't have an attribute Executable specified.
16509 @subsection package Gnatls
16512 The attributes of package @code{Gnatls} specify the tool options to be used
16513 when invoking the library browser @command{gnatls}.
16514 The following attributes apply to package @code{Gnatls}:
16518 This is a single attribute with a string list value. Each nonempty string
16519 in the list is an option when invoking @code{gnatls}.
16522 @subsection package Binder
16525 The attributes of package @code{Binder} specify the options to be used
16526 when invoking the binder in the construction of an executable.
16527 The following attributes apply to package @code{Binder}:
16530 @item Default_Switches
16531 This is an associative array attribute. Its
16532 domain is a set of language names. Its range is a string list that
16533 specifies options to be used when binding a main
16534 written in that language, for which no file-specific switches have been
16538 This is an associative array attribute. Its domain is
16539 a set of file names. Its range is a string list that specifies
16540 options to be used when binding the named main file. If a main file
16541 is not specified in the Switches attribute, it is bound with the
16542 options specified by Default_Switches of its language, if defined.
16545 @subsection package Linker
16548 The attributes of package @code{Linker} specify the options to be used when
16549 invoking the linker in the construction of an executable.
16550 The following attributes apply to package @code{Linker}:
16553 @item Default_Switches
16554 This is an associative array attribute. Its
16555 domain is a set of language names. Its range is a string list that
16556 specifies options to be used when linking a main
16557 written in that language, for which no file-specific switches have been
16561 This is an associative array attribute. Its domain is
16562 a set of file names. Its range is a string list that specifies
16563 options to be used when linking the named main file. If a main file
16564 is not specified in the Switches attribute, it is linked with the
16565 options specified by Default_Switches of its language, if defined.
16567 @item Linker_Options
16568 This is a string list attribute. Its value specifies additional options that
16569 be given to the linker when linking an executable. This attribute is not
16570 used in the main project, only in projects imported directly or indirectly.
16574 @subsection package Cross_Reference
16577 The attributes of package @code{Cross_Reference} specify the tool options
16579 when invoking the library tool @command{gnatxref}.
16580 The following attributes apply to package @code{Cross_Reference}:
16583 @item Default_Switches
16584 This is an associative array attribute. Its
16585 domain is a set of language names. Its range is a string list that
16586 specifies options to be used when calling @command{gnatxref} on a source
16587 written in that language, for which no file-specific switches have been
16591 This is an associative array attribute. Its domain is
16592 a set of file names. Its range is a string list that specifies
16593 options to be used when calling @command{gnatxref} on the named main source.
16594 If a source is not specified in the Switches attribute, @command{gnatxref} will
16595 be called with the options specified by Default_Switches of its language,
16599 @subsection package Finder
16602 The attributes of package @code{Finder} specify the tool options to be used
16603 when invoking the search tool @command{gnatfind}.
16604 The following attributes apply to package @code{Finder}:
16607 @item Default_Switches
16608 This is an associative array attribute. Its
16609 domain is a set of language names. Its range is a string list that
16610 specifies options to be used when calling @command{gnatfind} on a source
16611 written in that language, for which no file-specific switches have been
16615 This is an associative array attribute. Its domain is
16616 a set of file names. Its range is a string list that specifies
16617 options to be used when calling @command{gnatfind} on the named main source.
16618 If a source is not specified in the Switches attribute, @command{gnatfind} will
16619 be called with the options specified by Default_Switches of its language,
16623 @subsection package Pretty_Printer
16626 The attributes of package @code{Pretty_Printer}
16627 specify the tool options to be used
16628 when invoking the formatting tool @command{gnatpp}.
16629 The following attributes apply to package @code{Pretty_Printer}:
16632 @item Default_switches
16633 This is an associative array attribute. Its
16634 domain is a set of language names. Its range is a string list that
16635 specifies options to be used when calling @command{gnatpp} on a source
16636 written in that language, for which no file-specific switches have been
16640 This is an associative array attribute. Its domain is
16641 a set of file names. Its range is a string list that specifies
16642 options to be used when calling @command{gnatpp} on the named main source.
16643 If a source is not specified in the Switches attribute, @command{gnatpp} will
16644 be called with the options specified by Default_Switches of its language,
16648 @subsection package gnatstub
16651 The attributes of package @code{gnatstub}
16652 specify the tool options to be used
16653 when invoking the tool @command{gnatstub}.
16654 The following attributes apply to package @code{gnatstub}:
16657 @item Default_switches
16658 This is an associative array attribute. Its
16659 domain is a set of language names. Its range is a string list that
16660 specifies options to be used when calling @command{gnatstub} on a source
16661 written in that language, for which no file-specific switches have been
16665 This is an associative array attribute. Its domain is
16666 a set of file names. Its range is a string list that specifies
16667 options to be used when calling @command{gnatstub} on the named main source.
16668 If a source is not specified in the Switches attribute, @command{gnatpp} will
16669 be called with the options specified by Default_Switches of its language,
16673 @subsection package Eliminate
16676 The attributes of package @code{Eliminate}
16677 specify the tool options to be used
16678 when invoking the tool @command{gnatelim}.
16679 The following attributes apply to package @code{Eliminate}:
16682 @item Default_switches
16683 This is an associative array attribute. Its
16684 domain is a set of language names. Its range is a string list that
16685 specifies options to be used when calling @command{gnatelim} on a source
16686 written in that language, for which no file-specific switches have been
16690 This is an associative array attribute. Its domain is
16691 a set of file names. Its range is a string list that specifies
16692 options to be used when calling @command{gnatelim} on the named main source.
16693 If a source is not specified in the Switches attribute, @command{gnatelim} will
16694 be called with the options specified by Default_Switches of its language,
16698 @subsection package Metrics
16701 The attributes of package @code{Metrics}
16702 specify the tool options to be used
16703 when invoking the tool @command{gnatmetric}.
16704 The following attributes apply to package @code{Metrics}:
16707 @item Default_switches
16708 This is an associative array attribute. Its
16709 domain is a set of language names. Its range is a string list that
16710 specifies options to be used when calling @command{gnatmetric} on a source
16711 written in that language, for which no file-specific switches have been
16715 This is an associative array attribute. Its domain is
16716 a set of file names. Its range is a string list that specifies
16717 options to be used when calling @command{gnatmetric} on the named main source.
16718 If a source is not specified in the Switches attribute, @command{gnatmetric}
16719 will be called with the options specified by Default_Switches of its language,
16723 @subsection package IDE
16726 The attributes of package @code{IDE} specify the options to be used when using
16727 an Integrated Development Environment such as @command{GPS}.
16731 This is a simple attribute. Its value is a string that designates the remote
16732 host in a cross-compilation environment, to be used for remote compilation and
16733 debugging. This field should not be specified when running on the local
16737 This is a simple attribute. Its value is a string that specifies the
16738 name of IP address of the embedded target in a cross-compilation environment,
16739 on which the program should execute.
16741 @item Communication_Protocol
16742 This is a simple string attribute. Its value is the name of the protocol
16743 to use to communicate with the target in a cross-compilation environment,
16744 e.g.@: @code{"wtx"} or @code{"vxworks"}.
16746 @item Compiler_Command
16747 This is an associative array attribute, whose domain is a language name. Its
16748 value is string that denotes the command to be used to invoke the compiler.
16749 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16750 gnatmake, in particular in the handling of switches.
16752 @item Debugger_Command
16753 This is simple attribute, Its value is a string that specifies the name of
16754 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16756 @item Default_Switches
16757 This is an associative array attribute. Its indexes are the name of the
16758 external tools that the GNAT Programming System (GPS) is supporting. Its
16759 value is a list of switches to use when invoking that tool.
16762 This is a simple attribute. Its value is a string that specifies the name
16763 of the @command{gnatls} utility to be used to retrieve information about the
16764 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16767 This is a simple attribute. Its value is a string used to specify the
16768 Version Control System (VCS) to be used for this project, e.g.@: CVS, RCS
16769 ClearCase or Perforce.
16771 @item VCS_File_Check
16772 This is a simple attribute. Its value is a string that specifies the
16773 command used by the VCS to check the validity of a file, either
16774 when the user explicitly asks for a check, or as a sanity check before
16775 doing the check-in.
16777 @item VCS_Log_Check
16778 This is a simple attribute. Its value is a string that specifies
16779 the command used by the VCS to check the validity of a log file.
16781 @item VCS_Repository_Root
16782 The VCS repository root path. This is used to create tags or branches
16783 of the repository. For subversion the value should be the @code{URL}
16784 as specified to check-out the working copy of the repository.
16786 @item VCS_Patch_Root
16787 The local root directory to use for building patch file. All patch chunks
16788 will be relative to this path. The root project directory is used if
16789 this value is not defined.
16793 @node Package Renamings
16794 @section Package Renamings
16797 A package can be defined by a renaming declaration. The new package renames
16798 a package declared in a different project file, and has the same attributes
16799 as the package it renames.
16802 package_renaming ::==
16803 @b{package} package_identifier @b{renames}
16804 <project_>simple_name.package_identifier ;
16808 The package_identifier of the renamed package must be the same as the
16809 package_identifier. The project whose name is the prefix of the renamed
16810 package must contain a package declaration with this name. This project
16811 must appear in the context_clause of the enclosing project declaration,
16812 or be the parent project of the enclosing child project.
16818 A project file specifies a set of rules for constructing a software system.
16819 A project file can be self-contained, or depend on other project files.
16820 Dependencies are expressed through a context clause that names other projects.
16826 context_clause project_declaration
16828 project_declaration ::=
16829 simple_project_declaration | project_extension
16831 simple_project_declaration ::=
16832 @b{project} <project_>simple_name @b{is}
16833 @{declarative_item@}
16834 @b{end} <project_>simple_name;
16840 [@b{limited}] @b{with} path_name @{ , path_name @} ;
16847 A path name denotes a project file. A path name can be absolute or relative.
16848 An absolute path name includes a sequence of directories, in the syntax of
16849 the host operating system, that identifies uniquely the project file in the
16850 file system. A relative path name identifies the project file, relative
16851 to the directory that contains the current project, or relative to a
16852 directory listed in the environment variable ADA_PROJECT_PATH.
16853 Path names are case sensitive if file names in the host operating system
16854 are case sensitive.
16856 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16857 directory names separated by colons (semicolons on Windows).
16859 A given project name can appear only once in a context_clause.
16861 It is illegal for a project imported by a context clause to refer, directly
16862 or indirectly, to the project in which this context clause appears (the
16863 dependency graph cannot contain cycles), except when one of the with_clause
16864 in the cycle is a @code{limited with}.
16866 @node Project Extensions
16867 @section Project Extensions
16870 A project extension introduces a new project, which inherits the declarations
16871 of another project.
16875 project_extension ::=
16876 @b{project} <project_>simple_name @b{extends} path_name @b{is}
16877 @{declarative_item@}
16878 @b{end} <project_>simple_name;
16882 The project extension declares a child project. The child project inherits
16883 all the declarations and all the files of the parent project, These inherited
16884 declaration can be overridden in the child project, by means of suitable
16887 @node Project File Elaboration
16888 @section Project File Elaboration
16891 A project file is processed as part of the invocation of a gnat tool that
16892 uses the project option. Elaboration of the process file consists in the
16893 sequential elaboration of all its declarations. The computed values of
16894 attributes and variables in the project are then used to establish the
16895 environment in which the gnat tool will execute.
16897 @node Obsolescent Features
16898 @chapter Obsolescent Features
16901 This chapter describes features that are provided by GNAT, but are
16902 considered obsolescent since there are preferred ways of achieving
16903 the same effect. These features are provided solely for historical
16904 compatibility purposes.
16907 * pragma No_Run_Time::
16908 * pragma Ravenscar::
16909 * pragma Restricted_Run_Time::
16912 @node pragma No_Run_Time
16913 @section pragma No_Run_Time
16915 The pragma @code{No_Run_Time} is used to achieve an affect similar
16916 to the use of the "Zero Foot Print" configurable run time, but without
16917 requiring a specially configured run time. The result of using this
16918 pragma, which must be used for all units in a partition, is to restrict
16919 the use of any language features requiring run-time support code. The
16920 preferred usage is to use an appropriately configured run-time that
16921 includes just those features that are to be made accessible.
16923 @node pragma Ravenscar
16924 @section pragma Ravenscar
16926 The pragma @code{Ravenscar} has exactly the same effect as pragma
16927 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16928 is part of the new Ada 2005 standard.
16930 @node pragma Restricted_Run_Time
16931 @section pragma Restricted_Run_Time
16933 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16934 pragma @code{Profile (Restricted)}. The latter usage is
16935 preferred since the Ada 2005 pragma @code{Profile} is intended for
16936 this kind of implementation dependent addition.
16939 @c GNU Free Documentation License
16941 @node Index,,GNU Free Documentation License, Top