1 \input texinfo @c -*-texinfo-*-
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
7 @c GNAT DOCUMENTATION o
11 @c Copyright (C) 1995-2005 Free Software Foundation o
14 @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o
16 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
18 @setfilename gnat_rm.info
22 @settitle GNAT Reference Manual
24 @setchapternewpage odd
27 @include gcc-common.texi
29 @dircategory GNU Ada tools
31 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
35 Copyright @copyright{} 1995-2004, Free Software Foundation
37 Permission is granted to copy, distribute and/or modify this document
38 under the terms of the GNU Free Documentation License, Version 1.2
39 or any later version published by the Free Software Foundation;
40 with the Invariant Sections being ``GNU Free Documentation License'',
41 with the Front-Cover Texts being ``GNAT Reference Manual'', and with
42 no Back-Cover Texts. A copy of the license is included in the section
43 entitled ``GNU Free Documentation License''.
48 @title GNAT Reference Manual
49 @subtitle GNAT, The GNU Ada 95 Compiler
50 @subtitle GCC version @value{version-GCC}
51 @author Ada Core Technologies, Inc.
54 @vskip 0pt plus 1filll
61 @node Top, About This Guide, (dir), (dir)
62 @top GNAT Reference Manual
68 GNAT, The GNU Ada 95 Compiler@*
69 GCC version @value{version-GCC}@*
72 Ada Core Technologies, Inc.
76 * Implementation Defined Pragmas::
77 * Implementation Defined Attributes::
78 * Implementation Advice::
79 * Implementation Defined Characteristics::
80 * Intrinsic Subprograms::
81 * Representation Clauses and Pragmas::
82 * Standard Library Routines::
83 * The Implementation of Standard I/O::
85 * Interfacing to Other Languages::
86 * Specialized Needs Annexes::
87 * Implementation of Specific Ada Features::
88 * Project File Reference::
89 * Obsolescent Features::
90 * GNU Free Documentation License::
93 --- The Detailed Node Listing ---
97 * What This Reference Manual Contains::
98 * Related Information::
100 Implementation Defined Pragmas
102 * Pragma Abort_Defer::
109 * Pragma C_Pass_By_Copy::
111 * Pragma Common_Object::
112 * Pragma Compile_Time_Warning::
113 * Pragma Complex_Representation::
114 * Pragma Component_Alignment::
115 * Pragma Convention_Identifier::
117 * Pragma CPP_Constructor::
118 * Pragma CPP_Virtual::
119 * Pragma CPP_Vtable::
121 * Pragma Detect_Blocking::
122 * Pragma Elaboration_Checks::
124 * Pragma Export_Exception::
125 * Pragma Export_Function::
126 * Pragma Export_Object::
127 * Pragma Export_Procedure::
128 * Pragma Export_Value::
129 * Pragma Export_Valued_Procedure::
130 * Pragma Extend_System::
132 * Pragma External_Name_Casing::
133 * Pragma Finalize_Storage_Only::
134 * Pragma Float_Representation::
136 * Pragma Import_Exception::
137 * Pragma Import_Function::
138 * Pragma Import_Object::
139 * Pragma Import_Procedure::
140 * Pragma Import_Valued_Procedure::
141 * Pragma Initialize_Scalars::
142 * Pragma Inline_Always::
143 * Pragma Inline_Generic::
145 * Pragma Interface_Name::
146 * Pragma Interrupt_Handler::
147 * Pragma Interrupt_State::
148 * Pragma Keep_Names::
151 * Pragma Linker_Alias::
152 * Pragma Linker_Section::
153 * Pragma Long_Float::
154 * Pragma Machine_Attribute::
155 * Pragma Main_Storage::
157 * Pragma Normalize_Scalars::
158 * Pragma Obsolescent::
161 * Pragma Profile (Ravenscar)::
162 * Pragma Profile (Restricted)::
163 * Pragma Propagate_Exceptions::
164 * Pragma Psect_Object::
165 * Pragma Pure_Function::
166 * Pragma Restriction_Warnings::
167 * Pragma Source_File_Name::
168 * Pragma Source_File_Name_Project::
169 * Pragma Source_Reference::
170 * Pragma Stream_Convert::
171 * Pragma Style_Checks::
173 * Pragma Suppress_All::
174 * Pragma Suppress_Exception_Locations::
175 * Pragma Suppress_Initialization::
178 * Pragma Task_Storage::
179 * Pragma Thread_Body::
180 * Pragma Time_Slice::
182 * Pragma Unchecked_Union::
183 * Pragma Unimplemented_Unit::
184 * Pragma Universal_Data::
185 * Pragma Unreferenced::
186 * Pragma Unreserve_All_Interrupts::
187 * Pragma Unsuppress::
188 * Pragma Use_VADS_Size::
189 * Pragma Validity_Checks::
192 * Pragma Weak_External::
194 Implementation Defined Attributes
204 * Default_Bit_Order::
212 * Has_Access_Values::
213 * Has_Discriminants::
219 * Max_Interrupt_Priority::
221 * Maximum_Alignment::
225 * Passed_By_Reference::
236 * Unconstrained_Array::
237 * Universal_Literal_String::
238 * Unrestricted_Access::
244 The Implementation of Standard I/O
246 * Standard I/O Packages::
252 * Wide_Wide_Text_IO::
256 * Operations on C Streams::
257 * Interfacing to C Streams::
261 * Ada.Characters.Latin_9 (a-chlat9.ads)::
262 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
263 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
264 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
265 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
266 * Ada.Command_Line.Remove (a-colire.ads)::
267 * Ada.Command_Line.Environment (a-colien.ads)::
268 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
269 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
270 * Ada.Exceptions.Traceback (a-exctra.ads)::
271 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
272 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
273 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
274 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
275 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
276 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
277 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
278 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
279 * GNAT.Array_Split (g-arrspl.ads)::
280 * GNAT.AWK (g-awk.ads)::
281 * GNAT.Bounded_Buffers (g-boubuf.ads)::
282 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
283 * GNAT.Bubble_Sort (g-bubsor.ads)::
284 * GNAT.Bubble_Sort_A (g-busora.ads)::
285 * GNAT.Bubble_Sort_G (g-busorg.ads)::
286 * GNAT.Calendar (g-calend.ads)::
287 * GNAT.Calendar.Time_IO (g-catiio.ads)::
288 * GNAT.Case_Util (g-casuti.ads)::
289 * GNAT.CGI (g-cgi.ads)::
290 * GNAT.CGI.Cookie (g-cgicoo.ads)::
291 * GNAT.CGI.Debug (g-cgideb.ads)::
292 * GNAT.Command_Line (g-comlin.ads)::
293 * GNAT.Compiler_Version (g-comver.ads)::
294 * GNAT.Ctrl_C (g-ctrl_c.ads)::
295 * GNAT.CRC32 (g-crc32.ads)::
296 * GNAT.Current_Exception (g-curexc.ads)::
297 * GNAT.Debug_Pools (g-debpoo.ads)::
298 * GNAT.Debug_Utilities (g-debuti.ads)::
299 * GNAT.Directory_Operations (g-dirope.ads)::
300 * GNAT.Dynamic_HTables (g-dynhta.ads)::
301 * GNAT.Dynamic_Tables (g-dyntab.ads)::
302 * GNAT.Exception_Actions (g-excact.ads)::
303 * GNAT.Exception_Traces (g-exctra.ads)::
304 * GNAT.Exceptions (g-except.ads)::
305 * GNAT.Expect (g-expect.ads)::
306 * GNAT.Float_Control (g-flocon.ads)::
307 * GNAT.Heap_Sort (g-heasor.ads)::
308 * GNAT.Heap_Sort_A (g-hesora.ads)::
309 * GNAT.Heap_Sort_G (g-hesorg.ads)::
310 * GNAT.HTable (g-htable.ads)::
311 * GNAT.IO (g-io.ads)::
312 * GNAT.IO_Aux (g-io_aux.ads)::
313 * GNAT.Lock_Files (g-locfil.ads)::
314 * GNAT.MD5 (g-md5.ads)::
315 * GNAT.Memory_Dump (g-memdum.ads)::
316 * GNAT.Most_Recent_Exception (g-moreex.ads)::
317 * GNAT.OS_Lib (g-os_lib.ads)::
318 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
319 * GNAT.Regexp (g-regexp.ads)::
320 * GNAT.Registry (g-regist.ads)::
321 * GNAT.Regpat (g-regpat.ads)::
322 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
323 * GNAT.Semaphores (g-semaph.ads)::
324 * GNAT.Signals (g-signal.ads)::
325 * GNAT.Sockets (g-socket.ads)::
326 * GNAT.Source_Info (g-souinf.ads)::
327 * GNAT.Spell_Checker (g-speche.ads)::
328 * GNAT.Spitbol.Patterns (g-spipat.ads)::
329 * GNAT.Spitbol (g-spitbo.ads)::
330 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
331 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
332 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
333 * GNAT.Strings (g-string.ads)::
334 * GNAT.String_Split (g-strspl.ads)::
335 * GNAT.Table (g-table.ads)::
336 * GNAT.Task_Lock (g-tasloc.ads)::
337 * GNAT.Threads (g-thread.ads)::
338 * GNAT.Traceback (g-traceb.ads)::
339 * GNAT.Traceback.Symbolic (g-trasym.ads)::
340 * GNAT.Wide_String_Split (g-wistsp.ads)::
341 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
342 * Interfaces.C.Extensions (i-cexten.ads)::
343 * Interfaces.C.Streams (i-cstrea.ads)::
344 * Interfaces.CPP (i-cpp.ads)::
345 * Interfaces.Os2lib (i-os2lib.ads)::
346 * Interfaces.Os2lib.Errors (i-os2err.ads)::
347 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
348 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
349 * Interfaces.Packed_Decimal (i-pacdec.ads)::
350 * Interfaces.VxWorks (i-vxwork.ads)::
351 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
352 * System.Address_Image (s-addima.ads)::
353 * System.Assertions (s-assert.ads)::
354 * System.Memory (s-memory.ads)::
355 * System.Partition_Interface (s-parint.ads)::
356 * System.Restrictions (s-restri.ads)::
357 * System.Rident (s-rident.ads)::
358 * System.Task_Info (s-tasinf.ads)::
359 * System.Wch_Cnv (s-wchcnv.ads)::
360 * System.Wch_Con (s-wchcon.ads)::
364 * Text_IO Stream Pointer Positioning::
365 * Text_IO Reading and Writing Non-Regular Files::
367 * Treating Text_IO Files as Streams::
368 * Text_IO Extensions::
369 * Text_IO Facilities for Unbounded Strings::
373 * Wide_Text_IO Stream Pointer Positioning::
374 * Wide_Text_IO Reading and Writing Non-Regular Files::
378 * Wide_Wide_Text_IO Stream Pointer Positioning::
379 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
381 Interfacing to Other Languages
384 * Interfacing to C++::
385 * Interfacing to COBOL::
386 * Interfacing to Fortran::
387 * Interfacing to non-GNAT Ada code::
389 Specialized Needs Annexes
391 Implementation of Specific Ada Features
392 * Machine Code Insertions::
393 * GNAT Implementation of Tasking::
394 * GNAT Implementation of Shared Passive Packages::
395 * Code Generation for Array Aggregates::
396 * The Size of Discriminated Records with Default Discriminants::
398 Project File Reference
402 GNU Free Documentation License
409 @node About This Guide
410 @unnumbered About This Guide
414 This manual contains useful information in writing programs using the
415 GNAT compiler. It includes information on implementation dependent
416 characteristics of GNAT, including all the information required by Annex
422 This manual contains useful information in writing programs using the
423 GNAT Pro compiler. It includes information on implementation dependent
424 characteristics of GNAT Pro, including all the information required by Annex
428 Ada 95 is designed to be highly portable.
429 In general, a program will have the same effect even when compiled by
430 different compilers on different platforms.
431 However, since Ada 95 is designed to be used in a
432 wide variety of applications, it also contains a number of system
433 dependent features to be used in interfacing to the external world.
434 @cindex Implementation-dependent features
437 Note: Any program that makes use of implementation-dependent features
438 may be non-portable. You should follow good programming practice and
439 isolate and clearly document any sections of your program that make use
440 of these features in a non-portable manner.
443 For ease of exposition, ``GNAT Pro'' will be referred to simply as
444 ``GNAT'' in the remainder of this document.
448 * What This Reference Manual Contains::
450 * Related Information::
453 @node What This Reference Manual Contains
454 @unnumberedsec What This Reference Manual Contains
457 This reference manual contains the following chapters:
461 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
462 pragmas, which can be used to extend and enhance the functionality of the
466 @ref{Implementation Defined Attributes}, lists GNAT
467 implementation-dependent attributes which can be used to extend and
468 enhance the functionality of the compiler.
471 @ref{Implementation Advice}, provides information on generally
472 desirable behavior which are not requirements that all compilers must
473 follow since it cannot be provided on all systems, or which may be
474 undesirable on some systems.
477 @ref{Implementation Defined Characteristics}, provides a guide to
478 minimizing implementation dependent features.
481 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
482 implemented by GNAT, and how they can be imported into user
483 application programs.
486 @ref{Representation Clauses and Pragmas}, describes in detail the
487 way that GNAT represents data, and in particular the exact set
488 of representation clauses and pragmas that is accepted.
491 @ref{Standard Library Routines}, provides a listing of packages and a
492 brief description of the functionality that is provided by Ada's
493 extensive set of standard library routines as implemented by GNAT@.
496 @ref{The Implementation of Standard I/O}, details how the GNAT
497 implementation of the input-output facilities.
500 @ref{The GNAT Library}, is a catalog of packages that complement
501 the Ada predefined library.
504 @ref{Interfacing to Other Languages}, describes how programs
505 written in Ada using GNAT can be interfaced to other programming
508 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
509 of the specialized needs annexes.
512 @ref{Implementation of Specific Ada Features}, discusses issues related
513 to GNAT's implementation of machine code insertions, tasking, and several
517 @ref{Project File Reference}, presents the syntax and semantics
521 @ref{Obsolescent Features} documents implementation dependent features,
522 including pragmas and attributes, which are considered obsolescent, since
523 there are other preferred ways of achieving the same results. These
524 obsolescent forms are retained for backwards compatibility.
528 @cindex Ada 95 ISO/ANSI Standard
530 This reference manual assumes that you are familiar with Ada 95
531 language, as described in the International Standard
532 ANSI/ISO/IEC-8652:1995, Jan 1995.
535 @unnumberedsec Conventions
536 @cindex Conventions, typographical
537 @cindex Typographical conventions
540 Following are examples of the typographical and graphic conventions used
545 @code{Functions}, @code{utility program names}, @code{standard names},
552 @file{File Names}, @samp{button names}, and @samp{field names}.
561 [optional information or parameters]
564 Examples are described by text
566 and then shown this way.
571 Commands that are entered by the user are preceded in this manual by the
572 characters @samp{$ } (dollar sign followed by space). If your system uses this
573 sequence as a prompt, then the commands will appear exactly as you see them
574 in the manual. If your system uses some other prompt, then the command will
575 appear with the @samp{$} replaced by whatever prompt character you are using.
577 @node Related Information
578 @unnumberedsec Related Information
580 See the following documents for further information on GNAT:
584 @cite{GNAT User's Guide}, which provides information on how to use
585 the GNAT compiler system.
588 @cite{Ada 95 Reference Manual}, which contains all reference
589 material for the Ada 95 programming language.
592 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
593 of the standard reference manual cited above. The annotations describe
594 detailed aspects of the design decision, and in particular contain useful
595 sections on Ada 83 compatibility.
598 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
599 which contains specific information on compatibility between GNAT and
603 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
604 describes in detail the pragmas and attributes provided by the DEC Ada 83
609 @node Implementation Defined Pragmas
610 @chapter Implementation Defined Pragmas
613 Ada 95 defines a set of pragmas that can be used to supply additional
614 information to the compiler. These language defined pragmas are
615 implemented in GNAT and work as described in the Ada 95 Reference
618 In addition, Ada 95 allows implementations to define additional pragmas
619 whose meaning is defined by the implementation. GNAT provides a number
620 of these implementation-dependent pragmas which can be used to extend
621 and enhance the functionality of the compiler. This section of the GNAT
622 Reference Manual describes these additional pragmas.
624 Note that any program using these pragmas may not be portable to other
625 compilers (although GNAT implements this set of pragmas on all
626 platforms). Therefore if portability to other compilers is an important
627 consideration, the use of these pragmas should be minimized.
630 * Pragma Abort_Defer::
637 * Pragma C_Pass_By_Copy::
639 * Pragma Common_Object::
640 * Pragma Compile_Time_Warning::
641 * Pragma Complex_Representation::
642 * Pragma Component_Alignment::
643 * Pragma Convention_Identifier::
645 * Pragma CPP_Constructor::
646 * Pragma CPP_Virtual::
647 * Pragma CPP_Vtable::
649 * Pragma Detect_Blocking::
650 * Pragma Elaboration_Checks::
652 * Pragma Export_Exception::
653 * Pragma Export_Function::
654 * Pragma Export_Object::
655 * Pragma Export_Procedure::
656 * Pragma Export_Value::
657 * Pragma Export_Valued_Procedure::
658 * Pragma Extend_System::
660 * Pragma External_Name_Casing::
661 * Pragma Finalize_Storage_Only::
662 * Pragma Float_Representation::
664 * Pragma Import_Exception::
665 * Pragma Import_Function::
666 * Pragma Import_Object::
667 * Pragma Import_Procedure::
668 * Pragma Import_Valued_Procedure::
669 * Pragma Initialize_Scalars::
670 * Pragma Inline_Always::
671 * Pragma Inline_Generic::
673 * Pragma Interface_Name::
674 * Pragma Interrupt_Handler::
675 * Pragma Interrupt_State::
676 * Pragma Keep_Names::
679 * Pragma Linker_Alias::
680 * Pragma Linker_Section::
681 * Pragma Long_Float::
682 * Pragma Machine_Attribute::
683 * Pragma Main_Storage::
685 * Pragma Normalize_Scalars::
686 * Pragma Obsolescent::
689 * Pragma Profile (Ravenscar)::
690 * Pragma Profile (Restricted)::
691 * Pragma Propagate_Exceptions::
692 * Pragma Psect_Object::
693 * Pragma Pure_Function::
694 * Pragma Restriction_Warnings::
695 * Pragma Source_File_Name::
696 * Pragma Source_File_Name_Project::
697 * Pragma Source_Reference::
698 * Pragma Stream_Convert::
699 * Pragma Style_Checks::
701 * Pragma Suppress_All::
702 * Pragma Suppress_Exception_Locations::
703 * Pragma Suppress_Initialization::
706 * Pragma Task_Storage::
707 * Pragma Thread_Body::
708 * Pragma Time_Slice::
710 * Pragma Unchecked_Union::
711 * Pragma Unimplemented_Unit::
712 * Pragma Universal_Data::
713 * Pragma Unreferenced::
714 * Pragma Unreserve_All_Interrupts::
715 * Pragma Unsuppress::
716 * Pragma Use_VADS_Size::
717 * Pragma Validity_Checks::
720 * Pragma Weak_External::
723 @node Pragma Abort_Defer
724 @unnumberedsec Pragma Abort_Defer
726 @cindex Deferring aborts
734 This pragma must appear at the start of the statement sequence of a
735 handled sequence of statements (right after the @code{begin}). It has
736 the effect of deferring aborts for the sequence of statements (but not
737 for the declarations or handlers, if any, associated with this statement
741 @unnumberedsec Pragma Ada_83
750 A configuration pragma that establishes Ada 83 mode for the unit to
751 which it applies, regardless of the mode set by the command line
752 switches. In Ada 83 mode, GNAT attempts to be as compatible with
753 the syntax and semantics of Ada 83, as defined in the original Ada
754 83 Reference Manual as possible. In particular, the new Ada 95
755 keywords are not recognized, optional package bodies are allowed,
756 and generics may name types with unknown discriminants without using
757 the @code{(<>)} notation. In addition, some but not all of the additional
758 restrictions of Ada 83 are enforced.
760 Ada 83 mode is intended for two purposes. Firstly, it allows existing
761 legacy Ada 83 code to be compiled and adapted to GNAT with less effort.
762 Secondly, it aids in keeping code backwards compatible with Ada 83.
763 However, there is no guarantee that code that is processed correctly
764 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
765 83 compiler, since GNAT does not enforce all the additional checks
769 @unnumberedsec Pragma Ada_95
778 A configuration pragma that establishes Ada 95 mode for the unit to which
779 it applies, regardless of the mode set by the command line switches.
780 This mode is set automatically for the @code{Ada} and @code{System}
781 packages and their children, so you need not specify it in these
782 contexts. This pragma is useful when writing a reusable component that
783 itself uses Ada 95 features, but which is intended to be usable from
784 either Ada 83 or Ada 95 programs.
787 @unnumberedsec Pragma Ada_05
796 A configuration pragma that establishes Ada 2005 mode for the unit to which
797 it applies, regardless of the mode set by the command line switches.
798 This mode is set automatically for the @code{Ada} and @code{System}
799 packages and their children, so you need not specify it in these
800 contexts. This pragma is useful when writing a reusable component that
801 itself uses Ada 2005 features, but which is intended to be usable from
802 either Ada 83 or Ada 95 programs.
804 @node Pragma Annotate
805 @unnumberedsec Pragma Annotate
810 pragma Annotate (IDENTIFIER @{, ARG@});
812 ARG ::= NAME | EXPRESSION
816 This pragma is used to annotate programs. @var{identifier} identifies
817 the type of annotation. GNAT verifies this is an identifier, but does
818 not otherwise analyze it. The @var{arg} argument
819 can be either a string literal or an
820 expression. String literals are assumed to be of type
821 @code{Standard.String}. Names of entities are simply analyzed as entity
822 names. All other expressions are analyzed as expressions, and must be
825 The analyzed pragma is retained in the tree, but not otherwise processed
826 by any part of the GNAT compiler. This pragma is intended for use by
827 external tools, including ASIS@.
830 @unnumberedsec Pragma Assert
837 [, static_string_EXPRESSION]);
841 The effect of this pragma depends on whether the corresponding command
842 line switch is set to activate assertions. The pragma expands into code
843 equivalent to the following:
846 if assertions-enabled then
847 if not boolean_EXPRESSION then
848 System.Assertions.Raise_Assert_Failure
855 The string argument, if given, is the message that will be associated
856 with the exception occurrence if the exception is raised. If no second
857 argument is given, the default message is @samp{@var{file}:@var{nnn}},
858 where @var{file} is the name of the source file containing the assert,
859 and @var{nnn} is the line number of the assert. A pragma is not a
860 statement, so if a statement sequence contains nothing but a pragma
861 assert, then a null statement is required in addition, as in:
866 pragma Assert (K > 3, "Bad value for K");
872 Note that, as with the @code{if} statement to which it is equivalent, the
873 type of the expression is either @code{Standard.Boolean}, or any type derived
874 from this standard type.
876 If assertions are disabled (switch @code{-gnata} not used), then there
877 is no effect (and in particular, any side effects from the expression
878 are suppressed). More precisely it is not quite true that the pragma
879 has no effect, since the expression is analyzed, and may cause types
880 to be frozen if they are mentioned here for the first time.
882 If assertions are enabled, then the given expression is tested, and if
883 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
884 which results in the raising of @code{Assert_Failure} with the given message.
886 If the boolean expression has side effects, these side effects will turn
887 on and off with the setting of the assertions mode, resulting in
888 assertions that have an effect on the program. You should generally
889 avoid side effects in the expression arguments of this pragma. However,
890 the expressions are analyzed for semantic correctness whether or not
891 assertions are enabled, so turning assertions on and off cannot affect
892 the legality of a program.
894 @node Pragma Ast_Entry
895 @unnumberedsec Pragma Ast_Entry
901 pragma AST_Entry (entry_IDENTIFIER);
905 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
906 argument is the simple name of a single entry; at most one @code{AST_Entry}
907 pragma is allowed for any given entry. This pragma must be used in
908 conjunction with the @code{AST_Entry} attribute, and is only allowed after
909 the entry declaration and in the same task type specification or single task
910 as the entry to which it applies. This pragma specifies that the given entry
911 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
912 resulting from an OpenVMS system service call. The pragma does not affect
913 normal use of the entry. For further details on this pragma, see the
914 DEC Ada Language Reference Manual, section 9.12a.
916 @node Pragma C_Pass_By_Copy
917 @unnumberedsec Pragma C_Pass_By_Copy
918 @cindex Passing by copy
919 @findex C_Pass_By_Copy
923 pragma C_Pass_By_Copy
924 ([Max_Size =>] static_integer_EXPRESSION);
928 Normally the default mechanism for passing C convention records to C
929 convention subprograms is to pass them by reference, as suggested by RM
930 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
931 this default, by requiring that record formal parameters be passed by
932 copy if all of the following conditions are met:
936 The size of the record type does not exceed@*@var{static_integer_expression}.
938 The record type has @code{Convention C}.
940 The formal parameter has this record type, and the subprogram has a
941 foreign (non-Ada) convention.
945 If these conditions are met the argument is passed by copy, i.e.@: in a
946 manner consistent with what C expects if the corresponding formal in the
947 C prototype is a struct (rather than a pointer to a struct).
949 You can also pass records by copy by specifying the convention
950 @code{C_Pass_By_Copy} for the record type, or by using the extended
951 @code{Import} and @code{Export} pragmas, which allow specification of
952 passing mechanisms on a parameter by parameter basis.
955 @unnumberedsec Pragma Comment
961 pragma Comment (static_string_EXPRESSION);
965 This is almost identical in effect to pragma @code{Ident}. It allows the
966 placement of a comment into the object file and hence into the
967 executable file if the operating system permits such usage. The
968 difference is that @code{Comment}, unlike @code{Ident}, has
969 no limitations on placement of the pragma (it can be placed
970 anywhere in the main source unit), and if more than one pragma
971 is used, all comments are retained.
973 @node Pragma Common_Object
974 @unnumberedsec Pragma Common_Object
975 @findex Common_Object
980 pragma Common_Object (
981 [Internal =>] LOCAL_NAME,
982 [, [External =>] EXTERNAL_SYMBOL]
983 [, [Size =>] EXTERNAL_SYMBOL] );
987 | static_string_EXPRESSION
991 This pragma enables the shared use of variables stored in overlaid
992 linker areas corresponding to the use of @code{COMMON}
993 in Fortran. The single
994 object @var{local_name} is assigned to the area designated by
995 the @var{External} argument.
996 You may define a record to correspond to a series
997 of fields. The @var{size} argument
998 is syntax checked in GNAT, but otherwise ignored.
1000 @code{Common_Object} is not supported on all platforms. If no
1001 support is available, then the code generator will issue a message
1002 indicating that the necessary attribute for implementation of this
1003 pragma is not available.
1005 @node Pragma Compile_Time_Warning
1006 @unnumberedsec Pragma Compile_Time_Warning
1007 @findex Compile_Time_Warning
1011 @smallexample @c ada
1012 pragma Compile_Time_Warning
1013 (boolean_EXPRESSION, static_string_EXPRESSION);
1017 This pragma can be used to generate additional compile time warnings. It
1018 is particularly useful in generics, where warnings can be issued for
1019 specific problematic instantiations. The first parameter is a boolean
1020 expression. The pragma is effective only if the value of this expression
1021 is known at compile time, and has the value True. The set of expressions
1022 whose values are known at compile time includes all static boolean
1023 expressions, and also other values which the compiler can determine
1024 at compile time (e.g. the size of a record type set by an explicit
1025 size representation clause, or the value of a variable which was
1026 initialized to a constant and is known not to have been modified).
1027 If these conditions are met, a warning message is generated using
1028 the value given as the second argument. This string value may contain
1029 embedded ASCII.LF characters to break the message into multiple lines.
1031 @node Pragma Complex_Representation
1032 @unnumberedsec Pragma Complex_Representation
1033 @findex Complex_Representation
1037 @smallexample @c ada
1038 pragma Complex_Representation
1039 ([Entity =>] LOCAL_NAME);
1043 The @var{Entity} argument must be the name of a record type which has
1044 two fields of the same floating-point type. The effect of this pragma is
1045 to force gcc to use the special internal complex representation form for
1046 this record, which may be more efficient. Note that this may result in
1047 the code for this type not conforming to standard ABI (application
1048 binary interface) requirements for the handling of record types. For
1049 example, in some environments, there is a requirement for passing
1050 records by pointer, and the use of this pragma may result in passing
1051 this type in floating-point registers.
1053 @node Pragma Component_Alignment
1054 @unnumberedsec Pragma Component_Alignment
1055 @cindex Alignments of components
1056 @findex Component_Alignment
1060 @smallexample @c ada
1061 pragma Component_Alignment (
1062 [Form =>] ALIGNMENT_CHOICE
1063 [, [Name =>] type_LOCAL_NAME]);
1065 ALIGNMENT_CHOICE ::=
1073 Specifies the alignment of components in array or record types.
1074 The meaning of the @var{Form} argument is as follows:
1077 @findex Component_Size
1078 @item Component_Size
1079 Aligns scalar components and subcomponents of the array or record type
1080 on boundaries appropriate to their inherent size (naturally
1081 aligned). For example, 1-byte components are aligned on byte boundaries,
1082 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1083 integer components are aligned on 4-byte boundaries and so on. These
1084 alignment rules correspond to the normal rules for C compilers on all
1085 machines except the VAX@.
1087 @findex Component_Size_4
1088 @item Component_Size_4
1089 Naturally aligns components with a size of four or fewer
1090 bytes. Components that are larger than 4 bytes are placed on the next
1093 @findex Storage_Unit
1095 Specifies that array or record components are byte aligned, i.e.@:
1096 aligned on boundaries determined by the value of the constant
1097 @code{System.Storage_Unit}.
1101 Specifies that array or record components are aligned on default
1102 boundaries, appropriate to the underlying hardware or operating system or
1103 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1104 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1105 the @code{Default} choice is the same as @code{Component_Size} (natural
1110 If the @code{Name} parameter is present, @var{type_local_name} must
1111 refer to a local record or array type, and the specified alignment
1112 choice applies to the specified type. The use of
1113 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1114 @code{Component_Alignment} pragma to be ignored. The use of
1115 @code{Component_Alignment} together with a record representation clause
1116 is only effective for fields not specified by the representation clause.
1118 If the @code{Name} parameter is absent, the pragma can be used as either
1119 a configuration pragma, in which case it applies to one or more units in
1120 accordance with the normal rules for configuration pragmas, or it can be
1121 used within a declarative part, in which case it applies to types that
1122 are declared within this declarative part, or within any nested scope
1123 within this declarative part. In either case it specifies the alignment
1124 to be applied to any record or array type which has otherwise standard
1127 If the alignment for a record or array type is not specified (using
1128 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1129 clause), the GNAT uses the default alignment as described previously.
1131 @node Pragma Convention_Identifier
1132 @unnumberedsec Pragma Convention_Identifier
1133 @findex Convention_Identifier
1134 @cindex Conventions, synonyms
1138 @smallexample @c ada
1139 pragma Convention_Identifier (
1140 [Name =>] IDENTIFIER,
1141 [Convention =>] convention_IDENTIFIER);
1145 This pragma provides a mechanism for supplying synonyms for existing
1146 convention identifiers. The @code{Name} identifier can subsequently
1147 be used as a synonym for the given convention in other pragmas (including
1148 for example pragma @code{Import} or another @code{Convention_Identifier}
1149 pragma). As an example of the use of this, suppose you had legacy code
1150 which used Fortran77 as the identifier for Fortran. Then the pragma:
1152 @smallexample @c ada
1153 pragma Convention_Identifier (Fortran77, Fortran);
1157 would allow the use of the convention identifier @code{Fortran77} in
1158 subsequent code, avoiding the need to modify the sources. As another
1159 example, you could use this to parametrize convention requirements
1160 according to systems. Suppose you needed to use @code{Stdcall} on
1161 windows systems, and @code{C} on some other system, then you could
1162 define a convention identifier @code{Library} and use a single
1163 @code{Convention_Identifier} pragma to specify which convention
1164 would be used system-wide.
1166 @node Pragma CPP_Class
1167 @unnumberedsec Pragma CPP_Class
1169 @cindex Interfacing with C++
1173 @smallexample @c ada
1174 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1178 The argument denotes an entity in the current declarative region
1179 that is declared as a tagged or untagged record type. It indicates that
1180 the type corresponds to an externally declared C++ class type, and is to
1181 be laid out the same way that C++ would lay out the type.
1183 If (and only if) the type is tagged, at least one component in the
1184 record must be of type @code{Interfaces.CPP.Vtable_Ptr}, corresponding
1185 to the C++ Vtable (or Vtables in the case of multiple inheritance) used
1188 Types for which @code{CPP_Class} is specified do not have assignment or
1189 equality operators defined (such operations can be imported or declared
1190 as subprograms as required). Initialization is allowed only by
1191 constructor functions (see pragma @code{CPP_Constructor}).
1193 Pragma @code{CPP_Class} is intended primarily for automatic generation
1194 using an automatic binding generator tool.
1195 See @ref{Interfacing to C++} for related information.
1197 @node Pragma CPP_Constructor
1198 @unnumberedsec Pragma CPP_Constructor
1199 @cindex Interfacing with C++
1200 @findex CPP_Constructor
1204 @smallexample @c ada
1205 pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
1209 This pragma identifies an imported function (imported in the usual way
1210 with pragma @code{Import}) as corresponding to a C++
1211 constructor. The argument is a name that must have been
1212 previously mentioned in a pragma @code{Import}
1213 with @code{Convention} = @code{CPP}, and must be of one of the following
1218 @code{function @var{Fname} return @var{T}'Class}
1221 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1225 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1227 The first form is the default constructor, used when an object of type
1228 @var{T} is created on the Ada side with no explicit constructor. Other
1229 constructors (including the copy constructor, which is simply a special
1230 case of the second form in which the one and only argument is of type
1231 @var{T}), can only appear in two contexts:
1235 On the right side of an initialization of an object of type @var{T}.
1237 In an extension aggregate for an object of a type derived from @var{T}.
1241 Although the constructor is described as a function that returns a value
1242 on the Ada side, it is typically a procedure with an extra implicit
1243 argument (the object being initialized) at the implementation
1244 level. GNAT issues the appropriate call, whatever it is, to get the
1245 object properly initialized.
1247 In the case of derived objects, you may use one of two possible forms
1248 for declaring and creating an object:
1251 @item @code{New_Object : Derived_T}
1252 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1256 In the first case the default constructor is called and extension fields
1257 if any are initialized according to the default initialization
1258 expressions in the Ada declaration. In the second case, the given
1259 constructor is called and the extension aggregate indicates the explicit
1260 values of the extension fields.
1262 If no constructors are imported, it is impossible to create any objects
1263 on the Ada side. If no default constructor is imported, only the
1264 initialization forms using an explicit call to a constructor are
1267 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1268 using an automatic binding generator tool.
1269 See @ref{Interfacing to C++} for more related information.
1271 @node Pragma CPP_Virtual
1272 @unnumberedsec Pragma CPP_Virtual
1273 @cindex Interfacing to C++
1278 @smallexample @c ada
1281 [, [Vtable_Ptr =>] vtable_ENTITY,]
1282 [, [Position =>] static_integer_EXPRESSION]);
1286 This pragma serves the same function as pragma @code{Import} in that
1287 case of a virtual function imported from C++. The @var{Entity} argument
1289 primitive subprogram of a tagged type to which pragma @code{CPP_Class}
1290 applies. The @var{Vtable_Ptr} argument specifies
1291 the Vtable_Ptr component which contains the
1292 entry for this virtual function. The @var{Position} argument
1293 is the sequential number
1294 counting virtual functions for this Vtable starting at 1.
1296 The @code{Vtable_Ptr} and @code{Position} arguments may be omitted if
1297 there is one Vtable_Ptr present (single inheritance case) and all
1298 virtual functions are imported. In that case the compiler can deduce both
1301 No @code{External_Name} or @code{Link_Name} arguments are required for a
1302 virtual function, since it is always accessed indirectly via the
1303 appropriate Vtable entry.
1305 Pragma @code{CPP_Virtual} is intended primarily for automatic generation
1306 using an automatic binding generator tool.
1307 See @ref{Interfacing to C++} for related information.
1309 @node Pragma CPP_Vtable
1310 @unnumberedsec Pragma CPP_Vtable
1311 @cindex Interfacing with C++
1316 @smallexample @c ada
1319 [Vtable_Ptr =>] vtable_ENTITY,
1320 [Entry_Count =>] static_integer_EXPRESSION);
1324 Given a record to which the pragma @code{CPP_Class} applies,
1325 this pragma can be specified for each component of type
1326 @code{CPP.Interfaces.Vtable_Ptr}.
1327 @var{Entity} is the tagged type, @var{Vtable_Ptr}
1328 is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is
1329 the number of virtual functions on the C++ side. Not all of these
1330 functions need to be imported on the Ada side.
1332 You may omit the @code{CPP_Vtable} pragma if there is only one
1333 @code{Vtable_Ptr} component in the record and all virtual functions are
1334 imported on the Ada side (the default value for the entry count in this
1335 case is simply the total number of virtual functions).
1337 Pragma @code{CPP_Vtable} is intended primarily for automatic generation
1338 using an automatic binding generator tool.
1339 See @ref{Interfacing to C++} for related information.
1342 @unnumberedsec Pragma Debug
1347 @smallexample @c ada
1348 pragma Debug (PROCEDURE_CALL_WITHOUT_SEMICOLON);
1350 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1352 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1356 The argument has the syntactic form of an expression, meeting the
1357 syntactic requirements for pragmas.
1359 If assertions are not enabled on the command line, this pragma has no
1360 effect. If asserts are enabled, the semantics of the pragma is exactly
1361 equivalent to the procedure call statement corresponding to the argument
1362 with a terminating semicolon. Pragmas are permitted in sequences of
1363 declarations, so you can use pragma @code{Debug} to intersperse calls to
1364 debug procedures in the middle of declarations.
1366 @node Pragma Detect_Blocking
1367 @unnumberedsec Pragma Detect_Blocking
1368 @findex Detect_Blocking
1372 @smallexample @c ada
1373 pragma Detect_Blocking;
1377 This is a configuration pragma that forces the detection of potentially
1378 blocking operations within a protected operation, and to raise Program_Error
1381 @node Pragma Elaboration_Checks
1382 @unnumberedsec Pragma Elaboration_Checks
1383 @cindex Elaboration control
1384 @findex Elaboration_Checks
1388 @smallexample @c ada
1389 pragma Elaboration_Checks (Dynamic | Static);
1393 This is a configuration pragma that provides control over the
1394 elaboration model used by the compilation affected by the
1395 pragma. If the parameter is @code{Dynamic},
1396 then the dynamic elaboration
1397 model described in the Ada Reference Manual is used, as though
1398 the @code{-gnatE} switch had been specified on the command
1399 line. If the parameter is @code{Static}, then the default GNAT static
1400 model is used. This configuration pragma overrides the setting
1401 of the command line. For full details on the elaboration models
1402 used by the GNAT compiler, see section ``Elaboration Order
1403 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1405 @node Pragma Eliminate
1406 @unnumberedsec Pragma Eliminate
1407 @cindex Elimination of unused subprograms
1412 @smallexample @c ada
1414 [Unit_Name =>] IDENTIFIER |
1415 SELECTED_COMPONENT);
1418 [Unit_Name =>] IDENTIFIER |
1420 [Entity =>] IDENTIFIER |
1421 SELECTED_COMPONENT |
1423 [,OVERLOADING_RESOLUTION]);
1425 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1428 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1431 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1433 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1434 Result_Type => result_SUBTYPE_NAME]
1436 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1437 SUBTYPE_NAME ::= STRING_VALUE
1439 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1440 SOURCE_TRACE ::= STRING_VALUE
1442 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1446 This pragma indicates that the given entity is not used outside the
1447 compilation unit it is defined in. The entity must be an explicitly declared
1448 subprogram; this includes generic subprogram instances and
1449 subprograms declared in generic package instances.
1451 If the entity to be eliminated is a library level subprogram, then
1452 the first form of pragma @code{Eliminate} is used with only a single argument.
1453 In this form, the @code{Unit_Name} argument specifies the name of the
1454 library level unit to be eliminated.
1456 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1457 are required. If item is an entity of a library package, then the first
1458 argument specifies the unit name, and the second argument specifies
1459 the particular entity. If the second argument is in string form, it must
1460 correspond to the internal manner in which GNAT stores entity names (see
1461 compilation unit Namet in the compiler sources for details).
1463 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1464 to distinguish between overloaded subprograms. If a pragma does not contain
1465 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1466 subprograms denoted by the first two parameters.
1468 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1469 to be eliminated in a manner similar to that used for the extended
1470 @code{Import} and @code{Export} pragmas, except that the subtype names are
1471 always given as strings. At the moment, this form of distinguishing
1472 overloaded subprograms is implemented only partially, so we do not recommend
1473 using it for practical subprogram elimination.
1475 Note, that in case of a parameterless procedure its profile is represented
1476 as @code{Parameter_Types => ("")}
1478 Alternatively, the @code{Source_Location} parameter is used to specify
1479 which overloaded alternative is to be eliminated by pointing to the
1480 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1481 source text. The string literal (or concatenation of string literals)
1482 given as SOURCE_TRACE must have the following format:
1484 @smallexample @c ada
1485 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1490 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1491 FILE_NAME ::= STRING_LITERAL
1492 LINE_NUMBER ::= DIGIT @{DIGIT@}
1495 SOURCE_TRACE should be the short name of the source file (with no directory
1496 information), and LINE_NUMBER is supposed to point to the line where the
1497 defining name of the subprogram is located.
1499 For the subprograms that are not a part of generic instantiations, only one
1500 SOURCE_LOCATION is used. If a subprogram is declared in a package
1501 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1502 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1503 second one denotes the declaration of the corresponding subprogram in the
1504 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1505 in case of nested instantiations.
1507 The effect of the pragma is to allow the compiler to eliminate
1508 the code or data associated with the named entity. Any reference to
1509 an eliminated entity outside the compilation unit it is defined in,
1510 causes a compile time or link time error.
1512 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1513 in a system independent manner, with unused entities eliminated, without
1514 the requirement of modifying the source text. Normally the required set
1515 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1516 tool. Elimination of unused entities local to a compilation unit is
1517 automatic, without requiring the use of pragma @code{Eliminate}.
1519 Note that the reason this pragma takes string literals where names might
1520 be expected is that a pragma @code{Eliminate} can appear in a context where the
1521 relevant names are not visible.
1523 Note that any change in the source files that includes removing, splitting of
1524 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1527 @node Pragma Export_Exception
1528 @unnumberedsec Pragma Export_Exception
1530 @findex Export_Exception
1534 @smallexample @c ada
1535 pragma Export_Exception (
1536 [Internal =>] LOCAL_NAME,
1537 [, [External =>] EXTERNAL_SYMBOL,]
1538 [, [Form =>] Ada | VMS]
1539 [, [Code =>] static_integer_EXPRESSION]);
1543 | static_string_EXPRESSION
1547 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1548 causes the specified exception to be propagated outside of the Ada program,
1549 so that it can be handled by programs written in other OpenVMS languages.
1550 This pragma establishes an external name for an Ada exception and makes the
1551 name available to the OpenVMS Linker as a global symbol. For further details
1552 on this pragma, see the
1553 DEC Ada Language Reference Manual, section 13.9a3.2.
1555 @node Pragma Export_Function
1556 @unnumberedsec Pragma Export_Function
1557 @cindex Argument passing mechanisms
1558 @findex Export_Function
1563 @smallexample @c ada
1564 pragma Export_Function (
1565 [Internal =>] LOCAL_NAME,
1566 [, [External =>] EXTERNAL_SYMBOL]
1567 [, [Parameter_Types =>] PARAMETER_TYPES]
1568 [, [Result_Type =>] result_SUBTYPE_MARK]
1569 [, [Mechanism =>] MECHANISM]
1570 [, [Result_Mechanism =>] MECHANISM_NAME]);
1574 | static_string_EXPRESSION
1579 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1583 | subtype_Name ' Access
1587 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1589 MECHANISM_ASSOCIATION ::=
1590 [formal_parameter_NAME =>] MECHANISM_NAME
1598 Use this pragma to make a function externally callable and optionally
1599 provide information on mechanisms to be used for passing parameter and
1600 result values. We recommend, for the purposes of improving portability,
1601 this pragma always be used in conjunction with a separate pragma
1602 @code{Export}, which must precede the pragma @code{Export_Function}.
1603 GNAT does not require a separate pragma @code{Export}, but if none is
1604 present, @code{Convention Ada} is assumed, which is usually
1605 not what is wanted, so it is usually appropriate to use this
1606 pragma in conjunction with a @code{Export} or @code{Convention}
1607 pragma that specifies the desired foreign convention.
1608 Pragma @code{Export_Function}
1609 (and @code{Export}, if present) must appear in the same declarative
1610 region as the function to which they apply.
1612 @var{internal_name} must uniquely designate the function to which the
1613 pragma applies. If more than one function name exists of this name in
1614 the declarative part you must use the @code{Parameter_Types} and
1615 @code{Result_Type} parameters is mandatory to achieve the required
1616 unique designation. @var{subtype_ mark}s in these parameters must
1617 exactly match the subtypes in the corresponding function specification,
1618 using positional notation to match parameters with subtype marks.
1619 The form with an @code{'Access} attribute can be used to match an
1620 anonymous access parameter.
1623 @cindex Passing by descriptor
1624 Note that passing by descriptor is not supported, even on the OpenVMS
1627 @cindex Suppressing external name
1628 Special treatment is given if the EXTERNAL is an explicit null
1629 string or a static string expressions that evaluates to the null
1630 string. In this case, no external name is generated. This form
1631 still allows the specification of parameter mechanisms.
1633 @node Pragma Export_Object
1634 @unnumberedsec Pragma Export_Object
1635 @findex Export_Object
1639 @smallexample @c ada
1640 pragma Export_Object
1641 [Internal =>] LOCAL_NAME,
1642 [, [External =>] EXTERNAL_SYMBOL]
1643 [, [Size =>] EXTERNAL_SYMBOL]
1647 | static_string_EXPRESSION
1651 This pragma designates an object as exported, and apart from the
1652 extended rules for external symbols, is identical in effect to the use of
1653 the normal @code{Export} pragma applied to an object. You may use a
1654 separate Export pragma (and you probably should from the point of view
1655 of portability), but it is not required. @var{Size} is syntax checked,
1656 but otherwise ignored by GNAT@.
1658 @node Pragma Export_Procedure
1659 @unnumberedsec Pragma Export_Procedure
1660 @findex Export_Procedure
1664 @smallexample @c ada
1665 pragma Export_Procedure (
1666 [Internal =>] LOCAL_NAME
1667 [, [External =>] EXTERNAL_SYMBOL]
1668 [, [Parameter_Types =>] PARAMETER_TYPES]
1669 [, [Mechanism =>] MECHANISM]);
1673 | static_string_EXPRESSION
1678 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1682 | subtype_Name ' Access
1686 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1688 MECHANISM_ASSOCIATION ::=
1689 [formal_parameter_NAME =>] MECHANISM_NAME
1697 This pragma is identical to @code{Export_Function} except that it
1698 applies to a procedure rather than a function and the parameters
1699 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1700 GNAT does not require a separate pragma @code{Export}, but if none is
1701 present, @code{Convention Ada} is assumed, which is usually
1702 not what is wanted, so it is usually appropriate to use this
1703 pragma in conjunction with a @code{Export} or @code{Convention}
1704 pragma that specifies the desired foreign convention.
1707 @cindex Passing by descriptor
1708 Note that passing by descriptor is not supported, even on the OpenVMS
1711 @cindex Suppressing external name
1712 Special treatment is given if the EXTERNAL is an explicit null
1713 string or a static string expressions that evaluates to the null
1714 string. In this case, no external name is generated. This form
1715 still allows the specification of parameter mechanisms.
1717 @node Pragma Export_Value
1718 @unnumberedsec Pragma Export_Value
1719 @findex Export_Value
1723 @smallexample @c ada
1724 pragma Export_Value (
1725 [Value =>] static_integer_EXPRESSION,
1726 [Link_Name =>] static_string_EXPRESSION);
1730 This pragma serves to export a static integer value for external use.
1731 The first argument specifies the value to be exported. The Link_Name
1732 argument specifies the symbolic name to be associated with the integer
1733 value. This pragma is useful for defining a named static value in Ada
1734 that can be referenced in assembly language units to be linked with
1735 the application. This pragma is currently supported only for the
1736 AAMP target and is ignored for other targets.
1738 @node Pragma Export_Valued_Procedure
1739 @unnumberedsec Pragma Export_Valued_Procedure
1740 @findex Export_Valued_Procedure
1744 @smallexample @c ada
1745 pragma Export_Valued_Procedure (
1746 [Internal =>] LOCAL_NAME
1747 [, [External =>] EXTERNAL_SYMBOL]
1748 [, [Parameter_Types =>] PARAMETER_TYPES]
1749 [, [Mechanism =>] MECHANISM]);
1753 | static_string_EXPRESSION
1758 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1762 | subtype_Name ' Access
1766 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1768 MECHANISM_ASSOCIATION ::=
1769 [formal_parameter_NAME =>] MECHANISM_NAME
1777 This pragma is identical to @code{Export_Procedure} except that the
1778 first parameter of @var{local_name}, which must be present, must be of
1779 mode @code{OUT}, and externally the subprogram is treated as a function
1780 with this parameter as the result of the function. GNAT provides for
1781 this capability to allow the use of @code{OUT} and @code{IN OUT}
1782 parameters in interfacing to external functions (which are not permitted
1784 GNAT does not require a separate pragma @code{Export}, but if none is
1785 present, @code{Convention Ada} is assumed, which is almost certainly
1786 not what is wanted since the whole point of this pragma is to interface
1787 with foreign language functions, so it is usually appropriate to use this
1788 pragma in conjunction with a @code{Export} or @code{Convention}
1789 pragma that specifies the desired foreign convention.
1792 @cindex Passing by descriptor
1793 Note that passing by descriptor is not supported, even on the OpenVMS
1796 @cindex Suppressing external name
1797 Special treatment is given if the EXTERNAL is an explicit null
1798 string or a static string expressions that evaluates to the null
1799 string. In this case, no external name is generated. This form
1800 still allows the specification of parameter mechanisms.
1802 @node Pragma Extend_System
1803 @unnumberedsec Pragma Extend_System
1804 @cindex @code{system}, extending
1806 @findex Extend_System
1810 @smallexample @c ada
1811 pragma Extend_System ([Name =>] IDENTIFIER);
1815 This pragma is used to provide backwards compatibility with other
1816 implementations that extend the facilities of package @code{System}. In
1817 GNAT, @code{System} contains only the definitions that are present in
1818 the Ada 95 RM@. However, other implementations, notably the DEC Ada 83
1819 implementation, provide many extensions to package @code{System}.
1821 For each such implementation accommodated by this pragma, GNAT provides a
1822 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1823 implementation, which provides the required additional definitions. You
1824 can use this package in two ways. You can @code{with} it in the normal
1825 way and access entities either by selection or using a @code{use}
1826 clause. In this case no special processing is required.
1828 However, if existing code contains references such as
1829 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1830 definitions provided in package @code{System}, you may use this pragma
1831 to extend visibility in @code{System} in a non-standard way that
1832 provides greater compatibility with the existing code. Pragma
1833 @code{Extend_System} is a configuration pragma whose single argument is
1834 the name of the package containing the extended definition
1835 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
1836 control of this pragma will be processed using special visibility
1837 processing that looks in package @code{System.Aux_@var{xxx}} where
1838 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1839 package @code{System}, but not found in package @code{System}.
1841 You can use this pragma either to access a predefined @code{System}
1842 extension supplied with the compiler, for example @code{Aux_DEC} or
1843 you can construct your own extension unit following the above
1844 definition. Note that such a package is a child of @code{System}
1845 and thus is considered part of the implementation. To compile
1846 it you will have to use the appropriate switch for compiling
1847 system units. See the GNAT User's Guide for details.
1849 @node Pragma External
1850 @unnumberedsec Pragma External
1855 @smallexample @c ada
1857 [ Convention =>] convention_IDENTIFIER,
1858 [ Entity =>] local_NAME
1859 [, [External_Name =>] static_string_EXPRESSION ]
1860 [, [Link_Name =>] static_string_EXPRESSION ]);
1864 This pragma is identical in syntax and semantics to pragma
1865 @code{Export} as defined in the Ada Reference Manual. It is
1866 provided for compatibility with some Ada 83 compilers that
1867 used this pragma for exactly the same purposes as pragma
1868 @code{Export} before the latter was standardized.
1870 @node Pragma External_Name_Casing
1871 @unnumberedsec Pragma External_Name_Casing
1872 @cindex Dec Ada 83 casing compatibility
1873 @cindex External Names, casing
1874 @cindex Casing of External names
1875 @findex External_Name_Casing
1879 @smallexample @c ada
1880 pragma External_Name_Casing (
1881 Uppercase | Lowercase
1882 [, Uppercase | Lowercase | As_Is]);
1886 This pragma provides control over the casing of external names associated
1887 with Import and Export pragmas. There are two cases to consider:
1890 @item Implicit external names
1891 Implicit external names are derived from identifiers. The most common case
1892 arises when a standard Ada 95 Import or Export pragma is used with only two
1895 @smallexample @c ada
1896 pragma Import (C, C_Routine);
1900 Since Ada is a case insensitive language, the spelling of the identifier in
1901 the Ada source program does not provide any information on the desired
1902 casing of the external name, and so a convention is needed. In GNAT the
1903 default treatment is that such names are converted to all lower case
1904 letters. This corresponds to the normal C style in many environments.
1905 The first argument of pragma @code{External_Name_Casing} can be used to
1906 control this treatment. If @code{Uppercase} is specified, then the name
1907 will be forced to all uppercase letters. If @code{Lowercase} is specified,
1908 then the normal default of all lower case letters will be used.
1910 This same implicit treatment is also used in the case of extended DEC Ada 83
1911 compatible Import and Export pragmas where an external name is explicitly
1912 specified using an identifier rather than a string.
1914 @item Explicit external names
1915 Explicit external names are given as string literals. The most common case
1916 arises when a standard Ada 95 Import or Export pragma is used with three
1919 @smallexample @c ada
1920 pragma Import (C, C_Routine, "C_routine");
1924 In this case, the string literal normally provides the exact casing required
1925 for the external name. The second argument of pragma
1926 @code{External_Name_Casing} may be used to modify this behavior.
1927 If @code{Uppercase} is specified, then the name
1928 will be forced to all uppercase letters. If @code{Lowercase} is specified,
1929 then the name will be forced to all lowercase letters. A specification of
1930 @code{As_Is} provides the normal default behavior in which the casing is
1931 taken from the string provided.
1935 This pragma may appear anywhere that a pragma is valid. In particular, it
1936 can be used as a configuration pragma in the @file{gnat.adc} file, in which
1937 case it applies to all subsequent compilations, or it can be used as a program
1938 unit pragma, in which case it only applies to the current unit, or it can
1939 be used more locally to control individual Import/Export pragmas.
1941 It is primarily intended for use with OpenVMS systems, where many
1942 compilers convert all symbols to upper case by default. For interfacing to
1943 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
1946 @smallexample @c ada
1947 pragma External_Name_Casing (Uppercase, Uppercase);
1951 to enforce the upper casing of all external symbols.
1953 @node Pragma Finalize_Storage_Only
1954 @unnumberedsec Pragma Finalize_Storage_Only
1955 @findex Finalize_Storage_Only
1959 @smallexample @c ada
1960 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
1964 This pragma allows the compiler not to emit a Finalize call for objects
1965 defined at the library level. This is mostly useful for types where
1966 finalization is only used to deal with storage reclamation since in most
1967 environments it is not necessary to reclaim memory just before terminating
1968 execution, hence the name.
1970 @node Pragma Float_Representation
1971 @unnumberedsec Pragma Float_Representation
1973 @findex Float_Representation
1977 @smallexample @c ada
1978 pragma Float_Representation (FLOAT_REP);
1980 FLOAT_REP ::= VAX_Float | IEEE_Float
1985 allows control over the internal representation chosen for the predefined
1986 floating point types declared in the packages @code{Standard} and
1987 @code{System}. On all systems other than OpenVMS, the argument must
1988 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
1989 argument may be @code{VAX_Float} to specify the use of the VAX float
1990 format for the floating-point types in Standard. This requires that
1991 the standard runtime libraries be recompiled. See the
1992 description of the @code{GNAT LIBRARY} command in the OpenVMS version
1993 of the GNAT Users Guide for details on the use of this command.
1996 @unnumberedsec Pragma Ident
2001 @smallexample @c ada
2002 pragma Ident (static_string_EXPRESSION);
2006 This pragma provides a string identification in the generated object file,
2007 if the system supports the concept of this kind of identification string.
2008 This pragma is allowed only in the outermost declarative part or
2009 declarative items of a compilation unit. If more than one @code{Ident}
2010 pragma is given, only the last one processed is effective.
2012 On OpenVMS systems, the effect of the pragma is identical to the effect of
2013 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2014 maximum allowed length is 31 characters, so if it is important to
2015 maintain compatibility with this compiler, you should obey this length
2018 @node Pragma Import_Exception
2019 @unnumberedsec Pragma Import_Exception
2021 @findex Import_Exception
2025 @smallexample @c ada
2026 pragma Import_Exception (
2027 [Internal =>] LOCAL_NAME,
2028 [, [External =>] EXTERNAL_SYMBOL,]
2029 [, [Form =>] Ada | VMS]
2030 [, [Code =>] static_integer_EXPRESSION]);
2034 | static_string_EXPRESSION
2038 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2039 It allows OpenVMS conditions (for example, from OpenVMS system services or
2040 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2041 The pragma specifies that the exception associated with an exception
2042 declaration in an Ada program be defined externally (in non-Ada code).
2043 For further details on this pragma, see the
2044 DEC Ada Language Reference Manual, section 13.9a.3.1.
2046 @node Pragma Import_Function
2047 @unnumberedsec Pragma Import_Function
2048 @findex Import_Function
2052 @smallexample @c ada
2053 pragma Import_Function (
2054 [Internal =>] LOCAL_NAME,
2055 [, [External =>] EXTERNAL_SYMBOL]
2056 [, [Parameter_Types =>] PARAMETER_TYPES]
2057 [, [Result_Type =>] SUBTYPE_MARK]
2058 [, [Mechanism =>] MECHANISM]
2059 [, [Result_Mechanism =>] MECHANISM_NAME]
2060 [, [First_Optional_Parameter =>] IDENTIFIER]);
2064 | static_string_EXPRESSION
2068 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2072 | subtype_Name ' Access
2076 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2078 MECHANISM_ASSOCIATION ::=
2079 [formal_parameter_NAME =>] MECHANISM_NAME
2084 | Descriptor [([Class =>] CLASS_NAME)]
2086 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2090 This pragma is used in conjunction with a pragma @code{Import} to
2091 specify additional information for an imported function. The pragma
2092 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2093 @code{Import_Function} pragma and both must appear in the same
2094 declarative part as the function specification.
2096 The @var{Internal} argument must uniquely designate
2097 the function to which the
2098 pragma applies. If more than one function name exists of this name in
2099 the declarative part you must use the @code{Parameter_Types} and
2100 @var{Result_Type} parameters to achieve the required unique
2101 designation. Subtype marks in these parameters must exactly match the
2102 subtypes in the corresponding function specification, using positional
2103 notation to match parameters with subtype marks.
2104 The form with an @code{'Access} attribute can be used to match an
2105 anonymous access parameter.
2107 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2108 parameters to specify passing mechanisms for the
2109 parameters and result. If you specify a single mechanism name, it
2110 applies to all parameters. Otherwise you may specify a mechanism on a
2111 parameter by parameter basis using either positional or named
2112 notation. If the mechanism is not specified, the default mechanism
2116 @cindex Passing by descriptor
2117 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2119 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2120 It specifies that the designated parameter and all following parameters
2121 are optional, meaning that they are not passed at the generated code
2122 level (this is distinct from the notion of optional parameters in Ada
2123 where the parameters are passed anyway with the designated optional
2124 parameters). All optional parameters must be of mode @code{IN} and have
2125 default parameter values that are either known at compile time
2126 expressions, or uses of the @code{'Null_Parameter} attribute.
2128 @node Pragma Import_Object
2129 @unnumberedsec Pragma Import_Object
2130 @findex Import_Object
2134 @smallexample @c ada
2135 pragma Import_Object
2136 [Internal =>] LOCAL_NAME,
2137 [, [External =>] EXTERNAL_SYMBOL],
2138 [, [Size =>] EXTERNAL_SYMBOL]);
2142 | static_string_EXPRESSION
2146 This pragma designates an object as imported, and apart from the
2147 extended rules for external symbols, is identical in effect to the use of
2148 the normal @code{Import} pragma applied to an object. Unlike the
2149 subprogram case, you need not use a separate @code{Import} pragma,
2150 although you may do so (and probably should do so from a portability
2151 point of view). @var{size} is syntax checked, but otherwise ignored by
2154 @node Pragma Import_Procedure
2155 @unnumberedsec Pragma Import_Procedure
2156 @findex Import_Procedure
2160 @smallexample @c ada
2161 pragma Import_Procedure (
2162 [Internal =>] LOCAL_NAME,
2163 [, [External =>] EXTERNAL_SYMBOL]
2164 [, [Parameter_Types =>] PARAMETER_TYPES]
2165 [, [Mechanism =>] MECHANISM]
2166 [, [First_Optional_Parameter =>] IDENTIFIER]);
2170 | static_string_EXPRESSION
2174 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2178 | subtype_Name ' Access
2182 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2184 MECHANISM_ASSOCIATION ::=
2185 [formal_parameter_NAME =>] MECHANISM_NAME
2190 | Descriptor [([Class =>] CLASS_NAME)]
2192 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2196 This pragma is identical to @code{Import_Function} except that it
2197 applies to a procedure rather than a function and the parameters
2198 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2200 @node Pragma Import_Valued_Procedure
2201 @unnumberedsec Pragma Import_Valued_Procedure
2202 @findex Import_Valued_Procedure
2206 @smallexample @c ada
2207 pragma Import_Valued_Procedure (
2208 [Internal =>] LOCAL_NAME,
2209 [, [External =>] EXTERNAL_SYMBOL]
2210 [, [Parameter_Types =>] PARAMETER_TYPES]
2211 [, [Mechanism =>] MECHANISM]
2212 [, [First_Optional_Parameter =>] IDENTIFIER]);
2216 | static_string_EXPRESSION
2220 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2224 | subtype_Name ' Access
2228 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2230 MECHANISM_ASSOCIATION ::=
2231 [formal_parameter_NAME =>] MECHANISM_NAME
2236 | Descriptor [([Class =>] CLASS_NAME)]
2238 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2242 This pragma is identical to @code{Import_Procedure} except that the
2243 first parameter of @var{local_name}, which must be present, must be of
2244 mode @code{OUT}, and externally the subprogram is treated as a function
2245 with this parameter as the result of the function. The purpose of this
2246 capability is to allow the use of @code{OUT} and @code{IN OUT}
2247 parameters in interfacing to external functions (which are not permitted
2248 in Ada functions). You may optionally use the @code{Mechanism}
2249 parameters to specify passing mechanisms for the parameters.
2250 If you specify a single mechanism name, it applies to all parameters.
2251 Otherwise you may specify a mechanism on a parameter by parameter
2252 basis using either positional or named notation. If the mechanism is not
2253 specified, the default mechanism is used.
2255 Note that it is important to use this pragma in conjunction with a separate
2256 pragma Import that specifies the desired convention, since otherwise the
2257 default convention is Ada, which is almost certainly not what is required.
2259 @node Pragma Initialize_Scalars
2260 @unnumberedsec Pragma Initialize_Scalars
2261 @findex Initialize_Scalars
2262 @cindex debugging with Initialize_Scalars
2266 @smallexample @c ada
2267 pragma Initialize_Scalars;
2271 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2272 two important differences. First, there is no requirement for the pragma
2273 to be used uniformly in all units of a partition, in particular, it is fine
2274 to use this just for some or all of the application units of a partition,
2275 without needing to recompile the run-time library.
2277 In the case where some units are compiled with the pragma, and some without,
2278 then a declaration of a variable where the type is defined in package
2279 Standard or is locally declared will always be subject to initialization,
2280 as will any declaration of a scalar variable. For composite variables,
2281 whether the variable is initialized may also depend on whether the package
2282 in which the type of the variable is declared is compiled with the pragma.
2284 The other important difference is that you can control the value used
2285 for initializing scalar objects. At bind time, you can select several
2286 options for initialization. You can
2287 initialize with invalid values (similar to Normalize_Scalars, though for
2288 Initialize_Scalars it is not always possible to determine the invalid
2289 values in complex cases like signed component fields with non-standard
2290 sizes). You can also initialize with high or
2291 low values, or with a specified bit pattern. See the users guide for binder
2292 options for specifying these cases.
2294 This means that you can compile a program, and then without having to
2295 recompile the program, you can run it with different values being used
2296 for initializing otherwise uninitialized values, to test if your program
2297 behavior depends on the choice. Of course the behavior should not change,
2298 and if it does, then most likely you have an erroneous reference to an
2299 uninitialized value.
2301 It is even possible to change the value at execution time eliminating even
2302 the need to rebind with a different switch using an environment variable.
2303 See the GNAT users guide for details.
2305 Note that pragma @code{Initialize_Scalars} is particularly useful in
2306 conjunction with the enhanced validity checking that is now provided
2307 in GNAT, which checks for invalid values under more conditions.
2308 Using this feature (see description of the @code{-gnatV} flag in the
2309 users guide) in conjunction with pragma @code{Initialize_Scalars}
2310 provides a powerful new tool to assist in the detection of problems
2311 caused by uninitialized variables.
2313 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2314 effect on the generated code. This may cause your code to be
2315 substantially larger. It may also cause an increase in the amount
2316 of stack required, so it is probably a good idea to turn on stack
2317 checking (see description of stack checking in the GNAT users guide)
2318 when using this pragma.
2320 @node Pragma Inline_Always
2321 @unnumberedsec Pragma Inline_Always
2322 @findex Inline_Always
2326 @smallexample @c ada
2327 pragma Inline_Always (NAME [, NAME]);
2331 Similar to pragma @code{Inline} except that inlining is not subject to
2332 the use of option @code{-gnatn} and the inlining happens regardless of
2333 whether this option is used.
2335 @node Pragma Inline_Generic
2336 @unnumberedsec Pragma Inline_Generic
2337 @findex Inline_Generic
2341 @smallexample @c ada
2342 pragma Inline_Generic (generic_package_NAME);
2346 This is implemented for compatibility with DEC Ada 83 and is recognized,
2347 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2348 by default when using GNAT@.
2350 @node Pragma Interface
2351 @unnumberedsec Pragma Interface
2356 @smallexample @c ada
2358 [Convention =>] convention_identifier,
2359 [Entity =>] local_name
2360 [, [External_Name =>] static_string_expression],
2361 [, [Link_Name =>] static_string_expression]);
2365 This pragma is identical in syntax and semantics to
2366 the standard Ada 95 pragma @code{Import}. It is provided for compatibility
2367 with Ada 83. The definition is upwards compatible both with pragma
2368 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2369 with some extended implementations of this pragma in certain Ada 83
2372 @node Pragma Interface_Name
2373 @unnumberedsec Pragma Interface_Name
2374 @findex Interface_Name
2378 @smallexample @c ada
2379 pragma Interface_Name (
2380 [Entity =>] LOCAL_NAME
2381 [, [External_Name =>] static_string_EXPRESSION]
2382 [, [Link_Name =>] static_string_EXPRESSION]);
2386 This pragma provides an alternative way of specifying the interface name
2387 for an interfaced subprogram, and is provided for compatibility with Ada
2388 83 compilers that use the pragma for this purpose. You must provide at
2389 least one of @var{External_Name} or @var{Link_Name}.
2391 @node Pragma Interrupt_Handler
2392 @unnumberedsec Pragma Interrupt_Handler
2393 @findex Interrupt_Handler
2397 @smallexample @c ada
2398 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2402 This program unit pragma is supported for parameterless protected procedures
2403 as described in Annex C of the Ada Reference Manual. On the AAMP target
2404 the pragma can also be specified for nonprotected parameterless procedures
2405 that are declared at the library level (which includes procedures
2406 declared at the top level of a library package). In the case of AAMP,
2407 when this pragma is applied to a nonprotected procedure, the instruction
2408 @code{IERET} is generated for returns from the procedure, enabling
2409 maskable interrupts, in place of the normal return instruction.
2411 @node Pragma Interrupt_State
2412 @unnumberedsec Pragma Interrupt_State
2413 @findex Interrupt_State
2417 @smallexample @c ada
2418 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2422 Normally certain interrupts are reserved to the implementation. Any attempt
2423 to attach an interrupt causes Program_Error to be raised, as described in
2424 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
2425 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
2426 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2427 interrupt execution. Additionally, signals such as @code{SIGSEGV},
2428 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2429 Ada exceptions, or used to implement run-time functions such as the
2430 @code{abort} statement and stack overflow checking.
2432 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2433 such uses of interrupts. It subsumes the functionality of pragma
2434 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
2435 available on OS/2, Windows or VMS. On all other platforms than VxWorks,
2436 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2437 and may be used to mark interrupts required by the board support package
2440 Interrupts can be in one of three states:
2444 The interrupt is reserved (no Ada handler can be installed), and the
2445 Ada run-time may not install a handler. As a result you are guaranteed
2446 standard system default action if this interrupt is raised.
2450 The interrupt is reserved (no Ada handler can be installed). The run time
2451 is allowed to install a handler for internal control purposes, but is
2452 not required to do so.
2456 The interrupt is unreserved. The user may install a handler to provide
2461 These states are the allowed values of the @code{State} parameter of the
2462 pragma. The @code{Name} parameter is a value of the type
2463 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
2464 @code{Ada.Interrupts.Names}.
2466 This is a configuration pragma, and the binder will check that there
2467 are no inconsistencies between different units in a partition in how a
2468 given interrupt is specified. It may appear anywhere a pragma is legal.
2470 The effect is to move the interrupt to the specified state.
2472 By declaring interrupts to be SYSTEM, you guarantee the standard system
2473 action, such as a core dump.
2475 By declaring interrupts to be USER, you guarantee that you can install
2478 Note that certain signals on many operating systems cannot be caught and
2479 handled by applications. In such cases, the pragma is ignored. See the
2480 operating system documentation, or the value of the array @code{Reserved}
2481 declared in the specification of package @code{System.OS_Interface}.
2483 Overriding the default state of signals used by the Ada runtime may interfere
2484 with an application's runtime behavior in the cases of the synchronous signals,
2485 and in the case of the signal used to implement the @code{abort} statement.
2487 @node Pragma Keep_Names
2488 @unnumberedsec Pragma Keep_Names
2493 @smallexample @c ada
2494 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2498 The @var{LOCAL_NAME} argument
2499 must refer to an enumeration first subtype
2500 in the current declarative part. The effect is to retain the enumeration
2501 literal names for use by @code{Image} and @code{Value} even if a global
2502 @code{Discard_Names} pragma applies. This is useful when you want to
2503 generally suppress enumeration literal names and for example you therefore
2504 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2505 want to retain the names for specific enumeration types.
2507 @node Pragma License
2508 @unnumberedsec Pragma License
2510 @cindex License checking
2514 @smallexample @c ada
2515 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2519 This pragma is provided to allow automated checking for appropriate license
2520 conditions with respect to the standard and modified GPL@. A pragma
2521 @code{License}, which is a configuration pragma that typically appears at
2522 the start of a source file or in a separate @file{gnat.adc} file, specifies
2523 the licensing conditions of a unit as follows:
2527 This is used for a unit that can be freely used with no license restrictions.
2528 Examples of such units are public domain units, and units from the Ada
2532 This is used for a unit that is licensed under the unmodified GPL, and which
2533 therefore cannot be @code{with}'ed by a restricted unit.
2536 This is used for a unit licensed under the GNAT modified GPL that includes
2537 a special exception paragraph that specifically permits the inclusion of
2538 the unit in programs without requiring the entire program to be released
2539 under the GPL@. This is the license used for the GNAT run-time which ensures
2540 that the run-time can be used freely in any program without GPL concerns.
2543 This is used for a unit that is restricted in that it is not permitted to
2544 depend on units that are licensed under the GPL@. Typical examples are
2545 proprietary code that is to be released under more restrictive license
2546 conditions. Note that restricted units are permitted to @code{with} units
2547 which are licensed under the modified GPL (this is the whole point of the
2553 Normally a unit with no @code{License} pragma is considered to have an
2554 unknown license, and no checking is done. However, standard GNAT headers
2555 are recognized, and license information is derived from them as follows.
2559 A GNAT license header starts with a line containing 78 hyphens. The following
2560 comment text is searched for the appearance of any of the following strings.
2562 If the string ``GNU General Public License'' is found, then the unit is assumed
2563 to have GPL license, unless the string ``As a special exception'' follows, in
2564 which case the license is assumed to be modified GPL@.
2566 If one of the strings
2567 ``This specification is adapted from the Ada Semantic Interface'' or
2568 ``This specification is derived from the Ada Reference Manual'' is found
2569 then the unit is assumed to be unrestricted.
2573 These default actions means that a program with a restricted license pragma
2574 will automatically get warnings if a GPL unit is inappropriately
2575 @code{with}'ed. For example, the program:
2577 @smallexample @c ada
2580 procedure Secret_Stuff is
2586 if compiled with pragma @code{License} (@code{Restricted}) in a
2587 @file{gnat.adc} file will generate the warning:
2592 >>> license of withed unit "Sem_Ch3" is incompatible
2594 2. with GNAT.Sockets;
2595 3. procedure Secret_Stuff is
2599 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2600 compiler and is licensed under the
2601 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2602 run time, and is therefore licensed under the modified GPL@.
2604 @node Pragma Link_With
2605 @unnumberedsec Pragma Link_With
2610 @smallexample @c ada
2611 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2615 This pragma is provided for compatibility with certain Ada 83 compilers.
2616 It has exactly the same effect as pragma @code{Linker_Options} except
2617 that spaces occurring within one of the string expressions are treated
2618 as separators. For example, in the following case:
2620 @smallexample @c ada
2621 pragma Link_With ("-labc -ldef");
2625 results in passing the strings @code{-labc} and @code{-ldef} as two
2626 separate arguments to the linker. In addition pragma Link_With allows
2627 multiple arguments, with the same effect as successive pragmas.
2629 @node Pragma Linker_Alias
2630 @unnumberedsec Pragma Linker_Alias
2631 @findex Linker_Alias
2635 @smallexample @c ada
2636 pragma Linker_Alias (
2637 [Entity =>] LOCAL_NAME
2638 [Alias =>] static_string_EXPRESSION);
2642 This pragma establishes a linker alias for the given named entity. For
2643 further details on the exact effect, consult the GCC manual.
2645 @node Pragma Linker_Section
2646 @unnumberedsec Pragma Linker_Section
2647 @findex Linker_Section
2651 @smallexample @c ada
2652 pragma Linker_Section (
2653 [Entity =>] LOCAL_NAME
2654 [Section =>] static_string_EXPRESSION);
2658 This pragma specifies the name of the linker section for the given entity.
2659 For further details on the exact effect, consult the GCC manual.
2661 @node Pragma Long_Float
2662 @unnumberedsec Pragma Long_Float
2668 @smallexample @c ada
2669 pragma Long_Float (FLOAT_FORMAT);
2671 FLOAT_FORMAT ::= D_Float | G_Float
2675 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2676 It allows control over the internal representation chosen for the predefined
2677 type @code{Long_Float} and for floating point type representations with
2678 @code{digits} specified in the range 7 through 15.
2679 For further details on this pragma, see the
2680 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
2681 this pragma, the standard runtime libraries must be recompiled. See the
2682 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2683 of the GNAT User's Guide for details on the use of this command.
2685 @node Pragma Machine_Attribute
2686 @unnumberedsec Pragma Machine_Attribute
2687 @findex Machine_Attribute
2691 @smallexample @c ada
2692 pragma Machine_Attribute (
2693 [Attribute_Name =>] string_EXPRESSION,
2694 [Entity =>] LOCAL_NAME);
2698 Machine dependent attributes can be specified for types and/or
2699 declarations. Currently only subprogram entities are supported. This
2700 pragma is semantically equivalent to
2701 @code{__attribute__((@var{string_expression}))} in GNU C,
2702 where @code{@var{string_expression}} is
2703 recognized by the GNU C macros @code{VALID_MACHINE_TYPE_ATTRIBUTE} and
2704 @code{VALID_MACHINE_DECL_ATTRIBUTE} which are defined in the
2705 configuration header file @file{tm.h} for each machine. See the GCC
2706 manual for further information.
2708 @node Pragma Main_Storage
2709 @unnumberedsec Pragma Main_Storage
2711 @findex Main_Storage
2715 @smallexample @c ada
2717 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2719 MAIN_STORAGE_OPTION ::=
2720 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2721 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
2726 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
2727 no effect in GNAT, other than being syntax checked. Note that the pragma
2728 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2730 @node Pragma No_Return
2731 @unnumberedsec Pragma No_Return
2736 @smallexample @c ada
2737 pragma No_Return (procedure_LOCAL_NAME);
2741 @var{procedure_local_NAME} must refer to one or more procedure
2742 declarations in the current declarative part. A procedure to which this
2743 pragma is applied may not contain any explicit @code{return} statements,
2744 and also may not contain any implicit return statements from falling off
2745 the end of a statement sequence. One use of this pragma is to identify
2746 procedures whose only purpose is to raise an exception.
2748 Another use of this pragma is to suppress incorrect warnings about
2749 missing returns in functions, where the last statement of a function
2750 statement sequence is a call to such a procedure.
2752 @node Pragma Normalize_Scalars
2753 @unnumberedsec Pragma Normalize_Scalars
2754 @findex Normalize_Scalars
2758 @smallexample @c ada
2759 pragma Normalize_Scalars;
2763 This is a language defined pragma which is fully implemented in GNAT@. The
2764 effect is to cause all scalar objects that are not otherwise initialized
2765 to be initialized. The initial values are implementation dependent and
2769 @item Standard.Character
2771 Objects whose root type is Standard.Character are initialized to
2772 Character'Last unless the subtype range excludes NUL (in which case
2773 NUL is used). This choice will always generate an invalid value if
2776 @item Standard.Wide_Character
2778 Objects whose root type is Standard.Wide_Character are initialized to
2779 Wide_Character'Last unless the subtype range excludes NUL (in which case
2780 NUL is used). This choice will always generate an invalid value if
2783 @item Standard.Wide_Wide_Character
2785 Objects whose root type is Standard.Wide_Wide_Character are initialized to
2786 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
2787 which case NUL is used). This choice will always generate an invalid value if
2792 Objects of an integer type are treated differently depending on whether
2793 negative values are present in the subtype. If no negative values are
2794 present, then all one bits is used as the initial value except in the
2795 special case where zero is excluded from the subtype, in which case
2796 all zero bits are used. This choice will always generate an invalid
2797 value if one exists.
2799 For subtypes with negative values present, the largest negative number
2800 is used, except in the unusual case where this largest negative number
2801 is in the subtype, and the largest positive number is not, in which case
2802 the largest positive value is used. This choice will always generate
2803 an invalid value if one exists.
2805 @item Floating-Point Types
2806 Objects of all floating-point types are initialized to all 1-bits. For
2807 standard IEEE format, this corresponds to a NaN (not a number) which is
2808 indeed an invalid value.
2810 @item Fixed-Point Types
2811 Objects of all fixed-point types are treated as described above for integers,
2812 with the rules applying to the underlying integer value used to represent
2813 the fixed-point value.
2816 Objects of a modular type are initialized to all one bits, except in
2817 the special case where zero is excluded from the subtype, in which
2818 case all zero bits are used. This choice will always generate an
2819 invalid value if one exists.
2821 @item Enumeration types
2822 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
2823 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
2824 whose Pos value is zero, in which case a code of zero is used. This choice
2825 will always generate an invalid value if one exists.
2829 @node Pragma Obsolescent
2830 @unnumberedsec Pragma Obsolescent
2835 @smallexample @c ada
2836 pragma Obsolescent [(static_string_EXPRESSION)];
2840 This pragma must occur immediately following a subprogram
2841 declaration. It indicates that the associated function or procedure
2842 is considered obsolescent and should not be used. Typically this is
2843 used when an API must be modified by eventually removing or modifying
2844 existing subprograms. The pragma can be used at an intermediate stage
2845 when the subprogram is still present, but will be removed later.
2847 The effect of this pragma is to output a warning message that the
2848 subprogram is obsolescent if the appropriate warning option in the
2849 compiler is activated. If a parameter is present, then a second
2850 warning message is given containing this text.
2852 @node Pragma Passive
2853 @unnumberedsec Pragma Passive
2858 @smallexample @c ada
2859 pragma Passive ([Semaphore | No]);
2863 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
2864 compatibility with DEC Ada 83 implementations, where it is used within a
2865 task definition to request that a task be made passive. If the argument
2866 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
2867 treats the pragma as an assertion that the containing task is passive
2868 and that optimization of context switch with this task is permitted and
2869 desired. If the argument @code{No} is present, the task must not be
2870 optimized. GNAT does not attempt to optimize any tasks in this manner
2871 (since protected objects are available in place of passive tasks).
2873 @node Pragma Polling
2874 @unnumberedsec Pragma Polling
2879 @smallexample @c ada
2880 pragma Polling (ON | OFF);
2884 This pragma controls the generation of polling code. This is normally off.
2885 If @code{pragma Polling (ON)} is used then periodic calls are generated to
2886 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
2887 runtime library, and can be found in file @file{a-excpol.adb}.
2889 Pragma @code{Polling} can appear as a configuration pragma (for example it
2890 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
2891 can be used in the statement or declaration sequence to control polling
2894 A call to the polling routine is generated at the start of every loop and
2895 at the start of every subprogram call. This guarantees that the @code{Poll}
2896 routine is called frequently, and places an upper bound (determined by
2897 the complexity of the code) on the period between two @code{Poll} calls.
2899 The primary purpose of the polling interface is to enable asynchronous
2900 aborts on targets that cannot otherwise support it (for example Windows
2901 NT), but it may be used for any other purpose requiring periodic polling.
2902 The standard version is null, and can be replaced by a user program. This
2903 will require re-compilation of the @code{Ada.Exceptions} package that can
2904 be found in files @file{a-except.ads} and @file{a-except.adb}.
2906 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
2907 distribution) is used to enable the asynchronous abort capability on
2908 targets that do not normally support the capability. The version of
2909 @code{Poll} in this file makes a call to the appropriate runtime routine
2910 to test for an abort condition.
2912 Note that polling can also be enabled by use of the @code{-gnatP} switch. See
2913 the @cite{GNAT User's Guide} for details.
2915 @node Pragma Profile (Ravenscar)
2916 @unnumberedsec Pragma Profile (Ravenscar)
2921 @smallexample @c ada
2922 pragma Profile (Ravenscar);
2926 A configuration pragma that establishes the following set of configuration
2930 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
2931 [RM D.2.2] Tasks are dispatched following a preemptive
2932 priority-ordered scheduling policy.
2934 @item Locking_Policy (Ceiling_Locking)
2935 [RM D.3] While tasks and interrupts execute a protected action, they inherit
2936 the ceiling priority of the corresponding protected object.
2938 @c @item Detect_Blocking
2939 @c This pragma forces the detection of potentially blocking operations within a
2940 @c protected operation, and to raise Program_Error if that happens.
2944 plus the following set of restrictions:
2947 @item Max_Entry_Queue_Length = 1
2948 Defines the maximum number of calls that are queued on a (protected) entry.
2949 Note that this restrictions is checked at run time. Violation of this
2950 restriction results in the raising of Program_Error exception at the point of
2951 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
2952 always 1 and hence no task can be queued on a protected entry.
2954 @item Max_Protected_Entries = 1
2955 [RM D.7] Specifies the maximum number of entries per protected type. The
2956 bounds of every entry family of a protected unit shall be static, or shall be
2957 defined by a discriminant of a subtype whose corresponding bound is static.
2958 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
2960 @item Max_Task_Entries = 0
2961 [RM D.7] Specifies the maximum number of entries
2962 per task. The bounds of every entry family
2963 of a task unit shall be static, or shall be
2964 defined by a discriminant of a subtype whose
2965 corresponding bound is static. A value of zero
2966 indicates that no rendezvous are possible. For
2967 the Profile (Ravenscar), the value of Max_Task_Entries is always
2970 @item No_Abort_Statements
2971 [RM D.7] There are no abort_statements, and there are
2972 no calls to Task_Identification.Abort_Task.
2974 @item No_Asynchronous_Control
2975 [RM D.7] There are no semantic dependences on the package
2976 Asynchronous_Task_Control.
2979 There are no semantic dependencies on the package Ada.Calendar.
2981 @item No_Dynamic_Attachment
2982 There is no call to any of the operations defined in package Ada.Interrupts
2983 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
2984 Detach_Handler, and Reference).
2986 @item No_Dynamic_Priorities
2987 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
2989 @item No_Implicit_Heap_Allocations
2990 [RM D.7] No constructs are allowed to cause implicit heap allocation.
2992 @item No_Local_Protected_Objects
2993 Protected objects and access types that designate
2994 such objects shall be declared only at library level.
2996 @item No_Protected_Type_Allocators
2997 There are no allocators for protected types or
2998 types containing protected subcomponents.
3000 @item No_Relative_Delay
3001 There are no delay_relative statements.
3003 @item No_Requeue_Statements
3004 Requeue statements are not allowed.
3006 @item No_Select_Statements
3007 There are no select_statements.
3009 @item No_Task_Allocators
3010 [RM D.7] There are no allocators for task types
3011 or types containing task subcomponents.
3013 @item No_Task_Attributes_Package
3014 There are no semantic dependencies on the Ada.Task_Attributes package.
3016 @item No_Task_Hierarchy
3017 [RM D.7] All (non-environment) tasks depend
3018 directly on the environment task of the partition.
3020 @item No_Task_Termination
3021 Tasks which terminate are erroneous.
3023 @item Simple_Barriers
3024 Entry barrier condition expressions shall be either static
3025 boolean expressions or boolean objects which are declared in
3026 the protected type which contains the entry.
3030 This set of configuration pragmas and restrictions correspond to the
3031 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3032 published by the @cite{International Real-Time Ada Workshop}, 1997,
3033 and whose most recent description is available at
3034 @url{ftp://ftp.openravenscar.org/openravenscar/ravenscar00.pdf}.
3036 The original definition of the profile was revised at subsequent IRTAW
3037 meetings. It has been included in the ISO
3038 @cite{Guide for the Use of the Ada Programming Language in High
3039 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3040 the next revision of the standard. The formal definition given by
3041 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3042 AI-305) available at
3043 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3044 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3047 The above set is a superset of the restrictions provided by pragma
3048 @code{Profile (Restricted)}, it includes six additional restrictions
3049 (@code{Simple_Barriers}, @code{No_Select_Statements},
3050 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3051 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
3052 that pragma @code{Profile (Ravenscar)}, like the pragma
3053 @code{Profile (Restricted)},
3054 automatically causes the use of a simplified,
3055 more efficient version of the tasking run-time system.
3057 @node Pragma Profile (Restricted)
3058 @unnumberedsec Pragma Profile (Restricted)
3059 @findex Restricted Run Time
3063 @smallexample @c ada
3064 pragma Profile (Restricted);
3068 A configuration pragma that establishes the following set of restrictions:
3071 @item No_Abort_Statements
3072 @item No_Entry_Queue
3073 @item No_Task_Hierarchy
3074 @item No_Task_Allocators
3075 @item No_Dynamic_Priorities
3076 @item No_Terminate_Alternatives
3077 @item No_Dynamic_Attachment
3078 @item No_Protected_Type_Allocators
3079 @item No_Local_Protected_Objects
3080 @item No_Requeue_Statements
3081 @item No_Task_Attributes_Package
3082 @item Max_Asynchronous_Select_Nesting = 0
3083 @item Max_Task_Entries = 0
3084 @item Max_Protected_Entries = 1
3085 @item Max_Select_Alternatives = 0
3089 This set of restrictions causes the automatic selection of a simplified
3090 version of the run time that provides improved performance for the
3091 limited set of tasking functionality permitted by this set of restrictions.
3093 @node Pragma Propagate_Exceptions
3094 @unnumberedsec Pragma Propagate_Exceptions
3095 @findex Propagate_Exceptions
3096 @cindex Zero Cost Exceptions
3100 @smallexample @c ada
3101 pragma Propagate_Exceptions (subprogram_LOCAL_NAME);
3105 This pragma indicates that the given entity, which is the name of an
3106 imported foreign-language subprogram may receive an Ada exception,
3107 and that the exception should be propagated. It is relevant only if
3108 zero cost exception handling is in use, and is thus never needed if
3109 the alternative @code{longjmp} / @code{setjmp} implementation of
3110 exceptions is used (although it is harmless to use it in such cases).
3112 The implementation of fast exceptions always properly propagates
3113 exceptions through Ada code, as described in the Ada Reference Manual.
3114 However, this manual is silent about the propagation of exceptions
3115 through foreign code. For example, consider the
3116 situation where @code{P1} calls
3117 @code{P2}, and @code{P2} calls @code{P3}, where
3118 @code{P1} and @code{P3} are in Ada, but @code{P2} is in C@.
3119 @code{P3} raises an Ada exception. The question is whether or not
3120 it will be propagated through @code{P2} and can be handled in
3123 For the @code{longjmp} / @code{setjmp} implementation of exceptions,
3124 the answer is always yes. For some targets on which zero cost exception
3125 handling is implemented, the answer is also always yes. However, there
3126 are some targets, notably in the current version all x86 architecture
3127 targets, in which the answer is that such propagation does not
3128 happen automatically. If such propagation is required on these
3129 targets, it is mandatory to use @code{Propagate_Exceptions} to
3130 name all foreign language routines through which Ada exceptions
3133 @node Pragma Psect_Object
3134 @unnumberedsec Pragma Psect_Object
3135 @findex Psect_Object
3139 @smallexample @c ada
3140 pragma Psect_Object (
3141 [Internal =>] LOCAL_NAME,
3142 [, [External =>] EXTERNAL_SYMBOL]
3143 [, [Size =>] EXTERNAL_SYMBOL]);
3147 | static_string_EXPRESSION
3151 This pragma is identical in effect to pragma @code{Common_Object}.
3153 @node Pragma Pure_Function
3154 @unnumberedsec Pragma Pure_Function
3155 @findex Pure_Function
3159 @smallexample @c ada
3160 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
3164 This pragma appears in the same declarative part as a function
3165 declaration (or a set of function declarations if more than one
3166 overloaded declaration exists, in which case the pragma applies
3167 to all entities). It specifies that the function @code{Entity} is
3168 to be considered pure for the purposes of code generation. This means
3169 that the compiler can assume that there are no side effects, and
3170 in particular that two calls with identical arguments produce the
3171 same result. It also means that the function can be used in an
3174 Note that, quite deliberately, there are no static checks to try
3175 to ensure that this promise is met, so @code{Pure_Function} can be used
3176 with functions that are conceptually pure, even if they do modify
3177 global variables. For example, a square root function that is
3178 instrumented to count the number of times it is called is still
3179 conceptually pure, and can still be optimized, even though it
3180 modifies a global variable (the count). Memo functions are another
3181 example (where a table of previous calls is kept and consulted to
3182 avoid re-computation).
3185 Note: Most functions in a @code{Pure} package are automatically pure, and
3186 there is no need to use pragma @code{Pure_Function} for such functions. One
3187 exception is any function that has at least one formal of type
3188 @code{System.Address} or a type derived from it. Such functions are not
3189 considered pure by default, since the compiler assumes that the
3190 @code{Address} parameter may be functioning as a pointer and that the
3191 referenced data may change even if the address value does not.
3192 Similarly, imported functions are not considered to be pure by default,
3193 since there is no way of checking that they are in fact pure. The use
3194 of pragma @code{Pure_Function} for such a function will override these default
3195 assumption, and cause the compiler to treat a designated subprogram as pure
3198 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3199 applies to the underlying renamed function. This can be used to
3200 disambiguate cases of overloading where some but not all functions
3201 in a set of overloaded functions are to be designated as pure.
3203 @node Pragma Restriction_Warnings
3204 @unnumberedsec Pragma Restriction_Warnings
3205 @findex Restriction_Warnings
3209 @smallexample @c ada
3210 pragma Restriction_Warnings
3211 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3215 This pragma allows a series of restriction identifiers to be
3216 specified (the list of allowed identifiers is the same as for
3217 pragma @code{Restrictions}). For each of these identifiers
3218 the compiler checks for violations of the restriction, but
3219 generates a warning message rather than an error message
3220 if the restriction is violated.
3222 @node Pragma Source_File_Name
3223 @unnumberedsec Pragma Source_File_Name
3224 @findex Source_File_Name
3228 @smallexample @c ada
3229 pragma Source_File_Name (
3230 [Unit_Name =>] unit_NAME,
3231 Spec_File_Name => STRING_LITERAL);
3233 pragma Source_File_Name (
3234 [Unit_Name =>] unit_NAME,
3235 Body_File_Name => STRING_LITERAL);
3239 Use this to override the normal naming convention. It is a configuration
3240 pragma, and so has the usual applicability of configuration pragmas
3241 (i.e.@: it applies to either an entire partition, or to all units in a
3242 compilation, or to a single unit, depending on how it is used.
3243 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
3244 the second argument is required, and indicates whether this is the file
3245 name for the spec or for the body.
3247 Another form of the @code{Source_File_Name} pragma allows
3248 the specification of patterns defining alternative file naming schemes
3249 to apply to all files.
3251 @smallexample @c ada
3252 pragma Source_File_Name
3253 (Spec_File_Name => STRING_LITERAL
3254 [,Casing => CASING_SPEC]
3255 [,Dot_Replacement => STRING_LITERAL]);
3257 pragma Source_File_Name
3258 (Body_File_Name => STRING_LITERAL
3259 [,Casing => CASING_SPEC]
3260 [,Dot_Replacement => STRING_LITERAL]);
3262 pragma Source_File_Name
3263 (Subunit_File_Name => STRING_LITERAL
3264 [,Casing => CASING_SPEC]
3265 [,Dot_Replacement => STRING_LITERAL]);
3267 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3271 The first argument is a pattern that contains a single asterisk indicating
3272 the point at which the unit name is to be inserted in the pattern string
3273 to form the file name. The second argument is optional. If present it
3274 specifies the casing of the unit name in the resulting file name string.
3275 The default is lower case. Finally the third argument allows for systematic
3276 replacement of any dots in the unit name by the specified string literal.
3278 A pragma Source_File_Name cannot appear after a
3279 @ref{Pragma Source_File_Name_Project}.
3281 For more details on the use of the @code{Source_File_Name} pragma,
3282 see the sections ``Using Other File Names'' and
3283 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3285 @node Pragma Source_File_Name_Project
3286 @unnumberedsec Pragma Source_File_Name_Project
3287 @findex Source_File_Name_Project
3290 This pragma has the same syntax and semantics as pragma Source_File_Name.
3291 It is only allowed as a stand alone configuration pragma.
3292 It cannot appear after a @ref{Pragma Source_File_Name}, and
3293 most importantly, once pragma Source_File_Name_Project appears,
3294 no further Source_File_Name pragmas are allowed.
3296 The intention is that Source_File_Name_Project pragmas are always
3297 generated by the Project Manager in a manner consistent with the naming
3298 specified in a project file, and when naming is controlled in this manner,
3299 it is not permissible to attempt to modify this naming scheme using
3300 Source_File_Name pragmas (which would not be known to the project manager).
3302 @node Pragma Source_Reference
3303 @unnumberedsec Pragma Source_Reference
3304 @findex Source_Reference
3308 @smallexample @c ada
3309 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3313 This pragma must appear as the first line of a source file.
3314 @var{integer_literal} is the logical line number of the line following
3315 the pragma line (for use in error messages and debugging
3316 information). @var{string_literal} is a static string constant that
3317 specifies the file name to be used in error messages and debugging
3318 information. This is most notably used for the output of @code{gnatchop}
3319 with the @code{-r} switch, to make sure that the original unchopped
3320 source file is the one referred to.
3322 The second argument must be a string literal, it cannot be a static
3323 string expression other than a string literal. This is because its value
3324 is needed for error messages issued by all phases of the compiler.
3326 @node Pragma Stream_Convert
3327 @unnumberedsec Pragma Stream_Convert
3328 @findex Stream_Convert
3332 @smallexample @c ada
3333 pragma Stream_Convert (
3334 [Entity =>] type_LOCAL_NAME,
3335 [Read =>] function_NAME,
3336 [Write =>] function_NAME);
3340 This pragma provides an efficient way of providing stream functions for
3341 types defined in packages. Not only is it simpler to use than declaring
3342 the necessary functions with attribute representation clauses, but more
3343 significantly, it allows the declaration to made in such a way that the
3344 stream packages are not loaded unless they are needed. The use of
3345 the Stream_Convert pragma adds no overhead at all, unless the stream
3346 attributes are actually used on the designated type.
3348 The first argument specifies the type for which stream functions are
3349 provided. The second parameter provides a function used to read values
3350 of this type. It must name a function whose argument type may be any
3351 subtype, and whose returned type must be the type given as the first
3352 argument to the pragma.
3354 The meaning of the @var{Read}
3355 parameter is that if a stream attribute directly
3356 or indirectly specifies reading of the type given as the first parameter,
3357 then a value of the type given as the argument to the Read function is
3358 read from the stream, and then the Read function is used to convert this
3359 to the required target type.
3361 Similarly the @var{Write} parameter specifies how to treat write attributes
3362 that directly or indirectly apply to the type given as the first parameter.
3363 It must have an input parameter of the type specified by the first parameter,
3364 and the return type must be the same as the input type of the Read function.
3365 The effect is to first call the Write function to convert to the given stream
3366 type, and then write the result type to the stream.
3368 The Read and Write functions must not be overloaded subprograms. If necessary
3369 renamings can be supplied to meet this requirement.
3370 The usage of this attribute is best illustrated by a simple example, taken
3371 from the GNAT implementation of package Ada.Strings.Unbounded:
3373 @smallexample @c ada
3374 function To_Unbounded (S : String)
3375 return Unbounded_String
3376 renames To_Unbounded_String;
3378 pragma Stream_Convert
3379 (Unbounded_String, To_Unbounded, To_String);
3383 The specifications of the referenced functions, as given in the Ada 95
3384 Reference Manual are:
3386 @smallexample @c ada
3387 function To_Unbounded_String (Source : String)
3388 return Unbounded_String;
3390 function To_String (Source : Unbounded_String)
3395 The effect is that if the value of an unbounded string is written to a
3396 stream, then the representation of the item in the stream is in the same
3397 format used for @code{Standard.String}, and this same representation is
3398 expected when a value of this type is read from the stream.
3400 @node Pragma Style_Checks
3401 @unnumberedsec Pragma Style_Checks
3402 @findex Style_Checks
3406 @smallexample @c ada
3407 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3408 On | Off [, LOCAL_NAME]);
3412 This pragma is used in conjunction with compiler switches to control the
3413 built in style checking provided by GNAT@. The compiler switches, if set,
3414 provide an initial setting for the switches, and this pragma may be used
3415 to modify these settings, or the settings may be provided entirely by
3416 the use of the pragma. This pragma can be used anywhere that a pragma
3417 is legal, including use as a configuration pragma (including use in
3418 the @file{gnat.adc} file).
3420 The form with a string literal specifies which style options are to be
3421 activated. These are additive, so they apply in addition to any previously
3422 set style check options. The codes for the options are the same as those
3423 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3424 For example the following two methods can be used to enable
3429 @smallexample @c ada
3430 pragma Style_Checks ("l");
3435 gcc -c -gnatyl @dots{}
3440 The form ALL_CHECKS activates all standard checks (its use is equivalent
3441 to the use of the @code{gnaty} switch with no options. See GNAT User's
3444 The forms with @code{Off} and @code{On}
3445 can be used to temporarily disable style checks
3446 as shown in the following example:
3448 @smallexample @c ada
3452 pragma Style_Checks ("k"); -- requires keywords in lower case
3453 pragma Style_Checks (Off); -- turn off style checks
3454 NULL; -- this will not generate an error message
3455 pragma Style_Checks (On); -- turn style checks back on
3456 NULL; -- this will generate an error message
3460 Finally the two argument form is allowed only if the first argument is
3461 @code{On} or @code{Off}. The effect is to turn of semantic style checks
3462 for the specified entity, as shown in the following example:
3464 @smallexample @c ada
3468 pragma Style_Checks ("r"); -- require consistency of identifier casing
3470 Rf1 : Integer := ARG; -- incorrect, wrong case
3471 pragma Style_Checks (Off, Arg);
3472 Rf2 : Integer := ARG; -- OK, no error
3475 @node Pragma Subtitle
3476 @unnumberedsec Pragma Subtitle
3481 @smallexample @c ada
3482 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3486 This pragma is recognized for compatibility with other Ada compilers
3487 but is ignored by GNAT@.
3489 @node Pragma Suppress_All
3490 @unnumberedsec Pragma Suppress_All
3491 @findex Suppress_All
3495 @smallexample @c ada
3496 pragma Suppress_All;
3500 This pragma can only appear immediately following a compilation
3501 unit. The effect is to apply @code{Suppress (All_Checks)} to the unit
3502 which it follows. This pragma is implemented for compatibility with DEC
3503 Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal
3504 configuration pragma is the preferred usage in GNAT@.
3506 @node Pragma Suppress_Exception_Locations
3507 @unnumberedsec Pragma Suppress_Exception_Locations
3508 @findex Suppress_Exception_Locations
3512 @smallexample @c ada
3513 pragma Suppress_Exception_Locations;
3517 In normal mode, a raise statement for an exception by default generates
3518 an exception message giving the file name and line number for the location
3519 of the raise. This is useful for debugging and logging purposes, but this
3520 entails extra space for the strings for the messages. The configuration
3521 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3522 generation of these strings, with the result that space is saved, but the
3523 exception message for such raises is null. This configuration pragma may
3524 appear in a global configuration pragma file, or in a specific unit as
3525 usual. It is not required that this pragma be used consistently within
3526 a partition, so it is fine to have some units within a partition compiled
3527 with this pragma and others compiled in normal mode without it.
3529 @node Pragma Suppress_Initialization
3530 @unnumberedsec Pragma Suppress_Initialization
3531 @findex Suppress_Initialization
3532 @cindex Suppressing initialization
3533 @cindex Initialization, suppression of
3537 @smallexample @c ada
3538 pragma Suppress_Initialization ([Entity =>] type_Name);
3542 This pragma suppresses any implicit or explicit initialization
3543 associated with the given type name for all variables of this type.
3545 @node Pragma Task_Info
3546 @unnumberedsec Pragma Task_Info
3551 @smallexample @c ada
3552 pragma Task_Info (EXPRESSION);
3556 This pragma appears within a task definition (like pragma
3557 @code{Priority}) and applies to the task in which it appears. The
3558 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3559 The @code{Task_Info} pragma provides system dependent control over
3560 aspects of tasking implementation, for example, the ability to map
3561 tasks to specific processors. For details on the facilities available
3562 for the version of GNAT that you are using, see the documentation
3563 in the specification of package System.Task_Info in the runtime
3566 @node Pragma Task_Name
3567 @unnumberedsec Pragma Task_Name
3572 @smallexample @c ada
3573 pragma Task_Name (string_EXPRESSION);
3577 This pragma appears within a task definition (like pragma
3578 @code{Priority}) and applies to the task in which it appears. The
3579 argument must be of type String, and provides a name to be used for
3580 the task instance when the task is created. Note that this expression
3581 is not required to be static, and in particular, it can contain
3582 references to task discriminants. This facility can be used to
3583 provide different names for different tasks as they are created,
3584 as illustrated in the example below.
3586 The task name is recorded internally in the run-time structures
3587 and is accessible to tools like the debugger. In addition the
3588 routine @code{Ada.Task_Identification.Image} will return this
3589 string, with a unique task address appended.
3591 @smallexample @c ada
3592 -- Example of the use of pragma Task_Name
3594 with Ada.Task_Identification;
3595 use Ada.Task_Identification;
3596 with Text_IO; use Text_IO;
3599 type Astring is access String;
3601 task type Task_Typ (Name : access String) is
3602 pragma Task_Name (Name.all);
3605 task body Task_Typ is
3606 Nam : constant String := Image (Current_Task);
3608 Put_Line ("-->" & Nam (1 .. 14) & "<--");
3611 type Ptr_Task is access Task_Typ;
3612 Task_Var : Ptr_Task;
3616 new Task_Typ (new String'("This is task 1"));
3618 new Task_Typ (new String'("This is task 2"));
3622 @node Pragma Task_Storage
3623 @unnumberedsec Pragma Task_Storage
3624 @findex Task_Storage
3627 @smallexample @c ada
3628 pragma Task_Storage (
3629 [Task_Type =>] LOCAL_NAME,
3630 [Top_Guard =>] static_integer_EXPRESSION);
3634 This pragma specifies the length of the guard area for tasks. The guard
3635 area is an additional storage area allocated to a task. A value of zero
3636 means that either no guard area is created or a minimal guard area is
3637 created, depending on the target. This pragma can appear anywhere a
3638 @code{Storage_Size} attribute definition clause is allowed for a task
3641 @node Pragma Thread_Body
3642 @unnumberedsec Pragma Thread_Body
3646 @smallexample @c ada
3647 pragma Thread_Body (
3648 [Entity =>] LOCAL_NAME,
3649 [[Secondary_Stack_Size =>] static_integer_EXPRESSION)];
3653 This pragma specifies that the subprogram whose name is given as the
3654 @code{Entity} argument is a thread body, which will be activated
3655 by being called via its Address from foreign code. The purpose is
3656 to allow execution and registration of the foreign thread within the
3657 Ada run-time system.
3659 See the library unit @code{System.Threads} for details on the expansion of
3660 a thread body subprogram, including the calls made to subprograms
3661 within System.Threads to register the task. This unit also lists the
3662 targets and runtime systems for which this pragma is supported.
3664 A thread body subprogram may not be called directly from Ada code, and
3665 it is not permitted to apply the Access (or Unrestricted_Access) attributes
3666 to such a subprogram. The only legitimate way of calling such a subprogram
3667 is to pass its Address to foreign code and then make the call from the
3670 A thread body subprogram may have any parameters, and it may be a function
3671 returning a result. The convention of the thread body subprogram may be
3672 set in the usual manner using @code{pragma Convention}.
3674 The secondary stack size parameter, if given, is used to set the size
3675 of secondary stack for the thread. The secondary stack is allocated as
3676 a local variable of the expanded thread body subprogram, and thus is
3677 allocated out of the main thread stack size. If no secondary stack
3678 size parameter is present, the default size (from the declaration in
3679 @code{System.Secondary_Stack} is used.
3681 @node Pragma Time_Slice
3682 @unnumberedsec Pragma Time_Slice
3687 @smallexample @c ada
3688 pragma Time_Slice (static_duration_EXPRESSION);
3692 For implementations of GNAT on operating systems where it is possible
3693 to supply a time slice value, this pragma may be used for this purpose.
3694 It is ignored if it is used in a system that does not allow this control,
3695 or if it appears in other than the main program unit.
3697 Note that the effect of this pragma is identical to the effect of the
3698 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
3701 @unnumberedsec Pragma Title
3706 @smallexample @c ada
3707 pragma Title (TITLING_OPTION [, TITLING OPTION]);
3710 [Title =>] STRING_LITERAL,
3711 | [Subtitle =>] STRING_LITERAL
3715 Syntax checked but otherwise ignored by GNAT@. This is a listing control
3716 pragma used in DEC Ada 83 implementations to provide a title and/or
3717 subtitle for the program listing. The program listing generated by GNAT
3718 does not have titles or subtitles.
3720 Unlike other pragmas, the full flexibility of named notation is allowed
3721 for this pragma, i.e.@: the parameters may be given in any order if named
3722 notation is used, and named and positional notation can be mixed
3723 following the normal rules for procedure calls in Ada.
3725 @node Pragma Unchecked_Union
3726 @unnumberedsec Pragma Unchecked_Union
3728 @findex Unchecked_Union
3732 @smallexample @c ada
3733 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
3737 This pragma is used to declare that the specified type should be represented
3739 equivalent to a C union type, and is intended only for use in
3740 interfacing with C code that uses union types. In Ada terms, the named
3741 type must obey the following rules:
3745 It is a non-tagged non-limited record type.
3747 It has a single discrete discriminant with a default value.
3749 The component list consists of a single variant part.
3751 Each variant has a component list with a single component.
3753 No nested variants are allowed.
3755 No component has an explicit default value.
3757 No component has a non-static constraint.
3761 In addition, given a type that meets the above requirements, the
3762 following restrictions apply to its use throughout the program:
3766 The discriminant name can be mentioned only in an aggregate.
3768 No subtypes may be created of this type.
3770 The type may not be constrained by giving a discriminant value.
3772 The type cannot be passed as the actual for a generic formal with a
3777 Equality and inequality operations on @code{unchecked_unions} are not
3778 available, since there is no discriminant to compare and the compiler
3779 does not even know how many bits to compare. It is implementation
3780 dependent whether this is detected at compile time as an illegality or
3781 whether it is undetected and considered to be an erroneous construct. In
3782 GNAT, a direct comparison is illegal, but GNAT does not attempt to catch
3783 the composite case (where two composites are compared that contain an
3784 unchecked union component), so such comparisons are simply considered
3787 The layout of the resulting type corresponds exactly to a C union, where
3788 each branch of the union corresponds to a single variant in the Ada
3789 record. The semantics of the Ada program is not changed in any way by
3790 the pragma, i.e.@: provided the above restrictions are followed, and no
3791 erroneous incorrect references to fields or erroneous comparisons occur,
3792 the semantics is exactly as described by the Ada reference manual.
3793 Pragma @code{Suppress (Discriminant_Check)} applies implicitly to the
3794 type and the default convention is C.
3796 @node Pragma Unimplemented_Unit
3797 @unnumberedsec Pragma Unimplemented_Unit
3798 @findex Unimplemented_Unit
3802 @smallexample @c ada
3803 pragma Unimplemented_Unit;
3807 If this pragma occurs in a unit that is processed by the compiler, GNAT
3808 aborts with the message @samp{@var{xxx} not implemented}, where
3809 @var{xxx} is the name of the current compilation unit. This pragma is
3810 intended to allow the compiler to handle unimplemented library units in
3813 The abort only happens if code is being generated. Thus you can use
3814 specs of unimplemented packages in syntax or semantic checking mode.
3816 @node Pragma Universal_Data
3817 @unnumberedsec Pragma Universal_Data
3818 @findex Universal_Data
3822 @smallexample @c ada
3823 pragma Universal_Data [(library_unit_Name)];
3827 This pragma is supported only for the AAMP target and is ignored for
3828 other targets. The pragma specifies that all library-level objects
3829 (Counter 0 data) associated with the library unit are to be accessed
3830 and updated using universal addressing (24-bit addresses for AAMP5)
3831 rather than the default of 16-bit Data Environment (DENV) addressing.
3832 Use of this pragma will generally result in less efficient code for
3833 references to global data associated with the library unit, but
3834 allows such data to be located anywhere in memory. This pragma is
3835 a library unit pragma, but can also be used as a configuration pragma
3836 (including use in the @file{gnat.adc} file). The functionality
3837 of this pragma is also available by applying the -univ switch on the
3838 compilations of units where universal addressing of the data is desired.
3840 @node Pragma Unreferenced
3841 @unnumberedsec Pragma Unreferenced
3842 @findex Unreferenced
3843 @cindex Warnings, unreferenced
3847 @smallexample @c ada
3848 pragma Unreferenced (local_Name @{, local_Name@});
3852 This pragma signals that the entities whose names are listed are
3853 deliberately not referenced in the current source unit. This
3854 suppresses warnings about the
3855 entities being unreferenced, and in addition a warning will be
3856 generated if one of these entities is in fact referenced in the
3857 same unit as the pragma (or in the corresponding body, or one
3860 This is particularly useful for clearly signaling that a particular
3861 parameter is not referenced in some particular subprogram implementation
3862 and that this is deliberate. It can also be useful in the case of
3863 objects declared only for their initialization or finalization side
3866 If @code{local_Name} identifies more than one matching homonym in the
3867 current scope, then the entity most recently declared is the one to which
3870 The left hand side of an assignment does not count as a reference for the
3871 purpose of this pragma. Thus it is fine to assign to an entity for which
3872 pragma Unreferenced is given.
3874 @node Pragma Unreserve_All_Interrupts
3875 @unnumberedsec Pragma Unreserve_All_Interrupts
3876 @findex Unreserve_All_Interrupts
3880 @smallexample @c ada
3881 pragma Unreserve_All_Interrupts;
3885 Normally certain interrupts are reserved to the implementation. Any attempt
3886 to attach an interrupt causes Program_Error to be raised, as described in
3887 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3888 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
3889 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3890 interrupt execution.
3892 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
3893 a program, then all such interrupts are unreserved. This allows the
3894 program to handle these interrupts, but disables their standard
3895 functions. For example, if this pragma is used, then pressing
3896 @kbd{Ctrl-C} will not automatically interrupt execution. However,
3897 a program can then handle the @code{SIGINT} interrupt as it chooses.
3899 For a full list of the interrupts handled in a specific implementation,
3900 see the source code for the specification of @code{Ada.Interrupts.Names} in
3901 file @file{a-intnam.ads}. This is a target dependent file that contains the
3902 list of interrupts recognized for a given target. The documentation in
3903 this file also specifies what interrupts are affected by the use of
3904 the @code{Unreserve_All_Interrupts} pragma.
3906 For a more general facility for controlling what interrupts can be
3907 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
3908 of the @code{Unreserve_All_Interrupts} pragma.
3910 @node Pragma Unsuppress
3911 @unnumberedsec Pragma Unsuppress
3916 @smallexample @c ada
3917 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
3921 This pragma undoes the effect of a previous pragma @code{Suppress}. If
3922 there is no corresponding pragma @code{Suppress} in effect, it has no
3923 effect. The range of the effect is the same as for pragma
3924 @code{Suppress}. The meaning of the arguments is identical to that used
3925 in pragma @code{Suppress}.
3927 One important application is to ensure that checks are on in cases where
3928 code depends on the checks for its correct functioning, so that the code
3929 will compile correctly even if the compiler switches are set to suppress
3932 @node Pragma Use_VADS_Size
3933 @unnumberedsec Pragma Use_VADS_Size
3934 @cindex @code{Size}, VADS compatibility
3935 @findex Use_VADS_Size
3939 @smallexample @c ada
3940 pragma Use_VADS_Size;
3944 This is a configuration pragma. In a unit to which it applies, any use
3945 of the 'Size attribute is automatically interpreted as a use of the
3946 'VADS_Size attribute. Note that this may result in incorrect semantic
3947 processing of valid Ada 95 programs. This is intended to aid in the
3948 handling of legacy code which depends on the interpretation of Size
3949 as implemented in the VADS compiler. See description of the VADS_Size
3950 attribute for further details.
3952 @node Pragma Validity_Checks
3953 @unnumberedsec Pragma Validity_Checks
3954 @findex Validity_Checks
3958 @smallexample @c ada
3959 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
3963 This pragma is used in conjunction with compiler switches to control the
3964 built-in validity checking provided by GNAT@. The compiler switches, if set
3965 provide an initial setting for the switches, and this pragma may be used
3966 to modify these settings, or the settings may be provided entirely by
3967 the use of the pragma. This pragma can be used anywhere that a pragma
3968 is legal, including use as a configuration pragma (including use in
3969 the @file{gnat.adc} file).
3971 The form with a string literal specifies which validity options are to be
3972 activated. The validity checks are first set to include only the default
3973 reference manual settings, and then a string of letters in the string
3974 specifies the exact set of options required. The form of this string
3975 is exactly as described for the @code{-gnatVx} compiler switch (see the
3976 GNAT users guide for details). For example the following two methods
3977 can be used to enable validity checking for mode @code{in} and
3978 @code{in out} subprogram parameters:
3982 @smallexample @c ada
3983 pragma Validity_Checks ("im");
3988 gcc -c -gnatVim @dots{}
3993 The form ALL_CHECKS activates all standard checks (its use is equivalent
3994 to the use of the @code{gnatva} switch.
3996 The forms with @code{Off} and @code{On}
3997 can be used to temporarily disable validity checks
3998 as shown in the following example:
4000 @smallexample @c ada
4004 pragma Validity_Checks ("c"); -- validity checks for copies
4005 pragma Validity_Checks (Off); -- turn off validity checks
4006 A := B; -- B will not be validity checked
4007 pragma Validity_Checks (On); -- turn validity checks back on
4008 A := C; -- C will be validity checked
4011 @node Pragma Volatile
4012 @unnumberedsec Pragma Volatile
4017 @smallexample @c ada
4018 pragma Volatile (local_NAME);
4022 This pragma is defined by the Ada 95 Reference Manual, and the GNAT
4023 implementation is fully conformant with this definition. The reason it
4024 is mentioned in this section is that a pragma of the same name was supplied
4025 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 implementation
4026 of pragma Volatile is upwards compatible with the implementation in
4029 @node Pragma Warnings
4030 @unnumberedsec Pragma Warnings
4035 @smallexample @c ada
4036 pragma Warnings (On | Off [, LOCAL_NAME]);
4040 Normally warnings are enabled, with the output being controlled by
4041 the command line switch. Warnings (@code{Off}) turns off generation of
4042 warnings until a Warnings (@code{On}) is encountered or the end of the
4043 current unit. If generation of warnings is turned off using this
4044 pragma, then no warning messages are output, regardless of the
4045 setting of the command line switches.
4047 The form with a single argument is a configuration pragma.
4049 If the @var{local_name} parameter is present, warnings are suppressed for
4050 the specified entity. This suppression is effective from the point where
4051 it occurs till the end of the extended scope of the variable (similar to
4052 the scope of @code{Suppress}).
4054 @node Pragma Weak_External
4055 @unnumberedsec Pragma Weak_External
4056 @findex Weak_External
4060 @smallexample @c ada
4061 pragma Weak_External ([Entity =>] LOCAL_NAME);
4065 This pragma specifies that the given entity should be marked as a weak
4066 external (one that does not have to be resolved) for the linker. For
4067 further details, consult the GCC manual.
4069 @node Implementation Defined Attributes
4070 @chapter Implementation Defined Attributes
4071 Ada 95 defines (throughout the Ada 95 reference manual,
4072 summarized in annex K),
4073 a set of attributes that provide useful additional functionality in all
4074 areas of the language. These language defined attributes are implemented
4075 in GNAT and work as described in the Ada 95 Reference Manual.
4077 In addition, Ada 95 allows implementations to define additional
4078 attributes whose meaning is defined by the implementation. GNAT provides
4079 a number of these implementation-dependent attributes which can be used
4080 to extend and enhance the functionality of the compiler. This section of
4081 the GNAT reference manual describes these additional attributes.
4083 Note that any program using these attributes may not be portable to
4084 other compilers (although GNAT implements this set of attributes on all
4085 platforms). Therefore if portability to other compilers is an important
4086 consideration, you should minimize the use of these attributes.
4097 * Default_Bit_Order::
4105 * Has_Access_Values::
4106 * Has_Discriminants::
4112 * Max_Interrupt_Priority::
4114 * Maximum_Alignment::
4118 * Passed_By_Reference::
4129 * Unconstrained_Array::
4130 * Universal_Literal_String::
4131 * Unrestricted_Access::
4139 @unnumberedsec Abort_Signal
4140 @findex Abort_Signal
4142 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4143 prefix) provides the entity for the special exception used to signal
4144 task abort or asynchronous transfer of control. Normally this attribute
4145 should only be used in the tasking runtime (it is highly peculiar, and
4146 completely outside the normal semantics of Ada, for a user program to
4147 intercept the abort exception).
4150 @unnumberedsec Address_Size
4151 @cindex Size of @code{Address}
4152 @findex Address_Size
4154 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4155 prefix) is a static constant giving the number of bits in an
4156 @code{Address}. It is the same value as System.Address'Size,
4157 but has the advantage of being static, while a direct
4158 reference to System.Address'Size is non-static because Address
4162 @unnumberedsec Asm_Input
4165 The @code{Asm_Input} attribute denotes a function that takes two
4166 parameters. The first is a string, the second is an expression of the
4167 type designated by the prefix. The first (string) argument is required
4168 to be a static expression, and is the constraint for the parameter,
4169 (e.g.@: what kind of register is required). The second argument is the
4170 value to be used as the input argument. The possible values for the
4171 constant are the same as those used in the RTL, and are dependent on
4172 the configuration file used to built the GCC back end.
4173 @ref{Machine Code Insertions}
4176 @unnumberedsec Asm_Output
4179 The @code{Asm_Output} attribute denotes a function that takes two
4180 parameters. The first is a string, the second is the name of a variable
4181 of the type designated by the attribute prefix. The first (string)
4182 argument is required to be a static expression and designates the
4183 constraint for the parameter (e.g.@: what kind of register is
4184 required). The second argument is the variable to be updated with the
4185 result. The possible values for constraint are the same as those used in
4186 the RTL, and are dependent on the configuration file used to build the
4187 GCC back end. If there are no output operands, then this argument may
4188 either be omitted, or explicitly given as @code{No_Output_Operands}.
4189 @ref{Machine Code Insertions}
4192 @unnumberedsec AST_Entry
4196 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
4197 the name of an entry, it yields a value of the predefined type AST_Handler
4198 (declared in the predefined package System, as extended by the use of
4199 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
4200 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
4201 Language Reference Manual}, section 9.12a.
4206 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4207 offset within the storage unit (byte) that contains the first bit of
4208 storage allocated for the object. The value of this attribute is of the
4209 type @code{Universal_Integer}, and is always a non-negative number not
4210 exceeding the value of @code{System.Storage_Unit}.
4212 For an object that is a variable or a constant allocated in a register,
4213 the value is zero. (The use of this attribute does not force the
4214 allocation of a variable to memory).
4216 For an object that is a formal parameter, this attribute applies
4217 to either the matching actual parameter or to a copy of the
4218 matching actual parameter.
4220 For an access object the value is zero. Note that
4221 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4222 designated object. Similarly for a record component
4223 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4224 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4225 are subject to index checks.
4227 This attribute is designed to be compatible with the DEC Ada 83 definition
4228 and implementation of the @code{Bit} attribute.
4231 @unnumberedsec Bit_Position
4232 @findex Bit_Position
4234 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4235 of the fields of the record type, yields the bit
4236 offset within the record contains the first bit of
4237 storage allocated for the object. The value of this attribute is of the
4238 type @code{Universal_Integer}. The value depends only on the field
4239 @var{C} and is independent of the alignment of
4240 the containing record @var{R}.
4243 @unnumberedsec Code_Address
4244 @findex Code_Address
4245 @cindex Subprogram address
4246 @cindex Address of subprogram code
4249 attribute may be applied to subprograms in Ada 95, but the
4250 intended effect from the Ada 95 reference manual seems to be to provide
4251 an address value which can be used to call the subprogram by means of
4252 an address clause as in the following example:
4254 @smallexample @c ada
4255 procedure K is @dots{}
4258 for L'Address use K'Address;
4259 pragma Import (Ada, L);
4263 A call to @code{L} is then expected to result in a call to @code{K}@.
4264 In Ada 83, where there were no access-to-subprogram values, this was
4265 a common work around for getting the effect of an indirect call.
4266 GNAT implements the above use of @code{Address} and the technique
4267 illustrated by the example code works correctly.
4269 However, for some purposes, it is useful to have the address of the start
4270 of the generated code for the subprogram. On some architectures, this is
4271 not necessarily the same as the @code{Address} value described above.
4272 For example, the @code{Address} value may reference a subprogram
4273 descriptor rather than the subprogram itself.
4275 The @code{'Code_Address} attribute, which can only be applied to
4276 subprogram entities, always returns the address of the start of the
4277 generated code of the specified subprogram, which may or may not be
4278 the same value as is returned by the corresponding @code{'Address}
4281 @node Default_Bit_Order
4282 @unnumberedsec Default_Bit_Order
4284 @cindex Little endian
4285 @findex Default_Bit_Order
4287 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4288 permissible prefix), provides the value @code{System.Default_Bit_Order}
4289 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4290 @code{Low_Order_First}). This is used to construct the definition of
4291 @code{Default_Bit_Order} in package @code{System}.
4294 @unnumberedsec Elaborated
4297 The prefix of the @code{'Elaborated} attribute must be a unit name. The
4298 value is a Boolean which indicates whether or not the given unit has been
4299 elaborated. This attribute is primarily intended for internal use by the
4300 generated code for dynamic elaboration checking, but it can also be used
4301 in user programs. The value will always be True once elaboration of all
4302 units has been completed. An exception is for units which need no
4303 elaboration, the value is always False for such units.
4306 @unnumberedsec Elab_Body
4309 This attribute can only be applied to a program unit name. It returns
4310 the entity for the corresponding elaboration procedure for elaborating
4311 the body of the referenced unit. This is used in the main generated
4312 elaboration procedure by the binder and is not normally used in any
4313 other context. However, there may be specialized situations in which it
4314 is useful to be able to call this elaboration procedure from Ada code,
4315 e.g.@: if it is necessary to do selective re-elaboration to fix some
4319 @unnumberedsec Elab_Spec
4322 This attribute can only be applied to a program unit name. It returns
4323 the entity for the corresponding elaboration procedure for elaborating
4324 the specification of the referenced unit. This is used in the main
4325 generated elaboration procedure by the binder and is not normally used
4326 in any other context. However, there may be specialized situations in
4327 which it is useful to be able to call this elaboration procedure from
4328 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4333 @cindex Ada 83 attributes
4336 The @code{Emax} attribute is provided for compatibility with Ada 83. See
4337 the Ada 83 reference manual for an exact description of the semantics of
4341 @unnumberedsec Enum_Rep
4342 @cindex Representation of enums
4345 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4346 function with the following spec:
4348 @smallexample @c ada
4349 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4350 return @i{Universal_Integer};
4354 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4355 enumeration type or to a non-overloaded enumeration
4356 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
4357 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4358 enumeration literal or object.
4360 The function returns the representation value for the given enumeration
4361 value. This will be equal to value of the @code{Pos} attribute in the
4362 absence of an enumeration representation clause. This is a static
4363 attribute (i.e.@: the result is static if the argument is static).
4365 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4366 in which case it simply returns the integer value. The reason for this
4367 is to allow it to be used for @code{(<>)} discrete formal arguments in
4368 a generic unit that can be instantiated with either enumeration types
4369 or integer types. Note that if @code{Enum_Rep} is used on a modular
4370 type whose upper bound exceeds the upper bound of the largest signed
4371 integer type, and the argument is a variable, so that the universal
4372 integer calculation is done at run-time, then the call to @code{Enum_Rep}
4373 may raise @code{Constraint_Error}.
4376 @unnumberedsec Epsilon
4377 @cindex Ada 83 attributes
4380 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
4381 the Ada 83 reference manual for an exact description of the semantics of
4385 @unnumberedsec Fixed_Value
4388 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4389 function with the following specification:
4391 @smallexample @c ada
4392 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4397 The value returned is the fixed-point value @var{V} such that
4399 @smallexample @c ada
4400 @var{V} = Arg * @var{S}'Small
4404 The effect is thus similar to first converting the argument to the
4405 integer type used to represent @var{S}, and then doing an unchecked
4406 conversion to the fixed-point type. The difference is
4407 that there are full range checks, to ensure that the result is in range.
4408 This attribute is primarily intended for use in implementation of the
4409 input-output functions for fixed-point values.
4411 @node Has_Access_Values
4412 @unnumberedsec Has_Access_Values
4413 @cindex Access values, testing for
4414 @findex Has_Access_Values
4416 The prefix of the @code{Has_Access_Values} attribute is a type. The result
4417 is a Boolean value which is True if the is an access type, or is a composite
4418 type with a component (at any nesting depth) that is an access type, and is
4420 The intended use of this attribute is in conjunction with generic
4421 definitions. If the attribute is applied to a generic private type, it
4422 indicates whether or not the corresponding actual type has access values.
4424 @node Has_Discriminants
4425 @unnumberedsec Has_Discriminants
4426 @cindex Discriminants, testing for
4427 @findex Has_Discriminants
4429 The prefix of the @code{Has_Discriminants} attribute is a type. The result
4430 is a Boolean value which is True if the type has discriminants, and False
4431 otherwise. The intended use of this attribute is in conjunction with generic
4432 definitions. If the attribute is applied to a generic private type, it
4433 indicates whether or not the corresponding actual type has discriminants.
4439 The @code{Img} attribute differs from @code{Image} in that it may be
4440 applied to objects as well as types, in which case it gives the
4441 @code{Image} for the subtype of the object. This is convenient for
4444 @smallexample @c ada
4445 Put_Line ("X = " & X'Img);
4449 has the same meaning as the more verbose:
4451 @smallexample @c ada
4452 Put_Line ("X = " & @var{T}'Image (X));
4456 where @var{T} is the (sub)type of the object @code{X}.
4459 @unnumberedsec Integer_Value
4460 @findex Integer_Value
4462 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
4463 function with the following spec:
4465 @smallexample @c ada
4466 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
4471 The value returned is the integer value @var{V}, such that
4473 @smallexample @c ada
4474 Arg = @var{V} * @var{T}'Small
4478 where @var{T} is the type of @code{Arg}.
4479 The effect is thus similar to first doing an unchecked conversion from
4480 the fixed-point type to its corresponding implementation type, and then
4481 converting the result to the target integer type. The difference is
4482 that there are full range checks, to ensure that the result is in range.
4483 This attribute is primarily intended for use in implementation of the
4484 standard input-output functions for fixed-point values.
4487 @unnumberedsec Large
4488 @cindex Ada 83 attributes
4491 The @code{Large} attribute is provided for compatibility with Ada 83. See
4492 the Ada 83 reference manual for an exact description of the semantics of
4496 @unnumberedsec Machine_Size
4497 @findex Machine_Size
4499 This attribute is identical to the @code{Object_Size} attribute. It is
4500 provided for compatibility with the DEC Ada 83 attribute of this name.
4503 @unnumberedsec Mantissa
4504 @cindex Ada 83 attributes
4507 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
4508 the Ada 83 reference manual for an exact description of the semantics of
4511 @node Max_Interrupt_Priority
4512 @unnumberedsec Max_Interrupt_Priority
4513 @cindex Interrupt priority, maximum
4514 @findex Max_Interrupt_Priority
4516 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
4517 permissible prefix), provides the same value as
4518 @code{System.Max_Interrupt_Priority}.
4521 @unnumberedsec Max_Priority
4522 @cindex Priority, maximum
4523 @findex Max_Priority
4525 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
4526 prefix) provides the same value as @code{System.Max_Priority}.
4528 @node Maximum_Alignment
4529 @unnumberedsec Maximum_Alignment
4530 @cindex Alignment, maximum
4531 @findex Maximum_Alignment
4533 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
4534 permissible prefix) provides the maximum useful alignment value for the
4535 target. This is a static value that can be used to specify the alignment
4536 for an object, guaranteeing that it is properly aligned in all
4539 @node Mechanism_Code
4540 @unnumberedsec Mechanism_Code
4541 @cindex Return values, passing mechanism
4542 @cindex Parameters, passing mechanism
4543 @findex Mechanism_Code
4545 @code{@var{function}'Mechanism_Code} yields an integer code for the
4546 mechanism used for the result of function, and
4547 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
4548 used for formal parameter number @var{n} (a static integer value with 1
4549 meaning the first parameter) of @var{subprogram}. The code returned is:
4557 by descriptor (default descriptor class)
4559 by descriptor (UBS: unaligned bit string)
4561 by descriptor (UBSB: aligned bit string with arbitrary bounds)
4563 by descriptor (UBA: unaligned bit array)
4565 by descriptor (S: string, also scalar access type parameter)
4567 by descriptor (SB: string with arbitrary bounds)
4569 by descriptor (A: contiguous array)
4571 by descriptor (NCA: non-contiguous array)
4575 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
4578 @node Null_Parameter
4579 @unnumberedsec Null_Parameter
4580 @cindex Zero address, passing
4581 @findex Null_Parameter
4583 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
4584 type or subtype @var{T} allocated at machine address zero. The attribute
4585 is allowed only as the default expression of a formal parameter, or as
4586 an actual expression of a subprogram call. In either case, the
4587 subprogram must be imported.
4589 The identity of the object is represented by the address zero in the
4590 argument list, independent of the passing mechanism (explicit or
4593 This capability is needed to specify that a zero address should be
4594 passed for a record or other composite object passed by reference.
4595 There is no way of indicating this without the @code{Null_Parameter}
4599 @unnumberedsec Object_Size
4600 @cindex Size, used for objects
4603 The size of an object is not necessarily the same as the size of the type
4604 of an object. This is because by default object sizes are increased to be
4605 a multiple of the alignment of the object. For example,
4606 @code{Natural'Size} is
4607 31, but by default objects of type @code{Natural} will have a size of 32 bits.
4608 Similarly, a record containing an integer and a character:
4610 @smallexample @c ada
4618 will have a size of 40 (that is @code{Rec'Size} will be 40. The
4619 alignment will be 4, because of the
4620 integer field, and so the default size of record objects for this type
4621 will be 64 (8 bytes).
4623 The @code{@var{type}'Object_Size} attribute
4624 has been added to GNAT to allow the
4625 default object size of a type to be easily determined. For example,
4626 @code{Natural'Object_Size} is 32, and
4627 @code{Rec'Object_Size} (for the record type in the above example) will be
4628 64. Note also that, unlike the situation with the
4629 @code{Size} attribute as defined in the Ada RM, the
4630 @code{Object_Size} attribute can be specified individually
4631 for different subtypes. For example:
4633 @smallexample @c ada
4634 type R is new Integer;
4635 subtype R1 is R range 1 .. 10;
4636 subtype R2 is R range 1 .. 10;
4637 for R2'Object_Size use 8;
4641 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
4642 32 since the default object size for a subtype is the same as the object size
4643 for the parent subtype. This means that objects of type @code{R}
4645 by default be 32 bits (four bytes). But objects of type
4646 @code{R2} will be only
4647 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
4649 @node Passed_By_Reference
4650 @unnumberedsec Passed_By_Reference
4651 @cindex Parameters, when passed by reference
4652 @findex Passed_By_Reference
4654 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
4655 a value of type @code{Boolean} value that is @code{True} if the type is
4656 normally passed by reference and @code{False} if the type is normally
4657 passed by copy in calls. For scalar types, the result is always @code{False}
4658 and is static. For non-scalar types, the result is non-static.
4661 @unnumberedsec Range_Length
4662 @findex Range_Length
4664 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
4665 the number of values represented by the subtype (zero for a null
4666 range). The result is static for static subtypes. @code{Range_Length}
4667 applied to the index subtype of a one dimensional array always gives the
4668 same result as @code{Range} applied to the array itself.
4671 @unnumberedsec Safe_Emax
4672 @cindex Ada 83 attributes
4675 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
4676 the Ada 83 reference manual for an exact description of the semantics of
4680 @unnumberedsec Safe_Large
4681 @cindex Ada 83 attributes
4684 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
4685 the Ada 83 reference manual for an exact description of the semantics of
4689 @unnumberedsec Small
4690 @cindex Ada 83 attributes
4693 The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
4694 GNAT also allows this attribute to be applied to floating-point types
4695 for compatibility with Ada 83. See
4696 the Ada 83 reference manual for an exact description of the semantics of
4697 this attribute when applied to floating-point types.
4700 @unnumberedsec Storage_Unit
4701 @findex Storage_Unit
4703 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
4704 prefix) provides the same value as @code{System.Storage_Unit}.
4707 @unnumberedsec Target_Name
4710 @code{Standard'Target_Name} (@code{Standard} is the only permissible
4711 prefix) provides a static string value that identifies the target
4712 for the current compilation. For GCC implementations, this is the
4713 standard gcc target name without the terminating slash (for
4714 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
4720 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
4721 provides the same value as @code{System.Tick},
4724 @unnumberedsec To_Address
4727 The @code{System'To_Address}
4728 (@code{System} is the only permissible prefix)
4729 denotes a function identical to
4730 @code{System.Storage_Elements.To_Address} except that
4731 it is a static attribute. This means that if its argument is
4732 a static expression, then the result of the attribute is a
4733 static expression. The result is that such an expression can be
4734 used in contexts (e.g.@: preelaborable packages) which require a
4735 static expression and where the function call could not be used
4736 (since the function call is always non-static, even if its
4737 argument is static).
4740 @unnumberedsec Type_Class
4743 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
4744 the value of the type class for the full type of @var{type}. If
4745 @var{type} is a generic formal type, the value is the value for the
4746 corresponding actual subtype. The value of this attribute is of type
4747 @code{System.Aux_DEC.Type_Class}, which has the following definition:
4749 @smallexample @c ada
4751 (Type_Class_Enumeration,
4753 Type_Class_Fixed_Point,
4754 Type_Class_Floating_Point,
4759 Type_Class_Address);
4763 Protected types yield the value @code{Type_Class_Task}, which thus
4764 applies to all concurrent types. This attribute is designed to
4765 be compatible with the DEC Ada 83 attribute of the same name.
4768 @unnumberedsec UET_Address
4771 The @code{UET_Address} attribute can only be used for a prefix which
4772 denotes a library package. It yields the address of the unit exception
4773 table when zero cost exception handling is used. This attribute is
4774 intended only for use within the GNAT implementation. See the unit
4775 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
4776 for details on how this attribute is used in the implementation.
4778 @node Unconstrained_Array
4779 @unnumberedsec Unconstrained_Array
4780 @findex Unconstrained_Array
4782 The @code{Unconstrained_Array} attribute can be used with a prefix that
4783 denotes any type or subtype. It is a static attribute that yields
4784 @code{True} if the prefix designates an unconstrained array,
4785 and @code{False} otherwise. In a generic instance, the result is
4786 still static, and yields the result of applying this test to the
4789 @node Universal_Literal_String
4790 @unnumberedsec Universal_Literal_String
4791 @cindex Named numbers, representation of
4792 @findex Universal_Literal_String
4794 The prefix of @code{Universal_Literal_String} must be a named
4795 number. The static result is the string consisting of the characters of
4796 the number as defined in the original source. This allows the user
4797 program to access the actual text of named numbers without intermediate
4798 conversions and without the need to enclose the strings in quotes (which
4799 would preclude their use as numbers). This is used internally for the
4800 construction of values of the floating-point attributes from the file
4801 @file{ttypef.ads}, but may also be used by user programs.
4803 @node Unrestricted_Access
4804 @unnumberedsec Unrestricted_Access
4805 @cindex @code{Access}, unrestricted
4806 @findex Unrestricted_Access
4808 The @code{Unrestricted_Access} attribute is similar to @code{Access}
4809 except that all accessibility and aliased view checks are omitted. This
4810 is a user-beware attribute. It is similar to
4811 @code{Address}, for which it is a desirable replacement where the value
4812 desired is an access type. In other words, its effect is identical to
4813 first applying the @code{Address} attribute and then doing an unchecked
4814 conversion to a desired access type. In GNAT, but not necessarily in
4815 other implementations, the use of static chains for inner level
4816 subprograms means that @code{Unrestricted_Access} applied to a
4817 subprogram yields a value that can be called as long as the subprogram
4818 is in scope (normal Ada 95 accessibility rules restrict this usage).
4820 It is possible to use @code{Unrestricted_Access} for any type, but care
4821 must be exercised if it is used to create pointers to unconstrained
4822 objects. In this case, the resulting pointer has the same scope as the
4823 context of the attribute, and may not be returned to some enclosing
4824 scope. For instance, a function cannot use @code{Unrestricted_Access}
4825 to create a unconstrained pointer and then return that value to the
4829 @unnumberedsec VADS_Size
4830 @cindex @code{Size}, VADS compatibility
4833 The @code{'VADS_Size} attribute is intended to make it easier to port
4834 legacy code which relies on the semantics of @code{'Size} as implemented
4835 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
4836 same semantic interpretation. In particular, @code{'VADS_Size} applied
4837 to a predefined or other primitive type with no Size clause yields the
4838 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
4839 typical machines). In addition @code{'VADS_Size} applied to an object
4840 gives the result that would be obtained by applying the attribute to
4841 the corresponding type.
4844 @unnumberedsec Value_Size
4845 @cindex @code{Size}, setting for not-first subtype
4847 @code{@var{type}'Value_Size} is the number of bits required to represent
4848 a value of the given subtype. It is the same as @code{@var{type}'Size},
4849 but, unlike @code{Size}, may be set for non-first subtypes.
4852 @unnumberedsec Wchar_T_Size
4853 @findex Wchar_T_Size
4854 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
4855 prefix) provides the size in bits of the C @code{wchar_t} type
4856 primarily for constructing the definition of this type in
4857 package @code{Interfaces.C}.
4860 @unnumberedsec Word_Size
4862 @code{Standard'Word_Size} (@code{Standard} is the only permissible
4863 prefix) provides the value @code{System.Word_Size}.
4865 @c ------------------------
4866 @node Implementation Advice
4867 @chapter Implementation Advice
4869 The main text of the Ada 95 Reference Manual describes the required
4870 behavior of all Ada 95 compilers, and the GNAT compiler conforms to
4873 In addition, there are sections throughout the Ada 95
4874 reference manual headed
4875 by the phrase ``implementation advice''. These sections are not normative,
4876 i.e.@: they do not specify requirements that all compilers must
4877 follow. Rather they provide advice on generally desirable behavior. You
4878 may wonder why they are not requirements. The most typical answer is
4879 that they describe behavior that seems generally desirable, but cannot
4880 be provided on all systems, or which may be undesirable on some systems.
4882 As far as practical, GNAT follows the implementation advice sections in
4883 the Ada 95 Reference Manual. This chapter contains a table giving the
4884 reference manual section number, paragraph number and several keywords
4885 for each advice. Each entry consists of the text of the advice followed
4886 by the GNAT interpretation of this advice. Most often, this simply says
4887 ``followed'', which means that GNAT follows the advice. However, in a
4888 number of cases, GNAT deliberately deviates from this advice, in which
4889 case the text describes what GNAT does and why.
4891 @cindex Error detection
4892 @unnumberedsec 1.1.3(20): Error Detection
4895 If an implementation detects the use of an unsupported Specialized Needs
4896 Annex feature at run time, it should raise @code{Program_Error} if
4899 Not relevant. All specialized needs annex features are either supported,
4900 or diagnosed at compile time.
4903 @unnumberedsec 1.1.3(31): Child Units
4906 If an implementation wishes to provide implementation-defined
4907 extensions to the functionality of a language-defined library unit, it
4908 should normally do so by adding children to the library unit.
4912 @cindex Bounded errors
4913 @unnumberedsec 1.1.5(12): Bounded Errors
4916 If an implementation detects a bounded error or erroneous
4917 execution, it should raise @code{Program_Error}.
4919 Followed in all cases in which the implementation detects a bounded
4920 error or erroneous execution. Not all such situations are detected at
4924 @unnumberedsec 2.8(16): Pragmas
4927 Normally, implementation-defined pragmas should have no semantic effect
4928 for error-free programs; that is, if the implementation-defined pragmas
4929 are removed from a working program, the program should still be legal,
4930 and should still have the same semantics.
4932 The following implementation defined pragmas are exceptions to this
4944 @item CPP_Constructor
4952 @item Interface_Name
4954 @item Machine_Attribute
4956 @item Unimplemented_Unit
4958 @item Unchecked_Union
4963 In each of the above cases, it is essential to the purpose of the pragma
4964 that this advice not be followed. For details see the separate section
4965 on implementation defined pragmas.
4967 @unnumberedsec 2.8(17-19): Pragmas
4970 Normally, an implementation should not define pragmas that can
4971 make an illegal program legal, except as follows:
4975 A pragma used to complete a declaration, such as a pragma @code{Import};
4979 A pragma used to configure the environment by adding, removing, or
4980 replacing @code{library_items}.
4982 See response to paragraph 16 of this same section.
4984 @cindex Character Sets
4985 @cindex Alternative Character Sets
4986 @unnumberedsec 3.5.2(5): Alternative Character Sets
4989 If an implementation supports a mode with alternative interpretations
4990 for @code{Character} and @code{Wide_Character}, the set of graphic
4991 characters of @code{Character} should nevertheless remain a proper
4992 subset of the set of graphic characters of @code{Wide_Character}. Any
4993 character set ``localizations'' should be reflected in the results of
4994 the subprograms defined in the language-defined package
4995 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
4996 an alternative interpretation of @code{Character}, the implementation should
4997 also support a corresponding change in what is a legal
4998 @code{identifier_letter}.
5000 Not all wide character modes follow this advice, in particular the JIS
5001 and IEC modes reflect standard usage in Japan, and in these encoding,
5002 the upper half of the Latin-1 set is not part of the wide-character
5003 subset, since the most significant bit is used for wide character
5004 encoding. However, this only applies to the external forms. Internally
5005 there is no such restriction.
5007 @cindex Integer types
5008 @unnumberedsec 3.5.4(28): Integer Types
5012 An implementation should support @code{Long_Integer} in addition to
5013 @code{Integer} if the target machine supports 32-bit (or longer)
5014 arithmetic. No other named integer subtypes are recommended for package
5015 @code{Standard}. Instead, appropriate named integer subtypes should be
5016 provided in the library package @code{Interfaces} (see B.2).
5018 @code{Long_Integer} is supported. Other standard integer types are supported
5019 so this advice is not fully followed. These types
5020 are supported for convenient interface to C, and so that all hardware
5021 types of the machine are easily available.
5022 @unnumberedsec 3.5.4(29): Integer Types
5026 An implementation for a two's complement machine should support
5027 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
5028 implementation should support a non-binary modules up to @code{Integer'Last}.
5032 @cindex Enumeration values
5033 @unnumberedsec 3.5.5(8): Enumeration Values
5036 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
5037 subtype, if the value of the operand does not correspond to the internal
5038 code for any enumeration literal of its type (perhaps due to an
5039 un-initialized variable), then the implementation should raise
5040 @code{Program_Error}. This is particularly important for enumeration
5041 types with noncontiguous internal codes specified by an
5042 enumeration_representation_clause.
5047 @unnumberedsec 3.5.7(17): Float Types
5050 An implementation should support @code{Long_Float} in addition to
5051 @code{Float} if the target machine supports 11 or more digits of
5052 precision. No other named floating point subtypes are recommended for
5053 package @code{Standard}. Instead, appropriate named floating point subtypes
5054 should be provided in the library package @code{Interfaces} (see B.2).
5056 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
5057 former provides improved compatibility with other implementations
5058 supporting this type. The latter corresponds to the highest precision
5059 floating-point type supported by the hardware. On most machines, this
5060 will be the same as @code{Long_Float}, but on some machines, it will
5061 correspond to the IEEE extended form. The notable case is all ia32
5062 (x86) implementations, where @code{Long_Long_Float} corresponds to
5063 the 80-bit extended precision format supported in hardware on this
5064 processor. Note that the 128-bit format on SPARC is not supported,
5065 since this is a software rather than a hardware format.
5067 @cindex Multidimensional arrays
5068 @cindex Arrays, multidimensional
5069 @unnumberedsec 3.6.2(11): Multidimensional Arrays
5072 An implementation should normally represent multidimensional arrays in
5073 row-major order, consistent with the notation used for multidimensional
5074 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
5075 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
5076 column-major order should be used instead (see B.5, ``Interfacing with
5081 @findex Duration'Small
5082 @unnumberedsec 9.6(30-31): Duration'Small
5085 Whenever possible in an implementation, the value of @code{Duration'Small}
5086 should be no greater than 100 microseconds.
5088 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
5092 The time base for @code{delay_relative_statements} should be monotonic;
5093 it need not be the same time base as used for @code{Calendar.Clock}.
5097 @unnumberedsec 10.2.1(12): Consistent Representation
5100 In an implementation, a type declared in a pre-elaborated package should
5101 have the same representation in every elaboration of a given version of
5102 the package, whether the elaborations occur in distinct executions of
5103 the same program, or in executions of distinct programs or partitions
5104 that include the given version.
5106 Followed, except in the case of tagged types. Tagged types involve
5107 implicit pointers to a local copy of a dispatch table, and these pointers
5108 have representations which thus depend on a particular elaboration of the
5109 package. It is not easy to see how it would be possible to follow this
5110 advice without severely impacting efficiency of execution.
5112 @cindex Exception information
5113 @unnumberedsec 11.4.1(19): Exception Information
5116 @code{Exception_Message} by default and @code{Exception_Information}
5117 should produce information useful for
5118 debugging. @code{Exception_Message} should be short, about one
5119 line. @code{Exception_Information} can be long. @code{Exception_Message}
5120 should not include the
5121 @code{Exception_Name}. @code{Exception_Information} should include both
5122 the @code{Exception_Name} and the @code{Exception_Message}.
5124 Followed. For each exception that doesn't have a specified
5125 @code{Exception_Message}, the compiler generates one containing the location
5126 of the raise statement. This location has the form ``file:line'', where
5127 file is the short file name (without path information) and line is the line
5128 number in the file. Note that in the case of the Zero Cost Exception
5129 mechanism, these messages become redundant with the Exception_Information that
5130 contains a full backtrace of the calling sequence, so they are disabled.
5131 To disable explicitly the generation of the source location message, use the
5132 Pragma @code{Discard_Names}.
5134 @cindex Suppression of checks
5135 @cindex Checks, suppression of
5136 @unnumberedsec 11.5(28): Suppression of Checks
5139 The implementation should minimize the code executed for checks that
5140 have been suppressed.
5144 @cindex Representation clauses
5145 @unnumberedsec 13.1 (21-24): Representation Clauses
5148 The recommended level of support for all representation items is
5149 qualified as follows:
5153 An implementation need not support representation items containing
5154 non-static expressions, except that an implementation should support a
5155 representation item for a given entity if each non-static expression in
5156 the representation item is a name that statically denotes a constant
5157 declared before the entity.
5159 Followed. In fact, GNAT goes beyond the recommended level of support
5160 by allowing nonstatic expressions in some representation clauses even
5161 without the need to declare constants initialized with the values of
5165 @smallexample @c ada
5168 for Y'Address use X'Address;>>
5174 An implementation need not support a specification for the @code{Size}
5175 for a given composite subtype, nor the size or storage place for an
5176 object (including a component) of a given composite subtype, unless the
5177 constraints on the subtype and its composite subcomponents (if any) are
5178 all static constraints.
5180 Followed. Size Clauses are not permitted on non-static components, as
5185 An aliased component, or a component whose type is by-reference, should
5186 always be allocated at an addressable location.
5190 @cindex Packed types
5191 @unnumberedsec 13.2(6-8): Packed Types
5194 If a type is packed, then the implementation should try to minimize
5195 storage allocated to objects of the type, possibly at the expense of
5196 speed of accessing components, subject to reasonable complexity in
5197 addressing calculations.
5201 The recommended level of support pragma @code{Pack} is:
5203 For a packed record type, the components should be packed as tightly as
5204 possible subject to the Sizes of the component subtypes, and subject to
5205 any @code{record_representation_clause} that applies to the type; the
5206 implementation may, but need not, reorder components or cross aligned
5207 word boundaries to improve the packing. A component whose @code{Size} is
5208 greater than the word size may be allocated an integral number of words.
5210 Followed. Tight packing of arrays is supported for all component sizes
5211 up to 64-bits. If the array component size is 1 (that is to say, if
5212 the component is a boolean type or an enumeration type with two values)
5213 then values of the type are implicitly initialized to zero. This
5214 happens both for objects of the packed type, and for objects that have a
5215 subcomponent of the packed type.
5219 An implementation should support Address clauses for imported
5223 @cindex @code{Address} clauses
5224 @unnumberedsec 13.3(14-19): Address Clauses
5228 For an array @var{X}, @code{@var{X}'Address} should point at the first
5229 component of the array, and not at the array bounds.
5235 The recommended level of support for the @code{Address} attribute is:
5237 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5238 object that is aliased or of a by-reference type, or is an entity whose
5239 @code{Address} has been specified.
5241 Followed. A valid address will be produced even if none of those
5242 conditions have been met. If necessary, the object is forced into
5243 memory to ensure the address is valid.
5247 An implementation should support @code{Address} clauses for imported
5254 Objects (including subcomponents) that are aliased or of a by-reference
5255 type should be allocated on storage element boundaries.
5261 If the @code{Address} of an object is specified, or it is imported or exported,
5262 then the implementation should not perform optimizations based on
5263 assumptions of no aliases.
5267 @cindex @code{Alignment} clauses
5268 @unnumberedsec 13.3(29-35): Alignment Clauses
5271 The recommended level of support for the @code{Alignment} attribute for
5274 An implementation should support specified Alignments that are factors
5275 and multiples of the number of storage elements per word, subject to the
5282 An implementation need not support specified @code{Alignment}s for
5283 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5284 loaded and stored by available machine instructions.
5290 An implementation need not support specified @code{Alignment}s that are
5291 greater than the maximum @code{Alignment} the implementation ever returns by
5298 The recommended level of support for the @code{Alignment} attribute for
5301 Same as above, for subtypes, but in addition:
5307 For stand-alone library-level objects of statically constrained
5308 subtypes, the implementation should support all @code{Alignment}s
5309 supported by the target linker. For example, page alignment is likely to
5310 be supported for such objects, but not for subtypes.
5314 @cindex @code{Size} clauses
5315 @unnumberedsec 13.3(42-43): Size Clauses
5318 The recommended level of support for the @code{Size} attribute of
5321 A @code{Size} clause should be supported for an object if the specified
5322 @code{Size} is at least as large as its subtype's @code{Size}, and
5323 corresponds to a size in storage elements that is a multiple of the
5324 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5328 @unnumberedsec 13.3(50-56): Size Clauses
5331 If the @code{Size} of a subtype is specified, and allows for efficient
5332 independent addressability (see 9.10) on the target architecture, then
5333 the @code{Size} of the following objects of the subtype should equal the
5334 @code{Size} of the subtype:
5336 Aliased objects (including components).
5342 @code{Size} clause on a composite subtype should not affect the
5343 internal layout of components.
5349 The recommended level of support for the @code{Size} attribute of subtypes is:
5353 The @code{Size} (if not specified) of a static discrete or fixed point
5354 subtype should be the number of bits needed to represent each value
5355 belonging to the subtype using an unbiased representation, leaving space
5356 for a sign bit only if the subtype contains negative values. If such a
5357 subtype is a first subtype, then an implementation should support a
5358 specified @code{Size} for it that reflects this representation.
5364 For a subtype implemented with levels of indirection, the @code{Size}
5365 should include the size of the pointers, but not the size of what they
5370 @cindex @code{Component_Size} clauses
5371 @unnumberedsec 13.3(71-73): Component Size Clauses
5374 The recommended level of support for the @code{Component_Size}
5379 An implementation need not support specified @code{Component_Sizes} that are
5380 less than the @code{Size} of the component subtype.
5386 An implementation should support specified @code{Component_Size}s that
5387 are factors and multiples of the word size. For such
5388 @code{Component_Size}s, the array should contain no gaps between
5389 components. For other @code{Component_Size}s (if supported), the array
5390 should contain no gaps between components when packing is also
5391 specified; the implementation should forbid this combination in cases
5392 where it cannot support a no-gaps representation.
5396 @cindex Enumeration representation clauses
5397 @cindex Representation clauses, enumeration
5398 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
5401 The recommended level of support for enumeration representation clauses
5404 An implementation need not support enumeration representation clauses
5405 for boolean types, but should at minimum support the internal codes in
5406 the range @code{System.Min_Int.System.Max_Int}.
5410 @cindex Record representation clauses
5411 @cindex Representation clauses, records
5412 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
5415 The recommended level of support for
5416 @*@code{record_representation_clauses} is:
5418 An implementation should support storage places that can be extracted
5419 with a load, mask, shift sequence of machine code, and set with a load,
5420 shift, mask, store sequence, given the available machine instructions
5427 A storage place should be supported if its size is equal to the
5428 @code{Size} of the component subtype, and it starts and ends on a
5429 boundary that obeys the @code{Alignment} of the component subtype.
5435 If the default bit ordering applies to the declaration of a given type,
5436 then for a component whose subtype's @code{Size} is less than the word
5437 size, any storage place that does not cross an aligned word boundary
5438 should be supported.
5444 An implementation may reserve a storage place for the tag field of a
5445 tagged type, and disallow other components from overlapping that place.
5447 Followed. The storage place for the tag field is the beginning of the tagged
5448 record, and its size is Address'Size. GNAT will reject an explicit component
5449 clause for the tag field.
5453 An implementation need not support a @code{component_clause} for a
5454 component of an extension part if the storage place is not after the
5455 storage places of all components of the parent type, whether or not
5456 those storage places had been specified.
5458 Followed. The above advice on record representation clauses is followed,
5459 and all mentioned features are implemented.
5461 @cindex Storage place attributes
5462 @unnumberedsec 13.5.2(5): Storage Place Attributes
5465 If a component is represented using some form of pointer (such as an
5466 offset) to the actual data of the component, and this data is contiguous
5467 with the rest of the object, then the storage place attributes should
5468 reflect the place of the actual data, not the pointer. If a component is
5469 allocated discontinuously from the rest of the object, then a warning
5470 should be generated upon reference to one of its storage place
5473 Followed. There are no such components in GNAT@.
5475 @cindex Bit ordering
5476 @unnumberedsec 13.5.3(7-8): Bit Ordering
5479 The recommended level of support for the non-default bit ordering is:
5483 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
5484 should support the non-default bit ordering in addition to the default
5487 Followed. Word size does not equal storage size in this implementation.
5488 Thus non-default bit ordering is not supported.
5490 @cindex @code{Address}, as private type
5491 @unnumberedsec 13.7(37): Address as Private
5494 @code{Address} should be of a private type.
5498 @cindex Operations, on @code{Address}
5499 @cindex @code{Address}, operations of
5500 @unnumberedsec 13.7.1(16): Address Operations
5503 Operations in @code{System} and its children should reflect the target
5504 environment semantics as closely as is reasonable. For example, on most
5505 machines, it makes sense for address arithmetic to ``wrap around''.
5506 Operations that do not make sense should raise @code{Program_Error}.
5508 Followed. Address arithmetic is modular arithmetic that wraps around. No
5509 operation raises @code{Program_Error}, since all operations make sense.
5511 @cindex Unchecked conversion
5512 @unnumberedsec 13.9(14-17): Unchecked Conversion
5515 The @code{Size} of an array object should not include its bounds; hence,
5516 the bounds should not be part of the converted data.
5522 The implementation should not generate unnecessary run-time checks to
5523 ensure that the representation of @var{S} is a representation of the
5524 target type. It should take advantage of the permission to return by
5525 reference when possible. Restrictions on unchecked conversions should be
5526 avoided unless required by the target environment.
5528 Followed. There are no restrictions on unchecked conversion. A warning is
5529 generated if the source and target types do not have the same size since
5530 the semantics in this case may be target dependent.
5534 The recommended level of support for unchecked conversions is:
5538 Unchecked conversions should be supported and should be reversible in
5539 the cases where this clause defines the result. To enable meaningful use
5540 of unchecked conversion, a contiguous representation should be used for
5541 elementary subtypes, for statically constrained array subtypes whose
5542 component subtype is one of the subtypes described in this paragraph,
5543 and for record subtypes without discriminants whose component subtypes
5544 are described in this paragraph.
5548 @cindex Heap usage, implicit
5549 @unnumberedsec 13.11(23-25): Implicit Heap Usage
5552 An implementation should document any cases in which it dynamically
5553 allocates heap storage for a purpose other than the evaluation of an
5556 Followed, the only other points at which heap storage is dynamically
5557 allocated are as follows:
5561 At initial elaboration time, to allocate dynamically sized global
5565 To allocate space for a task when a task is created.
5568 To extend the secondary stack dynamically when needed. The secondary
5569 stack is used for returning variable length results.
5574 A default (implementation-provided) storage pool for an
5575 access-to-constant type should not have overhead to support deallocation of
5582 A storage pool for an anonymous access type should be created at the
5583 point of an allocator for the type, and be reclaimed when the designated
5584 object becomes inaccessible.
5588 @cindex Unchecked deallocation
5589 @unnumberedsec 13.11.2(17): Unchecked De-allocation
5592 For a standard storage pool, @code{Free} should actually reclaim the
5597 @cindex Stream oriented attributes
5598 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
5601 If a stream element is the same size as a storage element, then the
5602 normal in-memory representation should be used by @code{Read} and
5603 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
5604 should use the smallest number of stream elements needed to represent
5605 all values in the base range of the scalar type.
5608 Followed. By default, GNAT uses the interpretation suggested by AI-195,
5609 which specifies using the size of the first subtype.
5610 However, such an implementation is based on direct binary
5611 representations and is therefore target- and endianness-dependent.
5612 To address this issue, GNAT also supplies an alternate implementation
5613 of the stream attributes @code{Read} and @code{Write},
5614 which uses the target-independent XDR standard representation
5616 @cindex XDR representation
5617 @cindex @code{Read} attribute
5618 @cindex @code{Write} attribute
5619 @cindex Stream oriented attributes
5620 The XDR implementation is provided as an alternative body of the
5621 @code{System.Stream_Attributes} package, in the file
5622 @file{s-strxdr.adb} in the GNAT library.
5623 There is no @file{s-strxdr.ads} file.
5624 In order to install the XDR implementation, do the following:
5626 @item Replace the default implementation of the
5627 @code{System.Stream_Attributes} package with the XDR implementation.
5628 For example on a Unix platform issue the commands:
5630 $ mv s-stratt.adb s-strold.adb
5631 $ mv s-strxdr.adb s-stratt.adb
5635 Rebuild the GNAT run-time library as documented in the
5636 @cite{GNAT User's Guide}
5639 @unnumberedsec A.1(52): Names of Predefined Numeric Types
5642 If an implementation provides additional named predefined integer types,
5643 then the names should end with @samp{Integer} as in
5644 @samp{Long_Integer}. If an implementation provides additional named
5645 predefined floating point types, then the names should end with
5646 @samp{Float} as in @samp{Long_Float}.
5650 @findex Ada.Characters.Handling
5651 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
5654 If an implementation provides a localized definition of @code{Character}
5655 or @code{Wide_Character}, then the effects of the subprograms in
5656 @code{Characters.Handling} should reflect the localizations. See also
5659 Followed. GNAT provides no such localized definitions.
5661 @cindex Bounded-length strings
5662 @unnumberedsec A.4.4(106): Bounded-Length String Handling
5665 Bounded string objects should not be implemented by implicit pointers
5666 and dynamic allocation.
5668 Followed. No implicit pointers or dynamic allocation are used.
5670 @cindex Random number generation
5671 @unnumberedsec A.5.2(46-47): Random Number Generation
5674 Any storage associated with an object of type @code{Generator} should be
5675 reclaimed on exit from the scope of the object.
5681 If the generator period is sufficiently long in relation to the number
5682 of distinct initiator values, then each possible value of
5683 @code{Initiator} passed to @code{Reset} should initiate a sequence of
5684 random numbers that does not, in a practical sense, overlap the sequence
5685 initiated by any other value. If this is not possible, then the mapping
5686 between initiator values and generator states should be a rapidly
5687 varying function of the initiator value.
5689 Followed. The generator period is sufficiently long for the first
5690 condition here to hold true.
5692 @findex Get_Immediate
5693 @unnumberedsec A.10.7(23): @code{Get_Immediate}
5696 The @code{Get_Immediate} procedures should be implemented with
5697 unbuffered input. For a device such as a keyboard, input should be
5698 @dfn{available} if a key has already been typed, whereas for a disk
5699 file, input should always be available except at end of file. For a file
5700 associated with a keyboard-like device, any line-editing features of the
5701 underlying operating system should be disabled during the execution of
5702 @code{Get_Immediate}.
5704 Followed on all targets except VxWorks. For VxWorks, there is no way to
5705 provide this functionality that does not result in the input buffer being
5706 flushed before the @code{Get_Immediate} call. A special unit
5707 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
5711 @unnumberedsec B.1(39-41): Pragma @code{Export}
5714 If an implementation supports pragma @code{Export} to a given language,
5715 then it should also allow the main subprogram to be written in that
5716 language. It should support some mechanism for invoking the elaboration
5717 of the Ada library units included in the system, and for invoking the
5718 finalization of the environment task. On typical systems, the
5719 recommended mechanism is to provide two subprograms whose link names are
5720 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
5721 elaboration code for library units. @code{adafinal} should contain the
5722 finalization code. These subprograms should have no effect the second
5723 and subsequent time they are called.
5729 Automatic elaboration of pre-elaborated packages should be
5730 provided when pragma @code{Export} is supported.
5732 Followed when the main program is in Ada. If the main program is in a
5733 foreign language, then
5734 @code{adainit} must be called to elaborate pre-elaborated
5739 For each supported convention @var{L} other than @code{Intrinsic}, an
5740 implementation should support @code{Import} and @code{Export} pragmas
5741 for objects of @var{L}-compatible types and for subprograms, and pragma
5742 @code{Convention} for @var{L}-eligible types and for subprograms,
5743 presuming the other language has corresponding features. Pragma
5744 @code{Convention} need not be supported for scalar types.
5748 @cindex Package @code{Interfaces}
5750 @unnumberedsec B.2(12-13): Package @code{Interfaces}
5753 For each implementation-defined convention identifier, there should be a
5754 child package of package Interfaces with the corresponding name. This
5755 package should contain any declarations that would be useful for
5756 interfacing to the language (implementation) represented by the
5757 convention. Any declarations useful for interfacing to any language on
5758 the given hardware architecture should be provided directly in
5761 Followed. An additional package not defined
5762 in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
5763 for interfacing to C++.
5767 An implementation supporting an interface to C, COBOL, or Fortran should
5768 provide the corresponding package or packages described in the following
5771 Followed. GNAT provides all the packages described in this section.
5773 @cindex C, interfacing with
5774 @unnumberedsec B.3(63-71): Interfacing with C
5777 An implementation should support the following interface correspondences
5784 An Ada procedure corresponds to a void-returning C function.
5790 An Ada function corresponds to a non-void C function.
5796 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
5803 An Ada @code{in} parameter of an access-to-object type with designated
5804 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
5805 where @var{t} is the C type corresponding to the Ada type @var{T}.
5811 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
5812 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
5813 argument to a C function, where @var{t} is the C type corresponding to
5814 the Ada type @var{T}. In the case of an elementary @code{out} or
5815 @code{in out} parameter, a pointer to a temporary copy is used to
5816 preserve by-copy semantics.
5822 An Ada parameter of a record type @var{T}, of any mode, is passed as a
5823 @code{@var{t}*} argument to a C function, where @var{t} is the C
5824 structure corresponding to the Ada type @var{T}.
5826 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
5827 pragma, or Convention, or by explicitly specifying the mechanism for a given
5828 call using an extended import or export pragma.
5832 An Ada parameter of an array type with component type @var{T}, of any
5833 mode, is passed as a @code{@var{t}*} argument to a C function, where
5834 @var{t} is the C type corresponding to the Ada type @var{T}.
5840 An Ada parameter of an access-to-subprogram type is passed as a pointer
5841 to a C function whose prototype corresponds to the designated
5842 subprogram's specification.
5846 @cindex COBOL, interfacing with
5847 @unnumberedsec B.4(95-98): Interfacing with COBOL
5850 An Ada implementation should support the following interface
5851 correspondences between Ada and COBOL@.
5857 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
5858 the COBOL type corresponding to @var{T}.
5864 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
5865 the corresponding COBOL type.
5871 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
5872 COBOL type corresponding to the Ada parameter type; for scalars, a local
5873 copy is used if necessary to ensure by-copy semantics.
5877 @cindex Fortran, interfacing with
5878 @unnumberedsec B.5(22-26): Interfacing with Fortran
5881 An Ada implementation should support the following interface
5882 correspondences between Ada and Fortran:
5888 An Ada procedure corresponds to a Fortran subroutine.
5894 An Ada function corresponds to a Fortran function.
5900 An Ada parameter of an elementary, array, or record type @var{T} is
5901 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
5902 the Fortran type corresponding to the Ada type @var{T}, and where the
5903 INTENT attribute of the corresponding dummy argument matches the Ada
5904 formal parameter mode; the Fortran implementation's parameter passing
5905 conventions are used. For elementary types, a local copy is used if
5906 necessary to ensure by-copy semantics.
5912 An Ada parameter of an access-to-subprogram type is passed as a
5913 reference to a Fortran procedure whose interface corresponds to the
5914 designated subprogram's specification.
5918 @cindex Machine operations
5919 @unnumberedsec C.1(3-5): Access to Machine Operations
5922 The machine code or intrinsic support should allow access to all
5923 operations normally available to assembly language programmers for the
5924 target environment, including privileged instructions, if any.
5930 The interfacing pragmas (see Annex B) should support interface to
5931 assembler; the default assembler should be associated with the
5932 convention identifier @code{Assembler}.
5938 If an entity is exported to assembly language, then the implementation
5939 should allocate it at an addressable location, and should ensure that it
5940 is retained by the linking process, even if not otherwise referenced
5941 from the Ada code. The implementation should assume that any call to a
5942 machine code or assembler subprogram is allowed to read or update every
5943 object that is specified as exported.
5947 @unnumberedsec C.1(10-16): Access to Machine Operations
5950 The implementation should ensure that little or no overhead is
5951 associated with calling intrinsic and machine-code subprograms.
5953 Followed for both intrinsics and machine-code subprograms.
5957 It is recommended that intrinsic subprograms be provided for convenient
5958 access to any machine operations that provide special capabilities or
5959 efficiency and that are not otherwise available through the language
5962 Followed. A full set of machine operation intrinsic subprograms is provided.
5966 Atomic read-modify-write operations---e.g.@:, test and set, compare and
5967 swap, decrement and test, enqueue/dequeue.
5969 Followed on any target supporting such operations.
5973 Standard numeric functions---e.g.@:, sin, log.
5975 Followed on any target supporting such operations.
5979 String manipulation operations---e.g.@:, translate and test.
5981 Followed on any target supporting such operations.
5985 Vector operations---e.g.@:, compare vector against thresholds.
5987 Followed on any target supporting such operations.
5991 Direct operations on I/O ports.
5993 Followed on any target supporting such operations.
5995 @cindex Interrupt support
5996 @unnumberedsec C.3(28): Interrupt Support
5999 If the @code{Ceiling_Locking} policy is not in effect, the
6000 implementation should provide means for the application to specify which
6001 interrupts are to be blocked during protected actions, if the underlying
6002 system allows for a finer-grain control of interrupt blocking.
6004 Followed. The underlying system does not allow for finer-grain control
6005 of interrupt blocking.
6007 @cindex Protected procedure handlers
6008 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
6011 Whenever possible, the implementation should allow interrupt handlers to
6012 be called directly by the hardware.
6016 This is never possible under IRIX, so this is followed by default.
6018 Followed on any target where the underlying operating system permits
6023 Whenever practical, violations of any
6024 implementation-defined restrictions should be detected before run time.
6026 Followed. Compile time warnings are given when possible.
6028 @cindex Package @code{Interrupts}
6030 @unnumberedsec C.3.2(25): Package @code{Interrupts}
6034 If implementation-defined forms of interrupt handler procedures are
6035 supported, such as protected procedures with parameters, then for each
6036 such form of a handler, a type analogous to @code{Parameterless_Handler}
6037 should be specified in a child package of @code{Interrupts}, with the
6038 same operations as in the predefined package Interrupts.
6042 @cindex Pre-elaboration requirements
6043 @unnumberedsec C.4(14): Pre-elaboration Requirements
6046 It is recommended that pre-elaborated packages be implemented in such a
6047 way that there should be little or no code executed at run time for the
6048 elaboration of entities not already covered by the Implementation
6051 Followed. Executable code is generated in some cases, e.g.@: loops
6052 to initialize large arrays.
6054 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
6058 If the pragma applies to an entity, then the implementation should
6059 reduce the amount of storage used for storing names associated with that
6064 @cindex Package @code{Task_Attributes}
6065 @findex Task_Attributes
6066 @unnumberedsec C.7.2(30): The Package Task_Attributes
6069 Some implementations are targeted to domains in which memory use at run
6070 time must be completely deterministic. For such implementations, it is
6071 recommended that the storage for task attributes will be pre-allocated
6072 statically and not from the heap. This can be accomplished by either
6073 placing restrictions on the number and the size of the task's
6074 attributes, or by using the pre-allocated storage for the first @var{N}
6075 attribute objects, and the heap for the others. In the latter case,
6076 @var{N} should be documented.
6078 Not followed. This implementation is not targeted to such a domain.
6080 @cindex Locking Policies
6081 @unnumberedsec D.3(17): Locking Policies
6085 The implementation should use names that end with @samp{_Locking} for
6086 locking policies defined by the implementation.
6088 Followed. A single implementation-defined locking policy is defined,
6089 whose name (@code{Inheritance_Locking}) follows this suggestion.
6091 @cindex Entry queuing policies
6092 @unnumberedsec D.4(16): Entry Queuing Policies
6095 Names that end with @samp{_Queuing} should be used
6096 for all implementation-defined queuing policies.
6098 Followed. No such implementation-defined queuing policies exist.
6100 @cindex Preemptive abort
6101 @unnumberedsec D.6(9-10): Preemptive Abort
6104 Even though the @code{abort_statement} is included in the list of
6105 potentially blocking operations (see 9.5.1), it is recommended that this
6106 statement be implemented in a way that never requires the task executing
6107 the @code{abort_statement} to block.
6113 On a multi-processor, the delay associated with aborting a task on
6114 another processor should be bounded; the implementation should use
6115 periodic polling, if necessary, to achieve this.
6119 @cindex Tasking restrictions
6120 @unnumberedsec D.7(21): Tasking Restrictions
6123 When feasible, the implementation should take advantage of the specified
6124 restrictions to produce a more efficient implementation.
6126 GNAT currently takes advantage of these restrictions by providing an optimized
6127 run time when the Ravenscar profile and the GNAT restricted run time set
6128 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
6129 pragma @code{Profile (Restricted)} for more details.
6131 @cindex Time, monotonic
6132 @unnumberedsec D.8(47-49): Monotonic Time
6135 When appropriate, implementations should provide configuration
6136 mechanisms to change the value of @code{Tick}.
6138 Such configuration mechanisms are not appropriate to this implementation
6139 and are thus not supported.
6143 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6144 be implemented as transformations of the same time base.
6150 It is recommended that the @dfn{best} time base which exists in
6151 the underlying system be available to the application through
6152 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
6156 @cindex Partition communication subsystem
6158 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6161 Whenever possible, the PCS on the called partition should allow for
6162 multiple tasks to call the RPC-receiver with different messages and
6163 should allow them to block until the corresponding subprogram body
6166 Followed by GLADE, a separately supplied PCS that can be used with
6171 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6172 should raise @code{Storage_Error} if it runs out of space trying to
6173 write the @code{Item} into the stream.
6175 Followed by GLADE, a separately supplied PCS that can be used with
6178 @cindex COBOL support
6179 @unnumberedsec F(7): COBOL Support
6182 If COBOL (respectively, C) is widely supported in the target
6183 environment, implementations supporting the Information Systems Annex
6184 should provide the child package @code{Interfaces.COBOL} (respectively,
6185 @code{Interfaces.C}) specified in Annex B and should support a
6186 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6187 pragmas (see Annex B), thus allowing Ada programs to interface with
6188 programs written in that language.
6192 @cindex Decimal radix support
6193 @unnumberedsec F.1(2): Decimal Radix Support
6196 Packed decimal should be used as the internal representation for objects
6197 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6199 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
6203 @unnumberedsec G: Numerics
6206 If Fortran (respectively, C) is widely supported in the target
6207 environment, implementations supporting the Numerics Annex
6208 should provide the child package @code{Interfaces.Fortran} (respectively,
6209 @code{Interfaces.C}) specified in Annex B and should support a
6210 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6211 pragmas (see Annex B), thus allowing Ada programs to interface with
6212 programs written in that language.
6216 @cindex Complex types
6217 @unnumberedsec G.1.1(56-58): Complex Types
6220 Because the usual mathematical meaning of multiplication of a complex
6221 operand and a real operand is that of the scaling of both components of
6222 the former by the latter, an implementation should not perform this
6223 operation by first promoting the real operand to complex type and then
6224 performing a full complex multiplication. In systems that, in the
6225 future, support an Ada binding to IEC 559:1989, the latter technique
6226 will not generate the required result when one of the components of the
6227 complex operand is infinite. (Explicit multiplication of the infinite
6228 component by the zero component obtained during promotion yields a NaN
6229 that propagates into the final result.) Analogous advice applies in the
6230 case of multiplication of a complex operand and a pure-imaginary
6231 operand, and in the case of division of a complex operand by a real or
6232 pure-imaginary operand.
6238 Similarly, because the usual mathematical meaning of addition of a
6239 complex operand and a real operand is that the imaginary operand remains
6240 unchanged, an implementation should not perform this operation by first
6241 promoting the real operand to complex type and then performing a full
6242 complex addition. In implementations in which the @code{Signed_Zeros}
6243 attribute of the component type is @code{True} (and which therefore
6244 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6245 predefined arithmetic operations), the latter technique will not
6246 generate the required result when the imaginary component of the complex
6247 operand is a negatively signed zero. (Explicit addition of the negative
6248 zero to the zero obtained during promotion yields a positive zero.)
6249 Analogous advice applies in the case of addition of a complex operand
6250 and a pure-imaginary operand, and in the case of subtraction of a
6251 complex operand and a real or pure-imaginary operand.
6257 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6258 attempt to provide a rational treatment of the signs of zero results and
6259 result components. As one example, the result of the @code{Argument}
6260 function should have the sign of the imaginary component of the
6261 parameter @code{X} when the point represented by that parameter lies on
6262 the positive real axis; as another, the sign of the imaginary component
6263 of the @code{Compose_From_Polar} function should be the same as
6264 (respectively, the opposite of) that of the @code{Argument} parameter when that
6265 parameter has a value of zero and the @code{Modulus} parameter has a
6266 nonnegative (respectively, negative) value.
6270 @cindex Complex elementary functions
6271 @unnumberedsec G.1.2(49): Complex Elementary Functions
6274 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6275 @code{True} should attempt to provide a rational treatment of the signs
6276 of zero results and result components. For example, many of the complex
6277 elementary functions have components that are odd functions of one of
6278 the parameter components; in these cases, the result component should
6279 have the sign of the parameter component at the origin. Other complex
6280 elementary functions have zero components whose sign is opposite that of
6281 a parameter component at the origin, or is always positive or always
6286 @cindex Accuracy requirements
6287 @unnumberedsec G.2.4(19): Accuracy Requirements
6290 The versions of the forward trigonometric functions without a
6291 @code{Cycle} parameter should not be implemented by calling the
6292 corresponding version with a @code{Cycle} parameter of
6293 @code{2.0*Numerics.Pi}, since this will not provide the required
6294 accuracy in some portions of the domain. For the same reason, the
6295 version of @code{Log} without a @code{Base} parameter should not be
6296 implemented by calling the corresponding version with a @code{Base}
6297 parameter of @code{Numerics.e}.
6301 @cindex Complex arithmetic accuracy
6302 @cindex Accuracy, complex arithmetic
6303 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6307 The version of the @code{Compose_From_Polar} function without a
6308 @code{Cycle} parameter should not be implemented by calling the
6309 corresponding version with a @code{Cycle} parameter of
6310 @code{2.0*Numerics.Pi}, since this will not provide the required
6311 accuracy in some portions of the domain.
6315 @c -----------------------------------------
6316 @node Implementation Defined Characteristics
6317 @chapter Implementation Defined Characteristics
6320 In addition to the implementation dependent pragmas and attributes, and
6321 the implementation advice, there are a number of other features of Ada
6322 95 that are potentially implementation dependent. These are mentioned
6323 throughout the Ada 95 Reference Manual, and are summarized in annex M@.
6325 A requirement for conforming Ada compilers is that they provide
6326 documentation describing how the implementation deals with each of these
6327 issues. In this chapter, you will find each point in annex M listed
6328 followed by a description in italic font of how GNAT
6332 implementation on IRIX 5.3 operating system or greater
6334 handles the implementation dependence.
6336 You can use this chapter as a guide to minimizing implementation
6337 dependent features in your programs if portability to other compilers
6338 and other operating systems is an important consideration. The numbers
6339 in each section below correspond to the paragraph number in the Ada 95
6345 @strong{2}. Whether or not each recommendation given in Implementation
6346 Advice is followed. See 1.1.2(37).
6349 @xref{Implementation Advice}.
6354 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
6357 The complexity of programs that can be processed is limited only by the
6358 total amount of available virtual memory, and disk space for the
6359 generated object files.
6364 @strong{4}. Variations from the standard that are impractical to avoid
6365 given the implementation's execution environment. See 1.1.3(6).
6368 There are no variations from the standard.
6373 @strong{5}. Which @code{code_statement}s cause external
6374 interactions. See 1.1.3(10).
6377 Any @code{code_statement} can potentially cause external interactions.
6382 @strong{6}. The coded representation for the text of an Ada
6383 program. See 2.1(4).
6386 See separate section on source representation.
6391 @strong{7}. The control functions allowed in comments. See 2.1(14).
6394 See separate section on source representation.
6399 @strong{8}. The representation for an end of line. See 2.2(2).
6402 See separate section on source representation.
6407 @strong{9}. Maximum supported line length and lexical element
6408 length. See 2.2(15).
6411 The maximum line length is 255 characters an the maximum length of a
6412 lexical element is also 255 characters.
6417 @strong{10}. Implementation defined pragmas. See 2.8(14).
6421 @xref{Implementation Defined Pragmas}.
6426 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
6429 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
6430 parameter, checks that the optimization flag is set, and aborts if it is
6436 @strong{12}. The sequence of characters of the value returned by
6437 @code{@var{S}'Image} when some of the graphic characters of
6438 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
6442 The sequence of characters is as defined by the wide character encoding
6443 method used for the source. See section on source representation for
6449 @strong{13}. The predefined integer types declared in
6450 @code{Standard}. See 3.5.4(25).
6454 @item Short_Short_Integer
6457 (Short) 16 bit signed
6461 64 bit signed (Alpha OpenVMS only)
6462 32 bit signed (all other targets)
6463 @item Long_Long_Integer
6470 @strong{14}. Any nonstandard integer types and the operators defined
6471 for them. See 3.5.4(26).
6474 There are no nonstandard integer types.
6479 @strong{15}. Any nonstandard real types and the operators defined for
6483 There are no nonstandard real types.
6488 @strong{16}. What combinations of requested decimal precision and range
6489 are supported for floating point types. See 3.5.7(7).
6492 The precision and range is as defined by the IEEE standard.
6497 @strong{17}. The predefined floating point types declared in
6498 @code{Standard}. See 3.5.7(16).
6505 (Short) 32 bit IEEE short
6508 @item Long_Long_Float
6509 64 bit IEEE long (80 bit IEEE long on x86 processors)
6515 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
6518 @code{Fine_Delta} is 2**(@minus{}63)
6523 @strong{19}. What combinations of small, range, and digits are
6524 supported for fixed point types. See 3.5.9(10).
6527 Any combinations are permitted that do not result in a small less than
6528 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
6529 If the mantissa is larger than 53 bits on machines where Long_Long_Float
6530 is 64 bits (true of all architectures except ia32), then the output from
6531 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
6532 is because floating-point conversions are used to convert fixed point.
6537 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
6538 within an unnamed @code{block_statement}. See 3.9(10).
6541 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
6542 decimal integer are allocated.
6547 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
6550 @xref{Implementation Defined Attributes}.
6555 @strong{22}. Any implementation-defined time types. See 9.6(6).
6558 There are no implementation-defined time types.
6563 @strong{23}. The time base associated with relative delays.
6566 See 9.6(20). The time base used is that provided by the C library
6567 function @code{gettimeofday}.
6572 @strong{24}. The time base of the type @code{Calendar.Time}. See
6576 The time base used is that provided by the C library function
6577 @code{gettimeofday}.
6582 @strong{25}. The time zone used for package @code{Calendar}
6583 operations. See 9.6(24).
6586 The time zone used by package @code{Calendar} is the current system time zone
6587 setting for local time, as accessed by the C library function
6593 @strong{26}. Any limit on @code{delay_until_statements} of
6594 @code{select_statements}. See 9.6(29).
6597 There are no such limits.
6602 @strong{27}. Whether or not two non overlapping parts of a composite
6603 object are independently addressable, in the case where packing, record
6604 layout, or @code{Component_Size} is specified for the object. See
6608 Separate components are independently addressable if they do not share
6609 overlapping storage units.
6614 @strong{28}. The representation for a compilation. See 10.1(2).
6617 A compilation is represented by a sequence of files presented to the
6618 compiler in a single invocation of the @code{gcc} command.
6623 @strong{29}. Any restrictions on compilations that contain multiple
6624 compilation_units. See 10.1(4).
6627 No single file can contain more than one compilation unit, but any
6628 sequence of files can be presented to the compiler as a single
6634 @strong{30}. The mechanisms for creating an environment and for adding
6635 and replacing compilation units. See 10.1.4(3).
6638 See separate section on compilation model.
6643 @strong{31}. The manner of explicitly assigning library units to a
6644 partition. See 10.2(2).
6647 If a unit contains an Ada main program, then the Ada units for the partition
6648 are determined by recursive application of the rules in the Ada Reference
6649 Manual section 10.2(2-6). In other words, the Ada units will be those that
6650 are needed by the main program, and then this definition of need is applied
6651 recursively to those units, and the partition contains the transitive
6652 closure determined by this relationship. In short, all the necessary units
6653 are included, with no need to explicitly specify the list. If additional
6654 units are required, e.g.@: by foreign language units, then all units must be
6655 mentioned in the context clause of one of the needed Ada units.
6657 If the partition contains no main program, or if the main program is in
6658 a language other than Ada, then GNAT
6659 provides the binder options @code{-z} and @code{-n} respectively, and in
6660 this case a list of units can be explicitly supplied to the binder for
6661 inclusion in the partition (all units needed by these units will also
6662 be included automatically). For full details on the use of these
6663 options, refer to the @cite{GNAT User's Guide} sections on Binding
6669 @strong{32}. The implementation-defined means, if any, of specifying
6670 which compilation units are needed by a given compilation unit. See
6674 The units needed by a given compilation unit are as defined in
6675 the Ada Reference Manual section 10.2(2-6). There are no
6676 implementation-defined pragmas or other implementation-defined
6677 means for specifying needed units.
6682 @strong{33}. The manner of designating the main subprogram of a
6683 partition. See 10.2(7).
6686 The main program is designated by providing the name of the
6687 corresponding @file{ALI} file as the input parameter to the binder.
6692 @strong{34}. The order of elaboration of @code{library_items}. See
6696 The first constraint on ordering is that it meets the requirements of
6697 chapter 10 of the Ada 95 Reference Manual. This still leaves some
6698 implementation dependent choices, which are resolved by first
6699 elaborating bodies as early as possible (i.e.@: in preference to specs
6700 where there is a choice), and second by evaluating the immediate with
6701 clauses of a unit to determine the probably best choice, and
6702 third by elaborating in alphabetical order of unit names
6703 where a choice still remains.
6708 @strong{35}. Parameter passing and function return for the main
6709 subprogram. See 10.2(21).
6712 The main program has no parameters. It may be a procedure, or a function
6713 returning an integer type. In the latter case, the returned integer
6714 value is the return code of the program (overriding any value that
6715 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
6720 @strong{36}. The mechanisms for building and running partitions. See
6724 GNAT itself supports programs with only a single partition. The GNATDIST
6725 tool provided with the GLADE package (which also includes an implementation
6726 of the PCS) provides a completely flexible method for building and running
6727 programs consisting of multiple partitions. See the separate GLADE manual
6733 @strong{37}. The details of program execution, including program
6734 termination. See 10.2(25).
6737 See separate section on compilation model.
6742 @strong{38}. The semantics of any non-active partitions supported by the
6743 implementation. See 10.2(28).
6746 Passive partitions are supported on targets where shared memory is
6747 provided by the operating system. See the GLADE reference manual for
6753 @strong{39}. The information returned by @code{Exception_Message}. See
6757 Exception message returns the null string unless a specific message has
6758 been passed by the program.
6763 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
6764 declared within an unnamed @code{block_statement}. See 11.4.1(12).
6767 Blocks have implementation defined names of the form @code{B@var{nnn}}
6768 where @var{nnn} is an integer.
6773 @strong{41}. The information returned by
6774 @code{Exception_Information}. See 11.4.1(13).
6777 @code{Exception_Information} returns a string in the following format:
6780 @emph{Exception_Name:} nnnnn
6781 @emph{Message:} mmmmm
6783 @emph{Call stack traceback locations:}
6784 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
6792 @code{nnnn} is the fully qualified name of the exception in all upper
6793 case letters. This line is always present.
6796 @code{mmmm} is the message (this line present only if message is non-null)
6799 @code{ppp} is the Process Id value as a decimal integer (this line is
6800 present only if the Process Id is non-zero). Currently we are
6801 not making use of this field.
6804 The Call stack traceback locations line and the following values
6805 are present only if at least one traceback location was recorded.
6806 The values are given in C style format, with lower case letters
6807 for a-f, and only as many digits present as are necessary.
6811 The line terminator sequence at the end of each line, including
6812 the last line is a single @code{LF} character (@code{16#0A#}).
6817 @strong{42}. Implementation-defined check names. See 11.5(27).
6820 No implementation-defined check names are supported.
6825 @strong{43}. The interpretation of each aspect of representation. See
6829 See separate section on data representations.
6834 @strong{44}. Any restrictions placed upon representation items. See
6838 See separate section on data representations.
6843 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
6847 Size for an indefinite subtype is the maximum possible size, except that
6848 for the case of a subprogram parameter, the size of the parameter object
6854 @strong{46}. The default external representation for a type tag. See
6858 The default external representation for a type tag is the fully expanded
6859 name of the type in upper case letters.
6864 @strong{47}. What determines whether a compilation unit is the same in
6865 two different partitions. See 13.3(76).
6868 A compilation unit is the same in two different partitions if and only
6869 if it derives from the same source file.
6874 @strong{48}. Implementation-defined components. See 13.5.1(15).
6877 The only implementation defined component is the tag for a tagged type,
6878 which contains a pointer to the dispatching table.
6883 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
6884 ordering. See 13.5.3(5).
6887 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
6888 implementation, so no non-default bit ordering is supported. The default
6889 bit ordering corresponds to the natural endianness of the target architecture.
6894 @strong{50}. The contents of the visible part of package @code{System}
6895 and its language-defined children. See 13.7(2).
6898 See the definition of these packages in files @file{system.ads} and
6899 @file{s-stoele.ads}.
6904 @strong{51}. The contents of the visible part of package
6905 @code{System.Machine_Code}, and the meaning of
6906 @code{code_statements}. See 13.8(7).
6909 See the definition and documentation in file @file{s-maccod.ads}.
6914 @strong{52}. The effect of unchecked conversion. See 13.9(11).
6917 Unchecked conversion between types of the same size
6918 and results in an uninterpreted transmission of the bits from one type
6919 to the other. If the types are of unequal sizes, then in the case of
6920 discrete types, a shorter source is first zero or sign extended as
6921 necessary, and a shorter target is simply truncated on the left.
6922 For all non-discrete types, the source is first copied if necessary
6923 to ensure that the alignment requirements of the target are met, then
6924 a pointer is constructed to the source value, and the result is obtained
6925 by dereferencing this pointer after converting it to be a pointer to the
6931 @strong{53}. The manner of choosing a storage pool for an access type
6932 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
6935 There are 3 different standard pools used by the compiler when
6936 @code{Storage_Pool} is not specified depending whether the type is local
6937 to a subprogram or defined at the library level and whether
6938 @code{Storage_Size}is specified or not. See documentation in the runtime
6939 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
6940 @code{System.Pool_Local} in files @file{s-poosiz.ads},
6941 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
6947 @strong{54}. Whether or not the implementation provides user-accessible
6948 names for the standard pool type(s). See 13.11(17).
6952 See documentation in the sources of the run time mentioned in paragraph
6953 @strong{53} . All these pools are accessible by means of @code{with}'ing
6959 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
6962 @code{Storage_Size} is measured in storage units, and refers to the
6963 total space available for an access type collection, or to the primary
6964 stack space for a task.
6969 @strong{56}. Implementation-defined aspects of storage pools. See
6973 See documentation in the sources of the run time mentioned in paragraph
6974 @strong{53} for details on GNAT-defined aspects of storage pools.
6979 @strong{57}. The set of restrictions allowed in a pragma
6980 @code{Restrictions}. See 13.12(7).
6983 All RM defined Restriction identifiers are implemented. The following
6984 additional restriction identifiers are provided. There are two separate
6985 lists of implementation dependent restriction identifiers. The first
6986 set requires consistency throughout a partition (in other words, if the
6987 restriction identifier is used for any compilation unit in the partition,
6988 then all compilation units in the partition must obey the restriction.
6992 @item Simple_Barriers
6993 @findex Simple_Barriers
6994 This restriction ensures at compile time that barriers in entry declarations
6995 for protected types are restricted to either static boolean expressions or
6996 references to simple boolean variables defined in the private part of the
6997 protected type. No other form of entry barriers is permitted. This is one
6998 of the restrictions of the Ravenscar profile for limited tasking (see also
6999 pragma @code{Profile (Ravenscar)}).
7001 @item Max_Entry_Queue_Length => Expr
7002 @findex Max_Entry_Queue_Length
7003 This restriction is a declaration that any protected entry compiled in
7004 the scope of the restriction has at most the specified number of
7005 tasks waiting on the entry
7006 at any one time, and so no queue is required. This restriction is not
7007 checked at compile time. A program execution is erroneous if an attempt
7008 is made to queue more than the specified number of tasks on such an entry.
7012 This restriction ensures at compile time that there is no implicit or
7013 explicit dependence on the package @code{Ada.Calendar}.
7015 @item No_Direct_Boolean_Operators
7016 @findex No_Direct_Boolean_Operators
7017 This restriction ensures that no logical (and/or/xor) or comparison
7018 operators are used on operands of type Boolean (or any type derived
7019 from Boolean). This is intended for use in safety critical programs
7020 where the certification protocol requires the use of short-circuit
7021 (and then, or else) forms for all composite boolean operations.
7023 @item No_Dynamic_Attachment
7024 @findex No_Dynamic_Attachment
7025 This restriction ensures that there is no call to any of the operations
7026 defined in package Ada.Interrupts.
7028 @item No_Enumeration_Maps
7029 @findex No_Enumeration_Maps
7030 This restriction ensures at compile time that no operations requiring
7031 enumeration maps are used (that is Image and Value attributes applied
7032 to enumeration types).
7034 @item No_Entry_Calls_In_Elaboration_Code
7035 @findex No_Entry_Calls_In_Elaboration_Code
7036 This restriction ensures at compile time that no task or protected entry
7037 calls are made during elaboration code. As a result of the use of this
7038 restriction, the compiler can assume that no code past an accept statement
7039 in a task can be executed at elaboration time.
7041 @item No_Exception_Handlers
7042 @findex No_Exception_Handlers
7043 This restriction ensures at compile time that there are no explicit
7044 exception handlers. It also indicates that no exception propagation will
7045 be provided. In this mode, exceptions may be raised but will result in
7046 an immediate call to the last chance handler, a routine that the user
7047 must define with the following profile:
7049 procedure Last_Chance_Handler
7050 (Source_Location : System.Address; Line : Integer);
7051 pragma Export (C, Last_Chance_Handler,
7052 "__gnat_last_chance_handler");
7054 The parameter is a C null-terminated string representing a message to be
7055 associated with the exception (typically the source location of the raise
7056 statement generated by the compiler). The Line parameter when non-zero
7057 represents the line number in the source program where the raise occurs.
7059 @item No_Exception_Streams
7060 @findex No_Exception_Streams
7061 This restriction ensures at compile time that no stream operations for
7062 types Exception_Id or Exception_Occurrence are used. This also makes it
7063 impossible to pass exceptions to or from a partition with this restriction
7064 in a distributed environment. If this exception is active, then the generated
7065 code is simplified by omitting the otherwise-required global registration
7066 of exceptions when they are declared.
7068 @item No_Implicit_Conditionals
7069 @findex No_Implicit_Conditionals
7070 This restriction ensures that the generated code does not contain any
7071 implicit conditionals, either by modifying the generated code where possible,
7072 or by rejecting any construct that would otherwise generate an implicit
7073 conditional. Note that this check does not include run time constraint
7074 checks, which on some targets may generate implicit conditionals as
7075 well. To control the latter, constraint checks can be suppressed in the
7078 @item No_Implicit_Dynamic_Code
7079 @findex No_Implicit_Dynamic_Code
7080 This restriction prevents the compiler from building ``trampolines''.
7081 This is a structure that is built on the stack and contains dynamic
7082 code to be executed at run time. A trampoline is needed to indirectly
7083 address a nested subprogram (that is a subprogram that is not at the
7084 library level). The restriction prevents the use of any of the
7085 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
7086 being applied to a subprogram that is not at the library level.
7088 @item No_Implicit_Loops
7089 @findex No_Implicit_Loops
7090 This restriction ensures that the generated code does not contain any
7091 implicit @code{for} loops, either by modifying
7092 the generated code where possible,
7093 or by rejecting any construct that would otherwise generate an implicit
7096 @item No_Initialize_Scalars
7097 @findex No_Initialize_Scalars
7098 This restriction ensures that no unit in the partition is compiled with
7099 pragma Initialize_Scalars. This allows the generation of more efficient
7100 code, and in particular eliminates dummy null initialization routines that
7101 are otherwise generated for some record and array types.
7103 @item No_Local_Protected_Objects
7104 @findex No_Local_Protected_Objects
7105 This restriction ensures at compile time that protected objects are
7106 only declared at the library level.
7108 @item No_Protected_Type_Allocators
7109 @findex No_Protected_Type_Allocators
7110 This restriction ensures at compile time that there are no allocator
7111 expressions that attempt to allocate protected objects.
7113 @item No_Secondary_Stack
7114 @findex No_Secondary_Stack
7115 This restriction ensures at compile time that the generated code does not
7116 contain any reference to the secondary stack. The secondary stack is used
7117 to implement functions returning unconstrained objects (arrays or records)
7120 @item No_Select_Statements
7121 @findex No_Select_Statements
7122 This restriction ensures at compile time no select statements of any kind
7123 are permitted, that is the keyword @code{select} may not appear.
7124 This is one of the restrictions of the Ravenscar
7125 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7127 @item No_Standard_Storage_Pools
7128 @findex No_Standard_Storage_Pools
7129 This restriction ensures at compile time that no access types
7130 use the standard default storage pool. Any access type declared must
7131 have an explicit Storage_Pool attribute defined specifying a
7132 user-defined storage pool.
7136 This restriction ensures at compile/bind time that there are no
7137 stream objects created (and therefore no actual stream operations).
7138 This restriction does not forbid dependences on the package
7139 @code{Ada.Streams}. So it is permissible to with
7140 @code{Ada.Streams} (or another package that does so itself)
7141 as long as no actual stream objects are created.
7143 @item No_Task_Attributes_Package
7144 @findex No_Task_Attributes_Package
7145 This restriction ensures at compile time that there are no implicit or
7146 explicit dependencies on the package @code{Ada.Task_Attributes}.
7148 @item No_Task_Termination
7149 @findex No_Task_Termination
7150 This restriction ensures at compile time that no terminate alternatives
7151 appear in any task body.
7155 This restriction prevents the declaration of tasks or task types throughout
7156 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
7157 except that violations are caught at compile time and cause an error message
7158 to be output either by the compiler or binder.
7160 @item No_Wide_Characters
7161 @findex No_Wide_Characters
7162 This restriction ensures at compile time that no uses of the types
7163 @code{Wide_Character} or @code{Wide_String} or corresponding wide
7165 appear, and that no wide or wide wide string or character literals
7166 appear in the program (that is literals representing characters not in
7167 type @code{Character}.
7169 @item Static_Priorities
7170 @findex Static_Priorities
7171 This restriction ensures at compile time that all priority expressions
7172 are static, and that there are no dependencies on the package
7173 @code{Ada.Dynamic_Priorities}.
7175 @item Static_Storage_Size
7176 @findex Static_Storage_Size
7177 This restriction ensures at compile time that any expression appearing
7178 in a Storage_Size pragma or attribute definition clause is static.
7183 The second set of implementation dependent restriction identifiers
7184 does not require partition-wide consistency.
7185 The restriction may be enforced for a single
7186 compilation unit without any effect on any of the
7187 other compilation units in the partition.
7191 @item No_Elaboration_Code
7192 @findex No_Elaboration_Code
7193 This restriction ensures at compile time that no elaboration code is
7194 generated. Note that this is not the same condition as is enforced
7195 by pragma @code{Preelaborate}. There are cases in which pragma
7196 @code{Preelaborate} still permits code to be generated (e.g.@: code
7197 to initialize a large array to all zeroes), and there are cases of units
7198 which do not meet the requirements for pragma @code{Preelaborate},
7199 but for which no elaboration code is generated. Generally, it is
7200 the case that preelaborable units will meet the restrictions, with
7201 the exception of large aggregates initialized with an others_clause,
7202 and exception declarations (which generate calls to a run-time
7203 registry procedure). Note that this restriction is enforced on
7204 a unit by unit basis, it need not be obeyed consistently
7205 throughout a partition.
7207 @item No_Entry_Queue
7208 @findex No_Entry_Queue
7209 This restriction is a declaration that any protected entry compiled in
7210 the scope of the restriction has at most one task waiting on the entry
7211 at any one time, and so no queue is required. This restriction is not
7212 checked at compile time. A program execution is erroneous if an attempt
7213 is made to queue a second task on such an entry.
7215 @item No_Implementation_Attributes
7216 @findex No_Implementation_Attributes
7217 This restriction checks at compile time that no GNAT-defined attributes
7218 are present. With this restriction, the only attributes that can be used
7219 are those defined in the Ada 95 Reference Manual.
7221 @item No_Implementation_Pragmas
7222 @findex No_Implementation_Pragmas
7223 This restriction checks at compile time that no GNAT-defined pragmas
7224 are present. With this restriction, the only pragmas that can be used
7225 are those defined in the Ada 95 Reference Manual.
7227 @item No_Implementation_Restrictions
7228 @findex No_Implementation_Restrictions
7229 This restriction checks at compile time that no GNAT-defined restriction
7230 identifiers (other than @code{No_Implementation_Restrictions} itself)
7231 are present. With this restriction, the only other restriction identifiers
7232 that can be used are those defined in the Ada 95 Reference Manual.
7239 @strong{58}. The consequences of violating limitations on
7240 @code{Restrictions} pragmas. See 13.12(9).
7243 Restrictions that can be checked at compile time result in illegalities
7244 if violated. Currently there are no other consequences of violating
7250 @strong{59}. The representation used by the @code{Read} and
7251 @code{Write} attributes of elementary types in terms of stream
7252 elements. See 13.13.2(9).
7255 The representation is the in-memory representation of the base type of
7256 the type, using the number of bits corresponding to the
7257 @code{@var{type}'Size} value, and the natural ordering of the machine.
7262 @strong{60}. The names and characteristics of the numeric subtypes
7263 declared in the visible part of package @code{Standard}. See A.1(3).
7266 See items describing the integer and floating-point types supported.
7271 @strong{61}. The accuracy actually achieved by the elementary
7272 functions. See A.5.1(1).
7275 The elementary functions correspond to the functions available in the C
7276 library. Only fast math mode is implemented.
7281 @strong{62}. The sign of a zero result from some of the operators or
7282 functions in @code{Numerics.Generic_Elementary_Functions}, when
7283 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
7286 The sign of zeroes follows the requirements of the IEEE 754 standard on
7292 @strong{63}. The value of
7293 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
7296 Maximum image width is 649, see library file @file{a-numran.ads}.
7301 @strong{64}. The value of
7302 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
7305 Maximum image width is 80, see library file @file{a-nudira.ads}.
7310 @strong{65}. The algorithms for random number generation. See
7314 The algorithm is documented in the source files @file{a-numran.ads} and
7315 @file{a-numran.adb}.
7320 @strong{66}. The string representation of a random number generator's
7321 state. See A.5.2(38).
7324 See the documentation contained in the file @file{a-numran.adb}.
7329 @strong{67}. The minimum time interval between calls to the
7330 time-dependent Reset procedure that are guaranteed to initiate different
7331 random number sequences. See A.5.2(45).
7334 The minimum period between reset calls to guarantee distinct series of
7335 random numbers is one microsecond.
7340 @strong{68}. The values of the @code{Model_Mantissa},
7341 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
7342 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
7343 Annex is not supported. See A.5.3(72).
7346 See the source file @file{ttypef.ads} for the values of all numeric
7352 @strong{69}. Any implementation-defined characteristics of the
7353 input-output packages. See A.7(14).
7356 There are no special implementation defined characteristics for these
7362 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
7366 All type representations are contiguous, and the @code{Buffer_Size} is
7367 the value of @code{@var{type}'Size} rounded up to the next storage unit
7373 @strong{71}. External files for standard input, standard output, and
7374 standard error See A.10(5).
7377 These files are mapped onto the files provided by the C streams
7378 libraries. See source file @file{i-cstrea.ads} for further details.
7383 @strong{72}. The accuracy of the value produced by @code{Put}. See
7387 If more digits are requested in the output than are represented by the
7388 precision of the value, zeroes are output in the corresponding least
7389 significant digit positions.
7394 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
7395 @code{Command_Name}. See A.15(1).
7398 These are mapped onto the @code{argv} and @code{argc} parameters of the
7399 main program in the natural manner.
7404 @strong{74}. Implementation-defined convention names. See B.1(11).
7407 The following convention names are supported
7415 Synonym for Assembler
7417 Synonym for Assembler
7420 @item C_Pass_By_Copy
7421 Allowed only for record types, like C, but also notes that record
7422 is to be passed by copy rather than reference.
7428 Treated the same as C
7430 Treated the same as C
7434 For support of pragma @code{Import} with convention Intrinsic, see
7435 separate section on Intrinsic Subprograms.
7437 Stdcall (used for Windows implementations only). This convention correspond
7438 to the WINAPI (previously called Pascal convention) C/C++ convention under
7439 Windows. A function with this convention cleans the stack before exit.
7445 Stubbed is a special convention used to indicate that the body of the
7446 subprogram will be entirely ignored. Any call to the subprogram
7447 is converted into a raise of the @code{Program_Error} exception. If a
7448 pragma @code{Import} specifies convention @code{stubbed} then no body need
7449 be present at all. This convention is useful during development for the
7450 inclusion of subprograms whose body has not yet been written.
7454 In addition, all otherwise unrecognized convention names are also
7455 treated as being synonymous with convention C@. In all implementations
7456 except for VMS, use of such other names results in a warning. In VMS
7457 implementations, these names are accepted silently.
7462 @strong{75}. The meaning of link names. See B.1(36).
7465 Link names are the actual names used by the linker.
7470 @strong{76}. The manner of choosing link names when neither the link
7471 name nor the address of an imported or exported entity is specified. See
7475 The default linker name is that which would be assigned by the relevant
7476 external language, interpreting the Ada name as being in all lower case
7482 @strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37).
7485 The string passed to @code{Linker_Options} is presented uninterpreted as
7486 an argument to the link command, unless it contains Ascii.NUL characters.
7487 NUL characters if they appear act as argument separators, so for example
7489 @smallexample @c ada
7490 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
7494 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
7495 linker. The order of linker options is preserved for a given unit. The final
7496 list of options passed to the linker is in reverse order of the elaboration
7497 order. For example, linker options fo a body always appear before the options
7498 from the corresponding package spec.
7503 @strong{78}. The contents of the visible part of package
7504 @code{Interfaces} and its language-defined descendants. See B.2(1).
7507 See files with prefix @file{i-} in the distributed library.
7512 @strong{79}. Implementation-defined children of package
7513 @code{Interfaces}. The contents of the visible part of package
7514 @code{Interfaces}. See B.2(11).
7517 See files with prefix @file{i-} in the distributed library.
7522 @strong{80}. The types @code{Floating}, @code{Long_Floating},
7523 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
7524 @code{COBOL_Character}; and the initialization of the variables
7525 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
7526 @code{Interfaces.COBOL}. See B.4(50).
7533 (Floating) Long_Float
7538 @item Decimal_Element
7540 @item COBOL_Character
7545 For initialization, see the file @file{i-cobol.ads} in the distributed library.
7550 @strong{81}. Support for access to machine instructions. See C.1(1).
7553 See documentation in file @file{s-maccod.ads} in the distributed library.
7558 @strong{82}. Implementation-defined aspects of access to machine
7559 operations. See C.1(9).
7562 See documentation in file @file{s-maccod.ads} in the distributed library.
7567 @strong{83}. Implementation-defined aspects of interrupts. See C.3(2).
7570 Interrupts are mapped to signals or conditions as appropriate. See
7572 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
7573 on the interrupts supported on a particular target.
7578 @strong{84}. Implementation-defined aspects of pre-elaboration. See
7582 GNAT does not permit a partition to be restarted without reloading,
7583 except under control of the debugger.
7588 @strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7).
7591 Pragma @code{Discard_Names} causes names of enumeration literals to
7592 be suppressed. In the presence of this pragma, the Image attribute
7593 provides the image of the Pos of the literal, and Value accepts
7599 @strong{86}. The result of the @code{Task_Identification.Image}
7600 attribute. See C.7.1(7).
7603 The result of this attribute is an 8-digit hexadecimal string
7604 representing the virtual address of the task control block.
7609 @strong{87}. The value of @code{Current_Task} when in a protected entry
7610 or interrupt handler. See C.7.1(17).
7613 Protected entries or interrupt handlers can be executed by any
7614 convenient thread, so the value of @code{Current_Task} is undefined.
7619 @strong{88}. The effect of calling @code{Current_Task} from an entry
7620 body or interrupt handler. See C.7.1(19).
7623 The effect of calling @code{Current_Task} from an entry body or
7624 interrupt handler is to return the identification of the task currently
7630 @strong{89}. Implementation-defined aspects of
7631 @code{Task_Attributes}. See C.7.2(19).
7634 There are no implementation-defined aspects of @code{Task_Attributes}.
7639 @strong{90}. Values of all @code{Metrics}. See D(2).
7642 The metrics information for GNAT depends on the performance of the
7643 underlying operating system. The sources of the run-time for tasking
7644 implementation, together with the output from @code{-gnatG} can be
7645 used to determine the exact sequence of operating systems calls made
7646 to implement various tasking constructs. Together with appropriate
7647 information on the performance of the underlying operating system,
7648 on the exact target in use, this information can be used to determine
7649 the required metrics.
7654 @strong{91}. The declarations of @code{Any_Priority} and
7655 @code{Priority}. See D.1(11).
7658 See declarations in file @file{system.ads}.
7663 @strong{92}. Implementation-defined execution resources. See D.1(15).
7666 There are no implementation-defined execution resources.
7671 @strong{93}. Whether, on a multiprocessor, a task that is waiting for
7672 access to a protected object keeps its processor busy. See D.2.1(3).
7675 On a multi-processor, a task that is waiting for access to a protected
7676 object does not keep its processor busy.
7681 @strong{94}. The affect of implementation defined execution resources
7682 on task dispatching. See D.2.1(9).
7687 Tasks map to IRIX threads, and the dispatching policy is as defined by
7688 the IRIX implementation of threads.
7690 Tasks map to threads in the threads package used by GNAT@. Where possible
7691 and appropriate, these threads correspond to native threads of the
7692 underlying operating system.
7697 @strong{95}. Implementation-defined @code{policy_identifiers} allowed
7698 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
7701 There are no implementation-defined policy-identifiers allowed in this
7707 @strong{96}. Implementation-defined aspects of priority inversion. See
7711 Execution of a task cannot be preempted by the implementation processing
7712 of delay expirations for lower priority tasks.
7717 @strong{97}. Implementation defined task dispatching. See D.2.2(18).
7722 Tasks map to IRIX threads, and the dispatching policy is as defied by
7723 the IRIX implementation of threads.
7725 The policy is the same as that of the underlying threads implementation.
7730 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
7731 in a pragma @code{Locking_Policy}. See D.3(4).
7734 The only implementation defined policy permitted in GNAT is
7735 @code{Inheritance_Locking}. On targets that support this policy, locking
7736 is implemented by inheritance, i.e.@: the task owning the lock operates
7737 at a priority equal to the highest priority of any task currently
7738 requesting the lock.
7743 @strong{99}. Default ceiling priorities. See D.3(10).
7746 The ceiling priority of protected objects of the type
7747 @code{System.Interrupt_Priority'Last} as described in the Ada 95
7748 Reference Manual D.3(10),
7753 @strong{100}. The ceiling of any protected object used internally by
7754 the implementation. See D.3(16).
7757 The ceiling priority of internal protected objects is
7758 @code{System.Priority'Last}.
7763 @strong{101}. Implementation-defined queuing policies. See D.4(1).
7766 There are no implementation-defined queueing policies.
7771 @strong{102}. On a multiprocessor, any conditions that cause the
7772 completion of an aborted construct to be delayed later than what is
7773 specified for a single processor. See D.6(3).
7776 The semantics for abort on a multi-processor is the same as on a single
7777 processor, there are no further delays.
7782 @strong{103}. Any operations that implicitly require heap storage
7783 allocation. See D.7(8).
7786 The only operation that implicitly requires heap storage allocation is
7792 @strong{104}. Implementation-defined aspects of pragma
7793 @code{Restrictions}. See D.7(20).
7796 There are no such implementation-defined aspects.
7801 @strong{105}. Implementation-defined aspects of package
7802 @code{Real_Time}. See D.8(17).
7805 There are no implementation defined aspects of package @code{Real_Time}.
7810 @strong{106}. Implementation-defined aspects of
7811 @code{delay_statements}. See D.9(8).
7814 Any difference greater than one microsecond will cause the task to be
7815 delayed (see D.9(7)).
7820 @strong{107}. The upper bound on the duration of interrupt blocking
7821 caused by the implementation. See D.12(5).
7824 The upper bound is determined by the underlying operating system. In
7825 no cases is it more than 10 milliseconds.
7830 @strong{108}. The means for creating and executing distributed
7834 The GLADE package provides a utility GNATDIST for creating and executing
7835 distributed programs. See the GLADE reference manual for further details.
7840 @strong{109}. Any events that can result in a partition becoming
7841 inaccessible. See E.1(7).
7844 See the GLADE reference manual for full details on such events.
7849 @strong{110}. The scheduling policies, treatment of priorities, and
7850 management of shared resources between partitions in certain cases. See
7854 See the GLADE reference manual for full details on these aspects of
7855 multi-partition execution.
7860 @strong{111}. Events that cause the version of a compilation unit to
7864 Editing the source file of a compilation unit, or the source files of
7865 any units on which it is dependent in a significant way cause the version
7866 to change. No other actions cause the version number to change. All changes
7867 are significant except those which affect only layout, capitalization or
7873 @strong{112}. Whether the execution of the remote subprogram is
7874 immediately aborted as a result of cancellation. See E.4(13).
7877 See the GLADE reference manual for details on the effect of abort in
7878 a distributed application.
7883 @strong{113}. Implementation-defined aspects of the PCS@. See E.5(25).
7886 See the GLADE reference manual for a full description of all implementation
7887 defined aspects of the PCS@.
7892 @strong{114}. Implementation-defined interfaces in the PCS@. See
7896 See the GLADE reference manual for a full description of all
7897 implementation defined interfaces.
7902 @strong{115}. The values of named numbers in the package
7903 @code{Decimal}. See F.2(7).
7915 @item Max_Decimal_Digits
7922 @strong{116}. The value of @code{Max_Picture_Length} in the package
7923 @code{Text_IO.Editing}. See F.3.3(16).
7931 @strong{117}. The value of @code{Max_Picture_Length} in the package
7932 @code{Wide_Text_IO.Editing}. See F.3.4(5).
7940 @strong{118}. The accuracy actually achieved by the complex elementary
7941 functions and by other complex arithmetic operations. See G.1(1).
7944 Standard library functions are used for the complex arithmetic
7945 operations. Only fast math mode is currently supported.
7950 @strong{119}. The sign of a zero result (or a component thereof) from
7951 any operator or function in @code{Numerics.Generic_Complex_Types}, when
7952 @code{Real'Signed_Zeros} is True. See G.1.1(53).
7955 The signs of zero values are as recommended by the relevant
7956 implementation advice.
7961 @strong{120}. The sign of a zero result (or a component thereof) from
7962 any operator or function in
7963 @code{Numerics.Generic_Complex_Elementary_Functions}, when
7964 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
7967 The signs of zero values are as recommended by the relevant
7968 implementation advice.
7973 @strong{121}. Whether the strict mode or the relaxed mode is the
7974 default. See G.2(2).
7977 The strict mode is the default. There is no separate relaxed mode. GNAT
7978 provides a highly efficient implementation of strict mode.
7983 @strong{122}. The result interval in certain cases of fixed-to-float
7984 conversion. See G.2.1(10).
7987 For cases where the result interval is implementation dependent, the
7988 accuracy is that provided by performing all operations in 64-bit IEEE
7989 floating-point format.
7994 @strong{123}. The result of a floating point arithmetic operation in
7995 overflow situations, when the @code{Machine_Overflows} attribute of the
7996 result type is @code{False}. See G.2.1(13).
7999 Infinite and Nan values are produced as dictated by the IEEE
8000 floating-point standard.
8005 @strong{124}. The result interval for division (or exponentiation by a
8006 negative exponent), when the floating point hardware implements division
8007 as multiplication by a reciprocal. See G.2.1(16).
8010 Not relevant, division is IEEE exact.
8015 @strong{125}. The definition of close result set, which determines the
8016 accuracy of certain fixed point multiplications and divisions. See
8020 Operations in the close result set are performed using IEEE long format
8021 floating-point arithmetic. The input operands are converted to
8022 floating-point, the operation is done in floating-point, and the result
8023 is converted to the target type.
8028 @strong{126}. Conditions on a @code{universal_real} operand of a fixed
8029 point multiplication or division for which the result shall be in the
8030 perfect result set. See G.2.3(22).
8033 The result is only defined to be in the perfect result set if the result
8034 can be computed by a single scaling operation involving a scale factor
8035 representable in 64-bits.
8040 @strong{127}. The result of a fixed point arithmetic operation in
8041 overflow situations, when the @code{Machine_Overflows} attribute of the
8042 result type is @code{False}. See G.2.3(27).
8045 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
8051 @strong{128}. The result of an elementary function reference in
8052 overflow situations, when the @code{Machine_Overflows} attribute of the
8053 result type is @code{False}. See G.2.4(4).
8056 IEEE infinite and Nan values are produced as appropriate.
8061 @strong{129}. The value of the angle threshold, within which certain
8062 elementary functions, complex arithmetic operations, and complex
8063 elementary functions yield results conforming to a maximum relative
8064 error bound. See G.2.4(10).
8067 Information on this subject is not yet available.
8072 @strong{130}. The accuracy of certain elementary functions for
8073 parameters beyond the angle threshold. See G.2.4(10).
8076 Information on this subject is not yet available.
8081 @strong{131}. The result of a complex arithmetic operation or complex
8082 elementary function reference in overflow situations, when the
8083 @code{Machine_Overflows} attribute of the corresponding real type is
8084 @code{False}. See G.2.6(5).
8087 IEEE infinite and Nan values are produced as appropriate.
8092 @strong{132}. The accuracy of certain complex arithmetic operations and
8093 certain complex elementary functions for parameters (or components
8094 thereof) beyond the angle threshold. See G.2.6(8).
8097 Information on those subjects is not yet available.
8102 @strong{133}. Information regarding bounded errors and erroneous
8103 execution. See H.2(1).
8106 Information on this subject is not yet available.
8111 @strong{134}. Implementation-defined aspects of pragma
8112 @code{Inspection_Point}. See H.3.2(8).
8115 Pragma @code{Inspection_Point} ensures that the variable is live and can
8116 be examined by the debugger at the inspection point.
8121 @strong{135}. Implementation-defined aspects of pragma
8122 @code{Restrictions}. See H.4(25).
8125 There are no implementation-defined aspects of pragma @code{Restrictions}. The
8126 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
8127 generated code. Checks must suppressed by use of pragma @code{Suppress}.
8132 @strong{136}. Any restrictions on pragma @code{Restrictions}. See
8136 There are no restrictions on pragma @code{Restrictions}.
8138 @node Intrinsic Subprograms
8139 @chapter Intrinsic Subprograms
8140 @cindex Intrinsic Subprograms
8143 * Intrinsic Operators::
8144 * Enclosing_Entity::
8145 * Exception_Information::
8146 * Exception_Message::
8154 * Shift_Right_Arithmetic::
8159 GNAT allows a user application program to write the declaration:
8161 @smallexample @c ada
8162 pragma Import (Intrinsic, name);
8166 providing that the name corresponds to one of the implemented intrinsic
8167 subprograms in GNAT, and that the parameter profile of the referenced
8168 subprogram meets the requirements. This chapter describes the set of
8169 implemented intrinsic subprograms, and the requirements on parameter profiles.
8170 Note that no body is supplied; as with other uses of pragma Import, the
8171 body is supplied elsewhere (in this case by the compiler itself). Note
8172 that any use of this feature is potentially non-portable, since the
8173 Ada standard does not require Ada compilers to implement this feature.
8175 @node Intrinsic Operators
8176 @section Intrinsic Operators
8177 @cindex Intrinsic operator
8180 All the predefined numeric operators in package Standard
8181 in @code{pragma Import (Intrinsic,..)}
8182 declarations. In the binary operator case, the operands must have the same
8183 size. The operand or operands must also be appropriate for
8184 the operator. For example, for addition, the operands must
8185 both be floating-point or both be fixed-point, and the
8186 right operand for @code{"**"} must have a root type of
8187 @code{Standard.Integer'Base}.
8188 You can use an intrinsic operator declaration as in the following example:
8190 @smallexample @c ada
8191 type Int1 is new Integer;
8192 type Int2 is new Integer;
8194 function "+" (X1 : Int1; X2 : Int2) return Int1;
8195 function "+" (X1 : Int1; X2 : Int2) return Int2;
8196 pragma Import (Intrinsic, "+");
8200 This declaration would permit ``mixed mode'' arithmetic on items
8201 of the differing types @code{Int1} and @code{Int2}.
8202 It is also possible to specify such operators for private types, if the
8203 full views are appropriate arithmetic types.
8205 @node Enclosing_Entity
8206 @section Enclosing_Entity
8207 @cindex Enclosing_Entity
8209 This intrinsic subprogram is used in the implementation of the
8210 library routine @code{GNAT.Source_Info}. The only useful use of the
8211 intrinsic import in this case is the one in this unit, so an
8212 application program should simply call the function
8213 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8214 the current subprogram, package, task, entry, or protected subprogram.
8216 @node Exception_Information
8217 @section Exception_Information
8218 @cindex Exception_Information'
8220 This intrinsic subprogram is used in the implementation of the
8221 library routine @code{GNAT.Current_Exception}. The only useful
8222 use of the intrinsic import in this case is the one in this unit,
8223 so an application program should simply call the function
8224 @code{GNAT.Current_Exception.Exception_Information} to obtain
8225 the exception information associated with the current exception.
8227 @node Exception_Message
8228 @section Exception_Message
8229 @cindex Exception_Message
8231 This intrinsic subprogram is used in the implementation of the
8232 library routine @code{GNAT.Current_Exception}. The only useful
8233 use of the intrinsic import in this case is the one in this unit,
8234 so an application program should simply call the function
8235 @code{GNAT.Current_Exception.Exception_Message} to obtain
8236 the message associated with the current exception.
8238 @node Exception_Name
8239 @section Exception_Name
8240 @cindex Exception_Name
8242 This intrinsic subprogram is used in the implementation of the
8243 library routine @code{GNAT.Current_Exception}. The only useful
8244 use of the intrinsic import in this case is the one in this unit,
8245 so an application program should simply call the function
8246 @code{GNAT.Current_Exception.Exception_Name} to obtain
8247 the name of the current exception.
8253 This intrinsic subprogram is used in the implementation of the
8254 library routine @code{GNAT.Source_Info}. The only useful use of the
8255 intrinsic import in this case is the one in this unit, so an
8256 application program should simply call the function
8257 @code{GNAT.Source_Info.File} to obtain the name of the current
8264 This intrinsic subprogram is used in the implementation of the
8265 library routine @code{GNAT.Source_Info}. The only useful use of the
8266 intrinsic import in this case is the one in this unit, so an
8267 application program should simply call the function
8268 @code{GNAT.Source_Info.Line} to obtain the number of the current
8272 @section Rotate_Left
8275 In standard Ada 95, the @code{Rotate_Left} function is available only
8276 for the predefined modular types in package @code{Interfaces}. However, in
8277 GNAT it is possible to define a Rotate_Left function for a user
8278 defined modular type or any signed integer type as in this example:
8280 @smallexample @c ada
8282 (Value : My_Modular_Type;
8284 return My_Modular_Type;
8288 The requirements are that the profile be exactly as in the example
8289 above. The only modifications allowed are in the formal parameter
8290 names, and in the type of @code{Value} and the return type, which
8291 must be the same, and must be either a signed integer type, or
8292 a modular integer type with a binary modulus, and the size must
8293 be 8. 16, 32 or 64 bits.
8296 @section Rotate_Right
8297 @cindex Rotate_Right
8299 A @code{Rotate_Right} function can be defined for any user defined
8300 binary modular integer type, or signed integer type, as described
8301 above for @code{Rotate_Left}.
8307 A @code{Shift_Left} function can be defined for any user defined
8308 binary modular integer type, or signed integer type, as described
8309 above for @code{Rotate_Left}.
8312 @section Shift_Right
8315 A @code{Shift_Right} function can be defined for any user defined
8316 binary modular integer type, or signed integer type, as described
8317 above for @code{Rotate_Left}.
8319 @node Shift_Right_Arithmetic
8320 @section Shift_Right_Arithmetic
8321 @cindex Shift_Right_Arithmetic
8323 A @code{Shift_Right_Arithmetic} function can be defined for any user
8324 defined binary modular integer type, or signed integer type, as described
8325 above for @code{Rotate_Left}.
8327 @node Source_Location
8328 @section Source_Location
8329 @cindex Source_Location
8331 This intrinsic subprogram is used in the implementation of the
8332 library routine @code{GNAT.Source_Info}. The only useful use of the
8333 intrinsic import in this case is the one in this unit, so an
8334 application program should simply call the function
8335 @code{GNAT.Source_Info.Source_Location} to obtain the current
8336 source file location.
8338 @node Representation Clauses and Pragmas
8339 @chapter Representation Clauses and Pragmas
8340 @cindex Representation Clauses
8343 * Alignment Clauses::
8345 * Storage_Size Clauses::
8346 * Size of Variant Record Objects::
8347 * Biased Representation ::
8348 * Value_Size and Object_Size Clauses::
8349 * Component_Size Clauses::
8350 * Bit_Order Clauses::
8351 * Effect of Bit_Order on Byte Ordering::
8352 * Pragma Pack for Arrays::
8353 * Pragma Pack for Records::
8354 * Record Representation Clauses::
8355 * Enumeration Clauses::
8357 * Effect of Convention on Representation::
8358 * Determining the Representations chosen by GNAT::
8362 @cindex Representation Clause
8363 @cindex Representation Pragma
8364 @cindex Pragma, representation
8365 This section describes the representation clauses accepted by GNAT, and
8366 their effect on the representation of corresponding data objects.
8368 GNAT fully implements Annex C (Systems Programming). This means that all
8369 the implementation advice sections in chapter 13 are fully implemented.
8370 However, these sections only require a minimal level of support for
8371 representation clauses. GNAT provides much more extensive capabilities,
8372 and this section describes the additional capabilities provided.
8374 @node Alignment Clauses
8375 @section Alignment Clauses
8376 @cindex Alignment Clause
8379 GNAT requires that all alignment clauses specify a power of 2, and all
8380 default alignments are always a power of 2. The default alignment
8381 values are as follows:
8384 @item @emph{Primitive Types}.
8385 For primitive types, the alignment is the minimum of the actual size of
8386 objects of the type divided by @code{Storage_Unit},
8387 and the maximum alignment supported by the target.
8388 (This maximum alignment is given by the GNAT-specific attribute
8389 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
8390 @cindex @code{Maximum_Alignment} attribute
8391 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
8392 default alignment will be 8 on any target that supports alignments
8393 this large, but on some targets, the maximum alignment may be smaller
8394 than 8, in which case objects of type @code{Long_Float} will be maximally
8397 @item @emph{Arrays}.
8398 For arrays, the alignment is equal to the alignment of the component type
8399 for the normal case where no packing or component size is given. If the
8400 array is packed, and the packing is effective (see separate section on
8401 packed arrays), then the alignment will be one for long packed arrays,
8402 or arrays whose length is not known at compile time. For short packed
8403 arrays, which are handled internally as modular types, the alignment
8404 will be as described for primitive types, e.g.@: a packed array of length
8405 31 bits will have an object size of four bytes, and an alignment of 4.
8407 @item @emph{Records}.
8408 For the normal non-packed case, the alignment of a record is equal to
8409 the maximum alignment of any of its components. For tagged records, this
8410 includes the implicit access type used for the tag. If a pragma @code{Pack} is
8411 used and all fields are packable (see separate section on pragma @code{Pack}),
8412 then the resulting alignment is 1.
8414 A special case is when:
8417 the size of the record is given explicitly, or a
8418 full record representation clause is given, and
8420 the size of the record is 2, 4, or 8 bytes.
8423 In this case, an alignment is chosen to match the
8424 size of the record. For example, if we have:
8426 @smallexample @c ada
8427 type Small is record
8430 for Small'Size use 16;
8434 then the default alignment of the record type @code{Small} is 2, not 1. This
8435 leads to more efficient code when the record is treated as a unit, and also
8436 allows the type to specified as @code{Atomic} on architectures requiring
8442 An alignment clause may
8443 always specify a larger alignment than the default value, up to some
8444 maximum value dependent on the target (obtainable by using the
8445 attribute reference @code{Standard'Maximum_Alignment}).
8447 it is permissible to specify a smaller alignment than the default value
8448 is for a record with a record representation clause.
8449 In this case, packable fields for which a component clause is
8450 given still result in a default alignment corresponding to the original
8451 type, but this may be overridden, since these components in fact only
8452 require an alignment of one byte. For example, given
8454 @smallexample @c ada
8460 A at 0 range 0 .. 31;
8463 for V'alignment use 1;
8467 @cindex Alignment, default
8468 The default alignment for the type @code{V} is 4, as a result of the
8469 Integer field in the record, but since this field is placed with a
8470 component clause, it is permissible, as shown, to override the default
8471 alignment of the record with a smaller value.
8474 @section Size Clauses
8478 The default size for a type @code{T} is obtainable through the
8479 language-defined attribute @code{T'Size} and also through the
8480 equivalent GNAT-defined attribute @code{T'Value_Size}.
8481 For objects of type @code{T}, GNAT will generally increase the type size
8482 so that the object size (obtainable through the GNAT-defined attribute
8483 @code{T'Object_Size})
8484 is a multiple of @code{T'Alignment * Storage_Unit}.
8487 @smallexample @c ada
8488 type Smallint is range 1 .. 6;
8497 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
8498 as specified by the RM rules,
8499 but objects of this type will have a size of 8
8500 (@code{Smallint'Object_Size} = 8),
8501 since objects by default occupy an integral number
8502 of storage units. On some targets, notably older
8503 versions of the Digital Alpha, the size of stand
8504 alone objects of this type may be 32, reflecting
8505 the inability of the hardware to do byte load/stores.
8507 Similarly, the size of type @code{Rec} is 40 bits
8508 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
8509 the alignment is 4, so objects of this type will have
8510 their size increased to 64 bits so that it is a multiple
8511 of the alignment (in bits). This decision is
8512 in accordance with the specific Implementation Advice in RM 13.3(43):
8515 A @code{Size} clause should be supported for an object if the specified
8516 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
8517 to a size in storage elements that is a multiple of the object's
8518 @code{Alignment} (if the @code{Alignment} is nonzero).
8522 An explicit size clause may be used to override the default size by
8523 increasing it. For example, if we have:
8525 @smallexample @c ada
8526 type My_Boolean is new Boolean;
8527 for My_Boolean'Size use 32;
8531 then values of this type will always be 32 bits long. In the case of
8532 discrete types, the size can be increased up to 64 bits, with the effect
8533 that the entire specified field is used to hold the value, sign- or
8534 zero-extended as appropriate. If more than 64 bits is specified, then
8535 padding space is allocated after the value, and a warning is issued that
8536 there are unused bits.
8538 Similarly the size of records and arrays may be increased, and the effect
8539 is to add padding bits after the value. This also causes a warning message
8542 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
8543 Size in bits, this corresponds to an object of size 256 megabytes (minus
8544 one). This limitation is true on all targets. The reason for this
8545 limitation is that it improves the quality of the code in many cases
8546 if it is known that a Size value can be accommodated in an object of
8549 @node Storage_Size Clauses
8550 @section Storage_Size Clauses
8551 @cindex Storage_Size Clause
8554 For tasks, the @code{Storage_Size} clause specifies the amount of space
8555 to be allocated for the task stack. This cannot be extended, and if the
8556 stack is exhausted, then @code{Storage_Error} will be raised (if stack
8557 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
8558 or a @code{Storage_Size} pragma in the task definition to set the
8559 appropriate required size. A useful technique is to include in every
8560 task definition a pragma of the form:
8562 @smallexample @c ada
8563 pragma Storage_Size (Default_Stack_Size);
8567 Then @code{Default_Stack_Size} can be defined in a global package, and
8568 modified as required. Any tasks requiring stack sizes different from the
8569 default can have an appropriate alternative reference in the pragma.
8571 For access types, the @code{Storage_Size} clause specifies the maximum
8572 space available for allocation of objects of the type. If this space is
8573 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
8574 In the case where the access type is declared local to a subprogram, the
8575 use of a @code{Storage_Size} clause triggers automatic use of a special
8576 predefined storage pool (@code{System.Pool_Size}) that ensures that all
8577 space for the pool is automatically reclaimed on exit from the scope in
8578 which the type is declared.
8580 A special case recognized by the compiler is the specification of a
8581 @code{Storage_Size} of zero for an access type. This means that no
8582 items can be allocated from the pool, and this is recognized at compile
8583 time, and all the overhead normally associated with maintaining a fixed
8584 size storage pool is eliminated. Consider the following example:
8586 @smallexample @c ada
8588 type R is array (Natural) of Character;
8589 type P is access all R;
8590 for P'Storage_Size use 0;
8591 -- Above access type intended only for interfacing purposes
8595 procedure g (m : P);
8596 pragma Import (C, g);
8607 As indicated in this example, these dummy storage pools are often useful in
8608 connection with interfacing where no object will ever be allocated. If you
8609 compile the above example, you get the warning:
8612 p.adb:16:09: warning: allocation from empty storage pool
8613 p.adb:16:09: warning: Storage_Error will be raised at run time
8617 Of course in practice, there will not be any explicit allocators in the
8618 case of such an access declaration.
8620 @node Size of Variant Record Objects
8621 @section Size of Variant Record Objects
8622 @cindex Size, variant record objects
8623 @cindex Variant record objects, size
8626 In the case of variant record objects, there is a question whether Size gives
8627 information about a particular variant, or the maximum size required
8628 for any variant. Consider the following program
8630 @smallexample @c ada
8631 with Text_IO; use Text_IO;
8633 type R1 (A : Boolean := False) is record
8635 when True => X : Character;
8644 Put_Line (Integer'Image (V1'Size));
8645 Put_Line (Integer'Image (V2'Size));
8650 Here we are dealing with a variant record, where the True variant
8651 requires 16 bits, and the False variant requires 8 bits.
8652 In the above example, both V1 and V2 contain the False variant,
8653 which is only 8 bits long. However, the result of running the
8662 The reason for the difference here is that the discriminant value of
8663 V1 is fixed, and will always be False. It is not possible to assign
8664 a True variant value to V1, therefore 8 bits is sufficient. On the
8665 other hand, in the case of V2, the initial discriminant value is
8666 False (from the default), but it is possible to assign a True
8667 variant value to V2, therefore 16 bits must be allocated for V2
8668 in the general case, even fewer bits may be needed at any particular
8669 point during the program execution.
8671 As can be seen from the output of this program, the @code{'Size}
8672 attribute applied to such an object in GNAT gives the actual allocated
8673 size of the variable, which is the largest size of any of the variants.
8674 The Ada Reference Manual is not completely clear on what choice should
8675 be made here, but the GNAT behavior seems most consistent with the
8676 language in the RM@.
8678 In some cases, it may be desirable to obtain the size of the current
8679 variant, rather than the size of the largest variant. This can be
8680 achieved in GNAT by making use of the fact that in the case of a
8681 subprogram parameter, GNAT does indeed return the size of the current
8682 variant (because a subprogram has no way of knowing how much space
8683 is actually allocated for the actual).
8685 Consider the following modified version of the above program:
8687 @smallexample @c ada
8688 with Text_IO; use Text_IO;
8690 type R1 (A : Boolean := False) is record
8692 when True => X : Character;
8699 function Size (V : R1) return Integer is
8705 Put_Line (Integer'Image (V2'Size));
8706 Put_Line (Integer'IMage (Size (V2)));
8708 Put_Line (Integer'Image (V2'Size));
8709 Put_Line (Integer'IMage (Size (V2)));
8714 The output from this program is
8724 Here we see that while the @code{'Size} attribute always returns
8725 the maximum size, regardless of the current variant value, the
8726 @code{Size} function does indeed return the size of the current
8729 @node Biased Representation
8730 @section Biased Representation
8731 @cindex Size for biased representation
8732 @cindex Biased representation
8735 In the case of scalars with a range starting at other than zero, it is
8736 possible in some cases to specify a size smaller than the default minimum
8737 value, and in such cases, GNAT uses an unsigned biased representation,
8738 in which zero is used to represent the lower bound, and successive values
8739 represent successive values of the type.
8741 For example, suppose we have the declaration:
8743 @smallexample @c ada
8744 type Small is range -7 .. -4;
8745 for Small'Size use 2;
8749 Although the default size of type @code{Small} is 4, the @code{Size}
8750 clause is accepted by GNAT and results in the following representation
8754 -7 is represented as 2#00#
8755 -6 is represented as 2#01#
8756 -5 is represented as 2#10#
8757 -4 is represented as 2#11#
8761 Biased representation is only used if the specified @code{Size} clause
8762 cannot be accepted in any other manner. These reduced sizes that force
8763 biased representation can be used for all discrete types except for
8764 enumeration types for which a representation clause is given.
8766 @node Value_Size and Object_Size Clauses
8767 @section Value_Size and Object_Size Clauses
8770 @cindex Size, of objects
8773 In Ada 95, @code{T'Size} for a type @code{T} is the minimum number of bits
8774 required to hold values of type @code{T}. Although this interpretation was
8775 allowed in Ada 83, it was not required, and this requirement in practice
8776 can cause some significant difficulties. For example, in most Ada 83
8777 compilers, @code{Natural'Size} was 32. However, in Ada 95,
8778 @code{Natural'Size} is
8779 typically 31. This means that code may change in behavior when moving
8780 from Ada 83 to Ada 95. For example, consider:
8782 @smallexample @c ada
8789 at 0 range 0 .. Natural'Size - 1;
8790 at 0 range Natural'Size .. 2 * Natural'Size - 1;
8795 In the above code, since the typical size of @code{Natural} objects
8796 is 32 bits and @code{Natural'Size} is 31, the above code can cause
8797 unexpected inefficient packing in Ada 95, and in general there are
8798 cases where the fact that the object size can exceed the
8799 size of the type causes surprises.
8801 To help get around this problem GNAT provides two implementation
8802 defined attributes, @code{Value_Size} and @code{Object_Size}. When
8803 applied to a type, these attributes yield the size of the type
8804 (corresponding to the RM defined size attribute), and the size of
8805 objects of the type respectively.
8807 The @code{Object_Size} is used for determining the default size of
8808 objects and components. This size value can be referred to using the
8809 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
8810 the basis of the determination of the size. The backend is free to
8811 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
8812 character might be stored in 32 bits on a machine with no efficient
8813 byte access instructions such as the Alpha.
8815 The default rules for the value of @code{Object_Size} for
8816 discrete types are as follows:
8820 The @code{Object_Size} for base subtypes reflect the natural hardware
8821 size in bits (run the compiler with @option{-gnatS} to find those values
8822 for numeric types). Enumeration types and fixed-point base subtypes have
8823 8, 16, 32 or 64 bits for this size, depending on the range of values
8827 The @code{Object_Size} of a subtype is the same as the
8828 @code{Object_Size} of
8829 the type from which it is obtained.
8832 The @code{Object_Size} of a derived base type is copied from the parent
8833 base type, and the @code{Object_Size} of a derived first subtype is copied
8834 from the parent first subtype.
8838 The @code{Value_Size} attribute
8839 is the (minimum) number of bits required to store a value
8841 This value is used to determine how tightly to pack
8842 records or arrays with components of this type, and also affects
8843 the semantics of unchecked conversion (unchecked conversions where
8844 the @code{Value_Size} values differ generate a warning, and are potentially
8847 The default rules for the value of @code{Value_Size} are as follows:
8851 The @code{Value_Size} for a base subtype is the minimum number of bits
8852 required to store all values of the type (including the sign bit
8853 only if negative values are possible).
8856 If a subtype statically matches the first subtype of a given type, then it has
8857 by default the same @code{Value_Size} as the first subtype. This is a
8858 consequence of RM 13.1(14) (``if two subtypes statically match,
8859 then their subtype-specific aspects are the same''.)
8862 All other subtypes have a @code{Value_Size} corresponding to the minimum
8863 number of bits required to store all values of the subtype. For
8864 dynamic bounds, it is assumed that the value can range down or up
8865 to the corresponding bound of the ancestor
8869 The RM defined attribute @code{Size} corresponds to the
8870 @code{Value_Size} attribute.
8872 The @code{Size} attribute may be defined for a first-named subtype. This sets
8873 the @code{Value_Size} of
8874 the first-named subtype to the given value, and the
8875 @code{Object_Size} of this first-named subtype to the given value padded up
8876 to an appropriate boundary. It is a consequence of the default rules
8877 above that this @code{Object_Size} will apply to all further subtypes. On the
8878 other hand, @code{Value_Size} is affected only for the first subtype, any
8879 dynamic subtypes obtained from it directly, and any statically matching
8880 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
8882 @code{Value_Size} and
8883 @code{Object_Size} may be explicitly set for any subtype using
8884 an attribute definition clause. Note that the use of these attributes
8885 can cause the RM 13.1(14) rule to be violated. If two access types
8886 reference aliased objects whose subtypes have differing @code{Object_Size}
8887 values as a result of explicit attribute definition clauses, then it
8888 is erroneous to convert from one access subtype to the other.
8890 At the implementation level, Esize stores the Object_Size and the
8891 RM_Size field stores the @code{Value_Size} (and hence the value of the
8892 @code{Size} attribute,
8893 which, as noted above, is equivalent to @code{Value_Size}).
8895 To get a feel for the difference, consider the following examples (note
8896 that in each case the base is @code{Short_Short_Integer} with a size of 8):
8899 Object_Size Value_Size
8901 type x1 is range 0 .. 5; 8 3
8903 type x2 is range 0 .. 5;
8904 for x2'size use 12; 16 12
8906 subtype x3 is x2 range 0 .. 3; 16 2
8908 subtype x4 is x2'base range 0 .. 10; 8 4
8910 subtype x5 is x2 range 0 .. dynamic; 16 3*
8912 subtype x6 is x2'base range 0 .. dynamic; 8 3*
8917 Note: the entries marked ``3*'' are not actually specified by the Ada 95 RM,
8918 but it seems in the spirit of the RM rules to allocate the minimum number
8919 of bits (here 3, given the range for @code{x2})
8920 known to be large enough to hold the given range of values.
8922 So far, so good, but GNAT has to obey the RM rules, so the question is
8923 under what conditions must the RM @code{Size} be used.
8924 The following is a list
8925 of the occasions on which the RM @code{Size} must be used:
8929 Component size for packed arrays or records
8932 Value of the attribute @code{Size} for a type
8935 Warning about sizes not matching for unchecked conversion
8939 For record types, the @code{Object_Size} is always a multiple of the
8940 alignment of the type (this is true for all types). In some cases the
8941 @code{Value_Size} can be smaller. Consider:
8951 On a typical 32-bit architecture, the X component will be four bytes, and
8952 require four-byte alignment, and the Y component will be one byte. In this
8953 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
8954 required to store a value of this type, and for example, it is permissible
8955 to have a component of type R in an outer record whose component size is
8956 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
8957 since it must be rounded up so that this value is a multiple of the
8958 alignment (4 bytes = 32 bits).
8961 For all other types, the @code{Object_Size}
8962 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
8963 Only @code{Size} may be specified for such types.
8965 @node Component_Size Clauses
8966 @section Component_Size Clauses
8967 @cindex Component_Size Clause
8970 Normally, the value specified in a component clause must be consistent
8971 with the subtype of the array component with regard to size and alignment.
8972 In other words, the value specified must be at least equal to the size
8973 of this subtype, and must be a multiple of the alignment value.
8975 In addition, component size clauses are allowed which cause the array
8976 to be packed, by specifying a smaller value. The cases in which this
8977 is allowed are for component size values in the range 1 through 63. The value
8978 specified must not be smaller than the Size of the subtype. GNAT will
8979 accurately honor all packing requests in this range. For example, if
8982 @smallexample @c ada
8983 type r is array (1 .. 8) of Natural;
8984 for r'Component_Size use 31;
8988 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
8989 Of course access to the components of such an array is considerably
8990 less efficient than if the natural component size of 32 is used.
8992 @node Bit_Order Clauses
8993 @section Bit_Order Clauses
8994 @cindex Bit_Order Clause
8995 @cindex bit ordering
8996 @cindex ordering, of bits
8999 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
9000 attribute. The specification may either correspond to the default bit
9001 order for the target, in which case the specification has no effect and
9002 places no additional restrictions, or it may be for the non-standard
9003 setting (that is the opposite of the default).
9005 In the case where the non-standard value is specified, the effect is
9006 to renumber bits within each byte, but the ordering of bytes is not
9007 affected. There are certain
9008 restrictions placed on component clauses as follows:
9012 @item Components fitting within a single storage unit.
9014 These are unrestricted, and the effect is merely to renumber bits. For
9015 example if we are on a little-endian machine with @code{Low_Order_First}
9016 being the default, then the following two declarations have exactly
9019 @smallexample @c ada
9022 B : Integer range 1 .. 120;
9026 A at 0 range 0 .. 0;
9027 B at 0 range 1 .. 7;
9032 B : Integer range 1 .. 120;
9035 for R2'Bit_Order use High_Order_First;
9038 A at 0 range 7 .. 7;
9039 B at 0 range 0 .. 6;
9044 The useful application here is to write the second declaration with the
9045 @code{Bit_Order} attribute definition clause, and know that it will be treated
9046 the same, regardless of whether the target is little-endian or big-endian.
9048 @item Components occupying an integral number of bytes.
9050 These are components that exactly fit in two or more bytes. Such component
9051 declarations are allowed, but have no effect, since it is important to realize
9052 that the @code{Bit_Order} specification does not affect the ordering of bytes.
9053 In particular, the following attempt at getting an endian-independent integer
9056 @smallexample @c ada
9061 for R2'Bit_Order use High_Order_First;
9064 A at 0 range 0 .. 31;
9069 This declaration will result in a little-endian integer on a
9070 little-endian machine, and a big-endian integer on a big-endian machine.
9071 If byte flipping is required for interoperability between big- and
9072 little-endian machines, this must be explicitly programmed. This capability
9073 is not provided by @code{Bit_Order}.
9075 @item Components that are positioned across byte boundaries
9077 but do not occupy an integral number of bytes. Given that bytes are not
9078 reordered, such fields would occupy a non-contiguous sequence of bits
9079 in memory, requiring non-trivial code to reassemble. They are for this
9080 reason not permitted, and any component clause specifying such a layout
9081 will be flagged as illegal by GNAT@.
9086 Since the misconception that Bit_Order automatically deals with all
9087 endian-related incompatibilities is a common one, the specification of
9088 a component field that is an integral number of bytes will always
9089 generate a warning. This warning may be suppressed using
9090 @code{pragma Suppress} if desired. The following section contains additional
9091 details regarding the issue of byte ordering.
9093 @node Effect of Bit_Order on Byte Ordering
9094 @section Effect of Bit_Order on Byte Ordering
9095 @cindex byte ordering
9096 @cindex ordering, of bytes
9099 In this section we will review the effect of the @code{Bit_Order} attribute
9100 definition clause on byte ordering. Briefly, it has no effect at all, but
9101 a detailed example will be helpful. Before giving this
9102 example, let us review the precise
9103 definition of the effect of defining @code{Bit_Order}. The effect of a
9104 non-standard bit order is described in section 15.5.3 of the Ada
9108 2 A bit ordering is a method of interpreting the meaning of
9109 the storage place attributes.
9113 To understand the precise definition of storage place attributes in
9114 this context, we visit section 13.5.1 of the manual:
9117 13 A record_representation_clause (without the mod_clause)
9118 specifies the layout. The storage place attributes (see 13.5.2)
9119 are taken from the values of the position, first_bit, and last_bit
9120 expressions after normalizing those values so that first_bit is
9121 less than Storage_Unit.
9125 The critical point here is that storage places are taken from
9126 the values after normalization, not before. So the @code{Bit_Order}
9127 interpretation applies to normalized values. The interpretation
9128 is described in the later part of the 15.5.3 paragraph:
9131 2 A bit ordering is a method of interpreting the meaning of
9132 the storage place attributes. High_Order_First (known in the
9133 vernacular as ``big endian'') means that the first bit of a
9134 storage element (bit 0) is the most significant bit (interpreting
9135 the sequence of bits that represent a component as an unsigned
9136 integer value). Low_Order_First (known in the vernacular as
9137 ``little endian'') means the opposite: the first bit is the
9142 Note that the numbering is with respect to the bits of a storage
9143 unit. In other words, the specification affects only the numbering
9144 of bits within a single storage unit.
9146 We can make the effect clearer by giving an example.
9148 Suppose that we have an external device which presents two bytes, the first
9149 byte presented, which is the first (low addressed byte) of the two byte
9150 record is called Master, and the second byte is called Slave.
9152 The left most (most significant bit is called Control for each byte, and
9153 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9154 (least significant) bit.
9156 On a big-endian machine, we can write the following representation clause
9158 @smallexample @c ada
9160 Master_Control : Bit;
9168 Slave_Control : Bit;
9179 Master_Control at 0 range 0 .. 0;
9180 Master_V1 at 0 range 1 .. 1;
9181 Master_V2 at 0 range 2 .. 2;
9182 Master_V3 at 0 range 3 .. 3;
9183 Master_V4 at 0 range 4 .. 4;
9184 Master_V5 at 0 range 5 .. 5;
9185 Master_V6 at 0 range 6 .. 6;
9186 Master_V7 at 0 range 7 .. 7;
9187 Slave_Control at 1 range 0 .. 0;
9188 Slave_V1 at 1 range 1 .. 1;
9189 Slave_V2 at 1 range 2 .. 2;
9190 Slave_V3 at 1 range 3 .. 3;
9191 Slave_V4 at 1 range 4 .. 4;
9192 Slave_V5 at 1 range 5 .. 5;
9193 Slave_V6 at 1 range 6 .. 6;
9194 Slave_V7 at 1 range 7 .. 7;
9199 Now if we move this to a little endian machine, then the bit ordering within
9200 the byte is backwards, so we have to rewrite the record rep clause as:
9202 @smallexample @c ada
9204 Master_Control at 0 range 7 .. 7;
9205 Master_V1 at 0 range 6 .. 6;
9206 Master_V2 at 0 range 5 .. 5;
9207 Master_V3 at 0 range 4 .. 4;
9208 Master_V4 at 0 range 3 .. 3;
9209 Master_V5 at 0 range 2 .. 2;
9210 Master_V6 at 0 range 1 .. 1;
9211 Master_V7 at 0 range 0 .. 0;
9212 Slave_Control at 1 range 7 .. 7;
9213 Slave_V1 at 1 range 6 .. 6;
9214 Slave_V2 at 1 range 5 .. 5;
9215 Slave_V3 at 1 range 4 .. 4;
9216 Slave_V4 at 1 range 3 .. 3;
9217 Slave_V5 at 1 range 2 .. 2;
9218 Slave_V6 at 1 range 1 .. 1;
9219 Slave_V7 at 1 range 0 .. 0;
9224 It is a nuisance to have to rewrite the clause, especially if
9225 the code has to be maintained on both machines. However,
9226 this is a case that we can handle with the
9227 @code{Bit_Order} attribute if it is implemented.
9228 Note that the implementation is not required on byte addressed
9229 machines, but it is indeed implemented in GNAT.
9230 This means that we can simply use the
9231 first record clause, together with the declaration
9233 @smallexample @c ada
9234 for Data'Bit_Order use High_Order_First;
9238 and the effect is what is desired, namely the layout is exactly the same,
9239 independent of whether the code is compiled on a big-endian or little-endian
9242 The important point to understand is that byte ordering is not affected.
9243 A @code{Bit_Order} attribute definition never affects which byte a field
9244 ends up in, only where it ends up in that byte.
9245 To make this clear, let us rewrite the record rep clause of the previous
9248 @smallexample @c ada
9249 for Data'Bit_Order use High_Order_First;
9251 Master_Control at 0 range 0 .. 0;
9252 Master_V1 at 0 range 1 .. 1;
9253 Master_V2 at 0 range 2 .. 2;
9254 Master_V3 at 0 range 3 .. 3;
9255 Master_V4 at 0 range 4 .. 4;
9256 Master_V5 at 0 range 5 .. 5;
9257 Master_V6 at 0 range 6 .. 6;
9258 Master_V7 at 0 range 7 .. 7;
9259 Slave_Control at 0 range 8 .. 8;
9260 Slave_V1 at 0 range 9 .. 9;
9261 Slave_V2 at 0 range 10 .. 10;
9262 Slave_V3 at 0 range 11 .. 11;
9263 Slave_V4 at 0 range 12 .. 12;
9264 Slave_V5 at 0 range 13 .. 13;
9265 Slave_V6 at 0 range 14 .. 14;
9266 Slave_V7 at 0 range 15 .. 15;
9271 This is exactly equivalent to saying (a repeat of the first example):
9273 @smallexample @c ada
9274 for Data'Bit_Order use High_Order_First;
9276 Master_Control at 0 range 0 .. 0;
9277 Master_V1 at 0 range 1 .. 1;
9278 Master_V2 at 0 range 2 .. 2;
9279 Master_V3 at 0 range 3 .. 3;
9280 Master_V4 at 0 range 4 .. 4;
9281 Master_V5 at 0 range 5 .. 5;
9282 Master_V6 at 0 range 6 .. 6;
9283 Master_V7 at 0 range 7 .. 7;
9284 Slave_Control at 1 range 0 .. 0;
9285 Slave_V1 at 1 range 1 .. 1;
9286 Slave_V2 at 1 range 2 .. 2;
9287 Slave_V3 at 1 range 3 .. 3;
9288 Slave_V4 at 1 range 4 .. 4;
9289 Slave_V5 at 1 range 5 .. 5;
9290 Slave_V6 at 1 range 6 .. 6;
9291 Slave_V7 at 1 range 7 .. 7;
9296 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
9297 field. The storage place attributes are obtained by normalizing the
9298 values given so that the @code{First_Bit} value is less than 8. After
9299 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
9300 we specified in the other case.
9302 Now one might expect that the @code{Bit_Order} attribute might affect
9303 bit numbering within the entire record component (two bytes in this
9304 case, thus affecting which byte fields end up in), but that is not
9305 the way this feature is defined, it only affects numbering of bits,
9306 not which byte they end up in.
9308 Consequently it never makes sense to specify a starting bit number
9309 greater than 7 (for a byte addressable field) if an attribute
9310 definition for @code{Bit_Order} has been given, and indeed it
9311 may be actively confusing to specify such a value, so the compiler
9312 generates a warning for such usage.
9314 If you do need to control byte ordering then appropriate conditional
9315 values must be used. If in our example, the slave byte came first on
9316 some machines we might write:
9318 @smallexample @c ada
9319 Master_Byte_First constant Boolean := @dots{};
9321 Master_Byte : constant Natural :=
9322 1 - Boolean'Pos (Master_Byte_First);
9323 Slave_Byte : constant Natural :=
9324 Boolean'Pos (Master_Byte_First);
9326 for Data'Bit_Order use High_Order_First;
9328 Master_Control at Master_Byte range 0 .. 0;
9329 Master_V1 at Master_Byte range 1 .. 1;
9330 Master_V2 at Master_Byte range 2 .. 2;
9331 Master_V3 at Master_Byte range 3 .. 3;
9332 Master_V4 at Master_Byte range 4 .. 4;
9333 Master_V5 at Master_Byte range 5 .. 5;
9334 Master_V6 at Master_Byte range 6 .. 6;
9335 Master_V7 at Master_Byte range 7 .. 7;
9336 Slave_Control at Slave_Byte range 0 .. 0;
9337 Slave_V1 at Slave_Byte range 1 .. 1;
9338 Slave_V2 at Slave_Byte range 2 .. 2;
9339 Slave_V3 at Slave_Byte range 3 .. 3;
9340 Slave_V4 at Slave_Byte range 4 .. 4;
9341 Slave_V5 at Slave_Byte range 5 .. 5;
9342 Slave_V6 at Slave_Byte range 6 .. 6;
9343 Slave_V7 at Slave_Byte range 7 .. 7;
9348 Now to switch between machines, all that is necessary is
9349 to set the boolean constant @code{Master_Byte_First} in
9350 an appropriate manner.
9352 @node Pragma Pack for Arrays
9353 @section Pragma Pack for Arrays
9354 @cindex Pragma Pack (for arrays)
9357 Pragma @code{Pack} applied to an array has no effect unless the component type
9358 is packable. For a component type to be packable, it must be one of the
9365 Any type whose size is specified with a size clause
9367 Any packed array type with a static size
9371 For all these cases, if the component subtype size is in the range
9372 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
9373 component size were specified giving the component subtype size.
9374 For example if we have:
9376 @smallexample @c ada
9377 type r is range 0 .. 17;
9379 type ar is array (1 .. 8) of r;
9384 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
9385 and the size of the array @code{ar} will be exactly 40 bits.
9387 Note that in some cases this rather fierce approach to packing can produce
9388 unexpected effects. For example, in Ada 95, type Natural typically has a
9389 size of 31, meaning that if you pack an array of Natural, you get 31-bit
9390 close packing, which saves a few bits, but results in far less efficient
9391 access. Since many other Ada compilers will ignore such a packing request,
9392 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
9393 might not be what is intended. You can easily remove this warning by
9394 using an explicit @code{Component_Size} setting instead, which never generates
9395 a warning, since the intention of the programmer is clear in this case.
9397 GNAT treats packed arrays in one of two ways. If the size of the array is
9398 known at compile time and is less than 64 bits, then internally the array
9399 is represented as a single modular type, of exactly the appropriate number
9400 of bits. If the length is greater than 63 bits, or is not known at compile
9401 time, then the packed array is represented as an array of bytes, and the
9402 length is always a multiple of 8 bits.
9404 Note that to represent a packed array as a modular type, the alignment must
9405 be suitable for the modular type involved. For example, on typical machines
9406 a 32-bit packed array will be represented by a 32-bit modular integer with
9407 an alignment of four bytes. If you explicitly override the default alignment
9408 with an alignment clause that is too small, the modular representation
9409 cannot be used. For example, consider the following set of declarations:
9411 @smallexample @c ada
9412 type R is range 1 .. 3;
9413 type S is array (1 .. 31) of R;
9414 for S'Component_Size use 2;
9416 for S'Alignment use 1;
9420 If the alignment clause were not present, then a 62-bit modular
9421 representation would be chosen (typically with an alignment of 4 or 8
9422 bytes depending on the target). But the default alignment is overridden
9423 with the explicit alignment clause. This means that the modular
9424 representation cannot be used, and instead the array of bytes
9425 representation must be used, meaning that the length must be a multiple
9426 of 8. Thus the above set of declarations will result in a diagnostic
9427 rejecting the size clause and noting that the minimum size allowed is 64.
9429 @cindex Pragma Pack (for type Natural)
9430 @cindex Pragma Pack warning
9432 One special case that is worth noting occurs when the base type of the
9433 component size is 8/16/32 and the subtype is one bit less. Notably this
9434 occurs with subtype @code{Natural}. Consider:
9436 @smallexample @c ada
9437 type Arr is array (1 .. 32) of Natural;
9442 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
9443 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
9444 Ada 83 compilers did not attempt 31 bit packing.
9446 In Ada 95, @code{Natural'Size} is required to be 31. Furthermore, GNAT really
9447 does pack 31-bit subtype to 31 bits. This may result in a substantial
9448 unintended performance penalty when porting legacy Ada 83 code. To help
9449 prevent this, GNAT generates a warning in such cases. If you really want 31
9450 bit packing in a case like this, you can set the component size explicitly:
9452 @smallexample @c ada
9453 type Arr is array (1 .. 32) of Natural;
9454 for Arr'Component_Size use 31;
9458 Here 31-bit packing is achieved as required, and no warning is generated,
9459 since in this case the programmer intention is clear.
9461 @node Pragma Pack for Records
9462 @section Pragma Pack for Records
9463 @cindex Pragma Pack (for records)
9466 Pragma @code{Pack} applied to a record will pack the components to reduce
9467 wasted space from alignment gaps and by reducing the amount of space
9468 taken by components. We distinguish between @emph{packable} components and
9469 @emph{non-packable} components.
9470 Components of the following types are considered packable:
9473 All primitive types are packable.
9476 Small packed arrays, whose size does not exceed 64 bits, and where the
9477 size is statically known at compile time, are represented internally
9478 as modular integers, and so they are also packable.
9483 All packable components occupy the exact number of bits corresponding to
9484 their @code{Size} value, and are packed with no padding bits, i.e.@: they
9485 can start on an arbitrary bit boundary.
9487 All other types are non-packable, they occupy an integral number of
9489 are placed at a boundary corresponding to their alignment requirements.
9491 For example, consider the record
9493 @smallexample @c ada
9494 type Rb1 is array (1 .. 13) of Boolean;
9497 type Rb2 is array (1 .. 65) of Boolean;
9512 The representation for the record x2 is as follows:
9514 @smallexample @c ada
9515 for x2'Size use 224;
9517 l1 at 0 range 0 .. 0;
9518 l2 at 0 range 1 .. 64;
9519 l3 at 12 range 0 .. 31;
9520 l4 at 16 range 0 .. 0;
9521 l5 at 16 range 1 .. 13;
9522 l6 at 18 range 0 .. 71;
9527 Studying this example, we see that the packable fields @code{l1}
9529 of length equal to their sizes, and placed at specific bit boundaries (and
9530 not byte boundaries) to
9531 eliminate padding. But @code{l3} is of a non-packable float type, so
9532 it is on the next appropriate alignment boundary.
9534 The next two fields are fully packable, so @code{l4} and @code{l5} are
9535 minimally packed with no gaps. However, type @code{Rb2} is a packed
9536 array that is longer than 64 bits, so it is itself non-packable. Thus
9537 the @code{l6} field is aligned to the next byte boundary, and takes an
9538 integral number of bytes, i.e.@: 72 bits.
9540 @node Record Representation Clauses
9541 @section Record Representation Clauses
9542 @cindex Record Representation Clause
9545 Record representation clauses may be given for all record types, including
9546 types obtained by record extension. Component clauses are allowed for any
9547 static component. The restrictions on component clauses depend on the type
9550 @cindex Component Clause
9551 For all components of an elementary type, the only restriction on component
9552 clauses is that the size must be at least the 'Size value of the type
9553 (actually the Value_Size). There are no restrictions due to alignment,
9554 and such components may freely cross storage boundaries.
9556 Packed arrays with a size up to and including 64 bits are represented
9557 internally using a modular type with the appropriate number of bits, and
9558 thus the same lack of restriction applies. For example, if you declare:
9560 @smallexample @c ada
9561 type R is array (1 .. 49) of Boolean;
9567 then a component clause for a component of type R may start on any
9568 specified bit boundary, and may specify a value of 49 bits or greater.
9570 For packed bit arrays that are longer than 64 bits, there are two
9571 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
9572 including the important case of single bits or boolean values, then
9573 there are no limitations on placement of such components, and they
9574 may start and end at arbitrary bit boundaries.
9576 If the component size is not a power of 2 (e.g. 3 or 5), then
9577 an array of this type longer than 64 bits must always be placed on
9578 on a storage unit (byte) boundary and occupy an integral number
9579 of storage units (bytes). Any component clause that does not
9580 meet this requirement will be rejected.
9582 Any aliased component, or component of an aliased type, must
9583 have its normal alignment and size. A component clause that
9584 does not meet this requirement will be rejected.
9586 The tag field of a tagged type always occupies an address sized field at
9587 the start of the record. No component clause may attempt to overlay this
9588 tag. When a tagged type appears as a component, the tag field must have
9591 In the case of a record extension T1, of a type T, no component clause applied
9592 to the type T1 can specify a storage location that would overlap the first
9593 T'Size bytes of the record.
9595 For all other component types, including non-bit-packed arrays,
9596 the component can be placed at an arbitrary bit boundary,
9597 so for example, the following is permitted:
9599 @smallexample @c ada
9600 type R is array (1 .. 10) of Boolean;
9609 G at 0 range 0 .. 0;
9610 H at 0 range 1 .. 1;
9611 L at 0 range 2 .. 81;
9612 R at 0 range 82 .. 161;
9617 Note: the above rules apply to recent releases of GNAT 5.
9618 In GNAT 3, there are more severe restrictions on larger components.
9619 For non-primitive types, including packed arrays with a size greater than
9620 64 bits, component clauses must respect the alignment requirement of the
9621 type, in particular, always starting on a byte boundary, and the length
9622 must be a multiple of the storage unit.
9624 @node Enumeration Clauses
9625 @section Enumeration Clauses
9627 The only restriction on enumeration clauses is that the range of values
9628 must be representable. For the signed case, if one or more of the
9629 representation values are negative, all values must be in the range:
9631 @smallexample @c ada
9632 System.Min_Int .. System.Max_Int
9636 For the unsigned case, where all values are non negative, the values must
9639 @smallexample @c ada
9640 0 .. System.Max_Binary_Modulus;
9644 A @emph{confirming} representation clause is one in which the values range
9645 from 0 in sequence, i.e.@: a clause that confirms the default representation
9646 for an enumeration type.
9647 Such a confirming representation
9648 is permitted by these rules, and is specially recognized by the compiler so
9649 that no extra overhead results from the use of such a clause.
9651 If an array has an index type which is an enumeration type to which an
9652 enumeration clause has been applied, then the array is stored in a compact
9653 manner. Consider the declarations:
9655 @smallexample @c ada
9656 type r is (A, B, C);
9657 for r use (A => 1, B => 5, C => 10);
9658 type t is array (r) of Character;
9662 The array type t corresponds to a vector with exactly three elements and
9663 has a default size equal to @code{3*Character'Size}. This ensures efficient
9664 use of space, but means that accesses to elements of the array will incur
9665 the overhead of converting representation values to the corresponding
9666 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
9668 @node Address Clauses
9669 @section Address Clauses
9670 @cindex Address Clause
9672 The reference manual allows a general restriction on representation clauses,
9673 as found in RM 13.1(22):
9676 An implementation need not support representation
9677 items containing nonstatic expressions, except that
9678 an implementation should support a representation item
9679 for a given entity if each nonstatic expression in the
9680 representation item is a name that statically denotes
9681 a constant declared before the entity.
9685 In practice this is applicable only to address clauses, since this is the
9686 only case in which a non-static expression is permitted by the syntax. As
9687 the AARM notes in sections 13.1 (22.a-22.h):
9690 22.a Reason: This is to avoid the following sort of thing:
9692 22.b X : Integer := F(@dots{});
9693 Y : Address := G(@dots{});
9694 for X'Address use Y;
9696 22.c In the above, we have to evaluate the
9697 initialization expression for X before we
9698 know where to put the result. This seems
9699 like an unreasonable implementation burden.
9701 22.d The above code should instead be written
9704 22.e Y : constant Address := G(@dots{});
9705 X : Integer := F(@dots{});
9706 for X'Address use Y;
9708 22.f This allows the expression ``Y'' to be safely
9709 evaluated before X is created.
9711 22.g The constant could be a formal parameter of mode in.
9713 22.h An implementation can support other nonstatic
9714 expressions if it wants to. Expressions of type
9715 Address are hardly ever static, but their value
9716 might be known at compile time anyway in many
9721 GNAT does indeed permit many additional cases of non-static expressions. In
9722 particular, if the type involved is elementary there are no restrictions
9723 (since in this case, holding a temporary copy of the initialization value,
9724 if one is present, is inexpensive). In addition, if there is no implicit or
9725 explicit initialization, then there are no restrictions. GNAT will reject
9726 only the case where all three of these conditions hold:
9731 The type of the item is non-elementary (e.g.@: a record or array).
9734 There is explicit or implicit initialization required for the object.
9735 Note that access values are always implicitly initialized, and also
9736 in GNAT, certain bit-packed arrays (those having a dynamic length or
9737 a length greater than 64) will also be implicitly initialized to zero.
9740 The address value is non-static. Here GNAT is more permissive than the
9741 RM, and allows the address value to be the address of a previously declared
9742 stand-alone variable, as long as it does not itself have an address clause.
9744 @smallexample @c ada
9745 Anchor : Some_Initialized_Type;
9746 Overlay : Some_Initialized_Type;
9747 for Overlay'Address use Anchor'Address;
9751 However, the prefix of the address clause cannot be an array component, or
9752 a component of a discriminated record.
9757 As noted above in section 22.h, address values are typically non-static. In
9758 particular the To_Address function, even if applied to a literal value, is
9759 a non-static function call. To avoid this minor annoyance, GNAT provides
9760 the implementation defined attribute 'To_Address. The following two
9761 expressions have identical values:
9765 @smallexample @c ada
9766 To_Address (16#1234_0000#)
9767 System'To_Address (16#1234_0000#);
9771 except that the second form is considered to be a static expression, and
9772 thus when used as an address clause value is always permitted.
9775 Additionally, GNAT treats as static an address clause that is an
9776 unchecked_conversion of a static integer value. This simplifies the porting
9777 of legacy code, and provides a portable equivalent to the GNAT attribute
9780 Another issue with address clauses is the interaction with alignment
9781 requirements. When an address clause is given for an object, the address
9782 value must be consistent with the alignment of the object (which is usually
9783 the same as the alignment of the type of the object). If an address clause
9784 is given that specifies an inappropriately aligned address value, then the
9785 program execution is erroneous.
9787 Since this source of erroneous behavior can have unfortunate effects, GNAT
9788 checks (at compile time if possible, generating a warning, or at execution
9789 time with a run-time check) that the alignment is appropriate. If the
9790 run-time check fails, then @code{Program_Error} is raised. This run-time
9791 check is suppressed if range checks are suppressed, or if
9792 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
9795 An address clause cannot be given for an exported object. More
9796 understandably the real restriction is that objects with an address
9797 clause cannot be exported. This is because such variables are not
9798 defined by the Ada program, so there is no external object to export.
9801 It is permissible to give an address clause and a pragma Import for the
9802 same object. In this case, the variable is not really defined by the
9803 Ada program, so there is no external symbol to be linked. The link name
9804 and the external name are ignored in this case. The reason that we allow this
9805 combination is that it provides a useful idiom to avoid unwanted
9806 initializations on objects with address clauses.
9808 When an address clause is given for an object that has implicit or
9809 explicit initialization, then by default initialization takes place. This
9810 means that the effect of the object declaration is to overwrite the
9811 memory at the specified address. This is almost always not what the
9812 programmer wants, so GNAT will output a warning:
9822 for Ext'Address use System'To_Address (16#1234_1234#);
9824 >>> warning: implicit initialization of "Ext" may
9825 modify overlaid storage
9826 >>> warning: use pragma Import for "Ext" to suppress
9827 initialization (RM B(24))
9833 As indicated by the warning message, the solution is to use a (dummy) pragma
9834 Import to suppress this initialization. The pragma tell the compiler that the
9835 object is declared and initialized elsewhere. The following package compiles
9836 without warnings (and the initialization is suppressed):
9838 @smallexample @c ada
9846 for Ext'Address use System'To_Address (16#1234_1234#);
9847 pragma Import (Ada, Ext);
9852 A final issue with address clauses involves their use for overlaying
9853 variables, as in the following example:
9854 @cindex Overlaying of objects
9856 @smallexample @c ada
9859 for B'Address use A'Address;
9863 or alternatively, using the form recommended by the RM:
9865 @smallexample @c ada
9867 Addr : constant Address := A'Address;
9869 for B'Address use Addr;
9873 In both of these cases, @code{A}
9874 and @code{B} become aliased to one another via the
9875 address clause. This use of address clauses to overlay
9876 variables, achieving an effect similar to unchecked
9877 conversion was erroneous in Ada 83, but in Ada 95
9878 the effect is implementation defined. Furthermore, the
9879 Ada 95 RM specifically recommends that in a situation
9880 like this, @code{B} should be subject to the following
9881 implementation advice (RM 13.3(19)):
9884 19 If the Address of an object is specified, or it is imported
9885 or exported, then the implementation should not perform
9886 optimizations based on assumptions of no aliases.
9890 GNAT follows this recommendation, and goes further by also applying
9891 this recommendation to the overlaid variable (@code{A}
9892 in the above example) in this case. This means that the overlay
9893 works "as expected", in that a modification to one of the variables
9894 will affect the value of the other.
9896 @node Effect of Convention on Representation
9897 @section Effect of Convention on Representation
9898 @cindex Convention, effect on representation
9901 Normally the specification of a foreign language convention for a type or
9902 an object has no effect on the chosen representation. In particular, the
9903 representation chosen for data in GNAT generally meets the standard system
9904 conventions, and for example records are laid out in a manner that is
9905 consistent with C@. This means that specifying convention C (for example)
9908 There are three exceptions to this general rule:
9912 @item Convention Fortran and array subtypes
9913 If pragma Convention Fortran is specified for an array subtype, then in
9914 accordance with the implementation advice in section 3.6.2(11) of the
9915 Ada Reference Manual, the array will be stored in a Fortran-compatible
9916 column-major manner, instead of the normal default row-major order.
9918 @item Convention C and enumeration types
9919 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
9920 to accommodate all values of the type. For example, for the enumeration
9923 @smallexample @c ada
9924 type Color is (Red, Green, Blue);
9928 8 bits is sufficient to store all values of the type, so by default, objects
9929 of type @code{Color} will be represented using 8 bits. However, normal C
9930 convention is to use 32 bits for all enum values in C, since enum values
9931 are essentially of type int. If pragma @code{Convention C} is specified for an
9932 Ada enumeration type, then the size is modified as necessary (usually to
9933 32 bits) to be consistent with the C convention for enum values.
9935 @item Convention C/Fortran and Boolean types
9936 In C, the usual convention for boolean values, that is values used for
9937 conditions, is that zero represents false, and nonzero values represent
9938 true. In Ada, the normal convention is that two specific values, typically
9939 0/1, are used to represent false/true respectively.
9941 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
9942 value represents true).
9944 To accommodate the Fortran and C conventions, if a pragma Convention specifies
9945 C or Fortran convention for a derived Boolean, as in the following example:
9947 @smallexample @c ada
9948 type C_Switch is new Boolean;
9949 pragma Convention (C, C_Switch);
9953 then the GNAT generated code will treat any nonzero value as true. For truth
9954 values generated by GNAT, the conventional value 1 will be used for True, but
9955 when one of these values is read, any nonzero value is treated as True.
9959 @node Determining the Representations chosen by GNAT
9960 @section Determining the Representations chosen by GNAT
9961 @cindex Representation, determination of
9962 @cindex @code{-gnatR} switch
9965 Although the descriptions in this section are intended to be complete, it is
9966 often easier to simply experiment to see what GNAT accepts and what the
9967 effect is on the layout of types and objects.
9969 As required by the Ada RM, if a representation clause is not accepted, then
9970 it must be rejected as illegal by the compiler. However, when a
9971 representation clause or pragma is accepted, there can still be questions
9972 of what the compiler actually does. For example, if a partial record
9973 representation clause specifies the location of some components and not
9974 others, then where are the non-specified components placed? Or if pragma
9975 @code{Pack} is used on a record, then exactly where are the resulting
9976 fields placed? The section on pragma @code{Pack} in this chapter can be
9977 used to answer the second question, but it is often easier to just see
9978 what the compiler does.
9980 For this purpose, GNAT provides the option @code{-gnatR}. If you compile
9981 with this option, then the compiler will output information on the actual
9982 representations chosen, in a format similar to source representation
9983 clauses. For example, if we compile the package:
9985 @smallexample @c ada
9987 type r (x : boolean) is tagged record
9989 when True => S : String (1 .. 100);
9994 type r2 is new r (false) with record
9999 y2 at 16 range 0 .. 31;
10006 type x1 is array (1 .. 10) of x;
10007 for x1'component_size use 11;
10009 type ia is access integer;
10011 type Rb1 is array (1 .. 13) of Boolean;
10014 type Rb2 is array (1 .. 65) of Boolean;
10030 using the switch @code{-gnatR} we obtain the following output:
10033 Representation information for unit q
10034 -------------------------------------
10037 for r'Alignment use 4;
10039 x at 4 range 0 .. 7;
10040 _tag at 0 range 0 .. 31;
10041 s at 5 range 0 .. 799;
10044 for r2'Size use 160;
10045 for r2'Alignment use 4;
10047 x at 4 range 0 .. 7;
10048 _tag at 0 range 0 .. 31;
10049 _parent at 0 range 0 .. 63;
10050 y2 at 16 range 0 .. 31;
10054 for x'Alignment use 1;
10056 y at 0 range 0 .. 7;
10059 for x1'Size use 112;
10060 for x1'Alignment use 1;
10061 for x1'Component_Size use 11;
10063 for rb1'Size use 13;
10064 for rb1'Alignment use 2;
10065 for rb1'Component_Size use 1;
10067 for rb2'Size use 72;
10068 for rb2'Alignment use 1;
10069 for rb2'Component_Size use 1;
10071 for x2'Size use 224;
10072 for x2'Alignment use 4;
10074 l1 at 0 range 0 .. 0;
10075 l2 at 0 range 1 .. 64;
10076 l3 at 12 range 0 .. 31;
10077 l4 at 16 range 0 .. 0;
10078 l5 at 16 range 1 .. 13;
10079 l6 at 18 range 0 .. 71;
10084 The Size values are actually the Object_Size, i.e.@: the default size that
10085 will be allocated for objects of the type.
10086 The ?? size for type r indicates that we have a variant record, and the
10087 actual size of objects will depend on the discriminant value.
10089 The Alignment values show the actual alignment chosen by the compiler
10090 for each record or array type.
10092 The record representation clause for type r shows where all fields
10093 are placed, including the compiler generated tag field (whose location
10094 cannot be controlled by the programmer).
10096 The record representation clause for the type extension r2 shows all the
10097 fields present, including the parent field, which is a copy of the fields
10098 of the parent type of r2, i.e.@: r1.
10100 The component size and size clauses for types rb1 and rb2 show
10101 the exact effect of pragma @code{Pack} on these arrays, and the record
10102 representation clause for type x2 shows how pragma @code{Pack} affects
10105 In some cases, it may be useful to cut and paste the representation clauses
10106 generated by the compiler into the original source to fix and guarantee
10107 the actual representation to be used.
10109 @node Standard Library Routines
10110 @chapter Standard Library Routines
10113 The Ada 95 Reference Manual contains in Annex A a full description of an
10114 extensive set of standard library routines that can be used in any Ada
10115 program, and which must be provided by all Ada compilers. They are
10116 analogous to the standard C library used by C programs.
10118 GNAT implements all of the facilities described in annex A, and for most
10119 purposes the description in the Ada 95
10120 reference manual, or appropriate Ada
10121 text book, will be sufficient for making use of these facilities.
10123 In the case of the input-output facilities, @xref{The Implementation of
10124 Standard I/O}, gives details on exactly how GNAT interfaces to the
10125 file system. For the remaining packages, the Ada 95 reference manual
10126 should be sufficient. The following is a list of the packages included,
10127 together with a brief description of the functionality that is provided.
10129 For completeness, references are included to other predefined library
10130 routines defined in other sections of the Ada 95 reference manual (these are
10131 cross-indexed from annex A).
10135 This is a parent package for all the standard library packages. It is
10136 usually included implicitly in your program, and itself contains no
10137 useful data or routines.
10139 @item Ada.Calendar (9.6)
10140 @code{Calendar} provides time of day access, and routines for
10141 manipulating times and durations.
10143 @item Ada.Characters (A.3.1)
10144 This is a dummy parent package that contains no useful entities
10146 @item Ada.Characters.Handling (A.3.2)
10147 This package provides some basic character handling capabilities,
10148 including classification functions for classes of characters (e.g.@: test
10149 for letters, or digits).
10151 @item Ada.Characters.Latin_1 (A.3.3)
10152 This package includes a complete set of definitions of the characters
10153 that appear in type CHARACTER@. It is useful for writing programs that
10154 will run in international environments. For example, if you want an
10155 upper case E with an acute accent in a string, it is often better to use
10156 the definition of @code{UC_E_Acute} in this package. Then your program
10157 will print in an understandable manner even if your environment does not
10158 support these extended characters.
10160 @item Ada.Command_Line (A.15)
10161 This package provides access to the command line parameters and the name
10162 of the current program (analogous to the use of @code{argc} and @code{argv}
10163 in C), and also allows the exit status for the program to be set in a
10164 system-independent manner.
10166 @item Ada.Decimal (F.2)
10167 This package provides constants describing the range of decimal numbers
10168 implemented, and also a decimal divide routine (analogous to the COBOL
10169 verb DIVIDE .. GIVING .. REMAINDER ..)
10171 @item Ada.Direct_IO (A.8.4)
10172 This package provides input-output using a model of a set of records of
10173 fixed-length, containing an arbitrary definite Ada type, indexed by an
10174 integer record number.
10176 @item Ada.Dynamic_Priorities (D.5)
10177 This package allows the priorities of a task to be adjusted dynamically
10178 as the task is running.
10180 @item Ada.Exceptions (11.4.1)
10181 This package provides additional information on exceptions, and also
10182 contains facilities for treating exceptions as data objects, and raising
10183 exceptions with associated messages.
10185 @item Ada.Finalization (7.6)
10186 This package contains the declarations and subprograms to support the
10187 use of controlled types, providing for automatic initialization and
10188 finalization (analogous to the constructors and destructors of C++)
10190 @item Ada.Interrupts (C.3.2)
10191 This package provides facilities for interfacing to interrupts, which
10192 includes the set of signals or conditions that can be raised and
10193 recognized as interrupts.
10195 @item Ada.Interrupts.Names (C.3.2)
10196 This package provides the set of interrupt names (actually signal
10197 or condition names) that can be handled by GNAT@.
10199 @item Ada.IO_Exceptions (A.13)
10200 This package defines the set of exceptions that can be raised by use of
10201 the standard IO packages.
10204 This package contains some standard constants and exceptions used
10205 throughout the numerics packages. Note that the constants pi and e are
10206 defined here, and it is better to use these definitions than rolling
10209 @item Ada.Numerics.Complex_Elementary_Functions
10210 Provides the implementation of standard elementary functions (such as
10211 log and trigonometric functions) operating on complex numbers using the
10212 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10213 created by the package @code{Numerics.Complex_Types}.
10215 @item Ada.Numerics.Complex_Types
10216 This is a predefined instantiation of
10217 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10218 build the type @code{Complex} and @code{Imaginary}.
10220 @item Ada.Numerics.Discrete_Random
10221 This package provides a random number generator suitable for generating
10222 random integer values from a specified range.
10224 @item Ada.Numerics.Float_Random
10225 This package provides a random number generator suitable for generating
10226 uniformly distributed floating point values.
10228 @item Ada.Numerics.Generic_Complex_Elementary_Functions
10229 This is a generic version of the package that provides the
10230 implementation of standard elementary functions (such as log and
10231 trigonometric functions) for an arbitrary complex type.
10233 The following predefined instantiations of this package are provided:
10237 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
10239 @code{Ada.Numerics.Complex_Elementary_Functions}
10241 @code{Ada.Numerics.
10242 Long_Complex_Elementary_Functions}
10245 @item Ada.Numerics.Generic_Complex_Types
10246 This is a generic package that allows the creation of complex types,
10247 with associated complex arithmetic operations.
10249 The following predefined instantiations of this package exist
10252 @code{Ada.Numerics.Short_Complex_Complex_Types}
10254 @code{Ada.Numerics.Complex_Complex_Types}
10256 @code{Ada.Numerics.Long_Complex_Complex_Types}
10259 @item Ada.Numerics.Generic_Elementary_Functions
10260 This is a generic package that provides the implementation of standard
10261 elementary functions (such as log an trigonometric functions) for an
10262 arbitrary float type.
10264 The following predefined instantiations of this package exist
10268 @code{Ada.Numerics.Short_Elementary_Functions}
10270 @code{Ada.Numerics.Elementary_Functions}
10272 @code{Ada.Numerics.Long_Elementary_Functions}
10275 @item Ada.Real_Time (D.8)
10276 This package provides facilities similar to those of @code{Calendar}, but
10277 operating with a finer clock suitable for real time control. Note that
10278 annex D requires that there be no backward clock jumps, and GNAT generally
10279 guarantees this behavior, but of course if the external clock on which
10280 the GNAT runtime depends is deliberately reset by some external event,
10281 then such a backward jump may occur.
10283 @item Ada.Sequential_IO (A.8.1)
10284 This package provides input-output facilities for sequential files,
10285 which can contain a sequence of values of a single type, which can be
10286 any Ada type, including indefinite (unconstrained) types.
10288 @item Ada.Storage_IO (A.9)
10289 This package provides a facility for mapping arbitrary Ada types to and
10290 from a storage buffer. It is primarily intended for the creation of new
10293 @item Ada.Streams (13.13.1)
10294 This is a generic package that provides the basic support for the
10295 concept of streams as used by the stream attributes (@code{Input},
10296 @code{Output}, @code{Read} and @code{Write}).
10298 @item Ada.Streams.Stream_IO (A.12.1)
10299 This package is a specialization of the type @code{Streams} defined in
10300 package @code{Streams} together with a set of operations providing
10301 Stream_IO capability. The Stream_IO model permits both random and
10302 sequential access to a file which can contain an arbitrary set of values
10303 of one or more Ada types.
10305 @item Ada.Strings (A.4.1)
10306 This package provides some basic constants used by the string handling
10309 @item Ada.Strings.Bounded (A.4.4)
10310 This package provides facilities for handling variable length
10311 strings. The bounded model requires a maximum length. It is thus
10312 somewhat more limited than the unbounded model, but avoids the use of
10313 dynamic allocation or finalization.
10315 @item Ada.Strings.Fixed (A.4.3)
10316 This package provides facilities for handling fixed length strings.
10318 @item Ada.Strings.Maps (A.4.2)
10319 This package provides facilities for handling character mappings and
10320 arbitrarily defined subsets of characters. For instance it is useful in
10321 defining specialized translation tables.
10323 @item Ada.Strings.Maps.Constants (A.4.6)
10324 This package provides a standard set of predefined mappings and
10325 predefined character sets. For example, the standard upper to lower case
10326 conversion table is found in this package. Note that upper to lower case
10327 conversion is non-trivial if you want to take the entire set of
10328 characters, including extended characters like E with an acute accent,
10329 into account. You should use the mappings in this package (rather than
10330 adding 32 yourself) to do case mappings.
10332 @item Ada.Strings.Unbounded (A.4.5)
10333 This package provides facilities for handling variable length
10334 strings. The unbounded model allows arbitrary length strings, but
10335 requires the use of dynamic allocation and finalization.
10337 @item Ada.Strings.Wide_Bounded (A.4.7)
10338 @itemx Ada.Strings.Wide_Fixed (A.4.7)
10339 @itemx Ada.Strings.Wide_Maps (A.4.7)
10340 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
10341 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
10342 These packages provide analogous capabilities to the corresponding
10343 packages without @samp{Wide_} in the name, but operate with the types
10344 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
10345 and @code{Character}.
10347 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
10348 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
10349 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
10350 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
10351 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
10352 These packages provide analogous capabilities to the corresponding
10353 packages without @samp{Wide_} in the name, but operate with the types
10354 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
10355 of @code{String} and @code{Character}.
10357 @item Ada.Synchronous_Task_Control (D.10)
10358 This package provides some standard facilities for controlling task
10359 communication in a synchronous manner.
10362 This package contains definitions for manipulation of the tags of tagged
10365 @item Ada.Task_Attributes
10366 This package provides the capability of associating arbitrary
10367 task-specific data with separate tasks.
10370 This package provides basic text input-output capabilities for
10371 character, string and numeric data. The subpackages of this
10372 package are listed next.
10374 @item Ada.Text_IO.Decimal_IO
10375 Provides input-output facilities for decimal fixed-point types
10377 @item Ada.Text_IO.Enumeration_IO
10378 Provides input-output facilities for enumeration types.
10380 @item Ada.Text_IO.Fixed_IO
10381 Provides input-output facilities for ordinary fixed-point types.
10383 @item Ada.Text_IO.Float_IO
10384 Provides input-output facilities for float types. The following
10385 predefined instantiations of this generic package are available:
10389 @code{Short_Float_Text_IO}
10391 @code{Float_Text_IO}
10393 @code{Long_Float_Text_IO}
10396 @item Ada.Text_IO.Integer_IO
10397 Provides input-output facilities for integer types. The following
10398 predefined instantiations of this generic package are available:
10401 @item Short_Short_Integer
10402 @code{Ada.Short_Short_Integer_Text_IO}
10403 @item Short_Integer
10404 @code{Ada.Short_Integer_Text_IO}
10406 @code{Ada.Integer_Text_IO}
10408 @code{Ada.Long_Integer_Text_IO}
10409 @item Long_Long_Integer
10410 @code{Ada.Long_Long_Integer_Text_IO}
10413 @item Ada.Text_IO.Modular_IO
10414 Provides input-output facilities for modular (unsigned) types
10416 @item Ada.Text_IO.Complex_IO (G.1.3)
10417 This package provides basic text input-output capabilities for complex
10420 @item Ada.Text_IO.Editing (F.3.3)
10421 This package contains routines for edited output, analogous to the use
10422 of pictures in COBOL@. The picture formats used by this package are a
10423 close copy of the facility in COBOL@.
10425 @item Ada.Text_IO.Text_Streams (A.12.2)
10426 This package provides a facility that allows Text_IO files to be treated
10427 as streams, so that the stream attributes can be used for writing
10428 arbitrary data, including binary data, to Text_IO files.
10430 @item Ada.Unchecked_Conversion (13.9)
10431 This generic package allows arbitrary conversion from one type to
10432 another of the same size, providing for breaking the type safety in
10433 special circumstances.
10435 If the types have the same Size (more accurately the same Value_Size),
10436 then the effect is simply to transfer the bits from the source to the
10437 target type without any modification. This usage is well defined, and
10438 for simple types whose representation is typically the same across
10439 all implementations, gives a portable method of performing such
10442 If the types do not have the same size, then the result is implementation
10443 defined, and thus may be non-portable. The following describes how GNAT
10444 handles such unchecked conversion cases.
10446 If the types are of different sizes, and are both discrete types, then
10447 the effect is of a normal type conversion without any constraint checking.
10448 In particular if the result type has a larger size, the result will be
10449 zero or sign extended. If the result type has a smaller size, the result
10450 will be truncated by ignoring high order bits.
10452 If the types are of different sizes, and are not both discrete types,
10453 then the conversion works as though pointers were created to the source
10454 and target, and the pointer value is converted. The effect is that bits
10455 are copied from successive low order storage units and bits of the source
10456 up to the length of the target type.
10458 A warning is issued if the lengths differ, since the effect in this
10459 case is implementation dependent, and the above behavior may not match
10460 that of some other compiler.
10462 A pointer to one type may be converted to a pointer to another type using
10463 unchecked conversion. The only case in which the effect is undefined is
10464 when one or both pointers are pointers to unconstrained array types. In
10465 this case, the bounds information may get incorrectly transferred, and in
10466 particular, GNAT uses double size pointers for such types, and it is
10467 meaningless to convert between such pointer types. GNAT will issue a
10468 warning if the alignment of the target designated type is more strict
10469 than the alignment of the source designated type (since the result may
10470 be unaligned in this case).
10472 A pointer other than a pointer to an unconstrained array type may be
10473 converted to and from System.Address. Such usage is common in Ada 83
10474 programs, but note that Ada.Address_To_Access_Conversions is the
10475 preferred method of performing such conversions in Ada 95. Neither
10476 unchecked conversion nor Ada.Address_To_Access_Conversions should be
10477 used in conjunction with pointers to unconstrained objects, since
10478 the bounds information cannot be handled correctly in this case.
10480 @item Ada.Unchecked_Deallocation (13.11.2)
10481 This generic package allows explicit freeing of storage previously
10482 allocated by use of an allocator.
10484 @item Ada.Wide_Text_IO (A.11)
10485 This package is similar to @code{Ada.Text_IO}, except that the external
10486 file supports wide character representations, and the internal types are
10487 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10488 and @code{String}. It contains generic subpackages listed next.
10490 @item Ada.Wide_Text_IO.Decimal_IO
10491 Provides input-output facilities for decimal fixed-point types
10493 @item Ada.Wide_Text_IO.Enumeration_IO
10494 Provides input-output facilities for enumeration types.
10496 @item Ada.Wide_Text_IO.Fixed_IO
10497 Provides input-output facilities for ordinary fixed-point types.
10499 @item Ada.Wide_Text_IO.Float_IO
10500 Provides input-output facilities for float types. The following
10501 predefined instantiations of this generic package are available:
10505 @code{Short_Float_Wide_Text_IO}
10507 @code{Float_Wide_Text_IO}
10509 @code{Long_Float_Wide_Text_IO}
10512 @item Ada.Wide_Text_IO.Integer_IO
10513 Provides input-output facilities for integer types. The following
10514 predefined instantiations of this generic package are available:
10517 @item Short_Short_Integer
10518 @code{Ada.Short_Short_Integer_Wide_Text_IO}
10519 @item Short_Integer
10520 @code{Ada.Short_Integer_Wide_Text_IO}
10522 @code{Ada.Integer_Wide_Text_IO}
10524 @code{Ada.Long_Integer_Wide_Text_IO}
10525 @item Long_Long_Integer
10526 @code{Ada.Long_Long_Integer_Wide_Text_IO}
10529 @item Ada.Wide_Text_IO.Modular_IO
10530 Provides input-output facilities for modular (unsigned) types
10532 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
10533 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
10534 external file supports wide character representations.
10536 @item Ada.Wide_Text_IO.Editing (F.3.4)
10537 This package is similar to @code{Ada.Text_IO.Editing}, except that the
10538 types are @code{Wide_Character} and @code{Wide_String} instead of
10539 @code{Character} and @code{String}.
10541 @item Ada.Wide_Text_IO.Streams (A.12.3)
10542 This package is similar to @code{Ada.Text_IO.Streams}, except that the
10543 types are @code{Wide_Character} and @code{Wide_String} instead of
10544 @code{Character} and @code{String}.
10546 @item Ada.Wide_Wide_Text_IO (A.11)
10547 This package is similar to @code{Ada.Text_IO}, except that the external
10548 file supports wide character representations, and the internal types are
10549 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10550 and @code{String}. It contains generic subpackages listed next.
10552 @item Ada.Wide_Wide_Text_IO.Decimal_IO
10553 Provides input-output facilities for decimal fixed-point types
10555 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
10556 Provides input-output facilities for enumeration types.
10558 @item Ada.Wide_Wide_Text_IO.Fixed_IO
10559 Provides input-output facilities for ordinary fixed-point types.
10561 @item Ada.Wide_Wide_Text_IO.Float_IO
10562 Provides input-output facilities for float types. The following
10563 predefined instantiations of this generic package are available:
10567 @code{Short_Float_Wide_Wide_Text_IO}
10569 @code{Float_Wide_Wide_Text_IO}
10571 @code{Long_Float_Wide_Wide_Text_IO}
10574 @item Ada.Wide_Wide_Text_IO.Integer_IO
10575 Provides input-output facilities for integer types. The following
10576 predefined instantiations of this generic package are available:
10579 @item Short_Short_Integer
10580 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
10581 @item Short_Integer
10582 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
10584 @code{Ada.Integer_Wide_Wide_Text_IO}
10586 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
10587 @item Long_Long_Integer
10588 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
10591 @item Ada.Wide_Wide_Text_IO.Modular_IO
10592 Provides input-output facilities for modular (unsigned) types
10594 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
10595 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
10596 external file supports wide character representations.
10598 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
10599 This package is similar to @code{Ada.Text_IO.Editing}, except that the
10600 types are @code{Wide_Character} and @code{Wide_String} instead of
10601 @code{Character} and @code{String}.
10603 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
10604 This package is similar to @code{Ada.Text_IO.Streams}, except that the
10605 types are @code{Wide_Character} and @code{Wide_String} instead of
10606 @code{Character} and @code{String}.
10611 @node The Implementation of Standard I/O
10612 @chapter The Implementation of Standard I/O
10615 GNAT implements all the required input-output facilities described in
10616 A.6 through A.14. These sections of the Ada 95 reference manual describe the
10617 required behavior of these packages from the Ada point of view, and if
10618 you are writing a portable Ada program that does not need to know the
10619 exact manner in which Ada maps to the outside world when it comes to
10620 reading or writing external files, then you do not need to read this
10621 chapter. As long as your files are all regular files (not pipes or
10622 devices), and as long as you write and read the files only from Ada, the
10623 description in the Ada 95 reference manual is sufficient.
10625 However, if you want to do input-output to pipes or other devices, such
10626 as the keyboard or screen, or if the files you are dealing with are
10627 either generated by some other language, or to be read by some other
10628 language, then you need to know more about the details of how the GNAT
10629 implementation of these input-output facilities behaves.
10631 In this chapter we give a detailed description of exactly how GNAT
10632 interfaces to the file system. As always, the sources of the system are
10633 available to you for answering questions at an even more detailed level,
10634 but for most purposes the information in this chapter will suffice.
10636 Another reason that you may need to know more about how input-output is
10637 implemented arises when you have a program written in mixed languages
10638 where, for example, files are shared between the C and Ada sections of
10639 the same program. GNAT provides some additional facilities, in the form
10640 of additional child library packages, that facilitate this sharing, and
10641 these additional facilities are also described in this chapter.
10644 * Standard I/O Packages::
10650 * Wide_Wide_Text_IO::
10654 * Operations on C Streams::
10655 * Interfacing to C Streams::
10658 @node Standard I/O Packages
10659 @section Standard I/O Packages
10662 The Standard I/O packages described in Annex A for
10668 Ada.Text_IO.Complex_IO
10670 Ada.Text_IO.Text_Streams
10674 Ada.Wide_Text_IO.Complex_IO
10676 Ada.Wide_Text_IO.Text_Streams
10678 Ada.Wide_Wide_Text_IO
10680 Ada.Wide_Wide_Text_IO.Complex_IO
10682 Ada.Wide_Wide_Text_IO.Text_Streams
10692 are implemented using the C
10693 library streams facility; where
10697 All files are opened using @code{fopen}.
10699 All input/output operations use @code{fread}/@code{fwrite}.
10703 There is no internal buffering of any kind at the Ada library level. The
10704 only buffering is that provided at the system level in the
10705 implementation of the C library routines that support streams. This
10706 facilitates shared use of these streams by mixed language programs.
10709 @section FORM Strings
10712 The format of a FORM string in GNAT is:
10715 "keyword=value,keyword=value,@dots{},keyword=value"
10719 where letters may be in upper or lower case, and there are no spaces
10720 between values. The order of the entries is not important. Currently
10721 there are two keywords defined.
10729 The use of these parameters is described later in this section.
10735 Direct_IO can only be instantiated for definite types. This is a
10736 restriction of the Ada language, which means that the records are fixed
10737 length (the length being determined by @code{@var{type}'Size}, rounded
10738 up to the next storage unit boundary if necessary).
10740 The records of a Direct_IO file are simply written to the file in index
10741 sequence, with the first record starting at offset zero, and subsequent
10742 records following. There is no control information of any kind. For
10743 example, if 32-bit integers are being written, each record takes
10744 4-bytes, so the record at index @var{K} starts at offset
10745 (@var{K}@minus{}1)*4.
10747 There is no limit on the size of Direct_IO files, they are expanded as
10748 necessary to accommodate whatever records are written to the file.
10750 @node Sequential_IO
10751 @section Sequential_IO
10754 Sequential_IO may be instantiated with either a definite (constrained)
10755 or indefinite (unconstrained) type.
10757 For the definite type case, the elements written to the file are simply
10758 the memory images of the data values with no control information of any
10759 kind. The resulting file should be read using the same type, no validity
10760 checking is performed on input.
10762 For the indefinite type case, the elements written consist of two
10763 parts. First is the size of the data item, written as the memory image
10764 of a @code{Interfaces.C.size_t} value, followed by the memory image of
10765 the data value. The resulting file can only be read using the same
10766 (unconstrained) type. Normal assignment checks are performed on these
10767 read operations, and if these checks fail, @code{Data_Error} is
10768 raised. In particular, in the array case, the lengths must match, and in
10769 the variant record case, if the variable for a particular read operation
10770 is constrained, the discriminants must match.
10772 Note that it is not possible to use Sequential_IO to write variable
10773 length array items, and then read the data back into different length
10774 arrays. For example, the following will raise @code{Data_Error}:
10776 @smallexample @c ada
10777 package IO is new Sequential_IO (String);
10782 IO.Write (F, "hello!")
10783 IO.Reset (F, Mode=>In_File);
10790 On some Ada implementations, this will print @code{hell}, but the program is
10791 clearly incorrect, since there is only one element in the file, and that
10792 element is the string @code{hello!}.
10794 In Ada 95, this kind of behavior can be legitimately achieved using
10795 Stream_IO, and this is the preferred mechanism. In particular, the above
10796 program fragment rewritten to use Stream_IO will work correctly.
10802 Text_IO files consist of a stream of characters containing the following
10803 special control characters:
10806 LF (line feed, 16#0A#) Line Mark
10807 FF (form feed, 16#0C#) Page Mark
10811 A canonical Text_IO file is defined as one in which the following
10812 conditions are met:
10816 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
10820 The character @code{FF} is used only as a page mark, i.e.@: to mark the
10821 end of a page and consequently can appear only immediately following a
10822 @code{LF} (line mark) character.
10825 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
10826 (line mark, page mark). In the former case, the page mark is implicitly
10827 assumed to be present.
10831 A file written using Text_IO will be in canonical form provided that no
10832 explicit @code{LF} or @code{FF} characters are written using @code{Put}
10833 or @code{Put_Line}. There will be no @code{FF} character at the end of
10834 the file unless an explicit @code{New_Page} operation was performed
10835 before closing the file.
10837 A canonical Text_IO file that is a regular file, i.e.@: not a device or a
10838 pipe, can be read using any of the routines in Text_IO@. The
10839 semantics in this case will be exactly as defined in the Ada 95 reference
10840 manual and all the routines in Text_IO are fully implemented.
10842 A text file that does not meet the requirements for a canonical Text_IO
10843 file has one of the following:
10847 The file contains @code{FF} characters not immediately following a
10848 @code{LF} character.
10851 The file contains @code{LF} or @code{FF} characters written by
10852 @code{Put} or @code{Put_Line}, which are not logically considered to be
10853 line marks or page marks.
10856 The file ends in a character other than @code{LF} or @code{FF},
10857 i.e.@: there is no explicit line mark or page mark at the end of the file.
10861 Text_IO can be used to read such non-standard text files but subprograms
10862 to do with line or page numbers do not have defined meanings. In
10863 particular, a @code{FF} character that does not follow a @code{LF}
10864 character may or may not be treated as a page mark from the point of
10865 view of page and line numbering. Every @code{LF} character is considered
10866 to end a line, and there is an implied @code{LF} character at the end of
10870 * Text_IO Stream Pointer Positioning::
10871 * Text_IO Reading and Writing Non-Regular Files::
10873 * Treating Text_IO Files as Streams::
10874 * Text_IO Extensions::
10875 * Text_IO Facilities for Unbounded Strings::
10878 @node Text_IO Stream Pointer Positioning
10879 @subsection Stream Pointer Positioning
10882 @code{Ada.Text_IO} has a definition of current position for a file that
10883 is being read. No internal buffering occurs in Text_IO, and usually the
10884 physical position in the stream used to implement the file corresponds
10885 to this logical position defined by Text_IO@. There are two exceptions:
10889 After a call to @code{End_Of_Page} that returns @code{True}, the stream
10890 is positioned past the @code{LF} (line mark) that precedes the page
10891 mark. Text_IO maintains an internal flag so that subsequent read
10892 operations properly handle the logical position which is unchanged by
10893 the @code{End_Of_Page} call.
10896 After a call to @code{End_Of_File} that returns @code{True}, if the
10897 Text_IO file was positioned before the line mark at the end of file
10898 before the call, then the logical position is unchanged, but the stream
10899 is physically positioned right at the end of file (past the line mark,
10900 and past a possible page mark following the line mark. Again Text_IO
10901 maintains internal flags so that subsequent read operations properly
10902 handle the logical position.
10906 These discrepancies have no effect on the observable behavior of
10907 Text_IO, but if a single Ada stream is shared between a C program and
10908 Ada program, or shared (using @samp{shared=yes} in the form string)
10909 between two Ada files, then the difference may be observable in some
10912 @node Text_IO Reading and Writing Non-Regular Files
10913 @subsection Reading and Writing Non-Regular Files
10916 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
10917 can be used for reading and writing. Writing is not affected and the
10918 sequence of characters output is identical to the normal file case, but
10919 for reading, the behavior of Text_IO is modified to avoid undesirable
10920 look-ahead as follows:
10922 An input file that is not a regular file is considered to have no page
10923 marks. Any @code{Ascii.FF} characters (the character normally used for a
10924 page mark) appearing in the file are considered to be data
10925 characters. In particular:
10929 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
10930 following a line mark. If a page mark appears, it will be treated as a
10934 This avoids the need to wait for an extra character to be typed or
10935 entered from the pipe to complete one of these operations.
10938 @code{End_Of_Page} always returns @code{False}
10941 @code{End_Of_File} will return @code{False} if there is a page mark at
10942 the end of the file.
10946 Output to non-regular files is the same as for regular files. Page marks
10947 may be written to non-regular files using @code{New_Page}, but as noted
10948 above they will not be treated as page marks on input if the output is
10949 piped to another Ada program.
10951 Another important discrepancy when reading non-regular files is that the end
10952 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
10953 pressing the @key{EOT} key,
10955 is signaled once (i.e.@: the test @code{End_Of_File}
10956 will yield @code{True}, or a read will
10957 raise @code{End_Error}), but then reading can resume
10958 to read data past that end of
10959 file indication, until another end of file indication is entered.
10961 @node Get_Immediate
10962 @subsection Get_Immediate
10963 @cindex Get_Immediate
10966 Get_Immediate returns the next character (including control characters)
10967 from the input file. In particular, Get_Immediate will return LF or FF
10968 characters used as line marks or page marks. Such operations leave the
10969 file positioned past the control character, and it is thus not treated
10970 as having its normal function. This means that page, line and column
10971 counts after this kind of Get_Immediate call are set as though the mark
10972 did not occur. In the case where a Get_Immediate leaves the file
10973 positioned between the line mark and page mark (which is not normally
10974 possible), it is undefined whether the FF character will be treated as a
10977 @node Treating Text_IO Files as Streams
10978 @subsection Treating Text_IO Files as Streams
10979 @cindex Stream files
10982 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
10983 as a stream. Data written to a Text_IO file in this stream mode is
10984 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
10985 16#0C# (@code{FF}), the resulting file may have non-standard
10986 format. Similarly if read operations are used to read from a Text_IO
10987 file treated as a stream, then @code{LF} and @code{FF} characters may be
10988 skipped and the effect is similar to that described above for
10989 @code{Get_Immediate}.
10991 @node Text_IO Extensions
10992 @subsection Text_IO Extensions
10993 @cindex Text_IO extensions
10996 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
10997 to the standard @code{Text_IO} package:
11000 @item function File_Exists (Name : String) return Boolean;
11001 Determines if a file of the given name exists.
11003 @item function Get_Line return String;
11004 Reads a string from the standard input file. The value returned is exactly
11005 the length of the line that was read.
11007 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
11008 Similar, except that the parameter File specifies the file from which
11009 the string is to be read.
11013 @node Text_IO Facilities for Unbounded Strings
11014 @subsection Text_IO Facilities for Unbounded Strings
11015 @cindex Text_IO for unbounded strings
11016 @cindex Unbounded_String, Text_IO operations
11019 The package @code{Ada.Strings.Unbounded.Text_IO}
11020 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
11021 subprograms useful for Text_IO operations on unbounded strings:
11025 @item function Get_Line (File : File_Type) return Unbounded_String;
11026 Reads a line from the specified file
11027 and returns the result as an unbounded string.
11029 @item procedure Put (File : File_Type; U : Unbounded_String);
11030 Writes the value of the given unbounded string to the specified file
11031 Similar to the effect of
11032 @code{Put (To_String (U))} except that an extra copy is avoided.
11034 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
11035 Writes the value of the given unbounded string to the specified file,
11036 followed by a @code{New_Line}.
11037 Similar to the effect of @code{Put_Line (To_String (U))} except
11038 that an extra copy is avoided.
11042 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
11043 and is optional. If the parameter is omitted, then the standard input or
11044 output file is referenced as appropriate.
11046 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
11047 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
11048 @code{Wide_Text_IO} functionality for unbounded wide strings.
11050 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
11051 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
11052 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
11055 @section Wide_Text_IO
11058 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
11059 both input and output files may contain special sequences that represent
11060 wide character values. The encoding scheme for a given file may be
11061 specified using a FORM parameter:
11068 as part of the FORM string (WCEM = wide character encoding method),
11069 where @var{x} is one of the following characters
11075 Upper half encoding
11087 The encoding methods match those that
11088 can be used in a source
11089 program, but there is no requirement that the encoding method used for
11090 the source program be the same as the encoding method used for files,
11091 and different files may use different encoding methods.
11093 The default encoding method for the standard files, and for opened files
11094 for which no WCEM parameter is given in the FORM string matches the
11095 wide character encoding specified for the main program (the default
11096 being brackets encoding if no coding method was specified with -gnatW).
11100 In this encoding, a wide character is represented by a five character
11108 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
11109 characters (using upper case letters) of the wide character code. For
11110 example, ESC A345 is used to represent the wide character with code
11111 16#A345#. This scheme is compatible with use of the full
11112 @code{Wide_Character} set.
11114 @item Upper Half Coding
11115 The wide character with encoding 16#abcd#, where the upper bit is on
11116 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
11117 16#cd#. The second byte may never be a format control character, but is
11118 not required to be in the upper half. This method can be also used for
11119 shift-JIS or EUC where the internal coding matches the external coding.
11121 @item Shift JIS Coding
11122 A wide character is represented by a two character sequence 16#ab# and
11123 16#cd#, with the restrictions described for upper half encoding as
11124 described above. The internal character code is the corresponding JIS
11125 character according to the standard algorithm for Shift-JIS
11126 conversion. Only characters defined in the JIS code set table can be
11127 used with this encoding method.
11130 A wide character is represented by a two character sequence 16#ab# and
11131 16#cd#, with both characters being in the upper half. The internal
11132 character code is the corresponding JIS character according to the EUC
11133 encoding algorithm. Only characters defined in the JIS code set table
11134 can be used with this encoding method.
11137 A wide character is represented using
11138 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11139 10646-1/Am.2. Depending on the character value, the representation
11140 is a one, two, or three byte sequence:
11143 16#0000#-16#007f#: 2#0xxxxxxx#
11144 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
11145 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11149 where the xxx bits correspond to the left-padded bits of the
11150 16-bit character value. Note that all lower half ASCII characters
11151 are represented as ASCII bytes and all upper half characters and
11152 other wide characters are represented as sequences of upper-half
11153 (The full UTF-8 scheme allows for encoding 31-bit characters as
11154 6-byte sequences, but in this implementation, all UTF-8 sequences
11155 of four or more bytes length will raise a Constraint_Error, as
11156 will all invalid UTF-8 sequences.)
11158 @item Brackets Coding
11159 In this encoding, a wide character is represented by the following eight
11160 character sequence:
11167 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
11168 characters (using uppercase letters) of the wide character code. For
11169 example, @code{["A345"]} is used to represent the wide character with code
11171 This scheme is compatible with use of the full Wide_Character set.
11172 On input, brackets coding can also be used for upper half characters,
11173 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
11174 is only used for wide characters with a code greater than @code{16#FF#}.
11179 For the coding schemes other than Hex and Brackets encoding,
11180 not all wide character
11181 values can be represented. An attempt to output a character that cannot
11182 be represented using the encoding scheme for the file causes
11183 Constraint_Error to be raised. An invalid wide character sequence on
11184 input also causes Constraint_Error to be raised.
11187 * Wide_Text_IO Stream Pointer Positioning::
11188 * Wide_Text_IO Reading and Writing Non-Regular Files::
11191 @node Wide_Text_IO Stream Pointer Positioning
11192 @subsection Stream Pointer Positioning
11195 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
11196 of stream pointer positioning (@pxref{Text_IO}). There is one additional
11199 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
11200 normal lower ASCII set (i.e.@: a character in the range:
11202 @smallexample @c ada
11203 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
11207 then although the logical position of the file pointer is unchanged by
11208 the @code{Look_Ahead} call, the stream is physically positioned past the
11209 wide character sequence. Again this is to avoid the need for buffering
11210 or backup, and all @code{Wide_Text_IO} routines check the internal
11211 indication that this situation has occurred so that this is not visible
11212 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
11213 can be observed if the wide text file shares a stream with another file.
11215 @node Wide_Text_IO Reading and Writing Non-Regular Files
11216 @subsection Reading and Writing Non-Regular Files
11219 As in the case of Text_IO, when a non-regular file is read, it is
11220 assumed that the file contains no page marks (any form characters are
11221 treated as data characters), and @code{End_Of_Page} always returns
11222 @code{False}. Similarly, the end of file indication is not sticky, so
11223 it is possible to read beyond an end of file.
11225 @node Wide_Wide_Text_IO
11226 @section Wide_Wide_Text_IO
11229 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
11230 both input and output files may contain special sequences that represent
11231 wide wide character values. The encoding scheme for a given file may be
11232 specified using a FORM parameter:
11239 as part of the FORM string (WCEM = wide character encoding method),
11240 where @var{x} is one of the following characters
11246 Upper half encoding
11258 The encoding methods match those that
11259 can be used in a source
11260 program, but there is no requirement that the encoding method used for
11261 the source program be the same as the encoding method used for files,
11262 and different files may use different encoding methods.
11264 The default encoding method for the standard files, and for opened files
11265 for which no WCEM parameter is given in the FORM string matches the
11266 wide character encoding specified for the main program (the default
11267 being brackets encoding if no coding method was specified with -gnatW).
11272 A wide character is represented using
11273 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11274 10646-1/Am.2. Depending on the character value, the representation
11275 is a one, two, three, or four byte sequence:
11278 16#000000#-16#00007f#: 2#0xxxxxxx#
11279 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
11280 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11281 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
11285 where the xxx bits correspond to the left-padded bits of the
11286 21-bit character value. Note that all lower half ASCII characters
11287 are represented as ASCII bytes and all upper half characters and
11288 other wide characters are represented as sequences of upper-half
11291 @item Brackets Coding
11292 In this encoding, a wide wide character is represented by the following eight
11293 character sequence if is in wide character range
11299 and by the following ten character sequence if not
11302 [ " a b c d e f " ]
11306 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
11307 are the four or six hexadecimal
11308 characters (using uppercase letters) of the wide wide character code. For
11309 example, @code{["01A345"]} is used to represent the wide wide character
11310 with code @code{16#01A345#}.
11312 This scheme is compatible with use of the full Wide_Wide_Character set.
11313 On input, brackets coding can also be used for upper half characters,
11314 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
11315 is only used for wide characters with a code greater than @code{16#FF#}.
11320 If is also possible to use the other Wide_Character encoding methods,
11321 such as Shift-JIS, but the other schemes cannot support the full range
11322 of wide wide characters.
11323 An attempt to output a character that cannot
11324 be represented using the encoding scheme for the file causes
11325 Constraint_Error to be raised. An invalid wide character sequence on
11326 input also causes Constraint_Error to be raised.
11329 * Wide_Wide_Text_IO Stream Pointer Positioning::
11330 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
11333 @node Wide_Wide_Text_IO Stream Pointer Positioning
11334 @subsection Stream Pointer Positioning
11337 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
11338 of stream pointer positioning (@pxref{Text_IO}). There is one additional
11341 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
11342 normal lower ASCII set (i.e.@: a character in the range:
11344 @smallexample @c ada
11345 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
11349 then although the logical position of the file pointer is unchanged by
11350 the @code{Look_Ahead} call, the stream is physically positioned past the
11351 wide character sequence. Again this is to avoid the need for buffering
11352 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
11353 indication that this situation has occurred so that this is not visible
11354 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
11355 can be observed if the wide text file shares a stream with another file.
11357 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
11358 @subsection Reading and Writing Non-Regular Files
11361 As in the case of Text_IO, when a non-regular file is read, it is
11362 assumed that the file contains no page marks (any form characters are
11363 treated as data characters), and @code{End_Of_Page} always returns
11364 @code{False}. Similarly, the end of file indication is not sticky, so
11365 it is possible to read beyond an end of file.
11371 A stream file is a sequence of bytes, where individual elements are
11372 written to the file as described in the Ada 95 reference manual. The type
11373 @code{Stream_Element} is simply a byte. There are two ways to read or
11374 write a stream file.
11378 The operations @code{Read} and @code{Write} directly read or write a
11379 sequence of stream elements with no control information.
11382 The stream attributes applied to a stream file transfer data in the
11383 manner described for stream attributes.
11387 @section Shared Files
11390 Section A.14 of the Ada 95 Reference Manual allows implementations to
11391 provide a wide variety of behavior if an attempt is made to access the
11392 same external file with two or more internal files.
11394 To provide a full range of functionality, while at the same time
11395 minimizing the problems of portability caused by this implementation
11396 dependence, GNAT handles file sharing as follows:
11400 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
11401 to open two or more files with the same full name is considered an error
11402 and is not supported. The exception @code{Use_Error} will be
11403 raised. Note that a file that is not explicitly closed by the program
11404 remains open until the program terminates.
11407 If the form parameter @samp{shared=no} appears in the form string, the
11408 file can be opened or created with its own separate stream identifier,
11409 regardless of whether other files sharing the same external file are
11410 opened. The exact effect depends on how the C stream routines handle
11411 multiple accesses to the same external files using separate streams.
11414 If the form parameter @samp{shared=yes} appears in the form string for
11415 each of two or more files opened using the same full name, the same
11416 stream is shared between these files, and the semantics are as described
11417 in Ada 95 Reference Manual, Section A.14.
11421 When a program that opens multiple files with the same name is ported
11422 from another Ada compiler to GNAT, the effect will be that
11423 @code{Use_Error} is raised.
11425 The documentation of the original compiler and the documentation of the
11426 program should then be examined to determine if file sharing was
11427 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
11428 and @code{Create} calls as required.
11430 When a program is ported from GNAT to some other Ada compiler, no
11431 special attention is required unless the @samp{shared=@var{xxx}} form
11432 parameter is used in the program. In this case, you must examine the
11433 documentation of the new compiler to see if it supports the required
11434 file sharing semantics, and form strings modified appropriately. Of
11435 course it may be the case that the program cannot be ported if the
11436 target compiler does not support the required functionality. The best
11437 approach in writing portable code is to avoid file sharing (and hence
11438 the use of the @samp{shared=@var{xxx}} parameter in the form string)
11441 One common use of file sharing in Ada 83 is the use of instantiations of
11442 Sequential_IO on the same file with different types, to achieve
11443 heterogeneous input-output. Although this approach will work in GNAT if
11444 @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
11445 for this purpose (using the stream attributes)
11448 @section Open Modes
11451 @code{Open} and @code{Create} calls result in a call to @code{fopen}
11452 using the mode shown in the following table:
11455 @center @code{Open} and @code{Create} Call Modes
11457 @b{OPEN } @b{CREATE}
11458 Append_File "r+" "w+"
11460 Out_File (Direct_IO) "r+" "w"
11461 Out_File (all other cases) "w" "w"
11462 Inout_File "r+" "w+"
11466 If text file translation is required, then either @samp{b} or @samp{t}
11467 is added to the mode, depending on the setting of Text. Text file
11468 translation refers to the mapping of CR/LF sequences in an external file
11469 to LF characters internally. This mapping only occurs in DOS and
11470 DOS-like systems, and is not relevant to other systems.
11472 A special case occurs with Stream_IO@. As shown in the above table, the
11473 file is initially opened in @samp{r} or @samp{w} mode for the
11474 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
11475 subsequently requires switching from reading to writing or vice-versa,
11476 then the file is reopened in @samp{r+} mode to permit the required operation.
11478 @node Operations on C Streams
11479 @section Operations on C Streams
11480 The package @code{Interfaces.C_Streams} provides an Ada program with direct
11481 access to the C library functions for operations on C streams:
11483 @smallexample @c adanocomment
11484 package Interfaces.C_Streams is
11485 -- Note: the reason we do not use the types that are in
11486 -- Interfaces.C is that we want to avoid dragging in the
11487 -- code in this unit if possible.
11488 subtype chars is System.Address;
11489 -- Pointer to null-terminated array of characters
11490 subtype FILEs is System.Address;
11491 -- Corresponds to the C type FILE*
11492 subtype voids is System.Address;
11493 -- Corresponds to the C type void*
11494 subtype int is Integer;
11495 subtype long is Long_Integer;
11496 -- Note: the above types are subtypes deliberately, and it
11497 -- is part of this spec that the above correspondences are
11498 -- guaranteed. This means that it is legitimate to, for
11499 -- example, use Integer instead of int. We provide these
11500 -- synonyms for clarity, but in some cases it may be
11501 -- convenient to use the underlying types (for example to
11502 -- avoid an unnecessary dependency of a spec on the spec
11504 type size_t is mod 2 ** Standard'Address_Size;
11505 NULL_Stream : constant FILEs;
11506 -- Value returned (NULL in C) to indicate an
11507 -- fdopen/fopen/tmpfile error
11508 ----------------------------------
11509 -- Constants Defined in stdio.h --
11510 ----------------------------------
11511 EOF : constant int;
11512 -- Used by a number of routines to indicate error or
11514 IOFBF : constant int;
11515 IOLBF : constant int;
11516 IONBF : constant int;
11517 -- Used to indicate buffering mode for setvbuf call
11518 SEEK_CUR : constant int;
11519 SEEK_END : constant int;
11520 SEEK_SET : constant int;
11521 -- Used to indicate origin for fseek call
11522 function stdin return FILEs;
11523 function stdout return FILEs;
11524 function stderr return FILEs;
11525 -- Streams associated with standard files
11526 --------------------------
11527 -- Standard C functions --
11528 --------------------------
11529 -- The functions selected below are ones that are
11530 -- available in DOS, OS/2, UNIX and Xenix (but not
11531 -- necessarily in ANSI C). These are very thin interfaces
11532 -- which copy exactly the C headers. For more
11533 -- documentation on these functions, see the Microsoft C
11534 -- "Run-Time Library Reference" (Microsoft Press, 1990,
11535 -- ISBN 1-55615-225-6), which includes useful information
11536 -- on system compatibility.
11537 procedure clearerr (stream : FILEs);
11538 function fclose (stream : FILEs) return int;
11539 function fdopen (handle : int; mode : chars) return FILEs;
11540 function feof (stream : FILEs) return int;
11541 function ferror (stream : FILEs) return int;
11542 function fflush (stream : FILEs) return int;
11543 function fgetc (stream : FILEs) return int;
11544 function fgets (strng : chars; n : int; stream : FILEs)
11546 function fileno (stream : FILEs) return int;
11547 function fopen (filename : chars; Mode : chars)
11549 -- Note: to maintain target independence, use
11550 -- text_translation_required, a boolean variable defined in
11551 -- a-sysdep.c to deal with the target dependent text
11552 -- translation requirement. If this variable is set,
11553 -- then b/t should be appended to the standard mode
11554 -- argument to set the text translation mode off or on
11556 function fputc (C : int; stream : FILEs) return int;
11557 function fputs (Strng : chars; Stream : FILEs) return int;
11574 function ftell (stream : FILEs) return long;
11581 function isatty (handle : int) return int;
11582 procedure mktemp (template : chars);
11583 -- The return value (which is just a pointer to template)
11585 procedure rewind (stream : FILEs);
11586 function rmtmp return int;
11594 function tmpfile return FILEs;
11595 function ungetc (c : int; stream : FILEs) return int;
11596 function unlink (filename : chars) return int;
11597 ---------------------
11598 -- Extra functions --
11599 ---------------------
11600 -- These functions supply slightly thicker bindings than
11601 -- those above. They are derived from functions in the
11602 -- C Run-Time Library, but may do a bit more work than
11603 -- just directly calling one of the Library functions.
11604 function is_regular_file (handle : int) return int;
11605 -- Tests if given handle is for a regular file (result 1)
11606 -- or for a non-regular file (pipe or device, result 0).
11607 ---------------------------------
11608 -- Control of Text/Binary Mode --
11609 ---------------------------------
11610 -- If text_translation_required is true, then the following
11611 -- functions may be used to dynamically switch a file from
11612 -- binary to text mode or vice versa. These functions have
11613 -- no effect if text_translation_required is false (i.e. in
11614 -- normal UNIX mode). Use fileno to get a stream handle.
11615 procedure set_binary_mode (handle : int);
11616 procedure set_text_mode (handle : int);
11617 ----------------------------
11618 -- Full Path Name support --
11619 ----------------------------
11620 procedure full_name (nam : chars; buffer : chars);
11621 -- Given a NUL terminated string representing a file
11622 -- name, returns in buffer a NUL terminated string
11623 -- representing the full path name for the file name.
11624 -- On systems where it is relevant the drive is also
11625 -- part of the full path name. It is the responsibility
11626 -- of the caller to pass an actual parameter for buffer
11627 -- that is big enough for any full path name. Use
11628 -- max_path_len given below as the size of buffer.
11629 max_path_len : integer;
11630 -- Maximum length of an allowable full path name on the
11631 -- system, including a terminating NUL character.
11632 end Interfaces.C_Streams;
11635 @node Interfacing to C Streams
11636 @section Interfacing to C Streams
11639 The packages in this section permit interfacing Ada files to C Stream
11642 @smallexample @c ada
11643 with Interfaces.C_Streams;
11644 package Ada.Sequential_IO.C_Streams is
11645 function C_Stream (F : File_Type)
11646 return Interfaces.C_Streams.FILEs;
11648 (File : in out File_Type;
11649 Mode : in File_Mode;
11650 C_Stream : in Interfaces.C_Streams.FILEs;
11651 Form : in String := "");
11652 end Ada.Sequential_IO.C_Streams;
11654 with Interfaces.C_Streams;
11655 package Ada.Direct_IO.C_Streams is
11656 function C_Stream (F : File_Type)
11657 return Interfaces.C_Streams.FILEs;
11659 (File : in out File_Type;
11660 Mode : in File_Mode;
11661 C_Stream : in Interfaces.C_Streams.FILEs;
11662 Form : in String := "");
11663 end Ada.Direct_IO.C_Streams;
11665 with Interfaces.C_Streams;
11666 package Ada.Text_IO.C_Streams is
11667 function C_Stream (F : File_Type)
11668 return Interfaces.C_Streams.FILEs;
11670 (File : in out File_Type;
11671 Mode : in File_Mode;
11672 C_Stream : in Interfaces.C_Streams.FILEs;
11673 Form : in String := "");
11674 end Ada.Text_IO.C_Streams;
11676 with Interfaces.C_Streams;
11677 package Ada.Wide_Text_IO.C_Streams is
11678 function C_Stream (F : File_Type)
11679 return Interfaces.C_Streams.FILEs;
11681 (File : in out File_Type;
11682 Mode : in File_Mode;
11683 C_Stream : in Interfaces.C_Streams.FILEs;
11684 Form : in String := "");
11685 end Ada.Wide_Text_IO.C_Streams;
11687 with Interfaces.C_Streams;
11688 package Ada.Wide_Wide_Text_IO.C_Streams is
11689 function C_Stream (F : File_Type)
11690 return Interfaces.C_Streams.FILEs;
11692 (File : in out File_Type;
11693 Mode : in File_Mode;
11694 C_Stream : in Interfaces.C_Streams.FILEs;
11695 Form : in String := "");
11696 end Ada.Wide_Wide_Text_IO.C_Streams;
11698 with Interfaces.C_Streams;
11699 package Ada.Stream_IO.C_Streams is
11700 function C_Stream (F : File_Type)
11701 return Interfaces.C_Streams.FILEs;
11703 (File : in out File_Type;
11704 Mode : in File_Mode;
11705 C_Stream : in Interfaces.C_Streams.FILEs;
11706 Form : in String := "");
11707 end Ada.Stream_IO.C_Streams;
11711 In each of these six packages, the @code{C_Stream} function obtains the
11712 @code{FILE} pointer from a currently opened Ada file. It is then
11713 possible to use the @code{Interfaces.C_Streams} package to operate on
11714 this stream, or the stream can be passed to a C program which can
11715 operate on it directly. Of course the program is responsible for
11716 ensuring that only appropriate sequences of operations are executed.
11718 One particular use of relevance to an Ada program is that the
11719 @code{setvbuf} function can be used to control the buffering of the
11720 stream used by an Ada file. In the absence of such a call the standard
11721 default buffering is used.
11723 The @code{Open} procedures in these packages open a file giving an
11724 existing C Stream instead of a file name. Typically this stream is
11725 imported from a C program, allowing an Ada file to operate on an
11728 @node The GNAT Library
11729 @chapter The GNAT Library
11732 The GNAT library contains a number of general and special purpose packages.
11733 It represents functionality that the GNAT developers have found useful, and
11734 which is made available to GNAT users. The packages described here are fully
11735 supported, and upwards compatibility will be maintained in future releases,
11736 so you can use these facilities with the confidence that the same functionality
11737 will be available in future releases.
11739 The chapter here simply gives a brief summary of the facilities available.
11740 The full documentation is found in the spec file for the package. The full
11741 sources of these library packages, including both spec and body, are provided
11742 with all GNAT releases. For example, to find out the full specifications of
11743 the SPITBOL pattern matching capability, including a full tutorial and
11744 extensive examples, look in the @file{g-spipat.ads} file in the library.
11746 For each entry here, the package name (as it would appear in a @code{with}
11747 clause) is given, followed by the name of the corresponding spec file in
11748 parentheses. The packages are children in four hierarchies, @code{Ada},
11749 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
11750 GNAT-specific hierarchy.
11752 Note that an application program should only use packages in one of these
11753 four hierarchies if the package is defined in the Ada Reference Manual,
11754 or is listed in this section of the GNAT Programmers Reference Manual.
11755 All other units should be considered internal implementation units and
11756 should not be directly @code{with}'ed by application code. The use of
11757 a @code{with} statement that references one of these internal implementation
11758 units makes an application potentially dependent on changes in versions
11759 of GNAT, and will generate a warning message.
11762 * Ada.Characters.Latin_9 (a-chlat9.ads)::
11763 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
11764 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
11765 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
11766 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
11767 * Ada.Command_Line.Remove (a-colire.ads)::
11768 * Ada.Command_Line.Environment (a-colien.ads)::
11769 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
11770 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
11771 * Ada.Exceptions.Traceback (a-exctra.ads)::
11772 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
11773 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
11774 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
11775 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
11776 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
11777 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
11778 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
11779 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
11780 * GNAT.Array_Split (g-arrspl.ads)::
11781 * GNAT.AWK (g-awk.ads)::
11782 * GNAT.Bounded_Buffers (g-boubuf.ads)::
11783 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
11784 * GNAT.Bubble_Sort (g-bubsor.ads)::
11785 * GNAT.Bubble_Sort_A (g-busora.ads)::
11786 * GNAT.Bubble_Sort_G (g-busorg.ads)::
11787 * GNAT.Calendar (g-calend.ads)::
11788 * GNAT.Calendar.Time_IO (g-catiio.ads)::
11789 * GNAT.CRC32 (g-crc32.ads)::
11790 * GNAT.Case_Util (g-casuti.ads)::
11791 * GNAT.CGI (g-cgi.ads)::
11792 * GNAT.CGI.Cookie (g-cgicoo.ads)::
11793 * GNAT.CGI.Debug (g-cgideb.ads)::
11794 * GNAT.Command_Line (g-comlin.ads)::
11795 * GNAT.Compiler_Version (g-comver.ads)::
11796 * GNAT.Ctrl_C (g-ctrl_c.ads)::
11797 * GNAT.Current_Exception (g-curexc.ads)::
11798 * GNAT.Debug_Pools (g-debpoo.ads)::
11799 * GNAT.Debug_Utilities (g-debuti.ads)::
11800 * GNAT.Directory_Operations (g-dirope.ads)::
11801 * GNAT.Dynamic_HTables (g-dynhta.ads)::
11802 * GNAT.Dynamic_Tables (g-dyntab.ads)::
11803 * GNAT.Exception_Actions (g-excact.ads)::
11804 * GNAT.Exception_Traces (g-exctra.ads)::
11805 * GNAT.Exceptions (g-except.ads)::
11806 * GNAT.Expect (g-expect.ads)::
11807 * GNAT.Float_Control (g-flocon.ads)::
11808 * GNAT.Heap_Sort (g-heasor.ads)::
11809 * GNAT.Heap_Sort_A (g-hesora.ads)::
11810 * GNAT.Heap_Sort_G (g-hesorg.ads)::
11811 * GNAT.HTable (g-htable.ads)::
11812 * GNAT.IO (g-io.ads)::
11813 * GNAT.IO_Aux (g-io_aux.ads)::
11814 * GNAT.Lock_Files (g-locfil.ads)::
11815 * GNAT.MD5 (g-md5.ads)::
11816 * GNAT.Memory_Dump (g-memdum.ads)::
11817 * GNAT.Most_Recent_Exception (g-moreex.ads)::
11818 * GNAT.OS_Lib (g-os_lib.ads)::
11819 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
11820 * GNAT.Regexp (g-regexp.ads)::
11821 * GNAT.Registry (g-regist.ads)::
11822 * GNAT.Regpat (g-regpat.ads)::
11823 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
11824 * GNAT.Semaphores (g-semaph.ads)::
11825 * GNAT.Signals (g-signal.ads)::
11826 * GNAT.Sockets (g-socket.ads)::
11827 * GNAT.Source_Info (g-souinf.ads)::
11828 * GNAT.Spell_Checker (g-speche.ads)::
11829 * GNAT.Spitbol.Patterns (g-spipat.ads)::
11830 * GNAT.Spitbol (g-spitbo.ads)::
11831 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
11832 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
11833 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
11834 * GNAT.Strings (g-string.ads)::
11835 * GNAT.String_Split (g-strspl.ads)::
11836 * GNAT.UTF_32 (g-utf_32.ads)::
11837 * GNAT.Table (g-table.ads)::
11838 * GNAT.Task_Lock (g-tasloc.ads)::
11839 * GNAT.Threads (g-thread.ads)::
11840 * GNAT.Traceback (g-traceb.ads)::
11841 * GNAT.Traceback.Symbolic (g-trasym.ads)::
11842 * GNAT.Wide_String_Split (g-wistsp.ads)::
11843 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
11844 * Interfaces.C.Extensions (i-cexten.ads)::
11845 * Interfaces.C.Streams (i-cstrea.ads)::
11846 * Interfaces.CPP (i-cpp.ads)::
11847 * Interfaces.Os2lib (i-os2lib.ads)::
11848 * Interfaces.Os2lib.Errors (i-os2err.ads)::
11849 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
11850 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
11851 * Interfaces.Packed_Decimal (i-pacdec.ads)::
11852 * Interfaces.VxWorks (i-vxwork.ads)::
11853 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
11854 * System.Address_Image (s-addima.ads)::
11855 * System.Assertions (s-assert.ads)::
11856 * System.Memory (s-memory.ads)::
11857 * System.Partition_Interface (s-parint.ads)::
11858 * System.Restrictions (s-restri.ads)::
11859 * System.Rident (s-rident.ads)::
11860 * System.Task_Info (s-tasinf.ads)::
11861 * System.Wch_Cnv (s-wchcnv.ads)::
11862 * System.Wch_Con (s-wchcon.ads)::
11865 @node Ada.Characters.Latin_9 (a-chlat9.ads)
11866 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11867 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11868 @cindex Latin_9 constants for Character
11871 This child of @code{Ada.Characters}
11872 provides a set of definitions corresponding to those in the
11873 RM-defined package @code{Ada.Characters.Latin_1} but with the
11874 few modifications required for @code{Latin-9}
11875 The provision of such a package
11876 is specifically authorized by the Ada Reference Manual
11879 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
11880 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11881 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11882 @cindex Latin_1 constants for Wide_Character
11885 This child of @code{Ada.Characters}
11886 provides a set of definitions corresponding to those in the
11887 RM-defined package @code{Ada.Characters.Latin_1} but with the
11888 types of the constants being @code{Wide_Character}
11889 instead of @code{Character}. The provision of such a package
11890 is specifically authorized by the Ada Reference Manual
11893 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
11894 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11895 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11896 @cindex Latin_9 constants for Wide_Character
11899 This child of @code{Ada.Characters}
11900 provides a set of definitions corresponding to those in the
11901 GNAT defined package @code{Ada.Characters.Latin_9} but with the
11902 types of the constants being @code{Wide_Character}
11903 instead of @code{Character}. The provision of such a package
11904 is specifically authorized by the Ada Reference Manual
11907 @node Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)
11908 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
11909 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
11910 @cindex Latin_1 constants for Wide_Wide_Character
11913 This child of @code{Ada.Characters}
11914 provides a set of definitions corresponding to those in the
11915 RM-defined package @code{Ada.Characters.Latin_1} but with the
11916 types of the constants being @code{Wide_Wide_Character}
11917 instead of @code{Character}. The provision of such a package
11918 is specifically authorized by the Ada Reference Manual
11921 @node Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)
11922 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
11923 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
11924 @cindex Latin_9 constants for Wide_Wide_Character
11927 This child of @code{Ada.Characters}
11928 provides a set of definitions corresponding to those in the
11929 GNAT defined package @code{Ada.Characters.Latin_9} but with the
11930 types of the constants being @code{Wide_Wide_Character}
11931 instead of @code{Character}. The provision of such a package
11932 is specifically authorized by the Ada Reference Manual
11935 @node Ada.Command_Line.Remove (a-colire.ads)
11936 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11937 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11938 @cindex Removing command line arguments
11939 @cindex Command line, argument removal
11942 This child of @code{Ada.Command_Line}
11943 provides a mechanism for logically removing
11944 arguments from the argument list. Once removed, an argument is not visible
11945 to further calls on the subprograms in @code{Ada.Command_Line} will not
11946 see the removed argument.
11948 @node Ada.Command_Line.Environment (a-colien.ads)
11949 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11950 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11951 @cindex Environment entries
11954 This child of @code{Ada.Command_Line}
11955 provides a mechanism for obtaining environment values on systems
11956 where this concept makes sense.
11958 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
11959 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11960 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11961 @cindex C Streams, Interfacing with Direct_IO
11964 This package provides subprograms that allow interfacing between
11965 C streams and @code{Direct_IO}. The stream identifier can be
11966 extracted from a file opened on the Ada side, and an Ada file
11967 can be constructed from a stream opened on the C side.
11969 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
11970 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11971 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11972 @cindex Null_Occurrence, testing for
11975 This child subprogram provides a way of testing for the null
11976 exception occurrence (@code{Null_Occurrence}) without raising
11979 @node Ada.Exceptions.Traceback (a-exctra.ads)
11980 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11981 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11982 @cindex Traceback for Exception Occurrence
11985 This child package provides the subprogram (@code{Tracebacks}) to
11986 give a traceback array of addresses based on an exception
11989 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
11990 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11991 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11992 @cindex C Streams, Interfacing with Sequential_IO
11995 This package provides subprograms that allow interfacing between
11996 C streams and @code{Sequential_IO}. The stream identifier can be
11997 extracted from a file opened on the Ada side, and an Ada file
11998 can be constructed from a stream opened on the C side.
12000 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
12001 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12002 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12003 @cindex C Streams, Interfacing with Stream_IO
12006 This package provides subprograms that allow interfacing between
12007 C streams and @code{Stream_IO}. The stream identifier can be
12008 extracted from a file opened on the Ada side, and an Ada file
12009 can be constructed from a stream opened on the C side.
12011 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
12012 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12013 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12014 @cindex @code{Unbounded_String}, IO support
12015 @cindex @code{Text_IO}, extensions for unbounded strings
12018 This package provides subprograms for Text_IO for unbounded
12019 strings, avoiding the necessity for an intermediate operation
12020 with ordinary strings.
12022 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
12023 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12024 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12025 @cindex @code{Unbounded_Wide_String}, IO support
12026 @cindex @code{Text_IO}, extensions for unbounded wide strings
12029 This package provides subprograms for Text_IO for unbounded
12030 wide strings, avoiding the necessity for an intermediate operation
12031 with ordinary wide strings.
12033 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
12034 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12035 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12036 @cindex @code{Unbounded_Wide_Wide_String}, IO support
12037 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
12040 This package provides subprograms for Text_IO for unbounded
12041 wide wide strings, avoiding the necessity for an intermediate operation
12042 with ordinary wide wide strings.
12044 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
12045 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12046 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12047 @cindex C Streams, Interfacing with @code{Text_IO}
12050 This package provides subprograms that allow interfacing between
12051 C streams and @code{Text_IO}. The stream identifier can be
12052 extracted from a file opened on the Ada side, and an Ada file
12053 can be constructed from a stream opened on the C side.
12055 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
12056 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12057 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12058 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
12061 This package provides subprograms that allow interfacing between
12062 C streams and @code{Wide_Text_IO}. The stream identifier can be
12063 extracted from a file opened on the Ada side, and an Ada file
12064 can be constructed from a stream opened on the C side.
12066 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
12067 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12068 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12069 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
12072 This package provides subprograms that allow interfacing between
12073 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
12074 extracted from a file opened on the Ada side, and an Ada file
12075 can be constructed from a stream opened on the C side.
12078 @node GNAT.Array_Split (g-arrspl.ads)
12079 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12080 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12081 @cindex Array splitter
12084 Useful array-manipulation routines: given a set of separators, split
12085 an array wherever the separators appear, and provide direct access
12086 to the resulting slices.
12088 @node GNAT.AWK (g-awk.ads)
12089 @section @code{GNAT.AWK} (@file{g-awk.ads})
12090 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
12095 Provides AWK-like parsing functions, with an easy interface for parsing one
12096 or more files containing formatted data. The file is viewed as a database
12097 where each record is a line and a field is a data element in this line.
12099 @node GNAT.Bounded_Buffers (g-boubuf.ads)
12100 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
12101 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
12103 @cindex Bounded Buffers
12106 Provides a concurrent generic bounded buffer abstraction. Instances are
12107 useful directly or as parts of the implementations of other abstractions,
12110 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
12111 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
12112 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
12117 Provides a thread-safe asynchronous intertask mailbox communication facility.
12119 @node GNAT.Bubble_Sort (g-bubsor.ads)
12120 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
12121 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
12123 @cindex Bubble sort
12126 Provides a general implementation of bubble sort usable for sorting arbitrary
12127 data items. Exchange and comparison procedures are provided by passing
12128 access-to-procedure values.
12130 @node GNAT.Bubble_Sort_A (g-busora.ads)
12131 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
12132 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
12134 @cindex Bubble sort
12137 Provides a general implementation of bubble sort usable for sorting arbitrary
12138 data items. Move and comparison procedures are provided by passing
12139 access-to-procedure values. This is an older version, retained for
12140 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
12142 @node GNAT.Bubble_Sort_G (g-busorg.ads)
12143 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
12144 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
12146 @cindex Bubble sort
12149 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
12150 are provided as generic parameters, this improves efficiency, especially
12151 if the procedures can be inlined, at the expense of duplicating code for
12152 multiple instantiations.
12154 @node GNAT.Calendar (g-calend.ads)
12155 @section @code{GNAT.Calendar} (@file{g-calend.ads})
12156 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
12157 @cindex @code{Calendar}
12160 Extends the facilities provided by @code{Ada.Calendar} to include handling
12161 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
12162 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
12163 C @code{timeval} format.
12165 @node GNAT.Calendar.Time_IO (g-catiio.ads)
12166 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
12167 @cindex @code{Calendar}
12169 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
12171 @node GNAT.CRC32 (g-crc32.ads)
12172 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
12173 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
12175 @cindex Cyclic Redundancy Check
12178 This package implements the CRC-32 algorithm. For a full description
12179 of this algorithm see
12180 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
12181 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
12182 Aug.@: 1988. Sarwate, D.V@.
12185 Provides an extended capability for formatted output of time values with
12186 full user control over the format. Modeled on the GNU Date specification.
12188 @node GNAT.Case_Util (g-casuti.ads)
12189 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
12190 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
12191 @cindex Casing utilities
12192 @cindex Character handling (@code{GNAT.Case_Util})
12195 A set of simple routines for handling upper and lower casing of strings
12196 without the overhead of the full casing tables
12197 in @code{Ada.Characters.Handling}.
12199 @node GNAT.CGI (g-cgi.ads)
12200 @section @code{GNAT.CGI} (@file{g-cgi.ads})
12201 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
12202 @cindex CGI (Common Gateway Interface)
12205 This is a package for interfacing a GNAT program with a Web server via the
12206 Common Gateway Interface (CGI)@. Basically this package parses the CGI
12207 parameters, which are a set of key/value pairs sent by the Web server. It
12208 builds a table whose index is the key and provides some services to deal
12211 @node GNAT.CGI.Cookie (g-cgicoo.ads)
12212 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
12213 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
12214 @cindex CGI (Common Gateway Interface) cookie support
12215 @cindex Cookie support in CGI
12218 This is a package to interface a GNAT program with a Web server via the
12219 Common Gateway Interface (CGI). It exports services to deal with Web
12220 cookies (piece of information kept in the Web client software).
12222 @node GNAT.CGI.Debug (g-cgideb.ads)
12223 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
12224 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
12225 @cindex CGI (Common Gateway Interface) debugging
12228 This is a package to help debugging CGI (Common Gateway Interface)
12229 programs written in Ada.
12231 @node GNAT.Command_Line (g-comlin.ads)
12232 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
12233 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
12234 @cindex Command line
12237 Provides a high level interface to @code{Ada.Command_Line} facilities,
12238 including the ability to scan for named switches with optional parameters
12239 and expand file names using wild card notations.
12241 @node GNAT.Compiler_Version (g-comver.ads)
12242 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
12243 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
12244 @cindex Compiler Version
12245 @cindex Version, of compiler
12248 Provides a routine for obtaining the version of the compiler used to
12249 compile the program. More accurately this is the version of the binder
12250 used to bind the program (this will normally be the same as the version
12251 of the compiler if a consistent tool set is used to compile all units
12254 @node GNAT.Ctrl_C (g-ctrl_c.ads)
12255 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
12256 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
12260 Provides a simple interface to handle Ctrl-C keyboard events.
12262 @node GNAT.Current_Exception (g-curexc.ads)
12263 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
12264 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
12265 @cindex Current exception
12266 @cindex Exception retrieval
12269 Provides access to information on the current exception that has been raised
12270 without the need for using the Ada-95 exception choice parameter specification
12271 syntax. This is particularly useful in simulating typical facilities for
12272 obtaining information about exceptions provided by Ada 83 compilers.
12274 @node GNAT.Debug_Pools (g-debpoo.ads)
12275 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
12276 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
12278 @cindex Debug pools
12279 @cindex Memory corruption debugging
12282 Provide a debugging storage pools that helps tracking memory corruption
12283 problems. See section ``Finding memory problems with GNAT Debug Pool'' in
12284 the @cite{GNAT User's Guide}.
12286 @node GNAT.Debug_Utilities (g-debuti.ads)
12287 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
12288 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
12292 Provides a few useful utilities for debugging purposes, including conversion
12293 to and from string images of address values. Supports both C and Ada formats
12294 for hexadecimal literals.
12296 @node GNAT.Directory_Operations (g-dirope.ads)
12297 @section @code{GNAT.Directory_Operations} (g-dirope.ads)
12298 @cindex @code{GNAT.Directory_Operations} (g-dirope.ads)
12299 @cindex Directory operations
12302 Provides a set of routines for manipulating directories, including changing
12303 the current directory, making new directories, and scanning the files in a
12306 @node GNAT.Dynamic_HTables (g-dynhta.ads)
12307 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
12308 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
12309 @cindex Hash tables
12312 A generic implementation of hash tables that can be used to hash arbitrary
12313 data. Provided in two forms, a simple form with built in hash functions,
12314 and a more complex form in which the hash function is supplied.
12317 This package provides a facility similar to that of @code{GNAT.HTable},
12318 except that this package declares a type that can be used to define
12319 dynamic instances of the hash table, while an instantiation of
12320 @code{GNAT.HTable} creates a single instance of the hash table.
12322 @node GNAT.Dynamic_Tables (g-dyntab.ads)
12323 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
12324 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
12325 @cindex Table implementation
12326 @cindex Arrays, extendable
12329 A generic package providing a single dimension array abstraction where the
12330 length of the array can be dynamically modified.
12333 This package provides a facility similar to that of @code{GNAT.Table},
12334 except that this package declares a type that can be used to define
12335 dynamic instances of the table, while an instantiation of
12336 @code{GNAT.Table} creates a single instance of the table type.
12338 @node GNAT.Exception_Actions (g-excact.ads)
12339 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
12340 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
12341 @cindex Exception actions
12344 Provides callbacks when an exception is raised. Callbacks can be registered
12345 for specific exceptions, or when any exception is raised. This
12346 can be used for instance to force a core dump to ease debugging.
12348 @node GNAT.Exception_Traces (g-exctra.ads)
12349 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
12350 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
12351 @cindex Exception traces
12355 Provides an interface allowing to control automatic output upon exception
12358 @node GNAT.Exceptions (g-except.ads)
12359 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
12360 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
12361 @cindex Exceptions, Pure
12362 @cindex Pure packages, exceptions
12365 Normally it is not possible to raise an exception with
12366 a message from a subprogram in a pure package, since the
12367 necessary types and subprograms are in @code{Ada.Exceptions}
12368 which is not a pure unit. @code{GNAT.Exceptions} provides a
12369 facility for getting around this limitation for a few
12370 predefined exceptions, and for example allow raising
12371 @code{Constraint_Error} with a message from a pure subprogram.
12373 @node GNAT.Expect (g-expect.ads)
12374 @section @code{GNAT.Expect} (@file{g-expect.ads})
12375 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
12378 Provides a set of subprograms similar to what is available
12379 with the standard Tcl Expect tool.
12380 It allows you to easily spawn and communicate with an external process.
12381 You can send commands or inputs to the process, and compare the output
12382 with some expected regular expression. Currently @code{GNAT.Expect}
12383 is implemented on all native GNAT ports except for OpenVMS@.
12384 It is not implemented for cross ports, and in particular is not
12385 implemented for VxWorks or LynxOS@.
12387 @node GNAT.Float_Control (g-flocon.ads)
12388 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
12389 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
12390 @cindex Floating-Point Processor
12393 Provides an interface for resetting the floating-point processor into the
12394 mode required for correct semantic operation in Ada. Some third party
12395 library calls may cause this mode to be modified, and the Reset procedure
12396 in this package can be used to reestablish the required mode.
12398 @node GNAT.Heap_Sort (g-heasor.ads)
12399 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
12400 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
12404 Provides a general implementation of heap sort usable for sorting arbitrary
12405 data items. Exchange and comparison procedures are provided by passing
12406 access-to-procedure values. The algorithm used is a modified heap sort
12407 that performs approximately N*log(N) comparisons in the worst case.
12409 @node GNAT.Heap_Sort_A (g-hesora.ads)
12410 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
12411 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
12415 Provides a general implementation of heap sort usable for sorting arbitrary
12416 data items. Move and comparison procedures are provided by passing
12417 access-to-procedure values. The algorithm used is a modified heap sort
12418 that performs approximately N*log(N) comparisons in the worst case.
12419 This differs from @code{GNAT.Heap_Sort} in having a less convenient
12420 interface, but may be slightly more efficient.
12422 @node GNAT.Heap_Sort_G (g-hesorg.ads)
12423 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
12424 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
12428 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
12429 are provided as generic parameters, this improves efficiency, especially
12430 if the procedures can be inlined, at the expense of duplicating code for
12431 multiple instantiations.
12433 @node GNAT.HTable (g-htable.ads)
12434 @section @code{GNAT.HTable} (@file{g-htable.ads})
12435 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
12436 @cindex Hash tables
12439 A generic implementation of hash tables that can be used to hash arbitrary
12440 data. Provides two approaches, one a simple static approach, and the other
12441 allowing arbitrary dynamic hash tables.
12443 @node GNAT.IO (g-io.ads)
12444 @section @code{GNAT.IO} (@file{g-io.ads})
12445 @cindex @code{GNAT.IO} (@file{g-io.ads})
12447 @cindex Input/Output facilities
12450 A simple preelaborable input-output package that provides a subset of
12451 simple Text_IO functions for reading characters and strings from
12452 Standard_Input, and writing characters, strings and integers to either
12453 Standard_Output or Standard_Error.
12455 @node GNAT.IO_Aux (g-io_aux.ads)
12456 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12457 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12459 @cindex Input/Output facilities
12461 Provides some auxiliary functions for use with Text_IO, including a test
12462 for whether a file exists, and functions for reading a line of text.
12464 @node GNAT.Lock_Files (g-locfil.ads)
12465 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12466 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12467 @cindex File locking
12468 @cindex Locking using files
12471 Provides a general interface for using files as locks. Can be used for
12472 providing program level synchronization.
12474 @node GNAT.MD5 (g-md5.ads)
12475 @section @code{GNAT.MD5} (@file{g-md5.ads})
12476 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
12477 @cindex Message Digest MD5
12480 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
12482 @node GNAT.Memory_Dump (g-memdum.ads)
12483 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12484 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12485 @cindex Dump Memory
12488 Provides a convenient routine for dumping raw memory to either the
12489 standard output or standard error files. Uses GNAT.IO for actual
12492 @node GNAT.Most_Recent_Exception (g-moreex.ads)
12493 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12494 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12495 @cindex Exception, obtaining most recent
12498 Provides access to the most recently raised exception. Can be used for
12499 various logging purposes, including duplicating functionality of some
12500 Ada 83 implementation dependent extensions.
12502 @node GNAT.OS_Lib (g-os_lib.ads)
12503 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12504 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12505 @cindex Operating System interface
12506 @cindex Spawn capability
12509 Provides a range of target independent operating system interface functions,
12510 including time/date management, file operations, subprocess management,
12511 including a portable spawn procedure, and access to environment variables
12512 and error return codes.
12514 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
12515 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
12516 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
12517 @cindex Hash functions
12520 Provides a generator of static minimal perfect hash functions. No
12521 collisions occur and each item can be retrieved from the table in one
12522 probe (perfect property). The hash table size corresponds to the exact
12523 size of the key set and no larger (minimal property). The key set has to
12524 be know in advance (static property). The hash functions are also order
12525 preserving. If w2 is inserted after w1 in the generator, their
12526 hashcode are in the same order. These hashing functions are very
12527 convenient for use with realtime applications.
12529 @node GNAT.Regexp (g-regexp.ads)
12530 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
12531 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
12532 @cindex Regular expressions
12533 @cindex Pattern matching
12536 A simple implementation of regular expressions, using a subset of regular
12537 expression syntax copied from familiar Unix style utilities. This is the
12538 simples of the three pattern matching packages provided, and is particularly
12539 suitable for ``file globbing'' applications.
12541 @node GNAT.Registry (g-regist.ads)
12542 @section @code{GNAT.Registry} (@file{g-regist.ads})
12543 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
12544 @cindex Windows Registry
12547 This is a high level binding to the Windows registry. It is possible to
12548 do simple things like reading a key value, creating a new key. For full
12549 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
12550 package provided with the Win32Ada binding
12552 @node GNAT.Regpat (g-regpat.ads)
12553 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
12554 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
12555 @cindex Regular expressions
12556 @cindex Pattern matching
12559 A complete implementation of Unix-style regular expression matching, copied
12560 from the original V7 style regular expression library written in C by
12561 Henry Spencer (and binary compatible with this C library).
12563 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
12564 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12565 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12566 @cindex Secondary Stack Info
12569 Provide the capability to query the high water mark of the current task's
12572 @node GNAT.Semaphores (g-semaph.ads)
12573 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
12574 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
12578 Provides classic counting and binary semaphores using protected types.
12580 @node GNAT.Signals (g-signal.ads)
12581 @section @code{GNAT.Signals} (@file{g-signal.ads})
12582 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
12586 Provides the ability to manipulate the blocked status of signals on supported
12589 @node GNAT.Sockets (g-socket.ads)
12590 @section @code{GNAT.Sockets} (@file{g-socket.ads})
12591 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
12595 A high level and portable interface to develop sockets based applications.
12596 This package is based on the sockets thin binding found in
12597 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
12598 on all native GNAT ports except for OpenVMS@. It is not implemented
12599 for the LynxOS@ cross port.
12601 @node GNAT.Source_Info (g-souinf.ads)
12602 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
12603 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
12604 @cindex Source Information
12607 Provides subprograms that give access to source code information known at
12608 compile time, such as the current file name and line number.
12610 @node GNAT.Spell_Checker (g-speche.ads)
12611 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12612 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12613 @cindex Spell checking
12616 Provides a function for determining whether one string is a plausible
12617 near misspelling of another string.
12619 @node GNAT.Spitbol.Patterns (g-spipat.ads)
12620 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12621 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12622 @cindex SPITBOL pattern matching
12623 @cindex Pattern matching
12626 A complete implementation of SNOBOL4 style pattern matching. This is the
12627 most elaborate of the pattern matching packages provided. It fully duplicates
12628 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
12629 efficient algorithm developed by Robert Dewar for the SPITBOL system.
12631 @node GNAT.Spitbol (g-spitbo.ads)
12632 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12633 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12634 @cindex SPITBOL interface
12637 The top level package of the collection of SPITBOL-style functionality, this
12638 package provides basic SNOBOL4 string manipulation functions, such as
12639 Pad, Reverse, Trim, Substr capability, as well as a generic table function
12640 useful for constructing arbitrary mappings from strings in the style of
12641 the SNOBOL4 TABLE function.
12643 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
12644 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12645 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12646 @cindex Sets of strings
12647 @cindex SPITBOL Tables
12650 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12651 for type @code{Standard.Boolean}, giving an implementation of sets of
12654 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
12655 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12656 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12657 @cindex Integer maps
12659 @cindex SPITBOL Tables
12662 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12663 for type @code{Standard.Integer}, giving an implementation of maps
12664 from string to integer values.
12666 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
12667 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12668 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12669 @cindex String maps
12671 @cindex SPITBOL Tables
12674 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
12675 a variable length string type, giving an implementation of general
12676 maps from strings to strings.
12678 @node GNAT.Strings (g-string.ads)
12679 @section @code{GNAT.Strings} (@file{g-string.ads})
12680 @cindex @code{GNAT.Strings} (@file{g-string.ads})
12683 Common String access types and related subprograms. Basically it
12684 defines a string access and an array of string access types.
12686 @node GNAT.String_Split (g-strspl.ads)
12687 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
12688 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
12689 @cindex String splitter
12692 Useful string manipulation routines: given a set of separators, split
12693 a string wherever the separators appear, and provide direct access
12694 to the resulting slices. This package is instantiated from
12695 @code{GNAT.Array_Split}.
12697 @node GNAT.UTF_32 (g-utf_32.ads)
12698 @section @code{GNAT.UTF_32} (@file{g-table.ads})
12699 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
12700 @cindex Wide character codes
12703 This is a package intended to be used in conjunction with the
12704 @code{Wide_Character} type in Ada 95 and the
12705 @code{Wide_Wide_Character} type in Ada 2005 (available
12706 in @code{GNAT} in Ada 2005 mode). This package contains
12707 Unicode categorization routines, as well as lexical
12708 categorization routines corresponding to the Ada 2005
12709 lexical rules for identifiers and strings, and also a
12710 lower case to upper case fold routine corresponding to
12711 the Ada 2005 rules for identifier equivalence.
12713 @node GNAT.Table (g-table.ads)
12714 @section @code{GNAT.Table} (@file{g-table.ads})
12715 @cindex @code{GNAT.Table} (@file{g-table.ads})
12716 @cindex Table implementation
12717 @cindex Arrays, extendable
12720 A generic package providing a single dimension array abstraction where the
12721 length of the array can be dynamically modified.
12724 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
12725 except that this package declares a single instance of the table type,
12726 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
12727 used to define dynamic instances of the table.
12729 @node GNAT.Task_Lock (g-tasloc.ads)
12730 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12731 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12732 @cindex Task synchronization
12733 @cindex Task locking
12737 A very simple facility for locking and unlocking sections of code using a
12738 single global task lock. Appropriate for use in situations where contention
12739 between tasks is very rarely expected.
12741 @node GNAT.Threads (g-thread.ads)
12742 @section @code{GNAT.Threads} (@file{g-thread.ads})
12743 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
12744 @cindex Foreign threads
12745 @cindex Threads, foreign
12748 Provides facilities for creating and destroying threads with explicit calls.
12749 These threads are known to the GNAT run-time system. These subprograms are
12750 exported C-convention procedures intended to be called from foreign code.
12751 By using these primitives rather than directly calling operating systems
12752 routines, compatibility with the Ada tasking run-time is provided.
12754 @node GNAT.Traceback (g-traceb.ads)
12755 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
12756 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
12757 @cindex Trace back facilities
12760 Provides a facility for obtaining non-symbolic traceback information, useful
12761 in various debugging situations.
12763 @node GNAT.Traceback.Symbolic (g-trasym.ads)
12764 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12765 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12766 @cindex Trace back facilities
12769 Provides symbolic traceback information that includes the subprogram
12770 name and line number information.
12772 @node GNAT.Wide_String_Split (g-wistsp.ads)
12773 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12774 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12775 @cindex Wide_String splitter
12778 Useful wide string manipulation routines: given a set of separators, split
12779 a wide string wherever the separators appear, and provide direct access
12780 to the resulting slices. This package is instantiated from
12781 @code{GNAT.Array_Split}.
12783 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
12784 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
12785 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
12786 @cindex Wide_Wide_String splitter
12789 Useful wide wide string manipulation routines: given a set of separators, split
12790 a wide wide string wherever the separators appear, and provide direct access
12791 to the resulting slices. This package is instantiated from
12792 @code{GNAT.Array_Split}.
12794 @node Interfaces.C.Extensions (i-cexten.ads)
12795 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12796 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12799 This package contains additional C-related definitions, intended
12800 for use with either manually or automatically generated bindings
12803 @node Interfaces.C.Streams (i-cstrea.ads)
12804 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12805 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12806 @cindex C streams, interfacing
12809 This package is a binding for the most commonly used operations
12812 @node Interfaces.CPP (i-cpp.ads)
12813 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
12814 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
12815 @cindex C++ interfacing
12816 @cindex Interfacing, to C++
12819 This package provides facilities for use in interfacing to C++. It
12820 is primarily intended to be used in connection with automated tools
12821 for the generation of C++ interfaces.
12823 @node Interfaces.Os2lib (i-os2lib.ads)
12824 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12825 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12826 @cindex Interfacing, to OS/2
12827 @cindex OS/2 interfacing
12830 This package provides interface definitions to the OS/2 library.
12831 It is a thin binding which is a direct translation of the
12832 various @file{<bse@.h>} files.
12834 @node Interfaces.Os2lib.Errors (i-os2err.ads)
12835 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12836 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12837 @cindex OS/2 Error codes
12838 @cindex Interfacing, to OS/2
12839 @cindex OS/2 interfacing
12842 This package provides definitions of the OS/2 error codes.
12844 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
12845 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12846 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12847 @cindex Interfacing, to OS/2
12848 @cindex Synchronization, OS/2
12849 @cindex OS/2 synchronization primitives
12852 This is a child package that provides definitions for interfacing
12853 to the @code{OS/2} synchronization primitives.
12855 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
12856 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12857 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12858 @cindex Interfacing, to OS/2
12859 @cindex Thread control, OS/2
12860 @cindex OS/2 thread interfacing
12863 This is a child package that provides definitions for interfacing
12864 to the @code{OS/2} thread primitives.
12866 @node Interfaces.Packed_Decimal (i-pacdec.ads)
12867 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12868 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12869 @cindex IBM Packed Format
12870 @cindex Packed Decimal
12873 This package provides a set of routines for conversions to and
12874 from a packed decimal format compatible with that used on IBM
12877 @node Interfaces.VxWorks (i-vxwork.ads)
12878 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12879 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12880 @cindex Interfacing to VxWorks
12881 @cindex VxWorks, interfacing
12884 This package provides a limited binding to the VxWorks API.
12885 In particular, it interfaces with the
12886 VxWorks hardware interrupt facilities.
12888 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
12889 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12890 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12891 @cindex Interfacing to VxWorks' I/O
12892 @cindex VxWorks, I/O interfacing
12893 @cindex VxWorks, Get_Immediate
12894 @cindex Get_Immediate, VxWorks
12897 This package provides a binding to the ioctl (IO/Control)
12898 function of VxWorks, defining a set of option values and
12899 function codes. A particular use of this package is
12900 to enable the use of Get_Immediate under VxWorks.
12902 @node System.Address_Image (s-addima.ads)
12903 @section @code{System.Address_Image} (@file{s-addima.ads})
12904 @cindex @code{System.Address_Image} (@file{s-addima.ads})
12905 @cindex Address image
12906 @cindex Image, of an address
12909 This function provides a useful debugging
12910 function that gives an (implementation dependent)
12911 string which identifies an address.
12913 @node System.Assertions (s-assert.ads)
12914 @section @code{System.Assertions} (@file{s-assert.ads})
12915 @cindex @code{System.Assertions} (@file{s-assert.ads})
12917 @cindex Assert_Failure, exception
12920 This package provides the declaration of the exception raised
12921 by an run-time assertion failure, as well as the routine that
12922 is used internally to raise this assertion.
12924 @node System.Memory (s-memory.ads)
12925 @section @code{System.Memory} (@file{s-memory.ads})
12926 @cindex @code{System.Memory} (@file{s-memory.ads})
12927 @cindex Memory allocation
12930 This package provides the interface to the low level routines used
12931 by the generated code for allocation and freeing storage for the
12932 default storage pool (analogous to the C routines malloc and free.
12933 It also provides a reallocation interface analogous to the C routine
12934 realloc. The body of this unit may be modified to provide alternative
12935 allocation mechanisms for the default pool, and in addition, direct
12936 calls to this unit may be made for low level allocation uses (for
12937 example see the body of @code{GNAT.Tables}).
12939 @node System.Partition_Interface (s-parint.ads)
12940 @section @code{System.Partition_Interface} (@file{s-parint.ads})
12941 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
12942 @cindex Partition interfacing functions
12945 This package provides facilities for partition interfacing. It
12946 is used primarily in a distribution context when using Annex E
12949 @node System.Restrictions (s-restri.ads)
12950 @section @code{System.Restrictions} (@file{s-restri.ads})
12951 @cindex @code{System.Restrictions} (@file{s-restri.ads})
12952 @cindex Run-time restrictions access
12955 This package provides facilities for accessing at run-time
12956 the status of restrictions specified at compile time for
12957 the partition. Information is available both with regard
12958 to actual restrictions specified, and with regard to
12959 compiler determined information on which restrictions
12960 are violated by one or more packages in the partition.
12962 @node System.Rident (s-rident.ads)
12963 @section @code{System.Rident} (@file{s-rident.ads})
12964 @cindex @code{System.Rident} (@file{s-rident.ads})
12965 @cindex Restrictions definitions
12968 This package provides definitions of the restrictions
12969 identifiers supported by GNAT, and also the format of
12970 the restrictions provided in package System.Restrictions.
12971 It is not normally necessary to @code{with} this generic package
12972 since the necessary instantiation is included in
12973 package System.Restrictions.
12975 @node System.Task_Info (s-tasinf.ads)
12976 @section @code{System.Task_Info} (@file{s-tasinf.ads})
12977 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
12978 @cindex Task_Info pragma
12981 This package provides target dependent functionality that is used
12982 to support the @code{Task_Info} pragma
12984 @node System.Wch_Cnv (s-wchcnv.ads)
12985 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12986 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12987 @cindex Wide Character, Representation
12988 @cindex Wide String, Conversion
12989 @cindex Representation of wide characters
12992 This package provides routines for converting between
12993 wide and wide wide characters and a representation as a value of type
12994 @code{Standard.String}, using a specified wide character
12995 encoding method. It uses definitions in
12996 package @code{System.Wch_Con}.
12998 @node System.Wch_Con (s-wchcon.ads)
12999 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
13000 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
13003 This package provides definitions and descriptions of
13004 the various methods used for encoding wide characters
13005 in ordinary strings. These definitions are used by
13006 the package @code{System.Wch_Cnv}.
13008 @node Interfacing to Other Languages
13009 @chapter Interfacing to Other Languages
13011 The facilities in annex B of the Ada 95 Reference Manual are fully
13012 implemented in GNAT, and in addition, a full interface to C++ is
13016 * Interfacing to C::
13017 * Interfacing to C++::
13018 * Interfacing to COBOL::
13019 * Interfacing to Fortran::
13020 * Interfacing to non-GNAT Ada code::
13023 @node Interfacing to C
13024 @section Interfacing to C
13027 Interfacing to C with GNAT can use one of two approaches:
13031 The types in the package @code{Interfaces.C} may be used.
13033 Standard Ada types may be used directly. This may be less portable to
13034 other compilers, but will work on all GNAT compilers, which guarantee
13035 correspondence between the C and Ada types.
13039 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
13040 effect, since this is the default. The following table shows the
13041 correspondence between Ada scalar types and the corresponding C types.
13046 @item Short_Integer
13048 @item Short_Short_Integer
13052 @item Long_Long_Integer
13060 @item Long_Long_Float
13061 This is the longest floating-point type supported by the hardware.
13065 Additionally, there are the following general correspondences between Ada
13069 Ada enumeration types map to C enumeration types directly if pragma
13070 @code{Convention C} is specified, which causes them to have int
13071 length. Without pragma @code{Convention C}, Ada enumeration types map to
13072 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
13073 @code{int}, respectively) depending on the number of values passed.
13074 This is the only case in which pragma @code{Convention C} affects the
13075 representation of an Ada type.
13078 Ada access types map to C pointers, except for the case of pointers to
13079 unconstrained types in Ada, which have no direct C equivalent.
13082 Ada arrays map directly to C arrays.
13085 Ada records map directly to C structures.
13088 Packed Ada records map to C structures where all members are bit fields
13089 of the length corresponding to the @code{@var{type}'Size} value in Ada.
13092 @node Interfacing to C++
13093 @section Interfacing to C++
13096 The interface to C++ makes use of the following pragmas, which are
13097 primarily intended to be constructed automatically using a binding generator
13098 tool, although it is possible to construct them by hand. No suitable binding
13099 generator tool is supplied with GNAT though.
13101 Using these pragmas it is possible to achieve complete
13102 inter-operability between Ada tagged types and C class definitions.
13103 See @ref{Implementation Defined Pragmas}, for more details.
13106 @item pragma CPP_Class ([Entity =>] @var{local_name})
13107 The argument denotes an entity in the current declarative region that is
13108 declared as a tagged or untagged record type. It indicates that the type
13109 corresponds to an externally declared C++ class type, and is to be laid
13110 out the same way that C++ would lay out the type.
13112 @item pragma CPP_Constructor ([Entity =>] @var{local_name})
13113 This pragma identifies an imported function (imported in the usual way
13114 with pragma @code{Import}) as corresponding to a C++ constructor.
13116 @item pragma CPP_Vtable @dots{}
13117 One @code{CPP_Vtable} pragma can be present for each component of type
13118 @code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
13122 @node Interfacing to COBOL
13123 @section Interfacing to COBOL
13126 Interfacing to COBOL is achieved as described in section B.4 of
13127 the Ada 95 reference manual.
13129 @node Interfacing to Fortran
13130 @section Interfacing to Fortran
13133 Interfacing to Fortran is achieved as described in section B.5 of the
13134 reference manual. The pragma @code{Convention Fortran}, applied to a
13135 multi-dimensional array causes the array to be stored in column-major
13136 order as required for convenient interface to Fortran.
13138 @node Interfacing to non-GNAT Ada code
13139 @section Interfacing to non-GNAT Ada code
13141 It is possible to specify the convention @code{Ada} in a pragma
13142 @code{Import} or pragma @code{Export}. However this refers to
13143 the calling conventions used by GNAT, which may or may not be
13144 similar enough to those used by some other Ada 83 or Ada 95
13145 compiler to allow interoperation.
13147 If arguments types are kept simple, and if the foreign compiler generally
13148 follows system calling conventions, then it may be possible to integrate
13149 files compiled by other Ada compilers, provided that the elaboration
13150 issues are adequately addressed (for example by eliminating the
13151 need for any load time elaboration).
13153 In particular, GNAT running on VMS is designed to
13154 be highly compatible with the DEC Ada 83 compiler, so this is one
13155 case in which it is possible to import foreign units of this type,
13156 provided that the data items passed are restricted to simple scalar
13157 values or simple record types without variants, or simple array
13158 types with fixed bounds.
13160 @node Specialized Needs Annexes
13161 @chapter Specialized Needs Annexes
13164 Ada 95 defines a number of specialized needs annexes, which are not
13165 required in all implementations. However, as described in this chapter,
13166 GNAT implements all of these special needs annexes:
13169 @item Systems Programming (Annex C)
13170 The Systems Programming Annex is fully implemented.
13172 @item Real-Time Systems (Annex D)
13173 The Real-Time Systems Annex is fully implemented.
13175 @item Distributed Systems (Annex E)
13176 Stub generation is fully implemented in the GNAT compiler. In addition,
13177 a complete compatible PCS is available as part of the GLADE system,
13178 a separate product. When the two
13179 products are used in conjunction, this annex is fully implemented.
13181 @item Information Systems (Annex F)
13182 The Information Systems annex is fully implemented.
13184 @item Numerics (Annex G)
13185 The Numerics Annex is fully implemented.
13187 @item Safety and Security (Annex H)
13188 The Safety and Security annex is fully implemented.
13191 @node Implementation of Specific Ada Features
13192 @chapter Implementation of Specific Ada Features
13195 This chapter describes the GNAT implementation of several Ada language
13199 * Machine Code Insertions::
13200 * GNAT Implementation of Tasking::
13201 * GNAT Implementation of Shared Passive Packages::
13202 * Code Generation for Array Aggregates::
13203 * The Size of Discriminated Records with Default Discriminants::
13206 @node Machine Code Insertions
13207 @section Machine Code Insertions
13210 Package @code{Machine_Code} provides machine code support as described
13211 in the Ada 95 Reference Manual in two separate forms:
13214 Machine code statements, consisting of qualified expressions that
13215 fit the requirements of RM section 13.8.
13217 An intrinsic callable procedure, providing an alternative mechanism of
13218 including machine instructions in a subprogram.
13222 The two features are similar, and both are closely related to the mechanism
13223 provided by the asm instruction in the GNU C compiler. Full understanding
13224 and use of the facilities in this package requires understanding the asm
13225 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
13226 by Richard Stallman. The relevant section is titled ``Extensions to the C
13227 Language Family'' -> ``Assembler Instructions with C Expression Operands''.
13229 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
13230 semantic restrictions and effects as described below. Both are provided so
13231 that the procedure call can be used as a statement, and the function call
13232 can be used to form a code_statement.
13234 The first example given in the GCC documentation is the C @code{asm}
13237 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
13241 The equivalent can be written for GNAT as:
13243 @smallexample @c ada
13244 Asm ("fsinx %1 %0",
13245 My_Float'Asm_Output ("=f", result),
13246 My_Float'Asm_Input ("f", angle));
13250 The first argument to @code{Asm} is the assembler template, and is
13251 identical to what is used in GNU C@. This string must be a static
13252 expression. The second argument is the output operand list. It is
13253 either a single @code{Asm_Output} attribute reference, or a list of such
13254 references enclosed in parentheses (technically an array aggregate of
13257 The @code{Asm_Output} attribute denotes a function that takes two
13258 parameters. The first is a string, the second is the name of a variable
13259 of the type designated by the attribute prefix. The first (string)
13260 argument is required to be a static expression and designates the
13261 constraint for the parameter (e.g.@: what kind of register is
13262 required). The second argument is the variable to be updated with the
13263 result. The possible values for constraint are the same as those used in
13264 the RTL, and are dependent on the configuration file used to build the
13265 GCC back end. If there are no output operands, then this argument may
13266 either be omitted, or explicitly given as @code{No_Output_Operands}.
13268 The second argument of @code{@var{my_float}'Asm_Output} functions as
13269 though it were an @code{out} parameter, which is a little curious, but
13270 all names have the form of expressions, so there is no syntactic
13271 irregularity, even though normally functions would not be permitted
13272 @code{out} parameters. The third argument is the list of input
13273 operands. It is either a single @code{Asm_Input} attribute reference, or
13274 a list of such references enclosed in parentheses (technically an array
13275 aggregate of such references).
13277 The @code{Asm_Input} attribute denotes a function that takes two
13278 parameters. The first is a string, the second is an expression of the
13279 type designated by the prefix. The first (string) argument is required
13280 to be a static expression, and is the constraint for the parameter,
13281 (e.g.@: what kind of register is required). The second argument is the
13282 value to be used as the input argument. The possible values for the
13283 constant are the same as those used in the RTL, and are dependent on
13284 the configuration file used to built the GCC back end.
13286 If there are no input operands, this argument may either be omitted, or
13287 explicitly given as @code{No_Input_Operands}. The fourth argument, not
13288 present in the above example, is a list of register names, called the
13289 @dfn{clobber} argument. This argument, if given, must be a static string
13290 expression, and is a space or comma separated list of names of registers
13291 that must be considered destroyed as a result of the @code{Asm} call. If
13292 this argument is the null string (the default value), then the code
13293 generator assumes that no additional registers are destroyed.
13295 The fifth argument, not present in the above example, called the
13296 @dfn{volatile} argument, is by default @code{False}. It can be set to
13297 the literal value @code{True} to indicate to the code generator that all
13298 optimizations with respect to the instruction specified should be
13299 suppressed, and that in particular, for an instruction that has outputs,
13300 the instruction will still be generated, even if none of the outputs are
13301 used. See the full description in the GCC manual for further details.
13303 The @code{Asm} subprograms may be used in two ways. First the procedure
13304 forms can be used anywhere a procedure call would be valid, and
13305 correspond to what the RM calls ``intrinsic'' routines. Such calls can
13306 be used to intersperse machine instructions with other Ada statements.
13307 Second, the function forms, which return a dummy value of the limited
13308 private type @code{Asm_Insn}, can be used in code statements, and indeed
13309 this is the only context where such calls are allowed. Code statements
13310 appear as aggregates of the form:
13312 @smallexample @c ada
13313 Asm_Insn'(Asm (@dots{}));
13314 Asm_Insn'(Asm_Volatile (@dots{}));
13318 In accordance with RM rules, such code statements are allowed only
13319 within subprograms whose entire body consists of such statements. It is
13320 not permissible to intermix such statements with other Ada statements.
13322 Typically the form using intrinsic procedure calls is more convenient
13323 and more flexible. The code statement form is provided to meet the RM
13324 suggestion that such a facility should be made available. The following
13325 is the exact syntax of the call to @code{Asm}. As usual, if named notation
13326 is used, the arguments may be given in arbitrary order, following the
13327 normal rules for use of positional and named arguments)
13331 [Template =>] static_string_EXPRESSION
13332 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
13333 [,[Inputs =>] INPUT_OPERAND_LIST ]
13334 [,[Clobber =>] static_string_EXPRESSION ]
13335 [,[Volatile =>] static_boolean_EXPRESSION] )
13337 OUTPUT_OPERAND_LIST ::=
13338 [PREFIX.]No_Output_Operands
13339 | OUTPUT_OPERAND_ATTRIBUTE
13340 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
13342 OUTPUT_OPERAND_ATTRIBUTE ::=
13343 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
13345 INPUT_OPERAND_LIST ::=
13346 [PREFIX.]No_Input_Operands
13347 | INPUT_OPERAND_ATTRIBUTE
13348 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
13350 INPUT_OPERAND_ATTRIBUTE ::=
13351 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
13355 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
13356 are declared in the package @code{Machine_Code} and must be referenced
13357 according to normal visibility rules. In particular if there is no
13358 @code{use} clause for this package, then appropriate package name
13359 qualification is required.
13361 @node GNAT Implementation of Tasking
13362 @section GNAT Implementation of Tasking
13365 This chapter outlines the basic GNAT approach to tasking (in particular,
13366 a multi-layered library for portability) and discusses issues related
13367 to compliance with the Real-Time Systems Annex.
13370 * Mapping Ada Tasks onto the Underlying Kernel Threads::
13371 * Ensuring Compliance with the Real-Time Annex::
13374 @node Mapping Ada Tasks onto the Underlying Kernel Threads
13375 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
13378 GNAT's run-time support comprises two layers:
13381 @item GNARL (GNAT Run-time Layer)
13382 @item GNULL (GNAT Low-level Library)
13386 In GNAT, Ada's tasking services rely on a platform and OS independent
13387 layer known as GNARL@. This code is responsible for implementing the
13388 correct semantics of Ada's task creation, rendezvous, protected
13391 GNARL decomposes Ada's tasking semantics into simpler lower level
13392 operations such as create a thread, set the priority of a thread,
13393 yield, create a lock, lock/unlock, etc. The spec for these low-level
13394 operations constitutes GNULLI, the GNULL Interface. This interface is
13395 directly inspired from the POSIX real-time API@.
13397 If the underlying executive or OS implements the POSIX standard
13398 faithfully, the GNULL Interface maps as is to the services offered by
13399 the underlying kernel. Otherwise, some target dependent glue code maps
13400 the services offered by the underlying kernel to the semantics expected
13403 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
13404 key point is that each Ada task is mapped on a thread in the underlying
13405 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
13407 In addition Ada task priorities map onto the underlying thread priorities.
13408 Mapping Ada tasks onto the underlying kernel threads has several advantages:
13412 The underlying scheduler is used to schedule the Ada tasks. This
13413 makes Ada tasks as efficient as kernel threads from a scheduling
13417 Interaction with code written in C containing threads is eased
13418 since at the lowest level Ada tasks and C threads map onto the same
13419 underlying kernel concept.
13422 When an Ada task is blocked during I/O the remaining Ada tasks are
13426 On multiprocessor systems Ada tasks can execute in parallel.
13430 Some threads libraries offer a mechanism to fork a new process, with the
13431 child process duplicating the threads from the parent.
13433 support this functionality when the parent contains more than one task.
13434 @cindex Forking a new process
13436 @node Ensuring Compliance with the Real-Time Annex
13437 @subsection Ensuring Compliance with the Real-Time Annex
13438 @cindex Real-Time Systems Annex compliance
13441 Although mapping Ada tasks onto
13442 the underlying threads has significant advantages, it does create some
13443 complications when it comes to respecting the scheduling semantics
13444 specified in the real-time annex (Annex D).
13446 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
13447 scheduling policy states:
13450 @emph{When the active priority of a ready task that is not running
13451 changes, or the setting of its base priority takes effect, the
13452 task is removed from the ready queue for its old active priority
13453 and is added at the tail of the ready queue for its new active
13454 priority, except in the case where the active priority is lowered
13455 due to the loss of inherited priority, in which case the task is
13456 added at the head of the ready queue for its new active priority.}
13460 While most kernels do put tasks at the end of the priority queue when
13461 a task changes its priority, (which respects the main
13462 FIFO_Within_Priorities requirement), almost none keep a thread at the
13463 beginning of its priority queue when its priority drops from the loss
13464 of inherited priority.
13466 As a result most vendors have provided incomplete Annex D implementations.
13468 The GNAT run-time, has a nice cooperative solution to this problem
13469 which ensures that accurate FIFO_Within_Priorities semantics are
13472 The principle is as follows. When an Ada task T is about to start
13473 running, it checks whether some other Ada task R with the same
13474 priority as T has been suspended due to the loss of priority
13475 inheritance. If this is the case, T yields and is placed at the end of
13476 its priority queue. When R arrives at the front of the queue it
13479 Note that this simple scheme preserves the relative order of the tasks
13480 that were ready to execute in the priority queue where R has been
13483 @node GNAT Implementation of Shared Passive Packages
13484 @section GNAT Implementation of Shared Passive Packages
13485 @cindex Shared passive packages
13488 GNAT fully implements the pragma @code{Shared_Passive} for
13489 @cindex pragma @code{Shared_Passive}
13490 the purpose of designating shared passive packages.
13491 This allows the use of passive partitions in the
13492 context described in the Ada Reference Manual; i.e. for communication
13493 between separate partitions of a distributed application using the
13494 features in Annex E.
13496 @cindex Distribution Systems Annex
13498 However, the implementation approach used by GNAT provides for more
13499 extensive usage as follows:
13502 @item Communication between separate programs
13504 This allows separate programs to access the data in passive
13505 partitions, using protected objects for synchronization where
13506 needed. The only requirement is that the two programs have a
13507 common shared file system. It is even possible for programs
13508 running on different machines with different architectures
13509 (e.g. different endianness) to communicate via the data in
13510 a passive partition.
13512 @item Persistence between program runs
13514 The data in a passive package can persist from one run of a
13515 program to another, so that a later program sees the final
13516 values stored by a previous run of the same program.
13521 The implementation approach used is to store the data in files. A
13522 separate stream file is created for each object in the package, and
13523 an access to an object causes the corresponding file to be read or
13526 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
13527 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
13528 set to the directory to be used for these files.
13529 The files in this directory
13530 have names that correspond to their fully qualified names. For
13531 example, if we have the package
13533 @smallexample @c ada
13535 pragma Shared_Passive (X);
13542 and the environment variable is set to @code{/stemp/}, then the files created
13543 will have the names:
13551 These files are created when a value is initially written to the object, and
13552 the files are retained until manually deleted. This provides the persistence
13553 semantics. If no file exists, it means that no partition has assigned a value
13554 to the variable; in this case the initial value declared in the package
13555 will be used. This model ensures that there are no issues in synchronizing
13556 the elaboration process, since elaboration of passive packages elaborates the
13557 initial values, but does not create the files.
13559 The files are written using normal @code{Stream_IO} access.
13560 If you want to be able
13561 to communicate between programs or partitions running on different
13562 architectures, then you should use the XDR versions of the stream attribute
13563 routines, since these are architecture independent.
13565 If active synchronization is required for access to the variables in the
13566 shared passive package, then as described in the Ada Reference Manual, the
13567 package may contain protected objects used for this purpose. In this case
13568 a lock file (whose name is @file{___lock} (three underscores)
13569 is created in the shared memory directory.
13570 @cindex @file{___lock} file (for shared passive packages)
13571 This is used to provide the required locking
13572 semantics for proper protected object synchronization.
13574 As of January 2003, GNAT supports shared passive packages on all platforms
13575 except for OpenVMS.
13577 @node Code Generation for Array Aggregates
13578 @section Code Generation for Array Aggregates
13581 * Static constant aggregates with static bounds::
13582 * Constant aggregates with an unconstrained nominal types::
13583 * Aggregates with static bounds::
13584 * Aggregates with non-static bounds::
13585 * Aggregates in assignment statements::
13589 Aggregate have a rich syntax and allow the user to specify the values of
13590 complex data structures by means of a single construct. As a result, the
13591 code generated for aggregates can be quite complex and involve loops, case
13592 statements and multiple assignments. In the simplest cases, however, the
13593 compiler will recognize aggregates whose components and constraints are
13594 fully static, and in those cases the compiler will generate little or no
13595 executable code. The following is an outline of the code that GNAT generates
13596 for various aggregate constructs. For further details, the user will find it
13597 useful to examine the output produced by the -gnatG flag to see the expanded
13598 source that is input to the code generator. The user will also want to examine
13599 the assembly code generated at various levels of optimization.
13601 The code generated for aggregates depends on the context, the component values,
13602 and the type. In the context of an object declaration the code generated is
13603 generally simpler than in the case of an assignment. As a general rule, static
13604 component values and static subtypes also lead to simpler code.
13606 @node Static constant aggregates with static bounds
13607 @subsection Static constant aggregates with static bounds
13610 For the declarations:
13611 @smallexample @c ada
13612 type One_Dim is array (1..10) of integer;
13613 ar0 : constant One_Dim := ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
13617 GNAT generates no executable code: the constant ar0 is placed in static memory.
13618 The same is true for constant aggregates with named associations:
13620 @smallexample @c ada
13621 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1=> 1);
13622 Cr3 : constant One_Dim := (others => 7777);
13626 The same is true for multidimensional constant arrays such as:
13628 @smallexample @c ada
13629 type two_dim is array (1..3, 1..3) of integer;
13630 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
13634 The same is true for arrays of one-dimensional arrays: the following are
13637 @smallexample @c ada
13638 type ar1b is array (1..3) of boolean;
13639 type ar_ar is array (1..3) of ar1b;
13640 None : constant ar1b := (others => false); -- fully static
13641 None2 : constant ar_ar := (1..3 => None); -- fully static
13645 However, for multidimensional aggregates with named associations, GNAT will
13646 generate assignments and loops, even if all associations are static. The
13647 following two declarations generate a loop for the first dimension, and
13648 individual component assignments for the second dimension:
13650 @smallexample @c ada
13651 Zero1: constant two_dim := (1..3 => (1..3 => 0));
13652 Zero2: constant two_dim := (others => (others => 0));
13655 @node Constant aggregates with an unconstrained nominal types
13656 @subsection Constant aggregates with an unconstrained nominal types
13659 In such cases the aggregate itself establishes the subtype, so that
13660 associations with @code{others} cannot be used. GNAT determines the
13661 bounds for the actual subtype of the aggregate, and allocates the
13662 aggregate statically as well. No code is generated for the following:
13664 @smallexample @c ada
13665 type One_Unc is array (natural range <>) of integer;
13666 Cr_Unc : constant One_Unc := (12,24,36);
13669 @node Aggregates with static bounds
13670 @subsection Aggregates with static bounds
13673 In all previous examples the aggregate was the initial (and immutable) value
13674 of a constant. If the aggregate initializes a variable, then code is generated
13675 for it as a combination of individual assignments and loops over the target
13676 object. The declarations
13678 @smallexample @c ada
13679 Cr_Var1 : One_Dim := (2, 5, 7, 11);
13680 Cr_Var2 : One_Dim := (others > -1);
13684 generate the equivalent of
13686 @smallexample @c ada
13692 for I in Cr_Var2'range loop
13693 Cr_Var2 (I) := =-1;
13697 @node Aggregates with non-static bounds
13698 @subsection Aggregates with non-static bounds
13701 If the bounds of the aggregate are not statically compatible with the bounds
13702 of the nominal subtype of the target, then constraint checks have to be
13703 generated on the bounds. For a multidimensional array, constraint checks may
13704 have to be applied to sub-arrays individually, if they do not have statically
13705 compatible subtypes.
13707 @node Aggregates in assignment statements
13708 @subsection Aggregates in assignment statements
13711 In general, aggregate assignment requires the construction of a temporary,
13712 and a copy from the temporary to the target of the assignment. This is because
13713 it is not always possible to convert the assignment into a series of individual
13714 component assignments. For example, consider the simple case:
13716 @smallexample @c ada
13721 This cannot be converted into:
13723 @smallexample @c ada
13729 So the aggregate has to be built first in a separate location, and then
13730 copied into the target. GNAT recognizes simple cases where this intermediate
13731 step is not required, and the assignments can be performed in place, directly
13732 into the target. The following sufficient criteria are applied:
13736 The bounds of the aggregate are static, and the associations are static.
13738 The components of the aggregate are static constants, names of
13739 simple variables that are not renamings, or expressions not involving
13740 indexed components whose operands obey these rules.
13744 If any of these conditions are violated, the aggregate will be built in
13745 a temporary (created either by the front-end or the code generator) and then
13746 that temporary will be copied onto the target.
13749 @node The Size of Discriminated Records with Default Discriminants
13750 @section The Size of Discriminated Records with Default Discriminants
13753 If a discriminated type @code{T} has discriminants with default values, it is
13754 possible to declare an object of this type without providing an explicit
13757 @smallexample @c ada
13759 type Size is range 1..100;
13761 type Rec (D : Size := 15) is record
13762 Name : String (1..D);
13770 Such an object is said to be @emph{unconstrained}.
13771 The discriminant of the object
13772 can be modified by a full assignment to the object, as long as it preserves the
13773 relation between the value of the discriminant, and the value of the components
13776 @smallexample @c ada
13778 Word := (3, "yes");
13780 Word := (5, "maybe");
13782 Word := (5, "no"); -- raises Constraint_Error
13787 In order to support this behavior efficiently, an unconstrained object is
13788 given the maximum size that any value of the type requires. In the case
13789 above, @code{Word} has storage for the discriminant and for
13790 a @code{String} of length 100.
13791 It is important to note that unconstrained objects do not require dynamic
13792 allocation. It would be an improper implementation to place on the heap those
13793 components whose size depends on discriminants. (This improper implementation
13794 was used by some Ada83 compilers, where the @code{Name} component above
13796 been stored as a pointer to a dynamic string). Following the principle that
13797 dynamic storage management should never be introduced implicitly,
13798 an Ada95 compiler should reserve the full size for an unconstrained declared
13799 object, and place it on the stack.
13801 This maximum size approach
13802 has been a source of surprise to some users, who expect the default
13803 values of the discriminants to determine the size reserved for an
13804 unconstrained object: ``If the default is 15, why should the object occupy
13806 The answer, of course, is that the discriminant may be later modified,
13807 and its full range of values must be taken into account. This is why the
13812 type Rec (D : Positive := 15) is record
13813 Name : String (1..D);
13821 is flagged by the compiler with a warning:
13822 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
13823 because the required size includes @code{Positive'Last}
13824 bytes. As the first example indicates, the proper approach is to declare an
13825 index type of ``reasonable'' range so that unconstrained objects are not too
13828 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
13829 created in the heap by means of an allocator, then it is @emph{not}
13831 it is constrained by the default values of the discriminants, and those values
13832 cannot be modified by full assignment. This is because in the presence of
13833 aliasing all views of the object (which may be manipulated by different tasks,
13834 say) must be consistent, so it is imperative that the object, once created,
13840 @node Project File Reference
13841 @chapter Project File Reference
13844 This chapter describes the syntax and semantics of project files.
13845 Project files specify the options to be used when building a system.
13846 Project files can specify global settings for all tools,
13847 as well as tool-specific settings.
13848 See the chapter on project files in the GNAT Users guide for examples of use.
13852 * Lexical Elements::
13854 * Empty declarations::
13855 * Typed string declarations::
13859 * Project Attributes::
13860 * Attribute References::
13861 * External Values::
13862 * Case Construction::
13864 * Package Renamings::
13866 * Project Extensions::
13867 * Project File Elaboration::
13870 @node Reserved Words
13871 @section Reserved Words
13874 All Ada95 reserved words are reserved in project files, and cannot be used
13875 as variable names or project names. In addition, the following are
13876 also reserved in project files:
13879 @item @code{extends}
13881 @item @code{external}
13883 @item @code{project}
13887 @node Lexical Elements
13888 @section Lexical Elements
13891 Rules for identifiers are the same as in Ada95. Identifiers
13892 are case-insensitive. Strings are case sensitive, except where noted.
13893 Comments have the same form as in Ada95.
13903 simple_name @{. simple_name@}
13907 @section Declarations
13910 Declarations introduce new entities that denote types, variables, attributes,
13911 and packages. Some declarations can only appear immediately within a project
13912 declaration. Others can appear within a project or within a package.
13916 declarative_item ::=
13917 simple_declarative_item |
13918 typed_string_declaration |
13919 package_declaration
13921 simple_declarative_item ::=
13922 variable_declaration |
13923 typed_variable_declaration |
13924 attribute_declaration |
13925 case_construction |
13929 @node Empty declarations
13930 @section Empty declarations
13933 empty_declaration ::=
13937 An empty declaration is allowed anywhere a declaration is allowed.
13940 @node Typed string declarations
13941 @section Typed string declarations
13944 Typed strings are sequences of string literals. Typed strings are the only
13945 named types in project files. They are used in case constructions, where they
13946 provide support for conditional attribute definitions.
13950 typed_string_declaration ::=
13951 @b{type} <typed_string_>_simple_name @b{is}
13952 ( string_literal @{, string_literal@} );
13956 A typed string declaration can only appear immediately within a project
13959 All the string literals in a typed string declaration must be distinct.
13965 Variables denote values, and appear as constituents of expressions.
13968 typed_variable_declaration ::=
13969 <typed_variable_>simple_name : <typed_string_>name := string_expression ;
13971 variable_declaration ::=
13972 <variable_>simple_name := expression;
13976 The elaboration of a variable declaration introduces the variable and
13977 assigns to it the value of the expression. The name of the variable is
13978 available after the assignment symbol.
13981 A typed_variable can only be declare once.
13984 a non typed variable can be declared multiple times.
13987 Before the completion of its first declaration, the value of variable
13988 is the null string.
13991 @section Expressions
13994 An expression is a formula that defines a computation or retrieval of a value.
13995 In a project file the value of an expression is either a string or a list
13996 of strings. A string value in an expression is either a literal, the current
13997 value of a variable, an external value, an attribute reference, or a
13998 concatenation operation.
14011 attribute_reference
14017 ( <string_>expression @{ , <string_>expression @} )
14020 @subsection Concatenation
14022 The following concatenation functions are defined:
14024 @smallexample @c ada
14025 function "&" (X : String; Y : String) return String;
14026 function "&" (X : String_List; Y : String) return String_List;
14027 function "&" (X : String_List; Y : String_List) return String_List;
14031 @section Attributes
14034 An attribute declaration defines a property of a project or package. This
14035 property can later be queried by means of an attribute reference.
14036 Attribute values are strings or string lists.
14038 Some attributes are associative arrays. These attributes are mappings whose
14039 domain is a set of strings. These attributes are declared one association
14040 at a time, by specifying a point in the domain and the corresponding image
14041 of the attribute. They may also be declared as a full associative array,
14042 getting the same associations as the corresponding attribute in an imported
14043 or extended project.
14045 Attributes that are not associative arrays are called simple attributes.
14049 attribute_declaration ::=
14050 full_associative_array_declaration |
14051 @b{for} attribute_designator @b{use} expression ;
14053 full_associative_array_declaration ::=
14054 @b{for} <associative_array_attribute_>simple_name @b{use}
14055 <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
14057 attribute_designator ::=
14058 <simple_attribute_>simple_name |
14059 <associative_array_attribute_>simple_name ( string_literal )
14063 Some attributes are project-specific, and can only appear immediately within
14064 a project declaration. Others are package-specific, and can only appear within
14065 the proper package.
14067 The expression in an attribute definition must be a string or a string_list.
14068 The string literal appearing in the attribute_designator of an associative
14069 array attribute is case-insensitive.
14071 @node Project Attributes
14072 @section Project Attributes
14075 The following attributes apply to a project. All of them are simple
14080 Expression must be a path name. The attribute defines the
14081 directory in which the object files created by the build are to be placed. If
14082 not specified, object files are placed in the project directory.
14085 Expression must be a path name. The attribute defines the
14086 directory in which the executables created by the build are to be placed.
14087 If not specified, executables are placed in the object directory.
14090 Expression must be a list of path names. The attribute
14091 defines the directories in which the source files for the project are to be
14092 found. If not specified, source files are found in the project directory.
14095 Expression must be a list of file names. The attribute
14096 defines the individual files, in the project directory, which are to be used
14097 as sources for the project. File names are path_names that contain no directory
14098 information. If the project has no sources the attribute must be declared
14099 explicitly with an empty list.
14101 @item Source_List_File
14102 Expression must a single path name. The attribute
14103 defines a text file that contains a list of source file names to be used
14104 as sources for the project
14107 Expression must be a path name. The attribute defines the
14108 directory in which a library is to be built. The directory must exist, must
14109 be distinct from the project's object directory, and must be writable.
14112 Expression must be a string that is a legal file name,
14113 without extension. The attribute defines a string that is used to generate
14114 the name of the library to be built by the project.
14117 Argument must be a string value that must be one of the
14118 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
14119 string is case-insensitive. If this attribute is not specified, the library is
14120 a static library. Otherwise, the library may be dynamic or relocatable. This
14121 distinction is operating-system dependent.
14123 @item Library_Version
14124 Expression must be a string value whose interpretation
14125 is platform dependent. On UNIX, it is used only for dynamic/relocatable
14126 libraries as the internal name of the library (the @code{"soname"}). If the
14127 library file name (built from the @code{Library_Name}) is different from the
14128 @code{Library_Version}, then the library file will be a symbolic link to the
14129 actual file whose name will be @code{Library_Version}.
14131 @item Library_Interface
14132 Expression must be a string list. Each element of the string list
14133 must designate a unit of the project.
14134 If this attribute is present in a Library Project File, then the project
14135 file is a Stand-alone Library_Project_File.
14137 @item Library_Auto_Init
14138 Expression must be a single string "true" or "false", case-insensitive.
14139 If this attribute is present in a Stand-alone Library Project File,
14140 it indicates if initialization is automatic when the dynamic library
14143 @item Library_Options
14144 Expression must be a string list. Indicates additional switches that
14145 are to be used when building a shared library.
14148 Expression must be a single string. Designates an alternative to "gcc"
14149 for building shared libraries.
14151 @item Library_Src_Dir
14152 Expression must be a path name. The attribute defines the
14153 directory in which the sources of the interfaces of a Stand-alone Library will
14154 be copied. The directory must exist, must be distinct from the project's
14155 object directory and source directories, and must be writable.
14158 Expression must be a list of strings that are legal file names.
14159 These file names designate existing compilation units in the source directory
14160 that are legal main subprograms.
14162 When a project file is elaborated, as part of the execution of a gnatmake
14163 command, one or several executables are built and placed in the Exec_Dir.
14164 If the gnatmake command does not include explicit file names, the executables
14165 that are built correspond to the files specified by this attribute.
14167 @item Main_Language
14168 This is a simple attribute. Its value is a string that specifies the
14169 language of the main program.
14172 Expression must be a string list. Each string designates
14173 a programming language that is known to GNAT. The strings are case-insensitive.
14175 @item Locally_Removed_Files
14176 This attribute is legal only in a project file that extends another.
14177 Expression must be a list of strings that are legal file names.
14178 Each file name must designate a source that would normally be inherited
14179 by the current project file. It cannot designate an immediate source that is
14180 not inherited. Each of the source files in the list are not considered to
14181 be sources of the project file: they are not inherited.
14184 @node Attribute References
14185 @section Attribute References
14188 Attribute references are used to retrieve the value of previously defined
14189 attribute for a package or project.
14192 attribute_reference ::=
14193 attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
14195 attribute_prefix ::=
14197 <project_simple_name | package_identifier |
14198 <project_>simple_name . package_identifier
14202 If an attribute has not been specified for a given package or project, its
14203 value is the null string or the empty list.
14205 @node External Values
14206 @section External Values
14209 An external value is an expression whose value is obtained from the command
14210 that invoked the processing of the current project file (typically a
14216 @b{external} ( string_literal [, string_literal] )
14220 The first string_literal is the string to be used on the command line or
14221 in the environment to specify the external value. The second string_literal,
14222 if present, is the default to use if there is no specification for this
14223 external value either on the command line or in the environment.
14225 @node Case Construction
14226 @section Case Construction
14229 A case construction supports attribute declarations that depend on the value of
14230 a previously declared variable.
14234 case_construction ::=
14235 @b{case} <typed_variable_>name @b{is}
14240 @b{when} discrete_choice_list =>
14241 @{case_construction | attribute_declaration | empty_declaration@}
14243 discrete_choice_list ::=
14244 string_literal @{| string_literal@} |
14249 All choices in a choice list must be distinct. The choice lists of two
14250 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
14251 alternatives do not need to include all values of the type. An @code{others}
14252 choice must appear last in the list of alternatives.
14258 A package provides a grouping of variable declarations and attribute
14259 declarations to be used when invoking various GNAT tools. The name of
14260 the package indicates the tool(s) to which it applies.
14264 package_declaration ::=
14265 package_specification | package_renaming
14267 package_specification ::=
14268 @b{package} package_identifier @b{is}
14269 @{simple_declarative_item@}
14270 @b{end} package_identifier ;
14272 package_identifier ::=
14273 @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
14274 @code{Linker} | @code{Finder} | @code{Cross_Reference} |
14275 @code{gnatls} | @code{IDE} | @code{Pretty_Printer}
14278 @subsection Package Naming
14281 The attributes of a @code{Naming} package specifies the naming conventions
14282 that apply to the source files in a project. When invoking other GNAT tools,
14283 they will use the sources in the source directories that satisfy these
14284 naming conventions.
14286 The following attributes apply to a @code{Naming} package:
14290 This is a simple attribute whose value is a string. Legal values of this
14291 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
14292 These strings are themselves case insensitive.
14295 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
14297 @item Dot_Replacement
14298 This is a simple attribute whose string value satisfies the following
14302 @item It must not be empty
14303 @item It cannot start or end with an alphanumeric character
14304 @item It cannot be a single underscore
14305 @item It cannot start with an underscore followed by an alphanumeric
14306 @item It cannot contain a dot @code{'.'} if longer than one character
14310 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
14313 This is an associative array attribute, defined on language names,
14314 whose image is a string that must satisfy the following
14318 @item It must not be empty
14319 @item It cannot start with an alphanumeric character
14320 @item It cannot start with an underscore followed by an alphanumeric character
14324 For Ada, the attribute denotes the suffix used in file names that contain
14325 library unit declarations, that is to say units that are package and
14326 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
14327 specified, then the default is @code{".ads"}.
14329 For C and C++, the attribute denotes the suffix used in file names that
14330 contain prototypes.
14333 This is an associative array attribute defined on language names,
14334 whose image is a string that must satisfy the following
14338 @item It must not be empty
14339 @item It cannot start with an alphanumeric character
14340 @item It cannot start with an underscore followed by an alphanumeric character
14341 @item It cannot be a suffix of @code{Spec_Suffix}
14345 For Ada, the attribute denotes the suffix used in file names that contain
14346 library bodies, that is to say units that are package and subprogram bodies.
14347 If @code{Body_Suffix ("Ada")} is not specified, then the default is
14350 For C and C++, the attribute denotes the suffix used in file names that contain
14353 @item Separate_Suffix
14354 This is a simple attribute whose value satisfies the same conditions as
14355 @code{Body_Suffix}.
14357 This attribute is specific to Ada. It denotes the suffix used in file names
14358 that contain separate bodies. If it is not specified, then it defaults to same
14359 value as @code{Body_Suffix ("Ada")}.
14362 This is an associative array attribute, specific to Ada, defined over
14363 compilation unit names. The image is a string that is the name of the file
14364 that contains that library unit. The file name is case sensitive if the
14365 conventions of the host operating system require it.
14368 This is an associative array attribute, specific to Ada, defined over
14369 compilation unit names. The image is a string that is the name of the file
14370 that contains the library unit body for the named unit. The file name is case
14371 sensitive if the conventions of the host operating system require it.
14373 @item Specification_Exceptions
14374 This is an associative array attribute defined on language names,
14375 whose value is a list of strings.
14377 This attribute is not significant for Ada.
14379 For C and C++, each string in the list denotes the name of a file that
14380 contains prototypes, but whose suffix is not necessarily the
14381 @code{Spec_Suffix} for the language.
14383 @item Implementation_Exceptions
14384 This is an associative array attribute defined on language names,
14385 whose value is a list of strings.
14387 This attribute is not significant for Ada.
14389 For C and C++, each string in the list denotes the name of a file that
14390 contains source code, but whose suffix is not necessarily the
14391 @code{Body_Suffix} for the language.
14394 The following attributes of package @code{Naming} are obsolescent. They are
14395 kept as synonyms of other attributes for compatibility with previous versions
14396 of the Project Manager.
14399 @item Specification_Suffix
14400 This is a synonym of @code{Spec_Suffix}.
14402 @item Implementation_Suffix
14403 This is a synonym of @code{Body_Suffix}.
14405 @item Specification
14406 This is a synonym of @code{Spec}.
14408 @item Implementation
14409 This is a synonym of @code{Body}.
14412 @subsection package Compiler
14415 The attributes of the @code{Compiler} package specify the compilation options
14416 to be used by the underlying compiler.
14419 @item Default_Switches
14420 This is an associative array attribute. Its
14421 domain is a set of language names. Its range is a string list that
14422 specifies the compilation options to be used when compiling a component
14423 written in that language, for which no file-specific switches have been
14427 This is an associative array attribute. Its domain is
14428 a set of file names. Its range is a string list that specifies the
14429 compilation options to be used when compiling the named file. If a file
14430 is not specified in the Switches attribute, it is compiled with the
14431 settings specified by Default_Switches.
14433 @item Local_Configuration_Pragmas.
14434 This is a simple attribute, whose
14435 value is a path name that designates a file containing configuration pragmas
14436 to be used for all invocations of the compiler for immediate sources of the
14440 This is an associative array attribute. Its domain is
14441 a set of main source file names. Its range is a simple string that specifies
14442 the executable file name to be used when linking the specified main source.
14443 If a main source is not specified in the Executable attribute, the executable
14444 file name is deducted from the main source file name.
14447 @subsection package Builder
14450 The attributes of package @code{Builder} specify the compilation, binding, and
14451 linking options to be used when building an executable for a project. The
14452 following attributes apply to package @code{Builder}:
14455 @item Default_Switches
14461 @item Global_Configuration_Pragmas
14462 This is a simple attribute, whose
14463 value is a path name that designates a file that contains configuration pragmas
14464 to be used in every build of an executable. If both local and global
14465 configuration pragmas are specified, a compilation makes use of both sets.
14468 This is an associative array attribute, defined over
14469 compilation unit names. The image is a string that is the name of the
14470 executable file corresponding to the main source file index.
14471 This attribute has no effect if its value is the empty string.
14473 @item Executable_Suffix
14474 This is a simple attribute whose value is a suffix to be added to
14475 the executables that don't have an attribute Executable specified.
14478 @subsection package Gnatls
14481 The attributes of package @code{Gnatls} specify the tool options to be used
14482 when invoking the library browser @command{gnatls}.
14483 The following attributes apply to package @code{Gnatls}:
14490 @subsection package Binder
14493 The attributes of package @code{Binder} specify the options to be used
14494 when invoking the binder in the construction of an executable.
14495 The following attributes apply to package @code{Binder}:
14498 @item Default_Switches
14504 @subsection package Linker
14507 The attributes of package @code{Linker} specify the options to be used when
14508 invoking the linker in the construction of an executable.
14509 The following attributes apply to package @code{Linker}:
14512 @item Default_Switches
14518 @subsection package Cross_Reference
14521 The attributes of package @code{Cross_Reference} specify the tool options
14523 when invoking the library tool @command{gnatxref}.
14524 The following attributes apply to package @code{Cross_Reference}:
14527 @item Default_Switches
14533 @subsection package Finder
14536 The attributes of package @code{Finder} specify the tool options to be used
14537 when invoking the search tool @command{gnatfind}.
14538 The following attributes apply to package @code{Finder}:
14541 @item Default_Switches
14547 @subsection package Pretty_Printer
14550 The attributes of package @code{Pretty_Printer}
14551 specify the tool options to be used
14552 when invoking the formatting tool @command{gnatpp}.
14553 The following attributes apply to package @code{Pretty_Printer}:
14556 @item Default_switches
14562 @subsection package IDE
14565 The attributes of package @code{IDE} specify the options to be used when using
14566 an Integrated Development Environment such as @command{GPS}.
14570 This is a simple attribute. Its value is a string that designates the remote
14571 host in a cross-compilation environment, to be used for remote compilation and
14572 debugging. This field should not be specified when running on the local
14576 This is a simple attribute. Its value is a string that specifies the
14577 name of IP address of the embedded target in a cross-compilation environment,
14578 on which the program should execute.
14580 @item Communication_Protocol
14581 This is a simple string attribute. Its value is the name of the protocol
14582 to use to communicate with the target in a cross-compilation environment,
14583 e.g. @code{"wtx"} or @code{"vxworks"}.
14585 @item Compiler_Command
14586 This is an associative array attribute, whose domain is a language name. Its
14587 value is string that denotes the command to be used to invoke the compiler.
14588 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
14589 gnatmake, in particular in the handling of switches.
14591 @item Debugger_Command
14592 This is simple attribute, Its value is a string that specifies the name of
14593 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
14595 @item Default_Switches
14596 This is an associative array attribute. Its indexes are the name of the
14597 external tools that the GNAT Programming System (GPS) is supporting. Its
14598 value is a list of switches to use when invoking that tool.
14601 This is a simple attribute. Its value is a string that specifies the name
14602 of the @command{gnatls} utility to be used to retrieve information about the
14603 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
14606 This is a simple attribute. Is value is a string used to specify the
14607 Version Control System (VCS) to be used for this project, e.g CVS, RCS
14608 ClearCase or Perforce.
14610 @item VCS_File_Check
14611 This is a simple attribute. Its value is a string that specifies the
14612 command used by the VCS to check the validity of a file, either
14613 when the user explicitly asks for a check, or as a sanity check before
14614 doing the check-in.
14616 @item VCS_Log_Check
14617 This is a simple attribute. Its value is a string that specifies
14618 the command used by the VCS to check the validity of a log file.
14622 @node Package Renamings
14623 @section Package Renamings
14626 A package can be defined by a renaming declaration. The new package renames
14627 a package declared in a different project file, and has the same attributes
14628 as the package it renames.
14631 package_renaming ::==
14632 @b{package} package_identifier @b{renames}
14633 <project_>simple_name.package_identifier ;
14637 The package_identifier of the renamed package must be the same as the
14638 package_identifier. The project whose name is the prefix of the renamed
14639 package must contain a package declaration with this name. This project
14640 must appear in the context_clause of the enclosing project declaration,
14641 or be the parent project of the enclosing child project.
14647 A project file specifies a set of rules for constructing a software system.
14648 A project file can be self-contained, or depend on other project files.
14649 Dependencies are expressed through a context clause that names other projects.
14655 context_clause project_declaration
14657 project_declaration ::=
14658 simple_project_declaration | project_extension
14660 simple_project_declaration ::=
14661 @b{project} <project_>simple_name @b{is}
14662 @{declarative_item@}
14663 @b{end} <project_>simple_name;
14669 [@b{limited}] @b{with} path_name @{ , path_name @} ;
14676 A path name denotes a project file. A path name can be absolute or relative.
14677 An absolute path name includes a sequence of directories, in the syntax of
14678 the host operating system, that identifies uniquely the project file in the
14679 file system. A relative path name identifies the project file, relative
14680 to the directory that contains the current project, or relative to a
14681 directory listed in the environment variable ADA_PROJECT_PATH.
14682 Path names are case sensitive if file names in the host operating system
14683 are case sensitive.
14685 The syntax of the environment variable ADA_PROJECT_PATH is a list of
14686 directory names separated by colons (semicolons on Windows).
14688 A given project name can appear only once in a context_clause.
14690 It is illegal for a project imported by a context clause to refer, directly
14691 or indirectly, to the project in which this context clause appears (the
14692 dependency graph cannot contain cycles), except when one of the with_clause
14693 in the cycle is a @code{limited with}.
14695 @node Project Extensions
14696 @section Project Extensions
14699 A project extension introduces a new project, which inherits the declarations
14700 of another project.
14704 project_extension ::=
14705 @b{project} <project_>simple_name @b{extends} path_name @b{is}
14706 @{declarative_item@}
14707 @b{end} <project_>simple_name;
14711 The project extension declares a child project. The child project inherits
14712 all the declarations and all the files of the parent project, These inherited
14713 declaration can be overridden in the child project, by means of suitable
14716 @node Project File Elaboration
14717 @section Project File Elaboration
14720 A project file is processed as part of the invocation of a gnat tool that
14721 uses the project option. Elaboration of the process file consists in the
14722 sequential elaboration of all its declarations. The computed values of
14723 attributes and variables in the project are then used to establish the
14724 environment in which the gnat tool will execute.
14726 @node Obsolescent Features
14727 @chapter Obsolescent Features
14730 This chapter describes features that are provided by GNAT, but are
14731 considered obsolescent since there are preferred ways of achieving
14732 the same effect. These features are provided solely for historical
14733 compatibility purposes.
14736 * pragma No_Run_Time::
14737 * pragma Ravenscar::
14738 * pragma Restricted_Run_Time::
14741 @node pragma No_Run_Time
14742 @section pragma No_Run_Time
14744 The pragma @code{No_Run_Time} is used to achieve an affect similar
14745 to the use of the "Zero Foot Print" configurable run time, but without
14746 requiring a specially configured run time. The result of using this
14747 pragma, which must be used for all units in a partition, is to restrict
14748 the use of any language features requiring run-time support code. The
14749 preferred usage is to use an appropriately configured run-time that
14750 includes just those features that are to be made accessible.
14752 @node pragma Ravenscar
14753 @section pragma Ravenscar
14755 The pragma @code{Ravenscar} has exactly the same effect as pragma
14756 @code{Profile (Ravenscar)}. The latter usage is preferred since it
14757 is part of the new Ada 2005 standard.
14759 @node pragma Restricted_Run_Time
14760 @section pragma Restricted_Run_Time
14762 The pragma @code{Restricted_Run_Time} has exactly the same effect as
14763 pragma @code{Profile (Restricted)}. The latter usage is
14764 preferred since the Ada 2005 pragma @code{Profile} is intended for
14765 this kind of implementation dependent addition.
14768 @c GNU Free Documentation License
14770 @node Index,,GNU Free Documentation License, Top