1 \input texinfo @c -*-texinfo-*-
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
7 @c GNAT DOCUMENTATION o
11 @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
15 @setfilename gnat_rm.info
18 Copyright @copyright{} 1995-2012, Free Software Foundation, Inc.
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.3 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24 Manual'', and with no Back-Cover Texts. A copy of the license is
25 included in the section entitled ``GNU Free Documentation License''.
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
32 @settitle GNAT Reference Manual
34 @setchapternewpage odd
37 @include gcc-common.texi
39 @dircategory GNU Ada tools
41 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
50 @vskip 0pt plus 1filll
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
72 * Implementation Defined Pragmas::
73 * Implementation Defined Attributes::
74 * Standard and Implementation Defined Restrictions::
75 * Implementation Advice::
76 * Implementation Defined Characteristics::
77 * Intrinsic Subprograms::
78 * Representation Clauses and Pragmas::
79 * Standard Library Routines::
80 * The Implementation of Standard I/O::
82 * Interfacing to Other Languages::
83 * Specialized Needs Annexes::
84 * Implementation of Specific Ada Features::
85 * Implementation of Ada 2012 Features::
86 * Obsolescent Features::
87 * GNU Free Documentation License::
90 --- The Detailed Node Listing ---
94 * What This Reference Manual Contains::
95 * Related Information::
97 Implementation Defined Pragmas
99 * Pragma Abort_Defer::
108 * Pragma Assertion_Policy::
109 * Pragma Assume_No_Invalid_Values::
111 * Pragma C_Pass_By_Copy::
113 * Pragma Check_Name::
114 * Pragma Check_Policy::
116 * Pragma Common_Object::
117 * Pragma Compile_Time_Error::
118 * Pragma Compile_Time_Warning::
119 * Pragma Compiler_Unit::
120 * Pragma Complete_Representation::
121 * Pragma Complex_Representation::
122 * Pragma Component_Alignment::
123 * Pragma Contract_Case::
124 * Pragma Convention_Identifier::
126 * Pragma CPP_Constructor::
127 * Pragma CPP_Virtual::
128 * Pragma CPP_Vtable::
130 * Pragma Debug_Policy::
131 * Pragma Detect_Blocking::
132 * Pragma Elaboration_Checks::
134 * Pragma Export_Exception::
135 * Pragma Export_Function::
136 * Pragma Export_Object::
137 * Pragma Export_Procedure::
138 * Pragma Export_Value::
139 * Pragma Export_Valued_Procedure::
140 * Pragma Extend_System::
141 * Pragma Extensions_Allowed::
143 * Pragma External_Name_Casing::
145 * Pragma Favor_Top_Level::
146 * Pragma Finalize_Storage_Only::
147 * Pragma Float_Representation::
149 * Pragma Implemented::
150 * Pragma Implicit_Packing::
151 * Pragma Import_Exception::
152 * Pragma Import_Function::
153 * Pragma Import_Object::
154 * Pragma Import_Procedure::
155 * Pragma Import_Valued_Procedure::
156 * Pragma Initialize_Scalars::
157 * Pragma Inline_Always::
158 * Pragma Inline_Generic::
160 * Pragma Interface_Name::
161 * Pragma Interrupt_Handler::
162 * Pragma Interrupt_State::
164 * Pragma Keep_Names::
167 * Pragma Linker_Alias::
168 * Pragma Linker_Constructor::
169 * Pragma Linker_Destructor::
170 * Pragma Linker_Section::
171 * Pragma Long_Float::
172 * Pragma Machine_Attribute::
174 * Pragma Main_Storage::
177 * Pragma No_Strict_Aliasing ::
178 * Pragma Normalize_Scalars::
179 * Pragma Obsolescent::
180 * Pragma Optimize_Alignment::
183 * Pragma Persistent_BSS::
185 * Pragma Postcondition::
186 * Pragma Precondition::
187 * Pragma Profile (Ravenscar)::
188 * Pragma Profile (Restricted)::
189 * Pragma Psect_Object::
190 * Pragma Pure_Function::
191 * Pragma Remote_Access_Type::
192 * Pragma Restriction_Warnings::
194 * Pragma Short_Circuit_And_Or::
195 * Pragma Short_Descriptors::
196 * Pragma Simple_Storage_Pool_Type::
197 * Pragma Source_File_Name::
198 * Pragma Source_File_Name_Project::
199 * Pragma Source_Reference::
200 * Pragma Static_Elaboration_Desired::
201 * Pragma Stream_Convert::
202 * Pragma Style_Checks::
205 * Pragma Suppress_All::
206 * Pragma Suppress_Exception_Locations::
207 * Pragma Suppress_Initialization::
210 * Pragma Task_Storage::
212 * Pragma Thread_Local_Storage::
213 * Pragma Time_Slice::
215 * Pragma Unchecked_Union::
216 * Pragma Unimplemented_Unit::
217 * Pragma Universal_Aliasing ::
218 * Pragma Universal_Data::
219 * Pragma Unmodified::
220 * Pragma Unreferenced::
221 * Pragma Unreferenced_Objects::
222 * Pragma Unreserve_All_Interrupts::
223 * Pragma Unsuppress::
224 * Pragma Use_VADS_Size::
225 * Pragma Validity_Checks::
228 * Pragma Weak_External::
229 * Pragma Wide_Character_Encoding::
231 Implementation Defined Attributes
242 * Default_Bit_Order::
254 * Has_Access_Values::
255 * Has_Discriminants::
262 * Max_Interrupt_Priority::
264 * Maximum_Alignment::
268 * Passed_By_Reference::
274 * Scalar_Storage_Order::
275 * Simple_Storage_Pool::
279 * System_Allocator_Alignment::
285 * Unconstrained_Array::
286 * Universal_Literal_String::
287 * Unrestricted_Access::
294 Standard and Implementation Defined Restrictions
296 * Partition-Wide Restrictions::
297 * Program Unit Level Restrictions::
299 Partition-Wide Restrictions
301 * Immediate_Reclamation::
302 * Max_Asynchronous_Select_Nesting::
303 * Max_Entry_Queue_Length::
304 * Max_Protected_Entries::
305 * Max_Select_Alternatives::
306 * Max_Storage_At_Blocking::
309 * No_Abort_Statements::
310 * No_Access_Parameter_Allocators::
311 * No_Access_Subprograms::
313 * No_Anonymous_Allocators::
316 * No_Default_Initialization::
319 * No_Direct_Boolean_Operators::
321 * No_Dispatching_Calls::
322 * No_Dynamic_Attachment::
323 * No_Dynamic_Priorities::
324 * No_Entry_Calls_In_Elaboration_Code::
325 * No_Enumeration_Maps::
326 * No_Exception_Handlers::
327 * No_Exception_Propagation::
328 * No_Exception_Registration::
332 * No_Floating_Point::
333 * No_Implicit_Conditionals::
334 * No_Implicit_Dynamic_Code::
335 * No_Implicit_Heap_Allocations::
336 * No_Implicit_Loops::
337 * No_Initialize_Scalars::
339 * No_Local_Allocators::
340 * No_Local_Protected_Objects::
341 * No_Local_Timing_Events::
342 * No_Nested_Finalization::
343 * No_Protected_Type_Allocators::
344 * No_Protected_Types::
347 * No_Relative_Delay::
348 * No_Requeue_Statements::
349 * No_Secondary_Stack::
350 * No_Select_Statements::
351 * No_Specific_Termination_Handlers::
352 * No_Specification_of_Aspect::
353 * No_Standard_Allocators_After_Elaboration::
354 * No_Standard_Storage_Pools::
355 * No_Stream_Optimizations::
357 * No_Task_Allocators::
358 * No_Task_Attributes_Package::
359 * No_Task_Hierarchy::
360 * No_Task_Termination::
362 * No_Terminate_Alternatives::
363 * No_Unchecked_Access::
365 * Static_Priorities::
366 * Static_Storage_Size::
368 Program Unit Level Restrictions
370 * No_Elaboration_Code::
372 * No_Implementation_Aspect_Specifications::
373 * No_Implementation_Attributes::
374 * No_Implementation_Identifiers::
375 * No_Implementation_Pragmas::
376 * No_Implementation_Restrictions::
377 * No_Implementation_Units::
378 * No_Implicit_Aliasing::
379 * No_Obsolescent_Features::
380 * No_Wide_Characters::
383 The Implementation of Standard I/O
385 * Standard I/O Packages::
391 * Wide_Wide_Text_IO::
395 * Filenames encoding::
397 * Operations on C Streams::
398 * Interfacing to C Streams::
402 * Ada.Characters.Latin_9 (a-chlat9.ads)::
403 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
404 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
405 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
406 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
407 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
408 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
409 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
410 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
411 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
412 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
413 * Ada.Command_Line.Environment (a-colien.ads)::
414 * Ada.Command_Line.Remove (a-colire.ads)::
415 * Ada.Command_Line.Response_File (a-clrefi.ads)::
416 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
417 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
418 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
419 * Ada.Exceptions.Traceback (a-exctra.ads)::
420 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
421 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
422 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
423 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
424 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
425 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
426 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
427 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
428 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
429 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
430 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
431 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
432 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
433 * GNAT.Altivec (g-altive.ads)::
434 * GNAT.Altivec.Conversions (g-altcon.ads)::
435 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
436 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
437 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
438 * GNAT.Array_Split (g-arrspl.ads)::
439 * GNAT.AWK (g-awk.ads)::
440 * GNAT.Bounded_Buffers (g-boubuf.ads)::
441 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
442 * GNAT.Bubble_Sort (g-bubsor.ads)::
443 * GNAT.Bubble_Sort_A (g-busora.ads)::
444 * GNAT.Bubble_Sort_G (g-busorg.ads)::
445 * GNAT.Byte_Order_Mark (g-byorma.ads)::
446 * GNAT.Byte_Swapping (g-bytswa.ads)::
447 * GNAT.Calendar (g-calend.ads)::
448 * GNAT.Calendar.Time_IO (g-catiio.ads)::
449 * GNAT.Case_Util (g-casuti.ads)::
450 * GNAT.CGI (g-cgi.ads)::
451 * GNAT.CGI.Cookie (g-cgicoo.ads)::
452 * GNAT.CGI.Debug (g-cgideb.ads)::
453 * GNAT.Command_Line (g-comlin.ads)::
454 * GNAT.Compiler_Version (g-comver.ads)::
455 * GNAT.Ctrl_C (g-ctrl_c.ads)::
456 * GNAT.CRC32 (g-crc32.ads)::
457 * GNAT.Current_Exception (g-curexc.ads)::
458 * GNAT.Debug_Pools (g-debpoo.ads)::
459 * GNAT.Debug_Utilities (g-debuti.ads)::
460 * GNAT.Decode_String (g-decstr.ads)::
461 * GNAT.Decode_UTF8_String (g-deutst.ads)::
462 * GNAT.Directory_Operations (g-dirope.ads)::
463 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
464 * GNAT.Dynamic_HTables (g-dynhta.ads)::
465 * GNAT.Dynamic_Tables (g-dyntab.ads)::
466 * GNAT.Encode_String (g-encstr.ads)::
467 * GNAT.Encode_UTF8_String (g-enutst.ads)::
468 * GNAT.Exception_Actions (g-excact.ads)::
469 * GNAT.Exception_Traces (g-exctra.ads)::
470 * GNAT.Exceptions (g-except.ads)::
471 * GNAT.Expect (g-expect.ads)::
472 * GNAT.Expect.TTY (g-exptty.ads)::
473 * GNAT.Float_Control (g-flocon.ads)::
474 * GNAT.Heap_Sort (g-heasor.ads)::
475 * GNAT.Heap_Sort_A (g-hesora.ads)::
476 * GNAT.Heap_Sort_G (g-hesorg.ads)::
477 * GNAT.HTable (g-htable.ads)::
478 * GNAT.IO (g-io.ads)::
479 * GNAT.IO_Aux (g-io_aux.ads)::
480 * GNAT.Lock_Files (g-locfil.ads)::
481 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
482 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
483 * GNAT.MD5 (g-md5.ads)::
484 * GNAT.Memory_Dump (g-memdum.ads)::
485 * GNAT.Most_Recent_Exception (g-moreex.ads)::
486 * GNAT.OS_Lib (g-os_lib.ads)::
487 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
488 * GNAT.Random_Numbers (g-rannum.ads)::
489 * GNAT.Regexp (g-regexp.ads)::
490 * GNAT.Registry (g-regist.ads)::
491 * GNAT.Regpat (g-regpat.ads)::
492 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
493 * GNAT.Semaphores (g-semaph.ads)::
494 * GNAT.Serial_Communications (g-sercom.ads)::
495 * GNAT.SHA1 (g-sha1.ads)::
496 * GNAT.SHA224 (g-sha224.ads)::
497 * GNAT.SHA256 (g-sha256.ads)::
498 * GNAT.SHA384 (g-sha384.ads)::
499 * GNAT.SHA512 (g-sha512.ads)::
500 * GNAT.Signals (g-signal.ads)::
501 * GNAT.Sockets (g-socket.ads)::
502 * GNAT.Source_Info (g-souinf.ads)::
503 * GNAT.Spelling_Checker (g-speche.ads)::
504 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
505 * GNAT.Spitbol.Patterns (g-spipat.ads)::
506 * GNAT.Spitbol (g-spitbo.ads)::
507 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
508 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
509 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
510 * GNAT.SSE (g-sse.ads)::
511 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
512 * GNAT.Strings (g-string.ads)::
513 * GNAT.String_Split (g-strspl.ads)::
514 * GNAT.Table (g-table.ads)::
515 * GNAT.Task_Lock (g-tasloc.ads)::
516 * GNAT.Threads (g-thread.ads)::
517 * GNAT.Time_Stamp (g-timsta.ads)::
518 * GNAT.Traceback (g-traceb.ads)::
519 * GNAT.Traceback.Symbolic (g-trasym.ads)::
520 * GNAT.UTF_32 (g-utf_32.ads)::
521 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
522 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
523 * GNAT.Wide_String_Split (g-wistsp.ads)::
524 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
525 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
526 * Interfaces.C.Extensions (i-cexten.ads)::
527 * Interfaces.C.Streams (i-cstrea.ads)::
528 * Interfaces.CPP (i-cpp.ads)::
529 * Interfaces.Packed_Decimal (i-pacdec.ads)::
530 * Interfaces.VxWorks (i-vxwork.ads)::
531 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
532 * System.Address_Image (s-addima.ads)::
533 * System.Assertions (s-assert.ads)::
534 * System.Memory (s-memory.ads)::
535 * System.Partition_Interface (s-parint.ads)::
536 * System.Pool_Global (s-pooglo.ads)::
537 * System.Pool_Local (s-pooloc.ads)::
538 * System.Restrictions (s-restri.ads)::
539 * System.Rident (s-rident.ads)::
540 * System.Strings.Stream_Ops (s-ststop.ads)::
541 * System.Task_Info (s-tasinf.ads)::
542 * System.Wch_Cnv (s-wchcnv.ads)::
543 * System.Wch_Con (s-wchcon.ads)::
547 * Text_IO Stream Pointer Positioning::
548 * Text_IO Reading and Writing Non-Regular Files::
550 * Treating Text_IO Files as Streams::
551 * Text_IO Extensions::
552 * Text_IO Facilities for Unbounded Strings::
556 * Wide_Text_IO Stream Pointer Positioning::
557 * Wide_Text_IO Reading and Writing Non-Regular Files::
561 * Wide_Wide_Text_IO Stream Pointer Positioning::
562 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
564 Interfacing to Other Languages
567 * Interfacing to C++::
568 * Interfacing to COBOL::
569 * Interfacing to Fortran::
570 * Interfacing to non-GNAT Ada code::
572 Specialized Needs Annexes
574 Implementation of Specific Ada Features
575 * Machine Code Insertions::
576 * GNAT Implementation of Tasking::
577 * GNAT Implementation of Shared Passive Packages::
578 * Code Generation for Array Aggregates::
579 * The Size of Discriminated Records with Default Discriminants::
580 * Strict Conformance to the Ada Reference Manual::
582 Implementation of Ada 2012 Features
586 GNU Free Documentation License
593 @node About This Guide
594 @unnumbered About This Guide
597 This manual contains useful information in writing programs using the
598 @value{EDITION} compiler. It includes information on implementation dependent
599 characteristics of @value{EDITION}, including all the information required by
600 Annex M of the Ada language standard.
602 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
603 Ada 83 compatibility mode.
604 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
605 but you can override with a compiler switch
606 to explicitly specify the language version.
607 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
608 @value{EDITION} User's Guide}, for details on these switches.)
609 Throughout this manual, references to ``Ada'' without a year suffix
610 apply to both the Ada 95 and Ada 2005 versions of the language.
612 Ada is designed to be highly portable.
613 In general, a program will have the same effect even when compiled by
614 different compilers on different platforms.
615 However, since Ada is designed to be used in a
616 wide variety of applications, it also contains a number of system
617 dependent features to be used in interfacing to the external world.
618 @cindex Implementation-dependent features
621 Note: Any program that makes use of implementation-dependent features
622 may be non-portable. You should follow good programming practice and
623 isolate and clearly document any sections of your program that make use
624 of these features in a non-portable manner.
627 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
628 ``GNAT'' in the remainder of this document.
632 * What This Reference Manual Contains::
634 * Related Information::
637 @node What This Reference Manual Contains
638 @unnumberedsec What This Reference Manual Contains
641 This reference manual contains the following chapters:
645 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
646 pragmas, which can be used to extend and enhance the functionality of the
650 @ref{Implementation Defined Attributes}, lists GNAT
651 implementation-dependent attributes, which can be used to extend and
652 enhance the functionality of the compiler.
655 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
656 implementation-dependent restrictions, which can be used to extend and
657 enhance the functionality of the compiler.
660 @ref{Implementation Advice}, provides information on generally
661 desirable behavior which are not requirements that all compilers must
662 follow since it cannot be provided on all systems, or which may be
663 undesirable on some systems.
666 @ref{Implementation Defined Characteristics}, provides a guide to
667 minimizing implementation dependent features.
670 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
671 implemented by GNAT, and how they can be imported into user
672 application programs.
675 @ref{Representation Clauses and Pragmas}, describes in detail the
676 way that GNAT represents data, and in particular the exact set
677 of representation clauses and pragmas that is accepted.
680 @ref{Standard Library Routines}, provides a listing of packages and a
681 brief description of the functionality that is provided by Ada's
682 extensive set of standard library routines as implemented by GNAT@.
685 @ref{The Implementation of Standard I/O}, details how the GNAT
686 implementation of the input-output facilities.
689 @ref{The GNAT Library}, is a catalog of packages that complement
690 the Ada predefined library.
693 @ref{Interfacing to Other Languages}, describes how programs
694 written in Ada using GNAT can be interfaced to other programming
697 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
698 of the specialized needs annexes.
701 @ref{Implementation of Specific Ada Features}, discusses issues related
702 to GNAT's implementation of machine code insertions, tasking, and several
706 @ref{Implementation of Ada 2012 Features}, describes the status of the
707 GNAT implementation of the Ada 2012 language standard.
710 @ref{Obsolescent Features} documents implementation dependent features,
711 including pragmas and attributes, which are considered obsolescent, since
712 there are other preferred ways of achieving the same results. These
713 obsolescent forms are retained for backwards compatibility.
717 @cindex Ada 95 Language Reference Manual
718 @cindex Ada 2005 Language Reference Manual
720 This reference manual assumes a basic familiarity with the Ada 95 language, as
721 described in the International Standard ANSI/ISO/IEC-8652:1995,
723 It does not require knowledge of the new features introduced by Ada 2005,
724 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
726 Both reference manuals are included in the GNAT documentation
730 @unnumberedsec Conventions
731 @cindex Conventions, typographical
732 @cindex Typographical conventions
735 Following are examples of the typographical and graphic conventions used
740 @code{Functions}, @code{utility program names}, @code{standard names},
747 @file{File names}, @samp{button names}, and @samp{field names}.
750 @code{Variables}, @env{environment variables}, and @var{metasyntactic
757 [optional information or parameters]
760 Examples are described by text
762 and then shown this way.
767 Commands that are entered by the user are preceded in this manual by the
768 characters @samp{$ } (dollar sign followed by space). If your system uses this
769 sequence as a prompt, then the commands will appear exactly as you see them
770 in the manual. If your system uses some other prompt, then the command will
771 appear with the @samp{$} replaced by whatever prompt character you are using.
773 @node Related Information
774 @unnumberedsec Related Information
776 See the following documents for further information on GNAT:
780 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
781 @value{EDITION} User's Guide}, which provides information on how to use the
782 GNAT compiler system.
785 @cite{Ada 95 Reference Manual}, which contains all reference
786 material for the Ada 95 programming language.
789 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
790 of the Ada 95 standard. The annotations describe
791 detailed aspects of the design decision, and in particular contain useful
792 sections on Ada 83 compatibility.
795 @cite{Ada 2005 Reference Manual}, which contains all reference
796 material for the Ada 2005 programming language.
799 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
800 of the Ada 2005 standard. The annotations describe
801 detailed aspects of the design decision, and in particular contain useful
802 sections on Ada 83 and Ada 95 compatibility.
805 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
806 which contains specific information on compatibility between GNAT and
810 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
811 describes in detail the pragmas and attributes provided by the DEC Ada 83
816 @node Implementation Defined Pragmas
817 @chapter Implementation Defined Pragmas
820 Ada defines a set of pragmas that can be used to supply additional
821 information to the compiler. These language defined pragmas are
822 implemented in GNAT and work as described in the Ada Reference Manual.
824 In addition, Ada allows implementations to define additional pragmas
825 whose meaning is defined by the implementation. GNAT provides a number
826 of these implementation-defined pragmas, which can be used to extend
827 and enhance the functionality of the compiler. This section of the GNAT
828 Reference Manual describes these additional pragmas.
830 Note that any program using these pragmas might not be portable to other
831 compilers (although GNAT implements this set of pragmas on all
832 platforms). Therefore if portability to other compilers is an important
833 consideration, the use of these pragmas should be minimized.
836 * Pragma Abort_Defer::
845 * Pragma Assertion_Policy::
846 * Pragma Assume_No_Invalid_Values::
848 * Pragma C_Pass_By_Copy::
850 * Pragma Check_Name::
851 * Pragma Check_Policy::
853 * Pragma Common_Object::
854 * Pragma Compile_Time_Error::
855 * Pragma Compile_Time_Warning::
856 * Pragma Compiler_Unit::
857 * Pragma Complete_Representation::
858 * Pragma Complex_Representation::
859 * Pragma Component_Alignment::
860 * Pragma Contract_Case::
861 * Pragma Convention_Identifier::
863 * Pragma CPP_Constructor::
864 * Pragma CPP_Virtual::
865 * Pragma CPP_Vtable::
867 * Pragma Debug_Policy::
868 * Pragma Detect_Blocking::
869 * Pragma Elaboration_Checks::
871 * Pragma Export_Exception::
872 * Pragma Export_Function::
873 * Pragma Export_Object::
874 * Pragma Export_Procedure::
875 * Pragma Export_Value::
876 * Pragma Export_Valued_Procedure::
877 * Pragma Extend_System::
878 * Pragma Extensions_Allowed::
880 * Pragma External_Name_Casing::
882 * Pragma Favor_Top_Level::
883 * Pragma Finalize_Storage_Only::
884 * Pragma Float_Representation::
886 * Pragma Implemented::
887 * Pragma Implicit_Packing::
888 * Pragma Import_Exception::
889 * Pragma Import_Function::
890 * Pragma Import_Object::
891 * Pragma Import_Procedure::
892 * Pragma Import_Valued_Procedure::
893 * Pragma Initialize_Scalars::
894 * Pragma Inline_Always::
895 * Pragma Inline_Generic::
897 * Pragma Interface_Name::
898 * Pragma Interrupt_Handler::
899 * Pragma Interrupt_State::
901 * Pragma Keep_Names::
904 * Pragma Linker_Alias::
905 * Pragma Linker_Constructor::
906 * Pragma Linker_Destructor::
907 * Pragma Linker_Section::
908 * Pragma Long_Float::
909 * Pragma Machine_Attribute::
911 * Pragma Main_Storage::
914 * Pragma No_Strict_Aliasing::
915 * Pragma Normalize_Scalars::
916 * Pragma Obsolescent::
917 * Pragma Optimize_Alignment::
920 * Pragma Persistent_BSS::
922 * Pragma Postcondition::
923 * Pragma Precondition::
924 * Pragma Profile (Ravenscar)::
925 * Pragma Profile (Restricted)::
926 * Pragma Psect_Object::
927 * Pragma Pure_Function::
928 * Pragma Remote_Access_Type::
929 * Pragma Restriction_Warnings::
931 * Pragma Short_Circuit_And_Or::
932 * Pragma Short_Descriptors::
933 * Pragma Simple_Storage_Pool_Type::
934 * Pragma Source_File_Name::
935 * Pragma Source_File_Name_Project::
936 * Pragma Source_Reference::
937 * Pragma Static_Elaboration_Desired::
938 * Pragma Stream_Convert::
939 * Pragma Style_Checks::
942 * Pragma Suppress_All::
943 * Pragma Suppress_Exception_Locations::
944 * Pragma Suppress_Initialization::
947 * Pragma Task_Storage::
949 * Pragma Thread_Local_Storage::
950 * Pragma Time_Slice::
952 * Pragma Unchecked_Union::
953 * Pragma Unimplemented_Unit::
954 * Pragma Universal_Aliasing ::
955 * Pragma Universal_Data::
956 * Pragma Unmodified::
957 * Pragma Unreferenced::
958 * Pragma Unreferenced_Objects::
959 * Pragma Unreserve_All_Interrupts::
960 * Pragma Unsuppress::
961 * Pragma Use_VADS_Size::
962 * Pragma Validity_Checks::
965 * Pragma Weak_External::
966 * Pragma Wide_Character_Encoding::
969 @node Pragma Abort_Defer
970 @unnumberedsec Pragma Abort_Defer
972 @cindex Deferring aborts
980 This pragma must appear at the start of the statement sequence of a
981 handled sequence of statements (right after the @code{begin}). It has
982 the effect of deferring aborts for the sequence of statements (but not
983 for the declarations or handlers, if any, associated with this statement
987 @unnumberedsec Pragma Ada_83
996 A configuration pragma that establishes Ada 83 mode for the unit to
997 which it applies, regardless of the mode set by the command line
998 switches. In Ada 83 mode, GNAT attempts to be as compatible with
999 the syntax and semantics of Ada 83, as defined in the original Ada
1000 83 Reference Manual as possible. In particular, the keywords added by Ada 95
1001 and Ada 2005 are not recognized, optional package bodies are allowed,
1002 and generics may name types with unknown discriminants without using
1003 the @code{(<>)} notation. In addition, some but not all of the additional
1004 restrictions of Ada 83 are enforced.
1006 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1007 Ada 83 code to be compiled and adapted to GNAT with less effort.
1008 Secondly, it aids in keeping code backwards compatible with Ada 83.
1009 However, there is no guarantee that code that is processed correctly
1010 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1011 83 compiler, since GNAT does not enforce all the additional checks
1015 @unnumberedsec Pragma Ada_95
1019 @smallexample @c ada
1024 A configuration pragma that establishes Ada 95 mode for the unit to which
1025 it applies, regardless of the mode set by the command line switches.
1026 This mode is set automatically for the @code{Ada} and @code{System}
1027 packages and their children, so you need not specify it in these
1028 contexts. This pragma is useful when writing a reusable component that
1029 itself uses Ada 95 features, but which is intended to be usable from
1030 either Ada 83 or Ada 95 programs.
1033 @unnumberedsec Pragma Ada_05
1037 @smallexample @c ada
1042 A configuration pragma that establishes Ada 2005 mode for the unit to which
1043 it applies, regardless of the mode set by the command line switches.
1044 This pragma is useful when writing a reusable component that
1045 itself uses Ada 2005 features, but which is intended to be usable from
1046 either Ada 83 or Ada 95 programs.
1048 @node Pragma Ada_2005
1049 @unnumberedsec Pragma Ada_2005
1053 @smallexample @c ada
1058 This configuration pragma is a synonym for pragma Ada_05 and has the
1059 same syntax and effect.
1062 @unnumberedsec Pragma Ada_12
1066 @smallexample @c ada
1071 A configuration pragma that establishes Ada 2012 mode for the unit to which
1072 it applies, regardless of the mode set by the command line switches.
1073 This mode is set automatically for the @code{Ada} and @code{System}
1074 packages and their children, so you need not specify it in these
1075 contexts. This pragma is useful when writing a reusable component that
1076 itself uses Ada 2012 features, but which is intended to be usable from
1077 Ada 83, Ada 95, or Ada 2005 programs.
1079 @node Pragma Ada_2012
1080 @unnumberedsec Pragma Ada_2012
1084 @smallexample @c ada
1089 This configuration pragma is a synonym for pragma Ada_12 and has the
1090 same syntax and effect.
1092 @node Pragma Annotate
1093 @unnumberedsec Pragma Annotate
1097 @smallexample @c ada
1098 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1100 ARG ::= NAME | EXPRESSION
1104 This pragma is used to annotate programs. @var{identifier} identifies
1105 the type of annotation. GNAT verifies that it is an identifier, but does
1106 not otherwise analyze it. The second optional identifier is also left
1107 unanalyzed, and by convention is used to control the action of the tool to
1108 which the annotation is addressed. The remaining @var{arg} arguments
1109 can be either string literals or more generally expressions.
1110 String literals are assumed to be either of type
1111 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1112 depending on the character literals they contain.
1113 All other kinds of arguments are analyzed as expressions, and must be
1116 The analyzed pragma is retained in the tree, but not otherwise processed
1117 by any part of the GNAT compiler, except to generate corresponding note
1118 lines in the generated ALI file. For the format of these note lines, see
1119 the compiler source file lib-writ.ads. This pragma is intended for use by
1120 external tools, including ASIS@. The use of pragma Annotate does not
1121 affect the compilation process in any way. This pragma may be used as
1122 a configuration pragma.
1125 @unnumberedsec Pragma Assert
1129 @smallexample @c ada
1132 [, string_EXPRESSION]);
1136 The effect of this pragma depends on whether the corresponding command
1137 line switch is set to activate assertions. The pragma expands into code
1138 equivalent to the following:
1140 @smallexample @c ada
1141 if assertions-enabled then
1142 if not boolean_EXPRESSION then
1143 System.Assertions.Raise_Assert_Failure
1144 (string_EXPRESSION);
1150 The string argument, if given, is the message that will be associated
1151 with the exception occurrence if the exception is raised. If no second
1152 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1153 where @var{file} is the name of the source file containing the assert,
1154 and @var{nnn} is the line number of the assert. A pragma is not a
1155 statement, so if a statement sequence contains nothing but a pragma
1156 assert, then a null statement is required in addition, as in:
1158 @smallexample @c ada
1161 pragma Assert (K > 3, "Bad value for K");
1167 Note that, as with the @code{if} statement to which it is equivalent, the
1168 type of the expression is either @code{Standard.Boolean}, or any type derived
1169 from this standard type.
1171 If assertions are disabled (switch @option{-gnata} not used), then there
1172 is no run-time effect (and in particular, any side effects from the
1173 expression will not occur at run time). (The expression is still
1174 analyzed at compile time, and may cause types to be frozen if they are
1175 mentioned here for the first time).
1177 If assertions are enabled, then the given expression is tested, and if
1178 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1179 which results in the raising of @code{Assert_Failure} with the given message.
1181 You should generally avoid side effects in the expression arguments of
1182 this pragma, because these side effects will turn on and off with the
1183 setting of the assertions mode, resulting in assertions that have an
1184 effect on the program. However, the expressions are analyzed for
1185 semantic correctness whether or not assertions are enabled, so turning
1186 assertions on and off cannot affect the legality of a program.
1188 Note that the implementation defined policy @code{DISABLE}, given in a
1189 pragma Assertion_Policy, can be used to suppress this semantic analysis.
1191 Note: this is a standard language-defined pragma in versions
1192 of Ada from 2005 on. In GNAT, it is implemented in all versions
1193 of Ada, and the DISABLE policy is an implementation-defined
1197 @node Pragma Assertion_Policy
1198 @unnumberedsec Pragma Assertion_Policy
1199 @findex Debug_Policy
1203 @smallexample @c ada
1204 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1208 If the argument is @code{CHECK}, then assertions are enabled.
1209 If the argument is @code{IGNORE}, then assertions are ignored.
1210 This pragma overrides the effect of the @option{-gnata} switch on the
1213 Assertions are of three kinds:
1217 Pragma @code{Assert}.
1219 In Ada 2012, all assertions defined in the RM as aspects: preconditions,
1220 postconditions, type invariants and (sub)type predicates.
1222 Corresponding pragmas for type invariants and (sub)type predicates.
1225 The implementation defined policy @code{DISABLE} is like
1226 @code{IGNORE} except that it completely disables semantic
1227 checking of the argument to @code{pragma Assert}. This may
1228 be useful when the pragma argument references subprograms
1229 in a with'ed package which is replaced by a dummy package
1230 for the final build.
1232 Note: this is a standard language-defined pragma in versions
1233 of Ada from 2005 on. In GNAT, it is implemented in all versions
1234 of Ada, and the DISABLE policy is an implementation-defined
1237 @node Pragma Assume_No_Invalid_Values
1238 @unnumberedsec Pragma Assume_No_Invalid_Values
1239 @findex Assume_No_Invalid_Values
1240 @cindex Invalid representations
1241 @cindex Invalid values
1244 @smallexample @c ada
1245 pragma Assume_No_Invalid_Values (On | Off);
1249 This is a configuration pragma that controls the assumptions made by the
1250 compiler about the occurrence of invalid representations (invalid values)
1253 The default behavior (corresponding to an Off argument for this pragma), is
1254 to assume that values may in general be invalid unless the compiler can
1255 prove they are valid. Consider the following example:
1257 @smallexample @c ada
1258 V1 : Integer range 1 .. 10;
1259 V2 : Integer range 11 .. 20;
1261 for J in V2 .. V1 loop
1267 if V1 and V2 have valid values, then the loop is known at compile
1268 time not to execute since the lower bound must be greater than the
1269 upper bound. However in default mode, no such assumption is made,
1270 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1271 is given, the compiler will assume that any occurrence of a variable
1272 other than in an explicit @code{'Valid} test always has a valid
1273 value, and the loop above will be optimized away.
1275 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1276 you know your code is free of uninitialized variables and other
1277 possible sources of invalid representations, and may result in
1278 more efficient code. A program that accesses an invalid representation
1279 with this pragma in effect is erroneous, so no guarantees can be made
1282 It is peculiar though permissible to use this pragma in conjunction
1283 with validity checking (-gnatVa). In such cases, accessing invalid
1284 values will generally give an exception, though formally the program
1285 is erroneous so there are no guarantees that this will always be the
1286 case, and it is recommended that these two options not be used together.
1288 @node Pragma Ast_Entry
1289 @unnumberedsec Pragma Ast_Entry
1294 @smallexample @c ada
1295 pragma AST_Entry (entry_IDENTIFIER);
1299 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1300 argument is the simple name of a single entry; at most one @code{AST_Entry}
1301 pragma is allowed for any given entry. This pragma must be used in
1302 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1303 the entry declaration and in the same task type specification or single task
1304 as the entry to which it applies. This pragma specifies that the given entry
1305 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1306 resulting from an OpenVMS system service call. The pragma does not affect
1307 normal use of the entry. For further details on this pragma, see the
1308 DEC Ada Language Reference Manual, section 9.12a.
1310 @node Pragma C_Pass_By_Copy
1311 @unnumberedsec Pragma C_Pass_By_Copy
1312 @cindex Passing by copy
1313 @findex C_Pass_By_Copy
1316 @smallexample @c ada
1317 pragma C_Pass_By_Copy
1318 ([Max_Size =>] static_integer_EXPRESSION);
1322 Normally the default mechanism for passing C convention records to C
1323 convention subprograms is to pass them by reference, as suggested by RM
1324 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1325 this default, by requiring that record formal parameters be passed by
1326 copy if all of the following conditions are met:
1330 The size of the record type does not exceed the value specified for
1333 The record type has @code{Convention C}.
1335 The formal parameter has this record type, and the subprogram has a
1336 foreign (non-Ada) convention.
1340 If these conditions are met the argument is passed by copy, i.e.@: in a
1341 manner consistent with what C expects if the corresponding formal in the
1342 C prototype is a struct (rather than a pointer to a struct).
1344 You can also pass records by copy by specifying the convention
1345 @code{C_Pass_By_Copy} for the record type, or by using the extended
1346 @code{Import} and @code{Export} pragmas, which allow specification of
1347 passing mechanisms on a parameter by parameter basis.
1350 @unnumberedsec Pragma Check
1352 @cindex Named assertions
1356 @smallexample @c ada
1358 [Name =>] Identifier,
1359 [Check =>] Boolean_EXPRESSION
1360 [, [Message =>] string_EXPRESSION] );
1364 This pragma is similar to the predefined pragma @code{Assert} except that an
1365 extra identifier argument is present. In conjunction with pragma
1366 @code{Check_Policy}, this can be used to define groups of assertions that can
1367 be independently controlled. The identifier @code{Assertion} is special, it
1368 refers to the normal set of pragma @code{Assert} statements. The identifiers
1369 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1370 names, so these three names would normally not be used directly in a pragma
1373 Checks introduced by this pragma are normally deactivated by default. They can
1374 be activated either by the command line option @option{-gnata}, which turns on
1375 all checks, or individually controlled using pragma @code{Check_Policy}.
1377 @node Pragma Check_Name
1378 @unnumberedsec Pragma Check_Name
1379 @cindex Defining check names
1380 @cindex Check names, defining
1384 @smallexample @c ada
1385 pragma Check_Name (check_name_IDENTIFIER);
1389 This is a configuration pragma that defines a new implementation
1390 defined check name (unless IDENTIFIER matches one of the predefined
1391 check names, in which case the pragma has no effect). Check names
1392 are global to a partition, so if two or more configuration pragmas
1393 are present in a partition mentioning the same name, only one new
1394 check name is introduced.
1396 An implementation defined check name introduced with this pragma may
1397 be used in only three contexts: @code{pragma Suppress},
1398 @code{pragma Unsuppress},
1399 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1400 any of these three cases, the check name must be visible. A check
1401 name is visible if it is in the configuration pragmas applying to
1402 the current unit, or if it appears at the start of any unit that
1403 is part of the dependency set of the current unit (e.g., units that
1404 are mentioned in @code{with} clauses).
1406 @node Pragma Check_Policy
1407 @unnumberedsec Pragma Check_Policy
1408 @cindex Controlling assertions
1409 @cindex Assertions, control
1410 @cindex Check pragma control
1411 @cindex Named assertions
1415 @smallexample @c ada
1417 ([Name =>] Identifier,
1418 [Policy =>] POLICY_IDENTIFIER);
1420 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1424 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1425 except that it controls sets of named assertions introduced using the
1426 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1427 @code{Assertion_Policy}) can be used within a declarative part, in which case
1428 it controls the status to the end of the corresponding construct (in a manner
1429 identical to pragma @code{Suppress)}.
1431 The identifier given as the first argument corresponds to a name used in
1432 associated @code{Check} pragmas. For example, if the pragma:
1434 @smallexample @c ada
1435 pragma Check_Policy (Critical_Error, OFF);
1439 is given, then subsequent @code{Check} pragmas whose first argument is also
1440 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1441 controls the behavior of normal assertions (thus a pragma
1442 @code{Check_Policy} with this identifier is similar to the normal
1443 @code{Assertion_Policy} pragma except that it can appear within a
1446 The special identifiers @code{Precondition} and @code{Postcondition} control
1447 the status of preconditions and postconditions given as pragmas.
1448 If a @code{Precondition} pragma
1449 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1450 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1451 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1452 are recognized. Note that preconditions and postconditions given as aspects
1453 are controlled differently, either by the @code{Assertion_Policy} pragma or
1454 by the @code{Check_Policy} pragma with identifier @code{Assertion}.
1456 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1457 to turn on corresponding checks. The default for a set of checks for which no
1458 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1459 @option{-gnata} is given, which turns on all checks by default.
1461 The check policy settings @code{CHECK} and @code{IGNORE} are also recognized
1462 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1463 compatibility with the standard @code{Assertion_Policy} pragma.
1465 The implementation defined policy @code{DISABLE} is like
1466 @code{OFF} except that it completely disables semantic
1467 checking of the argument to the corresponding class of
1468 pragmas. This may be useful when the pragma arguments reference
1469 subprograms in a with'ed package which is replaced by a dummy package
1470 for the final build.
1472 @node Pragma Comment
1473 @unnumberedsec Pragma Comment
1478 @smallexample @c ada
1479 pragma Comment (static_string_EXPRESSION);
1483 This is almost identical in effect to pragma @code{Ident}. It allows the
1484 placement of a comment into the object file and hence into the
1485 executable file if the operating system permits such usage. The
1486 difference is that @code{Comment}, unlike @code{Ident}, has
1487 no limitations on placement of the pragma (it can be placed
1488 anywhere in the main source unit), and if more than one pragma
1489 is used, all comments are retained.
1491 @node Pragma Common_Object
1492 @unnumberedsec Pragma Common_Object
1493 @findex Common_Object
1497 @smallexample @c ada
1498 pragma Common_Object (
1499 [Internal =>] LOCAL_NAME
1500 [, [External =>] EXTERNAL_SYMBOL]
1501 [, [Size =>] EXTERNAL_SYMBOL] );
1505 | static_string_EXPRESSION
1509 This pragma enables the shared use of variables stored in overlaid
1510 linker areas corresponding to the use of @code{COMMON}
1511 in Fortran. The single
1512 object @var{LOCAL_NAME} is assigned to the area designated by
1513 the @var{External} argument.
1514 You may define a record to correspond to a series
1515 of fields. The @var{Size} argument
1516 is syntax checked in GNAT, but otherwise ignored.
1518 @code{Common_Object} is not supported on all platforms. If no
1519 support is available, then the code generator will issue a message
1520 indicating that the necessary attribute for implementation of this
1521 pragma is not available.
1523 @node Pragma Compile_Time_Error
1524 @unnumberedsec Pragma Compile_Time_Error
1525 @findex Compile_Time_Error
1529 @smallexample @c ada
1530 pragma Compile_Time_Error
1531 (boolean_EXPRESSION, static_string_EXPRESSION);
1535 This pragma can be used to generate additional compile time
1537 is particularly useful in generics, where errors can be issued for
1538 specific problematic instantiations. The first parameter is a boolean
1539 expression. The pragma is effective only if the value of this expression
1540 is known at compile time, and has the value True. The set of expressions
1541 whose values are known at compile time includes all static boolean
1542 expressions, and also other values which the compiler can determine
1543 at compile time (e.g., the size of a record type set by an explicit
1544 size representation clause, or the value of a variable which was
1545 initialized to a constant and is known not to have been modified).
1546 If these conditions are met, an error message is generated using
1547 the value given as the second argument. This string value may contain
1548 embedded ASCII.LF characters to break the message into multiple lines.
1550 @node Pragma Compile_Time_Warning
1551 @unnumberedsec Pragma Compile_Time_Warning
1552 @findex Compile_Time_Warning
1556 @smallexample @c ada
1557 pragma Compile_Time_Warning
1558 (boolean_EXPRESSION, static_string_EXPRESSION);
1562 Same as pragma Compile_Time_Error, except a warning is issued instead
1563 of an error message. Note that if this pragma is used in a package that
1564 is with'ed by a client, the client will get the warning even though it
1565 is issued by a with'ed package (normally warnings in with'ed units are
1566 suppressed, but this is a special exception to that rule).
1568 One typical use is within a generic where compile time known characteristics
1569 of formal parameters are tested, and warnings given appropriately. Another use
1570 with a first parameter of True is to warn a client about use of a package,
1571 for example that it is not fully implemented.
1573 @node Pragma Compiler_Unit
1574 @unnumberedsec Pragma Compiler_Unit
1575 @findex Compiler_Unit
1579 @smallexample @c ada
1580 pragma Compiler_Unit;
1584 This pragma is intended only for internal use in the GNAT run-time library.
1585 It indicates that the unit is used as part of the compiler build. The effect
1586 is to disallow constructs (raise with message, conditional expressions etc)
1587 that would cause trouble when bootstrapping using an older version of GNAT.
1588 For the exact list of restrictions, see the compiler sources and references
1589 to Is_Compiler_Unit.
1591 @node Pragma Complete_Representation
1592 @unnumberedsec Pragma Complete_Representation
1593 @findex Complete_Representation
1597 @smallexample @c ada
1598 pragma Complete_Representation;
1602 This pragma must appear immediately within a record representation
1603 clause. Typical placements are before the first component clause
1604 or after the last component clause. The effect is to give an error
1605 message if any component is missing a component clause. This pragma
1606 may be used to ensure that a record representation clause is
1607 complete, and that this invariant is maintained if fields are
1608 added to the record in the future.
1610 @node Pragma Complex_Representation
1611 @unnumberedsec Pragma Complex_Representation
1612 @findex Complex_Representation
1616 @smallexample @c ada
1617 pragma Complex_Representation
1618 ([Entity =>] LOCAL_NAME);
1622 The @var{Entity} argument must be the name of a record type which has
1623 two fields of the same floating-point type. The effect of this pragma is
1624 to force gcc to use the special internal complex representation form for
1625 this record, which may be more efficient. Note that this may result in
1626 the code for this type not conforming to standard ABI (application
1627 binary interface) requirements for the handling of record types. For
1628 example, in some environments, there is a requirement for passing
1629 records by pointer, and the use of this pragma may result in passing
1630 this type in floating-point registers.
1632 @node Pragma Component_Alignment
1633 @unnumberedsec Pragma Component_Alignment
1634 @cindex Alignments of components
1635 @findex Component_Alignment
1639 @smallexample @c ada
1640 pragma Component_Alignment (
1641 [Form =>] ALIGNMENT_CHOICE
1642 [, [Name =>] type_LOCAL_NAME]);
1644 ALIGNMENT_CHOICE ::=
1652 Specifies the alignment of components in array or record types.
1653 The meaning of the @var{Form} argument is as follows:
1656 @findex Component_Size
1657 @item Component_Size
1658 Aligns scalar components and subcomponents of the array or record type
1659 on boundaries appropriate to their inherent size (naturally
1660 aligned). For example, 1-byte components are aligned on byte boundaries,
1661 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1662 integer components are aligned on 4-byte boundaries and so on. These
1663 alignment rules correspond to the normal rules for C compilers on all
1664 machines except the VAX@.
1666 @findex Component_Size_4
1667 @item Component_Size_4
1668 Naturally aligns components with a size of four or fewer
1669 bytes. Components that are larger than 4 bytes are placed on the next
1672 @findex Storage_Unit
1674 Specifies that array or record components are byte aligned, i.e.@:
1675 aligned on boundaries determined by the value of the constant
1676 @code{System.Storage_Unit}.
1680 Specifies that array or record components are aligned on default
1681 boundaries, appropriate to the underlying hardware or operating system or
1682 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1683 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1684 the @code{Default} choice is the same as @code{Component_Size} (natural
1689 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1690 refer to a local record or array type, and the specified alignment
1691 choice applies to the specified type. The use of
1692 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1693 @code{Component_Alignment} pragma to be ignored. The use of
1694 @code{Component_Alignment} together with a record representation clause
1695 is only effective for fields not specified by the representation clause.
1697 If the @code{Name} parameter is absent, the pragma can be used as either
1698 a configuration pragma, in which case it applies to one or more units in
1699 accordance with the normal rules for configuration pragmas, or it can be
1700 used within a declarative part, in which case it applies to types that
1701 are declared within this declarative part, or within any nested scope
1702 within this declarative part. In either case it specifies the alignment
1703 to be applied to any record or array type which has otherwise standard
1706 If the alignment for a record or array type is not specified (using
1707 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1708 clause), the GNAT uses the default alignment as described previously.
1710 @node Pragma Contract_Case
1711 @unnumberedsec Pragma Contract_Case
1712 @cindex Contract cases
1713 @findex Contract_Case
1717 @smallexample @c ada
1718 pragma Contract_Case (
1719 [Name =>] static_string_Expression
1720 ,[Mode =>] (Nominal | Robustness)
1721 [, Requires => Boolean_Expression]
1722 [, Ensures => Boolean_Expression]);
1726 The @code{Contract_Case} pragma allows defining fine-grain specifications
1727 that can complement or replace the contract given by a precondition and a
1728 postcondition. Additionally, the @code{Contract_Case} pragma can be used
1729 by testing and formal verification tools. The compiler checks its validity and,
1730 depending on the assertion policy at the point of declaration of the pragma,
1731 it may insert a check in the executable. For code generation, the contract
1734 @smallexample @c ada
1735 pragma Contract_Case (
1745 @smallexample @c ada
1746 pragma Postcondition (not R'Old or else E);
1750 which is also equivalent to (in Ada 2012)
1752 @smallexample @c ada
1753 pragma Postcondition (if R'Old then E);
1757 expressing that, whenever condition @code{R} is satisfied on entry to the
1758 subprogram, condition @code{E} should be fulfilled on exit to the subprogram.
1760 A precondition @code{P} and postcondition @code{Q} can also be
1761 expressed as contract cases:
1763 @smallexample @c ada
1764 pragma Contract_Case (
1765 Name => "Replace precondition",
1769 pragma Contract_Case (
1770 Name => "Replace postcondition",
1776 @code{Contract_Case} pragmas may only appear immediately following the
1777 (separate) declaration of a subprogram in a package declaration, inside
1778 a package spec unit. Only other pragmas may intervene (that is appear
1779 between the subprogram declaration and a contract case).
1781 The compiler checks that boolean expressions given in @code{Requires} and
1782 @code{Ensures} are valid, where the rules for @code{Requires} are the
1783 same as the rule for an expression in @code{Precondition} and the rules
1784 for @code{Ensures} are the same as the rule for an expression in
1785 @code{Postcondition}. In particular, attributes @code{'Old} and
1786 @code{'Result} can only be used within the @code{Ensures}
1787 expression. The following is an example of use within a package spec:
1789 @smallexample @c ada
1790 package Math_Functions is
1792 function Sqrt (Arg : Float) return Float;
1793 pragma Contract_Case (Name => "Small argument",
1795 Requires => Arg < 100,
1796 Ensures => Sqrt'Result < 10);
1802 The meaning of a contract case is that, whenever the associated subprogram is
1803 executed in a context where @code{Requires} holds, then @code{Ensures}
1804 should hold when the subprogram returns. Mode @code{Nominal} indicates
1805 that the input context should also satisfy the precondition of the
1806 subprogram, and the output context should also satisfy its
1807 postcondition. More @code{Robustness} indicates that the precondition and
1808 postcondition of the subprogram should be ignored for this contract case,
1809 which is mostly useful when testing such a contract using a testing tool
1810 that understands contract cases.
1812 @node Pragma Convention_Identifier
1813 @unnumberedsec Pragma Convention_Identifier
1814 @findex Convention_Identifier
1815 @cindex Conventions, synonyms
1819 @smallexample @c ada
1820 pragma Convention_Identifier (
1821 [Name =>] IDENTIFIER,
1822 [Convention =>] convention_IDENTIFIER);
1826 This pragma provides a mechanism for supplying synonyms for existing
1827 convention identifiers. The @code{Name} identifier can subsequently
1828 be used as a synonym for the given convention in other pragmas (including
1829 for example pragma @code{Import} or another @code{Convention_Identifier}
1830 pragma). As an example of the use of this, suppose you had legacy code
1831 which used Fortran77 as the identifier for Fortran. Then the pragma:
1833 @smallexample @c ada
1834 pragma Convention_Identifier (Fortran77, Fortran);
1838 would allow the use of the convention identifier @code{Fortran77} in
1839 subsequent code, avoiding the need to modify the sources. As another
1840 example, you could use this to parameterize convention requirements
1841 according to systems. Suppose you needed to use @code{Stdcall} on
1842 windows systems, and @code{C} on some other system, then you could
1843 define a convention identifier @code{Library} and use a single
1844 @code{Convention_Identifier} pragma to specify which convention
1845 would be used system-wide.
1847 @node Pragma CPP_Class
1848 @unnumberedsec Pragma CPP_Class
1850 @cindex Interfacing with C++
1854 @smallexample @c ada
1855 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1859 The argument denotes an entity in the current declarative region that is
1860 declared as a record type. It indicates that the type corresponds to an
1861 externally declared C++ class type, and is to be laid out the same way
1862 that C++ would lay out the type. If the C++ class has virtual primitives
1863 then the record must be declared as a tagged record type.
1865 Types for which @code{CPP_Class} is specified do not have assignment or
1866 equality operators defined (such operations can be imported or declared
1867 as subprograms as required). Initialization is allowed only by constructor
1868 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1869 limited if not explicitly declared as limited or derived from a limited
1870 type, and an error is issued in that case.
1872 See @ref{Interfacing to C++} for related information.
1874 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1875 for backward compatibility but its functionality is available
1876 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1878 @node Pragma CPP_Constructor
1879 @unnumberedsec Pragma CPP_Constructor
1880 @cindex Interfacing with C++
1881 @findex CPP_Constructor
1885 @smallexample @c ada
1886 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1887 [, [External_Name =>] static_string_EXPRESSION ]
1888 [, [Link_Name =>] static_string_EXPRESSION ]);
1892 This pragma identifies an imported function (imported in the usual way
1893 with pragma @code{Import}) as corresponding to a C++ constructor. If
1894 @code{External_Name} and @code{Link_Name} are not specified then the
1895 @code{Entity} argument is a name that must have been previously mentioned
1896 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1897 must be of one of the following forms:
1901 @code{function @var{Fname} return @var{T}}
1905 @code{function @var{Fname} return @var{T}'Class}
1908 @code{function @var{Fname} (@dots{}) return @var{T}}
1912 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1916 where @var{T} is a limited record type imported from C++ with pragma
1917 @code{Import} and @code{Convention} = @code{CPP}.
1919 The first two forms import the default constructor, used when an object
1920 of type @var{T} is created on the Ada side with no explicit constructor.
1921 The latter two forms cover all the non-default constructors of the type.
1922 See the GNAT users guide for details.
1924 If no constructors are imported, it is impossible to create any objects
1925 on the Ada side and the type is implicitly declared abstract.
1927 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1928 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
1930 See @ref{Interfacing to C++} for more related information.
1932 Note: The use of functions returning class-wide types for constructors is
1933 currently obsolete. They are supported for backward compatibility. The
1934 use of functions returning the type T leave the Ada sources more clear
1935 because the imported C++ constructors always return an object of type T;
1936 that is, they never return an object whose type is a descendant of type T.
1938 @node Pragma CPP_Virtual
1939 @unnumberedsec Pragma CPP_Virtual
1940 @cindex Interfacing to C++
1943 This pragma is now obsolete has has no effect because GNAT generates
1944 the same object layout than the G++ compiler.
1946 See @ref{Interfacing to C++} for related information.
1948 @node Pragma CPP_Vtable
1949 @unnumberedsec Pragma CPP_Vtable
1950 @cindex Interfacing with C++
1953 This pragma is now obsolete has has no effect because GNAT generates
1954 the same object layout than the G++ compiler.
1956 See @ref{Interfacing to C++} for related information.
1959 @unnumberedsec Pragma Debug
1964 @smallexample @c ada
1965 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1967 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1969 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1973 The procedure call argument has the syntactic form of an expression, meeting
1974 the syntactic requirements for pragmas.
1976 If debug pragmas are not enabled or if the condition is present and evaluates
1977 to False, this pragma has no effect. If debug pragmas are enabled, the
1978 semantics of the pragma is exactly equivalent to the procedure call statement
1979 corresponding to the argument with a terminating semicolon. Pragmas are
1980 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1981 intersperse calls to debug procedures in the middle of declarations. Debug
1982 pragmas can be enabled either by use of the command line switch @option{-gnata}
1983 or by use of the configuration pragma @code{Debug_Policy}.
1985 @node Pragma Debug_Policy
1986 @unnumberedsec Pragma Debug_Policy
1987 @findex Debug_Policy
1991 @smallexample @c ada
1992 pragma Debug_Policy (CHECK | DISABLE | IGNORE);
1996 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1997 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1998 This pragma overrides the effect of the @option{-gnata} switch on the
2001 The implementation defined policy @code{DISABLE} is like
2002 @code{IGNORE} except that it completely disables semantic
2003 checking of the argument to @code{pragma Debug}. This may
2004 be useful when the pragma argument references subprograms
2005 in a with'ed package which is replaced by a dummy package
2006 for the final build.
2008 @node Pragma Detect_Blocking
2009 @unnumberedsec Pragma Detect_Blocking
2010 @findex Detect_Blocking
2014 @smallexample @c ada
2015 pragma Detect_Blocking;
2019 This is a configuration pragma that forces the detection of potentially
2020 blocking operations within a protected operation, and to raise Program_Error
2023 @node Pragma Elaboration_Checks
2024 @unnumberedsec Pragma Elaboration_Checks
2025 @cindex Elaboration control
2026 @findex Elaboration_Checks
2030 @smallexample @c ada
2031 pragma Elaboration_Checks (Dynamic | Static);
2035 This is a configuration pragma that provides control over the
2036 elaboration model used by the compilation affected by the
2037 pragma. If the parameter is @code{Dynamic},
2038 then the dynamic elaboration
2039 model described in the Ada Reference Manual is used, as though
2040 the @option{-gnatE} switch had been specified on the command
2041 line. If the parameter is @code{Static}, then the default GNAT static
2042 model is used. This configuration pragma overrides the setting
2043 of the command line. For full details on the elaboration models
2044 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2045 gnat_ugn, @value{EDITION} User's Guide}.
2047 @node Pragma Eliminate
2048 @unnumberedsec Pragma Eliminate
2049 @cindex Elimination of unused subprograms
2054 @smallexample @c ada
2055 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
2056 [Source_Location =>] STRING_LITERAL);
2060 The string literal given for the source location is a string which
2061 specifies the line number of the occurrence of the entity, using
2062 the syntax for SOURCE_TRACE given below:
2064 @smallexample @c ada
2065 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2070 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2072 LINE_NUMBER ::= DIGIT @{DIGIT@}
2076 Spaces around the colon in a @code{Source_Reference} are optional.
2078 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2079 explicit subprogram declaration, where the @code{entity} name in this
2080 designator appears on the source line specified by the source location.
2082 The source trace that is given as the @code{Source_Location} shall obey the
2083 following rules. The @code{FILE_NAME} is the short name (with no directory
2084 information) of an Ada source file, given using exactly the required syntax
2085 for the underlying file system (e.g. case is important if the underlying
2086 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2087 number of the occurrence of the @code{entity}
2088 as a decimal literal without an exponent or point. If an @code{entity} is not
2089 declared in a generic instantiation (this includes generic subprogram
2090 instances), the source trace includes only one source reference. If an entity
2091 is declared inside a generic instantiation, its source trace (when parsing
2092 from left to right) starts with the source location of the declaration of the
2093 entity in the generic unit and ends with the source location of the
2094 instantiation (it is given in square brackets). This approach is recursively
2095 used in case of nested instantiations: the rightmost (nested most deeply in
2096 square brackets) element of the source trace is the location of the outermost
2097 instantiation, the next to left element is the location of the next (first
2098 nested) instantiation in the code of the corresponding generic unit, and so
2099 on, and the leftmost element (that is out of any square brackets) is the
2100 location of the declaration of the entity to eliminate in a generic unit.
2102 Note that the @code{Source_Location} argument specifies which of a set of
2103 similarly named entities is being eliminated, dealing both with overloading,
2104 and also appearence of the same entity name in different scopes.
2106 This pragma indicates that the given entity is not used in the program to be
2107 compiled and built. The effect of the pragma is to allow the compiler to
2108 eliminate the code or data associated with the named entity. Any reference to
2109 an eliminated entity causes a compile-time or link-time error.
2111 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2112 in a system-independent manner, with unused entities eliminated, without
2113 needing to modify the source text. Normally the required set of
2114 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2116 Any source file change that removes, splits, or
2117 adds lines may make the set of Eliminate pragmas invalid because their
2118 @code{Source_Location} argument values may get out of date.
2120 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2121 operation. In this case all the subprograms to which the given operation can
2122 dispatch are considered to be unused (are never called as a result of a direct
2123 or a dispatching call).
2125 @node Pragma Export_Exception
2126 @unnumberedsec Pragma Export_Exception
2128 @findex Export_Exception
2132 @smallexample @c ada
2133 pragma Export_Exception (
2134 [Internal =>] LOCAL_NAME
2135 [, [External =>] EXTERNAL_SYMBOL]
2136 [, [Form =>] Ada | VMS]
2137 [, [Code =>] static_integer_EXPRESSION]);
2141 | static_string_EXPRESSION
2145 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
2146 causes the specified exception to be propagated outside of the Ada program,
2147 so that it can be handled by programs written in other OpenVMS languages.
2148 This pragma establishes an external name for an Ada exception and makes the
2149 name available to the OpenVMS Linker as a global symbol. For further details
2150 on this pragma, see the
2151 DEC Ada Language Reference Manual, section 13.9a3.2.
2153 @node Pragma Export_Function
2154 @unnumberedsec Pragma Export_Function
2155 @cindex Argument passing mechanisms
2156 @findex Export_Function
2161 @smallexample @c ada
2162 pragma Export_Function (
2163 [Internal =>] LOCAL_NAME
2164 [, [External =>] EXTERNAL_SYMBOL]
2165 [, [Parameter_Types =>] PARAMETER_TYPES]
2166 [, [Result_Type =>] result_SUBTYPE_MARK]
2167 [, [Mechanism =>] MECHANISM]
2168 [, [Result_Mechanism =>] MECHANISM_NAME]);
2172 | static_string_EXPRESSION
2177 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2181 | subtype_Name ' Access
2185 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2187 MECHANISM_ASSOCIATION ::=
2188 [formal_parameter_NAME =>] MECHANISM_NAME
2193 | Descriptor [([Class =>] CLASS_NAME)]
2194 | Short_Descriptor [([Class =>] CLASS_NAME)]
2196 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2200 Use this pragma to make a function externally callable and optionally
2201 provide information on mechanisms to be used for passing parameter and
2202 result values. We recommend, for the purposes of improving portability,
2203 this pragma always be used in conjunction with a separate pragma
2204 @code{Export}, which must precede the pragma @code{Export_Function}.
2205 GNAT does not require a separate pragma @code{Export}, but if none is
2206 present, @code{Convention Ada} is assumed, which is usually
2207 not what is wanted, so it is usually appropriate to use this
2208 pragma in conjunction with a @code{Export} or @code{Convention}
2209 pragma that specifies the desired foreign convention.
2210 Pragma @code{Export_Function}
2211 (and @code{Export}, if present) must appear in the same declarative
2212 region as the function to which they apply.
2214 @var{internal_name} must uniquely designate the function to which the
2215 pragma applies. If more than one function name exists of this name in
2216 the declarative part you must use the @code{Parameter_Types} and
2217 @code{Result_Type} parameters is mandatory to achieve the required
2218 unique designation. @var{subtype_mark}s in these parameters must
2219 exactly match the subtypes in the corresponding function specification,
2220 using positional notation to match parameters with subtype marks.
2221 The form with an @code{'Access} attribute can be used to match an
2222 anonymous access parameter.
2225 @cindex Passing by descriptor
2226 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2227 The default behavior for Export_Function is to accept either 64bit or
2228 32bit descriptors unless short_descriptor is specified, then only 32bit
2229 descriptors are accepted.
2231 @cindex Suppressing external name
2232 Special treatment is given if the EXTERNAL is an explicit null
2233 string or a static string expressions that evaluates to the null
2234 string. In this case, no external name is generated. This form
2235 still allows the specification of parameter mechanisms.
2237 @node Pragma Export_Object
2238 @unnumberedsec Pragma Export_Object
2239 @findex Export_Object
2243 @smallexample @c ada
2244 pragma Export_Object
2245 [Internal =>] LOCAL_NAME
2246 [, [External =>] EXTERNAL_SYMBOL]
2247 [, [Size =>] EXTERNAL_SYMBOL]
2251 | static_string_EXPRESSION
2255 This pragma designates an object as exported, and apart from the
2256 extended rules for external symbols, is identical in effect to the use of
2257 the normal @code{Export} pragma applied to an object. You may use a
2258 separate Export pragma (and you probably should from the point of view
2259 of portability), but it is not required. @var{Size} is syntax checked,
2260 but otherwise ignored by GNAT@.
2262 @node Pragma Export_Procedure
2263 @unnumberedsec Pragma Export_Procedure
2264 @findex Export_Procedure
2268 @smallexample @c ada
2269 pragma Export_Procedure (
2270 [Internal =>] LOCAL_NAME
2271 [, [External =>] EXTERNAL_SYMBOL]
2272 [, [Parameter_Types =>] PARAMETER_TYPES]
2273 [, [Mechanism =>] MECHANISM]);
2277 | static_string_EXPRESSION
2282 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2286 | subtype_Name ' Access
2290 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2292 MECHANISM_ASSOCIATION ::=
2293 [formal_parameter_NAME =>] MECHANISM_NAME
2298 | Descriptor [([Class =>] CLASS_NAME)]
2299 | Short_Descriptor [([Class =>] CLASS_NAME)]
2301 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2305 This pragma is identical to @code{Export_Function} except that it
2306 applies to a procedure rather than a function and the parameters
2307 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2308 GNAT does not require a separate pragma @code{Export}, but if none is
2309 present, @code{Convention Ada} is assumed, which is usually
2310 not what is wanted, so it is usually appropriate to use this
2311 pragma in conjunction with a @code{Export} or @code{Convention}
2312 pragma that specifies the desired foreign convention.
2315 @cindex Passing by descriptor
2316 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2317 The default behavior for Export_Procedure is to accept either 64bit or
2318 32bit descriptors unless short_descriptor is specified, then only 32bit
2319 descriptors are accepted.
2321 @cindex Suppressing external name
2322 Special treatment is given if the EXTERNAL is an explicit null
2323 string or a static string expressions that evaluates to the null
2324 string. In this case, no external name is generated. This form
2325 still allows the specification of parameter mechanisms.
2327 @node Pragma Export_Value
2328 @unnumberedsec Pragma Export_Value
2329 @findex Export_Value
2333 @smallexample @c ada
2334 pragma Export_Value (
2335 [Value =>] static_integer_EXPRESSION,
2336 [Link_Name =>] static_string_EXPRESSION);
2340 This pragma serves to export a static integer value for external use.
2341 The first argument specifies the value to be exported. The Link_Name
2342 argument specifies the symbolic name to be associated with the integer
2343 value. This pragma is useful for defining a named static value in Ada
2344 that can be referenced in assembly language units to be linked with
2345 the application. This pragma is currently supported only for the
2346 AAMP target and is ignored for other targets.
2348 @node Pragma Export_Valued_Procedure
2349 @unnumberedsec Pragma Export_Valued_Procedure
2350 @findex Export_Valued_Procedure
2354 @smallexample @c ada
2355 pragma Export_Valued_Procedure (
2356 [Internal =>] LOCAL_NAME
2357 [, [External =>] EXTERNAL_SYMBOL]
2358 [, [Parameter_Types =>] PARAMETER_TYPES]
2359 [, [Mechanism =>] MECHANISM]);
2363 | static_string_EXPRESSION
2368 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2372 | subtype_Name ' Access
2376 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2378 MECHANISM_ASSOCIATION ::=
2379 [formal_parameter_NAME =>] MECHANISM_NAME
2384 | Descriptor [([Class =>] CLASS_NAME)]
2385 | Short_Descriptor [([Class =>] CLASS_NAME)]
2387 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2391 This pragma is identical to @code{Export_Procedure} except that the
2392 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2393 mode @code{OUT}, and externally the subprogram is treated as a function
2394 with this parameter as the result of the function. GNAT provides for
2395 this capability to allow the use of @code{OUT} and @code{IN OUT}
2396 parameters in interfacing to external functions (which are not permitted
2398 GNAT does not require a separate pragma @code{Export}, but if none is
2399 present, @code{Convention Ada} is assumed, which is almost certainly
2400 not what is wanted since the whole point of this pragma is to interface
2401 with foreign language functions, so it is usually appropriate to use this
2402 pragma in conjunction with a @code{Export} or @code{Convention}
2403 pragma that specifies the desired foreign convention.
2406 @cindex Passing by descriptor
2407 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2408 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2409 32bit descriptors unless short_descriptor is specified, then only 32bit
2410 descriptors are accepted.
2412 @cindex Suppressing external name
2413 Special treatment is given if the EXTERNAL is an explicit null
2414 string or a static string expressions that evaluates to the null
2415 string. In this case, no external name is generated. This form
2416 still allows the specification of parameter mechanisms.
2418 @node Pragma Extend_System
2419 @unnumberedsec Pragma Extend_System
2420 @cindex @code{system}, extending
2422 @findex Extend_System
2426 @smallexample @c ada
2427 pragma Extend_System ([Name =>] IDENTIFIER);
2431 This pragma is used to provide backwards compatibility with other
2432 implementations that extend the facilities of package @code{System}. In
2433 GNAT, @code{System} contains only the definitions that are present in
2434 the Ada RM@. However, other implementations, notably the DEC Ada 83
2435 implementation, provide many extensions to package @code{System}.
2437 For each such implementation accommodated by this pragma, GNAT provides a
2438 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2439 implementation, which provides the required additional definitions. You
2440 can use this package in two ways. You can @code{with} it in the normal
2441 way and access entities either by selection or using a @code{use}
2442 clause. In this case no special processing is required.
2444 However, if existing code contains references such as
2445 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2446 definitions provided in package @code{System}, you may use this pragma
2447 to extend visibility in @code{System} in a non-standard way that
2448 provides greater compatibility with the existing code. Pragma
2449 @code{Extend_System} is a configuration pragma whose single argument is
2450 the name of the package containing the extended definition
2451 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2452 control of this pragma will be processed using special visibility
2453 processing that looks in package @code{System.Aux_@var{xxx}} where
2454 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2455 package @code{System}, but not found in package @code{System}.
2457 You can use this pragma either to access a predefined @code{System}
2458 extension supplied with the compiler, for example @code{Aux_DEC} or
2459 you can construct your own extension unit following the above
2460 definition. Note that such a package is a child of @code{System}
2461 and thus is considered part of the implementation. To compile
2462 it you will have to use the appropriate switch for compiling
2464 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2467 @node Pragma Extensions_Allowed
2468 @unnumberedsec Pragma Extensions_Allowed
2469 @cindex Ada Extensions
2470 @cindex GNAT Extensions
2471 @findex Extensions_Allowed
2475 @smallexample @c ada
2476 pragma Extensions_Allowed (On | Off);
2480 This configuration pragma enables or disables the implementation
2481 extension mode (the use of Off as a parameter cancels the effect
2482 of the @option{-gnatX} command switch).
2484 In extension mode, the latest version of the Ada language is
2485 implemented (currently Ada 2012), and in addition a small number
2486 of GNAT specific extensions are recognized as follows:
2489 @item Constrained attribute for generic objects
2490 The @code{Constrained} attribute is permitted for objects of
2491 generic types. The result indicates if the corresponding actual
2496 @node Pragma External
2497 @unnumberedsec Pragma External
2502 @smallexample @c ada
2504 [ Convention =>] convention_IDENTIFIER,
2505 [ Entity =>] LOCAL_NAME
2506 [, [External_Name =>] static_string_EXPRESSION ]
2507 [, [Link_Name =>] static_string_EXPRESSION ]);
2511 This pragma is identical in syntax and semantics to pragma
2512 @code{Export} as defined in the Ada Reference Manual. It is
2513 provided for compatibility with some Ada 83 compilers that
2514 used this pragma for exactly the same purposes as pragma
2515 @code{Export} before the latter was standardized.
2517 @node Pragma External_Name_Casing
2518 @unnumberedsec Pragma External_Name_Casing
2519 @cindex Dec Ada 83 casing compatibility
2520 @cindex External Names, casing
2521 @cindex Casing of External names
2522 @findex External_Name_Casing
2526 @smallexample @c ada
2527 pragma External_Name_Casing (
2528 Uppercase | Lowercase
2529 [, Uppercase | Lowercase | As_Is]);
2533 This pragma provides control over the casing of external names associated
2534 with Import and Export pragmas. There are two cases to consider:
2537 @item Implicit external names
2538 Implicit external names are derived from identifiers. The most common case
2539 arises when a standard Ada Import or Export pragma is used with only two
2542 @smallexample @c ada
2543 pragma Import (C, C_Routine);
2547 Since Ada is a case-insensitive language, the spelling of the identifier in
2548 the Ada source program does not provide any information on the desired
2549 casing of the external name, and so a convention is needed. In GNAT the
2550 default treatment is that such names are converted to all lower case
2551 letters. This corresponds to the normal C style in many environments.
2552 The first argument of pragma @code{External_Name_Casing} can be used to
2553 control this treatment. If @code{Uppercase} is specified, then the name
2554 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2555 then the normal default of all lower case letters will be used.
2557 This same implicit treatment is also used in the case of extended DEC Ada 83
2558 compatible Import and Export pragmas where an external name is explicitly
2559 specified using an identifier rather than a string.
2561 @item Explicit external names
2562 Explicit external names are given as string literals. The most common case
2563 arises when a standard Ada Import or Export pragma is used with three
2566 @smallexample @c ada
2567 pragma Import (C, C_Routine, "C_routine");
2571 In this case, the string literal normally provides the exact casing required
2572 for the external name. The second argument of pragma
2573 @code{External_Name_Casing} may be used to modify this behavior.
2574 If @code{Uppercase} is specified, then the name
2575 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2576 then the name will be forced to all lowercase letters. A specification of
2577 @code{As_Is} provides the normal default behavior in which the casing is
2578 taken from the string provided.
2582 This pragma may appear anywhere that a pragma is valid. In particular, it
2583 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2584 case it applies to all subsequent compilations, or it can be used as a program
2585 unit pragma, in which case it only applies to the current unit, or it can
2586 be used more locally to control individual Import/Export pragmas.
2588 It is primarily intended for use with OpenVMS systems, where many
2589 compilers convert all symbols to upper case by default. For interfacing to
2590 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2593 @smallexample @c ada
2594 pragma External_Name_Casing (Uppercase, Uppercase);
2598 to enforce the upper casing of all external symbols.
2600 @node Pragma Fast_Math
2601 @unnumberedsec Pragma Fast_Math
2606 @smallexample @c ada
2611 This is a configuration pragma which activates a mode in which speed is
2612 considered more important for floating-point operations than absolutely
2613 accurate adherence to the requirements of the standard. Currently the
2614 following operations are affected:
2617 @item Complex Multiplication
2618 The normal simple formula for complex multiplication can result in intermediate
2619 overflows for numbers near the end of the range. The Ada standard requires that
2620 this situation be detected and corrected by scaling, but in Fast_Math mode such
2621 cases will simply result in overflow. Note that to take advantage of this you
2622 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2623 under control of the pragma, rather than use the preinstantiated versions.
2626 @node Pragma Favor_Top_Level
2627 @unnumberedsec Pragma Favor_Top_Level
2628 @findex Favor_Top_Level
2632 @smallexample @c ada
2633 pragma Favor_Top_Level (type_NAME);
2637 The named type must be an access-to-subprogram type. This pragma is an
2638 efficiency hint to the compiler, regarding the use of 'Access or
2639 'Unrestricted_Access on nested (non-library-level) subprograms. The
2640 pragma means that nested subprograms are not used with this type, or
2641 are rare, so that the generated code should be efficient in the
2642 top-level case. When this pragma is used, dynamically generated
2643 trampolines may be used on some targets for nested subprograms.
2644 See also the No_Implicit_Dynamic_Code restriction.
2646 @node Pragma Finalize_Storage_Only
2647 @unnumberedsec Pragma Finalize_Storage_Only
2648 @findex Finalize_Storage_Only
2652 @smallexample @c ada
2653 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2657 This pragma allows the compiler not to emit a Finalize call for objects
2658 defined at the library level. This is mostly useful for types where
2659 finalization is only used to deal with storage reclamation since in most
2660 environments it is not necessary to reclaim memory just before terminating
2661 execution, hence the name.
2663 @node Pragma Float_Representation
2664 @unnumberedsec Pragma Float_Representation
2666 @findex Float_Representation
2670 @smallexample @c ada
2671 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2673 FLOAT_REP ::= VAX_Float | IEEE_Float
2677 In the one argument form, this pragma is a configuration pragma which
2678 allows control over the internal representation chosen for the predefined
2679 floating point types declared in the packages @code{Standard} and
2680 @code{System}. On all systems other than OpenVMS, the argument must
2681 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2682 argument may be @code{VAX_Float} to specify the use of the VAX float
2683 format for the floating-point types in Standard. This requires that
2684 the standard runtime libraries be recompiled.
2686 The two argument form specifies the representation to be used for
2687 the specified floating-point type. On all systems other than OpenVMS,
2689 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2690 argument may be @code{VAX_Float} to specify the use of the VAX float
2695 For digits values up to 6, F float format will be used.
2697 For digits values from 7 to 9, D float format will be used.
2699 For digits values from 10 to 15, G float format will be used.
2701 Digits values above 15 are not allowed.
2705 @unnumberedsec Pragma Ident
2710 @smallexample @c ada
2711 pragma Ident (static_string_EXPRESSION);
2715 This pragma provides a string identification in the generated object file,
2716 if the system supports the concept of this kind of identification string.
2717 This pragma is allowed only in the outermost declarative part or
2718 declarative items of a compilation unit. If more than one @code{Ident}
2719 pragma is given, only the last one processed is effective.
2721 On OpenVMS systems, the effect of the pragma is identical to the effect of
2722 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2723 maximum allowed length is 31 characters, so if it is important to
2724 maintain compatibility with this compiler, you should obey this length
2727 @node Pragma Implemented
2728 @unnumberedsec Pragma Implemented
2733 @smallexample @c ada
2734 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2736 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2740 This is an Ada 2012 representation pragma which applies to protected, task
2741 and synchronized interface primitives. The use of pragma Implemented provides
2742 a way to impose a static requirement on the overriding operation by adhering
2743 to one of the three implementation kids: entry, protected procedure or any of
2746 @smallexample @c ada
2747 type Synch_Iface is synchronized interface;
2748 procedure Prim_Op (Obj : in out Iface) is abstract;
2749 pragma Implemented (Prim_Op, By_Protected_Procedure);
2751 protected type Prot_1 is new Synch_Iface with
2752 procedure Prim_Op; -- Legal
2755 protected type Prot_2 is new Synch_Iface with
2756 entry Prim_Op; -- Illegal
2759 task type Task_Typ is new Synch_Iface with
2760 entry Prim_Op; -- Illegal
2765 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2766 Implemented determines the runtime behavior of the requeue. Implementation kind
2767 By_Entry guarantees that the action of requeueing will proceed from an entry to
2768 another entry. Implementation kind By_Protected_Procedure transforms the
2769 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2770 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2771 the target's overriding subprogram kind.
2773 @node Pragma Implicit_Packing
2774 @unnumberedsec Pragma Implicit_Packing
2775 @findex Implicit_Packing
2779 @smallexample @c ada
2780 pragma Implicit_Packing;
2784 This is a configuration pragma that requests implicit packing for packed
2785 arrays for which a size clause is given but no explicit pragma Pack or
2786 specification of Component_Size is present. It also applies to records
2787 where no record representation clause is present. Consider this example:
2789 @smallexample @c ada
2790 type R is array (0 .. 7) of Boolean;
2795 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2796 does not change the layout of a composite object. So the Size clause in the
2797 above example is normally rejected, since the default layout of the array uses
2798 8-bit components, and thus the array requires a minimum of 64 bits.
2800 If this declaration is compiled in a region of code covered by an occurrence
2801 of the configuration pragma Implicit_Packing, then the Size clause in this
2802 and similar examples will cause implicit packing and thus be accepted. For
2803 this implicit packing to occur, the type in question must be an array of small
2804 components whose size is known at compile time, and the Size clause must
2805 specify the exact size that corresponds to the length of the array multiplied
2806 by the size in bits of the component type.
2807 @cindex Array packing
2809 Similarly, the following example shows the use in the record case
2811 @smallexample @c ada
2813 a, b, c, d, e, f, g, h : boolean;
2820 Without a pragma Pack, each Boolean field requires 8 bits, so the
2821 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2822 sufficient. The use of pragma Implicit_Packing allows this record
2823 declaration to compile without an explicit pragma Pack.
2824 @node Pragma Import_Exception
2825 @unnumberedsec Pragma Import_Exception
2827 @findex Import_Exception
2831 @smallexample @c ada
2832 pragma Import_Exception (
2833 [Internal =>] LOCAL_NAME
2834 [, [External =>] EXTERNAL_SYMBOL]
2835 [, [Form =>] Ada | VMS]
2836 [, [Code =>] static_integer_EXPRESSION]);
2840 | static_string_EXPRESSION
2844 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2845 It allows OpenVMS conditions (for example, from OpenVMS system services or
2846 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2847 The pragma specifies that the exception associated with an exception
2848 declaration in an Ada program be defined externally (in non-Ada code).
2849 For further details on this pragma, see the
2850 DEC Ada Language Reference Manual, section 13.9a.3.1.
2852 @node Pragma Import_Function
2853 @unnumberedsec Pragma Import_Function
2854 @findex Import_Function
2858 @smallexample @c ada
2859 pragma Import_Function (
2860 [Internal =>] LOCAL_NAME,
2861 [, [External =>] EXTERNAL_SYMBOL]
2862 [, [Parameter_Types =>] PARAMETER_TYPES]
2863 [, [Result_Type =>] SUBTYPE_MARK]
2864 [, [Mechanism =>] MECHANISM]
2865 [, [Result_Mechanism =>] MECHANISM_NAME]
2866 [, [First_Optional_Parameter =>] IDENTIFIER]);
2870 | static_string_EXPRESSION
2874 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2878 | subtype_Name ' Access
2882 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2884 MECHANISM_ASSOCIATION ::=
2885 [formal_parameter_NAME =>] MECHANISM_NAME
2890 | Descriptor [([Class =>] CLASS_NAME)]
2891 | Short_Descriptor [([Class =>] CLASS_NAME)]
2893 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2897 This pragma is used in conjunction with a pragma @code{Import} to
2898 specify additional information for an imported function. The pragma
2899 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2900 @code{Import_Function} pragma and both must appear in the same
2901 declarative part as the function specification.
2903 The @var{Internal} argument must uniquely designate
2904 the function to which the
2905 pragma applies. If more than one function name exists of this name in
2906 the declarative part you must use the @code{Parameter_Types} and
2907 @var{Result_Type} parameters to achieve the required unique
2908 designation. Subtype marks in these parameters must exactly match the
2909 subtypes in the corresponding function specification, using positional
2910 notation to match parameters with subtype marks.
2911 The form with an @code{'Access} attribute can be used to match an
2912 anonymous access parameter.
2914 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2915 parameters to specify passing mechanisms for the
2916 parameters and result. If you specify a single mechanism name, it
2917 applies to all parameters. Otherwise you may specify a mechanism on a
2918 parameter by parameter basis using either positional or named
2919 notation. If the mechanism is not specified, the default mechanism
2923 @cindex Passing by descriptor
2924 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2925 The default behavior for Import_Function is to pass a 64bit descriptor
2926 unless short_descriptor is specified, then a 32bit descriptor is passed.
2928 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2929 It specifies that the designated parameter and all following parameters
2930 are optional, meaning that they are not passed at the generated code
2931 level (this is distinct from the notion of optional parameters in Ada
2932 where the parameters are passed anyway with the designated optional
2933 parameters). All optional parameters must be of mode @code{IN} and have
2934 default parameter values that are either known at compile time
2935 expressions, or uses of the @code{'Null_Parameter} attribute.
2937 @node Pragma Import_Object
2938 @unnumberedsec Pragma Import_Object
2939 @findex Import_Object
2943 @smallexample @c ada
2944 pragma Import_Object
2945 [Internal =>] LOCAL_NAME
2946 [, [External =>] EXTERNAL_SYMBOL]
2947 [, [Size =>] EXTERNAL_SYMBOL]);
2951 | static_string_EXPRESSION
2955 This pragma designates an object as imported, and apart from the
2956 extended rules for external symbols, is identical in effect to the use of
2957 the normal @code{Import} pragma applied to an object. Unlike the
2958 subprogram case, you need not use a separate @code{Import} pragma,
2959 although you may do so (and probably should do so from a portability
2960 point of view). @var{size} is syntax checked, but otherwise ignored by
2963 @node Pragma Import_Procedure
2964 @unnumberedsec Pragma Import_Procedure
2965 @findex Import_Procedure
2969 @smallexample @c ada
2970 pragma Import_Procedure (
2971 [Internal =>] LOCAL_NAME
2972 [, [External =>] EXTERNAL_SYMBOL]
2973 [, [Parameter_Types =>] PARAMETER_TYPES]
2974 [, [Mechanism =>] MECHANISM]
2975 [, [First_Optional_Parameter =>] IDENTIFIER]);
2979 | static_string_EXPRESSION
2983 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2987 | subtype_Name ' Access
2991 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2993 MECHANISM_ASSOCIATION ::=
2994 [formal_parameter_NAME =>] MECHANISM_NAME
2999 | Descriptor [([Class =>] CLASS_NAME)]
3000 | Short_Descriptor [([Class =>] CLASS_NAME)]
3002 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3006 This pragma is identical to @code{Import_Function} except that it
3007 applies to a procedure rather than a function and the parameters
3008 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3010 @node Pragma Import_Valued_Procedure
3011 @unnumberedsec Pragma Import_Valued_Procedure
3012 @findex Import_Valued_Procedure
3016 @smallexample @c ada
3017 pragma Import_Valued_Procedure (
3018 [Internal =>] LOCAL_NAME
3019 [, [External =>] EXTERNAL_SYMBOL]
3020 [, [Parameter_Types =>] PARAMETER_TYPES]
3021 [, [Mechanism =>] MECHANISM]
3022 [, [First_Optional_Parameter =>] IDENTIFIER]);
3026 | static_string_EXPRESSION
3030 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3034 | subtype_Name ' Access
3038 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3040 MECHANISM_ASSOCIATION ::=
3041 [formal_parameter_NAME =>] MECHANISM_NAME
3046 | Descriptor [([Class =>] CLASS_NAME)]
3047 | Short_Descriptor [([Class =>] CLASS_NAME)]
3049 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3053 This pragma is identical to @code{Import_Procedure} except that the
3054 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3055 mode @code{OUT}, and externally the subprogram is treated as a function
3056 with this parameter as the result of the function. The purpose of this
3057 capability is to allow the use of @code{OUT} and @code{IN OUT}
3058 parameters in interfacing to external functions (which are not permitted
3059 in Ada functions). You may optionally use the @code{Mechanism}
3060 parameters to specify passing mechanisms for the parameters.
3061 If you specify a single mechanism name, it applies to all parameters.
3062 Otherwise you may specify a mechanism on a parameter by parameter
3063 basis using either positional or named notation. If the mechanism is not
3064 specified, the default mechanism is used.
3066 Note that it is important to use this pragma in conjunction with a separate
3067 pragma Import that specifies the desired convention, since otherwise the
3068 default convention is Ada, which is almost certainly not what is required.
3070 @node Pragma Initialize_Scalars
3071 @unnumberedsec Pragma Initialize_Scalars
3072 @findex Initialize_Scalars
3073 @cindex debugging with Initialize_Scalars
3077 @smallexample @c ada
3078 pragma Initialize_Scalars;
3082 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3083 two important differences. First, there is no requirement for the pragma
3084 to be used uniformly in all units of a partition, in particular, it is fine
3085 to use this just for some or all of the application units of a partition,
3086 without needing to recompile the run-time library.
3088 In the case where some units are compiled with the pragma, and some without,
3089 then a declaration of a variable where the type is defined in package
3090 Standard or is locally declared will always be subject to initialization,
3091 as will any declaration of a scalar variable. For composite variables,
3092 whether the variable is initialized may also depend on whether the package
3093 in which the type of the variable is declared is compiled with the pragma.
3095 The other important difference is that you can control the value used
3096 for initializing scalar objects. At bind time, you can select several
3097 options for initialization. You can
3098 initialize with invalid values (similar to Normalize_Scalars, though for
3099 Initialize_Scalars it is not always possible to determine the invalid
3100 values in complex cases like signed component fields with non-standard
3101 sizes). You can also initialize with high or
3102 low values, or with a specified bit pattern. See the users guide for binder
3103 options for specifying these cases.
3105 This means that you can compile a program, and then without having to
3106 recompile the program, you can run it with different values being used
3107 for initializing otherwise uninitialized values, to test if your program
3108 behavior depends on the choice. Of course the behavior should not change,
3109 and if it does, then most likely you have an erroneous reference to an
3110 uninitialized value.
3112 It is even possible to change the value at execution time eliminating even
3113 the need to rebind with a different switch using an environment variable.
3114 See the GNAT users guide for details.
3116 Note that pragma @code{Initialize_Scalars} is particularly useful in
3117 conjunction with the enhanced validity checking that is now provided
3118 in GNAT, which checks for invalid values under more conditions.
3119 Using this feature (see description of the @option{-gnatV} flag in the
3120 users guide) in conjunction with pragma @code{Initialize_Scalars}
3121 provides a powerful new tool to assist in the detection of problems
3122 caused by uninitialized variables.
3124 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3125 effect on the generated code. This may cause your code to be
3126 substantially larger. It may also cause an increase in the amount
3127 of stack required, so it is probably a good idea to turn on stack
3128 checking (see description of stack checking in the GNAT users guide)
3129 when using this pragma.
3131 @node Pragma Inline_Always
3132 @unnumberedsec Pragma Inline_Always
3133 @findex Inline_Always
3137 @smallexample @c ada
3138 pragma Inline_Always (NAME [, NAME]);
3142 Similar to pragma @code{Inline} except that inlining is not subject to
3143 the use of option @option{-gnatn} and the inlining happens regardless of
3144 whether this option is used.
3146 @node Pragma Inline_Generic
3147 @unnumberedsec Pragma Inline_Generic
3148 @findex Inline_Generic
3152 @smallexample @c ada
3153 pragma Inline_Generic (generic_package_NAME);
3157 This is implemented for compatibility with DEC Ada 83 and is recognized,
3158 but otherwise ignored, by GNAT@. All generic instantiations are inlined
3159 by default when using GNAT@.
3161 @node Pragma Interface
3162 @unnumberedsec Pragma Interface
3167 @smallexample @c ada
3169 [Convention =>] convention_identifier,
3170 [Entity =>] local_NAME
3171 [, [External_Name =>] static_string_expression]
3172 [, [Link_Name =>] static_string_expression]);
3176 This pragma is identical in syntax and semantics to
3177 the standard Ada pragma @code{Import}. It is provided for compatibility
3178 with Ada 83. The definition is upwards compatible both with pragma
3179 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3180 with some extended implementations of this pragma in certain Ada 83
3181 implementations. The only difference between pragma @code{Interface}
3182 and pragma @code{Import} is that there is special circuitry to allow
3183 both pragmas to appear for the same subprogram entity (normally it
3184 is illegal to have multiple @code{Import} pragmas. This is useful in
3185 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3188 @node Pragma Interface_Name
3189 @unnumberedsec Pragma Interface_Name
3190 @findex Interface_Name
3194 @smallexample @c ada
3195 pragma Interface_Name (
3196 [Entity =>] LOCAL_NAME
3197 [, [External_Name =>] static_string_EXPRESSION]
3198 [, [Link_Name =>] static_string_EXPRESSION]);
3202 This pragma provides an alternative way of specifying the interface name
3203 for an interfaced subprogram, and is provided for compatibility with Ada
3204 83 compilers that use the pragma for this purpose. You must provide at
3205 least one of @var{External_Name} or @var{Link_Name}.
3207 @node Pragma Interrupt_Handler
3208 @unnumberedsec Pragma Interrupt_Handler
3209 @findex Interrupt_Handler
3213 @smallexample @c ada
3214 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3218 This program unit pragma is supported for parameterless protected procedures
3219 as described in Annex C of the Ada Reference Manual. On the AAMP target
3220 the pragma can also be specified for nonprotected parameterless procedures
3221 that are declared at the library level (which includes procedures
3222 declared at the top level of a library package). In the case of AAMP,
3223 when this pragma is applied to a nonprotected procedure, the instruction
3224 @code{IERET} is generated for returns from the procedure, enabling
3225 maskable interrupts, in place of the normal return instruction.
3227 @node Pragma Interrupt_State
3228 @unnumberedsec Pragma Interrupt_State
3229 @findex Interrupt_State
3233 @smallexample @c ada
3234 pragma Interrupt_State
3236 [State =>] SYSTEM | RUNTIME | USER);
3240 Normally certain interrupts are reserved to the implementation. Any attempt
3241 to attach an interrupt causes Program_Error to be raised, as described in
3242 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3243 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3244 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3245 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3246 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3247 Ada exceptions, or used to implement run-time functions such as the
3248 @code{abort} statement and stack overflow checking.
3250 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3251 such uses of interrupts. It subsumes the functionality of pragma
3252 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3253 available on Windows or VMS. On all other platforms than VxWorks,
3254 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3255 and may be used to mark interrupts required by the board support package
3258 Interrupts can be in one of three states:
3262 The interrupt is reserved (no Ada handler can be installed), and the
3263 Ada run-time may not install a handler. As a result you are guaranteed
3264 standard system default action if this interrupt is raised.
3268 The interrupt is reserved (no Ada handler can be installed). The run time
3269 is allowed to install a handler for internal control purposes, but is
3270 not required to do so.
3274 The interrupt is unreserved. The user may install a handler to provide
3279 These states are the allowed values of the @code{State} parameter of the
3280 pragma. The @code{Name} parameter is a value of the type
3281 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3282 @code{Ada.Interrupts.Names}.
3284 This is a configuration pragma, and the binder will check that there
3285 are no inconsistencies between different units in a partition in how a
3286 given interrupt is specified. It may appear anywhere a pragma is legal.
3288 The effect is to move the interrupt to the specified state.
3290 By declaring interrupts to be SYSTEM, you guarantee the standard system
3291 action, such as a core dump.
3293 By declaring interrupts to be USER, you guarantee that you can install
3296 Note that certain signals on many operating systems cannot be caught and
3297 handled by applications. In such cases, the pragma is ignored. See the
3298 operating system documentation, or the value of the array @code{Reserved}
3299 declared in the spec of package @code{System.OS_Interface}.
3301 Overriding the default state of signals used by the Ada runtime may interfere
3302 with an application's runtime behavior in the cases of the synchronous signals,
3303 and in the case of the signal used to implement the @code{abort} statement.
3305 @node Pragma Invariant
3306 @unnumberedsec Pragma Invariant
3311 @smallexample @c ada
3313 ([Entity =>] private_type_LOCAL_NAME,
3314 [Check =>] EXPRESSION
3315 [,[Message =>] String_Expression]);
3319 This pragma provides exactly the same capabilities as the Type_Invariant aspect
3320 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
3321 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
3322 requires the use of the aspect syntax, which is not available except in 2012
3323 mode, it is not possible to use the Type_Invariant aspect in earlier versions
3324 of Ada. However the Invariant pragma may be used in any version of Ada. Also
3325 note that the aspect Invariant is a synonym in GNAT for the aspect
3326 Type_Invariant, but there is no pragma Type_Invariant.
3328 The pragma must appear within the visible part of the package specification,
3329 after the type to which its Entity argument appears. As with the Invariant
3330 aspect, the Check expression is not analyzed until the end of the visible
3331 part of the package, so it may contain forward references. The Message
3332 argument, if present, provides the exception message used if the invariant
3333 is violated. If no Message parameter is provided, a default message that
3334 identifies the line on which the pragma appears is used.
3336 It is permissible to have multiple Invariants for the same type entity, in
3337 which case they are and'ed together. It is permissible to use this pragma
3338 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3339 invariant pragma for the same entity.
3341 For further details on the use of this pragma, see the Ada 2012 documentation
3342 of the Type_Invariant aspect.
3344 @node Pragma Keep_Names
3345 @unnumberedsec Pragma Keep_Names
3350 @smallexample @c ada
3351 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3355 The @var{LOCAL_NAME} argument
3356 must refer to an enumeration first subtype
3357 in the current declarative part. The effect is to retain the enumeration
3358 literal names for use by @code{Image} and @code{Value} even if a global
3359 @code{Discard_Names} pragma applies. This is useful when you want to
3360 generally suppress enumeration literal names and for example you therefore
3361 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3362 want to retain the names for specific enumeration types.
3364 @node Pragma License
3365 @unnumberedsec Pragma License
3367 @cindex License checking
3371 @smallexample @c ada
3372 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3376 This pragma is provided to allow automated checking for appropriate license
3377 conditions with respect to the standard and modified GPL@. A pragma
3378 @code{License}, which is a configuration pragma that typically appears at
3379 the start of a source file or in a separate @file{gnat.adc} file, specifies
3380 the licensing conditions of a unit as follows:
3384 This is used for a unit that can be freely used with no license restrictions.
3385 Examples of such units are public domain units, and units from the Ada
3389 This is used for a unit that is licensed under the unmodified GPL, and which
3390 therefore cannot be @code{with}'ed by a restricted unit.
3393 This is used for a unit licensed under the GNAT modified GPL that includes
3394 a special exception paragraph that specifically permits the inclusion of
3395 the unit in programs without requiring the entire program to be released
3399 This is used for a unit that is restricted in that it is not permitted to
3400 depend on units that are licensed under the GPL@. Typical examples are
3401 proprietary code that is to be released under more restrictive license
3402 conditions. Note that restricted units are permitted to @code{with} units
3403 which are licensed under the modified GPL (this is the whole point of the
3409 Normally a unit with no @code{License} pragma is considered to have an
3410 unknown license, and no checking is done. However, standard GNAT headers
3411 are recognized, and license information is derived from them as follows.
3415 A GNAT license header starts with a line containing 78 hyphens. The following
3416 comment text is searched for the appearance of any of the following strings.
3418 If the string ``GNU General Public License'' is found, then the unit is assumed
3419 to have GPL license, unless the string ``As a special exception'' follows, in
3420 which case the license is assumed to be modified GPL@.
3422 If one of the strings
3423 ``This specification is adapted from the Ada Semantic Interface'' or
3424 ``This specification is derived from the Ada Reference Manual'' is found
3425 then the unit is assumed to be unrestricted.
3429 These default actions means that a program with a restricted license pragma
3430 will automatically get warnings if a GPL unit is inappropriately
3431 @code{with}'ed. For example, the program:
3433 @smallexample @c ada
3436 procedure Secret_Stuff is
3442 if compiled with pragma @code{License} (@code{Restricted}) in a
3443 @file{gnat.adc} file will generate the warning:
3448 >>> license of withed unit "Sem_Ch3" is incompatible
3450 2. with GNAT.Sockets;
3451 3. procedure Secret_Stuff is
3455 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3456 compiler and is licensed under the
3457 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3458 run time, and is therefore licensed under the modified GPL@.
3460 @node Pragma Link_With
3461 @unnumberedsec Pragma Link_With
3466 @smallexample @c ada
3467 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3471 This pragma is provided for compatibility with certain Ada 83 compilers.
3472 It has exactly the same effect as pragma @code{Linker_Options} except
3473 that spaces occurring within one of the string expressions are treated
3474 as separators. For example, in the following case:
3476 @smallexample @c ada
3477 pragma Link_With ("-labc -ldef");
3481 results in passing the strings @code{-labc} and @code{-ldef} as two
3482 separate arguments to the linker. In addition pragma Link_With allows
3483 multiple arguments, with the same effect as successive pragmas.
3485 @node Pragma Linker_Alias
3486 @unnumberedsec Pragma Linker_Alias
3487 @findex Linker_Alias
3491 @smallexample @c ada
3492 pragma Linker_Alias (
3493 [Entity =>] LOCAL_NAME,
3494 [Target =>] static_string_EXPRESSION);
3498 @var{LOCAL_NAME} must refer to an object that is declared at the library
3499 level. This pragma establishes the given entity as a linker alias for the
3500 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3501 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3502 @var{static_string_EXPRESSION} in the object file, that is to say no space
3503 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3504 to the same address as @var{static_string_EXPRESSION} by the linker.
3506 The actual linker name for the target must be used (e.g.@: the fully
3507 encoded name with qualification in Ada, or the mangled name in C++),
3508 or it must be declared using the C convention with @code{pragma Import}
3509 or @code{pragma Export}.
3511 Not all target machines support this pragma. On some of them it is accepted
3512 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3514 @smallexample @c ada
3515 -- Example of the use of pragma Linker_Alias
3519 pragma Export (C, i);
3521 new_name_for_i : Integer;
3522 pragma Linker_Alias (new_name_for_i, "i");
3526 @node Pragma Linker_Constructor
3527 @unnumberedsec Pragma Linker_Constructor
3528 @findex Linker_Constructor
3532 @smallexample @c ada
3533 pragma Linker_Constructor (procedure_LOCAL_NAME);
3537 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3538 is declared at the library level. A procedure to which this pragma is
3539 applied will be treated as an initialization routine by the linker.
3540 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3541 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3542 of the executable is called (or immediately after the shared library is
3543 loaded if the procedure is linked in a shared library), in particular
3544 before the Ada run-time environment is set up.
3546 Because of these specific contexts, the set of operations such a procedure
3547 can perform is very limited and the type of objects it can manipulate is
3548 essentially restricted to the elementary types. In particular, it must only
3549 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3551 This pragma is used by GNAT to implement auto-initialization of shared Stand
3552 Alone Libraries, which provides a related capability without the restrictions
3553 listed above. Where possible, the use of Stand Alone Libraries is preferable
3554 to the use of this pragma.
3556 @node Pragma Linker_Destructor
3557 @unnumberedsec Pragma Linker_Destructor
3558 @findex Linker_Destructor
3562 @smallexample @c ada
3563 pragma Linker_Destructor (procedure_LOCAL_NAME);
3567 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3568 is declared at the library level. A procedure to which this pragma is
3569 applied will be treated as a finalization routine by the linker.
3570 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3571 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3572 of the executable has exited (or immediately before the shared library
3573 is unloaded if the procedure is linked in a shared library), in particular
3574 after the Ada run-time environment is shut down.
3576 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3577 because of these specific contexts.
3579 @node Pragma Linker_Section
3580 @unnumberedsec Pragma Linker_Section
3581 @findex Linker_Section
3585 @smallexample @c ada
3586 pragma Linker_Section (
3587 [Entity =>] LOCAL_NAME,
3588 [Section =>] static_string_EXPRESSION);
3592 @var{LOCAL_NAME} must refer to an object that is declared at the library
3593 level. This pragma specifies the name of the linker section for the given
3594 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3595 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3596 section of the executable (assuming the linker doesn't rename the section).
3598 The compiler normally places library-level objects in standard sections
3599 depending on their type: procedures and functions generally go in the
3600 @code{.text} section, initialized variables in the @code{.data} section
3601 and uninitialized variables in the @code{.bss} section.
3603 Other, special sections may exist on given target machines to map special
3604 hardware, for example I/O ports or flash memory. This pragma is a means to
3605 defer the final layout of the executable to the linker, thus fully working
3606 at the symbolic level with the compiler.
3608 Some file formats do not support arbitrary sections so not all target
3609 machines support this pragma. The use of this pragma may cause a program
3610 execution to be erroneous if it is used to place an entity into an
3611 inappropriate section (e.g.@: a modified variable into the @code{.text}
3612 section). See also @code{pragma Persistent_BSS}.
3614 @smallexample @c ada
3615 -- Example of the use of pragma Linker_Section
3619 pragma Volatile (Port_A);
3620 pragma Linker_Section (Port_A, ".bss.port_a");
3623 pragma Volatile (Port_B);
3624 pragma Linker_Section (Port_B, ".bss.port_b");
3628 @node Pragma Long_Float
3629 @unnumberedsec Pragma Long_Float
3635 @smallexample @c ada
3636 pragma Long_Float (FLOAT_FORMAT);
3638 FLOAT_FORMAT ::= D_Float | G_Float
3642 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3643 It allows control over the internal representation chosen for the predefined
3644 type @code{Long_Float} and for floating point type representations with
3645 @code{digits} specified in the range 7 through 15.
3646 For further details on this pragma, see the
3647 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3648 this pragma, the standard runtime libraries must be recompiled.
3650 @node Pragma Machine_Attribute
3651 @unnumberedsec Pragma Machine_Attribute
3652 @findex Machine_Attribute
3656 @smallexample @c ada
3657 pragma Machine_Attribute (
3658 [Entity =>] LOCAL_NAME,
3659 [Attribute_Name =>] static_string_EXPRESSION
3660 [, [Info =>] static_EXPRESSION] );
3664 Machine-dependent attributes can be specified for types and/or
3665 declarations. This pragma is semantically equivalent to
3666 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3667 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3668 in GNU C, where @code{@var{attribute_name}} is recognized by the
3669 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3670 specific macro. A string literal for the optional parameter @var{info}
3671 is transformed into an identifier, which may make this pragma unusable
3672 for some attributes. @xref{Target Attributes,, Defining target-specific
3673 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3674 Internals}, further information.
3677 @unnumberedsec Pragma Main
3683 @smallexample @c ada
3685 (MAIN_OPTION [, MAIN_OPTION]);
3688 [Stack_Size =>] static_integer_EXPRESSION
3689 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3690 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3694 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3695 no effect in GNAT, other than being syntax checked.
3697 @node Pragma Main_Storage
3698 @unnumberedsec Pragma Main_Storage
3700 @findex Main_Storage
3704 @smallexample @c ada
3706 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3708 MAIN_STORAGE_OPTION ::=
3709 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3710 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3714 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3715 no effect in GNAT, other than being syntax checked. Note that the pragma
3716 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3718 @node Pragma No_Body
3719 @unnumberedsec Pragma No_Body
3724 @smallexample @c ada
3729 There are a number of cases in which a package spec does not require a body,
3730 and in fact a body is not permitted. GNAT will not permit the spec to be
3731 compiled if there is a body around. The pragma No_Body allows you to provide
3732 a body file, even in a case where no body is allowed. The body file must
3733 contain only comments and a single No_Body pragma. This is recognized by
3734 the compiler as indicating that no body is logically present.
3736 This is particularly useful during maintenance when a package is modified in
3737 such a way that a body needed before is no longer needed. The provision of a
3738 dummy body with a No_Body pragma ensures that there is no interference from
3739 earlier versions of the package body.
3741 @node Pragma No_Return
3742 @unnumberedsec Pragma No_Return
3747 @smallexample @c ada
3748 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3752 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3753 declarations in the current declarative part. A procedure to which this
3754 pragma is applied may not contain any explicit @code{return} statements.
3755 In addition, if the procedure contains any implicit returns from falling
3756 off the end of a statement sequence, then execution of that implicit
3757 return will cause Program_Error to be raised.
3759 One use of this pragma is to identify procedures whose only purpose is to raise
3760 an exception. Another use of this pragma is to suppress incorrect warnings
3761 about missing returns in functions, where the last statement of a function
3762 statement sequence is a call to such a procedure.
3764 Note that in Ada 2005 mode, this pragma is part of the language, and is
3765 identical in effect to the pragma as implemented in Ada 95 mode.
3767 @node Pragma No_Strict_Aliasing
3768 @unnumberedsec Pragma No_Strict_Aliasing
3769 @findex No_Strict_Aliasing
3773 @smallexample @c ada
3774 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3778 @var{type_LOCAL_NAME} must refer to an access type
3779 declaration in the current declarative part. The effect is to inhibit
3780 strict aliasing optimization for the given type. The form with no
3781 arguments is a configuration pragma which applies to all access types
3782 declared in units to which the pragma applies. For a detailed
3783 description of the strict aliasing optimization, and the situations
3784 in which it must be suppressed, see @ref{Optimization and Strict
3785 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3787 This pragma currently has no effects on access to unconstrained array types.
3789 @node Pragma Normalize_Scalars
3790 @unnumberedsec Pragma Normalize_Scalars
3791 @findex Normalize_Scalars
3795 @smallexample @c ada
3796 pragma Normalize_Scalars;
3800 This is a language defined pragma which is fully implemented in GNAT@. The
3801 effect is to cause all scalar objects that are not otherwise initialized
3802 to be initialized. The initial values are implementation dependent and
3806 @item Standard.Character
3808 Objects whose root type is Standard.Character are initialized to
3809 Character'Last unless the subtype range excludes NUL (in which case
3810 NUL is used). This choice will always generate an invalid value if
3813 @item Standard.Wide_Character
3815 Objects whose root type is Standard.Wide_Character are initialized to
3816 Wide_Character'Last unless the subtype range excludes NUL (in which case
3817 NUL is used). This choice will always generate an invalid value if
3820 @item Standard.Wide_Wide_Character
3822 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3823 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3824 which case NUL is used). This choice will always generate an invalid value if
3829 Objects of an integer type are treated differently depending on whether
3830 negative values are present in the subtype. If no negative values are
3831 present, then all one bits is used as the initial value except in the
3832 special case where zero is excluded from the subtype, in which case
3833 all zero bits are used. This choice will always generate an invalid
3834 value if one exists.
3836 For subtypes with negative values present, the largest negative number
3837 is used, except in the unusual case where this largest negative number
3838 is in the subtype, and the largest positive number is not, in which case
3839 the largest positive value is used. This choice will always generate
3840 an invalid value if one exists.
3842 @item Floating-Point Types
3843 Objects of all floating-point types are initialized to all 1-bits. For
3844 standard IEEE format, this corresponds to a NaN (not a number) which is
3845 indeed an invalid value.
3847 @item Fixed-Point Types
3848 Objects of all fixed-point types are treated as described above for integers,
3849 with the rules applying to the underlying integer value used to represent
3850 the fixed-point value.
3853 Objects of a modular type are initialized to all one bits, except in
3854 the special case where zero is excluded from the subtype, in which
3855 case all zero bits are used. This choice will always generate an
3856 invalid value if one exists.
3858 @item Enumeration types
3859 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3860 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3861 whose Pos value is zero, in which case a code of zero is used. This choice
3862 will always generate an invalid value if one exists.
3866 @node Pragma Obsolescent
3867 @unnumberedsec Pragma Obsolescent
3872 @smallexample @c ada
3875 pragma Obsolescent (
3876 [Message =>] static_string_EXPRESSION
3877 [,[Version =>] Ada_05]]);
3879 pragma Obsolescent (
3881 [,[Message =>] static_string_EXPRESSION
3882 [,[Version =>] Ada_05]] );
3886 This pragma can occur immediately following a declaration of an entity,
3887 including the case of a record component. If no Entity argument is present,
3888 then this declaration is the one to which the pragma applies. If an Entity
3889 parameter is present, it must either match the name of the entity in this
3890 declaration, or alternatively, the pragma can immediately follow an enumeration
3891 type declaration, where the Entity argument names one of the enumeration
3894 This pragma is used to indicate that the named entity
3895 is considered obsolescent and should not be used. Typically this is
3896 used when an API must be modified by eventually removing or modifying
3897 existing subprograms or other entities. The pragma can be used at an
3898 intermediate stage when the entity is still present, but will be
3901 The effect of this pragma is to output a warning message on a reference to
3902 an entity thus marked that the subprogram is obsolescent if the appropriate
3903 warning option in the compiler is activated. If the Message parameter is
3904 present, then a second warning message is given containing this text. In
3905 addition, a reference to the entity is considered to be a violation of pragma
3906 Restrictions (No_Obsolescent_Features).
3908 This pragma can also be used as a program unit pragma for a package,
3909 in which case the entity name is the name of the package, and the
3910 pragma indicates that the entire package is considered
3911 obsolescent. In this case a client @code{with}'ing such a package
3912 violates the restriction, and the @code{with} statement is
3913 flagged with warnings if the warning option is set.
3915 If the Version parameter is present (which must be exactly
3916 the identifier Ada_05, no other argument is allowed), then the
3917 indication of obsolescence applies only when compiling in Ada 2005
3918 mode. This is primarily intended for dealing with the situations
3919 in the predefined library where subprograms or packages
3920 have become defined as obsolescent in Ada 2005
3921 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3923 The following examples show typical uses of this pragma:
3925 @smallexample @c ada
3927 pragma Obsolescent (p, Message => "use pp instead of p");
3932 pragma Obsolescent ("use q2new instead");
3934 type R is new integer;
3937 Message => "use RR in Ada 2005",
3947 type E is (a, bc, 'd', quack);
3948 pragma Obsolescent (Entity => bc)
3949 pragma Obsolescent (Entity => 'd')
3952 (a, b : character) return character;
3953 pragma Obsolescent (Entity => "+");
3958 Note that, as for all pragmas, if you use a pragma argument identifier,
3959 then all subsequent parameters must also use a pragma argument identifier.
3960 So if you specify "Entity =>" for the Entity argument, and a Message
3961 argument is present, it must be preceded by "Message =>".
3963 @node Pragma Optimize_Alignment
3964 @unnumberedsec Pragma Optimize_Alignment
3965 @findex Optimize_Alignment
3966 @cindex Alignment, default settings
3970 @smallexample @c ada
3971 pragma Optimize_Alignment (TIME | SPACE | OFF);
3975 This is a configuration pragma which affects the choice of default alignments
3976 for types where no alignment is explicitly specified. There is a time/space
3977 trade-off in the selection of these values. Large alignments result in more
3978 efficient code, at the expense of larger data space, since sizes have to be
3979 increased to match these alignments. Smaller alignments save space, but the
3980 access code is slower. The normal choice of default alignments (which is what
3981 you get if you do not use this pragma, or if you use an argument of OFF),
3982 tries to balance these two requirements.
3984 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3985 First any packed record is given an alignment of 1. Second, if a size is given
3986 for the type, then the alignment is chosen to avoid increasing this size. For
3989 @smallexample @c ada
3999 In the default mode, this type gets an alignment of 4, so that access to the
4000 Integer field X are efficient. But this means that objects of the type end up
4001 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4002 allowed to be bigger than the size of the type, but it can waste space if for
4003 example fields of type R appear in an enclosing record. If the above type is
4004 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4006 Specifying TIME causes larger default alignments to be chosen in the case of
4007 small types with sizes that are not a power of 2. For example, consider:
4009 @smallexample @c ada
4021 The default alignment for this record is normally 1, but if this type is
4022 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
4023 to 4, which wastes space for objects of the type, since they are now 4 bytes
4024 long, but results in more efficient access when the whole record is referenced.
4026 As noted above, this is a configuration pragma, and there is a requirement
4027 that all units in a partition be compiled with a consistent setting of the
4028 optimization setting. This would normally be achieved by use of a configuration
4029 pragma file containing the appropriate setting. The exception to this rule is
4030 that units with an explicit configuration pragma in the same file as the source
4031 unit are excluded from the consistency check, as are all predefined units. The
4032 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4033 pragma appears at the start of the file.
4035 @node Pragma Ordered
4036 @unnumberedsec Pragma Ordered
4038 @findex pragma @code{Ordered}
4042 @smallexample @c ada
4043 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4047 Most enumeration types are from a conceptual point of view unordered.
4048 For example, consider:
4050 @smallexample @c ada
4051 type Color is (Red, Blue, Green, Yellow);
4055 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
4056 but really these relations make no sense; the enumeration type merely
4057 specifies a set of possible colors, and the order is unimportant.
4059 For unordered enumeration types, it is generally a good idea if
4060 clients avoid comparisons (other than equality or inequality) and
4061 explicit ranges. (A @emph{client} is a unit where the type is referenced,
4062 other than the unit where the type is declared, its body, and its subunits.)
4063 For example, if code buried in some client says:
4065 @smallexample @c ada
4066 if Current_Color < Yellow then ...
4067 if Current_Color in Blue .. Green then ...
4071 then the client code is relying on the order, which is undesirable.
4072 It makes the code hard to read and creates maintenance difficulties if
4073 entries have to be added to the enumeration type. Instead,
4074 the code in the client should list the possibilities, or an
4075 appropriate subtype should be declared in the unit that declares
4076 the original enumeration type. E.g., the following subtype could
4077 be declared along with the type @code{Color}:
4079 @smallexample @c ada
4080 subtype RBG is Color range Red .. Green;
4084 and then the client could write:
4086 @smallexample @c ada
4087 if Current_Color in RBG then ...
4088 if Current_Color = Blue or Current_Color = Green then ...
4092 However, some enumeration types are legitimately ordered from a conceptual
4093 point of view. For example, if you declare:
4095 @smallexample @c ada
4096 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
4100 then the ordering imposed by the language is reasonable, and
4101 clients can depend on it, writing for example:
4103 @smallexample @c ada
4104 if D in Mon .. Fri then ...
4109 The pragma @option{Ordered} is provided to mark enumeration types that
4110 are conceptually ordered, alerting the reader that clients may depend
4111 on the ordering. GNAT provides a pragma to mark enumerations as ordered
4112 rather than one to mark them as unordered, since in our experience,
4113 the great majority of enumeration types are conceptually unordered.
4115 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
4116 and @code{Wide_Wide_Character}
4117 are considered to be ordered types, so each is declared with a
4118 pragma @code{Ordered} in package @code{Standard}.
4120 Normally pragma @code{Ordered} serves only as documentation and a guide for
4121 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
4122 requests warnings for inappropriate uses (comparisons and explicit
4123 subranges) for unordered types. If this switch is used, then any
4124 enumeration type not marked with pragma @code{Ordered} will be considered
4125 as unordered, and will generate warnings for inappropriate uses.
4127 For additional information please refer to the description of the
4128 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
4130 @node Pragma Passive
4131 @unnumberedsec Pragma Passive
4136 @smallexample @c ada
4137 pragma Passive [(Semaphore | No)];
4141 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
4142 compatibility with DEC Ada 83 implementations, where it is used within a
4143 task definition to request that a task be made passive. If the argument
4144 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
4145 treats the pragma as an assertion that the containing task is passive
4146 and that optimization of context switch with this task is permitted and
4147 desired. If the argument @code{No} is present, the task must not be
4148 optimized. GNAT does not attempt to optimize any tasks in this manner
4149 (since protected objects are available in place of passive tasks).
4151 @node Pragma Persistent_BSS
4152 @unnumberedsec Pragma Persistent_BSS
4153 @findex Persistent_BSS
4157 @smallexample @c ada
4158 pragma Persistent_BSS [(LOCAL_NAME)]
4162 This pragma allows selected objects to be placed in the @code{.persistent_bss}
4163 section. On some targets the linker and loader provide for special
4164 treatment of this section, allowing a program to be reloaded without
4165 affecting the contents of this data (hence the name persistent).
4167 There are two forms of usage. If an argument is given, it must be the
4168 local name of a library level object, with no explicit initialization
4169 and whose type is potentially persistent. If no argument is given, then
4170 the pragma is a configuration pragma, and applies to all library level
4171 objects with no explicit initialization of potentially persistent types.
4173 A potentially persistent type is a scalar type, or a non-tagged,
4174 non-discriminated record, all of whose components have no explicit
4175 initialization and are themselves of a potentially persistent type,
4176 or an array, all of whose constraints are static, and whose component
4177 type is potentially persistent.
4179 If this pragma is used on a target where this feature is not supported,
4180 then the pragma will be ignored. See also @code{pragma Linker_Section}.
4182 @node Pragma Polling
4183 @unnumberedsec Pragma Polling
4188 @smallexample @c ada
4189 pragma Polling (ON | OFF);
4193 This pragma controls the generation of polling code. This is normally off.
4194 If @code{pragma Polling (ON)} is used then periodic calls are generated to
4195 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
4196 runtime library, and can be found in file @file{a-excpol.adb}.
4198 Pragma @code{Polling} can appear as a configuration pragma (for example it
4199 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
4200 can be used in the statement or declaration sequence to control polling
4203 A call to the polling routine is generated at the start of every loop and
4204 at the start of every subprogram call. This guarantees that the @code{Poll}
4205 routine is called frequently, and places an upper bound (determined by
4206 the complexity of the code) on the period between two @code{Poll} calls.
4208 The primary purpose of the polling interface is to enable asynchronous
4209 aborts on targets that cannot otherwise support it (for example Windows
4210 NT), but it may be used for any other purpose requiring periodic polling.
4211 The standard version is null, and can be replaced by a user program. This
4212 will require re-compilation of the @code{Ada.Exceptions} package that can
4213 be found in files @file{a-except.ads} and @file{a-except.adb}.
4215 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
4216 distribution) is used to enable the asynchronous abort capability on
4217 targets that do not normally support the capability. The version of
4218 @code{Poll} in this file makes a call to the appropriate runtime routine
4219 to test for an abort condition.
4221 Note that polling can also be enabled by use of the @option{-gnatP} switch.
4222 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
4225 @node Pragma Postcondition
4226 @unnumberedsec Pragma Postcondition
4227 @cindex Postconditions
4228 @cindex Checks, postconditions
4229 @findex Postconditions
4233 @smallexample @c ada
4234 pragma Postcondition (
4235 [Check =>] Boolean_Expression
4236 [,[Message =>] String_Expression]);
4240 The @code{Postcondition} pragma allows specification of automatic
4241 postcondition checks for subprograms. These checks are similar to
4242 assertions, but are automatically inserted just prior to the return
4243 statements of the subprogram with which they are associated (including
4244 implicit returns at the end of procedure bodies and associated
4245 exception handlers).
4247 In addition, the boolean expression which is the condition which
4248 must be true may contain references to function'Result in the case
4249 of a function to refer to the returned value.
4251 @code{Postcondition} pragmas may appear either immediately following the
4252 (separate) declaration of a subprogram, or at the start of the
4253 declarations of a subprogram body. Only other pragmas may intervene
4254 (that is appear between the subprogram declaration and its
4255 postconditions, or appear before the postcondition in the
4256 declaration sequence in a subprogram body). In the case of a
4257 postcondition appearing after a subprogram declaration, the
4258 formal arguments of the subprogram are visible, and can be
4259 referenced in the postcondition expressions.
4261 The postconditions are collected and automatically tested just
4262 before any return (implicit or explicit) in the subprogram body.
4263 A postcondition is only recognized if postconditions are active
4264 at the time the pragma is encountered. The compiler switch @option{gnata}
4265 turns on all postconditions by default, and pragma @code{Check_Policy}
4266 with an identifier of @code{Postcondition} can also be used to
4267 control whether postconditions are active.
4269 The general approach is that postconditions are placed in the spec
4270 if they represent functional aspects which make sense to the client.
4271 For example we might have:
4273 @smallexample @c ada
4274 function Direction return Integer;
4275 pragma Postcondition
4276 (Direction'Result = +1
4278 Direction'Result = -1);
4282 which serves to document that the result must be +1 or -1, and
4283 will test that this is the case at run time if postcondition
4286 Postconditions within the subprogram body can be used to
4287 check that some internal aspect of the implementation,
4288 not visible to the client, is operating as expected.
4289 For instance if a square root routine keeps an internal
4290 counter of the number of times it is called, then we
4291 might have the following postcondition:
4293 @smallexample @c ada
4294 Sqrt_Calls : Natural := 0;
4296 function Sqrt (Arg : Float) return Float is
4297 pragma Postcondition
4298 (Sqrt_Calls = Sqrt_Calls'Old + 1);
4304 As this example, shows, the use of the @code{Old} attribute
4305 is often useful in postconditions to refer to the state on
4306 entry to the subprogram.
4308 Note that postconditions are only checked on normal returns
4309 from the subprogram. If an abnormal return results from
4310 raising an exception, then the postconditions are not checked.
4312 If a postcondition fails, then the exception
4313 @code{System.Assertions.Assert_Failure} is raised. If
4314 a message argument was supplied, then the given string
4315 will be used as the exception message. If no message
4316 argument was supplied, then the default message has
4317 the form "Postcondition failed at file:line". The
4318 exception is raised in the context of the subprogram
4319 body, so it is possible to catch postcondition failures
4320 within the subprogram body itself.
4322 Within a package spec, normal visibility rules
4323 in Ada would prevent forward references within a
4324 postcondition pragma to functions defined later in
4325 the same package. This would introduce undesirable
4326 ordering constraints. To avoid this problem, all
4327 postcondition pragmas are analyzed at the end of
4328 the package spec, allowing forward references.
4330 The following example shows that this even allows
4331 mutually recursive postconditions as in:
4333 @smallexample @c ada
4334 package Parity_Functions is
4335 function Odd (X : Natural) return Boolean;
4336 pragma Postcondition
4340 (x /= 0 and then Even (X - 1))));
4342 function Even (X : Natural) return Boolean;
4343 pragma Postcondition
4347 (x /= 1 and then Odd (X - 1))));
4349 end Parity_Functions;
4353 There are no restrictions on the complexity or form of
4354 conditions used within @code{Postcondition} pragmas.
4355 The following example shows that it is even possible
4356 to verify performance behavior.
4358 @smallexample @c ada
4361 Performance : constant Float;
4362 -- Performance constant set by implementation
4363 -- to match target architecture behavior.
4365 procedure Treesort (Arg : String);
4366 -- Sorts characters of argument using N*logN sort
4367 pragma Postcondition
4368 (Float (Clock - Clock'Old) <=
4369 Float (Arg'Length) *
4370 log (Float (Arg'Length)) *
4376 Note: postcondition pragmas associated with subprograms that are
4377 marked as Inline_Always, or those marked as Inline with front-end
4378 inlining (-gnatN option set) are accepted and legality-checked
4379 by the compiler, but are ignored at run-time even if postcondition
4380 checking is enabled.
4382 @node Pragma Precondition
4383 @unnumberedsec Pragma Precondition
4384 @cindex Preconditions
4385 @cindex Checks, preconditions
4386 @findex Preconditions
4390 @smallexample @c ada
4391 pragma Precondition (
4392 [Check =>] Boolean_Expression
4393 [,[Message =>] String_Expression]);
4397 The @code{Precondition} pragma is similar to @code{Postcondition}
4398 except that the corresponding checks take place immediately upon
4399 entry to the subprogram, and if a precondition fails, the exception
4400 is raised in the context of the caller, and the attribute 'Result
4401 cannot be used within the precondition expression.
4403 Otherwise, the placement and visibility rules are identical to those
4404 described for postconditions. The following is an example of use
4405 within a package spec:
4407 @smallexample @c ada
4408 package Math_Functions is
4410 function Sqrt (Arg : Float) return Float;
4411 pragma Precondition (Arg >= 0.0)
4417 @code{Precondition} pragmas may appear either immediately following the
4418 (separate) declaration of a subprogram, or at the start of the
4419 declarations of a subprogram body. Only other pragmas may intervene
4420 (that is appear between the subprogram declaration and its
4421 postconditions, or appear before the postcondition in the
4422 declaration sequence in a subprogram body).
4424 Note: postcondition pragmas associated with subprograms that are
4425 marked as Inline_Always, or those marked as Inline with front-end
4426 inlining (-gnatN option set) are accepted and legality-checked
4427 by the compiler, but are ignored at run-time even if postcondition
4428 checking is enabled.
4430 @node Pragma Profile (Ravenscar)
4431 @unnumberedsec Pragma Profile (Ravenscar)
4436 @smallexample @c ada
4437 pragma Profile (Ravenscar);
4441 A configuration pragma that establishes the following set of configuration
4445 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4446 [RM D.2.2] Tasks are dispatched following a preemptive
4447 priority-ordered scheduling policy.
4449 @item Locking_Policy (Ceiling_Locking)
4450 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4451 the ceiling priority of the corresponding protected object.
4453 @c @item Detect_Blocking
4454 @c This pragma forces the detection of potentially blocking operations within a
4455 @c protected operation, and to raise Program_Error if that happens.
4459 plus the following set of restrictions:
4462 @item Max_Entry_Queue_Length => 1
4463 No task can be queued on a protected entry.
4464 @item Max_Protected_Entries => 1
4465 @item Max_Task_Entries => 0
4466 No rendezvous statements are allowed.
4467 @item No_Abort_Statements
4468 @item No_Dynamic_Attachment
4469 @item No_Dynamic_Priorities
4470 @item No_Implicit_Heap_Allocations
4471 @item No_Local_Protected_Objects
4472 @item No_Local_Timing_Events
4473 @item No_Protected_Type_Allocators
4474 @item No_Relative_Delay
4475 @item No_Requeue_Statements
4476 @item No_Select_Statements
4477 @item No_Specific_Termination_Handlers
4478 @item No_Task_Allocators
4479 @item No_Task_Hierarchy
4480 @item No_Task_Termination
4481 @item Simple_Barriers
4485 The Ravenscar profile also includes the following restrictions that specify
4486 that there are no semantic dependences on the corresponding predefined
4490 @item No_Dependence => Ada.Asynchronous_Task_Control
4491 @item No_Dependence => Ada.Calendar
4492 @item No_Dependence => Ada.Execution_Time.Group_Budget
4493 @item No_Dependence => Ada.Execution_Time.Timers
4494 @item No_Dependence => Ada.Task_Attributes
4495 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
4500 This set of configuration pragmas and restrictions correspond to the
4501 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4502 published by the @cite{International Real-Time Ada Workshop}, 1997,
4503 and whose most recent description is available at
4504 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4506 The original definition of the profile was revised at subsequent IRTAW
4507 meetings. It has been included in the ISO
4508 @cite{Guide for the Use of the Ada Programming Language in High
4509 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4510 the next revision of the standard. The formal definition given by
4511 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4512 AI-305) available at
4513 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
4514 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
4516 The above set is a superset of the restrictions provided by pragma
4517 @code{Profile (Restricted)}, it includes six additional restrictions
4518 (@code{Simple_Barriers}, @code{No_Select_Statements},
4519 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4520 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4521 that pragma @code{Profile (Ravenscar)}, like the pragma
4522 @code{Profile (Restricted)},
4523 automatically causes the use of a simplified,
4524 more efficient version of the tasking run-time system.
4526 @node Pragma Profile (Restricted)
4527 @unnumberedsec Pragma Profile (Restricted)
4528 @findex Restricted Run Time
4532 @smallexample @c ada
4533 pragma Profile (Restricted);
4537 A configuration pragma that establishes the following set of restrictions:
4540 @item No_Abort_Statements
4541 @item No_Entry_Queue
4542 @item No_Task_Hierarchy
4543 @item No_Task_Allocators
4544 @item No_Dynamic_Priorities
4545 @item No_Terminate_Alternatives
4546 @item No_Dynamic_Attachment
4547 @item No_Protected_Type_Allocators
4548 @item No_Local_Protected_Objects
4549 @item No_Requeue_Statements
4550 @item No_Task_Attributes_Package
4551 @item Max_Asynchronous_Select_Nesting = 0
4552 @item Max_Task_Entries = 0
4553 @item Max_Protected_Entries = 1
4554 @item Max_Select_Alternatives = 0
4558 This set of restrictions causes the automatic selection of a simplified
4559 version of the run time that provides improved performance for the
4560 limited set of tasking functionality permitted by this set of restrictions.
4562 @node Pragma Psect_Object
4563 @unnumberedsec Pragma Psect_Object
4564 @findex Psect_Object
4568 @smallexample @c ada
4569 pragma Psect_Object (
4570 [Internal =>] LOCAL_NAME,
4571 [, [External =>] EXTERNAL_SYMBOL]
4572 [, [Size =>] EXTERNAL_SYMBOL]);
4576 | static_string_EXPRESSION
4580 This pragma is identical in effect to pragma @code{Common_Object}.
4582 @node Pragma Pure_Function
4583 @unnumberedsec Pragma Pure_Function
4584 @findex Pure_Function
4588 @smallexample @c ada
4589 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4593 This pragma appears in the same declarative part as a function
4594 declaration (or a set of function declarations if more than one
4595 overloaded declaration exists, in which case the pragma applies
4596 to all entities). It specifies that the function @code{Entity} is
4597 to be considered pure for the purposes of code generation. This means
4598 that the compiler can assume that there are no side effects, and
4599 in particular that two calls with identical arguments produce the
4600 same result. It also means that the function can be used in an
4603 Note that, quite deliberately, there are no static checks to try
4604 to ensure that this promise is met, so @code{Pure_Function} can be used
4605 with functions that are conceptually pure, even if they do modify
4606 global variables. For example, a square root function that is
4607 instrumented to count the number of times it is called is still
4608 conceptually pure, and can still be optimized, even though it
4609 modifies a global variable (the count). Memo functions are another
4610 example (where a table of previous calls is kept and consulted to
4611 avoid re-computation).
4613 Note also that the normal rules excluding optimization of subprograms
4614 in pure units (when parameter types are descended from System.Address,
4615 or when the full view of a parameter type is limited), do not apply
4616 for the Pure_Function case. If you explicitly specify Pure_Function,
4617 the compiler may optimize away calls with identical arguments, and
4618 if that results in unexpected behavior, the proper action is not to
4619 use the pragma for subprograms that are not (conceptually) pure.
4622 Note: Most functions in a @code{Pure} package are automatically pure, and
4623 there is no need to use pragma @code{Pure_Function} for such functions. One
4624 exception is any function that has at least one formal of type
4625 @code{System.Address} or a type derived from it. Such functions are not
4626 considered pure by default, since the compiler assumes that the
4627 @code{Address} parameter may be functioning as a pointer and that the
4628 referenced data may change even if the address value does not.
4629 Similarly, imported functions are not considered to be pure by default,
4630 since there is no way of checking that they are in fact pure. The use
4631 of pragma @code{Pure_Function} for such a function will override these default
4632 assumption, and cause the compiler to treat a designated subprogram as pure
4635 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4636 applies to the underlying renamed function. This can be used to
4637 disambiguate cases of overloading where some but not all functions
4638 in a set of overloaded functions are to be designated as pure.
4640 If pragma @code{Pure_Function} is applied to a library level function, the
4641 function is also considered pure from an optimization point of view, but the
4642 unit is not a Pure unit in the categorization sense. So for example, a function
4643 thus marked is free to @code{with} non-pure units.
4645 @node Pragma Remote_Access_Type
4646 @unnumberedsec Pragma Remote_Access_Type
4647 @findex Remote_Access_Type
4651 @smallexample @c ada
4652 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
4656 This pragma appears in the formal part of a generic declaration.
4657 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
4658 the use of a remote access to class-wide type as actual for a formal
4661 When this pragma applies to a formal access type @code{Entity}, that
4662 type is treated as a remote access to class-wide type in the generic.
4663 It must be a formal general access type, and its designated type must
4664 be the class-wide type of a formal tagged limited private type from the
4665 same generic declaration.
4667 In the generic unit, the formal type is subject to all restrictions
4668 pertaining to remote access to class-wide types. At instantiation, the
4669 actual type must be a remote access to class-wide type.
4671 @node Pragma Restriction_Warnings
4672 @unnumberedsec Pragma Restriction_Warnings
4673 @findex Restriction_Warnings
4677 @smallexample @c ada
4678 pragma Restriction_Warnings
4679 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4683 This pragma allows a series of restriction identifiers to be
4684 specified (the list of allowed identifiers is the same as for
4685 pragma @code{Restrictions}). For each of these identifiers
4686 the compiler checks for violations of the restriction, but
4687 generates a warning message rather than an error message
4688 if the restriction is violated.
4691 @unnumberedsec Pragma Shared
4695 This pragma is provided for compatibility with Ada 83. The syntax and
4696 semantics are identical to pragma Atomic.
4698 @node Pragma Short_Circuit_And_Or
4699 @unnumberedsec Pragma Short_Circuit_And_Or
4700 @findex Short_Circuit_And_Or
4703 This configuration pragma causes any occurrence of the AND operator applied to
4704 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4705 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4706 may be useful in the context of certification protocols requiring the use of
4707 short-circuited logical operators. If this configuration pragma occurs locally
4708 within the file being compiled, it applies only to the file being compiled.
4709 There is no requirement that all units in a partition use this option.
4711 @node Pragma Short_Descriptors
4712 @unnumberedsec Pragma Short_Descriptors
4713 @findex Short_Descriptors
4717 @smallexample @c ada
4718 pragma Short_Descriptors
4722 In VMS versions of the compiler, this configuration pragma causes all
4723 occurrences of the mechanism types Descriptor[_xxx] to be treated as
4724 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
4725 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
4728 @node Pragma Simple_Storage_Pool_Type
4729 @unnumberedsec Pragma Simple_Storage_Pool_Type
4730 @findex Simple_Storage_Pool_Type
4731 @cindex Storage pool, simple
4732 @cindex Simple storage pool
4736 @smallexample @c ada
4737 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
4741 A type can be established as a ``simple storage pool type'' by applying
4742 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
4743 A type named in the pragma must be a library-level immutably limited record
4744 type or limited tagged type declared immediately within a package declaration.
4745 The type can also be a limited private type whose full type is allowed as
4746 a simple storage pool type.
4748 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
4749 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
4750 are subtype conformant with the following subprogram declarations:
4752 @smallexample @c ada
4755 Storage_Address : out System.Address;
4756 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
4757 Alignment : System.Storage_Elements.Storage_Count);
4759 procedure Deallocate
4761 Storage_Address : System.Address;
4762 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
4763 Alignment : System.Storage_Elements.Storage_Count);
4765 function Storage_Size (Pool : SSP)
4766 return System.Storage_Elements.Storage_Count;
4770 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
4771 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
4772 applying an unchecked deallocation has no effect other than to set its actual
4773 parameter to null. If @code{Storage_Size} is not declared, then the
4774 @code{Storage_Size} attribute applied to an access type associated with
4775 a pool object of type SSP returns zero. Additional operations can be declared
4776 for a simple storage pool type (such as for supporting a mark/release
4777 storage-management discipline).
4779 An object of a simple storage pool type can be associated with an access
4780 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
4782 @smallexample @c ada
4784 My_Pool : My_Simple_Storage_Pool_Type;
4786 type Acc is access My_Data_Type;
4788 for Acc'Simple_Storage_Pool use My_Pool;
4793 See attribute @code{Simple_Storage_Pool} for further details.
4795 @node Pragma Source_File_Name
4796 @unnumberedsec Pragma Source_File_Name
4797 @findex Source_File_Name
4801 @smallexample @c ada
4802 pragma Source_File_Name (
4803 [Unit_Name =>] unit_NAME,
4804 Spec_File_Name => STRING_LITERAL,
4805 [Index => INTEGER_LITERAL]);
4807 pragma Source_File_Name (
4808 [Unit_Name =>] unit_NAME,
4809 Body_File_Name => STRING_LITERAL,
4810 [Index => INTEGER_LITERAL]);
4814 Use this to override the normal naming convention. It is a configuration
4815 pragma, and so has the usual applicability of configuration pragmas
4816 (i.e.@: it applies to either an entire partition, or to all units in a
4817 compilation, or to a single unit, depending on how it is used.
4818 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4819 the second argument is required, and indicates whether this is the file
4820 name for the spec or for the body.
4822 The optional Index argument should be used when a file contains multiple
4823 units, and when you do not want to use @code{gnatchop} to separate then
4824 into multiple files (which is the recommended procedure to limit the
4825 number of recompilations that are needed when some sources change).
4826 For instance, if the source file @file{source.ada} contains
4828 @smallexample @c ada
4840 you could use the following configuration pragmas:
4842 @smallexample @c ada
4843 pragma Source_File_Name
4844 (B, Spec_File_Name => "source.ada", Index => 1);
4845 pragma Source_File_Name
4846 (A, Body_File_Name => "source.ada", Index => 2);
4849 Note that the @code{gnatname} utility can also be used to generate those
4850 configuration pragmas.
4852 Another form of the @code{Source_File_Name} pragma allows
4853 the specification of patterns defining alternative file naming schemes
4854 to apply to all files.
4856 @smallexample @c ada
4857 pragma Source_File_Name
4858 ( [Spec_File_Name =>] STRING_LITERAL
4859 [,[Casing =>] CASING_SPEC]
4860 [,[Dot_Replacement =>] STRING_LITERAL]);
4862 pragma Source_File_Name
4863 ( [Body_File_Name =>] STRING_LITERAL
4864 [,[Casing =>] CASING_SPEC]
4865 [,[Dot_Replacement =>] STRING_LITERAL]);
4867 pragma Source_File_Name
4868 ( [Subunit_File_Name =>] STRING_LITERAL
4869 [,[Casing =>] CASING_SPEC]
4870 [,[Dot_Replacement =>] STRING_LITERAL]);
4872 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4876 The first argument is a pattern that contains a single asterisk indicating
4877 the point at which the unit name is to be inserted in the pattern string
4878 to form the file name. The second argument is optional. If present it
4879 specifies the casing of the unit name in the resulting file name string.
4880 The default is lower case. Finally the third argument allows for systematic
4881 replacement of any dots in the unit name by the specified string literal.
4883 Note that Source_File_Name pragmas should not be used if you are using
4884 project files. The reason for this rule is that the project manager is not
4885 aware of these pragmas, and so other tools that use the projet file would not
4886 be aware of the intended naming conventions. If you are using project files,
4887 file naming is controlled by Source_File_Name_Project pragmas, which are
4888 usually supplied automatically by the project manager. A pragma
4889 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
4891 For more details on the use of the @code{Source_File_Name} pragma,
4892 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4893 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4896 @node Pragma Source_File_Name_Project
4897 @unnumberedsec Pragma Source_File_Name_Project
4898 @findex Source_File_Name_Project
4901 This pragma has the same syntax and semantics as pragma Source_File_Name.
4902 It is only allowed as a stand alone configuration pragma.
4903 It cannot appear after a @ref{Pragma Source_File_Name}, and
4904 most importantly, once pragma Source_File_Name_Project appears,
4905 no further Source_File_Name pragmas are allowed.
4907 The intention is that Source_File_Name_Project pragmas are always
4908 generated by the Project Manager in a manner consistent with the naming
4909 specified in a project file, and when naming is controlled in this manner,
4910 it is not permissible to attempt to modify this naming scheme using
4911 Source_File_Name or Source_File_Name_Project pragmas (which would not be
4912 known to the project manager).
4914 @node Pragma Source_Reference
4915 @unnumberedsec Pragma Source_Reference
4916 @findex Source_Reference
4920 @smallexample @c ada
4921 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4925 This pragma must appear as the first line of a source file.
4926 @var{integer_literal} is the logical line number of the line following
4927 the pragma line (for use in error messages and debugging
4928 information). @var{string_literal} is a static string constant that
4929 specifies the file name to be used in error messages and debugging
4930 information. This is most notably used for the output of @code{gnatchop}
4931 with the @option{-r} switch, to make sure that the original unchopped
4932 source file is the one referred to.
4934 The second argument must be a string literal, it cannot be a static
4935 string expression other than a string literal. This is because its value
4936 is needed for error messages issued by all phases of the compiler.
4938 @node Pragma Static_Elaboration_Desired
4939 @unnumberedsec Pragma Static_Elaboration_Desired
4940 @findex Static_Elaboration_Desired
4944 @smallexample @c ada
4945 pragma Static_Elaboration_Desired;
4949 This pragma is used to indicate that the compiler should attempt to initialize
4950 statically the objects declared in the library unit to which the pragma applies,
4951 when these objects are initialized (explicitly or implicitly) by an aggregate.
4952 In the absence of this pragma, aggregates in object declarations are expanded
4953 into assignments and loops, even when the aggregate components are static
4954 constants. When the aggregate is present the compiler builds a static expression
4955 that requires no run-time code, so that the initialized object can be placed in
4956 read-only data space. If the components are not static, or the aggregate has
4957 more that 100 components, the compiler emits a warning that the pragma cannot
4958 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
4959 construction of larger aggregates with static components that include an others
4962 @node Pragma Stream_Convert
4963 @unnumberedsec Pragma Stream_Convert
4964 @findex Stream_Convert
4968 @smallexample @c ada
4969 pragma Stream_Convert (
4970 [Entity =>] type_LOCAL_NAME,
4971 [Read =>] function_NAME,
4972 [Write =>] function_NAME);
4976 This pragma provides an efficient way of providing stream functions for
4977 types defined in packages. Not only is it simpler to use than declaring
4978 the necessary functions with attribute representation clauses, but more
4979 significantly, it allows the declaration to made in such a way that the
4980 stream packages are not loaded unless they are needed. The use of
4981 the Stream_Convert pragma adds no overhead at all, unless the stream
4982 attributes are actually used on the designated type.
4984 The first argument specifies the type for which stream functions are
4985 provided. The second parameter provides a function used to read values
4986 of this type. It must name a function whose argument type may be any
4987 subtype, and whose returned type must be the type given as the first
4988 argument to the pragma.
4990 The meaning of the @var{Read}
4991 parameter is that if a stream attribute directly
4992 or indirectly specifies reading of the type given as the first parameter,
4993 then a value of the type given as the argument to the Read function is
4994 read from the stream, and then the Read function is used to convert this
4995 to the required target type.
4997 Similarly the @var{Write} parameter specifies how to treat write attributes
4998 that directly or indirectly apply to the type given as the first parameter.
4999 It must have an input parameter of the type specified by the first parameter,
5000 and the return type must be the same as the input type of the Read function.
5001 The effect is to first call the Write function to convert to the given stream
5002 type, and then write the result type to the stream.
5004 The Read and Write functions must not be overloaded subprograms. If necessary
5005 renamings can be supplied to meet this requirement.
5006 The usage of this attribute is best illustrated by a simple example, taken
5007 from the GNAT implementation of package Ada.Strings.Unbounded:
5009 @smallexample @c ada
5010 function To_Unbounded (S : String)
5011 return Unbounded_String
5012 renames To_Unbounded_String;
5014 pragma Stream_Convert
5015 (Unbounded_String, To_Unbounded, To_String);
5019 The specifications of the referenced functions, as given in the Ada
5020 Reference Manual are:
5022 @smallexample @c ada
5023 function To_Unbounded_String (Source : String)
5024 return Unbounded_String;
5026 function To_String (Source : Unbounded_String)
5031 The effect is that if the value of an unbounded string is written to a stream,
5032 then the representation of the item in the stream is in the same format that
5033 would be used for @code{Standard.String'Output}, and this same representation
5034 is expected when a value of this type is read from the stream. Note that the
5035 value written always includes the bounds, even for Unbounded_String'Write,
5036 since Unbounded_String is not an array type.
5038 @node Pragma Style_Checks
5039 @unnumberedsec Pragma Style_Checks
5040 @findex Style_Checks
5044 @smallexample @c ada
5045 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
5046 On | Off [, LOCAL_NAME]);
5050 This pragma is used in conjunction with compiler switches to control the
5051 built in style checking provided by GNAT@. The compiler switches, if set,
5052 provide an initial setting for the switches, and this pragma may be used
5053 to modify these settings, or the settings may be provided entirely by
5054 the use of the pragma. This pragma can be used anywhere that a pragma
5055 is legal, including use as a configuration pragma (including use in
5056 the @file{gnat.adc} file).
5058 The form with a string literal specifies which style options are to be
5059 activated. These are additive, so they apply in addition to any previously
5060 set style check options. The codes for the options are the same as those
5061 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
5062 For example the following two methods can be used to enable
5067 @smallexample @c ada
5068 pragma Style_Checks ("l");
5073 gcc -c -gnatyl @dots{}
5078 The form ALL_CHECKS activates all standard checks (its use is equivalent
5079 to the use of the @code{gnaty} switch with no options. @xref{Top,
5080 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
5081 @value{EDITION} User's Guide}, for details.)
5083 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
5084 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
5085 options (i.e. equivalent to -gnatyg).
5087 The forms with @code{Off} and @code{On}
5088 can be used to temporarily disable style checks
5089 as shown in the following example:
5091 @smallexample @c ada
5095 pragma Style_Checks ("k"); -- requires keywords in lower case
5096 pragma Style_Checks (Off); -- turn off style checks
5097 NULL; -- this will not generate an error message
5098 pragma Style_Checks (On); -- turn style checks back on
5099 NULL; -- this will generate an error message
5103 Finally the two argument form is allowed only if the first argument is
5104 @code{On} or @code{Off}. The effect is to turn of semantic style checks
5105 for the specified entity, as shown in the following example:
5107 @smallexample @c ada
5111 pragma Style_Checks ("r"); -- require consistency of identifier casing
5113 Rf1 : Integer := ARG; -- incorrect, wrong case
5114 pragma Style_Checks (Off, Arg);
5115 Rf2 : Integer := ARG; -- OK, no error
5118 @node Pragma Subtitle
5119 @unnumberedsec Pragma Subtitle
5124 @smallexample @c ada
5125 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
5129 This pragma is recognized for compatibility with other Ada compilers
5130 but is ignored by GNAT@.
5132 @node Pragma Suppress
5133 @unnumberedsec Pragma Suppress
5138 @smallexample @c ada
5139 pragma Suppress (Identifier [, [On =>] Name]);
5143 This is a standard pragma, and supports all the check names required in
5144 the RM. It is included here because GNAT recognizes one additional check
5145 name: @code{Alignment_Check} which can be used to suppress alignment checks
5146 on addresses used in address clauses. Such checks can also be suppressed
5147 by suppressing range checks, but the specific use of @code{Alignment_Check}
5148 allows suppression of alignment checks without suppressing other range checks.
5150 Note that pragma Suppress gives the compiler permission to omit
5151 checks, but does not require the compiler to omit checks. The compiler
5152 will generate checks if they are essentially free, even when they are
5153 suppressed. In particular, if the compiler can prove that a certain
5154 check will necessarily fail, it will generate code to do an
5155 unconditional ``raise'', even if checks are suppressed. The compiler
5158 Of course, run-time checks are omitted whenever the compiler can prove
5159 that they will not fail, whether or not checks are suppressed.
5161 @node Pragma Suppress_All
5162 @unnumberedsec Pragma Suppress_All
5163 @findex Suppress_All
5167 @smallexample @c ada
5168 pragma Suppress_All;
5172 This pragma can appear anywhere within a unit.
5173 The effect is to apply @code{Suppress (All_Checks)} to the unit
5174 in which it appears. This pragma is implemented for compatibility with DEC
5175 Ada 83 usage where it appears at the end of a unit, and for compatibility
5176 with Rational Ada, where it appears as a program unit pragma.
5177 The use of the standard Ada pragma @code{Suppress (All_Checks)}
5178 as a normal configuration pragma is the preferred usage in GNAT@.
5180 @node Pragma Suppress_Exception_Locations
5181 @unnumberedsec Pragma Suppress_Exception_Locations
5182 @findex Suppress_Exception_Locations
5186 @smallexample @c ada
5187 pragma Suppress_Exception_Locations;
5191 In normal mode, a raise statement for an exception by default generates
5192 an exception message giving the file name and line number for the location
5193 of the raise. This is useful for debugging and logging purposes, but this
5194 entails extra space for the strings for the messages. The configuration
5195 pragma @code{Suppress_Exception_Locations} can be used to suppress the
5196 generation of these strings, with the result that space is saved, but the
5197 exception message for such raises is null. This configuration pragma may
5198 appear in a global configuration pragma file, or in a specific unit as
5199 usual. It is not required that this pragma be used consistently within
5200 a partition, so it is fine to have some units within a partition compiled
5201 with this pragma and others compiled in normal mode without it.
5203 @node Pragma Suppress_Initialization
5204 @unnumberedsec Pragma Suppress_Initialization
5205 @findex Suppress_Initialization
5206 @cindex Suppressing initialization
5207 @cindex Initialization, suppression of
5211 @smallexample @c ada
5212 pragma Suppress_Initialization ([Entity =>] subtype_Name);
5216 Here subtype_Name is the name introduced by a type declaration
5217 or subtype declaration.
5218 This pragma suppresses any implicit or explicit initialization
5219 for all variables of the given type or subtype,
5220 including initialization resulting from the use of pragmas
5221 Normalize_Scalars or Initialize_Scalars.
5223 This is considered a representation item, so it cannot be given after
5224 the type is frozen. It applies to all subsequent object declarations,
5225 and also any allocator that creates objects of the type.
5227 If the pragma is given for the first subtype, then it is considered
5228 to apply to the base type and all its subtypes. If the pragma is given
5229 for other than a first subtype, then it applies only to the given subtype.
5230 The pragma may not be given after the type is frozen.
5232 @node Pragma Task_Info
5233 @unnumberedsec Pragma Task_Info
5238 @smallexample @c ada
5239 pragma Task_Info (EXPRESSION);
5243 This pragma appears within a task definition (like pragma
5244 @code{Priority}) and applies to the task in which it appears. The
5245 argument must be of type @code{System.Task_Info.Task_Info_Type}.
5246 The @code{Task_Info} pragma provides system dependent control over
5247 aspects of tasking implementation, for example, the ability to map
5248 tasks to specific processors. For details on the facilities available
5249 for the version of GNAT that you are using, see the documentation
5250 in the spec of package System.Task_Info in the runtime
5253 @node Pragma Task_Name
5254 @unnumberedsec Pragma Task_Name
5259 @smallexample @c ada
5260 pragma Task_Name (string_EXPRESSION);
5264 This pragma appears within a task definition (like pragma
5265 @code{Priority}) and applies to the task in which it appears. The
5266 argument must be of type String, and provides a name to be used for
5267 the task instance when the task is created. Note that this expression
5268 is not required to be static, and in particular, it can contain
5269 references to task discriminants. This facility can be used to
5270 provide different names for different tasks as they are created,
5271 as illustrated in the example below.
5273 The task name is recorded internally in the run-time structures
5274 and is accessible to tools like the debugger. In addition the
5275 routine @code{Ada.Task_Identification.Image} will return this
5276 string, with a unique task address appended.
5278 @smallexample @c ada
5279 -- Example of the use of pragma Task_Name
5281 with Ada.Task_Identification;
5282 use Ada.Task_Identification;
5283 with Text_IO; use Text_IO;
5286 type Astring is access String;
5288 task type Task_Typ (Name : access String) is
5289 pragma Task_Name (Name.all);
5292 task body Task_Typ is
5293 Nam : constant String := Image (Current_Task);
5295 Put_Line ("-->" & Nam (1 .. 14) & "<--");
5298 type Ptr_Task is access Task_Typ;
5299 Task_Var : Ptr_Task;
5303 new Task_Typ (new String'("This is task 1"));
5305 new Task_Typ (new String'("This is task 2"));
5309 @node Pragma Task_Storage
5310 @unnumberedsec Pragma Task_Storage
5311 @findex Task_Storage
5314 @smallexample @c ada
5315 pragma Task_Storage (
5316 [Task_Type =>] LOCAL_NAME,
5317 [Top_Guard =>] static_integer_EXPRESSION);
5321 This pragma specifies the length of the guard area for tasks. The guard
5322 area is an additional storage area allocated to a task. A value of zero
5323 means that either no guard area is created or a minimal guard area is
5324 created, depending on the target. This pragma can appear anywhere a
5325 @code{Storage_Size} attribute definition clause is allowed for a task
5328 @node Pragma Test_Case
5329 @unnumberedsec Pragma Test_Case
5335 @smallexample @c ada
5337 [Name =>] static_string_Expression
5338 ,[Mode =>] (Nominal | Robustness)
5339 [, Requires => Boolean_Expression]
5340 [, Ensures => Boolean_Expression]);
5344 The @code{Test_Case} pragma allows defining fine-grain specifications
5345 for use by testing tools. Its syntax is similar to the syntax of the
5346 @code{Contract_Case} pragma, which is used for both testing and
5347 formal verification.
5348 The compiler checks the validity of the @code{Test_Case} pragma, but its
5349 presence does not lead to any modification of the code generated by the
5350 compiler, contrary to the treatment of the @code{Contract_Case} pragma.
5352 @code{Test_Case} pragmas may only appear immediately following the
5353 (separate) declaration of a subprogram in a package declaration, inside
5354 a package spec unit. Only other pragmas may intervene (that is appear
5355 between the subprogram declaration and a test case).
5357 The compiler checks that boolean expressions given in @code{Requires} and
5358 @code{Ensures} are valid, where the rules for @code{Requires} are the
5359 same as the rule for an expression in @code{Precondition} and the rules
5360 for @code{Ensures} are the same as the rule for an expression in
5361 @code{Postcondition}. In particular, attributes @code{'Old} and
5362 @code{'Result} can only be used within the @code{Ensures}
5363 expression. The following is an example of use within a package spec:
5365 @smallexample @c ada
5366 package Math_Functions is
5368 function Sqrt (Arg : Float) return Float;
5369 pragma Test_Case (Name => "Test 1",
5371 Requires => Arg < 10000,
5372 Ensures => Sqrt'Result < 10);
5378 The meaning of a test case is that there is at least one context where
5379 @code{Requires} holds such that, if the associated subprogram is executed in
5380 that context, then @code{Ensures} holds when the subprogram returns.
5381 Mode @code{Nominal} indicates that the input context should also satisfy the
5382 precondition of the subprogram, and the output context should also satisfy its
5383 postcondition. More @code{Robustness} indicates that the precondition and
5384 postcondition of the subprogram should be ignored for this test case.
5386 @node Pragma Thread_Local_Storage
5387 @unnumberedsec Pragma Thread_Local_Storage
5388 @findex Thread_Local_Storage
5389 @cindex Task specific storage
5390 @cindex TLS (Thread Local Storage)
5393 @smallexample @c ada
5394 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
5398 This pragma specifies that the specified entity, which must be
5399 a variable declared in a library level package, is to be marked as
5400 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
5401 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
5402 (and hence each Ada task) to see a distinct copy of the variable.
5404 The variable may not have default initialization, and if there is
5405 an explicit initialization, it must be either @code{null} for an
5406 access variable, or a static expression for a scalar variable.
5407 This provides a low level mechanism similar to that provided by
5408 the @code{Ada.Task_Attributes} package, but much more efficient
5409 and is also useful in writing interface code that will interact
5410 with foreign threads.
5412 If this pragma is used on a system where @code{TLS} is not supported,
5413 then an error message will be generated and the program will be rejected.
5415 @node Pragma Time_Slice
5416 @unnumberedsec Pragma Time_Slice
5421 @smallexample @c ada
5422 pragma Time_Slice (static_duration_EXPRESSION);
5426 For implementations of GNAT on operating systems where it is possible
5427 to supply a time slice value, this pragma may be used for this purpose.
5428 It is ignored if it is used in a system that does not allow this control,
5429 or if it appears in other than the main program unit.
5431 Note that the effect of this pragma is identical to the effect of the
5432 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
5435 @unnumberedsec Pragma Title
5440 @smallexample @c ada
5441 pragma Title (TITLING_OPTION [, TITLING OPTION]);
5444 [Title =>] STRING_LITERAL,
5445 | [Subtitle =>] STRING_LITERAL
5449 Syntax checked but otherwise ignored by GNAT@. This is a listing control
5450 pragma used in DEC Ada 83 implementations to provide a title and/or
5451 subtitle for the program listing. The program listing generated by GNAT
5452 does not have titles or subtitles.
5454 Unlike other pragmas, the full flexibility of named notation is allowed
5455 for this pragma, i.e.@: the parameters may be given in any order if named
5456 notation is used, and named and positional notation can be mixed
5457 following the normal rules for procedure calls in Ada.
5459 @node Pragma Unchecked_Union
5460 @unnumberedsec Pragma Unchecked_Union
5462 @findex Unchecked_Union
5466 @smallexample @c ada
5467 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5471 This pragma is used to specify a representation of a record type that is
5472 equivalent to a C union. It was introduced as a GNAT implementation defined
5473 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5474 pragma, making it language defined, and GNAT fully implements this extended
5475 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5476 details, consult the Ada 2005 Reference Manual, section B.3.3.
5478 @node Pragma Unimplemented_Unit
5479 @unnumberedsec Pragma Unimplemented_Unit
5480 @findex Unimplemented_Unit
5484 @smallexample @c ada
5485 pragma Unimplemented_Unit;
5489 If this pragma occurs in a unit that is processed by the compiler, GNAT
5490 aborts with the message @samp{@var{xxx} not implemented}, where
5491 @var{xxx} is the name of the current compilation unit. This pragma is
5492 intended to allow the compiler to handle unimplemented library units in
5495 The abort only happens if code is being generated. Thus you can use
5496 specs of unimplemented packages in syntax or semantic checking mode.
5498 @node Pragma Universal_Aliasing
5499 @unnumberedsec Pragma Universal_Aliasing
5500 @findex Universal_Aliasing
5504 @smallexample @c ada
5505 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5509 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5510 declarative part. The effect is to inhibit strict type-based aliasing
5511 optimization for the given type. In other words, the effect is as though
5512 access types designating this type were subject to pragma No_Strict_Aliasing.
5513 For a detailed description of the strict aliasing optimization, and the
5514 situations in which it must be suppressed, @xref{Optimization and Strict
5515 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5517 @node Pragma Universal_Data
5518 @unnumberedsec Pragma Universal_Data
5519 @findex Universal_Data
5523 @smallexample @c ada
5524 pragma Universal_Data [(library_unit_Name)];
5528 This pragma is supported only for the AAMP target and is ignored for
5529 other targets. The pragma specifies that all library-level objects
5530 (Counter 0 data) associated with the library unit are to be accessed
5531 and updated using universal addressing (24-bit addresses for AAMP5)
5532 rather than the default of 16-bit Data Environment (DENV) addressing.
5533 Use of this pragma will generally result in less efficient code for
5534 references to global data associated with the library unit, but
5535 allows such data to be located anywhere in memory. This pragma is
5536 a library unit pragma, but can also be used as a configuration pragma
5537 (including use in the @file{gnat.adc} file). The functionality
5538 of this pragma is also available by applying the -univ switch on the
5539 compilations of units where universal addressing of the data is desired.
5541 @node Pragma Unmodified
5542 @unnumberedsec Pragma Unmodified
5544 @cindex Warnings, unmodified
5548 @smallexample @c ada
5549 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
5553 This pragma signals that the assignable entities (variables,
5554 @code{out} parameters, @code{in out} parameters) whose names are listed are
5555 deliberately not assigned in the current source unit. This
5556 suppresses warnings about the
5557 entities being referenced but not assigned, and in addition a warning will be
5558 generated if one of these entities is in fact assigned in the
5559 same unit as the pragma (or in the corresponding body, or one
5562 This is particularly useful for clearly signaling that a particular
5563 parameter is not modified, even though the spec suggests that it might
5566 @node Pragma Unreferenced
5567 @unnumberedsec Pragma Unreferenced
5568 @findex Unreferenced
5569 @cindex Warnings, unreferenced
5573 @smallexample @c ada
5574 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
5575 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
5579 This pragma signals that the entities whose names are listed are
5580 deliberately not referenced in the current source unit. This
5581 suppresses warnings about the
5582 entities being unreferenced, and in addition a warning will be
5583 generated if one of these entities is in fact subsequently referenced in the
5584 same unit as the pragma (or in the corresponding body, or one
5587 This is particularly useful for clearly signaling that a particular
5588 parameter is not referenced in some particular subprogram implementation
5589 and that this is deliberate. It can also be useful in the case of
5590 objects declared only for their initialization or finalization side
5593 If @code{LOCAL_NAME} identifies more than one matching homonym in the
5594 current scope, then the entity most recently declared is the one to which
5595 the pragma applies. Note that in the case of accept formals, the pragma
5596 Unreferenced may appear immediately after the keyword @code{do} which
5597 allows the indication of whether or not accept formals are referenced
5598 or not to be given individually for each accept statement.
5600 The left hand side of an assignment does not count as a reference for the
5601 purpose of this pragma. Thus it is fine to assign to an entity for which
5602 pragma Unreferenced is given.
5604 Note that if a warning is desired for all calls to a given subprogram,
5605 regardless of whether they occur in the same unit as the subprogram
5606 declaration, then this pragma should not be used (calls from another
5607 unit would not be flagged); pragma Obsolescent can be used instead
5608 for this purpose, see @xref{Pragma Obsolescent}.
5610 The second form of pragma @code{Unreferenced} is used within a context
5611 clause. In this case the arguments must be unit names of units previously
5612 mentioned in @code{with} clauses (similar to the usage of pragma
5613 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
5614 units and unreferenced entities within these units.
5616 @node Pragma Unreferenced_Objects
5617 @unnumberedsec Pragma Unreferenced_Objects
5618 @findex Unreferenced_Objects
5619 @cindex Warnings, unreferenced
5623 @smallexample @c ada
5624 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5628 This pragma signals that for the types or subtypes whose names are
5629 listed, objects which are declared with one of these types or subtypes may
5630 not be referenced, and if no references appear, no warnings are given.
5632 This is particularly useful for objects which are declared solely for their
5633 initialization and finalization effect. Such variables are sometimes referred
5634 to as RAII variables (Resource Acquisition Is Initialization). Using this
5635 pragma on the relevant type (most typically a limited controlled type), the
5636 compiler will automatically suppress unwanted warnings about these variables
5637 not being referenced.
5639 @node Pragma Unreserve_All_Interrupts
5640 @unnumberedsec Pragma Unreserve_All_Interrupts
5641 @findex Unreserve_All_Interrupts
5645 @smallexample @c ada
5646 pragma Unreserve_All_Interrupts;
5650 Normally certain interrupts are reserved to the implementation. Any attempt
5651 to attach an interrupt causes Program_Error to be raised, as described in
5652 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
5653 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
5654 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5655 interrupt execution.
5657 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5658 a program, then all such interrupts are unreserved. This allows the
5659 program to handle these interrupts, but disables their standard
5660 functions. For example, if this pragma is used, then pressing
5661 @kbd{Ctrl-C} will not automatically interrupt execution. However,
5662 a program can then handle the @code{SIGINT} interrupt as it chooses.
5664 For a full list of the interrupts handled in a specific implementation,
5665 see the source code for the spec of @code{Ada.Interrupts.Names} in
5666 file @file{a-intnam.ads}. This is a target dependent file that contains the
5667 list of interrupts recognized for a given target. The documentation in
5668 this file also specifies what interrupts are affected by the use of
5669 the @code{Unreserve_All_Interrupts} pragma.
5671 For a more general facility for controlling what interrupts can be
5672 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5673 of the @code{Unreserve_All_Interrupts} pragma.
5675 @node Pragma Unsuppress
5676 @unnumberedsec Pragma Unsuppress
5681 @smallexample @c ada
5682 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5686 This pragma undoes the effect of a previous pragma @code{Suppress}. If
5687 there is no corresponding pragma @code{Suppress} in effect, it has no
5688 effect. The range of the effect is the same as for pragma
5689 @code{Suppress}. The meaning of the arguments is identical to that used
5690 in pragma @code{Suppress}.
5692 One important application is to ensure that checks are on in cases where
5693 code depends on the checks for its correct functioning, so that the code
5694 will compile correctly even if the compiler switches are set to suppress
5697 @node Pragma Use_VADS_Size
5698 @unnumberedsec Pragma Use_VADS_Size
5699 @cindex @code{Size}, VADS compatibility
5700 @findex Use_VADS_Size
5704 @smallexample @c ada
5705 pragma Use_VADS_Size;
5709 This is a configuration pragma. In a unit to which it applies, any use
5710 of the 'Size attribute is automatically interpreted as a use of the
5711 'VADS_Size attribute. Note that this may result in incorrect semantic
5712 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
5713 the handling of existing code which depends on the interpretation of Size
5714 as implemented in the VADS compiler. See description of the VADS_Size
5715 attribute for further details.
5717 @node Pragma Validity_Checks
5718 @unnumberedsec Pragma Validity_Checks
5719 @findex Validity_Checks
5723 @smallexample @c ada
5724 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5728 This pragma is used in conjunction with compiler switches to control the
5729 built-in validity checking provided by GNAT@. The compiler switches, if set
5730 provide an initial setting for the switches, and this pragma may be used
5731 to modify these settings, or the settings may be provided entirely by
5732 the use of the pragma. This pragma can be used anywhere that a pragma
5733 is legal, including use as a configuration pragma (including use in
5734 the @file{gnat.adc} file).
5736 The form with a string literal specifies which validity options are to be
5737 activated. The validity checks are first set to include only the default
5738 reference manual settings, and then a string of letters in the string
5739 specifies the exact set of options required. The form of this string
5740 is exactly as described for the @option{-gnatVx} compiler switch (see the
5741 GNAT users guide for details). For example the following two methods
5742 can be used to enable validity checking for mode @code{in} and
5743 @code{in out} subprogram parameters:
5747 @smallexample @c ada
5748 pragma Validity_Checks ("im");
5753 gcc -c -gnatVim @dots{}
5758 The form ALL_CHECKS activates all standard checks (its use is equivalent
5759 to the use of the @code{gnatva} switch.
5761 The forms with @code{Off} and @code{On}
5762 can be used to temporarily disable validity checks
5763 as shown in the following example:
5765 @smallexample @c ada
5769 pragma Validity_Checks ("c"); -- validity checks for copies
5770 pragma Validity_Checks (Off); -- turn off validity checks
5771 A := B; -- B will not be validity checked
5772 pragma Validity_Checks (On); -- turn validity checks back on
5773 A := C; -- C will be validity checked
5776 @node Pragma Volatile
5777 @unnumberedsec Pragma Volatile
5782 @smallexample @c ada
5783 pragma Volatile (LOCAL_NAME);
5787 This pragma is defined by the Ada Reference Manual, and the GNAT
5788 implementation is fully conformant with this definition. The reason it
5789 is mentioned in this section is that a pragma of the same name was supplied
5790 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
5791 implementation of pragma Volatile is upwards compatible with the
5792 implementation in DEC Ada 83.
5794 @node Pragma Warnings
5795 @unnumberedsec Pragma Warnings
5800 @smallexample @c ada
5801 pragma Warnings (On | Off);
5802 pragma Warnings (On | Off, LOCAL_NAME);
5803 pragma Warnings (static_string_EXPRESSION);
5804 pragma Warnings (On | Off, static_string_EXPRESSION);
5808 Normally warnings are enabled, with the output being controlled by
5809 the command line switch. Warnings (@code{Off}) turns off generation of
5810 warnings until a Warnings (@code{On}) is encountered or the end of the
5811 current unit. If generation of warnings is turned off using this
5812 pragma, then no warning messages are output, regardless of the
5813 setting of the command line switches.
5815 The form with a single argument may be used as a configuration pragma.
5817 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5818 the specified entity. This suppression is effective from the point where
5819 it occurs till the end of the extended scope of the variable (similar to
5820 the scope of @code{Suppress}).
5822 The form with a single static_string_EXPRESSION argument provides more precise
5823 control over which warnings are active. The string is a list of letters
5824 specifying which warnings are to be activated and which deactivated. The
5825 code for these letters is the same as the string used in the command
5826 line switch controlling warnings. For a brief summary, use the gnatmake
5827 command with no arguments, which will generate usage information containing
5828 the list of warnings switches supported. For
5829 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5833 The specified warnings will be in effect until the end of the program
5834 or another pragma Warnings is encountered. The effect of the pragma is
5835 cumulative. Initially the set of warnings is the standard default set
5836 as possibly modified by compiler switches. Then each pragma Warning
5837 modifies this set of warnings as specified. This form of the pragma may
5838 also be used as a configuration pragma.
5840 The fourth form, with an @code{On|Off} parameter and a string, is used to
5841 control individual messages, based on their text. The string argument
5842 is a pattern that is used to match against the text of individual
5843 warning messages (not including the initial "warning: " tag).
5845 The pattern may contain asterisks, which match zero or more characters in
5846 the message. For example, you can use
5847 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5848 message @code{warning: 960 bits of "a" unused}. No other regular
5849 expression notations are permitted. All characters other than asterisk in
5850 these three specific cases are treated as literal characters in the match.
5852 There are two ways to use the pragma in this form. The OFF form can be used as a
5853 configuration pragma. The effect is to suppress all warnings (if any)
5854 that match the pattern string throughout the compilation.
5856 The second usage is to suppress a warning locally, and in this case, two
5857 pragmas must appear in sequence:
5859 @smallexample @c ada
5860 pragma Warnings (Off, Pattern);
5861 @dots{} code where given warning is to be suppressed
5862 pragma Warnings (On, Pattern);
5866 In this usage, the pattern string must match in the Off and On pragmas,
5867 and at least one matching warning must be suppressed.
5869 Note: to write a string that will match any warning, use the string
5870 @code{"***"}. It will not work to use a single asterisk or two asterisks
5871 since this looks like an operator name. This form with three asterisks
5872 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
5873 matching @code{pragma Warnings (On, "***")} will be required. This can be
5874 helpful in avoiding forgetting to turn warnings back on.
5876 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5877 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5878 be useful in checking whether obsolete pragmas in existing programs are hiding
5881 Note: pragma Warnings does not affect the processing of style messages. See
5882 separate entry for pragma Style_Checks for control of style messages.
5884 @node Pragma Weak_External
5885 @unnumberedsec Pragma Weak_External
5886 @findex Weak_External
5890 @smallexample @c ada
5891 pragma Weak_External ([Entity =>] LOCAL_NAME);
5895 @var{LOCAL_NAME} must refer to an object that is declared at the library
5896 level. This pragma specifies that the given entity should be marked as a
5897 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5898 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5899 of a regular symbol, that is to say a symbol that does not have to be
5900 resolved by the linker if used in conjunction with a pragma Import.
5902 When a weak symbol is not resolved by the linker, its address is set to
5903 zero. This is useful in writing interfaces to external modules that may
5904 or may not be linked in the final executable, for example depending on
5905 configuration settings.
5907 If a program references at run time an entity to which this pragma has been
5908 applied, and the corresponding symbol was not resolved at link time, then
5909 the execution of the program is erroneous. It is not erroneous to take the
5910 Address of such an entity, for example to guard potential references,
5911 as shown in the example below.
5913 Some file formats do not support weak symbols so not all target machines
5914 support this pragma.
5916 @smallexample @c ada
5917 -- Example of the use of pragma Weak_External
5919 package External_Module is
5921 pragma Import (C, key);
5922 pragma Weak_External (key);
5923 function Present return boolean;
5924 end External_Module;
5926 with System; use System;
5927 package body External_Module is
5928 function Present return boolean is
5930 return key'Address /= System.Null_Address;
5932 end External_Module;
5935 @node Pragma Wide_Character_Encoding
5936 @unnumberedsec Pragma Wide_Character_Encoding
5937 @findex Wide_Character_Encoding
5941 @smallexample @c ada
5942 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5946 This pragma specifies the wide character encoding to be used in program
5947 source text appearing subsequently. It is a configuration pragma, but may
5948 also be used at any point that a pragma is allowed, and it is permissible
5949 to have more than one such pragma in a file, allowing multiple encodings
5950 to appear within the same file.
5952 The argument can be an identifier or a character literal. In the identifier
5953 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5954 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5955 case it is correspondingly one of the characters @samp{h}, @samp{u},
5956 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5958 Note that when the pragma is used within a file, it affects only the
5959 encoding within that file, and does not affect withed units, specs,
5962 @node Implementation Defined Attributes
5963 @chapter Implementation Defined Attributes
5964 Ada defines (throughout the Ada reference manual,
5965 summarized in Annex K),
5966 a set of attributes that provide useful additional functionality in all
5967 areas of the language. These language defined attributes are implemented
5968 in GNAT and work as described in the Ada Reference Manual.
5970 In addition, Ada allows implementations to define additional
5971 attributes whose meaning is defined by the implementation. GNAT provides
5972 a number of these implementation-dependent attributes which can be used
5973 to extend and enhance the functionality of the compiler. This section of
5974 the GNAT reference manual describes these additional attributes.
5976 Note that any program using these attributes may not be portable to
5977 other compilers (although GNAT implements this set of attributes on all
5978 platforms). Therefore if portability to other compilers is an important
5979 consideration, you should minimize the use of these attributes.
5989 * Compiler_Version::
5991 * Default_Bit_Order::
6003 * Has_Access_Values::
6004 * Has_Discriminants::
6011 * Max_Interrupt_Priority::
6013 * Maximum_Alignment::
6017 * Passed_By_Reference::
6024 * Scalar_Storage_Order::
6025 * Simple_Storage_Pool::
6029 * System_Allocator_Alignment::
6035 * Unconstrained_Array::
6036 * Universal_Literal_String::
6037 * Unrestricted_Access::
6046 @unnumberedsec Abort_Signal
6047 @findex Abort_Signal
6049 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
6050 prefix) provides the entity for the special exception used to signal
6051 task abort or asynchronous transfer of control. Normally this attribute
6052 should only be used in the tasking runtime (it is highly peculiar, and
6053 completely outside the normal semantics of Ada, for a user program to
6054 intercept the abort exception).
6057 @unnumberedsec Address_Size
6058 @cindex Size of @code{Address}
6059 @findex Address_Size
6061 @code{Standard'Address_Size} (@code{Standard} is the only allowed
6062 prefix) is a static constant giving the number of bits in an
6063 @code{Address}. It is the same value as System.Address'Size,
6064 but has the advantage of being static, while a direct
6065 reference to System.Address'Size is non-static because Address
6069 @unnumberedsec Asm_Input
6072 The @code{Asm_Input} attribute denotes a function that takes two
6073 parameters. The first is a string, the second is an expression of the
6074 type designated by the prefix. The first (string) argument is required
6075 to be a static expression, and is the constraint for the parameter,
6076 (e.g.@: what kind of register is required). The second argument is the
6077 value to be used as the input argument. The possible values for the
6078 constant are the same as those used in the RTL, and are dependent on
6079 the configuration file used to built the GCC back end.
6080 @ref{Machine Code Insertions}
6083 @unnumberedsec Asm_Output
6086 The @code{Asm_Output} attribute denotes a function that takes two
6087 parameters. The first is a string, the second is the name of a variable
6088 of the type designated by the attribute prefix. The first (string)
6089 argument is required to be a static expression and designates the
6090 constraint for the parameter (e.g.@: what kind of register is
6091 required). The second argument is the variable to be updated with the
6092 result. The possible values for constraint are the same as those used in
6093 the RTL, and are dependent on the configuration file used to build the
6094 GCC back end. If there are no output operands, then this argument may
6095 either be omitted, or explicitly given as @code{No_Output_Operands}.
6096 @ref{Machine Code Insertions}
6099 @unnumberedsec AST_Entry
6103 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
6104 the name of an entry, it yields a value of the predefined type AST_Handler
6105 (declared in the predefined package System, as extended by the use of
6106 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
6107 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
6108 Language Reference Manual}, section 9.12a.
6113 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
6114 offset within the storage unit (byte) that contains the first bit of
6115 storage allocated for the object. The value of this attribute is of the
6116 type @code{Universal_Integer}, and is always a non-negative number not
6117 exceeding the value of @code{System.Storage_Unit}.
6119 For an object that is a variable or a constant allocated in a register,
6120 the value is zero. (The use of this attribute does not force the
6121 allocation of a variable to memory).
6123 For an object that is a formal parameter, this attribute applies
6124 to either the matching actual parameter or to a copy of the
6125 matching actual parameter.
6127 For an access object the value is zero. Note that
6128 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
6129 designated object. Similarly for a record component
6130 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
6131 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
6132 are subject to index checks.
6134 This attribute is designed to be compatible with the DEC Ada 83 definition
6135 and implementation of the @code{Bit} attribute.
6138 @unnumberedsec Bit_Position
6139 @findex Bit_Position
6141 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
6142 of the fields of the record type, yields the bit
6143 offset within the record contains the first bit of
6144 storage allocated for the object. The value of this attribute is of the
6145 type @code{Universal_Integer}. The value depends only on the field
6146 @var{C} and is independent of the alignment of
6147 the containing record @var{R}.
6149 @node Compiler_Version
6150 @unnumberedsec Compiler_Version
6151 @findex Compiler_Version
6153 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
6154 prefix) yields a static string identifying the version of the compiler
6155 being used to compile the unit containing the attribute reference. A
6156 typical result would be something like "@value{EDITION} @i{version} (20090221)".
6159 @unnumberedsec Code_Address
6160 @findex Code_Address
6161 @cindex Subprogram address
6162 @cindex Address of subprogram code
6165 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
6166 intended effect seems to be to provide
6167 an address value which can be used to call the subprogram by means of
6168 an address clause as in the following example:
6170 @smallexample @c ada
6171 procedure K is @dots{}
6174 for L'Address use K'Address;
6175 pragma Import (Ada, L);
6179 A call to @code{L} is then expected to result in a call to @code{K}@.
6180 In Ada 83, where there were no access-to-subprogram values, this was
6181 a common work-around for getting the effect of an indirect call.
6182 GNAT implements the above use of @code{Address} and the technique
6183 illustrated by the example code works correctly.
6185 However, for some purposes, it is useful to have the address of the start
6186 of the generated code for the subprogram. On some architectures, this is
6187 not necessarily the same as the @code{Address} value described above.
6188 For example, the @code{Address} value may reference a subprogram
6189 descriptor rather than the subprogram itself.
6191 The @code{'Code_Address} attribute, which can only be applied to
6192 subprogram entities, always returns the address of the start of the
6193 generated code of the specified subprogram, which may or may not be
6194 the same value as is returned by the corresponding @code{'Address}
6197 @node Default_Bit_Order
6198 @unnumberedsec Default_Bit_Order
6200 @cindex Little endian
6201 @findex Default_Bit_Order
6203 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
6204 permissible prefix), provides the value @code{System.Default_Bit_Order}
6205 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
6206 @code{Low_Order_First}). This is used to construct the definition of
6207 @code{Default_Bit_Order} in package @code{System}.
6209 @node Descriptor_Size
6210 @unnumberedsec Descriptor_Size
6213 @findex Descriptor_Size
6215 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
6216 descriptor allocated for a type. The result is non-zero only for unconstrained
6217 array types and the returned value is of type universal integer. In GNAT, an
6218 array descriptor contains bounds information and is located immediately before
6219 the first element of the array.
6221 @smallexample @c ada
6222 type Unconstr_Array is array (Positive range <>) of Boolean;
6223 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
6227 The attribute takes into account any additional padding due to type alignment.
6228 In the example above, the descriptor contains two values of type
6229 @code{Positive} representing the low and high bound. Since @code{Positive} has
6230 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
6231 Positive'Size + 2} or 64 bits.
6234 @unnumberedsec Elaborated
6237 The prefix of the @code{'Elaborated} attribute must be a unit name. The
6238 value is a Boolean which indicates whether or not the given unit has been
6239 elaborated. This attribute is primarily intended for internal use by the
6240 generated code for dynamic elaboration checking, but it can also be used
6241 in user programs. The value will always be True once elaboration of all
6242 units has been completed. An exception is for units which need no
6243 elaboration, the value is always False for such units.
6246 @unnumberedsec Elab_Body
6249 This attribute can only be applied to a program unit name. It returns
6250 the entity for the corresponding elaboration procedure for elaborating
6251 the body of the referenced unit. This is used in the main generated
6252 elaboration procedure by the binder and is not normally used in any
6253 other context. However, there may be specialized situations in which it
6254 is useful to be able to call this elaboration procedure from Ada code,
6255 e.g.@: if it is necessary to do selective re-elaboration to fix some
6259 @unnumberedsec Elab_Spec
6262 This attribute can only be applied to a program unit name. It returns
6263 the entity for the corresponding elaboration procedure for elaborating
6264 the spec of the referenced unit. This is used in the main
6265 generated elaboration procedure by the binder and is not normally used
6266 in any other context. However, there may be specialized situations in
6267 which it is useful to be able to call this elaboration procedure from
6268 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
6271 @node Elab_Subp_Body
6272 @unnumberedsec Elab_Subp_Body
6273 @findex Elab_Subp_Body
6275 This attribute can only be applied to a library level subprogram
6276 name and is only allowed in CodePeer mode. It returns the entity
6277 for the corresponding elaboration procedure for elaborating the body
6278 of the referenced subprogram unit. This is used in the main generated
6279 elaboration procedure by the binder in CodePeer mode only and is unrecognized
6284 @cindex Ada 83 attributes
6287 The @code{Emax} attribute is provided for compatibility with Ada 83. See
6288 the Ada 83 reference manual for an exact description of the semantics of
6292 @unnumberedsec Enabled
6295 The @code{Enabled} attribute allows an application program to check at compile
6296 time to see if the designated check is currently enabled. The prefix is a
6297 simple identifier, referencing any predefined check name (other than
6298 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
6299 no argument is given for the attribute, the check is for the general state
6300 of the check, if an argument is given, then it is an entity name, and the
6301 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
6302 given naming the entity (if not, then the argument is ignored).
6304 Note that instantiations inherit the check status at the point of the
6305 instantiation, so a useful idiom is to have a library package that
6306 introduces a check name with @code{pragma Check_Name}, and then contains
6307 generic packages or subprograms which use the @code{Enabled} attribute
6308 to see if the check is enabled. A user of this package can then issue
6309 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
6310 the package or subprogram, controlling whether the check will be present.
6313 @unnumberedsec Enum_Rep
6314 @cindex Representation of enums
6317 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
6318 function with the following spec:
6320 @smallexample @c ada
6321 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
6322 return @i{Universal_Integer};
6326 It is also allowable to apply @code{Enum_Rep} directly to an object of an
6327 enumeration type or to a non-overloaded enumeration
6328 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
6329 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
6330 enumeration literal or object.
6332 The function returns the representation value for the given enumeration
6333 value. This will be equal to value of the @code{Pos} attribute in the
6334 absence of an enumeration representation clause. This is a static
6335 attribute (i.e.@: the result is static if the argument is static).
6337 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
6338 in which case it simply returns the integer value. The reason for this
6339 is to allow it to be used for @code{(<>)} discrete formal arguments in
6340 a generic unit that can be instantiated with either enumeration types
6341 or integer types. Note that if @code{Enum_Rep} is used on a modular
6342 type whose upper bound exceeds the upper bound of the largest signed
6343 integer type, and the argument is a variable, so that the universal
6344 integer calculation is done at run time, then the call to @code{Enum_Rep}
6345 may raise @code{Constraint_Error}.
6348 @unnumberedsec Enum_Val
6349 @cindex Representation of enums
6352 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
6353 function with the following spec:
6355 @smallexample @c ada
6356 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
6357 return @var{S}'Base};
6361 The function returns the enumeration value whose representation matches the
6362 argument, or raises Constraint_Error if no enumeration literal of the type
6363 has the matching value.
6364 This will be equal to value of the @code{Val} attribute in the
6365 absence of an enumeration representation clause. This is a static
6366 attribute (i.e.@: the result is static if the argument is static).
6369 @unnumberedsec Epsilon
6370 @cindex Ada 83 attributes
6373 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
6374 the Ada 83 reference manual for an exact description of the semantics of
6378 @unnumberedsec Fixed_Value
6381 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
6382 function with the following specification:
6384 @smallexample @c ada
6385 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
6390 The value returned is the fixed-point value @var{V} such that
6392 @smallexample @c ada
6393 @var{V} = Arg * @var{S}'Small
6397 The effect is thus similar to first converting the argument to the
6398 integer type used to represent @var{S}, and then doing an unchecked
6399 conversion to the fixed-point type. The difference is
6400 that there are full range checks, to ensure that the result is in range.
6401 This attribute is primarily intended for use in implementation of the
6402 input-output functions for fixed-point values.
6404 @node Has_Access_Values
6405 @unnumberedsec Has_Access_Values
6406 @cindex Access values, testing for
6407 @findex Has_Access_Values
6409 The prefix of the @code{Has_Access_Values} attribute is a type. The result
6410 is a Boolean value which is True if the is an access type, or is a composite
6411 type with a component (at any nesting depth) that is an access type, and is
6413 The intended use of this attribute is in conjunction with generic
6414 definitions. If the attribute is applied to a generic private type, it
6415 indicates whether or not the corresponding actual type has access values.
6417 @node Has_Discriminants
6418 @unnumberedsec Has_Discriminants
6419 @cindex Discriminants, testing for
6420 @findex Has_Discriminants
6422 The prefix of the @code{Has_Discriminants} attribute is a type. The result
6423 is a Boolean value which is True if the type has discriminants, and False
6424 otherwise. The intended use of this attribute is in conjunction with generic
6425 definitions. If the attribute is applied to a generic private type, it
6426 indicates whether or not the corresponding actual type has discriminants.
6432 The @code{Img} attribute differs from @code{Image} in that it may be
6433 applied to objects as well as types, in which case it gives the
6434 @code{Image} for the subtype of the object. This is convenient for
6437 @smallexample @c ada
6438 Put_Line ("X = " & X'Img);
6442 has the same meaning as the more verbose:
6444 @smallexample @c ada
6445 Put_Line ("X = " & @var{T}'Image (X));
6449 where @var{T} is the (sub)type of the object @code{X}.
6452 @unnumberedsec Integer_Value
6453 @findex Integer_Value
6455 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
6456 function with the following spec:
6458 @smallexample @c ada
6459 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
6464 The value returned is the integer value @var{V}, such that
6466 @smallexample @c ada
6467 Arg = @var{V} * @var{T}'Small
6471 where @var{T} is the type of @code{Arg}.
6472 The effect is thus similar to first doing an unchecked conversion from
6473 the fixed-point type to its corresponding implementation type, and then
6474 converting the result to the target integer type. The difference is
6475 that there are full range checks, to ensure that the result is in range.
6476 This attribute is primarily intended for use in implementation of the
6477 standard input-output functions for fixed-point values.
6480 @unnumberedsec Invalid_Value
6481 @findex Invalid_Value
6483 For every scalar type S, S'Invalid_Value returns an undefined value of the
6484 type. If possible this value is an invalid representation for the type. The
6485 value returned is identical to the value used to initialize an otherwise
6486 uninitialized value of the type if pragma Initialize_Scalars is used,
6487 including the ability to modify the value with the binder -Sxx flag and
6488 relevant environment variables at run time.
6491 @unnumberedsec Large
6492 @cindex Ada 83 attributes
6495 The @code{Large} attribute is provided for compatibility with Ada 83. See
6496 the Ada 83 reference manual for an exact description of the semantics of
6500 @unnumberedsec Machine_Size
6501 @findex Machine_Size
6503 This attribute is identical to the @code{Object_Size} attribute. It is
6504 provided for compatibility with the DEC Ada 83 attribute of this name.
6507 @unnumberedsec Mantissa
6508 @cindex Ada 83 attributes
6511 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
6512 the Ada 83 reference manual for an exact description of the semantics of
6515 @node Max_Interrupt_Priority
6516 @unnumberedsec Max_Interrupt_Priority
6517 @cindex Interrupt priority, maximum
6518 @findex Max_Interrupt_Priority
6520 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6521 permissible prefix), provides the same value as
6522 @code{System.Max_Interrupt_Priority}.
6525 @unnumberedsec Max_Priority
6526 @cindex Priority, maximum
6527 @findex Max_Priority
6529 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
6530 prefix) provides the same value as @code{System.Max_Priority}.
6532 @node Maximum_Alignment
6533 @unnumberedsec Maximum_Alignment
6534 @cindex Alignment, maximum
6535 @findex Maximum_Alignment
6537 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
6538 permissible prefix) provides the maximum useful alignment value for the
6539 target. This is a static value that can be used to specify the alignment
6540 for an object, guaranteeing that it is properly aligned in all
6543 @node Mechanism_Code
6544 @unnumberedsec Mechanism_Code
6545 @cindex Return values, passing mechanism
6546 @cindex Parameters, passing mechanism
6547 @findex Mechanism_Code
6549 @code{@var{function}'Mechanism_Code} yields an integer code for the
6550 mechanism used for the result of function, and
6551 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
6552 used for formal parameter number @var{n} (a static integer value with 1
6553 meaning the first parameter) of @var{subprogram}. The code returned is:
6561 by descriptor (default descriptor class)
6563 by descriptor (UBS: unaligned bit string)
6565 by descriptor (UBSB: aligned bit string with arbitrary bounds)
6567 by descriptor (UBA: unaligned bit array)
6569 by descriptor (S: string, also scalar access type parameter)
6571 by descriptor (SB: string with arbitrary bounds)
6573 by descriptor (A: contiguous array)
6575 by descriptor (NCA: non-contiguous array)
6579 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
6582 @node Null_Parameter
6583 @unnumberedsec Null_Parameter
6584 @cindex Zero address, passing
6585 @findex Null_Parameter
6587 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
6588 type or subtype @var{T} allocated at machine address zero. The attribute
6589 is allowed only as the default expression of a formal parameter, or as
6590 an actual expression of a subprogram call. In either case, the
6591 subprogram must be imported.
6593 The identity of the object is represented by the address zero in the
6594 argument list, independent of the passing mechanism (explicit or
6597 This capability is needed to specify that a zero address should be
6598 passed for a record or other composite object passed by reference.
6599 There is no way of indicating this without the @code{Null_Parameter}
6603 @unnumberedsec Object_Size
6604 @cindex Size, used for objects
6607 The size of an object is not necessarily the same as the size of the type
6608 of an object. This is because by default object sizes are increased to be
6609 a multiple of the alignment of the object. For example,
6610 @code{Natural'Size} is
6611 31, but by default objects of type @code{Natural} will have a size of 32 bits.
6612 Similarly, a record containing an integer and a character:
6614 @smallexample @c ada
6622 will have a size of 40 (that is @code{Rec'Size} will be 40). The
6623 alignment will be 4, because of the
6624 integer field, and so the default size of record objects for this type
6625 will be 64 (8 bytes).
6627 @node Passed_By_Reference
6628 @unnumberedsec Passed_By_Reference
6629 @cindex Parameters, when passed by reference
6630 @findex Passed_By_Reference
6632 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6633 a value of type @code{Boolean} value that is @code{True} if the type is
6634 normally passed by reference and @code{False} if the type is normally
6635 passed by copy in calls. For scalar types, the result is always @code{False}
6636 and is static. For non-scalar types, the result is non-static.
6639 @unnumberedsec Pool_Address
6640 @cindex Parameters, when passed by reference
6641 @findex Pool_Address
6643 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6644 of X within its storage pool. This is the same as
6645 @code{@var{X}'Address}, except that for an unconstrained array whose
6646 bounds are allocated just before the first component,
6647 @code{@var{X}'Pool_Address} returns the address of those bounds,
6648 whereas @code{@var{X}'Address} returns the address of the first
6651 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6652 the object is allocated'', which could be a user-defined storage pool,
6653 the global heap, on the stack, or in a static memory area. For an
6654 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6655 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6658 @unnumberedsec Range_Length
6659 @findex Range_Length
6661 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6662 the number of values represented by the subtype (zero for a null
6663 range). The result is static for static subtypes. @code{Range_Length}
6664 applied to the index subtype of a one dimensional array always gives the
6665 same result as @code{Range} applied to the array itself.
6671 The @code{System.Address'Ref}
6672 (@code{System.Address} is the only permissible prefix)
6673 denotes a function identical to
6674 @code{System.Storage_Elements.To_Address} except that
6675 it is a static attribute. See @ref{To_Address} for more details.
6678 @unnumberedsec Result
6681 @code{@var{function}'Result} can only be used with in a Postcondition pragma
6682 for a function. The prefix must be the name of the corresponding function. This
6683 is used to refer to the result of the function in the postcondition expression.
6684 For a further discussion of the use of this attribute and examples of its use,
6685 see the description of pragma Postcondition.
6688 @unnumberedsec Safe_Emax
6689 @cindex Ada 83 attributes
6692 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
6693 the Ada 83 reference manual for an exact description of the semantics of
6697 @unnumberedsec Safe_Large
6698 @cindex Ada 83 attributes
6701 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
6702 the Ada 83 reference manual for an exact description of the semantics of
6705 @node Scalar_Storage_Order
6706 @unnumberedsec Scalar_Storage_Order
6708 @cindex Scalar storage order
6709 @findex Scalar_Storage_Order
6711 For every array or record type @var{S}, the representation attribute
6712 @code{Scalar_Storage_Order} denotes the order in which storage elements
6713 that make up scalar components are ordered within S. Other properties are
6714 as for standard representation attribute @code{Bit_Order}, as defined by
6715 Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
6717 If @code{@var{S}'Scalar_Storage_Order} is specified explicitly, it shall be
6718 equal to @code{@var{S}'Bit_Order}. Note: This means that if a
6719 @code{Scalar_Storage_Order} attribute definition clause is not confirming,
6720 then the type's @code{Bit_Order} shall be specified explicitly and set to
6723 If a component of S has itself a record or array type, then it shall also
6724 have a @code{Scalar_Storage_Order} attribute definition clause. In addition,
6725 if the component does not start on a byte boundary, then the scalar storage
6726 order specified for S and for the nested component type shall be identical.
6728 No component of a type that has a @code{Scalar_Storage_Order} attribute
6729 definition may be aliased.
6731 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
6732 with a value equal to @code{System.Default_Bit_Order}) has no effect.
6734 If the opposite storage order is specified, then whenever the value of
6735 a scalar component of S is read, the storage elements of the enclosing
6736 machine scalar are first reversed (before retrieving the component value,
6737 possibly applying some shift and mask operatings on the enclosing machine
6738 scalar), and the opposite operation is done for writes.
6740 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
6741 are relaxed. Instead, the following rules apply:
6744 @item the underlying storage elements are those at positions
6745 @code{(position + first_bit / storage_element_size) ..
6746 (position + (last_bit + storage_element_size - 1) /
6747 storage_element_size)}
6748 @item the sequence of underlying storage elements shall have
6749 a size no greater than the largest machine scalar
6750 @item the enclosing machine scalar is defined as the smallest machine
6751 scalar starting at a position no greater than
6752 @code{position + first_bit / storage_element_size} and covering
6753 storage elements at least up to @code{position + (last_bit +
6754 storage_element_size - 1) / storage_element_size}
6755 @item the position of the component is interpreted relative to that machine
6760 @node Simple_Storage_Pool
6761 @unnumberedsec Simple_Storage_Pool
6762 @cindex Storage pool, simple
6763 @cindex Simple storage pool
6764 @findex Simple_Storage_Pool
6766 For every nonformal, nonderived access-to-object type @var{Acc}, the
6767 representation attribute @code{Simple_Storage_Pool} may be specified
6768 via an attribute_definition_clause (or by specifying the equivalent aspect):
6770 @smallexample @c ada
6772 My_Pool : My_Simple_Storage_Pool_Type;
6774 type Acc is access My_Data_Type;
6776 for Acc'Simple_Storage_Pool use My_Pool;
6781 The name given in an attribute_definition_clause for the
6782 @code{Simple_Storage_Pool} attribute shall denote a variable of
6783 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
6785 The use of this attribute is only allowed for a prefix denoting a type
6786 for which it has been specified. The type of the attribute is the type
6787 of the variable specified as the simple storage pool of the access type,
6788 and the attribute denotes that variable.
6790 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
6791 for the same access type.
6793 If the @code{Simple_Storage_Pool} attribute has been specified for an access
6794 type, then applying the @code{Storage_Pool} attribute to the type is flagged
6795 with a warning and its evaluation raises the exception @code{Program_Error}.
6797 If the Simple_Storage_Pool attribute has been specified for an access
6798 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
6799 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
6800 which is intended to indicate the number of storage elements reserved for
6801 the simple storage pool. If the Storage_Size function has not been defined
6802 for the simple storage pool type, then this attribute returns zero.
6804 If an access type @var{S} has a specified simple storage pool of type
6805 @var{SSP}, then the evaluation of an allocator for that access type calls
6806 the primitive @code{Allocate} procedure for type @var{SSP}, passing
6807 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
6808 semantics of such allocators is the same as those defined for allocators
6809 in section 13.11 of the Ada Reference Manual, with the term
6810 ``simple storage pool'' substituted for ``storage pool''.
6812 If an access type @var{S} has a specified simple storage pool of type
6813 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
6814 for that access type invokes the primitive @code{Deallocate} procedure
6815 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
6816 parameter. The detailed semantics of such unchecked deallocations is the same
6817 as defined in section 13.11.2 of the Ada Reference Manual, except that the
6818 term ``simple storage pool'' is substituted for ``storage pool''.
6821 @unnumberedsec Small
6822 @cindex Ada 83 attributes
6825 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6827 GNAT also allows this attribute to be applied to floating-point types
6828 for compatibility with Ada 83. See
6829 the Ada 83 reference manual for an exact description of the semantics of
6830 this attribute when applied to floating-point types.
6833 @unnumberedsec Storage_Unit
6834 @findex Storage_Unit
6836 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6837 prefix) provides the same value as @code{System.Storage_Unit}.
6840 @unnumberedsec Stub_Type
6843 The GNAT implementation of remote access-to-classwide types is
6844 organized as described in AARM section E.4 (20.t): a value of an RACW type
6845 (designating a remote object) is represented as a normal access
6846 value, pointing to a "stub" object which in turn contains the
6847 necessary information to contact the designated remote object. A
6848 call on any dispatching operation of such a stub object does the
6849 remote call, if necessary, using the information in the stub object
6850 to locate the target partition, etc.
6852 For a prefix @code{T} that denotes a remote access-to-classwide type,
6853 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6855 By construction, the layout of @code{T'Stub_Type} is identical to that of
6856 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6857 unit @code{System.Partition_Interface}. Use of this attribute will create
6858 an implicit dependency on this unit.
6860 @node System_Allocator_Alignment
6861 @unnumberedsec System_Allocator_Alignment
6862 @cindex Alignment, allocator
6863 @findex System_Allocator_Alignment
6865 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
6866 permissible prefix) provides the observable guaranted to be honored by
6867 the system allocator (malloc). This is a static value that can be used
6868 in user storage pools based on malloc either to reject allocation
6869 with alignment too large or to enable a realignment circuitry if the
6870 alignment request is larger than this value.
6873 @unnumberedsec Target_Name
6876 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6877 prefix) provides a static string value that identifies the target
6878 for the current compilation. For GCC implementations, this is the
6879 standard gcc target name without the terminating slash (for
6880 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6886 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6887 provides the same value as @code{System.Tick},
6890 @unnumberedsec To_Address
6893 The @code{System'To_Address}
6894 (@code{System} is the only permissible prefix)
6895 denotes a function identical to
6896 @code{System.Storage_Elements.To_Address} except that
6897 it is a static attribute. This means that if its argument is
6898 a static expression, then the result of the attribute is a
6899 static expression. The result is that such an expression can be
6900 used in contexts (e.g.@: preelaborable packages) which require a
6901 static expression and where the function call could not be used
6902 (since the function call is always non-static, even if its
6903 argument is static).
6906 @unnumberedsec Type_Class
6909 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6910 the value of the type class for the full type of @var{type}. If
6911 @var{type} is a generic formal type, the value is the value for the
6912 corresponding actual subtype. The value of this attribute is of type
6913 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6915 @smallexample @c ada
6917 (Type_Class_Enumeration,
6919 Type_Class_Fixed_Point,
6920 Type_Class_Floating_Point,
6925 Type_Class_Address);
6929 Protected types yield the value @code{Type_Class_Task}, which thus
6930 applies to all concurrent types. This attribute is designed to
6931 be compatible with the DEC Ada 83 attribute of the same name.
6934 @unnumberedsec UET_Address
6937 The @code{UET_Address} attribute can only be used for a prefix which
6938 denotes a library package. It yields the address of the unit exception
6939 table when zero cost exception handling is used. This attribute is
6940 intended only for use within the GNAT implementation. See the unit
6941 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6942 for details on how this attribute is used in the implementation.
6944 @node Unconstrained_Array
6945 @unnumberedsec Unconstrained_Array
6946 @findex Unconstrained_Array
6948 The @code{Unconstrained_Array} attribute can be used with a prefix that
6949 denotes any type or subtype. It is a static attribute that yields
6950 @code{True} if the prefix designates an unconstrained array,
6951 and @code{False} otherwise. In a generic instance, the result is
6952 still static, and yields the result of applying this test to the
6955 @node Universal_Literal_String
6956 @unnumberedsec Universal_Literal_String
6957 @cindex Named numbers, representation of
6958 @findex Universal_Literal_String
6960 The prefix of @code{Universal_Literal_String} must be a named
6961 number. The static result is the string consisting of the characters of
6962 the number as defined in the original source. This allows the user
6963 program to access the actual text of named numbers without intermediate
6964 conversions and without the need to enclose the strings in quotes (which
6965 would preclude their use as numbers).
6967 For example, the following program prints the first 50 digits of pi:
6969 @smallexample @c ada
6970 with Text_IO; use Text_IO;
6974 Put (Ada.Numerics.Pi'Universal_Literal_String);
6978 @node Unrestricted_Access
6979 @unnumberedsec Unrestricted_Access
6980 @cindex @code{Access}, unrestricted
6981 @findex Unrestricted_Access
6983 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6984 except that all accessibility and aliased view checks are omitted. This
6985 is a user-beware attribute. It is similar to
6986 @code{Address}, for which it is a desirable replacement where the value
6987 desired is an access type. In other words, its effect is identical to
6988 first applying the @code{Address} attribute and then doing an unchecked
6989 conversion to a desired access type. In GNAT, but not necessarily in
6990 other implementations, the use of static chains for inner level
6991 subprograms means that @code{Unrestricted_Access} applied to a
6992 subprogram yields a value that can be called as long as the subprogram
6993 is in scope (normal Ada accessibility rules restrict this usage).
6995 It is possible to use @code{Unrestricted_Access} for any type, but care
6996 must be exercised if it is used to create pointers to unconstrained
6997 objects. In this case, the resulting pointer has the same scope as the
6998 context of the attribute, and may not be returned to some enclosing
6999 scope. For instance, a function cannot use @code{Unrestricted_Access}
7000 to create a unconstrained pointer and then return that value to the
7004 @unnumberedsec Valid_Scalars
7005 @findex Valid_Scalars
7007 The @code{'Valid_Scalars} attribute is intended to make it easier to
7008 check the validity of scalar subcomponents of composite objects. It
7009 is defined for any prefix @code{X} that denotes an object.
7010 The value of this attribute is of the predefined type Boolean.
7011 @code{X'Valid_Scalars} yields True if and only if evaluation of
7012 @code{P'Valid} yields True for every scalar part P of X or if X has
7013 no scalar parts. It is not specified in what order the scalar parts
7014 are checked, nor whether any more are checked after any one of them
7015 is determined to be invalid. If the prefix @code{X} is of a class-wide
7016 type @code{T'Class} (where @code{T} is the associated specific type),
7017 or if the prefix @code{X} is of a specific tagged type @code{T}, then
7018 only the scalar parts of components of @code{T} are traversed; in other
7019 words, components of extensions of @code{T} are not traversed even if
7020 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
7021 be determined at compile time that the prefix of the attribute has no
7022 scalar parts (e.g., if the prefix is of an access type, an interface type,
7023 an undiscriminated task type, or an undiscriminated protected type).
7026 @unnumberedsec VADS_Size
7027 @cindex @code{Size}, VADS compatibility
7030 The @code{'VADS_Size} attribute is intended to make it easier to port
7031 legacy code which relies on the semantics of @code{'Size} as implemented
7032 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
7033 same semantic interpretation. In particular, @code{'VADS_Size} applied
7034 to a predefined or other primitive type with no Size clause yields the
7035 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
7036 typical machines). In addition @code{'VADS_Size} applied to an object
7037 gives the result that would be obtained by applying the attribute to
7038 the corresponding type.
7041 @unnumberedsec Value_Size
7042 @cindex @code{Size}, setting for not-first subtype
7044 @code{@var{type}'Value_Size} is the number of bits required to represent
7045 a value of the given subtype. It is the same as @code{@var{type}'Size},
7046 but, unlike @code{Size}, may be set for non-first subtypes.
7049 @unnumberedsec Wchar_T_Size
7050 @findex Wchar_T_Size
7051 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
7052 prefix) provides the size in bits of the C @code{wchar_t} type
7053 primarily for constructing the definition of this type in
7054 package @code{Interfaces.C}.
7057 @unnumberedsec Word_Size
7059 @code{Standard'Word_Size} (@code{Standard} is the only permissible
7060 prefix) provides the value @code{System.Word_Size}.
7062 @node Standard and Implementation Defined Restrictions
7063 @chapter Standard and Implementation Defined Restrictions
7066 All RM defined Restriction identifiers are implemented:
7069 @item language-defined restrictions (see 13.12.1)
7070 @item tasking restrictions (see D.7)
7071 @item high integrity restrictions (see H.4)
7075 GNAT implements additional restriction identifiers. All restrictions, whether
7076 language defined or GNAT-specific, are listed in the following.
7079 * Partition-Wide Restrictions::
7080 * Program Unit Level Restrictions::
7083 @node Partition-Wide Restrictions
7084 @section Partition-Wide Restrictions
7086 There are two separate lists of restriction identifiers. The first
7087 set requires consistency throughout a partition (in other words, if the
7088 restriction identifier is used for any compilation unit in the partition,
7089 then all compilation units in the partition must obey the restriction).
7092 * Immediate_Reclamation::
7093 * Max_Asynchronous_Select_Nesting::
7094 * Max_Entry_Queue_Length::
7095 * Max_Protected_Entries::
7096 * Max_Select_Alternatives::
7097 * Max_Storage_At_Blocking::
7098 * Max_Task_Entries::
7100 * No_Abort_Statements::
7101 * No_Access_Parameter_Allocators::
7102 * No_Access_Subprograms::
7104 * No_Anonymous_Allocators::
7107 * No_Default_Initialization::
7110 * No_Direct_Boolean_Operators::
7112 * No_Dispatching_Calls::
7113 * No_Dynamic_Attachment::
7114 * No_Dynamic_Priorities::
7115 * No_Entry_Calls_In_Elaboration_Code::
7116 * No_Enumeration_Maps::
7117 * No_Exception_Handlers::
7118 * No_Exception_Propagation::
7119 * No_Exception_Registration::
7123 * No_Floating_Point::
7124 * No_Implicit_Conditionals::
7125 * No_Implicit_Dynamic_Code::
7126 * No_Implicit_Heap_Allocations::
7127 * No_Implicit_Loops::
7128 * No_Initialize_Scalars::
7130 * No_Local_Allocators::
7131 * No_Local_Protected_Objects::
7132 * No_Local_Timing_Events::
7133 * No_Nested_Finalization::
7134 * No_Protected_Type_Allocators::
7135 * No_Protected_Types::
7138 * No_Relative_Delay::
7139 * No_Requeue_Statements::
7140 * No_Secondary_Stack::
7141 * No_Select_Statements::
7142 * No_Specific_Termination_Handlers::
7143 * No_Specification_of_Aspect::
7144 * No_Standard_Allocators_After_Elaboration::
7145 * No_Standard_Storage_Pools::
7146 * No_Stream_Optimizations::
7148 * No_Task_Allocators::
7149 * No_Task_Attributes_Package::
7150 * No_Task_Hierarchy::
7151 * No_Task_Termination::
7153 * No_Terminate_Alternatives::
7154 * No_Unchecked_Access::
7156 * Static_Priorities::
7157 * Static_Storage_Size::
7160 @node Immediate_Reclamation
7161 @unnumberedsubsec Immediate_Reclamation
7162 @findex Immediate_Reclamation
7163 [RM H.4] This restriction ensures that, except for storage occupied by
7164 objects created by allocators and not deallocated via unchecked
7165 deallocation, any storage reserved at run time for an object is
7166 immediately reclaimed when the object no longer exists.
7168 @node Max_Asynchronous_Select_Nesting
7169 @unnumberedsubsec Max_Asynchronous_Select_Nesting
7170 @findex Max_Asynchronous_Select_Nesting
7171 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
7172 selects. Violations of this restriction with a value of zero are
7173 detected at compile time. Violations of this restriction with values
7174 other than zero cause Storage_Error to be raised.
7176 @node Max_Entry_Queue_Length
7177 @unnumberedsubsec Max_Entry_Queue_Length
7178 @findex Max_Entry_Queue_Length
7179 [RM D.7] This restriction is a declaration that any protected entry compiled in
7180 the scope of the restriction has at most the specified number of
7181 tasks waiting on the entry at any one time, and so no queue is required.
7182 Note that this restriction is checked at run time. Violation of this
7183 restriction results in the raising of Program_Error exception at the point of
7186 @node Max_Protected_Entries
7187 @unnumberedsubsec Max_Protected_Entries
7188 @findex Max_Protected_Entries
7189 [RM D.7] Specifies the maximum number of entries per protected type. The
7190 bounds of every entry family of a protected unit shall be static, or shall be
7191 defined by a discriminant of a subtype whose corresponding bound is static.
7193 @node Max_Select_Alternatives
7194 @unnumberedsubsec Max_Select_Alternatives
7195 @findex Max_Select_Alternatives
7196 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
7198 @node Max_Storage_At_Blocking
7199 @unnumberedsubsec Max_Storage_At_Blocking
7200 @findex Max_Storage_At_Blocking
7201 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
7202 Storage_Size that can be retained by a blocked task. A violation of this
7203 restriction causes Storage_Error to be raised.
7205 @node Max_Task_Entries
7206 @unnumberedsubsec Max_Task_Entries
7207 @findex Max_Task_Entries
7208 [RM D.7] Specifies the maximum number of entries
7209 per task. The bounds of every entry family
7210 of a task unit shall be static, or shall be
7211 defined by a discriminant of a subtype whose
7212 corresponding bound is static.
7215 @unnumberedsubsec Max_Tasks
7217 [RM D.7] Specifies the maximum number of task that may be created, not
7218 counting the creation of the environment task. Violations of this
7219 restriction with a value of zero are detected at compile
7220 time. Violations of this restriction with values other than zero cause
7221 Storage_Error to be raised.
7223 @node No_Abort_Statements
7224 @unnumberedsubsec No_Abort_Statements
7225 @findex No_Abort_Statements
7226 [RM D.7] There are no abort_statements, and there are
7227 no calls to Task_Identification.Abort_Task.
7229 @node No_Access_Parameter_Allocators
7230 @unnumberedsubsec No_Access_Parameter_Allocators
7231 @findex No_Access_Parameter_Allocators
7232 [RM H.4] This restriction ensures at compile time that there are no
7233 occurrences of an allocator as the actual parameter to an access
7236 @node No_Access_Subprograms
7237 @unnumberedsubsec No_Access_Subprograms
7238 @findex No_Access_Subprograms
7239 [RM H.4] This restriction ensures at compile time that there are no
7240 declarations of access-to-subprogram types.
7243 @unnumberedsubsec No_Allocators
7244 @findex No_Allocators
7245 [RM H.4] This restriction ensures at compile time that there are no
7246 occurrences of an allocator.
7248 @node No_Anonymous_Allocators
7249 @unnumberedsubsec No_Anonymous_Allocators
7250 @findex No_Anonymous_Allocators
7251 [RM H.4] This restriction ensures at compile time that there are no
7252 occurrences of an allocator of anonymous access type.
7255 @unnumberedsubsec No_Calendar
7257 [GNAT] This restriction ensures at compile time that there is no implicit or
7258 explicit dependence on the package @code{Ada.Calendar}.
7260 @node No_Coextensions
7261 @unnumberedsubsec No_Coextensions
7262 @findex No_Coextensions
7263 [RM H.4] This restriction ensures at compile time that there are no
7264 coextensions. See 3.10.2.
7266 @node No_Default_Initialization
7267 @unnumberedsubsec No_Default_Initialization
7268 @findex No_Default_Initialization
7270 [GNAT] This restriction prohibits any instance of default initialization
7271 of variables. The binder implements a consistency rule which prevents
7272 any unit compiled without the restriction from with'ing a unit with the
7273 restriction (this allows the generation of initialization procedures to
7274 be skipped, since you can be sure that no call is ever generated to an
7275 initialization procedure in a unit with the restriction active). If used
7276 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
7277 is to prohibit all cases of variables declared without a specific
7278 initializer (including the case of OUT scalar parameters).
7281 @unnumberedsubsec No_Delay
7283 [RM H.4] This restriction ensures at compile time that there are no
7284 delay statements and no dependences on package Calendar.
7287 @unnumberedsubsec No_Dependence
7288 @findex No_Dependence
7289 [RM 13.12.1] This restriction checks at compile time that there are no
7290 dependence on a library unit.
7292 @node No_Direct_Boolean_Operators
7293 @unnumberedsubsec No_Direct_Boolean_Operators
7294 @findex No_Direct_Boolean_Operators
7295 [GNAT] This restriction ensures that no logical (and/or/xor) are used on
7296 operands of type Boolean (or any type derived
7297 from Boolean). This is intended for use in safety critical programs
7298 where the certification protocol requires the use of short-circuit
7299 (and then, or else) forms for all composite boolean operations.
7302 @unnumberedsubsec No_Dispatch
7304 [RM H.4] This restriction ensures at compile time that there are no
7305 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
7307 @node No_Dispatching_Calls
7308 @unnumberedsubsec No_Dispatching_Calls
7309 @findex No_Dispatching_Calls
7310 [GNAT] This restriction ensures at compile time that the code generated by the
7311 compiler involves no dispatching calls. The use of this restriction allows the
7312 safe use of record extensions, classwide membership tests and other classwide
7313 features not involving implicit dispatching. This restriction ensures that
7314 the code contains no indirect calls through a dispatching mechanism. Note that
7315 this includes internally-generated calls created by the compiler, for example
7316 in the implementation of class-wide objects assignments. The
7317 membership test is allowed in the presence of this restriction, because its
7318 implementation requires no dispatching.
7319 This restriction is comparable to the official Ada restriction
7320 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7321 all classwide constructs that do not imply dispatching.
7322 The following example indicates constructs that violate this restriction.
7326 type T is tagged record
7329 procedure P (X : T);
7331 type DT is new T with record
7332 More_Data : Natural;
7334 procedure Q (X : DT);
7338 procedure Example is
7339 procedure Test (O : T'Class) is
7340 N : Natural := O'Size;-- Error: Dispatching call
7341 C : T'Class := O; -- Error: implicit Dispatching Call
7343 if O in DT'Class then -- OK : Membership test
7344 Q (DT (O)); -- OK : Type conversion plus direct call
7346 P (O); -- Error: Dispatching call
7352 P (Obj); -- OK : Direct call
7353 P (T (Obj)); -- OK : Type conversion plus direct call
7354 P (T'Class (Obj)); -- Error: Dispatching call
7356 Test (Obj); -- OK : Type conversion
7358 if Obj in T'Class then -- OK : Membership test
7364 @node No_Dynamic_Attachment
7365 @unnumberedsubsec No_Dynamic_Attachment
7366 @findex No_Dynamic_Attachment
7367 [RM D.7] This restriction ensures that there is no call to any of the
7368 operations defined in package Ada.Interrupts
7369 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
7370 Detach_Handler, and Reference).
7372 @node No_Dynamic_Priorities
7373 @unnumberedsubsec No_Dynamic_Priorities
7374 @findex No_Dynamic_Priorities
7375 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
7377 @node No_Entry_Calls_In_Elaboration_Code
7378 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
7379 @findex No_Entry_Calls_In_Elaboration_Code
7380 [GNAT] This restriction ensures at compile time that no task or protected entry
7381 calls are made during elaboration code. As a result of the use of this
7382 restriction, the compiler can assume that no code past an accept statement
7383 in a task can be executed at elaboration time.
7385 @node No_Enumeration_Maps
7386 @unnumberedsubsec No_Enumeration_Maps
7387 @findex No_Enumeration_Maps
7388 [GNAT] This restriction ensures at compile time that no operations requiring
7389 enumeration maps are used (that is Image and Value attributes applied
7390 to enumeration types).
7392 @node No_Exception_Handlers
7393 @unnumberedsubsec No_Exception_Handlers
7394 @findex No_Exception_Handlers
7395 [GNAT] This restriction ensures at compile time that there are no explicit
7396 exception handlers. It also indicates that no exception propagation will
7397 be provided. In this mode, exceptions may be raised but will result in
7398 an immediate call to the last chance handler, a routine that the user
7399 must define with the following profile:
7401 @smallexample @c ada
7402 procedure Last_Chance_Handler
7403 (Source_Location : System.Address; Line : Integer);
7404 pragma Export (C, Last_Chance_Handler,
7405 "__gnat_last_chance_handler");
7408 The parameter is a C null-terminated string representing a message to be
7409 associated with the exception (typically the source location of the raise
7410 statement generated by the compiler). The Line parameter when nonzero
7411 represents the line number in the source program where the raise occurs.
7413 @node No_Exception_Propagation
7414 @unnumberedsubsec No_Exception_Propagation
7415 @findex No_Exception_Propagation
7416 [GNAT] This restriction guarantees that exceptions are never propagated
7417 to an outer subprogram scope. The only case in which an exception may
7418 be raised is when the handler is statically in the same subprogram, so
7419 that the effect of a raise is essentially like a goto statement. Any
7420 other raise statement (implicit or explicit) will be considered
7421 unhandled. Exception handlers are allowed, but may not contain an
7422 exception occurrence identifier (exception choice). In addition, use of
7423 the package GNAT.Current_Exception is not permitted, and reraise
7424 statements (raise with no operand) are not permitted.
7426 @node No_Exception_Registration
7427 @unnumberedsubsec No_Exception_Registration
7428 @findex No_Exception_Registration
7429 [GNAT] This restriction ensures at compile time that no stream operations for
7430 types Exception_Id or Exception_Occurrence are used. This also makes it
7431 impossible to pass exceptions to or from a partition with this restriction
7432 in a distributed environment. If this exception is active, then the generated
7433 code is simplified by omitting the otherwise-required global registration
7434 of exceptions when they are declared.
7437 @unnumberedsubsec No_Exceptions
7438 @findex No_Exceptions
7439 [RM H.4] This restriction ensures at compile time that there are no
7440 raise statements and no exception handlers.
7442 @node No_Finalization
7443 @unnumberedsubsec No_Finalization
7444 @findex No_Finalization
7445 [GNAT] This restriction disables the language features described in
7446 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
7447 performed by the compiler to support these features. The following types
7448 are no longer considered controlled when this restriction is in effect:
7451 @code{Ada.Finalization.Controlled}
7453 @code{Ada.Finalization.Limited_Controlled}
7455 Derivations from @code{Controlled} or @code{Limited_Controlled}
7463 Array and record types with controlled components
7465 The compiler no longer generates code to initialize, finalize or adjust an
7466 object or a nested component, either declared on the stack or on the heap. The
7467 deallocation of a controlled object no longer finalizes its contents.
7469 @node No_Fixed_Point
7470 @unnumberedsubsec No_Fixed_Point
7471 @findex No_Fixed_Point
7472 [RM H.4] This restriction ensures at compile time that there are no
7473 occurrences of fixed point types and operations.
7475 @node No_Floating_Point
7476 @unnumberedsubsec No_Floating_Point
7477 @findex No_Floating_Point
7478 [RM H.4] This restriction ensures at compile time that there are no
7479 occurrences of floating point types and operations.
7481 @node No_Implicit_Conditionals
7482 @unnumberedsubsec No_Implicit_Conditionals
7483 @findex No_Implicit_Conditionals
7484 [GNAT] This restriction ensures that the generated code does not contain any
7485 implicit conditionals, either by modifying the generated code where possible,
7486 or by rejecting any construct that would otherwise generate an implicit
7487 conditional. Note that this check does not include run time constraint
7488 checks, which on some targets may generate implicit conditionals as
7489 well. To control the latter, constraint checks can be suppressed in the
7490 normal manner. Constructs generating implicit conditionals include comparisons
7491 of composite objects and the Max/Min attributes.
7493 @node No_Implicit_Dynamic_Code
7494 @unnumberedsubsec No_Implicit_Dynamic_Code
7495 @findex No_Implicit_Dynamic_Code
7497 [GNAT] This restriction prevents the compiler from building ``trampolines''.
7498 This is a structure that is built on the stack and contains dynamic
7499 code to be executed at run time. On some targets, a trampoline is
7500 built for the following features: @code{Access},
7501 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
7502 nested task bodies; primitive operations of nested tagged types.
7503 Trampolines do not work on machines that prevent execution of stack
7504 data. For example, on windows systems, enabling DEP (data execution
7505 protection) will cause trampolines to raise an exception.
7506 Trampolines are also quite slow at run time.
7508 On many targets, trampolines have been largely eliminated. Look at the
7509 version of system.ads for your target --- if it has
7510 Always_Compatible_Rep equal to False, then trampolines are largely
7511 eliminated. In particular, a trampoline is built for the following
7512 features: @code{Address} of a nested subprogram;
7513 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
7514 but only if pragma Favor_Top_Level applies, or the access type has a
7515 foreign-language convention; primitive operations of nested tagged
7518 @node No_Implicit_Heap_Allocations
7519 @unnumberedsubsec No_Implicit_Heap_Allocations
7520 @findex No_Implicit_Heap_Allocations
7521 [RM D.7] No constructs are allowed to cause implicit heap allocation.
7523 @node No_Implicit_Loops
7524 @unnumberedsubsec No_Implicit_Loops
7525 @findex No_Implicit_Loops
7526 [GNAT] This restriction ensures that the generated code does not contain any
7527 implicit @code{for} loops, either by modifying
7528 the generated code where possible,
7529 or by rejecting any construct that would otherwise generate an implicit
7530 @code{for} loop. If this restriction is active, it is possible to build
7531 large array aggregates with all static components without generating an
7532 intermediate temporary, and without generating a loop to initialize individual
7533 components. Otherwise, a loop is created for arrays larger than about 5000
7536 @node No_Initialize_Scalars
7537 @unnumberedsubsec No_Initialize_Scalars
7538 @findex No_Initialize_Scalars
7539 [GNAT] This restriction ensures that no unit in the partition is compiled with
7540 pragma Initialize_Scalars. This allows the generation of more efficient
7541 code, and in particular eliminates dummy null initialization routines that
7542 are otherwise generated for some record and array types.
7545 @unnumberedsubsec No_IO
7547 [RM H.4] This restriction ensures at compile time that there are no
7548 dependences on any of the library units Sequential_IO, Direct_IO,
7549 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
7551 @node No_Local_Allocators
7552 @unnumberedsubsec No_Local_Allocators
7553 @findex No_Local_Allocators
7554 [RM H.4] This restriction ensures at compile time that there are no
7555 occurrences of an allocator in subprograms, generic subprograms, tasks,
7558 @node No_Local_Protected_Objects
7559 @unnumberedsubsec No_Local_Protected_Objects
7560 @findex No_Local_Protected_Objects
7561 [RM D.7] This restriction ensures at compile time that protected objects are
7562 only declared at the library level.
7564 @node No_Local_Timing_Events
7565 @unnumberedsubsec No_Local_Timing_Events
7566 @findex No_Local_Timing_Events
7567 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
7568 declared at the library level.
7570 @node No_Nested_Finalization
7571 @unnumberedsubsec No_Nested_Finalization
7572 @findex No_Nested_Finalization
7573 [RM D.7] All objects requiring finalization are declared at the library level.
7575 @node No_Protected_Type_Allocators
7576 @unnumberedsubsec No_Protected_Type_Allocators
7577 @findex No_Protected_Type_Allocators
7578 [RM D.7] This restriction ensures at compile time that there are no allocator
7579 expressions that attempt to allocate protected objects.
7581 @node No_Protected_Types
7582 @unnumberedsubsec No_Protected_Types
7583 @findex No_Protected_Types
7584 [RM H.4] This restriction ensures at compile time that there are no
7585 declarations of protected types or protected objects.
7588 @unnumberedsubsec No_Recursion
7589 @findex No_Recursion
7590 [RM H.4] A program execution is erroneous if a subprogram is invoked as
7591 part of its execution.
7594 @unnumberedsubsec No_Reentrancy
7595 @findex No_Reentrancy
7596 [RM H.4] A program execution is erroneous if a subprogram is executed by
7597 two tasks at the same time.
7599 @node No_Relative_Delay
7600 @unnumberedsubsec No_Relative_Delay
7601 @findex No_Relative_Delay
7602 [RM D.7] This restriction ensures at compile time that there are no delay
7603 relative statements and prevents expressions such as @code{delay 1.23;} from
7604 appearing in source code.
7606 @node No_Requeue_Statements
7607 @unnumberedsubsec No_Requeue_Statements
7608 @findex No_Requeue_Statements
7609 [RM D.7] This restriction ensures at compile time that no requeue statements
7610 are permitted and prevents keyword @code{requeue} from being used in source
7613 @node No_Secondary_Stack
7614 @unnumberedsubsec No_Secondary_Stack
7615 @findex No_Secondary_Stack
7616 [GNAT] This restriction ensures at compile time that the generated code
7617 does not contain any reference to the secondary stack. The secondary
7618 stack is used to implement functions returning unconstrained objects
7619 (arrays or records) on some targets.
7621 @node No_Select_Statements
7622 @unnumberedsubsec No_Select_Statements
7623 @findex No_Select_Statements
7624 [RM D.7] This restriction ensures at compile time no select statements of any
7625 kind are permitted, that is the keyword @code{select} may not appear.
7627 @node No_Specific_Termination_Handlers
7628 @unnumberedsubsec No_Specific_Termination_Handlers
7629 @findex No_Specific_Termination_Handlers
7630 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
7631 or to Ada.Task_Termination.Specific_Handler.
7633 @node No_Specification_of_Aspect
7634 @unnumberedsubsec No_Specification_of_Aspect
7635 @findex No_Specification_of_Aspect
7636 [RM 13.12.1] This restriction checks at compile time that no aspect
7637 specification, attribute definition clause, or pragma is given for a
7640 @node No_Standard_Allocators_After_Elaboration
7641 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
7642 @findex No_Standard_Allocators_After_Elaboration
7643 [RM D.7] Specifies that an allocator using a standard storage pool
7644 should never be evaluated at run time after the elaboration of the
7645 library items of the partition has completed. Otherwise, Storage_Error
7648 @node No_Standard_Storage_Pools
7649 @unnumberedsubsec No_Standard_Storage_Pools
7650 @findex No_Standard_Storage_Pools
7651 [GNAT] This restriction ensures at compile time that no access types
7652 use the standard default storage pool. Any access type declared must
7653 have an explicit Storage_Pool attribute defined specifying a
7654 user-defined storage pool.
7656 @node No_Stream_Optimizations
7657 @unnumberedsubsec No_Stream_Optimizations
7658 @findex No_Stream_Optimizations
7659 [GNAT] This restriction affects the performance of stream operations on types
7660 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
7661 compiler uses block reads and writes when manipulating @code{String} objects
7662 due to their supperior performance. When this restriction is in effect, the
7663 compiler performs all IO operations on a per-character basis.
7666 @unnumberedsubsec No_Streams
7668 [GNAT] This restriction ensures at compile/bind time that there are no
7669 stream objects created and no use of stream attributes.
7670 This restriction does not forbid dependences on the package
7671 @code{Ada.Streams}. So it is permissible to with
7672 @code{Ada.Streams} (or another package that does so itself)
7673 as long as no actual stream objects are created and no
7674 stream attributes are used.
7676 Note that the use of restriction allows optimization of tagged types,
7677 since they do not need to worry about dispatching stream operations.
7678 To take maximum advantage of this space-saving optimization, any
7679 unit declaring a tagged type should be compiled with the restriction,
7680 though this is not required.
7682 @node No_Task_Allocators
7683 @unnumberedsubsec No_Task_Allocators
7684 @findex No_Task_Allocators
7685 [RM D.7] There are no allocators for task types
7686 or types containing task subcomponents.
7688 @node No_Task_Attributes_Package
7689 @unnumberedsubsec No_Task_Attributes_Package
7690 @findex No_Task_Attributes_Package
7691 [GNAT] This restriction ensures at compile time that there are no implicit or
7692 explicit dependencies on the package @code{Ada.Task_Attributes}.
7694 @node No_Task_Hierarchy
7695 @unnumberedsubsec No_Task_Hierarchy
7696 @findex No_Task_Hierarchy
7697 [RM D.7] All (non-environment) tasks depend
7698 directly on the environment task of the partition.
7700 @node No_Task_Termination
7701 @unnumberedsubsec No_Task_Termination
7702 @findex No_Task_Termination
7703 [RM D.7] Tasks which terminate are erroneous.
7706 @unnumberedsubsec No_Tasking
7708 [GNAT] This restriction prevents the declaration of tasks or task types
7709 throughout the partition. It is similar in effect to the use of
7710 @code{Max_Tasks => 0} except that violations are caught at compile time
7711 and cause an error message to be output either by the compiler or
7714 @node No_Terminate_Alternatives
7715 @unnumberedsubsec No_Terminate_Alternatives
7716 @findex No_Terminate_Alternatives
7717 [RM D.7] There are no selective accepts with terminate alternatives.
7719 @node No_Unchecked_Access
7720 @unnumberedsubsec No_Unchecked_Access
7721 @findex No_Unchecked_Access
7722 [RM H.4] This restriction ensures at compile time that there are no
7723 occurrences of the Unchecked_Access attribute.
7725 @node Simple_Barriers
7726 @unnumberedsubsec Simple_Barriers
7727 @findex Simple_Barriers
7728 [RM D.7] This restriction ensures at compile time that barriers in entry
7729 declarations for protected types are restricted to either static boolean
7730 expressions or references to simple boolean variables defined in the private
7731 part of the protected type. No other form of entry barriers is permitted.
7733 @node Static_Priorities
7734 @unnumberedsubsec Static_Priorities
7735 @findex Static_Priorities
7736 [GNAT] This restriction ensures at compile time that all priority expressions
7737 are static, and that there are no dependences on the package
7738 @code{Ada.Dynamic_Priorities}.
7740 @node Static_Storage_Size
7741 @unnumberedsubsec Static_Storage_Size
7742 @findex Static_Storage_Size
7743 [GNAT] This restriction ensures at compile time that any expression appearing
7744 in a Storage_Size pragma or attribute definition clause is static.
7746 @node Program Unit Level Restrictions
7747 @section Program Unit Level Restrictions
7750 The second set of restriction identifiers
7751 does not require partition-wide consistency.
7752 The restriction may be enforced for a single
7753 compilation unit without any effect on any of the
7754 other compilation units in the partition.
7757 * No_Elaboration_Code::
7759 * No_Implementation_Aspect_Specifications::
7760 * No_Implementation_Attributes::
7761 * No_Implementation_Identifiers::
7762 * No_Implementation_Pragmas::
7763 * No_Implementation_Restrictions::
7764 * No_Implementation_Units::
7765 * No_Implicit_Aliasing::
7766 * No_Obsolescent_Features::
7767 * No_Wide_Characters::
7771 @node No_Elaboration_Code
7772 @unnumberedsubsec No_Elaboration_Code
7773 @findex No_Elaboration_Code
7774 [GNAT] This restriction ensures at compile time that no elaboration code is
7775 generated. Note that this is not the same condition as is enforced
7776 by pragma @code{Preelaborate}. There are cases in which pragma
7777 @code{Preelaborate} still permits code to be generated (e.g.@: code
7778 to initialize a large array to all zeroes), and there are cases of units
7779 which do not meet the requirements for pragma @code{Preelaborate},
7780 but for which no elaboration code is generated. Generally, it is
7781 the case that preelaborable units will meet the restrictions, with
7782 the exception of large aggregates initialized with an others_clause,
7783 and exception declarations (which generate calls to a run-time
7784 registry procedure). This restriction is enforced on
7785 a unit by unit basis, it need not be obeyed consistently
7786 throughout a partition.
7788 In the case of aggregates with others, if the aggregate has a dynamic
7789 size, there is no way to eliminate the elaboration code (such dynamic
7790 bounds would be incompatible with @code{Preelaborate} in any case). If
7791 the bounds are static, then use of this restriction actually modifies
7792 the code choice of the compiler to avoid generating a loop, and instead
7793 generate the aggregate statically if possible, no matter how many times
7794 the data for the others clause must be repeatedly generated.
7796 It is not possible to precisely document
7797 the constructs which are compatible with this restriction, since,
7798 unlike most other restrictions, this is not a restriction on the
7799 source code, but a restriction on the generated object code. For
7800 example, if the source contains a declaration:
7803 Val : constant Integer := X;
7807 where X is not a static constant, it may be possible, depending
7808 on complex optimization circuitry, for the compiler to figure
7809 out the value of X at compile time, in which case this initialization
7810 can be done by the loader, and requires no initialization code. It
7811 is not possible to document the precise conditions under which the
7812 optimizer can figure this out.
7814 Note that this the implementation of this restriction requires full
7815 code generation. If it is used in conjunction with "semantics only"
7816 checking, then some cases of violations may be missed.
7818 @node No_Entry_Queue
7819 @unnumberedsubsec No_Entry_Queue
7820 @findex No_Entry_Queue
7821 [GNAT] This restriction is a declaration that any protected entry compiled in
7822 the scope of the restriction has at most one task waiting on the entry
7823 at any one time, and so no queue is required. This restriction is not
7824 checked at compile time. A program execution is erroneous if an attempt
7825 is made to queue a second task on such an entry.
7827 @node No_Implementation_Aspect_Specifications
7828 @unnumberedsubsec No_Implementation_Aspect_Specifications
7829 @findex No_Implementation_Aspect_Specifications
7830 [RM 13.12.1] This restriction checks at compile time that no
7831 GNAT-defined aspects are present. With this restriction, the only
7832 aspects that can be used are those defined in the Ada Reference Manual.
7834 @node No_Implementation_Attributes
7835 @unnumberedsubsec No_Implementation_Attributes
7836 @findex No_Implementation_Attributes
7837 [RM 13.12.1] This restriction checks at compile time that no
7838 GNAT-defined attributes are present. With this restriction, the only
7839 attributes that can be used are those defined in the Ada Reference
7842 @node No_Implementation_Identifiers
7843 @unnumberedsubsec No_Implementation_Identifiers
7844 @findex No_Implementation_Identifiers
7845 [RM 13.12.1] This restriction checks at compile time that no
7846 implementation-defined identifiers occur within language-defined
7849 @node No_Implementation_Pragmas
7850 @unnumberedsubsec No_Implementation_Pragmas
7851 @findex No_Implementation_Pragmas
7852 [RM 13.12.1] This restriction checks at compile time that no
7853 GNAT-defined pragmas are present. With this restriction, the only
7854 pragmas that can be used are those defined in the Ada Reference Manual.
7856 @node No_Implementation_Restrictions
7857 @unnumberedsubsec No_Implementation_Restrictions
7858 @findex No_Implementation_Restrictions
7859 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
7860 identifiers (other than @code{No_Implementation_Restrictions} itself)
7861 are present. With this restriction, the only other restriction identifiers
7862 that can be used are those defined in the Ada Reference Manual.
7864 @node No_Implementation_Units
7865 @unnumberedsubsec No_Implementation_Units
7866 @findex No_Implementation_Units
7867 [RM 13.12.1] This restriction checks at compile time that there is no
7868 mention in the context clause of any implementation-defined descendants
7869 of packages Ada, Interfaces, or System.
7871 @node No_Implicit_Aliasing
7872 @unnumberedsubsec No_Implicit_Aliasing
7873 @findex No_Implicit_Aliasing
7874 [GNAT] This restriction, which is not required to be partition-wide consistent,
7875 requires an explicit aliased keyword for an object to which 'Access,
7876 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
7877 the 'Unrestricted_Access attribute for objects. Note: the reason that
7878 Unrestricted_Access is forbidden is that it would require the prefix
7879 to be aliased, and in such cases, it can always be replaced by
7880 the standard attribute Unchecked_Access which is preferable.
7882 @node No_Obsolescent_Features
7883 @unnumberedsubsec No_Obsolescent_Features
7884 @findex No_Obsolescent_Features
7885 [RM 13.12.1] This restriction checks at compile time that no obsolescent
7886 features are used, as defined in Annex J of the Ada Reference Manual.
7888 @node No_Wide_Characters
7889 @unnumberedsubsec No_Wide_Characters
7890 @findex No_Wide_Characters
7891 [GNAT] This restriction ensures at compile time that no uses of the types
7892 @code{Wide_Character} or @code{Wide_String} or corresponding wide
7894 appear, and that no wide or wide wide string or character literals
7895 appear in the program (that is literals representing characters not in
7896 type @code{Character}.
7899 @unnumberedsubsec SPARK
7901 [GNAT] This restriction checks at compile time that some constructs
7902 forbidden in SPARK are not present. The SPARK version used as a
7903 reference is the same as the Ada mode for the unit, so a unit compiled
7904 in Ada 95 mode with SPARK restrictions will be checked for constructs
7905 forbidden in SPARK 95. Error messages related to SPARK restriction have
7909 violation of restriction "SPARK" at <file>
7913 This is not a replacement for the semantic checks performed by the
7914 SPARK Examiner tool, as the compiler only deals currently with code,
7915 not at all with SPARK annotations and does not guarantee catching all
7916 cases of constructs forbidden by SPARK.
7918 Thus it may well be the case that code which
7919 passes the compiler in SPARK mode is rejected by the SPARK Examiner,
7920 e.g. due to the different visibility rules of the Examiner based on
7921 SPARK @code{inherit} annotations.
7923 This restriction can be useful in providing an initial filter for
7924 code developed using SPARK, or in examining legacy code to see how far
7925 it is from meeting SPARK restrictions.
7927 @c ------------------------
7928 @node Implementation Advice
7929 @chapter Implementation Advice
7931 The main text of the Ada Reference Manual describes the required
7932 behavior of all Ada compilers, and the GNAT compiler conforms to
7935 In addition, there are sections throughout the Ada Reference Manual headed
7936 by the phrase ``Implementation advice''. These sections are not normative,
7937 i.e., they do not specify requirements that all compilers must
7938 follow. Rather they provide advice on generally desirable behavior. You
7939 may wonder why they are not requirements. The most typical answer is
7940 that they describe behavior that seems generally desirable, but cannot
7941 be provided on all systems, or which may be undesirable on some systems.
7943 As far as practical, GNAT follows the implementation advice sections in
7944 the Ada Reference Manual. This chapter contains a table giving the
7945 reference manual section number, paragraph number and several keywords
7946 for each advice. Each entry consists of the text of the advice followed
7947 by the GNAT interpretation of this advice. Most often, this simply says
7948 ``followed'', which means that GNAT follows the advice. However, in a
7949 number of cases, GNAT deliberately deviates from this advice, in which
7950 case the text describes what GNAT does and why.
7952 @cindex Error detection
7953 @unnumberedsec 1.1.3(20): Error Detection
7956 If an implementation detects the use of an unsupported Specialized Needs
7957 Annex feature at run time, it should raise @code{Program_Error} if
7960 Not relevant. All specialized needs annex features are either supported,
7961 or diagnosed at compile time.
7964 @unnumberedsec 1.1.3(31): Child Units
7967 If an implementation wishes to provide implementation-defined
7968 extensions to the functionality of a language-defined library unit, it
7969 should normally do so by adding children to the library unit.
7973 @cindex Bounded errors
7974 @unnumberedsec 1.1.5(12): Bounded Errors
7977 If an implementation detects a bounded error or erroneous
7978 execution, it should raise @code{Program_Error}.
7980 Followed in all cases in which the implementation detects a bounded
7981 error or erroneous execution. Not all such situations are detected at
7985 @unnumberedsec 2.8(16): Pragmas
7988 Normally, implementation-defined pragmas should have no semantic effect
7989 for error-free programs; that is, if the implementation-defined pragmas
7990 are removed from a working program, the program should still be legal,
7991 and should still have the same semantics.
7993 The following implementation defined pragmas are exceptions to this
8005 @item CPP_Constructor
8009 @item Interface_Name
8011 @item Machine_Attribute
8013 @item Unimplemented_Unit
8015 @item Unchecked_Union
8020 In each of the above cases, it is essential to the purpose of the pragma
8021 that this advice not be followed. For details see the separate section
8022 on implementation defined pragmas.
8024 @unnumberedsec 2.8(17-19): Pragmas
8027 Normally, an implementation should not define pragmas that can
8028 make an illegal program legal, except as follows:
8032 A pragma used to complete a declaration, such as a pragma @code{Import};
8036 A pragma used to configure the environment by adding, removing, or
8037 replacing @code{library_items}.
8039 See response to paragraph 16 of this same section.
8041 @cindex Character Sets
8042 @cindex Alternative Character Sets
8043 @unnumberedsec 3.5.2(5): Alternative Character Sets
8046 If an implementation supports a mode with alternative interpretations
8047 for @code{Character} and @code{Wide_Character}, the set of graphic
8048 characters of @code{Character} should nevertheless remain a proper
8049 subset of the set of graphic characters of @code{Wide_Character}. Any
8050 character set ``localizations'' should be reflected in the results of
8051 the subprograms defined in the language-defined package
8052 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
8053 an alternative interpretation of @code{Character}, the implementation should
8054 also support a corresponding change in what is a legal
8055 @code{identifier_letter}.
8057 Not all wide character modes follow this advice, in particular the JIS
8058 and IEC modes reflect standard usage in Japan, and in these encoding,
8059 the upper half of the Latin-1 set is not part of the wide-character
8060 subset, since the most significant bit is used for wide character
8061 encoding. However, this only applies to the external forms. Internally
8062 there is no such restriction.
8064 @cindex Integer types
8065 @unnumberedsec 3.5.4(28): Integer Types
8069 An implementation should support @code{Long_Integer} in addition to
8070 @code{Integer} if the target machine supports 32-bit (or longer)
8071 arithmetic. No other named integer subtypes are recommended for package
8072 @code{Standard}. Instead, appropriate named integer subtypes should be
8073 provided in the library package @code{Interfaces} (see B.2).
8075 @code{Long_Integer} is supported. Other standard integer types are supported
8076 so this advice is not fully followed. These types
8077 are supported for convenient interface to C, and so that all hardware
8078 types of the machine are easily available.
8079 @unnumberedsec 3.5.4(29): Integer Types
8083 An implementation for a two's complement machine should support
8084 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
8085 implementation should support a non-binary modules up to @code{Integer'Last}.
8089 @cindex Enumeration values
8090 @unnumberedsec 3.5.5(8): Enumeration Values
8093 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
8094 subtype, if the value of the operand does not correspond to the internal
8095 code for any enumeration literal of its type (perhaps due to an
8096 un-initialized variable), then the implementation should raise
8097 @code{Program_Error}. This is particularly important for enumeration
8098 types with noncontiguous internal codes specified by an
8099 enumeration_representation_clause.
8104 @unnumberedsec 3.5.7(17): Float Types
8107 An implementation should support @code{Long_Float} in addition to
8108 @code{Float} if the target machine supports 11 or more digits of
8109 precision. No other named floating point subtypes are recommended for
8110 package @code{Standard}. Instead, appropriate named floating point subtypes
8111 should be provided in the library package @code{Interfaces} (see B.2).
8113 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
8114 former provides improved compatibility with other implementations
8115 supporting this type. The latter corresponds to the highest precision
8116 floating-point type supported by the hardware. On most machines, this
8117 will be the same as @code{Long_Float}, but on some machines, it will
8118 correspond to the IEEE extended form. The notable case is all ia32
8119 (x86) implementations, where @code{Long_Long_Float} corresponds to
8120 the 80-bit extended precision format supported in hardware on this
8121 processor. Note that the 128-bit format on SPARC is not supported,
8122 since this is a software rather than a hardware format.
8124 @cindex Multidimensional arrays
8125 @cindex Arrays, multidimensional
8126 @unnumberedsec 3.6.2(11): Multidimensional Arrays
8129 An implementation should normally represent multidimensional arrays in
8130 row-major order, consistent with the notation used for multidimensional
8131 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
8132 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
8133 column-major order should be used instead (see B.5, ``Interfacing with
8138 @findex Duration'Small
8139 @unnumberedsec 9.6(30-31): Duration'Small
8142 Whenever possible in an implementation, the value of @code{Duration'Small}
8143 should be no greater than 100 microseconds.
8145 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
8149 The time base for @code{delay_relative_statements} should be monotonic;
8150 it need not be the same time base as used for @code{Calendar.Clock}.
8154 @unnumberedsec 10.2.1(12): Consistent Representation
8157 In an implementation, a type declared in a pre-elaborated package should
8158 have the same representation in every elaboration of a given version of
8159 the package, whether the elaborations occur in distinct executions of
8160 the same program, or in executions of distinct programs or partitions
8161 that include the given version.
8163 Followed, except in the case of tagged types. Tagged types involve
8164 implicit pointers to a local copy of a dispatch table, and these pointers
8165 have representations which thus depend on a particular elaboration of the
8166 package. It is not easy to see how it would be possible to follow this
8167 advice without severely impacting efficiency of execution.
8169 @cindex Exception information
8170 @unnumberedsec 11.4.1(19): Exception Information
8173 @code{Exception_Message} by default and @code{Exception_Information}
8174 should produce information useful for
8175 debugging. @code{Exception_Message} should be short, about one
8176 line. @code{Exception_Information} can be long. @code{Exception_Message}
8177 should not include the
8178 @code{Exception_Name}. @code{Exception_Information} should include both
8179 the @code{Exception_Name} and the @code{Exception_Message}.
8181 Followed. For each exception that doesn't have a specified
8182 @code{Exception_Message}, the compiler generates one containing the location
8183 of the raise statement. This location has the form ``file:line'', where
8184 file is the short file name (without path information) and line is the line
8185 number in the file. Note that in the case of the Zero Cost Exception
8186 mechanism, these messages become redundant with the Exception_Information that
8187 contains a full backtrace of the calling sequence, so they are disabled.
8188 To disable explicitly the generation of the source location message, use the
8189 Pragma @code{Discard_Names}.
8191 @cindex Suppression of checks
8192 @cindex Checks, suppression of
8193 @unnumberedsec 11.5(28): Suppression of Checks
8196 The implementation should minimize the code executed for checks that
8197 have been suppressed.
8201 @cindex Representation clauses
8202 @unnumberedsec 13.1 (21-24): Representation Clauses
8205 The recommended level of support for all representation items is
8206 qualified as follows:
8210 An implementation need not support representation items containing
8211 non-static expressions, except that an implementation should support a
8212 representation item for a given entity if each non-static expression in
8213 the representation item is a name that statically denotes a constant
8214 declared before the entity.
8216 Followed. In fact, GNAT goes beyond the recommended level of support
8217 by allowing nonstatic expressions in some representation clauses even
8218 without the need to declare constants initialized with the values of
8222 @smallexample @c ada
8225 for Y'Address use X'Address;>>
8230 An implementation need not support a specification for the @code{Size}
8231 for a given composite subtype, nor the size or storage place for an
8232 object (including a component) of a given composite subtype, unless the
8233 constraints on the subtype and its composite subcomponents (if any) are
8234 all static constraints.
8236 Followed. Size Clauses are not permitted on non-static components, as
8241 An aliased component, or a component whose type is by-reference, should
8242 always be allocated at an addressable location.
8246 @cindex Packed types
8247 @unnumberedsec 13.2(6-8): Packed Types
8250 If a type is packed, then the implementation should try to minimize
8251 storage allocated to objects of the type, possibly at the expense of
8252 speed of accessing components, subject to reasonable complexity in
8253 addressing calculations.
8257 The recommended level of support pragma @code{Pack} is:
8259 For a packed record type, the components should be packed as tightly as
8260 possible subject to the Sizes of the component subtypes, and subject to
8261 any @code{record_representation_clause} that applies to the type; the
8262 implementation may, but need not, reorder components or cross aligned
8263 word boundaries to improve the packing. A component whose @code{Size} is
8264 greater than the word size may be allocated an integral number of words.
8266 Followed. Tight packing of arrays is supported for all component sizes
8267 up to 64-bits. If the array component size is 1 (that is to say, if
8268 the component is a boolean type or an enumeration type with two values)
8269 then values of the type are implicitly initialized to zero. This
8270 happens both for objects of the packed type, and for objects that have a
8271 subcomponent of the packed type.
8275 An implementation should support Address clauses for imported
8279 @cindex @code{Address} clauses
8280 @unnumberedsec 13.3(14-19): Address Clauses
8284 For an array @var{X}, @code{@var{X}'Address} should point at the first
8285 component of the array, and not at the array bounds.
8291 The recommended level of support for the @code{Address} attribute is:
8293 @code{@var{X}'Address} should produce a useful result if @var{X} is an
8294 object that is aliased or of a by-reference type, or is an entity whose
8295 @code{Address} has been specified.
8297 Followed. A valid address will be produced even if none of those
8298 conditions have been met. If necessary, the object is forced into
8299 memory to ensure the address is valid.
8303 An implementation should support @code{Address} clauses for imported
8310 Objects (including subcomponents) that are aliased or of a by-reference
8311 type should be allocated on storage element boundaries.
8317 If the @code{Address} of an object is specified, or it is imported or exported,
8318 then the implementation should not perform optimizations based on
8319 assumptions of no aliases.
8323 @cindex @code{Alignment} clauses
8324 @unnumberedsec 13.3(29-35): Alignment Clauses
8327 The recommended level of support for the @code{Alignment} attribute for
8330 An implementation should support specified Alignments that are factors
8331 and multiples of the number of storage elements per word, subject to the
8338 An implementation need not support specified @code{Alignment}s for
8339 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
8340 loaded and stored by available machine instructions.
8346 An implementation need not support specified @code{Alignment}s that are
8347 greater than the maximum @code{Alignment} the implementation ever returns by
8354 The recommended level of support for the @code{Alignment} attribute for
8357 Same as above, for subtypes, but in addition:
8363 For stand-alone library-level objects of statically constrained
8364 subtypes, the implementation should support all @code{Alignment}s
8365 supported by the target linker. For example, page alignment is likely to
8366 be supported for such objects, but not for subtypes.
8370 @cindex @code{Size} clauses
8371 @unnumberedsec 13.3(42-43): Size Clauses
8374 The recommended level of support for the @code{Size} attribute of
8377 A @code{Size} clause should be supported for an object if the specified
8378 @code{Size} is at least as large as its subtype's @code{Size}, and
8379 corresponds to a size in storage elements that is a multiple of the
8380 object's @code{Alignment} (if the @code{Alignment} is nonzero).
8384 @unnumberedsec 13.3(50-56): Size Clauses
8387 If the @code{Size} of a subtype is specified, and allows for efficient
8388 independent addressability (see 9.10) on the target architecture, then
8389 the @code{Size} of the following objects of the subtype should equal the
8390 @code{Size} of the subtype:
8392 Aliased objects (including components).
8398 @code{Size} clause on a composite subtype should not affect the
8399 internal layout of components.
8401 Followed. But note that this can be overridden by use of the implementation
8402 pragma Implicit_Packing in the case of packed arrays.
8406 The recommended level of support for the @code{Size} attribute of subtypes is:
8410 The @code{Size} (if not specified) of a static discrete or fixed point
8411 subtype should be the number of bits needed to represent each value
8412 belonging to the subtype using an unbiased representation, leaving space
8413 for a sign bit only if the subtype contains negative values. If such a
8414 subtype is a first subtype, then an implementation should support a
8415 specified @code{Size} for it that reflects this representation.
8421 For a subtype implemented with levels of indirection, the @code{Size}
8422 should include the size of the pointers, but not the size of what they
8427 @cindex @code{Component_Size} clauses
8428 @unnumberedsec 13.3(71-73): Component Size Clauses
8431 The recommended level of support for the @code{Component_Size}
8436 An implementation need not support specified @code{Component_Sizes} that are
8437 less than the @code{Size} of the component subtype.
8443 An implementation should support specified @code{Component_Size}s that
8444 are factors and multiples of the word size. For such
8445 @code{Component_Size}s, the array should contain no gaps between
8446 components. For other @code{Component_Size}s (if supported), the array
8447 should contain no gaps between components when packing is also
8448 specified; the implementation should forbid this combination in cases
8449 where it cannot support a no-gaps representation.
8453 @cindex Enumeration representation clauses
8454 @cindex Representation clauses, enumeration
8455 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
8458 The recommended level of support for enumeration representation clauses
8461 An implementation need not support enumeration representation clauses
8462 for boolean types, but should at minimum support the internal codes in
8463 the range @code{System.Min_Int.System.Max_Int}.
8467 @cindex Record representation clauses
8468 @cindex Representation clauses, records
8469 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
8472 The recommended level of support for
8473 @*@code{record_representation_clauses} is:
8475 An implementation should support storage places that can be extracted
8476 with a load, mask, shift sequence of machine code, and set with a load,
8477 shift, mask, store sequence, given the available machine instructions
8484 A storage place should be supported if its size is equal to the
8485 @code{Size} of the component subtype, and it starts and ends on a
8486 boundary that obeys the @code{Alignment} of the component subtype.
8492 If the default bit ordering applies to the declaration of a given type,
8493 then for a component whose subtype's @code{Size} is less than the word
8494 size, any storage place that does not cross an aligned word boundary
8495 should be supported.
8501 An implementation may reserve a storage place for the tag field of a
8502 tagged type, and disallow other components from overlapping that place.
8504 Followed. The storage place for the tag field is the beginning of the tagged
8505 record, and its size is Address'Size. GNAT will reject an explicit component
8506 clause for the tag field.
8510 An implementation need not support a @code{component_clause} for a
8511 component of an extension part if the storage place is not after the
8512 storage places of all components of the parent type, whether or not
8513 those storage places had been specified.
8515 Followed. The above advice on record representation clauses is followed,
8516 and all mentioned features are implemented.
8518 @cindex Storage place attributes
8519 @unnumberedsec 13.5.2(5): Storage Place Attributes
8522 If a component is represented using some form of pointer (such as an
8523 offset) to the actual data of the component, and this data is contiguous
8524 with the rest of the object, then the storage place attributes should
8525 reflect the place of the actual data, not the pointer. If a component is
8526 allocated discontinuously from the rest of the object, then a warning
8527 should be generated upon reference to one of its storage place
8530 Followed. There are no such components in GNAT@.
8532 @cindex Bit ordering
8533 @unnumberedsec 13.5.3(7-8): Bit Ordering
8536 The recommended level of support for the non-default bit ordering is:
8540 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
8541 should support the non-default bit ordering in addition to the default
8544 Followed. Word size does not equal storage size in this implementation.
8545 Thus non-default bit ordering is not supported.
8547 @cindex @code{Address}, as private type
8548 @unnumberedsec 13.7(37): Address as Private
8551 @code{Address} should be of a private type.
8555 @cindex Operations, on @code{Address}
8556 @cindex @code{Address}, operations of
8557 @unnumberedsec 13.7.1(16): Address Operations
8560 Operations in @code{System} and its children should reflect the target
8561 environment semantics as closely as is reasonable. For example, on most
8562 machines, it makes sense for address arithmetic to ``wrap around''.
8563 Operations that do not make sense should raise @code{Program_Error}.
8565 Followed. Address arithmetic is modular arithmetic that wraps around. No
8566 operation raises @code{Program_Error}, since all operations make sense.
8568 @cindex Unchecked conversion
8569 @unnumberedsec 13.9(14-17): Unchecked Conversion
8572 The @code{Size} of an array object should not include its bounds; hence,
8573 the bounds should not be part of the converted data.
8579 The implementation should not generate unnecessary run-time checks to
8580 ensure that the representation of @var{S} is a representation of the
8581 target type. It should take advantage of the permission to return by
8582 reference when possible. Restrictions on unchecked conversions should be
8583 avoided unless required by the target environment.
8585 Followed. There are no restrictions on unchecked conversion. A warning is
8586 generated if the source and target types do not have the same size since
8587 the semantics in this case may be target dependent.
8591 The recommended level of support for unchecked conversions is:
8595 Unchecked conversions should be supported and should be reversible in
8596 the cases where this clause defines the result. To enable meaningful use
8597 of unchecked conversion, a contiguous representation should be used for
8598 elementary subtypes, for statically constrained array subtypes whose
8599 component subtype is one of the subtypes described in this paragraph,
8600 and for record subtypes without discriminants whose component subtypes
8601 are described in this paragraph.
8605 @cindex Heap usage, implicit
8606 @unnumberedsec 13.11(23-25): Implicit Heap Usage
8609 An implementation should document any cases in which it dynamically
8610 allocates heap storage for a purpose other than the evaluation of an
8613 Followed, the only other points at which heap storage is dynamically
8614 allocated are as follows:
8618 At initial elaboration time, to allocate dynamically sized global
8622 To allocate space for a task when a task is created.
8625 To extend the secondary stack dynamically when needed. The secondary
8626 stack is used for returning variable length results.
8631 A default (implementation-provided) storage pool for an
8632 access-to-constant type should not have overhead to support deallocation of
8639 A storage pool for an anonymous access type should be created at the
8640 point of an allocator for the type, and be reclaimed when the designated
8641 object becomes inaccessible.
8645 @cindex Unchecked deallocation
8646 @unnumberedsec 13.11.2(17): Unchecked De-allocation
8649 For a standard storage pool, @code{Free} should actually reclaim the
8654 @cindex Stream oriented attributes
8655 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
8658 If a stream element is the same size as a storage element, then the
8659 normal in-memory representation should be used by @code{Read} and
8660 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
8661 should use the smallest number of stream elements needed to represent
8662 all values in the base range of the scalar type.
8665 Followed. By default, GNAT uses the interpretation suggested by AI-195,
8666 which specifies using the size of the first subtype.
8667 However, such an implementation is based on direct binary
8668 representations and is therefore target- and endianness-dependent.
8669 To address this issue, GNAT also supplies an alternate implementation
8670 of the stream attributes @code{Read} and @code{Write},
8671 which uses the target-independent XDR standard representation
8673 @cindex XDR representation
8674 @cindex @code{Read} attribute
8675 @cindex @code{Write} attribute
8676 @cindex Stream oriented attributes
8677 The XDR implementation is provided as an alternative body of the
8678 @code{System.Stream_Attributes} package, in the file
8679 @file{s-stratt-xdr.adb} in the GNAT library.
8680 There is no @file{s-stratt-xdr.ads} file.
8681 In order to install the XDR implementation, do the following:
8683 @item Replace the default implementation of the
8684 @code{System.Stream_Attributes} package with the XDR implementation.
8685 For example on a Unix platform issue the commands:
8687 $ mv s-stratt.adb s-stratt-default.adb
8688 $ mv s-stratt-xdr.adb s-stratt.adb
8692 Rebuild the GNAT run-time library as documented in
8693 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
8696 @unnumberedsec A.1(52): Names of Predefined Numeric Types
8699 If an implementation provides additional named predefined integer types,
8700 then the names should end with @samp{Integer} as in
8701 @samp{Long_Integer}. If an implementation provides additional named
8702 predefined floating point types, then the names should end with
8703 @samp{Float} as in @samp{Long_Float}.
8707 @findex Ada.Characters.Handling
8708 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
8711 If an implementation provides a localized definition of @code{Character}
8712 or @code{Wide_Character}, then the effects of the subprograms in
8713 @code{Characters.Handling} should reflect the localizations. See also
8716 Followed. GNAT provides no such localized definitions.
8718 @cindex Bounded-length strings
8719 @unnumberedsec A.4.4(106): Bounded-Length String Handling
8722 Bounded string objects should not be implemented by implicit pointers
8723 and dynamic allocation.
8725 Followed. No implicit pointers or dynamic allocation are used.
8727 @cindex Random number generation
8728 @unnumberedsec A.5.2(46-47): Random Number Generation
8731 Any storage associated with an object of type @code{Generator} should be
8732 reclaimed on exit from the scope of the object.
8738 If the generator period is sufficiently long in relation to the number
8739 of distinct initiator values, then each possible value of
8740 @code{Initiator} passed to @code{Reset} should initiate a sequence of
8741 random numbers that does not, in a practical sense, overlap the sequence
8742 initiated by any other value. If this is not possible, then the mapping
8743 between initiator values and generator states should be a rapidly
8744 varying function of the initiator value.
8746 Followed. The generator period is sufficiently long for the first
8747 condition here to hold true.
8749 @findex Get_Immediate
8750 @unnumberedsec A.10.7(23): @code{Get_Immediate}
8753 The @code{Get_Immediate} procedures should be implemented with
8754 unbuffered input. For a device such as a keyboard, input should be
8755 @dfn{available} if a key has already been typed, whereas for a disk
8756 file, input should always be available except at end of file. For a file
8757 associated with a keyboard-like device, any line-editing features of the
8758 underlying operating system should be disabled during the execution of
8759 @code{Get_Immediate}.
8761 Followed on all targets except VxWorks. For VxWorks, there is no way to
8762 provide this functionality that does not result in the input buffer being
8763 flushed before the @code{Get_Immediate} call. A special unit
8764 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
8768 @unnumberedsec B.1(39-41): Pragma @code{Export}
8771 If an implementation supports pragma @code{Export} to a given language,
8772 then it should also allow the main subprogram to be written in that
8773 language. It should support some mechanism for invoking the elaboration
8774 of the Ada library units included in the system, and for invoking the
8775 finalization of the environment task. On typical systems, the
8776 recommended mechanism is to provide two subprograms whose link names are
8777 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
8778 elaboration code for library units. @code{adafinal} should contain the
8779 finalization code. These subprograms should have no effect the second
8780 and subsequent time they are called.
8786 Automatic elaboration of pre-elaborated packages should be
8787 provided when pragma @code{Export} is supported.
8789 Followed when the main program is in Ada. If the main program is in a
8790 foreign language, then
8791 @code{adainit} must be called to elaborate pre-elaborated
8796 For each supported convention @var{L} other than @code{Intrinsic}, an
8797 implementation should support @code{Import} and @code{Export} pragmas
8798 for objects of @var{L}-compatible types and for subprograms, and pragma
8799 @code{Convention} for @var{L}-eligible types and for subprograms,
8800 presuming the other language has corresponding features. Pragma
8801 @code{Convention} need not be supported for scalar types.
8805 @cindex Package @code{Interfaces}
8807 @unnumberedsec B.2(12-13): Package @code{Interfaces}
8810 For each implementation-defined convention identifier, there should be a
8811 child package of package Interfaces with the corresponding name. This
8812 package should contain any declarations that would be useful for
8813 interfacing to the language (implementation) represented by the
8814 convention. Any declarations useful for interfacing to any language on
8815 the given hardware architecture should be provided directly in
8818 Followed. An additional package not defined
8819 in the Ada Reference Manual is @code{Interfaces.CPP}, used
8820 for interfacing to C++.
8824 An implementation supporting an interface to C, COBOL, or Fortran should
8825 provide the corresponding package or packages described in the following
8828 Followed. GNAT provides all the packages described in this section.
8830 @cindex C, interfacing with
8831 @unnumberedsec B.3(63-71): Interfacing with C
8834 An implementation should support the following interface correspondences
8841 An Ada procedure corresponds to a void-returning C function.
8847 An Ada function corresponds to a non-void C function.
8853 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
8860 An Ada @code{in} parameter of an access-to-object type with designated
8861 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
8862 where @var{t} is the C type corresponding to the Ada type @var{T}.
8868 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
8869 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
8870 argument to a C function, where @var{t} is the C type corresponding to
8871 the Ada type @var{T}. In the case of an elementary @code{out} or
8872 @code{in out} parameter, a pointer to a temporary copy is used to
8873 preserve by-copy semantics.
8879 An Ada parameter of a record type @var{T}, of any mode, is passed as a
8880 @code{@var{t}*} argument to a C function, where @var{t} is the C
8881 structure corresponding to the Ada type @var{T}.
8883 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
8884 pragma, or Convention, or by explicitly specifying the mechanism for a given
8885 call using an extended import or export pragma.
8889 An Ada parameter of an array type with component type @var{T}, of any
8890 mode, is passed as a @code{@var{t}*} argument to a C function, where
8891 @var{t} is the C type corresponding to the Ada type @var{T}.
8897 An Ada parameter of an access-to-subprogram type is passed as a pointer
8898 to a C function whose prototype corresponds to the designated
8899 subprogram's specification.
8903 @cindex COBOL, interfacing with
8904 @unnumberedsec B.4(95-98): Interfacing with COBOL
8907 An Ada implementation should support the following interface
8908 correspondences between Ada and COBOL@.
8914 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
8915 the COBOL type corresponding to @var{T}.
8921 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
8922 the corresponding COBOL type.
8928 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
8929 COBOL type corresponding to the Ada parameter type; for scalars, a local
8930 copy is used if necessary to ensure by-copy semantics.
8934 @cindex Fortran, interfacing with
8935 @unnumberedsec B.5(22-26): Interfacing with Fortran
8938 An Ada implementation should support the following interface
8939 correspondences between Ada and Fortran:
8945 An Ada procedure corresponds to a Fortran subroutine.
8951 An Ada function corresponds to a Fortran function.
8957 An Ada parameter of an elementary, array, or record type @var{T} is
8958 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
8959 the Fortran type corresponding to the Ada type @var{T}, and where the
8960 INTENT attribute of the corresponding dummy argument matches the Ada
8961 formal parameter mode; the Fortran implementation's parameter passing
8962 conventions are used. For elementary types, a local copy is used if
8963 necessary to ensure by-copy semantics.
8969 An Ada parameter of an access-to-subprogram type is passed as a
8970 reference to a Fortran procedure whose interface corresponds to the
8971 designated subprogram's specification.
8975 @cindex Machine operations
8976 @unnumberedsec C.1(3-5): Access to Machine Operations
8979 The machine code or intrinsic support should allow access to all
8980 operations normally available to assembly language programmers for the
8981 target environment, including privileged instructions, if any.
8987 The interfacing pragmas (see Annex B) should support interface to
8988 assembler; the default assembler should be associated with the
8989 convention identifier @code{Assembler}.
8995 If an entity is exported to assembly language, then the implementation
8996 should allocate it at an addressable location, and should ensure that it
8997 is retained by the linking process, even if not otherwise referenced
8998 from the Ada code. The implementation should assume that any call to a
8999 machine code or assembler subprogram is allowed to read or update every
9000 object that is specified as exported.
9004 @unnumberedsec C.1(10-16): Access to Machine Operations
9007 The implementation should ensure that little or no overhead is
9008 associated with calling intrinsic and machine-code subprograms.
9010 Followed for both intrinsics and machine-code subprograms.
9014 It is recommended that intrinsic subprograms be provided for convenient
9015 access to any machine operations that provide special capabilities or
9016 efficiency and that are not otherwise available through the language
9019 Followed. A full set of machine operation intrinsic subprograms is provided.
9023 Atomic read-modify-write operations---e.g.@:, test and set, compare and
9024 swap, decrement and test, enqueue/dequeue.
9026 Followed on any target supporting such operations.
9030 Standard numeric functions---e.g.@:, sin, log.
9032 Followed on any target supporting such operations.
9036 String manipulation operations---e.g.@:, translate and test.
9038 Followed on any target supporting such operations.
9042 Vector operations---e.g.@:, compare vector against thresholds.
9044 Followed on any target supporting such operations.
9048 Direct operations on I/O ports.
9050 Followed on any target supporting such operations.
9052 @cindex Interrupt support
9053 @unnumberedsec C.3(28): Interrupt Support
9056 If the @code{Ceiling_Locking} policy is not in effect, the
9057 implementation should provide means for the application to specify which
9058 interrupts are to be blocked during protected actions, if the underlying
9059 system allows for a finer-grain control of interrupt blocking.
9061 Followed. The underlying system does not allow for finer-grain control
9062 of interrupt blocking.
9064 @cindex Protected procedure handlers
9065 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
9068 Whenever possible, the implementation should allow interrupt handlers to
9069 be called directly by the hardware.
9071 Followed on any target where the underlying operating system permits
9076 Whenever practical, violations of any
9077 implementation-defined restrictions should be detected before run time.
9079 Followed. Compile time warnings are given when possible.
9081 @cindex Package @code{Interrupts}
9083 @unnumberedsec C.3.2(25): Package @code{Interrupts}
9087 If implementation-defined forms of interrupt handler procedures are
9088 supported, such as protected procedures with parameters, then for each
9089 such form of a handler, a type analogous to @code{Parameterless_Handler}
9090 should be specified in a child package of @code{Interrupts}, with the
9091 same operations as in the predefined package Interrupts.
9095 @cindex Pre-elaboration requirements
9096 @unnumberedsec C.4(14): Pre-elaboration Requirements
9099 It is recommended that pre-elaborated packages be implemented in such a
9100 way that there should be little or no code executed at run time for the
9101 elaboration of entities not already covered by the Implementation
9104 Followed. Executable code is generated in some cases, e.g.@: loops
9105 to initialize large arrays.
9107 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
9110 If the pragma applies to an entity, then the implementation should
9111 reduce the amount of storage used for storing names associated with that
9116 @cindex Package @code{Task_Attributes}
9117 @findex Task_Attributes
9118 @unnumberedsec C.7.2(30): The Package Task_Attributes
9121 Some implementations are targeted to domains in which memory use at run
9122 time must be completely deterministic. For such implementations, it is
9123 recommended that the storage for task attributes will be pre-allocated
9124 statically and not from the heap. This can be accomplished by either
9125 placing restrictions on the number and the size of the task's
9126 attributes, or by using the pre-allocated storage for the first @var{N}
9127 attribute objects, and the heap for the others. In the latter case,
9128 @var{N} should be documented.
9130 Not followed. This implementation is not targeted to such a domain.
9132 @cindex Locking Policies
9133 @unnumberedsec D.3(17): Locking Policies
9137 The implementation should use names that end with @samp{_Locking} for
9138 locking policies defined by the implementation.
9140 Followed. Two implementation-defined locking policies are defined,
9141 whose names (@code{Inheritance_Locking} and
9142 @code{Concurrent_Readers_Locking}) follow this suggestion.
9144 @cindex Entry queuing policies
9145 @unnumberedsec D.4(16): Entry Queuing Policies
9148 Names that end with @samp{_Queuing} should be used
9149 for all implementation-defined queuing policies.
9151 Followed. No such implementation-defined queuing policies exist.
9153 @cindex Preemptive abort
9154 @unnumberedsec D.6(9-10): Preemptive Abort
9157 Even though the @code{abort_statement} is included in the list of
9158 potentially blocking operations (see 9.5.1), it is recommended that this
9159 statement be implemented in a way that never requires the task executing
9160 the @code{abort_statement} to block.
9166 On a multi-processor, the delay associated with aborting a task on
9167 another processor should be bounded; the implementation should use
9168 periodic polling, if necessary, to achieve this.
9172 @cindex Tasking restrictions
9173 @unnumberedsec D.7(21): Tasking Restrictions
9176 When feasible, the implementation should take advantage of the specified
9177 restrictions to produce a more efficient implementation.
9179 GNAT currently takes advantage of these restrictions by providing an optimized
9180 run time when the Ravenscar profile and the GNAT restricted run time set
9181 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
9182 pragma @code{Profile (Restricted)} for more details.
9184 @cindex Time, monotonic
9185 @unnumberedsec D.8(47-49): Monotonic Time
9188 When appropriate, implementations should provide configuration
9189 mechanisms to change the value of @code{Tick}.
9191 Such configuration mechanisms are not appropriate to this implementation
9192 and are thus not supported.
9196 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
9197 be implemented as transformations of the same time base.
9203 It is recommended that the @dfn{best} time base which exists in
9204 the underlying system be available to the application through
9205 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
9209 @cindex Partition communication subsystem
9211 @unnumberedsec E.5(28-29): Partition Communication Subsystem
9214 Whenever possible, the PCS on the called partition should allow for
9215 multiple tasks to call the RPC-receiver with different messages and
9216 should allow them to block until the corresponding subprogram body
9219 Followed by GLADE, a separately supplied PCS that can be used with
9224 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
9225 should raise @code{Storage_Error} if it runs out of space trying to
9226 write the @code{Item} into the stream.
9228 Followed by GLADE, a separately supplied PCS that can be used with
9231 @cindex COBOL support
9232 @unnumberedsec F(7): COBOL Support
9235 If COBOL (respectively, C) is widely supported in the target
9236 environment, implementations supporting the Information Systems Annex
9237 should provide the child package @code{Interfaces.COBOL} (respectively,
9238 @code{Interfaces.C}) specified in Annex B and should support a
9239 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
9240 pragmas (see Annex B), thus allowing Ada programs to interface with
9241 programs written in that language.
9245 @cindex Decimal radix support
9246 @unnumberedsec F.1(2): Decimal Radix Support
9249 Packed decimal should be used as the internal representation for objects
9250 of subtype @var{S} when @var{S}'Machine_Radix = 10.
9252 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
9256 @unnumberedsec G: Numerics
9259 If Fortran (respectively, C) is widely supported in the target
9260 environment, implementations supporting the Numerics Annex
9261 should provide the child package @code{Interfaces.Fortran} (respectively,
9262 @code{Interfaces.C}) specified in Annex B and should support a
9263 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
9264 pragmas (see Annex B), thus allowing Ada programs to interface with
9265 programs written in that language.
9269 @cindex Complex types
9270 @unnumberedsec G.1.1(56-58): Complex Types
9273 Because the usual mathematical meaning of multiplication of a complex
9274 operand and a real operand is that of the scaling of both components of
9275 the former by the latter, an implementation should not perform this
9276 operation by first promoting the real operand to complex type and then
9277 performing a full complex multiplication. In systems that, in the
9278 future, support an Ada binding to IEC 559:1989, the latter technique
9279 will not generate the required result when one of the components of the
9280 complex operand is infinite. (Explicit multiplication of the infinite
9281 component by the zero component obtained during promotion yields a NaN
9282 that propagates into the final result.) Analogous advice applies in the
9283 case of multiplication of a complex operand and a pure-imaginary
9284 operand, and in the case of division of a complex operand by a real or
9285 pure-imaginary operand.
9291 Similarly, because the usual mathematical meaning of addition of a
9292 complex operand and a real operand is that the imaginary operand remains
9293 unchanged, an implementation should not perform this operation by first
9294 promoting the real operand to complex type and then performing a full
9295 complex addition. In implementations in which the @code{Signed_Zeros}
9296 attribute of the component type is @code{True} (and which therefore
9297 conform to IEC 559:1989 in regard to the handling of the sign of zero in
9298 predefined arithmetic operations), the latter technique will not
9299 generate the required result when the imaginary component of the complex
9300 operand is a negatively signed zero. (Explicit addition of the negative
9301 zero to the zero obtained during promotion yields a positive zero.)
9302 Analogous advice applies in the case of addition of a complex operand
9303 and a pure-imaginary operand, and in the case of subtraction of a
9304 complex operand and a real or pure-imaginary operand.
9310 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
9311 attempt to provide a rational treatment of the signs of zero results and
9312 result components. As one example, the result of the @code{Argument}
9313 function should have the sign of the imaginary component of the
9314 parameter @code{X} when the point represented by that parameter lies on
9315 the positive real axis; as another, the sign of the imaginary component
9316 of the @code{Compose_From_Polar} function should be the same as
9317 (respectively, the opposite of) that of the @code{Argument} parameter when that
9318 parameter has a value of zero and the @code{Modulus} parameter has a
9319 nonnegative (respectively, negative) value.
9323 @cindex Complex elementary functions
9324 @unnumberedsec G.1.2(49): Complex Elementary Functions
9327 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
9328 @code{True} should attempt to provide a rational treatment of the signs
9329 of zero results and result components. For example, many of the complex
9330 elementary functions have components that are odd functions of one of
9331 the parameter components; in these cases, the result component should
9332 have the sign of the parameter component at the origin. Other complex
9333 elementary functions have zero components whose sign is opposite that of
9334 a parameter component at the origin, or is always positive or always
9339 @cindex Accuracy requirements
9340 @unnumberedsec G.2.4(19): Accuracy Requirements
9343 The versions of the forward trigonometric functions without a
9344 @code{Cycle} parameter should not be implemented by calling the
9345 corresponding version with a @code{Cycle} parameter of
9346 @code{2.0*Numerics.Pi}, since this will not provide the required
9347 accuracy in some portions of the domain. For the same reason, the
9348 version of @code{Log} without a @code{Base} parameter should not be
9349 implemented by calling the corresponding version with a @code{Base}
9350 parameter of @code{Numerics.e}.
9354 @cindex Complex arithmetic accuracy
9355 @cindex Accuracy, complex arithmetic
9356 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
9360 The version of the @code{Compose_From_Polar} function without a
9361 @code{Cycle} parameter should not be implemented by calling the
9362 corresponding version with a @code{Cycle} parameter of
9363 @code{2.0*Numerics.Pi}, since this will not provide the required
9364 accuracy in some portions of the domain.
9368 @c -----------------------------------------
9369 @node Implementation Defined Characteristics
9370 @chapter Implementation Defined Characteristics
9373 In addition to the implementation dependent pragmas and attributes, and the
9374 implementation advice, there are a number of other Ada features that are
9375 potentially implementation dependent and are designated as
9376 implementation-defined. These are mentioned throughout the Ada Reference
9377 Manual, and are summarized in Annex M@.
9379 A requirement for conforming Ada compilers is that they provide
9380 documentation describing how the implementation deals with each of these
9381 issues. In this chapter, you will find each point in Annex M listed
9382 followed by a description in italic font of how GNAT
9383 handles the implementation dependence.
9385 You can use this chapter as a guide to minimizing implementation
9386 dependent features in your programs if portability to other compilers
9387 and other operating systems is an important consideration. The numbers
9388 in each section below correspond to the paragraph number in the Ada
9394 @strong{2}. Whether or not each recommendation given in Implementation
9395 Advice is followed. See 1.1.2(37).
9398 @xref{Implementation Advice}.
9403 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
9406 The complexity of programs that can be processed is limited only by the
9407 total amount of available virtual memory, and disk space for the
9408 generated object files.
9413 @strong{4}. Variations from the standard that are impractical to avoid
9414 given the implementation's execution environment. See 1.1.3(6).
9417 There are no variations from the standard.
9422 @strong{5}. Which @code{code_statement}s cause external
9423 interactions. See 1.1.3(10).
9426 Any @code{code_statement} can potentially cause external interactions.
9431 @strong{6}. The coded representation for the text of an Ada
9432 program. See 2.1(4).
9435 See separate section on source representation.
9440 @strong{7}. The control functions allowed in comments. See 2.1(14).
9443 See separate section on source representation.
9448 @strong{8}. The representation for an end of line. See 2.2(2).
9451 See separate section on source representation.
9456 @strong{9}. Maximum supported line length and lexical element
9457 length. See 2.2(15).
9460 The maximum line length is 255 characters and the maximum length of a
9461 lexical element is also 255 characters.
9466 @strong{10}. Implementation defined pragmas. See 2.8(14).
9470 @xref{Implementation Defined Pragmas}.
9475 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
9478 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
9479 parameter, checks that the optimization flag is set, and aborts if it is
9485 @strong{12}. The sequence of characters of the value returned by
9486 @code{@var{S}'Image} when some of the graphic characters of
9487 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
9491 The sequence of characters is as defined by the wide character encoding
9492 method used for the source. See section on source representation for
9498 @strong{13}. The predefined integer types declared in
9499 @code{Standard}. See 3.5.4(25).
9503 @item Short_Short_Integer
9506 (Short) 16 bit signed
9510 64 bit signed (on most 64 bit targets, depending on the C definition of long).
9511 32 bit signed (all other targets)
9512 @item Long_Long_Integer
9519 @strong{14}. Any nonstandard integer types and the operators defined
9520 for them. See 3.5.4(26).
9523 There are no nonstandard integer types.
9528 @strong{15}. Any nonstandard real types and the operators defined for
9532 There are no nonstandard real types.
9537 @strong{16}. What combinations of requested decimal precision and range
9538 are supported for floating point types. See 3.5.7(7).
9541 The precision and range is as defined by the IEEE standard.
9546 @strong{17}. The predefined floating point types declared in
9547 @code{Standard}. See 3.5.7(16).
9554 (Short) 32 bit IEEE short
9557 @item Long_Long_Float
9558 64 bit IEEE long (80 bit IEEE long on x86 processors)
9564 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
9567 @code{Fine_Delta} is 2**(@minus{}63)
9572 @strong{19}. What combinations of small, range, and digits are
9573 supported for fixed point types. See 3.5.9(10).
9576 Any combinations are permitted that do not result in a small less than
9577 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
9578 If the mantissa is larger than 53 bits on machines where Long_Long_Float
9579 is 64 bits (true of all architectures except ia32), then the output from
9580 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
9581 is because floating-point conversions are used to convert fixed point.
9586 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
9587 within an unnamed @code{block_statement}. See 3.9(10).
9590 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
9591 decimal integer are allocated.
9596 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
9599 @xref{Implementation Defined Attributes}.
9604 @strong{22}. Any implementation-defined time types. See 9.6(6).
9607 There are no implementation-defined time types.
9612 @strong{23}. The time base associated with relative delays.
9615 See 9.6(20). The time base used is that provided by the C library
9616 function @code{gettimeofday}.
9621 @strong{24}. The time base of the type @code{Calendar.Time}. See
9625 The time base used is that provided by the C library function
9626 @code{gettimeofday}.
9631 @strong{25}. The time zone used for package @code{Calendar}
9632 operations. See 9.6(24).
9635 The time zone used by package @code{Calendar} is the current system time zone
9636 setting for local time, as accessed by the C library function
9642 @strong{26}. Any limit on @code{delay_until_statements} of
9643 @code{select_statements}. See 9.6(29).
9646 There are no such limits.
9651 @strong{27}. Whether or not two non-overlapping parts of a composite
9652 object are independently addressable, in the case where packing, record
9653 layout, or @code{Component_Size} is specified for the object. See
9657 Separate components are independently addressable if they do not share
9658 overlapping storage units.
9663 @strong{28}. The representation for a compilation. See 10.1(2).
9666 A compilation is represented by a sequence of files presented to the
9667 compiler in a single invocation of the @command{gcc} command.
9672 @strong{29}. Any restrictions on compilations that contain multiple
9673 compilation_units. See 10.1(4).
9676 No single file can contain more than one compilation unit, but any
9677 sequence of files can be presented to the compiler as a single
9683 @strong{30}. The mechanisms for creating an environment and for adding
9684 and replacing compilation units. See 10.1.4(3).
9687 See separate section on compilation model.
9692 @strong{31}. The manner of explicitly assigning library units to a
9693 partition. See 10.2(2).
9696 If a unit contains an Ada main program, then the Ada units for the partition
9697 are determined by recursive application of the rules in the Ada Reference
9698 Manual section 10.2(2-6). In other words, the Ada units will be those that
9699 are needed by the main program, and then this definition of need is applied
9700 recursively to those units, and the partition contains the transitive
9701 closure determined by this relationship. In short, all the necessary units
9702 are included, with no need to explicitly specify the list. If additional
9703 units are required, e.g.@: by foreign language units, then all units must be
9704 mentioned in the context clause of one of the needed Ada units.
9706 If the partition contains no main program, or if the main program is in
9707 a language other than Ada, then GNAT
9708 provides the binder options @option{-z} and @option{-n} respectively, and in
9709 this case a list of units can be explicitly supplied to the binder for
9710 inclusion in the partition (all units needed by these units will also
9711 be included automatically). For full details on the use of these
9712 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
9713 @value{EDITION} User's Guide}.
9718 @strong{32}. The implementation-defined means, if any, of specifying
9719 which compilation units are needed by a given compilation unit. See
9723 The units needed by a given compilation unit are as defined in
9724 the Ada Reference Manual section 10.2(2-6). There are no
9725 implementation-defined pragmas or other implementation-defined
9726 means for specifying needed units.
9731 @strong{33}. The manner of designating the main subprogram of a
9732 partition. See 10.2(7).
9735 The main program is designated by providing the name of the
9736 corresponding @file{ALI} file as the input parameter to the binder.
9741 @strong{34}. The order of elaboration of @code{library_items}. See
9745 The first constraint on ordering is that it meets the requirements of
9746 Chapter 10 of the Ada Reference Manual. This still leaves some
9747 implementation dependent choices, which are resolved by first
9748 elaborating bodies as early as possible (i.e., in preference to specs
9749 where there is a choice), and second by evaluating the immediate with
9750 clauses of a unit to determine the probably best choice, and
9751 third by elaborating in alphabetical order of unit names
9752 where a choice still remains.
9757 @strong{35}. Parameter passing and function return for the main
9758 subprogram. See 10.2(21).
9761 The main program has no parameters. It may be a procedure, or a function
9762 returning an integer type. In the latter case, the returned integer
9763 value is the return code of the program (overriding any value that
9764 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
9769 @strong{36}. The mechanisms for building and running partitions. See
9773 GNAT itself supports programs with only a single partition. The GNATDIST
9774 tool provided with the GLADE package (which also includes an implementation
9775 of the PCS) provides a completely flexible method for building and running
9776 programs consisting of multiple partitions. See the separate GLADE manual
9782 @strong{37}. The details of program execution, including program
9783 termination. See 10.2(25).
9786 See separate section on compilation model.
9791 @strong{38}. The semantics of any non-active partitions supported by the
9792 implementation. See 10.2(28).
9795 Passive partitions are supported on targets where shared memory is
9796 provided by the operating system. See the GLADE reference manual for
9802 @strong{39}. The information returned by @code{Exception_Message}. See
9806 Exception message returns the null string unless a specific message has
9807 been passed by the program.
9812 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
9813 declared within an unnamed @code{block_statement}. See 11.4.1(12).
9816 Blocks have implementation defined names of the form @code{B@var{nnn}}
9817 where @var{nnn} is an integer.
9822 @strong{41}. The information returned by
9823 @code{Exception_Information}. See 11.4.1(13).
9826 @code{Exception_Information} returns a string in the following format:
9829 @emph{Exception_Name:} nnnnn
9830 @emph{Message:} mmmmm
9832 @emph{Call stack traceback locations:}
9833 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
9841 @code{nnnn} is the fully qualified name of the exception in all upper
9842 case letters. This line is always present.
9845 @code{mmmm} is the message (this line present only if message is non-null)
9848 @code{ppp} is the Process Id value as a decimal integer (this line is
9849 present only if the Process Id is nonzero). Currently we are
9850 not making use of this field.
9853 The Call stack traceback locations line and the following values
9854 are present only if at least one traceback location was recorded.
9855 The values are given in C style format, with lower case letters
9856 for a-f, and only as many digits present as are necessary.
9860 The line terminator sequence at the end of each line, including
9861 the last line is a single @code{LF} character (@code{16#0A#}).
9866 @strong{42}. Implementation-defined check names. See 11.5(27).
9869 The implementation defined check name Alignment_Check controls checking of
9870 address clause values for proper alignment (that is, the address supplied
9871 must be consistent with the alignment of the type).
9873 In addition, a user program can add implementation-defined check names
9874 by means of the pragma Check_Name.
9879 @strong{43}. The interpretation of each aspect of representation. See
9883 See separate section on data representations.
9888 @strong{44}. Any restrictions placed upon representation items. See
9892 See separate section on data representations.
9897 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
9901 Size for an indefinite subtype is the maximum possible size, except that
9902 for the case of a subprogram parameter, the size of the parameter object
9908 @strong{46}. The default external representation for a type tag. See
9912 The default external representation for a type tag is the fully expanded
9913 name of the type in upper case letters.
9918 @strong{47}. What determines whether a compilation unit is the same in
9919 two different partitions. See 13.3(76).
9922 A compilation unit is the same in two different partitions if and only
9923 if it derives from the same source file.
9928 @strong{48}. Implementation-defined components. See 13.5.1(15).
9931 The only implementation defined component is the tag for a tagged type,
9932 which contains a pointer to the dispatching table.
9937 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
9938 ordering. See 13.5.3(5).
9941 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
9942 implementation, so no non-default bit ordering is supported. The default
9943 bit ordering corresponds to the natural endianness of the target architecture.
9948 @strong{50}. The contents of the visible part of package @code{System}
9949 and its language-defined children. See 13.7(2).
9952 See the definition of these packages in files @file{system.ads} and
9953 @file{s-stoele.ads}.
9958 @strong{51}. The contents of the visible part of package
9959 @code{System.Machine_Code}, and the meaning of
9960 @code{code_statements}. See 13.8(7).
9963 See the definition and documentation in file @file{s-maccod.ads}.
9968 @strong{52}. The effect of unchecked conversion. See 13.9(11).
9971 Unchecked conversion between types of the same size
9972 results in an uninterpreted transmission of the bits from one type
9973 to the other. If the types are of unequal sizes, then in the case of
9974 discrete types, a shorter source is first zero or sign extended as
9975 necessary, and a shorter target is simply truncated on the left.
9976 For all non-discrete types, the source is first copied if necessary
9977 to ensure that the alignment requirements of the target are met, then
9978 a pointer is constructed to the source value, and the result is obtained
9979 by dereferencing this pointer after converting it to be a pointer to the
9980 target type. Unchecked conversions where the target subtype is an
9981 unconstrained array are not permitted. If the target alignment is
9982 greater than the source alignment, then a copy of the result is
9983 made with appropriate alignment
9988 @strong{53}. The semantics of operations on invalid representations.
9992 For assignments and other operations where the use of invalid values cannot
9993 result in erroneous behavior, the compiler ignores the possibility of invalid
9994 values. An exception is raised at the point where an invalid value would
9995 result in erroneous behavior. For example executing:
9997 @smallexample @c ada
9998 procedure invalidvals is
10000 Y : Natural range 1 .. 10;
10001 for Y'Address use X'Address;
10002 Z : Natural range 1 .. 10;
10003 A : array (Natural range 1 .. 10) of Integer;
10005 Z := Y; -- no exception
10006 A (Z) := 3; -- exception raised;
10011 As indicated, an exception is raised on the array assignment, but not
10012 on the simple assignment of the invalid negative value from Y to Z.
10017 @strong{53}. The manner of choosing a storage pool for an access type
10018 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
10021 There are 3 different standard pools used by the compiler when
10022 @code{Storage_Pool} is not specified depending whether the type is local
10023 to a subprogram or defined at the library level and whether
10024 @code{Storage_Size}is specified or not. See documentation in the runtime
10025 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
10026 @code{System.Pool_Local} in files @file{s-poosiz.ads},
10027 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
10028 default pools used.
10033 @strong{54}. Whether or not the implementation provides user-accessible
10034 names for the standard pool type(s). See 13.11(17).
10038 See documentation in the sources of the run time mentioned in paragraph
10039 @strong{53} . All these pools are accessible by means of @code{with}'ing
10045 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
10048 @code{Storage_Size} is measured in storage units, and refers to the
10049 total space available for an access type collection, or to the primary
10050 stack space for a task.
10055 @strong{56}. Implementation-defined aspects of storage pools. See
10059 See documentation in the sources of the run time mentioned in paragraph
10060 @strong{53} for details on GNAT-defined aspects of storage pools.
10065 @strong{57}. The set of restrictions allowed in a pragma
10066 @code{Restrictions}. See 13.12(7).
10069 @xref{Standard and Implementation Defined Restrictions}.
10074 @strong{58}. The consequences of violating limitations on
10075 @code{Restrictions} pragmas. See 13.12(9).
10078 Restrictions that can be checked at compile time result in illegalities
10079 if violated. Currently there are no other consequences of violating
10085 @strong{59}. The representation used by the @code{Read} and
10086 @code{Write} attributes of elementary types in terms of stream
10087 elements. See 13.13.2(9).
10090 The representation is the in-memory representation of the base type of
10091 the type, using the number of bits corresponding to the
10092 @code{@var{type}'Size} value, and the natural ordering of the machine.
10097 @strong{60}. The names and characteristics of the numeric subtypes
10098 declared in the visible part of package @code{Standard}. See A.1(3).
10101 See items describing the integer and floating-point types supported.
10106 @strong{61}. The accuracy actually achieved by the elementary
10107 functions. See A.5.1(1).
10110 The elementary functions correspond to the functions available in the C
10111 library. Only fast math mode is implemented.
10116 @strong{62}. The sign of a zero result from some of the operators or
10117 functions in @code{Numerics.Generic_Elementary_Functions}, when
10118 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
10121 The sign of zeroes follows the requirements of the IEEE 754 standard on
10127 @strong{63}. The value of
10128 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
10131 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10136 @strong{64}. The value of
10137 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
10140 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10145 @strong{65}. The algorithms for random number generation. See
10149 The algorithm is the Mersenne Twister, as documented in the source file
10150 @file{s-rannum.adb}. This version of the algorithm has a period of
10156 @strong{66}. The string representation of a random number generator's
10157 state. See A.5.2(38).
10160 The value returned by the Image function is the concatenation of
10161 the fixed-width decimal representations of the 624 32-bit integers
10162 of the state vector.
10167 @strong{67}. The minimum time interval between calls to the
10168 time-dependent Reset procedure that are guaranteed to initiate different
10169 random number sequences. See A.5.2(45).
10172 The minimum period between reset calls to guarantee distinct series of
10173 random numbers is one microsecond.
10178 @strong{68}. The values of the @code{Model_Mantissa},
10179 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
10180 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
10181 Annex is not supported. See A.5.3(72).
10184 Run the compiler with @option{-gnatS} to produce a listing of package
10185 @code{Standard}, has the values of all numeric attributes.
10190 @strong{69}. Any implementation-defined characteristics of the
10191 input-output packages. See A.7(14).
10194 There are no special implementation defined characteristics for these
10200 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
10204 All type representations are contiguous, and the @code{Buffer_Size} is
10205 the value of @code{@var{type}'Size} rounded up to the next storage unit
10211 @strong{71}. External files for standard input, standard output, and
10212 standard error See A.10(5).
10215 These files are mapped onto the files provided by the C streams
10216 libraries. See source file @file{i-cstrea.ads} for further details.
10221 @strong{72}. The accuracy of the value produced by @code{Put}. See
10225 If more digits are requested in the output than are represented by the
10226 precision of the value, zeroes are output in the corresponding least
10227 significant digit positions.
10232 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
10233 @code{Command_Name}. See A.15(1).
10236 These are mapped onto the @code{argv} and @code{argc} parameters of the
10237 main program in the natural manner.
10242 @strong{74}. The interpretation of the @code{Form} parameter in procedure
10243 @code{Create_Directory}. See A.16(56).
10246 The @code{Form} parameter is not used.
10251 @strong{75}. The interpretation of the @code{Form} parameter in procedure
10252 @code{Create_Path}. See A.16(60).
10255 The @code{Form} parameter is not used.
10260 @strong{76}. The interpretation of the @code{Form} parameter in procedure
10261 @code{Copy_File}. See A.16(68).
10264 The @code{Form} parameter is case-insensitive.
10266 Two fields are recognized in the @code{Form} parameter:
10270 @item preserve=<value>
10277 <value> starts immediately after the character '=' and ends with the
10278 character immediately preceding the next comma (',') or with the last
10279 character of the parameter.
10281 The only possible values for preserve= are:
10285 @item no_attributes
10286 Do not try to preserve any file attributes. This is the default if no
10287 preserve= is found in Form.
10289 @item all_attributes
10290 Try to preserve all file attributes (timestamps, access rights).
10293 Preserve the timestamp of the copied file, but not the other file attributes.
10298 The only possible values for mode= are:
10303 Only do the copy if the destination file does not already exist. If it already
10304 exists, Copy_File fails.
10307 Copy the file in all cases. Overwrite an already existing destination file.
10310 Append the original file to the destination file. If the destination file does
10311 not exist, the destination file is a copy of the source file. When mode=append,
10312 the field preserve=, if it exists, is not taken into account.
10317 If the Form parameter includes one or both of the fields and the value or
10318 values are incorrect, Copy_file fails with Use_Error.
10320 Examples of correct Forms:
10323 Form => "preserve=no_attributes,mode=overwrite" (the default)
10324 Form => "mode=append"
10325 Form => "mode=copy, preserve=all_attributes"
10329 Examples of incorrect Forms
10332 Form => "preserve=junk"
10333 Form => "mode=internal, preserve=timestamps"
10339 @strong{77}. Implementation-defined convention names. See B.1(11).
10342 The following convention names are supported
10347 @item Ada_Pass_By_Copy
10348 Allowed for any types except by-reference types such as limited
10349 records. Compatible with convention Ada, but causes any parameters
10350 with this convention to be passed by copy.
10351 @item Ada_Pass_By_Reference
10352 Allowed for any types except by-copy types such as scalars.
10353 Compatible with convention Ada, but causes any parameters
10354 with this convention to be passed by reference.
10358 Synonym for Assembler
10360 Synonym for Assembler
10363 @item C_Pass_By_Copy
10364 Allowed only for record types, like C, but also notes that record
10365 is to be passed by copy rather than reference.
10368 @item C_Plus_Plus (or CPP)
10371 Treated the same as C
10373 Treated the same as C
10377 For support of pragma @code{Import} with convention Intrinsic, see
10378 separate section on Intrinsic Subprograms.
10380 Stdcall (used for Windows implementations only). This convention correspond
10381 to the WINAPI (previously called Pascal convention) C/C++ convention under
10382 Windows. A routine with this convention cleans the stack before
10383 exit. This pragma cannot be applied to a dispatching call.
10385 Synonym for Stdcall
10387 Synonym for Stdcall
10389 Stubbed is a special convention used to indicate that the body of the
10390 subprogram will be entirely ignored. Any call to the subprogram
10391 is converted into a raise of the @code{Program_Error} exception. If a
10392 pragma @code{Import} specifies convention @code{stubbed} then no body need
10393 be present at all. This convention is useful during development for the
10394 inclusion of subprograms whose body has not yet been written.
10398 In addition, all otherwise unrecognized convention names are also
10399 treated as being synonymous with convention C@. In all implementations
10400 except for VMS, use of such other names results in a warning. In VMS
10401 implementations, these names are accepted silently.
10406 @strong{78}. The meaning of link names. See B.1(36).
10409 Link names are the actual names used by the linker.
10414 @strong{79}. The manner of choosing link names when neither the link
10415 name nor the address of an imported or exported entity is specified. See
10419 The default linker name is that which would be assigned by the relevant
10420 external language, interpreting the Ada name as being in all lower case
10426 @strong{80}. The effect of pragma @code{Linker_Options}. See B.1(37).
10429 The string passed to @code{Linker_Options} is presented uninterpreted as
10430 an argument to the link command, unless it contains ASCII.NUL characters.
10431 NUL characters if they appear act as argument separators, so for example
10433 @smallexample @c ada
10434 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
10438 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
10439 linker. The order of linker options is preserved for a given unit. The final
10440 list of options passed to the linker is in reverse order of the elaboration
10441 order. For example, linker options for a body always appear before the options
10442 from the corresponding package spec.
10447 @strong{81}. The contents of the visible part of package
10448 @code{Interfaces} and its language-defined descendants. See B.2(1).
10451 See files with prefix @file{i-} in the distributed library.
10456 @strong{82}. Implementation-defined children of package
10457 @code{Interfaces}. The contents of the visible part of package
10458 @code{Interfaces}. See B.2(11).
10461 See files with prefix @file{i-} in the distributed library.
10466 @strong{83}. The types @code{Floating}, @code{Long_Floating},
10467 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
10468 @code{COBOL_Character}; and the initialization of the variables
10469 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
10470 @code{Interfaces.COBOL}. See B.4(50).
10476 @item Long_Floating
10477 (Floating) Long_Float
10482 @item Decimal_Element
10484 @item COBOL_Character
10489 For initialization, see the file @file{i-cobol.ads} in the distributed library.
10494 @strong{84}. Support for access to machine instructions. See C.1(1).
10497 See documentation in file @file{s-maccod.ads} in the distributed library.
10502 @strong{85}. Implementation-defined aspects of access to machine
10503 operations. See C.1(9).
10506 See documentation in file @file{s-maccod.ads} in the distributed library.
10511 @strong{86}. Implementation-defined aspects of interrupts. See C.3(2).
10514 Interrupts are mapped to signals or conditions as appropriate. See
10516 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
10517 on the interrupts supported on a particular target.
10522 @strong{87}. Implementation-defined aspects of pre-elaboration. See
10526 GNAT does not permit a partition to be restarted without reloading,
10527 except under control of the debugger.
10532 @strong{88}. The semantics of pragma @code{Discard_Names}. See C.5(7).
10535 Pragma @code{Discard_Names} causes names of enumeration literals to
10536 be suppressed. In the presence of this pragma, the Image attribute
10537 provides the image of the Pos of the literal, and Value accepts
10543 @strong{89}. The result of the @code{Task_Identification.Image}
10544 attribute. See C.7.1(7).
10547 The result of this attribute is a string that identifies
10548 the object or component that denotes a given task. If a variable @code{Var}
10549 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
10551 is the hexadecimal representation of the virtual address of the corresponding
10552 task control block. If the variable is an array of tasks, the image of each
10553 task will have the form of an indexed component indicating the position of a
10554 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
10555 component of a record, the image of the task will have the form of a selected
10556 component. These rules are fully recursive, so that the image of a task that
10557 is a subcomponent of a composite object corresponds to the expression that
10558 designates this task.
10560 If a task is created by an allocator, its image depends on the context. If the
10561 allocator is part of an object declaration, the rules described above are used
10562 to construct its image, and this image is not affected by subsequent
10563 assignments. If the allocator appears within an expression, the image
10564 includes only the name of the task type.
10566 If the configuration pragma Discard_Names is present, or if the restriction
10567 No_Implicit_Heap_Allocation is in effect, the image reduces to
10568 the numeric suffix, that is to say the hexadecimal representation of the
10569 virtual address of the control block of the task.
10573 @strong{90}. The value of @code{Current_Task} when in a protected entry
10574 or interrupt handler. See C.7.1(17).
10577 Protected entries or interrupt handlers can be executed by any
10578 convenient thread, so the value of @code{Current_Task} is undefined.
10583 @strong{91}. The effect of calling @code{Current_Task} from an entry
10584 body or interrupt handler. See C.7.1(19).
10587 The effect of calling @code{Current_Task} from an entry body or
10588 interrupt handler is to return the identification of the task currently
10589 executing the code.
10594 @strong{92}. Implementation-defined aspects of
10595 @code{Task_Attributes}. See C.7.2(19).
10598 There are no implementation-defined aspects of @code{Task_Attributes}.
10603 @strong{93}. Values of all @code{Metrics}. See D(2).
10606 The metrics information for GNAT depends on the performance of the
10607 underlying operating system. The sources of the run-time for tasking
10608 implementation, together with the output from @option{-gnatG} can be
10609 used to determine the exact sequence of operating systems calls made
10610 to implement various tasking constructs. Together with appropriate
10611 information on the performance of the underlying operating system,
10612 on the exact target in use, this information can be used to determine
10613 the required metrics.
10618 @strong{94}. The declarations of @code{Any_Priority} and
10619 @code{Priority}. See D.1(11).
10622 See declarations in file @file{system.ads}.
10627 @strong{95}. Implementation-defined execution resources. See D.1(15).
10630 There are no implementation-defined execution resources.
10635 @strong{96}. Whether, on a multiprocessor, a task that is waiting for
10636 access to a protected object keeps its processor busy. See D.2.1(3).
10639 On a multi-processor, a task that is waiting for access to a protected
10640 object does not keep its processor busy.
10645 @strong{97}. The affect of implementation defined execution resources
10646 on task dispatching. See D.2.1(9).
10649 Tasks map to threads in the threads package used by GNAT@. Where possible
10650 and appropriate, these threads correspond to native threads of the
10651 underlying operating system.
10656 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
10657 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
10660 There are no implementation-defined policy-identifiers allowed in this
10666 @strong{99}. Implementation-defined aspects of priority inversion. See
10670 Execution of a task cannot be preempted by the implementation processing
10671 of delay expirations for lower priority tasks.
10676 @strong{100}. Implementation-defined task dispatching. See D.2.2(18).
10679 The policy is the same as that of the underlying threads implementation.
10684 @strong{101}. Implementation-defined @code{policy_identifiers} allowed
10685 in a pragma @code{Locking_Policy}. See D.3(4).
10688 The two implementation defined policies permitted in GNAT are
10689 @code{Inheritance_Locking} and @code{Conccurent_Readers_Locking}. On
10690 targets that support the @code{Inheritance_Locking} policy, locking is
10691 implemented by inheritance, i.e.@: the task owning the lock operates
10692 at a priority equal to the highest priority of any task currently
10693 requesting the lock. On targets that support the
10694 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
10695 read/write lock allowing multiple propected object functions to enter
10701 @strong{102}. Default ceiling priorities. See D.3(10).
10704 The ceiling priority of protected objects of the type
10705 @code{System.Interrupt_Priority'Last} as described in the Ada
10706 Reference Manual D.3(10),
10711 @strong{103}. The ceiling of any protected object used internally by
10712 the implementation. See D.3(16).
10715 The ceiling priority of internal protected objects is
10716 @code{System.Priority'Last}.
10721 @strong{104}. Implementation-defined queuing policies. See D.4(1).
10724 There are no implementation-defined queuing policies.
10729 @strong{105}. On a multiprocessor, any conditions that cause the
10730 completion of an aborted construct to be delayed later than what is
10731 specified for a single processor. See D.6(3).
10734 The semantics for abort on a multi-processor is the same as on a single
10735 processor, there are no further delays.
10740 @strong{106}. Any operations that implicitly require heap storage
10741 allocation. See D.7(8).
10744 The only operation that implicitly requires heap storage allocation is
10750 @strong{107}. Implementation-defined aspects of pragma
10751 @code{Restrictions}. See D.7(20).
10754 There are no such implementation-defined aspects.
10759 @strong{108}. Implementation-defined aspects of package
10760 @code{Real_Time}. See D.8(17).
10763 There are no implementation defined aspects of package @code{Real_Time}.
10768 @strong{109}. Implementation-defined aspects of
10769 @code{delay_statements}. See D.9(8).
10772 Any difference greater than one microsecond will cause the task to be
10773 delayed (see D.9(7)).
10778 @strong{110}. The upper bound on the duration of interrupt blocking
10779 caused by the implementation. See D.12(5).
10782 The upper bound is determined by the underlying operating system. In
10783 no cases is it more than 10 milliseconds.
10788 @strong{111}. The means for creating and executing distributed
10789 programs. See E(5).
10792 The GLADE package provides a utility GNATDIST for creating and executing
10793 distributed programs. See the GLADE reference manual for further details.
10798 @strong{112}. Any events that can result in a partition becoming
10799 inaccessible. See E.1(7).
10802 See the GLADE reference manual for full details on such events.
10807 @strong{113}. The scheduling policies, treatment of priorities, and
10808 management of shared resources between partitions in certain cases. See
10812 See the GLADE reference manual for full details on these aspects of
10813 multi-partition execution.
10818 @strong{114}. Events that cause the version of a compilation unit to
10819 change. See E.3(5).
10822 Editing the source file of a compilation unit, or the source files of
10823 any units on which it is dependent in a significant way cause the version
10824 to change. No other actions cause the version number to change. All changes
10825 are significant except those which affect only layout, capitalization or
10831 @strong{115}. Whether the execution of the remote subprogram is
10832 immediately aborted as a result of cancellation. See E.4(13).
10835 See the GLADE reference manual for details on the effect of abort in
10836 a distributed application.
10841 @strong{116}. Implementation-defined aspects of the PCS@. See E.5(25).
10844 See the GLADE reference manual for a full description of all implementation
10845 defined aspects of the PCS@.
10850 @strong{117}. Implementation-defined interfaces in the PCS@. See
10854 See the GLADE reference manual for a full description of all
10855 implementation defined interfaces.
10860 @strong{118}. The values of named numbers in the package
10861 @code{Decimal}. See F.2(7).
10873 @item Max_Decimal_Digits
10880 @strong{119}. The value of @code{Max_Picture_Length} in the package
10881 @code{Text_IO.Editing}. See F.3.3(16).
10889 @strong{120}. The value of @code{Max_Picture_Length} in the package
10890 @code{Wide_Text_IO.Editing}. See F.3.4(5).
10898 @strong{121}. The accuracy actually achieved by the complex elementary
10899 functions and by other complex arithmetic operations. See G.1(1).
10902 Standard library functions are used for the complex arithmetic
10903 operations. Only fast math mode is currently supported.
10908 @strong{122}. The sign of a zero result (or a component thereof) from
10909 any operator or function in @code{Numerics.Generic_Complex_Types}, when
10910 @code{Real'Signed_Zeros} is True. See G.1.1(53).
10913 The signs of zero values are as recommended by the relevant
10914 implementation advice.
10919 @strong{123}. The sign of a zero result (or a component thereof) from
10920 any operator or function in
10921 @code{Numerics.Generic_Complex_Elementary_Functions}, when
10922 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
10925 The signs of zero values are as recommended by the relevant
10926 implementation advice.
10931 @strong{124}. Whether the strict mode or the relaxed mode is the
10932 default. See G.2(2).
10935 The strict mode is the default. There is no separate relaxed mode. GNAT
10936 provides a highly efficient implementation of strict mode.
10941 @strong{125}. The result interval in certain cases of fixed-to-float
10942 conversion. See G.2.1(10).
10945 For cases where the result interval is implementation dependent, the
10946 accuracy is that provided by performing all operations in 64-bit IEEE
10947 floating-point format.
10952 @strong{126}. The result of a floating point arithmetic operation in
10953 overflow situations, when the @code{Machine_Overflows} attribute of the
10954 result type is @code{False}. See G.2.1(13).
10957 Infinite and NaN values are produced as dictated by the IEEE
10958 floating-point standard.
10960 Note that on machines that are not fully compliant with the IEEE
10961 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
10962 must be used for achieving IEEE conforming behavior (although at the cost
10963 of a significant performance penalty), so infinite and NaN values are
10964 properly generated.
10969 @strong{127}. The result interval for division (or exponentiation by a
10970 negative exponent), when the floating point hardware implements division
10971 as multiplication by a reciprocal. See G.2.1(16).
10974 Not relevant, division is IEEE exact.
10979 @strong{128}. The definition of close result set, which determines the
10980 accuracy of certain fixed point multiplications and divisions. See
10984 Operations in the close result set are performed using IEEE long format
10985 floating-point arithmetic. The input operands are converted to
10986 floating-point, the operation is done in floating-point, and the result
10987 is converted to the target type.
10992 @strong{129}. Conditions on a @code{universal_real} operand of a fixed
10993 point multiplication or division for which the result shall be in the
10994 perfect result set. See G.2.3(22).
10997 The result is only defined to be in the perfect result set if the result
10998 can be computed by a single scaling operation involving a scale factor
10999 representable in 64-bits.
11004 @strong{130}. The result of a fixed point arithmetic operation in
11005 overflow situations, when the @code{Machine_Overflows} attribute of the
11006 result type is @code{False}. See G.2.3(27).
11009 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
11015 @strong{131}. The result of an elementary function reference in
11016 overflow situations, when the @code{Machine_Overflows} attribute of the
11017 result type is @code{False}. See G.2.4(4).
11020 IEEE infinite and Nan values are produced as appropriate.
11025 @strong{132}. The value of the angle threshold, within which certain
11026 elementary functions, complex arithmetic operations, and complex
11027 elementary functions yield results conforming to a maximum relative
11028 error bound. See G.2.4(10).
11031 Information on this subject is not yet available.
11036 @strong{133}. The accuracy of certain elementary functions for
11037 parameters beyond the angle threshold. See G.2.4(10).
11040 Information on this subject is not yet available.
11045 @strong{134}. The result of a complex arithmetic operation or complex
11046 elementary function reference in overflow situations, when the
11047 @code{Machine_Overflows} attribute of the corresponding real type is
11048 @code{False}. See G.2.6(5).
11051 IEEE infinite and Nan values are produced as appropriate.
11056 @strong{135}. The accuracy of certain complex arithmetic operations and
11057 certain complex elementary functions for parameters (or components
11058 thereof) beyond the angle threshold. See G.2.6(8).
11061 Information on those subjects is not yet available.
11066 @strong{136}. Information regarding bounded errors and erroneous
11067 execution. See H.2(1).
11070 Information on this subject is not yet available.
11075 @strong{137}. Implementation-defined aspects of pragma
11076 @code{Inspection_Point}. See H.3.2(8).
11079 Pragma @code{Inspection_Point} ensures that the variable is live and can
11080 be examined by the debugger at the inspection point.
11085 @strong{138}. Implementation-defined aspects of pragma
11086 @code{Restrictions}. See H.4(25).
11089 There are no implementation-defined aspects of pragma @code{Restrictions}. The
11090 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
11091 generated code. Checks must suppressed by use of pragma @code{Suppress}.
11096 @strong{139}. Any restrictions on pragma @code{Restrictions}. See
11100 There are no restrictions on pragma @code{Restrictions}.
11102 @node Intrinsic Subprograms
11103 @chapter Intrinsic Subprograms
11104 @cindex Intrinsic Subprograms
11107 * Intrinsic Operators::
11108 * Enclosing_Entity::
11109 * Exception_Information::
11110 * Exception_Message::
11114 * Shifts and Rotates::
11115 * Source_Location::
11119 GNAT allows a user application program to write the declaration:
11121 @smallexample @c ada
11122 pragma Import (Intrinsic, name);
11126 providing that the name corresponds to one of the implemented intrinsic
11127 subprograms in GNAT, and that the parameter profile of the referenced
11128 subprogram meets the requirements. This chapter describes the set of
11129 implemented intrinsic subprograms, and the requirements on parameter profiles.
11130 Note that no body is supplied; as with other uses of pragma Import, the
11131 body is supplied elsewhere (in this case by the compiler itself). Note
11132 that any use of this feature is potentially non-portable, since the
11133 Ada standard does not require Ada compilers to implement this feature.
11135 @node Intrinsic Operators
11136 @section Intrinsic Operators
11137 @cindex Intrinsic operator
11140 All the predefined numeric operators in package Standard
11141 in @code{pragma Import (Intrinsic,..)}
11142 declarations. In the binary operator case, the operands must have the same
11143 size. The operand or operands must also be appropriate for
11144 the operator. For example, for addition, the operands must
11145 both be floating-point or both be fixed-point, and the
11146 right operand for @code{"**"} must have a root type of
11147 @code{Standard.Integer'Base}.
11148 You can use an intrinsic operator declaration as in the following example:
11150 @smallexample @c ada
11151 type Int1 is new Integer;
11152 type Int2 is new Integer;
11154 function "+" (X1 : Int1; X2 : Int2) return Int1;
11155 function "+" (X1 : Int1; X2 : Int2) return Int2;
11156 pragma Import (Intrinsic, "+");
11160 This declaration would permit ``mixed mode'' arithmetic on items
11161 of the differing types @code{Int1} and @code{Int2}.
11162 It is also possible to specify such operators for private types, if the
11163 full views are appropriate arithmetic types.
11165 @node Enclosing_Entity
11166 @section Enclosing_Entity
11167 @cindex Enclosing_Entity
11169 This intrinsic subprogram is used in the implementation of the
11170 library routine @code{GNAT.Source_Info}. The only useful use of the
11171 intrinsic import in this case is the one in this unit, so an
11172 application program should simply call the function
11173 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
11174 the current subprogram, package, task, entry, or protected subprogram.
11176 @node Exception_Information
11177 @section Exception_Information
11178 @cindex Exception_Information'
11180 This intrinsic subprogram is used in the implementation of the
11181 library routine @code{GNAT.Current_Exception}. The only useful
11182 use of the intrinsic import in this case is the one in this unit,
11183 so an application program should simply call the function
11184 @code{GNAT.Current_Exception.Exception_Information} to obtain
11185 the exception information associated with the current exception.
11187 @node Exception_Message
11188 @section Exception_Message
11189 @cindex Exception_Message
11191 This intrinsic subprogram is used in the implementation of the
11192 library routine @code{GNAT.Current_Exception}. The only useful
11193 use of the intrinsic import in this case is the one in this unit,
11194 so an application program should simply call the function
11195 @code{GNAT.Current_Exception.Exception_Message} to obtain
11196 the message associated with the current exception.
11198 @node Exception_Name
11199 @section Exception_Name
11200 @cindex Exception_Name
11202 This intrinsic subprogram is used in the implementation of the
11203 library routine @code{GNAT.Current_Exception}. The only useful
11204 use of the intrinsic import in this case is the one in this unit,
11205 so an application program should simply call the function
11206 @code{GNAT.Current_Exception.Exception_Name} to obtain
11207 the name of the current exception.
11213 This intrinsic subprogram is used in the implementation of the
11214 library routine @code{GNAT.Source_Info}. The only useful use of the
11215 intrinsic import in this case is the one in this unit, so an
11216 application program should simply call the function
11217 @code{GNAT.Source_Info.File} to obtain the name of the current
11224 This intrinsic subprogram is used in the implementation of the
11225 library routine @code{GNAT.Source_Info}. The only useful use of the
11226 intrinsic import in this case is the one in this unit, so an
11227 application program should simply call the function
11228 @code{GNAT.Source_Info.Line} to obtain the number of the current
11231 @node Shifts and Rotates
11232 @section Shifts and Rotates
11234 @cindex Shift_Right
11235 @cindex Shift_Right_Arithmetic
11236 @cindex Rotate_Left
11237 @cindex Rotate_Right
11239 In standard Ada, the shift and rotate functions are available only
11240 for the predefined modular types in package @code{Interfaces}. However, in
11241 GNAT it is possible to define these functions for any integer
11242 type (signed or modular), as in this example:
11244 @smallexample @c ada
11245 function Shift_Left
11252 The function name must be one of
11253 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
11254 Rotate_Right. T must be an integer type. T'Size must be
11255 8, 16, 32 or 64 bits; if T is modular, the modulus
11256 must be 2**8, 2**16, 2**32 or 2**64.
11257 The result type must be the same as the type of @code{Value}.
11258 The shift amount must be Natural.
11259 The formal parameter names can be anything.
11261 @node Source_Location
11262 @section Source_Location
11263 @cindex Source_Location
11265 This intrinsic subprogram is used in the implementation of the
11266 library routine @code{GNAT.Source_Info}. The only useful use of the
11267 intrinsic import in this case is the one in this unit, so an
11268 application program should simply call the function
11269 @code{GNAT.Source_Info.Source_Location} to obtain the current
11270 source file location.
11272 @node Representation Clauses and Pragmas
11273 @chapter Representation Clauses and Pragmas
11274 @cindex Representation Clauses
11277 * Alignment Clauses::
11279 * Storage_Size Clauses::
11280 * Size of Variant Record Objects::
11281 * Biased Representation ::
11282 * Value_Size and Object_Size Clauses::
11283 * Component_Size Clauses::
11284 * Bit_Order Clauses::
11285 * Effect of Bit_Order on Byte Ordering::
11286 * Pragma Pack for Arrays::
11287 * Pragma Pack for Records::
11288 * Record Representation Clauses::
11289 * Enumeration Clauses::
11290 * Address Clauses::
11291 * Effect of Convention on Representation::
11292 * Determining the Representations chosen by GNAT::
11296 @cindex Representation Clause
11297 @cindex Representation Pragma
11298 @cindex Pragma, representation
11299 This section describes the representation clauses accepted by GNAT, and
11300 their effect on the representation of corresponding data objects.
11302 GNAT fully implements Annex C (Systems Programming). This means that all
11303 the implementation advice sections in chapter 13 are fully implemented.
11304 However, these sections only require a minimal level of support for
11305 representation clauses. GNAT provides much more extensive capabilities,
11306 and this section describes the additional capabilities provided.
11308 @node Alignment Clauses
11309 @section Alignment Clauses
11310 @cindex Alignment Clause
11313 GNAT requires that all alignment clauses specify a power of 2, and all
11314 default alignments are always a power of 2. The default alignment
11315 values are as follows:
11318 @item @emph{Primitive Types}.
11319 For primitive types, the alignment is the minimum of the actual size of
11320 objects of the type divided by @code{Storage_Unit},
11321 and the maximum alignment supported by the target.
11322 (This maximum alignment is given by the GNAT-specific attribute
11323 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
11324 @cindex @code{Maximum_Alignment} attribute
11325 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
11326 default alignment will be 8 on any target that supports alignments
11327 this large, but on some targets, the maximum alignment may be smaller
11328 than 8, in which case objects of type @code{Long_Float} will be maximally
11331 @item @emph{Arrays}.
11332 For arrays, the alignment is equal to the alignment of the component type
11333 for the normal case where no packing or component size is given. If the
11334 array is packed, and the packing is effective (see separate section on
11335 packed arrays), then the alignment will be one for long packed arrays,
11336 or arrays whose length is not known at compile time. For short packed
11337 arrays, which are handled internally as modular types, the alignment
11338 will be as described for primitive types, e.g.@: a packed array of length
11339 31 bits will have an object size of four bytes, and an alignment of 4.
11341 @item @emph{Records}.
11342 For the normal non-packed case, the alignment of a record is equal to
11343 the maximum alignment of any of its components. For tagged records, this
11344 includes the implicit access type used for the tag. If a pragma @code{Pack}
11345 is used and all components are packable (see separate section on pragma
11346 @code{Pack}), then the resulting alignment is 1, unless the layout of the
11347 record makes it profitable to increase it.
11349 A special case is when:
11352 the size of the record is given explicitly, or a
11353 full record representation clause is given, and
11355 the size of the record is 2, 4, or 8 bytes.
11358 In this case, an alignment is chosen to match the
11359 size of the record. For example, if we have:
11361 @smallexample @c ada
11362 type Small is record
11365 for Small'Size use 16;
11369 then the default alignment of the record type @code{Small} is 2, not 1. This
11370 leads to more efficient code when the record is treated as a unit, and also
11371 allows the type to specified as @code{Atomic} on architectures requiring
11377 An alignment clause may specify a larger alignment than the default value
11378 up to some maximum value dependent on the target (obtainable by using the
11379 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
11380 a smaller alignment than the default value for enumeration, integer and
11381 fixed point types, as well as for record types, for example
11383 @smallexample @c ada
11388 for V'alignment use 1;
11392 @cindex Alignment, default
11393 The default alignment for the type @code{V} is 4, as a result of the
11394 Integer field in the record, but it is permissible, as shown, to
11395 override the default alignment of the record with a smaller value.
11398 @section Size Clauses
11399 @cindex Size Clause
11402 The default size for a type @code{T} is obtainable through the
11403 language-defined attribute @code{T'Size} and also through the
11404 equivalent GNAT-defined attribute @code{T'Value_Size}.
11405 For objects of type @code{T}, GNAT will generally increase the type size
11406 so that the object size (obtainable through the GNAT-defined attribute
11407 @code{T'Object_Size})
11408 is a multiple of @code{T'Alignment * Storage_Unit}.
11411 @smallexample @c ada
11412 type Smallint is range 1 .. 6;
11421 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
11422 as specified by the RM rules,
11423 but objects of this type will have a size of 8
11424 (@code{Smallint'Object_Size} = 8),
11425 since objects by default occupy an integral number
11426 of storage units. On some targets, notably older
11427 versions of the Digital Alpha, the size of stand
11428 alone objects of this type may be 32, reflecting
11429 the inability of the hardware to do byte load/stores.
11431 Similarly, the size of type @code{Rec} is 40 bits
11432 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
11433 the alignment is 4, so objects of this type will have
11434 their size increased to 64 bits so that it is a multiple
11435 of the alignment (in bits). This decision is
11436 in accordance with the specific Implementation Advice in RM 13.3(43):
11439 A @code{Size} clause should be supported for an object if the specified
11440 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
11441 to a size in storage elements that is a multiple of the object's
11442 @code{Alignment} (if the @code{Alignment} is nonzero).
11446 An explicit size clause may be used to override the default size by
11447 increasing it. For example, if we have:
11449 @smallexample @c ada
11450 type My_Boolean is new Boolean;
11451 for My_Boolean'Size use 32;
11455 then values of this type will always be 32 bits long. In the case of
11456 discrete types, the size can be increased up to 64 bits, with the effect
11457 that the entire specified field is used to hold the value, sign- or
11458 zero-extended as appropriate. If more than 64 bits is specified, then
11459 padding space is allocated after the value, and a warning is issued that
11460 there are unused bits.
11462 Similarly the size of records and arrays may be increased, and the effect
11463 is to add padding bits after the value. This also causes a warning message
11466 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
11467 Size in bits, this corresponds to an object of size 256 megabytes (minus
11468 one). This limitation is true on all targets. The reason for this
11469 limitation is that it improves the quality of the code in many cases
11470 if it is known that a Size value can be accommodated in an object of
11473 @node Storage_Size Clauses
11474 @section Storage_Size Clauses
11475 @cindex Storage_Size Clause
11478 For tasks, the @code{Storage_Size} clause specifies the amount of space
11479 to be allocated for the task stack. This cannot be extended, and if the
11480 stack is exhausted, then @code{Storage_Error} will be raised (if stack
11481 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
11482 or a @code{Storage_Size} pragma in the task definition to set the
11483 appropriate required size. A useful technique is to include in every
11484 task definition a pragma of the form:
11486 @smallexample @c ada
11487 pragma Storage_Size (Default_Stack_Size);
11491 Then @code{Default_Stack_Size} can be defined in a global package, and
11492 modified as required. Any tasks requiring stack sizes different from the
11493 default can have an appropriate alternative reference in the pragma.
11495 You can also use the @option{-d} binder switch to modify the default stack
11498 For access types, the @code{Storage_Size} clause specifies the maximum
11499 space available for allocation of objects of the type. If this space is
11500 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
11501 In the case where the access type is declared local to a subprogram, the
11502 use of a @code{Storage_Size} clause triggers automatic use of a special
11503 predefined storage pool (@code{System.Pool_Size}) that ensures that all
11504 space for the pool is automatically reclaimed on exit from the scope in
11505 which the type is declared.
11507 A special case recognized by the compiler is the specification of a
11508 @code{Storage_Size} of zero for an access type. This means that no
11509 items can be allocated from the pool, and this is recognized at compile
11510 time, and all the overhead normally associated with maintaining a fixed
11511 size storage pool is eliminated. Consider the following example:
11513 @smallexample @c ada
11515 type R is array (Natural) of Character;
11516 type P is access all R;
11517 for P'Storage_Size use 0;
11518 -- Above access type intended only for interfacing purposes
11522 procedure g (m : P);
11523 pragma Import (C, g);
11534 As indicated in this example, these dummy storage pools are often useful in
11535 connection with interfacing where no object will ever be allocated. If you
11536 compile the above example, you get the warning:
11539 p.adb:16:09: warning: allocation from empty storage pool
11540 p.adb:16:09: warning: Storage_Error will be raised at run time
11544 Of course in practice, there will not be any explicit allocators in the
11545 case of such an access declaration.
11547 @node Size of Variant Record Objects
11548 @section Size of Variant Record Objects
11549 @cindex Size, variant record objects
11550 @cindex Variant record objects, size
11553 In the case of variant record objects, there is a question whether Size gives
11554 information about a particular variant, or the maximum size required
11555 for any variant. Consider the following program
11557 @smallexample @c ada
11558 with Text_IO; use Text_IO;
11560 type R1 (A : Boolean := False) is record
11562 when True => X : Character;
11563 when False => null;
11571 Put_Line (Integer'Image (V1'Size));
11572 Put_Line (Integer'Image (V2'Size));
11577 Here we are dealing with a variant record, where the True variant
11578 requires 16 bits, and the False variant requires 8 bits.
11579 In the above example, both V1 and V2 contain the False variant,
11580 which is only 8 bits long. However, the result of running the
11589 The reason for the difference here is that the discriminant value of
11590 V1 is fixed, and will always be False. It is not possible to assign
11591 a True variant value to V1, therefore 8 bits is sufficient. On the
11592 other hand, in the case of V2, the initial discriminant value is
11593 False (from the default), but it is possible to assign a True
11594 variant value to V2, therefore 16 bits must be allocated for V2
11595 in the general case, even fewer bits may be needed at any particular
11596 point during the program execution.
11598 As can be seen from the output of this program, the @code{'Size}
11599 attribute applied to such an object in GNAT gives the actual allocated
11600 size of the variable, which is the largest size of any of the variants.
11601 The Ada Reference Manual is not completely clear on what choice should
11602 be made here, but the GNAT behavior seems most consistent with the
11603 language in the RM@.
11605 In some cases, it may be desirable to obtain the size of the current
11606 variant, rather than the size of the largest variant. This can be
11607 achieved in GNAT by making use of the fact that in the case of a
11608 subprogram parameter, GNAT does indeed return the size of the current
11609 variant (because a subprogram has no way of knowing how much space
11610 is actually allocated for the actual).
11612 Consider the following modified version of the above program:
11614 @smallexample @c ada
11615 with Text_IO; use Text_IO;
11617 type R1 (A : Boolean := False) is record
11619 when True => X : Character;
11620 when False => null;
11626 function Size (V : R1) return Integer is
11632 Put_Line (Integer'Image (V2'Size));
11633 Put_Line (Integer'IMage (Size (V2)));
11635 Put_Line (Integer'Image (V2'Size));
11636 Put_Line (Integer'IMage (Size (V2)));
11641 The output from this program is
11651 Here we see that while the @code{'Size} attribute always returns
11652 the maximum size, regardless of the current variant value, the
11653 @code{Size} function does indeed return the size of the current
11656 @node Biased Representation
11657 @section Biased Representation
11658 @cindex Size for biased representation
11659 @cindex Biased representation
11662 In the case of scalars with a range starting at other than zero, it is
11663 possible in some cases to specify a size smaller than the default minimum
11664 value, and in such cases, GNAT uses an unsigned biased representation,
11665 in which zero is used to represent the lower bound, and successive values
11666 represent successive values of the type.
11668 For example, suppose we have the declaration:
11670 @smallexample @c ada
11671 type Small is range -7 .. -4;
11672 for Small'Size use 2;
11676 Although the default size of type @code{Small} is 4, the @code{Size}
11677 clause is accepted by GNAT and results in the following representation
11681 -7 is represented as 2#00#
11682 -6 is represented as 2#01#
11683 -5 is represented as 2#10#
11684 -4 is represented as 2#11#
11688 Biased representation is only used if the specified @code{Size} clause
11689 cannot be accepted in any other manner. These reduced sizes that force
11690 biased representation can be used for all discrete types except for
11691 enumeration types for which a representation clause is given.
11693 @node Value_Size and Object_Size Clauses
11694 @section Value_Size and Object_Size Clauses
11696 @findex Object_Size
11697 @cindex Size, of objects
11700 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
11701 number of bits required to hold values of type @code{T}.
11702 Although this interpretation was allowed in Ada 83, it was not required,
11703 and this requirement in practice can cause some significant difficulties.
11704 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
11705 However, in Ada 95 and Ada 2005,
11706 @code{Natural'Size} is
11707 typically 31. This means that code may change in behavior when moving
11708 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
11710 @smallexample @c ada
11711 type Rec is record;
11717 at 0 range 0 .. Natural'Size - 1;
11718 at 0 range Natural'Size .. 2 * Natural'Size - 1;
11723 In the above code, since the typical size of @code{Natural} objects
11724 is 32 bits and @code{Natural'Size} is 31, the above code can cause
11725 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
11726 there are cases where the fact that the object size can exceed the
11727 size of the type causes surprises.
11729 To help get around this problem GNAT provides two implementation
11730 defined attributes, @code{Value_Size} and @code{Object_Size}. When
11731 applied to a type, these attributes yield the size of the type
11732 (corresponding to the RM defined size attribute), and the size of
11733 objects of the type respectively.
11735 The @code{Object_Size} is used for determining the default size of
11736 objects and components. This size value can be referred to using the
11737 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
11738 the basis of the determination of the size. The backend is free to
11739 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
11740 character might be stored in 32 bits on a machine with no efficient
11741 byte access instructions such as the Alpha.
11743 The default rules for the value of @code{Object_Size} for
11744 discrete types are as follows:
11748 The @code{Object_Size} for base subtypes reflect the natural hardware
11749 size in bits (run the compiler with @option{-gnatS} to find those values
11750 for numeric types). Enumeration types and fixed-point base subtypes have
11751 8, 16, 32 or 64 bits for this size, depending on the range of values
11755 The @code{Object_Size} of a subtype is the same as the
11756 @code{Object_Size} of
11757 the type from which it is obtained.
11760 The @code{Object_Size} of a derived base type is copied from the parent
11761 base type, and the @code{Object_Size} of a derived first subtype is copied
11762 from the parent first subtype.
11766 The @code{Value_Size} attribute
11767 is the (minimum) number of bits required to store a value
11769 This value is used to determine how tightly to pack
11770 records or arrays with components of this type, and also affects
11771 the semantics of unchecked conversion (unchecked conversions where
11772 the @code{Value_Size} values differ generate a warning, and are potentially
11775 The default rules for the value of @code{Value_Size} are as follows:
11779 The @code{Value_Size} for a base subtype is the minimum number of bits
11780 required to store all values of the type (including the sign bit
11781 only if negative values are possible).
11784 If a subtype statically matches the first subtype of a given type, then it has
11785 by default the same @code{Value_Size} as the first subtype. This is a
11786 consequence of RM 13.1(14) (``if two subtypes statically match,
11787 then their subtype-specific aspects are the same''.)
11790 All other subtypes have a @code{Value_Size} corresponding to the minimum
11791 number of bits required to store all values of the subtype. For
11792 dynamic bounds, it is assumed that the value can range down or up
11793 to the corresponding bound of the ancestor
11797 The RM defined attribute @code{Size} corresponds to the
11798 @code{Value_Size} attribute.
11800 The @code{Size} attribute may be defined for a first-named subtype. This sets
11801 the @code{Value_Size} of
11802 the first-named subtype to the given value, and the
11803 @code{Object_Size} of this first-named subtype to the given value padded up
11804 to an appropriate boundary. It is a consequence of the default rules
11805 above that this @code{Object_Size} will apply to all further subtypes. On the
11806 other hand, @code{Value_Size} is affected only for the first subtype, any
11807 dynamic subtypes obtained from it directly, and any statically matching
11808 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
11810 @code{Value_Size} and
11811 @code{Object_Size} may be explicitly set for any subtype using
11812 an attribute definition clause. Note that the use of these attributes
11813 can cause the RM 13.1(14) rule to be violated. If two access types
11814 reference aliased objects whose subtypes have differing @code{Object_Size}
11815 values as a result of explicit attribute definition clauses, then it
11816 is erroneous to convert from one access subtype to the other.
11818 At the implementation level, Esize stores the Object_Size and the
11819 RM_Size field stores the @code{Value_Size} (and hence the value of the
11820 @code{Size} attribute,
11821 which, as noted above, is equivalent to @code{Value_Size}).
11823 To get a feel for the difference, consider the following examples (note
11824 that in each case the base is @code{Short_Short_Integer} with a size of 8):
11827 Object_Size Value_Size
11829 type x1 is range 0 .. 5; 8 3
11831 type x2 is range 0 .. 5;
11832 for x2'size use 12; 16 12
11834 subtype x3 is x2 range 0 .. 3; 16 2
11836 subtype x4 is x2'base range 0 .. 10; 8 4
11838 subtype x5 is x2 range 0 .. dynamic; 16 3*
11840 subtype x6 is x2'base range 0 .. dynamic; 8 3*
11845 Note: the entries marked ``3*'' are not actually specified by the Ada
11846 Reference Manual, but it seems in the spirit of the RM rules to allocate
11847 the minimum number of bits (here 3, given the range for @code{x2})
11848 known to be large enough to hold the given range of values.
11850 So far, so good, but GNAT has to obey the RM rules, so the question is
11851 under what conditions must the RM @code{Size} be used.
11852 The following is a list
11853 of the occasions on which the RM @code{Size} must be used:
11857 Component size for packed arrays or records
11860 Value of the attribute @code{Size} for a type
11863 Warning about sizes not matching for unchecked conversion
11867 For record types, the @code{Object_Size} is always a multiple of the
11868 alignment of the type (this is true for all types). In some cases the
11869 @code{Value_Size} can be smaller. Consider:
11879 On a typical 32-bit architecture, the X component will be four bytes, and
11880 require four-byte alignment, and the Y component will be one byte. In this
11881 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
11882 required to store a value of this type, and for example, it is permissible
11883 to have a component of type R in an outer array whose component size is
11884 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
11885 since it must be rounded up so that this value is a multiple of the
11886 alignment (4 bytes = 32 bits).
11889 For all other types, the @code{Object_Size}
11890 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
11891 Only @code{Size} may be specified for such types.
11893 @node Component_Size Clauses
11894 @section Component_Size Clauses
11895 @cindex Component_Size Clause
11898 Normally, the value specified in a component size clause must be consistent
11899 with the subtype of the array component with regard to size and alignment.
11900 In other words, the value specified must be at least equal to the size
11901 of this subtype, and must be a multiple of the alignment value.
11903 In addition, component size clauses are allowed which cause the array
11904 to be packed, by specifying a smaller value. A first case is for
11905 component size values in the range 1 through 63. The value specified
11906 must not be smaller than the Size of the subtype. GNAT will accurately
11907 honor all packing requests in this range. For example, if we have:
11909 @smallexample @c ada
11910 type r is array (1 .. 8) of Natural;
11911 for r'Component_Size use 31;
11915 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
11916 Of course access to the components of such an array is considerably
11917 less efficient than if the natural component size of 32 is used.
11918 A second case is when the subtype of the component is a record type
11919 padded because of its default alignment. For example, if we have:
11921 @smallexample @c ada
11928 type a is array (1 .. 8) of r;
11929 for a'Component_Size use 72;
11933 then the resulting array has a length of 72 bytes, instead of 96 bytes
11934 if the alignment of the record (4) was obeyed.
11936 Note that there is no point in giving both a component size clause
11937 and a pragma Pack for the same array type. if such duplicate
11938 clauses are given, the pragma Pack will be ignored.
11940 @node Bit_Order Clauses
11941 @section Bit_Order Clauses
11942 @cindex Bit_Order Clause
11943 @cindex bit ordering
11944 @cindex ordering, of bits
11947 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
11948 attribute. The specification may either correspond to the default bit
11949 order for the target, in which case the specification has no effect and
11950 places no additional restrictions, or it may be for the non-standard
11951 setting (that is the opposite of the default).
11953 In the case where the non-standard value is specified, the effect is
11954 to renumber bits within each byte, but the ordering of bytes is not
11955 affected. There are certain
11956 restrictions placed on component clauses as follows:
11960 @item Components fitting within a single storage unit.
11962 These are unrestricted, and the effect is merely to renumber bits. For
11963 example if we are on a little-endian machine with @code{Low_Order_First}
11964 being the default, then the following two declarations have exactly
11967 @smallexample @c ada
11970 B : Integer range 1 .. 120;
11974 A at 0 range 0 .. 0;
11975 B at 0 range 1 .. 7;
11980 B : Integer range 1 .. 120;
11983 for R2'Bit_Order use High_Order_First;
11986 A at 0 range 7 .. 7;
11987 B at 0 range 0 .. 6;
11992 The useful application here is to write the second declaration with the
11993 @code{Bit_Order} attribute definition clause, and know that it will be treated
11994 the same, regardless of whether the target is little-endian or big-endian.
11996 @item Components occupying an integral number of bytes.
11998 These are components that exactly fit in two or more bytes. Such component
11999 declarations are allowed, but have no effect, since it is important to realize
12000 that the @code{Bit_Order} specification does not affect the ordering of bytes.
12001 In particular, the following attempt at getting an endian-independent integer
12004 @smallexample @c ada
12009 for R2'Bit_Order use High_Order_First;
12012 A at 0 range 0 .. 31;
12017 This declaration will result in a little-endian integer on a
12018 little-endian machine, and a big-endian integer on a big-endian machine.
12019 If byte flipping is required for interoperability between big- and
12020 little-endian machines, this must be explicitly programmed. This capability
12021 is not provided by @code{Bit_Order}.
12023 @item Components that are positioned across byte boundaries
12025 but do not occupy an integral number of bytes. Given that bytes are not
12026 reordered, such fields would occupy a non-contiguous sequence of bits
12027 in memory, requiring non-trivial code to reassemble. They are for this
12028 reason not permitted, and any component clause specifying such a layout
12029 will be flagged as illegal by GNAT@.
12034 Since the misconception that Bit_Order automatically deals with all
12035 endian-related incompatibilities is a common one, the specification of
12036 a component field that is an integral number of bytes will always
12037 generate a warning. This warning may be suppressed using @code{pragma
12038 Warnings (Off)} if desired. The following section contains additional
12039 details regarding the issue of byte ordering.
12041 @node Effect of Bit_Order on Byte Ordering
12042 @section Effect of Bit_Order on Byte Ordering
12043 @cindex byte ordering
12044 @cindex ordering, of bytes
12047 In this section we will review the effect of the @code{Bit_Order} attribute
12048 definition clause on byte ordering. Briefly, it has no effect at all, but
12049 a detailed example will be helpful. Before giving this
12050 example, let us review the precise
12051 definition of the effect of defining @code{Bit_Order}. The effect of a
12052 non-standard bit order is described in section 15.5.3 of the Ada
12056 2 A bit ordering is a method of interpreting the meaning of
12057 the storage place attributes.
12061 To understand the precise definition of storage place attributes in
12062 this context, we visit section 13.5.1 of the manual:
12065 13 A record_representation_clause (without the mod_clause)
12066 specifies the layout. The storage place attributes (see 13.5.2)
12067 are taken from the values of the position, first_bit, and last_bit
12068 expressions after normalizing those values so that first_bit is
12069 less than Storage_Unit.
12073 The critical point here is that storage places are taken from
12074 the values after normalization, not before. So the @code{Bit_Order}
12075 interpretation applies to normalized values. The interpretation
12076 is described in the later part of the 15.5.3 paragraph:
12079 2 A bit ordering is a method of interpreting the meaning of
12080 the storage place attributes. High_Order_First (known in the
12081 vernacular as ``big endian'') means that the first bit of a
12082 storage element (bit 0) is the most significant bit (interpreting
12083 the sequence of bits that represent a component as an unsigned
12084 integer value). Low_Order_First (known in the vernacular as
12085 ``little endian'') means the opposite: the first bit is the
12090 Note that the numbering is with respect to the bits of a storage
12091 unit. In other words, the specification affects only the numbering
12092 of bits within a single storage unit.
12094 We can make the effect clearer by giving an example.
12096 Suppose that we have an external device which presents two bytes, the first
12097 byte presented, which is the first (low addressed byte) of the two byte
12098 record is called Master, and the second byte is called Slave.
12100 The left most (most significant bit is called Control for each byte, and
12101 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
12102 (least significant) bit.
12104 On a big-endian machine, we can write the following representation clause
12106 @smallexample @c ada
12107 type Data is record
12108 Master_Control : Bit;
12116 Slave_Control : Bit;
12126 for Data use record
12127 Master_Control at 0 range 0 .. 0;
12128 Master_V1 at 0 range 1 .. 1;
12129 Master_V2 at 0 range 2 .. 2;
12130 Master_V3 at 0 range 3 .. 3;
12131 Master_V4 at 0 range 4 .. 4;
12132 Master_V5 at 0 range 5 .. 5;
12133 Master_V6 at 0 range 6 .. 6;
12134 Master_V7 at 0 range 7 .. 7;
12135 Slave_Control at 1 range 0 .. 0;
12136 Slave_V1 at 1 range 1 .. 1;
12137 Slave_V2 at 1 range 2 .. 2;
12138 Slave_V3 at 1 range 3 .. 3;
12139 Slave_V4 at 1 range 4 .. 4;
12140 Slave_V5 at 1 range 5 .. 5;
12141 Slave_V6 at 1 range 6 .. 6;
12142 Slave_V7 at 1 range 7 .. 7;
12147 Now if we move this to a little endian machine, then the bit ordering within
12148 the byte is backwards, so we have to rewrite the record rep clause as:
12150 @smallexample @c ada
12151 for Data use record
12152 Master_Control at 0 range 7 .. 7;
12153 Master_V1 at 0 range 6 .. 6;
12154 Master_V2 at 0 range 5 .. 5;
12155 Master_V3 at 0 range 4 .. 4;
12156 Master_V4 at 0 range 3 .. 3;
12157 Master_V5 at 0 range 2 .. 2;
12158 Master_V6 at 0 range 1 .. 1;
12159 Master_V7 at 0 range 0 .. 0;
12160 Slave_Control at 1 range 7 .. 7;
12161 Slave_V1 at 1 range 6 .. 6;
12162 Slave_V2 at 1 range 5 .. 5;
12163 Slave_V3 at 1 range 4 .. 4;
12164 Slave_V4 at 1 range 3 .. 3;
12165 Slave_V5 at 1 range 2 .. 2;
12166 Slave_V6 at 1 range 1 .. 1;
12167 Slave_V7 at 1 range 0 .. 0;
12172 It is a nuisance to have to rewrite the clause, especially if
12173 the code has to be maintained on both machines. However,
12174 this is a case that we can handle with the
12175 @code{Bit_Order} attribute if it is implemented.
12176 Note that the implementation is not required on byte addressed
12177 machines, but it is indeed implemented in GNAT.
12178 This means that we can simply use the
12179 first record clause, together with the declaration
12181 @smallexample @c ada
12182 for Data'Bit_Order use High_Order_First;
12186 and the effect is what is desired, namely the layout is exactly the same,
12187 independent of whether the code is compiled on a big-endian or little-endian
12190 The important point to understand is that byte ordering is not affected.
12191 A @code{Bit_Order} attribute definition never affects which byte a field
12192 ends up in, only where it ends up in that byte.
12193 To make this clear, let us rewrite the record rep clause of the previous
12196 @smallexample @c ada
12197 for Data'Bit_Order use High_Order_First;
12198 for Data use record
12199 Master_Control at 0 range 0 .. 0;
12200 Master_V1 at 0 range 1 .. 1;
12201 Master_V2 at 0 range 2 .. 2;
12202 Master_V3 at 0 range 3 .. 3;
12203 Master_V4 at 0 range 4 .. 4;
12204 Master_V5 at 0 range 5 .. 5;
12205 Master_V6 at 0 range 6 .. 6;
12206 Master_V7 at 0 range 7 .. 7;
12207 Slave_Control at 0 range 8 .. 8;
12208 Slave_V1 at 0 range 9 .. 9;
12209 Slave_V2 at 0 range 10 .. 10;
12210 Slave_V3 at 0 range 11 .. 11;
12211 Slave_V4 at 0 range 12 .. 12;
12212 Slave_V5 at 0 range 13 .. 13;
12213 Slave_V6 at 0 range 14 .. 14;
12214 Slave_V7 at 0 range 15 .. 15;
12219 This is exactly equivalent to saying (a repeat of the first example):
12221 @smallexample @c ada
12222 for Data'Bit_Order use High_Order_First;
12223 for Data use record
12224 Master_Control at 0 range 0 .. 0;
12225 Master_V1 at 0 range 1 .. 1;
12226 Master_V2 at 0 range 2 .. 2;
12227 Master_V3 at 0 range 3 .. 3;
12228 Master_V4 at 0 range 4 .. 4;
12229 Master_V5 at 0 range 5 .. 5;
12230 Master_V6 at 0 range 6 .. 6;
12231 Master_V7 at 0 range 7 .. 7;
12232 Slave_Control at 1 range 0 .. 0;
12233 Slave_V1 at 1 range 1 .. 1;
12234 Slave_V2 at 1 range 2 .. 2;
12235 Slave_V3 at 1 range 3 .. 3;
12236 Slave_V4 at 1 range 4 .. 4;
12237 Slave_V5 at 1 range 5 .. 5;
12238 Slave_V6 at 1 range 6 .. 6;
12239 Slave_V7 at 1 range 7 .. 7;
12244 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
12245 field. The storage place attributes are obtained by normalizing the
12246 values given so that the @code{First_Bit} value is less than 8. After
12247 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
12248 we specified in the other case.
12250 Now one might expect that the @code{Bit_Order} attribute might affect
12251 bit numbering within the entire record component (two bytes in this
12252 case, thus affecting which byte fields end up in), but that is not
12253 the way this feature is defined, it only affects numbering of bits,
12254 not which byte they end up in.
12256 Consequently it never makes sense to specify a starting bit number
12257 greater than 7 (for a byte addressable field) if an attribute
12258 definition for @code{Bit_Order} has been given, and indeed it
12259 may be actively confusing to specify such a value, so the compiler
12260 generates a warning for such usage.
12262 If you do need to control byte ordering then appropriate conditional
12263 values must be used. If in our example, the slave byte came first on
12264 some machines we might write:
12266 @smallexample @c ada
12267 Master_Byte_First constant Boolean := @dots{};
12269 Master_Byte : constant Natural :=
12270 1 - Boolean'Pos (Master_Byte_First);
12271 Slave_Byte : constant Natural :=
12272 Boolean'Pos (Master_Byte_First);
12274 for Data'Bit_Order use High_Order_First;
12275 for Data use record
12276 Master_Control at Master_Byte range 0 .. 0;
12277 Master_V1 at Master_Byte range 1 .. 1;
12278 Master_V2 at Master_Byte range 2 .. 2;
12279 Master_V3 at Master_Byte range 3 .. 3;
12280 Master_V4 at Master_Byte range 4 .. 4;
12281 Master_V5 at Master_Byte range 5 .. 5;
12282 Master_V6 at Master_Byte range 6 .. 6;
12283 Master_V7 at Master_Byte range 7 .. 7;
12284 Slave_Control at Slave_Byte range 0 .. 0;
12285 Slave_V1 at Slave_Byte range 1 .. 1;
12286 Slave_V2 at Slave_Byte range 2 .. 2;
12287 Slave_V3 at Slave_Byte range 3 .. 3;
12288 Slave_V4 at Slave_Byte range 4 .. 4;
12289 Slave_V5 at Slave_Byte range 5 .. 5;
12290 Slave_V6 at Slave_Byte range 6 .. 6;
12291 Slave_V7 at Slave_Byte range 7 .. 7;
12296 Now to switch between machines, all that is necessary is
12297 to set the boolean constant @code{Master_Byte_First} in
12298 an appropriate manner.
12300 @node Pragma Pack for Arrays
12301 @section Pragma Pack for Arrays
12302 @cindex Pragma Pack (for arrays)
12305 Pragma @code{Pack} applied to an array has no effect unless the component type
12306 is packable. For a component type to be packable, it must be one of the
12313 Any type whose size is specified with a size clause
12315 Any packed array type with a static size
12317 Any record type padded because of its default alignment
12321 For all these cases, if the component subtype size is in the range
12322 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
12323 component size were specified giving the component subtype size.
12324 For example if we have:
12326 @smallexample @c ada
12327 type r is range 0 .. 17;
12329 type ar is array (1 .. 8) of r;
12334 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
12335 and the size of the array @code{ar} will be exactly 40 bits.
12337 Note that in some cases this rather fierce approach to packing can produce
12338 unexpected effects. For example, in Ada 95 and Ada 2005,
12339 subtype @code{Natural} typically has a size of 31, meaning that if you
12340 pack an array of @code{Natural}, you get 31-bit
12341 close packing, which saves a few bits, but results in far less efficient
12342 access. Since many other Ada compilers will ignore such a packing request,
12343 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
12344 might not be what is intended. You can easily remove this warning by
12345 using an explicit @code{Component_Size} setting instead, which never generates
12346 a warning, since the intention of the programmer is clear in this case.
12348 GNAT treats packed arrays in one of two ways. If the size of the array is
12349 known at compile time and is less than 64 bits, then internally the array
12350 is represented as a single modular type, of exactly the appropriate number
12351 of bits. If the length is greater than 63 bits, or is not known at compile
12352 time, then the packed array is represented as an array of bytes, and the
12353 length is always a multiple of 8 bits.
12355 Note that to represent a packed array as a modular type, the alignment must
12356 be suitable for the modular type involved. For example, on typical machines
12357 a 32-bit packed array will be represented by a 32-bit modular integer with
12358 an alignment of four bytes. If you explicitly override the default alignment
12359 with an alignment clause that is too small, the modular representation
12360 cannot be used. For example, consider the following set of declarations:
12362 @smallexample @c ada
12363 type R is range 1 .. 3;
12364 type S is array (1 .. 31) of R;
12365 for S'Component_Size use 2;
12367 for S'Alignment use 1;
12371 If the alignment clause were not present, then a 62-bit modular
12372 representation would be chosen (typically with an alignment of 4 or 8
12373 bytes depending on the target). But the default alignment is overridden
12374 with the explicit alignment clause. This means that the modular
12375 representation cannot be used, and instead the array of bytes
12376 representation must be used, meaning that the length must be a multiple
12377 of 8. Thus the above set of declarations will result in a diagnostic
12378 rejecting the size clause and noting that the minimum size allowed is 64.
12380 @cindex Pragma Pack (for type Natural)
12381 @cindex Pragma Pack warning
12383 One special case that is worth noting occurs when the base type of the
12384 component size is 8/16/32 and the subtype is one bit less. Notably this
12385 occurs with subtype @code{Natural}. Consider:
12387 @smallexample @c ada
12388 type Arr is array (1 .. 32) of Natural;
12393 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
12394 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
12395 Ada 83 compilers did not attempt 31 bit packing.
12397 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
12398 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
12399 substantial unintended performance penalty when porting legacy Ada 83 code.
12400 To help prevent this, GNAT generates a warning in such cases. If you really
12401 want 31 bit packing in a case like this, you can set the component size
12404 @smallexample @c ada
12405 type Arr is array (1 .. 32) of Natural;
12406 for Arr'Component_Size use 31;
12410 Here 31-bit packing is achieved as required, and no warning is generated,
12411 since in this case the programmer intention is clear.
12413 @node Pragma Pack for Records
12414 @section Pragma Pack for Records
12415 @cindex Pragma Pack (for records)
12418 Pragma @code{Pack} applied to a record will pack the components to reduce
12419 wasted space from alignment gaps and by reducing the amount of space
12420 taken by components. We distinguish between @emph{packable} components and
12421 @emph{non-packable} components.
12422 Components of the following types are considered packable:
12425 All primitive types are packable.
12428 Small packed arrays, whose size does not exceed 64 bits, and where the
12429 size is statically known at compile time, are represented internally
12430 as modular integers, and so they are also packable.
12435 All packable components occupy the exact number of bits corresponding to
12436 their @code{Size} value, and are packed with no padding bits, i.e.@: they
12437 can start on an arbitrary bit boundary.
12439 All other types are non-packable, they occupy an integral number of
12441 are placed at a boundary corresponding to their alignment requirements.
12443 For example, consider the record
12445 @smallexample @c ada
12446 type Rb1 is array (1 .. 13) of Boolean;
12449 type Rb2 is array (1 .. 65) of Boolean;
12464 The representation for the record x2 is as follows:
12466 @smallexample @c ada
12467 for x2'Size use 224;
12469 l1 at 0 range 0 .. 0;
12470 l2 at 0 range 1 .. 64;
12471 l3 at 12 range 0 .. 31;
12472 l4 at 16 range 0 .. 0;
12473 l5 at 16 range 1 .. 13;
12474 l6 at 18 range 0 .. 71;
12479 Studying this example, we see that the packable fields @code{l1}
12481 of length equal to their sizes, and placed at specific bit boundaries (and
12482 not byte boundaries) to
12483 eliminate padding. But @code{l3} is of a non-packable float type, so
12484 it is on the next appropriate alignment boundary.
12486 The next two fields are fully packable, so @code{l4} and @code{l5} are
12487 minimally packed with no gaps. However, type @code{Rb2} is a packed
12488 array that is longer than 64 bits, so it is itself non-packable. Thus
12489 the @code{l6} field is aligned to the next byte boundary, and takes an
12490 integral number of bytes, i.e.@: 72 bits.
12492 @node Record Representation Clauses
12493 @section Record Representation Clauses
12494 @cindex Record Representation Clause
12497 Record representation clauses may be given for all record types, including
12498 types obtained by record extension. Component clauses are allowed for any
12499 static component. The restrictions on component clauses depend on the type
12502 @cindex Component Clause
12503 For all components of an elementary type, the only restriction on component
12504 clauses is that the size must be at least the 'Size value of the type
12505 (actually the Value_Size). There are no restrictions due to alignment,
12506 and such components may freely cross storage boundaries.
12508 Packed arrays with a size up to and including 64 bits are represented
12509 internally using a modular type with the appropriate number of bits, and
12510 thus the same lack of restriction applies. For example, if you declare:
12512 @smallexample @c ada
12513 type R is array (1 .. 49) of Boolean;
12519 then a component clause for a component of type R may start on any
12520 specified bit boundary, and may specify a value of 49 bits or greater.
12522 For packed bit arrays that are longer than 64 bits, there are two
12523 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
12524 including the important case of single bits or boolean values, then
12525 there are no limitations on placement of such components, and they
12526 may start and end at arbitrary bit boundaries.
12528 If the component size is not a power of 2 (e.g.@: 3 or 5), then
12529 an array of this type longer than 64 bits must always be placed on
12530 on a storage unit (byte) boundary and occupy an integral number
12531 of storage units (bytes). Any component clause that does not
12532 meet this requirement will be rejected.
12534 Any aliased component, or component of an aliased type, must
12535 have its normal alignment and size. A component clause that
12536 does not meet this requirement will be rejected.
12538 The tag field of a tagged type always occupies an address sized field at
12539 the start of the record. No component clause may attempt to overlay this
12540 tag. When a tagged type appears as a component, the tag field must have
12543 In the case of a record extension T1, of a type T, no component clause applied
12544 to the type T1 can specify a storage location that would overlap the first
12545 T'Size bytes of the record.
12547 For all other component types, including non-bit-packed arrays,
12548 the component can be placed at an arbitrary bit boundary,
12549 so for example, the following is permitted:
12551 @smallexample @c ada
12552 type R is array (1 .. 10) of Boolean;
12561 G at 0 range 0 .. 0;
12562 H at 0 range 1 .. 1;
12563 L at 0 range 2 .. 81;
12564 R at 0 range 82 .. 161;
12569 Note: the above rules apply to recent releases of GNAT 5.
12570 In GNAT 3, there are more severe restrictions on larger components.
12571 For non-primitive types, including packed arrays with a size greater than
12572 64 bits, component clauses must respect the alignment requirement of the
12573 type, in particular, always starting on a byte boundary, and the length
12574 must be a multiple of the storage unit.
12576 @node Enumeration Clauses
12577 @section Enumeration Clauses
12579 The only restriction on enumeration clauses is that the range of values
12580 must be representable. For the signed case, if one or more of the
12581 representation values are negative, all values must be in the range:
12583 @smallexample @c ada
12584 System.Min_Int .. System.Max_Int
12588 For the unsigned case, where all values are nonnegative, the values must
12591 @smallexample @c ada
12592 0 .. System.Max_Binary_Modulus;
12596 A @emph{confirming} representation clause is one in which the values range
12597 from 0 in sequence, i.e.@: a clause that confirms the default representation
12598 for an enumeration type.
12599 Such a confirming representation
12600 is permitted by these rules, and is specially recognized by the compiler so
12601 that no extra overhead results from the use of such a clause.
12603 If an array has an index type which is an enumeration type to which an
12604 enumeration clause has been applied, then the array is stored in a compact
12605 manner. Consider the declarations:
12607 @smallexample @c ada
12608 type r is (A, B, C);
12609 for r use (A => 1, B => 5, C => 10);
12610 type t is array (r) of Character;
12614 The array type t corresponds to a vector with exactly three elements and
12615 has a default size equal to @code{3*Character'Size}. This ensures efficient
12616 use of space, but means that accesses to elements of the array will incur
12617 the overhead of converting representation values to the corresponding
12618 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
12620 @node Address Clauses
12621 @section Address Clauses
12622 @cindex Address Clause
12624 The reference manual allows a general restriction on representation clauses,
12625 as found in RM 13.1(22):
12628 An implementation need not support representation
12629 items containing nonstatic expressions, except that
12630 an implementation should support a representation item
12631 for a given entity if each nonstatic expression in the
12632 representation item is a name that statically denotes
12633 a constant declared before the entity.
12637 In practice this is applicable only to address clauses, since this is the
12638 only case in which a non-static expression is permitted by the syntax. As
12639 the AARM notes in sections 13.1 (22.a-22.h):
12642 22.a Reason: This is to avoid the following sort of thing:
12644 22.b X : Integer := F(@dots{});
12645 Y : Address := G(@dots{});
12646 for X'Address use Y;
12648 22.c In the above, we have to evaluate the
12649 initialization expression for X before we
12650 know where to put the result. This seems
12651 like an unreasonable implementation burden.
12653 22.d The above code should instead be written
12656 22.e Y : constant Address := G(@dots{});
12657 X : Integer := F(@dots{});
12658 for X'Address use Y;
12660 22.f This allows the expression ``Y'' to be safely
12661 evaluated before X is created.
12663 22.g The constant could be a formal parameter of mode in.
12665 22.h An implementation can support other nonstatic
12666 expressions if it wants to. Expressions of type
12667 Address are hardly ever static, but their value
12668 might be known at compile time anyway in many
12673 GNAT does indeed permit many additional cases of non-static expressions. In
12674 particular, if the type involved is elementary there are no restrictions
12675 (since in this case, holding a temporary copy of the initialization value,
12676 if one is present, is inexpensive). In addition, if there is no implicit or
12677 explicit initialization, then there are no restrictions. GNAT will reject
12678 only the case where all three of these conditions hold:
12683 The type of the item is non-elementary (e.g.@: a record or array).
12686 There is explicit or implicit initialization required for the object.
12687 Note that access values are always implicitly initialized.
12690 The address value is non-static. Here GNAT is more permissive than the
12691 RM, and allows the address value to be the address of a previously declared
12692 stand-alone variable, as long as it does not itself have an address clause.
12694 @smallexample @c ada
12695 Anchor : Some_Initialized_Type;
12696 Overlay : Some_Initialized_Type;
12697 for Overlay'Address use Anchor'Address;
12701 However, the prefix of the address clause cannot be an array component, or
12702 a component of a discriminated record.
12707 As noted above in section 22.h, address values are typically non-static. In
12708 particular the To_Address function, even if applied to a literal value, is
12709 a non-static function call. To avoid this minor annoyance, GNAT provides
12710 the implementation defined attribute 'To_Address. The following two
12711 expressions have identical values:
12715 @smallexample @c ada
12716 To_Address (16#1234_0000#)
12717 System'To_Address (16#1234_0000#);
12721 except that the second form is considered to be a static expression, and
12722 thus when used as an address clause value is always permitted.
12725 Additionally, GNAT treats as static an address clause that is an
12726 unchecked_conversion of a static integer value. This simplifies the porting
12727 of legacy code, and provides a portable equivalent to the GNAT attribute
12730 Another issue with address clauses is the interaction with alignment
12731 requirements. When an address clause is given for an object, the address
12732 value must be consistent with the alignment of the object (which is usually
12733 the same as the alignment of the type of the object). If an address clause
12734 is given that specifies an inappropriately aligned address value, then the
12735 program execution is erroneous.
12737 Since this source of erroneous behavior can have unfortunate effects, GNAT
12738 checks (at compile time if possible, generating a warning, or at execution
12739 time with a run-time check) that the alignment is appropriate. If the
12740 run-time check fails, then @code{Program_Error} is raised. This run-time
12741 check is suppressed if range checks are suppressed, or if the special GNAT
12742 check Alignment_Check is suppressed, or if
12743 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
12745 Finally, GNAT does not permit overlaying of objects of controlled types or
12746 composite types containing a controlled component. In most cases, the compiler
12747 can detect an attempt at such overlays and will generate a warning at compile
12748 time and a Program_Error exception at run time.
12751 An address clause cannot be given for an exported object. More
12752 understandably the real restriction is that objects with an address
12753 clause cannot be exported. This is because such variables are not
12754 defined by the Ada program, so there is no external object to export.
12757 It is permissible to give an address clause and a pragma Import for the
12758 same object. In this case, the variable is not really defined by the
12759 Ada program, so there is no external symbol to be linked. The link name
12760 and the external name are ignored in this case. The reason that we allow this
12761 combination is that it provides a useful idiom to avoid unwanted
12762 initializations on objects with address clauses.
12764 When an address clause is given for an object that has implicit or
12765 explicit initialization, then by default initialization takes place. This
12766 means that the effect of the object declaration is to overwrite the
12767 memory at the specified address. This is almost always not what the
12768 programmer wants, so GNAT will output a warning:
12778 for Ext'Address use System'To_Address (16#1234_1234#);
12780 >>> warning: implicit initialization of "Ext" may
12781 modify overlaid storage
12782 >>> warning: use pragma Import for "Ext" to suppress
12783 initialization (RM B(24))
12789 As indicated by the warning message, the solution is to use a (dummy) pragma
12790 Import to suppress this initialization. The pragma tell the compiler that the
12791 object is declared and initialized elsewhere. The following package compiles
12792 without warnings (and the initialization is suppressed):
12794 @smallexample @c ada
12802 for Ext'Address use System'To_Address (16#1234_1234#);
12803 pragma Import (Ada, Ext);
12808 A final issue with address clauses involves their use for overlaying
12809 variables, as in the following example:
12810 @cindex Overlaying of objects
12812 @smallexample @c ada
12815 for B'Address use A'Address;
12819 or alternatively, using the form recommended by the RM:
12821 @smallexample @c ada
12823 Addr : constant Address := A'Address;
12825 for B'Address use Addr;
12829 In both of these cases, @code{A}
12830 and @code{B} become aliased to one another via the
12831 address clause. This use of address clauses to overlay
12832 variables, achieving an effect similar to unchecked
12833 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
12834 the effect is implementation defined. Furthermore, the
12835 Ada RM specifically recommends that in a situation
12836 like this, @code{B} should be subject to the following
12837 implementation advice (RM 13.3(19)):
12840 19 If the Address of an object is specified, or it is imported
12841 or exported, then the implementation should not perform
12842 optimizations based on assumptions of no aliases.
12846 GNAT follows this recommendation, and goes further by also applying
12847 this recommendation to the overlaid variable (@code{A}
12848 in the above example) in this case. This means that the overlay
12849 works "as expected", in that a modification to one of the variables
12850 will affect the value of the other.
12852 @node Effect of Convention on Representation
12853 @section Effect of Convention on Representation
12854 @cindex Convention, effect on representation
12857 Normally the specification of a foreign language convention for a type or
12858 an object has no effect on the chosen representation. In particular, the
12859 representation chosen for data in GNAT generally meets the standard system
12860 conventions, and for example records are laid out in a manner that is
12861 consistent with C@. This means that specifying convention C (for example)
12864 There are four exceptions to this general rule:
12868 @item Convention Fortran and array subtypes
12869 If pragma Convention Fortran is specified for an array subtype, then in
12870 accordance with the implementation advice in section 3.6.2(11) of the
12871 Ada Reference Manual, the array will be stored in a Fortran-compatible
12872 column-major manner, instead of the normal default row-major order.
12874 @item Convention C and enumeration types
12875 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
12876 to accommodate all values of the type. For example, for the enumeration
12879 @smallexample @c ada
12880 type Color is (Red, Green, Blue);
12884 8 bits is sufficient to store all values of the type, so by default, objects
12885 of type @code{Color} will be represented using 8 bits. However, normal C
12886 convention is to use 32 bits for all enum values in C, since enum values
12887 are essentially of type int. If pragma @code{Convention C} is specified for an
12888 Ada enumeration type, then the size is modified as necessary (usually to
12889 32 bits) to be consistent with the C convention for enum values.
12891 Note that this treatment applies only to types. If Convention C is given for
12892 an enumeration object, where the enumeration type is not Convention C, then
12893 Object_Size bits are allocated. For example, for a normal enumeration type,
12894 with less than 256 elements, only 8 bits will be allocated for the object.
12895 Since this may be a surprise in terms of what C expects, GNAT will issue a
12896 warning in this situation. The warning can be suppressed by giving an explicit
12897 size clause specifying the desired size.
12899 @item Convention C/Fortran and Boolean types
12900 In C, the usual convention for boolean values, that is values used for
12901 conditions, is that zero represents false, and nonzero values represent
12902 true. In Ada, the normal convention is that two specific values, typically
12903 0/1, are used to represent false/true respectively.
12905 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
12906 value represents true).
12908 To accommodate the Fortran and C conventions, if a pragma Convention specifies
12909 C or Fortran convention for a derived Boolean, as in the following example:
12911 @smallexample @c ada
12912 type C_Switch is new Boolean;
12913 pragma Convention (C, C_Switch);
12917 then the GNAT generated code will treat any nonzero value as true. For truth
12918 values generated by GNAT, the conventional value 1 will be used for True, but
12919 when one of these values is read, any nonzero value is treated as True.
12921 @item Access types on OpenVMS
12922 For 64-bit OpenVMS systems, access types (other than those for unconstrained
12923 arrays) are 64-bits long. An exception to this rule is for the case of
12924 C-convention access types where there is no explicit size clause present (or
12925 inherited for derived types). In this case, GNAT chooses to make these
12926 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
12927 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
12931 @node Determining the Representations chosen by GNAT
12932 @section Determining the Representations chosen by GNAT
12933 @cindex Representation, determination of
12934 @cindex @option{-gnatR} switch
12937 Although the descriptions in this section are intended to be complete, it is
12938 often easier to simply experiment to see what GNAT accepts and what the
12939 effect is on the layout of types and objects.
12941 As required by the Ada RM, if a representation clause is not accepted, then
12942 it must be rejected as illegal by the compiler. However, when a
12943 representation clause or pragma is accepted, there can still be questions
12944 of what the compiler actually does. For example, if a partial record
12945 representation clause specifies the location of some components and not
12946 others, then where are the non-specified components placed? Or if pragma
12947 @code{Pack} is used on a record, then exactly where are the resulting
12948 fields placed? The section on pragma @code{Pack} in this chapter can be
12949 used to answer the second question, but it is often easier to just see
12950 what the compiler does.
12952 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
12953 with this option, then the compiler will output information on the actual
12954 representations chosen, in a format similar to source representation
12955 clauses. For example, if we compile the package:
12957 @smallexample @c ada
12959 type r (x : boolean) is tagged record
12961 when True => S : String (1 .. 100);
12962 when False => null;
12966 type r2 is new r (false) with record
12971 y2 at 16 range 0 .. 31;
12978 type x1 is array (1 .. 10) of x;
12979 for x1'component_size use 11;
12981 type ia is access integer;
12983 type Rb1 is array (1 .. 13) of Boolean;
12986 type Rb2 is array (1 .. 65) of Boolean;
13002 using the switch @option{-gnatR} we obtain the following output:
13005 Representation information for unit q
13006 -------------------------------------
13009 for r'Alignment use 4;
13011 x at 4 range 0 .. 7;
13012 _tag at 0 range 0 .. 31;
13013 s at 5 range 0 .. 799;
13016 for r2'Size use 160;
13017 for r2'Alignment use 4;
13019 x at 4 range 0 .. 7;
13020 _tag at 0 range 0 .. 31;
13021 _parent at 0 range 0 .. 63;
13022 y2 at 16 range 0 .. 31;
13026 for x'Alignment use 1;
13028 y at 0 range 0 .. 7;
13031 for x1'Size use 112;
13032 for x1'Alignment use 1;
13033 for x1'Component_Size use 11;
13035 for rb1'Size use 13;
13036 for rb1'Alignment use 2;
13037 for rb1'Component_Size use 1;
13039 for rb2'Size use 72;
13040 for rb2'Alignment use 1;
13041 for rb2'Component_Size use 1;
13043 for x2'Size use 224;
13044 for x2'Alignment use 4;
13046 l1 at 0 range 0 .. 0;
13047 l2 at 0 range 1 .. 64;
13048 l3 at 12 range 0 .. 31;
13049 l4 at 16 range 0 .. 0;
13050 l5 at 16 range 1 .. 13;
13051 l6 at 18 range 0 .. 71;
13056 The Size values are actually the Object_Size, i.e.@: the default size that
13057 will be allocated for objects of the type.
13058 The ?? size for type r indicates that we have a variant record, and the
13059 actual size of objects will depend on the discriminant value.
13061 The Alignment values show the actual alignment chosen by the compiler
13062 for each record or array type.
13064 The record representation clause for type r shows where all fields
13065 are placed, including the compiler generated tag field (whose location
13066 cannot be controlled by the programmer).
13068 The record representation clause for the type extension r2 shows all the
13069 fields present, including the parent field, which is a copy of the fields
13070 of the parent type of r2, i.e.@: r1.
13072 The component size and size clauses for types rb1 and rb2 show
13073 the exact effect of pragma @code{Pack} on these arrays, and the record
13074 representation clause for type x2 shows how pragma @code{Pack} affects
13077 In some cases, it may be useful to cut and paste the representation clauses
13078 generated by the compiler into the original source to fix and guarantee
13079 the actual representation to be used.
13081 @node Standard Library Routines
13082 @chapter Standard Library Routines
13085 The Ada Reference Manual contains in Annex A a full description of an
13086 extensive set of standard library routines that can be used in any Ada
13087 program, and which must be provided by all Ada compilers. They are
13088 analogous to the standard C library used by C programs.
13090 GNAT implements all of the facilities described in annex A, and for most
13091 purposes the description in the Ada Reference Manual, or appropriate Ada
13092 text book, will be sufficient for making use of these facilities.
13094 In the case of the input-output facilities,
13095 @xref{The Implementation of Standard I/O},
13096 gives details on exactly how GNAT interfaces to the
13097 file system. For the remaining packages, the Ada Reference Manual
13098 should be sufficient. The following is a list of the packages included,
13099 together with a brief description of the functionality that is provided.
13101 For completeness, references are included to other predefined library
13102 routines defined in other sections of the Ada Reference Manual (these are
13103 cross-indexed from Annex A).
13107 This is a parent package for all the standard library packages. It is
13108 usually included implicitly in your program, and itself contains no
13109 useful data or routines.
13111 @item Ada.Calendar (9.6)
13112 @code{Calendar} provides time of day access, and routines for
13113 manipulating times and durations.
13115 @item Ada.Characters (A.3.1)
13116 This is a dummy parent package that contains no useful entities
13118 @item Ada.Characters.Handling (A.3.2)
13119 This package provides some basic character handling capabilities,
13120 including classification functions for classes of characters (e.g.@: test
13121 for letters, or digits).
13123 @item Ada.Characters.Latin_1 (A.3.3)
13124 This package includes a complete set of definitions of the characters
13125 that appear in type CHARACTER@. It is useful for writing programs that
13126 will run in international environments. For example, if you want an
13127 upper case E with an acute accent in a string, it is often better to use
13128 the definition of @code{UC_E_Acute} in this package. Then your program
13129 will print in an understandable manner even if your environment does not
13130 support these extended characters.
13132 @item Ada.Command_Line (A.15)
13133 This package provides access to the command line parameters and the name
13134 of the current program (analogous to the use of @code{argc} and @code{argv}
13135 in C), and also allows the exit status for the program to be set in a
13136 system-independent manner.
13138 @item Ada.Decimal (F.2)
13139 This package provides constants describing the range of decimal numbers
13140 implemented, and also a decimal divide routine (analogous to the COBOL
13141 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
13143 @item Ada.Direct_IO (A.8.4)
13144 This package provides input-output using a model of a set of records of
13145 fixed-length, containing an arbitrary definite Ada type, indexed by an
13146 integer record number.
13148 @item Ada.Dynamic_Priorities (D.5)
13149 This package allows the priorities of a task to be adjusted dynamically
13150 as the task is running.
13152 @item Ada.Exceptions (11.4.1)
13153 This package provides additional information on exceptions, and also
13154 contains facilities for treating exceptions as data objects, and raising
13155 exceptions with associated messages.
13157 @item Ada.Finalization (7.6)
13158 This package contains the declarations and subprograms to support the
13159 use of controlled types, providing for automatic initialization and
13160 finalization (analogous to the constructors and destructors of C++)
13162 @item Ada.Interrupts (C.3.2)
13163 This package provides facilities for interfacing to interrupts, which
13164 includes the set of signals or conditions that can be raised and
13165 recognized as interrupts.
13167 @item Ada.Interrupts.Names (C.3.2)
13168 This package provides the set of interrupt names (actually signal
13169 or condition names) that can be handled by GNAT@.
13171 @item Ada.IO_Exceptions (A.13)
13172 This package defines the set of exceptions that can be raised by use of
13173 the standard IO packages.
13176 This package contains some standard constants and exceptions used
13177 throughout the numerics packages. Note that the constants pi and e are
13178 defined here, and it is better to use these definitions than rolling
13181 @item Ada.Numerics.Complex_Elementary_Functions
13182 Provides the implementation of standard elementary functions (such as
13183 log and trigonometric functions) operating on complex numbers using the
13184 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
13185 created by the package @code{Numerics.Complex_Types}.
13187 @item Ada.Numerics.Complex_Types
13188 This is a predefined instantiation of
13189 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
13190 build the type @code{Complex} and @code{Imaginary}.
13192 @item Ada.Numerics.Discrete_Random
13193 This generic package provides a random number generator suitable for generating
13194 uniformly distributed values of a specified discrete subtype.
13196 @item Ada.Numerics.Float_Random
13197 This package provides a random number generator suitable for generating
13198 uniformly distributed floating point values in the unit interval.
13200 @item Ada.Numerics.Generic_Complex_Elementary_Functions
13201 This is a generic version of the package that provides the
13202 implementation of standard elementary functions (such as log and
13203 trigonometric functions) for an arbitrary complex type.
13205 The following predefined instantiations of this package are provided:
13209 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
13211 @code{Ada.Numerics.Complex_Elementary_Functions}
13213 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
13216 @item Ada.Numerics.Generic_Complex_Types
13217 This is a generic package that allows the creation of complex types,
13218 with associated complex arithmetic operations.
13220 The following predefined instantiations of this package exist
13223 @code{Ada.Numerics.Short_Complex_Complex_Types}
13225 @code{Ada.Numerics.Complex_Complex_Types}
13227 @code{Ada.Numerics.Long_Complex_Complex_Types}
13230 @item Ada.Numerics.Generic_Elementary_Functions
13231 This is a generic package that provides the implementation of standard
13232 elementary functions (such as log an trigonometric functions) for an
13233 arbitrary float type.
13235 The following predefined instantiations of this package exist
13239 @code{Ada.Numerics.Short_Elementary_Functions}
13241 @code{Ada.Numerics.Elementary_Functions}
13243 @code{Ada.Numerics.Long_Elementary_Functions}
13246 @item Ada.Real_Time (D.8)
13247 This package provides facilities similar to those of @code{Calendar}, but
13248 operating with a finer clock suitable for real time control. Note that
13249 annex D requires that there be no backward clock jumps, and GNAT generally
13250 guarantees this behavior, but of course if the external clock on which
13251 the GNAT runtime depends is deliberately reset by some external event,
13252 then such a backward jump may occur.
13254 @item Ada.Sequential_IO (A.8.1)
13255 This package provides input-output facilities for sequential files,
13256 which can contain a sequence of values of a single type, which can be
13257 any Ada type, including indefinite (unconstrained) types.
13259 @item Ada.Storage_IO (A.9)
13260 This package provides a facility for mapping arbitrary Ada types to and
13261 from a storage buffer. It is primarily intended for the creation of new
13264 @item Ada.Streams (13.13.1)
13265 This is a generic package that provides the basic support for the
13266 concept of streams as used by the stream attributes (@code{Input},
13267 @code{Output}, @code{Read} and @code{Write}).
13269 @item Ada.Streams.Stream_IO (A.12.1)
13270 This package is a specialization of the type @code{Streams} defined in
13271 package @code{Streams} together with a set of operations providing
13272 Stream_IO capability. The Stream_IO model permits both random and
13273 sequential access to a file which can contain an arbitrary set of values
13274 of one or more Ada types.
13276 @item Ada.Strings (A.4.1)
13277 This package provides some basic constants used by the string handling
13280 @item Ada.Strings.Bounded (A.4.4)
13281 This package provides facilities for handling variable length
13282 strings. The bounded model requires a maximum length. It is thus
13283 somewhat more limited than the unbounded model, but avoids the use of
13284 dynamic allocation or finalization.
13286 @item Ada.Strings.Fixed (A.4.3)
13287 This package provides facilities for handling fixed length strings.
13289 @item Ada.Strings.Maps (A.4.2)
13290 This package provides facilities for handling character mappings and
13291 arbitrarily defined subsets of characters. For instance it is useful in
13292 defining specialized translation tables.
13294 @item Ada.Strings.Maps.Constants (A.4.6)
13295 This package provides a standard set of predefined mappings and
13296 predefined character sets. For example, the standard upper to lower case
13297 conversion table is found in this package. Note that upper to lower case
13298 conversion is non-trivial if you want to take the entire set of
13299 characters, including extended characters like E with an acute accent,
13300 into account. You should use the mappings in this package (rather than
13301 adding 32 yourself) to do case mappings.
13303 @item Ada.Strings.Unbounded (A.4.5)
13304 This package provides facilities for handling variable length
13305 strings. The unbounded model allows arbitrary length strings, but
13306 requires the use of dynamic allocation and finalization.
13308 @item Ada.Strings.Wide_Bounded (A.4.7)
13309 @itemx Ada.Strings.Wide_Fixed (A.4.7)
13310 @itemx Ada.Strings.Wide_Maps (A.4.7)
13311 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
13312 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
13313 These packages provide analogous capabilities to the corresponding
13314 packages without @samp{Wide_} in the name, but operate with the types
13315 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
13316 and @code{Character}.
13318 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
13319 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
13320 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
13321 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
13322 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
13323 These packages provide analogous capabilities to the corresponding
13324 packages without @samp{Wide_} in the name, but operate with the types
13325 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
13326 of @code{String} and @code{Character}.
13328 @item Ada.Synchronous_Task_Control (D.10)
13329 This package provides some standard facilities for controlling task
13330 communication in a synchronous manner.
13333 This package contains definitions for manipulation of the tags of tagged
13336 @item Ada.Task_Attributes
13337 This package provides the capability of associating arbitrary
13338 task-specific data with separate tasks.
13341 This package provides basic text input-output capabilities for
13342 character, string and numeric data. The subpackages of this
13343 package are listed next.
13345 @item Ada.Text_IO.Decimal_IO
13346 Provides input-output facilities for decimal fixed-point types
13348 @item Ada.Text_IO.Enumeration_IO
13349 Provides input-output facilities for enumeration types.
13351 @item Ada.Text_IO.Fixed_IO
13352 Provides input-output facilities for ordinary fixed-point types.
13354 @item Ada.Text_IO.Float_IO
13355 Provides input-output facilities for float types. The following
13356 predefined instantiations of this generic package are available:
13360 @code{Short_Float_Text_IO}
13362 @code{Float_Text_IO}
13364 @code{Long_Float_Text_IO}
13367 @item Ada.Text_IO.Integer_IO
13368 Provides input-output facilities for integer types. The following
13369 predefined instantiations of this generic package are available:
13372 @item Short_Short_Integer
13373 @code{Ada.Short_Short_Integer_Text_IO}
13374 @item Short_Integer
13375 @code{Ada.Short_Integer_Text_IO}
13377 @code{Ada.Integer_Text_IO}
13379 @code{Ada.Long_Integer_Text_IO}
13380 @item Long_Long_Integer
13381 @code{Ada.Long_Long_Integer_Text_IO}
13384 @item Ada.Text_IO.Modular_IO
13385 Provides input-output facilities for modular (unsigned) types
13387 @item Ada.Text_IO.Complex_IO (G.1.3)
13388 This package provides basic text input-output capabilities for complex
13391 @item Ada.Text_IO.Editing (F.3.3)
13392 This package contains routines for edited output, analogous to the use
13393 of pictures in COBOL@. The picture formats used by this package are a
13394 close copy of the facility in COBOL@.
13396 @item Ada.Text_IO.Text_Streams (A.12.2)
13397 This package provides a facility that allows Text_IO files to be treated
13398 as streams, so that the stream attributes can be used for writing
13399 arbitrary data, including binary data, to Text_IO files.
13401 @item Ada.Unchecked_Conversion (13.9)
13402 This generic package allows arbitrary conversion from one type to
13403 another of the same size, providing for breaking the type safety in
13404 special circumstances.
13406 If the types have the same Size (more accurately the same Value_Size),
13407 then the effect is simply to transfer the bits from the source to the
13408 target type without any modification. This usage is well defined, and
13409 for simple types whose representation is typically the same across
13410 all implementations, gives a portable method of performing such
13413 If the types do not have the same size, then the result is implementation
13414 defined, and thus may be non-portable. The following describes how GNAT
13415 handles such unchecked conversion cases.
13417 If the types are of different sizes, and are both discrete types, then
13418 the effect is of a normal type conversion without any constraint checking.
13419 In particular if the result type has a larger size, the result will be
13420 zero or sign extended. If the result type has a smaller size, the result
13421 will be truncated by ignoring high order bits.
13423 If the types are of different sizes, and are not both discrete types,
13424 then the conversion works as though pointers were created to the source
13425 and target, and the pointer value is converted. The effect is that bits
13426 are copied from successive low order storage units and bits of the source
13427 up to the length of the target type.
13429 A warning is issued if the lengths differ, since the effect in this
13430 case is implementation dependent, and the above behavior may not match
13431 that of some other compiler.
13433 A pointer to one type may be converted to a pointer to another type using
13434 unchecked conversion. The only case in which the effect is undefined is
13435 when one or both pointers are pointers to unconstrained array types. In
13436 this case, the bounds information may get incorrectly transferred, and in
13437 particular, GNAT uses double size pointers for such types, and it is
13438 meaningless to convert between such pointer types. GNAT will issue a
13439 warning if the alignment of the target designated type is more strict
13440 than the alignment of the source designated type (since the result may
13441 be unaligned in this case).
13443 A pointer other than a pointer to an unconstrained array type may be
13444 converted to and from System.Address. Such usage is common in Ada 83
13445 programs, but note that Ada.Address_To_Access_Conversions is the
13446 preferred method of performing such conversions in Ada 95 and Ada 2005.
13448 unchecked conversion nor Ada.Address_To_Access_Conversions should be
13449 used in conjunction with pointers to unconstrained objects, since
13450 the bounds information cannot be handled correctly in this case.
13452 @item Ada.Unchecked_Deallocation (13.11.2)
13453 This generic package allows explicit freeing of storage previously
13454 allocated by use of an allocator.
13456 @item Ada.Wide_Text_IO (A.11)
13457 This package is similar to @code{Ada.Text_IO}, except that the external
13458 file supports wide character representations, and the internal types are
13459 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
13460 and @code{String}. It contains generic subpackages listed next.
13462 @item Ada.Wide_Text_IO.Decimal_IO
13463 Provides input-output facilities for decimal fixed-point types
13465 @item Ada.Wide_Text_IO.Enumeration_IO
13466 Provides input-output facilities for enumeration types.
13468 @item Ada.Wide_Text_IO.Fixed_IO
13469 Provides input-output facilities for ordinary fixed-point types.
13471 @item Ada.Wide_Text_IO.Float_IO
13472 Provides input-output facilities for float types. The following
13473 predefined instantiations of this generic package are available:
13477 @code{Short_Float_Wide_Text_IO}
13479 @code{Float_Wide_Text_IO}
13481 @code{Long_Float_Wide_Text_IO}
13484 @item Ada.Wide_Text_IO.Integer_IO
13485 Provides input-output facilities for integer types. The following
13486 predefined instantiations of this generic package are available:
13489 @item Short_Short_Integer
13490 @code{Ada.Short_Short_Integer_Wide_Text_IO}
13491 @item Short_Integer
13492 @code{Ada.Short_Integer_Wide_Text_IO}
13494 @code{Ada.Integer_Wide_Text_IO}
13496 @code{Ada.Long_Integer_Wide_Text_IO}
13497 @item Long_Long_Integer
13498 @code{Ada.Long_Long_Integer_Wide_Text_IO}
13501 @item Ada.Wide_Text_IO.Modular_IO
13502 Provides input-output facilities for modular (unsigned) types
13504 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
13505 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
13506 external file supports wide character representations.
13508 @item Ada.Wide_Text_IO.Editing (F.3.4)
13509 This package is similar to @code{Ada.Text_IO.Editing}, except that the
13510 types are @code{Wide_Character} and @code{Wide_String} instead of
13511 @code{Character} and @code{String}.
13513 @item Ada.Wide_Text_IO.Streams (A.12.3)
13514 This package is similar to @code{Ada.Text_IO.Streams}, except that the
13515 types are @code{Wide_Character} and @code{Wide_String} instead of
13516 @code{Character} and @code{String}.
13518 @item Ada.Wide_Wide_Text_IO (A.11)
13519 This package is similar to @code{Ada.Text_IO}, except that the external
13520 file supports wide character representations, and the internal types are
13521 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
13522 and @code{String}. It contains generic subpackages listed next.
13524 @item Ada.Wide_Wide_Text_IO.Decimal_IO
13525 Provides input-output facilities for decimal fixed-point types
13527 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
13528 Provides input-output facilities for enumeration types.
13530 @item Ada.Wide_Wide_Text_IO.Fixed_IO
13531 Provides input-output facilities for ordinary fixed-point types.
13533 @item Ada.Wide_Wide_Text_IO.Float_IO
13534 Provides input-output facilities for float types. The following
13535 predefined instantiations of this generic package are available:
13539 @code{Short_Float_Wide_Wide_Text_IO}
13541 @code{Float_Wide_Wide_Text_IO}
13543 @code{Long_Float_Wide_Wide_Text_IO}
13546 @item Ada.Wide_Wide_Text_IO.Integer_IO
13547 Provides input-output facilities for integer types. The following
13548 predefined instantiations of this generic package are available:
13551 @item Short_Short_Integer
13552 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
13553 @item Short_Integer
13554 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
13556 @code{Ada.Integer_Wide_Wide_Text_IO}
13558 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
13559 @item Long_Long_Integer
13560 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
13563 @item Ada.Wide_Wide_Text_IO.Modular_IO
13564 Provides input-output facilities for modular (unsigned) types
13566 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
13567 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
13568 external file supports wide character representations.
13570 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
13571 This package is similar to @code{Ada.Text_IO.Editing}, except that the
13572 types are @code{Wide_Character} and @code{Wide_String} instead of
13573 @code{Character} and @code{String}.
13575 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
13576 This package is similar to @code{Ada.Text_IO.Streams}, except that the
13577 types are @code{Wide_Character} and @code{Wide_String} instead of
13578 @code{Character} and @code{String}.
13581 @node The Implementation of Standard I/O
13582 @chapter The Implementation of Standard I/O
13585 GNAT implements all the required input-output facilities described in
13586 A.6 through A.14. These sections of the Ada Reference Manual describe the
13587 required behavior of these packages from the Ada point of view, and if
13588 you are writing a portable Ada program that does not need to know the
13589 exact manner in which Ada maps to the outside world when it comes to
13590 reading or writing external files, then you do not need to read this
13591 chapter. As long as your files are all regular files (not pipes or
13592 devices), and as long as you write and read the files only from Ada, the
13593 description in the Ada Reference Manual is sufficient.
13595 However, if you want to do input-output to pipes or other devices, such
13596 as the keyboard or screen, or if the files you are dealing with are
13597 either generated by some other language, or to be read by some other
13598 language, then you need to know more about the details of how the GNAT
13599 implementation of these input-output facilities behaves.
13601 In this chapter we give a detailed description of exactly how GNAT
13602 interfaces to the file system. As always, the sources of the system are
13603 available to you for answering questions at an even more detailed level,
13604 but for most purposes the information in this chapter will suffice.
13606 Another reason that you may need to know more about how input-output is
13607 implemented arises when you have a program written in mixed languages
13608 where, for example, files are shared between the C and Ada sections of
13609 the same program. GNAT provides some additional facilities, in the form
13610 of additional child library packages, that facilitate this sharing, and
13611 these additional facilities are also described in this chapter.
13614 * Standard I/O Packages::
13620 * Wide_Wide_Text_IO::
13622 * Text Translation::
13624 * Filenames encoding::
13626 * Operations on C Streams::
13627 * Interfacing to C Streams::
13630 @node Standard I/O Packages
13631 @section Standard I/O Packages
13634 The Standard I/O packages described in Annex A for
13640 Ada.Text_IO.Complex_IO
13642 Ada.Text_IO.Text_Streams
13646 Ada.Wide_Text_IO.Complex_IO
13648 Ada.Wide_Text_IO.Text_Streams
13650 Ada.Wide_Wide_Text_IO
13652 Ada.Wide_Wide_Text_IO.Complex_IO
13654 Ada.Wide_Wide_Text_IO.Text_Streams
13664 are implemented using the C
13665 library streams facility; where
13669 All files are opened using @code{fopen}.
13671 All input/output operations use @code{fread}/@code{fwrite}.
13675 There is no internal buffering of any kind at the Ada library level. The only
13676 buffering is that provided at the system level in the implementation of the
13677 library routines that support streams. This facilitates shared use of these
13678 streams by mixed language programs. Note though that system level buffering is
13679 explicitly enabled at elaboration of the standard I/O packages and that can
13680 have an impact on mixed language programs, in particular those using I/O before
13681 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
13682 the Ada elaboration routine before performing any I/O or when impractical,
13683 flush the common I/O streams and in particular Standard_Output before
13684 elaborating the Ada code.
13687 @section FORM Strings
13690 The format of a FORM string in GNAT is:
13693 "keyword=value,keyword=value,@dots{},keyword=value"
13697 where letters may be in upper or lower case, and there are no spaces
13698 between values. The order of the entries is not important. Currently
13699 the following keywords defined.
13702 TEXT_TRANSLATION=[YES|NO]
13704 WCEM=[n|h|u|s|e|8|b]
13705 ENCODING=[UTF8|8BITS]
13709 The use of these parameters is described later in this section. If an
13710 unrecognized keyword appears in a form string, it is silently ignored
13711 and not considered invalid.
13717 Direct_IO can only be instantiated for definite types. This is a
13718 restriction of the Ada language, which means that the records are fixed
13719 length (the length being determined by @code{@var{type}'Size}, rounded
13720 up to the next storage unit boundary if necessary).
13722 The records of a Direct_IO file are simply written to the file in index
13723 sequence, with the first record starting at offset zero, and subsequent
13724 records following. There is no control information of any kind. For
13725 example, if 32-bit integers are being written, each record takes
13726 4-bytes, so the record at index @var{K} starts at offset
13727 (@var{K}@minus{}1)*4.
13729 There is no limit on the size of Direct_IO files, they are expanded as
13730 necessary to accommodate whatever records are written to the file.
13732 @node Sequential_IO
13733 @section Sequential_IO
13736 Sequential_IO may be instantiated with either a definite (constrained)
13737 or indefinite (unconstrained) type.
13739 For the definite type case, the elements written to the file are simply
13740 the memory images of the data values with no control information of any
13741 kind. The resulting file should be read using the same type, no validity
13742 checking is performed on input.
13744 For the indefinite type case, the elements written consist of two
13745 parts. First is the size of the data item, written as the memory image
13746 of a @code{Interfaces.C.size_t} value, followed by the memory image of
13747 the data value. The resulting file can only be read using the same
13748 (unconstrained) type. Normal assignment checks are performed on these
13749 read operations, and if these checks fail, @code{Data_Error} is
13750 raised. In particular, in the array case, the lengths must match, and in
13751 the variant record case, if the variable for a particular read operation
13752 is constrained, the discriminants must match.
13754 Note that it is not possible to use Sequential_IO to write variable
13755 length array items, and then read the data back into different length
13756 arrays. For example, the following will raise @code{Data_Error}:
13758 @smallexample @c ada
13759 package IO is new Sequential_IO (String);
13764 IO.Write (F, "hello!")
13765 IO.Reset (F, Mode=>In_File);
13772 On some Ada implementations, this will print @code{hell}, but the program is
13773 clearly incorrect, since there is only one element in the file, and that
13774 element is the string @code{hello!}.
13776 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
13777 using Stream_IO, and this is the preferred mechanism. In particular, the
13778 above program fragment rewritten to use Stream_IO will work correctly.
13784 Text_IO files consist of a stream of characters containing the following
13785 special control characters:
13788 LF (line feed, 16#0A#) Line Mark
13789 FF (form feed, 16#0C#) Page Mark
13793 A canonical Text_IO file is defined as one in which the following
13794 conditions are met:
13798 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
13802 The character @code{FF} is used only as a page mark, i.e.@: to mark the
13803 end of a page and consequently can appear only immediately following a
13804 @code{LF} (line mark) character.
13807 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
13808 (line mark, page mark). In the former case, the page mark is implicitly
13809 assumed to be present.
13813 A file written using Text_IO will be in canonical form provided that no
13814 explicit @code{LF} or @code{FF} characters are written using @code{Put}
13815 or @code{Put_Line}. There will be no @code{FF} character at the end of
13816 the file unless an explicit @code{New_Page} operation was performed
13817 before closing the file.
13819 A canonical Text_IO file that is a regular file (i.e., not a device or a
13820 pipe) can be read using any of the routines in Text_IO@. The
13821 semantics in this case will be exactly as defined in the Ada Reference
13822 Manual, and all the routines in Text_IO are fully implemented.
13824 A text file that does not meet the requirements for a canonical Text_IO
13825 file has one of the following:
13829 The file contains @code{FF} characters not immediately following a
13830 @code{LF} character.
13833 The file contains @code{LF} or @code{FF} characters written by
13834 @code{Put} or @code{Put_Line}, which are not logically considered to be
13835 line marks or page marks.
13838 The file ends in a character other than @code{LF} or @code{FF},
13839 i.e.@: there is no explicit line mark or page mark at the end of the file.
13843 Text_IO can be used to read such non-standard text files but subprograms
13844 to do with line or page numbers do not have defined meanings. In
13845 particular, a @code{FF} character that does not follow a @code{LF}
13846 character may or may not be treated as a page mark from the point of
13847 view of page and line numbering. Every @code{LF} character is considered
13848 to end a line, and there is an implied @code{LF} character at the end of
13852 * Text_IO Stream Pointer Positioning::
13853 * Text_IO Reading and Writing Non-Regular Files::
13855 * Treating Text_IO Files as Streams::
13856 * Text_IO Extensions::
13857 * Text_IO Facilities for Unbounded Strings::
13860 @node Text_IO Stream Pointer Positioning
13861 @subsection Stream Pointer Positioning
13864 @code{Ada.Text_IO} has a definition of current position for a file that
13865 is being read. No internal buffering occurs in Text_IO, and usually the
13866 physical position in the stream used to implement the file corresponds
13867 to this logical position defined by Text_IO@. There are two exceptions:
13871 After a call to @code{End_Of_Page} that returns @code{True}, the stream
13872 is positioned past the @code{LF} (line mark) that precedes the page
13873 mark. Text_IO maintains an internal flag so that subsequent read
13874 operations properly handle the logical position which is unchanged by
13875 the @code{End_Of_Page} call.
13878 After a call to @code{End_Of_File} that returns @code{True}, if the
13879 Text_IO file was positioned before the line mark at the end of file
13880 before the call, then the logical position is unchanged, but the stream
13881 is physically positioned right at the end of file (past the line mark,
13882 and past a possible page mark following the line mark. Again Text_IO
13883 maintains internal flags so that subsequent read operations properly
13884 handle the logical position.
13888 These discrepancies have no effect on the observable behavior of
13889 Text_IO, but if a single Ada stream is shared between a C program and
13890 Ada program, or shared (using @samp{shared=yes} in the form string)
13891 between two Ada files, then the difference may be observable in some
13894 @node Text_IO Reading and Writing Non-Regular Files
13895 @subsection Reading and Writing Non-Regular Files
13898 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
13899 can be used for reading and writing. Writing is not affected and the
13900 sequence of characters output is identical to the normal file case, but
13901 for reading, the behavior of Text_IO is modified to avoid undesirable
13902 look-ahead as follows:
13904 An input file that is not a regular file is considered to have no page
13905 marks. Any @code{Ascii.FF} characters (the character normally used for a
13906 page mark) appearing in the file are considered to be data
13907 characters. In particular:
13911 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
13912 following a line mark. If a page mark appears, it will be treated as a
13916 This avoids the need to wait for an extra character to be typed or
13917 entered from the pipe to complete one of these operations.
13920 @code{End_Of_Page} always returns @code{False}
13923 @code{End_Of_File} will return @code{False} if there is a page mark at
13924 the end of the file.
13928 Output to non-regular files is the same as for regular files. Page marks
13929 may be written to non-regular files using @code{New_Page}, but as noted
13930 above they will not be treated as page marks on input if the output is
13931 piped to another Ada program.
13933 Another important discrepancy when reading non-regular files is that the end
13934 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
13935 pressing the @key{EOT} key,
13937 is signaled once (i.e.@: the test @code{End_Of_File}
13938 will yield @code{True}, or a read will
13939 raise @code{End_Error}), but then reading can resume
13940 to read data past that end of
13941 file indication, until another end of file indication is entered.
13943 @node Get_Immediate
13944 @subsection Get_Immediate
13945 @cindex Get_Immediate
13948 Get_Immediate returns the next character (including control characters)
13949 from the input file. In particular, Get_Immediate will return LF or FF
13950 characters used as line marks or page marks. Such operations leave the
13951 file positioned past the control character, and it is thus not treated
13952 as having its normal function. This means that page, line and column
13953 counts after this kind of Get_Immediate call are set as though the mark
13954 did not occur. In the case where a Get_Immediate leaves the file
13955 positioned between the line mark and page mark (which is not normally
13956 possible), it is undefined whether the FF character will be treated as a
13959 @node Treating Text_IO Files as Streams
13960 @subsection Treating Text_IO Files as Streams
13961 @cindex Stream files
13964 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
13965 as a stream. Data written to a Text_IO file in this stream mode is
13966 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
13967 16#0C# (@code{FF}), the resulting file may have non-standard
13968 format. Similarly if read operations are used to read from a Text_IO
13969 file treated as a stream, then @code{LF} and @code{FF} characters may be
13970 skipped and the effect is similar to that described above for
13971 @code{Get_Immediate}.
13973 @node Text_IO Extensions
13974 @subsection Text_IO Extensions
13975 @cindex Text_IO extensions
13978 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
13979 to the standard @code{Text_IO} package:
13982 @item function File_Exists (Name : String) return Boolean;
13983 Determines if a file of the given name exists.
13985 @item function Get_Line return String;
13986 Reads a string from the standard input file. The value returned is exactly
13987 the length of the line that was read.
13989 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
13990 Similar, except that the parameter File specifies the file from which
13991 the string is to be read.
13995 @node Text_IO Facilities for Unbounded Strings
13996 @subsection Text_IO Facilities for Unbounded Strings
13997 @cindex Text_IO for unbounded strings
13998 @cindex Unbounded_String, Text_IO operations
14001 The package @code{Ada.Strings.Unbounded.Text_IO}
14002 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
14003 subprograms useful for Text_IO operations on unbounded strings:
14007 @item function Get_Line (File : File_Type) return Unbounded_String;
14008 Reads a line from the specified file
14009 and returns the result as an unbounded string.
14011 @item procedure Put (File : File_Type; U : Unbounded_String);
14012 Writes the value of the given unbounded string to the specified file
14013 Similar to the effect of
14014 @code{Put (To_String (U))} except that an extra copy is avoided.
14016 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
14017 Writes the value of the given unbounded string to the specified file,
14018 followed by a @code{New_Line}.
14019 Similar to the effect of @code{Put_Line (To_String (U))} except
14020 that an extra copy is avoided.
14024 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
14025 and is optional. If the parameter is omitted, then the standard input or
14026 output file is referenced as appropriate.
14028 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
14029 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
14030 @code{Wide_Text_IO} functionality for unbounded wide strings.
14032 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
14033 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
14034 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
14037 @section Wide_Text_IO
14040 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
14041 both input and output files may contain special sequences that represent
14042 wide character values. The encoding scheme for a given file may be
14043 specified using a FORM parameter:
14050 as part of the FORM string (WCEM = wide character encoding method),
14051 where @var{x} is one of the following characters
14057 Upper half encoding
14069 The encoding methods match those that
14070 can be used in a source
14071 program, but there is no requirement that the encoding method used for
14072 the source program be the same as the encoding method used for files,
14073 and different files may use different encoding methods.
14075 The default encoding method for the standard files, and for opened files
14076 for which no WCEM parameter is given in the FORM string matches the
14077 wide character encoding specified for the main program (the default
14078 being brackets encoding if no coding method was specified with -gnatW).
14082 In this encoding, a wide character is represented by a five character
14090 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
14091 characters (using upper case letters) of the wide character code. For
14092 example, ESC A345 is used to represent the wide character with code
14093 16#A345#. This scheme is compatible with use of the full
14094 @code{Wide_Character} set.
14096 @item Upper Half Coding
14097 The wide character with encoding 16#abcd#, where the upper bit is on
14098 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
14099 16#cd#. The second byte may never be a format control character, but is
14100 not required to be in the upper half. This method can be also used for
14101 shift-JIS or EUC where the internal coding matches the external coding.
14103 @item Shift JIS Coding
14104 A wide character is represented by a two character sequence 16#ab# and
14105 16#cd#, with the restrictions described for upper half encoding as
14106 described above. The internal character code is the corresponding JIS
14107 character according to the standard algorithm for Shift-JIS
14108 conversion. Only characters defined in the JIS code set table can be
14109 used with this encoding method.
14112 A wide character is represented by a two character sequence 16#ab# and
14113 16#cd#, with both characters being in the upper half. The internal
14114 character code is the corresponding JIS character according to the EUC
14115 encoding algorithm. Only characters defined in the JIS code set table
14116 can be used with this encoding method.
14119 A wide character is represented using
14120 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14121 10646-1/Am.2. Depending on the character value, the representation
14122 is a one, two, or three byte sequence:
14125 16#0000#-16#007f#: 2#0xxxxxxx#
14126 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
14127 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14131 where the @var{xxx} bits correspond to the left-padded bits of the
14132 16-bit character value. Note that all lower half ASCII characters
14133 are represented as ASCII bytes and all upper half characters and
14134 other wide characters are represented as sequences of upper-half
14135 (The full UTF-8 scheme allows for encoding 31-bit characters as
14136 6-byte sequences, but in this implementation, all UTF-8 sequences
14137 of four or more bytes length will raise a Constraint_Error, as
14138 will all invalid UTF-8 sequences.)
14140 @item Brackets Coding
14141 In this encoding, a wide character is represented by the following eight
14142 character sequence:
14149 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
14150 characters (using uppercase letters) of the wide character code. For
14151 example, @code{["A345"]} is used to represent the wide character with code
14153 This scheme is compatible with use of the full Wide_Character set.
14154 On input, brackets coding can also be used for upper half characters,
14155 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
14156 is only used for wide characters with a code greater than @code{16#FF#}.
14158 Note that brackets coding is not normally used in the context of
14159 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
14160 a portable way of encoding source files. In the context of Wide_Text_IO
14161 or Wide_Wide_Text_IO, it can only be used if the file does not contain
14162 any instance of the left bracket character other than to encode wide
14163 character values using the brackets encoding method. In practice it is
14164 expected that some standard wide character encoding method such
14165 as UTF-8 will be used for text input output.
14167 If brackets notation is used, then any occurrence of a left bracket
14168 in the input file which is not the start of a valid wide character
14169 sequence will cause Constraint_Error to be raised. It is possible to
14170 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
14171 input will interpret this as a left bracket.
14173 However, when a left bracket is output, it will be output as a left bracket
14174 and not as ["5B"]. We make this decision because for normal use of
14175 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
14176 brackets. For example, if we write:
14179 Put_Line ("Start of output [first run]");
14183 we really do not want to have the left bracket in this message clobbered so
14184 that the output reads:
14187 Start of output ["5B"]first run]
14191 In practice brackets encoding is reasonably useful for normal Put_Line use
14192 since we won't get confused between left brackets and wide character
14193 sequences in the output. But for input, or when files are written out
14194 and read back in, it really makes better sense to use one of the standard
14195 encoding methods such as UTF-8.
14200 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
14201 not all wide character
14202 values can be represented. An attempt to output a character that cannot
14203 be represented using the encoding scheme for the file causes
14204 Constraint_Error to be raised. An invalid wide character sequence on
14205 input also causes Constraint_Error to be raised.
14208 * Wide_Text_IO Stream Pointer Positioning::
14209 * Wide_Text_IO Reading and Writing Non-Regular Files::
14212 @node Wide_Text_IO Stream Pointer Positioning
14213 @subsection Stream Pointer Positioning
14216 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14217 of stream pointer positioning (@pxref{Text_IO}). There is one additional
14220 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
14221 normal lower ASCII set (i.e.@: a character in the range:
14223 @smallexample @c ada
14224 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
14228 then although the logical position of the file pointer is unchanged by
14229 the @code{Look_Ahead} call, the stream is physically positioned past the
14230 wide character sequence. Again this is to avoid the need for buffering
14231 or backup, and all @code{Wide_Text_IO} routines check the internal
14232 indication that this situation has occurred so that this is not visible
14233 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
14234 can be observed if the wide text file shares a stream with another file.
14236 @node Wide_Text_IO Reading and Writing Non-Regular Files
14237 @subsection Reading and Writing Non-Regular Files
14240 As in the case of Text_IO, when a non-regular file is read, it is
14241 assumed that the file contains no page marks (any form characters are
14242 treated as data characters), and @code{End_Of_Page} always returns
14243 @code{False}. Similarly, the end of file indication is not sticky, so
14244 it is possible to read beyond an end of file.
14246 @node Wide_Wide_Text_IO
14247 @section Wide_Wide_Text_IO
14250 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
14251 both input and output files may contain special sequences that represent
14252 wide wide character values. The encoding scheme for a given file may be
14253 specified using a FORM parameter:
14260 as part of the FORM string (WCEM = wide character encoding method),
14261 where @var{x} is one of the following characters
14267 Upper half encoding
14279 The encoding methods match those that
14280 can be used in a source
14281 program, but there is no requirement that the encoding method used for
14282 the source program be the same as the encoding method used for files,
14283 and different files may use different encoding methods.
14285 The default encoding method for the standard files, and for opened files
14286 for which no WCEM parameter is given in the FORM string matches the
14287 wide character encoding specified for the main program (the default
14288 being brackets encoding if no coding method was specified with -gnatW).
14293 A wide character is represented using
14294 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14295 10646-1/Am.2. Depending on the character value, the representation
14296 is a one, two, three, or four byte sequence:
14299 16#000000#-16#00007f#: 2#0xxxxxxx#
14300 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
14301 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14302 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
14306 where the @var{xxx} bits correspond to the left-padded bits of the
14307 21-bit character value. Note that all lower half ASCII characters
14308 are represented as ASCII bytes and all upper half characters and
14309 other wide characters are represented as sequences of upper-half
14312 @item Brackets Coding
14313 In this encoding, a wide wide character is represented by the following eight
14314 character sequence if is in wide character range
14320 and by the following ten character sequence if not
14323 [ " a b c d e f " ]
14327 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
14328 are the four or six hexadecimal
14329 characters (using uppercase letters) of the wide wide character code. For
14330 example, @code{["01A345"]} is used to represent the wide wide character
14331 with code @code{16#01A345#}.
14333 This scheme is compatible with use of the full Wide_Wide_Character set.
14334 On input, brackets coding can also be used for upper half characters,
14335 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
14336 is only used for wide characters with a code greater than @code{16#FF#}.
14341 If is also possible to use the other Wide_Character encoding methods,
14342 such as Shift-JIS, but the other schemes cannot support the full range
14343 of wide wide characters.
14344 An attempt to output a character that cannot
14345 be represented using the encoding scheme for the file causes
14346 Constraint_Error to be raised. An invalid wide character sequence on
14347 input also causes Constraint_Error to be raised.
14350 * Wide_Wide_Text_IO Stream Pointer Positioning::
14351 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
14354 @node Wide_Wide_Text_IO Stream Pointer Positioning
14355 @subsection Stream Pointer Positioning
14358 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14359 of stream pointer positioning (@pxref{Text_IO}). There is one additional
14362 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
14363 normal lower ASCII set (i.e.@: a character in the range:
14365 @smallexample @c ada
14366 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
14370 then although the logical position of the file pointer is unchanged by
14371 the @code{Look_Ahead} call, the stream is physically positioned past the
14372 wide character sequence. Again this is to avoid the need for buffering
14373 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
14374 indication that this situation has occurred so that this is not visible
14375 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
14376 can be observed if the wide text file shares a stream with another file.
14378 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
14379 @subsection Reading and Writing Non-Regular Files
14382 As in the case of Text_IO, when a non-regular file is read, it is
14383 assumed that the file contains no page marks (any form characters are
14384 treated as data characters), and @code{End_Of_Page} always returns
14385 @code{False}. Similarly, the end of file indication is not sticky, so
14386 it is possible to read beyond an end of file.
14392 A stream file is a sequence of bytes, where individual elements are
14393 written to the file as described in the Ada Reference Manual. The type
14394 @code{Stream_Element} is simply a byte. There are two ways to read or
14395 write a stream file.
14399 The operations @code{Read} and @code{Write} directly read or write a
14400 sequence of stream elements with no control information.
14403 The stream attributes applied to a stream file transfer data in the
14404 manner described for stream attributes.
14407 @node Text Translation
14408 @section Text Translation
14411 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
14412 passed to Text_IO.Create and Text_IO.Open:
14413 @samp{Text_Translation=@var{Yes}} is the default, which means to
14414 translate LF to/from CR/LF on Windows systems.
14415 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
14416 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
14417 may be used to create Unix-style files on
14418 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
14422 @section Shared Files
14425 Section A.14 of the Ada Reference Manual allows implementations to
14426 provide a wide variety of behavior if an attempt is made to access the
14427 same external file with two or more internal files.
14429 To provide a full range of functionality, while at the same time
14430 minimizing the problems of portability caused by this implementation
14431 dependence, GNAT handles file sharing as follows:
14435 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
14436 to open two or more files with the same full name is considered an error
14437 and is not supported. The exception @code{Use_Error} will be
14438 raised. Note that a file that is not explicitly closed by the program
14439 remains open until the program terminates.
14442 If the form parameter @samp{shared=no} appears in the form string, the
14443 file can be opened or created with its own separate stream identifier,
14444 regardless of whether other files sharing the same external file are
14445 opened. The exact effect depends on how the C stream routines handle
14446 multiple accesses to the same external files using separate streams.
14449 If the form parameter @samp{shared=yes} appears in the form string for
14450 each of two or more files opened using the same full name, the same
14451 stream is shared between these files, and the semantics are as described
14452 in Ada Reference Manual, Section A.14.
14456 When a program that opens multiple files with the same name is ported
14457 from another Ada compiler to GNAT, the effect will be that
14458 @code{Use_Error} is raised.
14460 The documentation of the original compiler and the documentation of the
14461 program should then be examined to determine if file sharing was
14462 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
14463 and @code{Create} calls as required.
14465 When a program is ported from GNAT to some other Ada compiler, no
14466 special attention is required unless the @samp{shared=@var{xxx}} form
14467 parameter is used in the program. In this case, you must examine the
14468 documentation of the new compiler to see if it supports the required
14469 file sharing semantics, and form strings modified appropriately. Of
14470 course it may be the case that the program cannot be ported if the
14471 target compiler does not support the required functionality. The best
14472 approach in writing portable code is to avoid file sharing (and hence
14473 the use of the @samp{shared=@var{xxx}} parameter in the form string)
14476 One common use of file sharing in Ada 83 is the use of instantiations of
14477 Sequential_IO on the same file with different types, to achieve
14478 heterogeneous input-output. Although this approach will work in GNAT if
14479 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
14480 for this purpose (using the stream attributes)
14482 @node Filenames encoding
14483 @section Filenames encoding
14486 An encoding form parameter can be used to specify the filename
14487 encoding @samp{encoding=@var{xxx}}.
14491 If the form parameter @samp{encoding=utf8} appears in the form string, the
14492 filename must be encoded in UTF-8.
14495 If the form parameter @samp{encoding=8bits} appears in the form
14496 string, the filename must be a standard 8bits string.
14499 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
14500 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
14501 variable. And if not set @samp{utf8} is assumed.
14505 The current system Windows ANSI code page.
14510 This encoding form parameter is only supported on the Windows
14511 platform. On the other Operating Systems the run-time is supporting
14515 @section Open Modes
14518 @code{Open} and @code{Create} calls result in a call to @code{fopen}
14519 using the mode shown in the following table:
14522 @center @code{Open} and @code{Create} Call Modes
14524 @b{OPEN } @b{CREATE}
14525 Append_File "r+" "w+"
14527 Out_File (Direct_IO) "r+" "w"
14528 Out_File (all other cases) "w" "w"
14529 Inout_File "r+" "w+"
14533 If text file translation is required, then either @samp{b} or @samp{t}
14534 is added to the mode, depending on the setting of Text. Text file
14535 translation refers to the mapping of CR/LF sequences in an external file
14536 to LF characters internally. This mapping only occurs in DOS and
14537 DOS-like systems, and is not relevant to other systems.
14539 A special case occurs with Stream_IO@. As shown in the above table, the
14540 file is initially opened in @samp{r} or @samp{w} mode for the
14541 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
14542 subsequently requires switching from reading to writing or vice-versa,
14543 then the file is reopened in @samp{r+} mode to permit the required operation.
14545 @node Operations on C Streams
14546 @section Operations on C Streams
14547 The package @code{Interfaces.C_Streams} provides an Ada program with direct
14548 access to the C library functions for operations on C streams:
14550 @smallexample @c adanocomment
14551 package Interfaces.C_Streams is
14552 -- Note: the reason we do not use the types that are in
14553 -- Interfaces.C is that we want to avoid dragging in the
14554 -- code in this unit if possible.
14555 subtype chars is System.Address;
14556 -- Pointer to null-terminated array of characters
14557 subtype FILEs is System.Address;
14558 -- Corresponds to the C type FILE*
14559 subtype voids is System.Address;
14560 -- Corresponds to the C type void*
14561 subtype int is Integer;
14562 subtype long is Long_Integer;
14563 -- Note: the above types are subtypes deliberately, and it
14564 -- is part of this spec that the above correspondences are
14565 -- guaranteed. This means that it is legitimate to, for
14566 -- example, use Integer instead of int. We provide these
14567 -- synonyms for clarity, but in some cases it may be
14568 -- convenient to use the underlying types (for example to
14569 -- avoid an unnecessary dependency of a spec on the spec
14571 type size_t is mod 2 ** Standard'Address_Size;
14572 NULL_Stream : constant FILEs;
14573 -- Value returned (NULL in C) to indicate an
14574 -- fdopen/fopen/tmpfile error
14575 ----------------------------------
14576 -- Constants Defined in stdio.h --
14577 ----------------------------------
14578 EOF : constant int;
14579 -- Used by a number of routines to indicate error or
14581 IOFBF : constant int;
14582 IOLBF : constant int;
14583 IONBF : constant int;
14584 -- Used to indicate buffering mode for setvbuf call
14585 SEEK_CUR : constant int;
14586 SEEK_END : constant int;
14587 SEEK_SET : constant int;
14588 -- Used to indicate origin for fseek call
14589 function stdin return FILEs;
14590 function stdout return FILEs;
14591 function stderr return FILEs;
14592 -- Streams associated with standard files
14593 --------------------------
14594 -- Standard C functions --
14595 --------------------------
14596 -- The functions selected below are ones that are
14597 -- available in UNIX (but not necessarily in ANSI C).
14598 -- These are very thin interfaces
14599 -- which copy exactly the C headers. For more
14600 -- documentation on these functions, see the Microsoft C
14601 -- "Run-Time Library Reference" (Microsoft Press, 1990,
14602 -- ISBN 1-55615-225-6), which includes useful information
14603 -- on system compatibility.
14604 procedure clearerr (stream : FILEs);
14605 function fclose (stream : FILEs) return int;
14606 function fdopen (handle : int; mode : chars) return FILEs;
14607 function feof (stream : FILEs) return int;
14608 function ferror (stream : FILEs) return int;
14609 function fflush (stream : FILEs) return int;
14610 function fgetc (stream : FILEs) return int;
14611 function fgets (strng : chars; n : int; stream : FILEs)
14613 function fileno (stream : FILEs) return int;
14614 function fopen (filename : chars; Mode : chars)
14616 -- Note: to maintain target independence, use
14617 -- text_translation_required, a boolean variable defined in
14618 -- a-sysdep.c to deal with the target dependent text
14619 -- translation requirement. If this variable is set,
14620 -- then b/t should be appended to the standard mode
14621 -- argument to set the text translation mode off or on
14623 function fputc (C : int; stream : FILEs) return int;
14624 function fputs (Strng : chars; Stream : FILEs) return int;
14641 function ftell (stream : FILEs) return long;
14648 function isatty (handle : int) return int;
14649 procedure mktemp (template : chars);
14650 -- The return value (which is just a pointer to template)
14652 procedure rewind (stream : FILEs);
14653 function rmtmp return int;
14661 function tmpfile return FILEs;
14662 function ungetc (c : int; stream : FILEs) return int;
14663 function unlink (filename : chars) return int;
14664 ---------------------
14665 -- Extra functions --
14666 ---------------------
14667 -- These functions supply slightly thicker bindings than
14668 -- those above. They are derived from functions in the
14669 -- C Run-Time Library, but may do a bit more work than
14670 -- just directly calling one of the Library functions.
14671 function is_regular_file (handle : int) return int;
14672 -- Tests if given handle is for a regular file (result 1)
14673 -- or for a non-regular file (pipe or device, result 0).
14674 ---------------------------------
14675 -- Control of Text/Binary Mode --
14676 ---------------------------------
14677 -- If text_translation_required is true, then the following
14678 -- functions may be used to dynamically switch a file from
14679 -- binary to text mode or vice versa. These functions have
14680 -- no effect if text_translation_required is false (i.e.@: in
14681 -- normal UNIX mode). Use fileno to get a stream handle.
14682 procedure set_binary_mode (handle : int);
14683 procedure set_text_mode (handle : int);
14684 ----------------------------
14685 -- Full Path Name support --
14686 ----------------------------
14687 procedure full_name (nam : chars; buffer : chars);
14688 -- Given a NUL terminated string representing a file
14689 -- name, returns in buffer a NUL terminated string
14690 -- representing the full path name for the file name.
14691 -- On systems where it is relevant the drive is also
14692 -- part of the full path name. It is the responsibility
14693 -- of the caller to pass an actual parameter for buffer
14694 -- that is big enough for any full path name. Use
14695 -- max_path_len given below as the size of buffer.
14696 max_path_len : integer;
14697 -- Maximum length of an allowable full path name on the
14698 -- system, including a terminating NUL character.
14699 end Interfaces.C_Streams;
14702 @node Interfacing to C Streams
14703 @section Interfacing to C Streams
14706 The packages in this section permit interfacing Ada files to C Stream
14709 @smallexample @c ada
14710 with Interfaces.C_Streams;
14711 package Ada.Sequential_IO.C_Streams is
14712 function C_Stream (F : File_Type)
14713 return Interfaces.C_Streams.FILEs;
14715 (File : in out File_Type;
14716 Mode : in File_Mode;
14717 C_Stream : in Interfaces.C_Streams.FILEs;
14718 Form : in String := "");
14719 end Ada.Sequential_IO.C_Streams;
14721 with Interfaces.C_Streams;
14722 package Ada.Direct_IO.C_Streams is
14723 function C_Stream (F : File_Type)
14724 return Interfaces.C_Streams.FILEs;
14726 (File : in out File_Type;
14727 Mode : in File_Mode;
14728 C_Stream : in Interfaces.C_Streams.FILEs;
14729 Form : in String := "");
14730 end Ada.Direct_IO.C_Streams;
14732 with Interfaces.C_Streams;
14733 package Ada.Text_IO.C_Streams is
14734 function C_Stream (F : File_Type)
14735 return Interfaces.C_Streams.FILEs;
14737 (File : in out File_Type;
14738 Mode : in File_Mode;
14739 C_Stream : in Interfaces.C_Streams.FILEs;
14740 Form : in String := "");
14741 end Ada.Text_IO.C_Streams;
14743 with Interfaces.C_Streams;
14744 package Ada.Wide_Text_IO.C_Streams is
14745 function C_Stream (F : File_Type)
14746 return Interfaces.C_Streams.FILEs;
14748 (File : in out File_Type;
14749 Mode : in File_Mode;
14750 C_Stream : in Interfaces.C_Streams.FILEs;
14751 Form : in String := "");
14752 end Ada.Wide_Text_IO.C_Streams;
14754 with Interfaces.C_Streams;
14755 package Ada.Wide_Wide_Text_IO.C_Streams is
14756 function C_Stream (F : File_Type)
14757 return Interfaces.C_Streams.FILEs;
14759 (File : in out File_Type;
14760 Mode : in File_Mode;
14761 C_Stream : in Interfaces.C_Streams.FILEs;
14762 Form : in String := "");
14763 end Ada.Wide_Wide_Text_IO.C_Streams;
14765 with Interfaces.C_Streams;
14766 package Ada.Stream_IO.C_Streams is
14767 function C_Stream (F : File_Type)
14768 return Interfaces.C_Streams.FILEs;
14770 (File : in out File_Type;
14771 Mode : in File_Mode;
14772 C_Stream : in Interfaces.C_Streams.FILEs;
14773 Form : in String := "");
14774 end Ada.Stream_IO.C_Streams;
14778 In each of these six packages, the @code{C_Stream} function obtains the
14779 @code{FILE} pointer from a currently opened Ada file. It is then
14780 possible to use the @code{Interfaces.C_Streams} package to operate on
14781 this stream, or the stream can be passed to a C program which can
14782 operate on it directly. Of course the program is responsible for
14783 ensuring that only appropriate sequences of operations are executed.
14785 One particular use of relevance to an Ada program is that the
14786 @code{setvbuf} function can be used to control the buffering of the
14787 stream used by an Ada file. In the absence of such a call the standard
14788 default buffering is used.
14790 The @code{Open} procedures in these packages open a file giving an
14791 existing C Stream instead of a file name. Typically this stream is
14792 imported from a C program, allowing an Ada file to operate on an
14795 @node The GNAT Library
14796 @chapter The GNAT Library
14799 The GNAT library contains a number of general and special purpose packages.
14800 It represents functionality that the GNAT developers have found useful, and
14801 which is made available to GNAT users. The packages described here are fully
14802 supported, and upwards compatibility will be maintained in future releases,
14803 so you can use these facilities with the confidence that the same functionality
14804 will be available in future releases.
14806 The chapter here simply gives a brief summary of the facilities available.
14807 The full documentation is found in the spec file for the package. The full
14808 sources of these library packages, including both spec and body, are provided
14809 with all GNAT releases. For example, to find out the full specifications of
14810 the SPITBOL pattern matching capability, including a full tutorial and
14811 extensive examples, look in the @file{g-spipat.ads} file in the library.
14813 For each entry here, the package name (as it would appear in a @code{with}
14814 clause) is given, followed by the name of the corresponding spec file in
14815 parentheses. The packages are children in four hierarchies, @code{Ada},
14816 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
14817 GNAT-specific hierarchy.
14819 Note that an application program should only use packages in one of these
14820 four hierarchies if the package is defined in the Ada Reference Manual,
14821 or is listed in this section of the GNAT Programmers Reference Manual.
14822 All other units should be considered internal implementation units and
14823 should not be directly @code{with}'ed by application code. The use of
14824 a @code{with} statement that references one of these internal implementation
14825 units makes an application potentially dependent on changes in versions
14826 of GNAT, and will generate a warning message.
14829 * Ada.Characters.Latin_9 (a-chlat9.ads)::
14830 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
14831 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
14832 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
14833 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
14834 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
14835 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
14836 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
14837 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
14838 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
14839 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
14840 * Ada.Command_Line.Environment (a-colien.ads)::
14841 * Ada.Command_Line.Remove (a-colire.ads)::
14842 * Ada.Command_Line.Response_File (a-clrefi.ads)::
14843 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
14844 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
14845 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
14846 * Ada.Exceptions.Traceback (a-exctra.ads)::
14847 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
14848 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
14849 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
14850 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
14851 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
14852 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
14853 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
14854 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
14855 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
14856 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
14857 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
14858 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
14859 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
14860 * GNAT.Altivec (g-altive.ads)::
14861 * GNAT.Altivec.Conversions (g-altcon.ads)::
14862 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
14863 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
14864 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
14865 * GNAT.Array_Split (g-arrspl.ads)::
14866 * GNAT.AWK (g-awk.ads)::
14867 * GNAT.Bounded_Buffers (g-boubuf.ads)::
14868 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
14869 * GNAT.Bubble_Sort (g-bubsor.ads)::
14870 * GNAT.Bubble_Sort_A (g-busora.ads)::
14871 * GNAT.Bubble_Sort_G (g-busorg.ads)::
14872 * GNAT.Byte_Order_Mark (g-byorma.ads)::
14873 * GNAT.Byte_Swapping (g-bytswa.ads)::
14874 * GNAT.Calendar (g-calend.ads)::
14875 * GNAT.Calendar.Time_IO (g-catiio.ads)::
14876 * GNAT.Case_Util (g-casuti.ads)::
14877 * GNAT.CGI (g-cgi.ads)::
14878 * GNAT.CGI.Cookie (g-cgicoo.ads)::
14879 * GNAT.CGI.Debug (g-cgideb.ads)::
14880 * GNAT.Command_Line (g-comlin.ads)::
14881 * GNAT.Compiler_Version (g-comver.ads)::
14882 * GNAT.Ctrl_C (g-ctrl_c.ads)::
14883 * GNAT.CRC32 (g-crc32.ads)::
14884 * GNAT.Current_Exception (g-curexc.ads)::
14885 * GNAT.Debug_Pools (g-debpoo.ads)::
14886 * GNAT.Debug_Utilities (g-debuti.ads)::
14887 * GNAT.Decode_String (g-decstr.ads)::
14888 * GNAT.Decode_UTF8_String (g-deutst.ads)::
14889 * GNAT.Directory_Operations (g-dirope.ads)::
14890 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
14891 * GNAT.Dynamic_HTables (g-dynhta.ads)::
14892 * GNAT.Dynamic_Tables (g-dyntab.ads)::
14893 * GNAT.Encode_String (g-encstr.ads)::
14894 * GNAT.Encode_UTF8_String (g-enutst.ads)::
14895 * GNAT.Exception_Actions (g-excact.ads)::
14896 * GNAT.Exception_Traces (g-exctra.ads)::
14897 * GNAT.Exceptions (g-except.ads)::
14898 * GNAT.Expect (g-expect.ads)::
14899 * GNAT.Expect.TTY (g-exptty.ads)::
14900 * GNAT.Float_Control (g-flocon.ads)::
14901 * GNAT.Heap_Sort (g-heasor.ads)::
14902 * GNAT.Heap_Sort_A (g-hesora.ads)::
14903 * GNAT.Heap_Sort_G (g-hesorg.ads)::
14904 * GNAT.HTable (g-htable.ads)::
14905 * GNAT.IO (g-io.ads)::
14906 * GNAT.IO_Aux (g-io_aux.ads)::
14907 * GNAT.Lock_Files (g-locfil.ads)::
14908 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
14909 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
14910 * GNAT.MD5 (g-md5.ads)::
14911 * GNAT.Memory_Dump (g-memdum.ads)::
14912 * GNAT.Most_Recent_Exception (g-moreex.ads)::
14913 * GNAT.OS_Lib (g-os_lib.ads)::
14914 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
14915 * GNAT.Random_Numbers (g-rannum.ads)::
14916 * GNAT.Regexp (g-regexp.ads)::
14917 * GNAT.Registry (g-regist.ads)::
14918 * GNAT.Regpat (g-regpat.ads)::
14919 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
14920 * GNAT.Semaphores (g-semaph.ads)::
14921 * GNAT.Serial_Communications (g-sercom.ads)::
14922 * GNAT.SHA1 (g-sha1.ads)::
14923 * GNAT.SHA224 (g-sha224.ads)::
14924 * GNAT.SHA256 (g-sha256.ads)::
14925 * GNAT.SHA384 (g-sha384.ads)::
14926 * GNAT.SHA512 (g-sha512.ads)::
14927 * GNAT.Signals (g-signal.ads)::
14928 * GNAT.Sockets (g-socket.ads)::
14929 * GNAT.Source_Info (g-souinf.ads)::
14930 * GNAT.Spelling_Checker (g-speche.ads)::
14931 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
14932 * GNAT.Spitbol.Patterns (g-spipat.ads)::
14933 * GNAT.Spitbol (g-spitbo.ads)::
14934 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
14935 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
14936 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
14937 * GNAT.SSE (g-sse.ads)::
14938 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
14939 * GNAT.Strings (g-string.ads)::
14940 * GNAT.String_Split (g-strspl.ads)::
14941 * GNAT.Table (g-table.ads)::
14942 * GNAT.Task_Lock (g-tasloc.ads)::
14943 * GNAT.Threads (g-thread.ads)::
14944 * GNAT.Time_Stamp (g-timsta.ads)::
14945 * GNAT.Traceback (g-traceb.ads)::
14946 * GNAT.Traceback.Symbolic (g-trasym.ads)::
14947 * GNAT.UTF_32 (g-utf_32.ads)::
14948 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
14949 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
14950 * GNAT.Wide_String_Split (g-wistsp.ads)::
14951 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
14952 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
14953 * Interfaces.C.Extensions (i-cexten.ads)::
14954 * Interfaces.C.Streams (i-cstrea.ads)::
14955 * Interfaces.CPP (i-cpp.ads)::
14956 * Interfaces.Packed_Decimal (i-pacdec.ads)::
14957 * Interfaces.VxWorks (i-vxwork.ads)::
14958 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
14959 * System.Address_Image (s-addima.ads)::
14960 * System.Assertions (s-assert.ads)::
14961 * System.Memory (s-memory.ads)::
14962 * System.Partition_Interface (s-parint.ads)::
14963 * System.Pool_Global (s-pooglo.ads)::
14964 * System.Pool_Local (s-pooloc.ads)::
14965 * System.Restrictions (s-restri.ads)::
14966 * System.Rident (s-rident.ads)::
14967 * System.Strings.Stream_Ops (s-ststop.ads)::
14968 * System.Task_Info (s-tasinf.ads)::
14969 * System.Wch_Cnv (s-wchcnv.ads)::
14970 * System.Wch_Con (s-wchcon.ads)::
14973 @node Ada.Characters.Latin_9 (a-chlat9.ads)
14974 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
14975 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
14976 @cindex Latin_9 constants for Character
14979 This child of @code{Ada.Characters}
14980 provides a set of definitions corresponding to those in the
14981 RM-defined package @code{Ada.Characters.Latin_1} but with the
14982 few modifications required for @code{Latin-9}
14983 The provision of such a package
14984 is specifically authorized by the Ada Reference Manual
14987 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
14988 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
14989 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
14990 @cindex Latin_1 constants for Wide_Character
14993 This child of @code{Ada.Characters}
14994 provides a set of definitions corresponding to those in the
14995 RM-defined package @code{Ada.Characters.Latin_1} but with the
14996 types of the constants being @code{Wide_Character}
14997 instead of @code{Character}. The provision of such a package
14998 is specifically authorized by the Ada Reference Manual
15001 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
15002 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
15003 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
15004 @cindex Latin_9 constants for Wide_Character
15007 This child of @code{Ada.Characters}
15008 provides a set of definitions corresponding to those in the
15009 GNAT defined package @code{Ada.Characters.Latin_9} but with the
15010 types of the constants being @code{Wide_Character}
15011 instead of @code{Character}. The provision of such a package
15012 is specifically authorized by the Ada Reference Manual
15015 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
15016 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
15017 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
15018 @cindex Latin_1 constants for Wide_Wide_Character
15021 This child of @code{Ada.Characters}
15022 provides a set of definitions corresponding to those in the
15023 RM-defined package @code{Ada.Characters.Latin_1} but with the
15024 types of the constants being @code{Wide_Wide_Character}
15025 instead of @code{Character}. The provision of such a package
15026 is specifically authorized by the Ada Reference Manual
15029 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
15030 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
15031 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
15032 @cindex Latin_9 constants for Wide_Wide_Character
15035 This child of @code{Ada.Characters}
15036 provides a set of definitions corresponding to those in the
15037 GNAT defined package @code{Ada.Characters.Latin_9} but with the
15038 types of the constants being @code{Wide_Wide_Character}
15039 instead of @code{Character}. The provision of such a package
15040 is specifically authorized by the Ada Reference Manual
15043 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
15044 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
15045 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
15046 @cindex Formal container for doubly linked lists
15049 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15050 container for doubly linked lists, meant to facilitate formal verification of
15051 code using such containers.
15053 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
15054 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
15055 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
15056 @cindex Formal container for hashed maps
15059 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15060 container for hashed maps, meant to facilitate formal verification of
15061 code using such containers.
15063 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
15064 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
15065 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
15066 @cindex Formal container for hashed sets
15069 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15070 container for hashed sets, meant to facilitate formal verification of
15071 code using such containers.
15073 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
15074 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
15075 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
15076 @cindex Formal container for ordered maps
15079 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15080 container for ordered maps, meant to facilitate formal verification of
15081 code using such containers.
15083 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
15084 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
15085 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
15086 @cindex Formal container for ordered sets
15089 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15090 container for ordered sets, meant to facilitate formal verification of
15091 code using such containers.
15093 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
15094 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
15095 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
15096 @cindex Formal container for vectors
15099 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15100 container for vectors, meant to facilitate formal verification of
15101 code using such containers.
15103 @node Ada.Command_Line.Environment (a-colien.ads)
15104 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
15105 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
15106 @cindex Environment entries
15109 This child of @code{Ada.Command_Line}
15110 provides a mechanism for obtaining environment values on systems
15111 where this concept makes sense.
15113 @node Ada.Command_Line.Remove (a-colire.ads)
15114 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
15115 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
15116 @cindex Removing command line arguments
15117 @cindex Command line, argument removal
15120 This child of @code{Ada.Command_Line}
15121 provides a mechanism for logically removing
15122 arguments from the argument list. Once removed, an argument is not visible
15123 to further calls on the subprograms in @code{Ada.Command_Line} will not
15124 see the removed argument.
15126 @node Ada.Command_Line.Response_File (a-clrefi.ads)
15127 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15128 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15129 @cindex Response file for command line
15130 @cindex Command line, response file
15131 @cindex Command line, handling long command lines
15134 This child of @code{Ada.Command_Line} provides a mechanism facilities for
15135 getting command line arguments from a text file, called a "response file".
15136 Using a response file allow passing a set of arguments to an executable longer
15137 than the maximum allowed by the system on the command line.
15139 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
15140 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15141 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15142 @cindex C Streams, Interfacing with Direct_IO
15145 This package provides subprograms that allow interfacing between
15146 C streams and @code{Direct_IO}. The stream identifier can be
15147 extracted from a file opened on the Ada side, and an Ada file
15148 can be constructed from a stream opened on the C side.
15150 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
15151 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15152 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15153 @cindex Null_Occurrence, testing for
15156 This child subprogram provides a way of testing for the null
15157 exception occurrence (@code{Null_Occurrence}) without raising
15160 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
15161 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15162 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15163 @cindex Null_Occurrence, testing for
15166 This child subprogram is used for handling otherwise unhandled
15167 exceptions (hence the name last chance), and perform clean ups before
15168 terminating the program. Note that this subprogram never returns.
15170 @node Ada.Exceptions.Traceback (a-exctra.ads)
15171 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15172 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15173 @cindex Traceback for Exception Occurrence
15176 This child package provides the subprogram (@code{Tracebacks}) to
15177 give a traceback array of addresses based on an exception
15180 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
15181 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15182 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15183 @cindex C Streams, Interfacing with Sequential_IO
15186 This package provides subprograms that allow interfacing between
15187 C streams and @code{Sequential_IO}. The stream identifier can be
15188 extracted from a file opened on the Ada side, and an Ada file
15189 can be constructed from a stream opened on the C side.
15191 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
15192 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15193 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15194 @cindex C Streams, Interfacing with Stream_IO
15197 This package provides subprograms that allow interfacing between
15198 C streams and @code{Stream_IO}. The stream identifier can be
15199 extracted from a file opened on the Ada side, and an Ada file
15200 can be constructed from a stream opened on the C side.
15202 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
15203 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15204 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15205 @cindex @code{Unbounded_String}, IO support
15206 @cindex @code{Text_IO}, extensions for unbounded strings
15209 This package provides subprograms for Text_IO for unbounded
15210 strings, avoiding the necessity for an intermediate operation
15211 with ordinary strings.
15213 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
15214 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15215 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15216 @cindex @code{Unbounded_Wide_String}, IO support
15217 @cindex @code{Text_IO}, extensions for unbounded wide strings
15220 This package provides subprograms for Text_IO for unbounded
15221 wide strings, avoiding the necessity for an intermediate operation
15222 with ordinary wide strings.
15224 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
15225 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15226 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15227 @cindex @code{Unbounded_Wide_Wide_String}, IO support
15228 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
15231 This package provides subprograms for Text_IO for unbounded
15232 wide wide strings, avoiding the necessity for an intermediate operation
15233 with ordinary wide wide strings.
15235 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
15236 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15237 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15238 @cindex C Streams, Interfacing with @code{Text_IO}
15241 This package provides subprograms that allow interfacing between
15242 C streams and @code{Text_IO}. The stream identifier can be
15243 extracted from a file opened on the Ada side, and an Ada file
15244 can be constructed from a stream opened on the C side.
15246 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
15247 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15248 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15249 @cindex @code{Text_IO} resetting standard files
15252 This procedure is used to reset the status of the standard files used
15253 by Ada.Text_IO. This is useful in a situation (such as a restart in an
15254 embedded application) where the status of the files may change during
15255 execution (for example a standard input file may be redefined to be
15258 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
15259 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15260 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15261 @cindex Unicode categorization, Wide_Character
15264 This package provides subprograms that allow categorization of
15265 Wide_Character values according to Unicode categories.
15267 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
15268 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15269 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15270 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
15273 This package provides subprograms that allow interfacing between
15274 C streams and @code{Wide_Text_IO}. The stream identifier can be
15275 extracted from a file opened on the Ada side, and an Ada file
15276 can be constructed from a stream opened on the C side.
15278 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
15279 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15280 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15281 @cindex @code{Wide_Text_IO} resetting standard files
15284 This procedure is used to reset the status of the standard files used
15285 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
15286 embedded application) where the status of the files may change during
15287 execution (for example a standard input file may be redefined to be
15290 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
15291 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15292 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15293 @cindex Unicode categorization, Wide_Wide_Character
15296 This package provides subprograms that allow categorization of
15297 Wide_Wide_Character values according to Unicode categories.
15299 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
15300 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15301 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15302 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
15305 This package provides subprograms that allow interfacing between
15306 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
15307 extracted from a file opened on the Ada side, and an Ada file
15308 can be constructed from a stream opened on the C side.
15310 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
15311 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15312 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15313 @cindex @code{Wide_Wide_Text_IO} resetting standard files
15316 This procedure is used to reset the status of the standard files used
15317 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
15318 restart in an embedded application) where the status of the files may
15319 change during execution (for example a standard input file may be
15320 redefined to be interactive).
15322 @node GNAT.Altivec (g-altive.ads)
15323 @section @code{GNAT.Altivec} (@file{g-altive.ads})
15324 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
15328 This is the root package of the GNAT AltiVec binding. It provides
15329 definitions of constants and types common to all the versions of the
15332 @node GNAT.Altivec.Conversions (g-altcon.ads)
15333 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15334 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15338 This package provides the Vector/View conversion routines.
15340 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
15341 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15342 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15346 This package exposes the Ada interface to the AltiVec operations on
15347 vector objects. A soft emulation is included by default in the GNAT
15348 library. The hard binding is provided as a separate package. This unit
15349 is common to both bindings.
15351 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
15352 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15353 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15357 This package exposes the various vector types part of the Ada binding
15358 to AltiVec facilities.
15360 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
15361 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15362 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15366 This package provides public 'View' data types from/to which private
15367 vector representations can be converted via
15368 GNAT.Altivec.Conversions. This allows convenient access to individual
15369 vector elements and provides a simple way to initialize vector
15372 @node GNAT.Array_Split (g-arrspl.ads)
15373 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15374 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15375 @cindex Array splitter
15378 Useful array-manipulation routines: given a set of separators, split
15379 an array wherever the separators appear, and provide direct access
15380 to the resulting slices.
15382 @node GNAT.AWK (g-awk.ads)
15383 @section @code{GNAT.AWK} (@file{g-awk.ads})
15384 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
15389 Provides AWK-like parsing functions, with an easy interface for parsing one
15390 or more files containing formatted data. The file is viewed as a database
15391 where each record is a line and a field is a data element in this line.
15393 @node GNAT.Bounded_Buffers (g-boubuf.ads)
15394 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15395 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15397 @cindex Bounded Buffers
15400 Provides a concurrent generic bounded buffer abstraction. Instances are
15401 useful directly or as parts of the implementations of other abstractions,
15404 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
15405 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15406 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15411 Provides a thread-safe asynchronous intertask mailbox communication facility.
15413 @node GNAT.Bubble_Sort (g-bubsor.ads)
15414 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15415 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15417 @cindex Bubble sort
15420 Provides a general implementation of bubble sort usable for sorting arbitrary
15421 data items. Exchange and comparison procedures are provided by passing
15422 access-to-procedure values.
15424 @node GNAT.Bubble_Sort_A (g-busora.ads)
15425 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15426 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15428 @cindex Bubble sort
15431 Provides a general implementation of bubble sort usable for sorting arbitrary
15432 data items. Move and comparison procedures are provided by passing
15433 access-to-procedure values. This is an older version, retained for
15434 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
15436 @node GNAT.Bubble_Sort_G (g-busorg.ads)
15437 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
15438 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
15440 @cindex Bubble sort
15443 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
15444 are provided as generic parameters, this improves efficiency, especially
15445 if the procedures can be inlined, at the expense of duplicating code for
15446 multiple instantiations.
15448 @node GNAT.Byte_Order_Mark (g-byorma.ads)
15449 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
15450 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
15451 @cindex UTF-8 representation
15452 @cindex Wide characte representations
15455 Provides a routine which given a string, reads the start of the string to
15456 see whether it is one of the standard byte order marks (BOM's) which signal
15457 the encoding of the string. The routine includes detection of special XML
15458 sequences for various UCS input formats.
15460 @node GNAT.Byte_Swapping (g-bytswa.ads)
15461 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
15462 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
15463 @cindex Byte swapping
15467 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
15468 Machine-specific implementations are available in some cases.
15470 @node GNAT.Calendar (g-calend.ads)
15471 @section @code{GNAT.Calendar} (@file{g-calend.ads})
15472 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
15473 @cindex @code{Calendar}
15476 Extends the facilities provided by @code{Ada.Calendar} to include handling
15477 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
15478 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
15479 C @code{timeval} format.
15481 @node GNAT.Calendar.Time_IO (g-catiio.ads)
15482 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
15483 @cindex @code{Calendar}
15485 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
15487 @node GNAT.CRC32 (g-crc32.ads)
15488 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
15489 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
15491 @cindex Cyclic Redundancy Check
15494 This package implements the CRC-32 algorithm. For a full description
15495 of this algorithm see
15496 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
15497 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
15498 Aug.@: 1988. Sarwate, D.V@.
15500 @node GNAT.Case_Util (g-casuti.ads)
15501 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
15502 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
15503 @cindex Casing utilities
15504 @cindex Character handling (@code{GNAT.Case_Util})
15507 A set of simple routines for handling upper and lower casing of strings
15508 without the overhead of the full casing tables
15509 in @code{Ada.Characters.Handling}.
15511 @node GNAT.CGI (g-cgi.ads)
15512 @section @code{GNAT.CGI} (@file{g-cgi.ads})
15513 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
15514 @cindex CGI (Common Gateway Interface)
15517 This is a package for interfacing a GNAT program with a Web server via the
15518 Common Gateway Interface (CGI)@. Basically this package parses the CGI
15519 parameters, which are a set of key/value pairs sent by the Web server. It
15520 builds a table whose index is the key and provides some services to deal
15523 @node GNAT.CGI.Cookie (g-cgicoo.ads)
15524 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
15525 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
15526 @cindex CGI (Common Gateway Interface) cookie support
15527 @cindex Cookie support in CGI
15530 This is a package to interface a GNAT program with a Web server via the
15531 Common Gateway Interface (CGI). It exports services to deal with Web
15532 cookies (piece of information kept in the Web client software).
15534 @node GNAT.CGI.Debug (g-cgideb.ads)
15535 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
15536 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
15537 @cindex CGI (Common Gateway Interface) debugging
15540 This is a package to help debugging CGI (Common Gateway Interface)
15541 programs written in Ada.
15543 @node GNAT.Command_Line (g-comlin.ads)
15544 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
15545 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
15546 @cindex Command line
15549 Provides a high level interface to @code{Ada.Command_Line} facilities,
15550 including the ability to scan for named switches with optional parameters
15551 and expand file names using wild card notations.
15553 @node GNAT.Compiler_Version (g-comver.ads)
15554 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
15555 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
15556 @cindex Compiler Version
15557 @cindex Version, of compiler
15560 Provides a routine for obtaining the version of the compiler used to
15561 compile the program. More accurately this is the version of the binder
15562 used to bind the program (this will normally be the same as the version
15563 of the compiler if a consistent tool set is used to compile all units
15566 @node GNAT.Ctrl_C (g-ctrl_c.ads)
15567 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
15568 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
15572 Provides a simple interface to handle Ctrl-C keyboard events.
15574 @node GNAT.Current_Exception (g-curexc.ads)
15575 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
15576 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
15577 @cindex Current exception
15578 @cindex Exception retrieval
15581 Provides access to information on the current exception that has been raised
15582 without the need for using the Ada 95 / Ada 2005 exception choice parameter
15583 specification syntax.
15584 This is particularly useful in simulating typical facilities for
15585 obtaining information about exceptions provided by Ada 83 compilers.
15587 @node GNAT.Debug_Pools (g-debpoo.ads)
15588 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
15589 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
15591 @cindex Debug pools
15592 @cindex Memory corruption debugging
15595 Provide a debugging storage pools that helps tracking memory corruption
15596 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
15597 @value{EDITION} User's Guide}.
15599 @node GNAT.Debug_Utilities (g-debuti.ads)
15600 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
15601 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
15605 Provides a few useful utilities for debugging purposes, including conversion
15606 to and from string images of address values. Supports both C and Ada formats
15607 for hexadecimal literals.
15609 @node GNAT.Decode_String (g-decstr.ads)
15610 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
15611 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
15612 @cindex Decoding strings
15613 @cindex String decoding
15614 @cindex Wide character encoding
15619 A generic package providing routines for decoding wide character and wide wide
15620 character strings encoded as sequences of 8-bit characters using a specified
15621 encoding method. Includes validation routines, and also routines for stepping
15622 to next or previous encoded character in an encoded string.
15623 Useful in conjunction with Unicode character coding. Note there is a
15624 preinstantiation for UTF-8. See next entry.
15626 @node GNAT.Decode_UTF8_String (g-deutst.ads)
15627 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
15628 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
15629 @cindex Decoding strings
15630 @cindex Decoding UTF-8 strings
15631 @cindex UTF-8 string decoding
15632 @cindex Wide character decoding
15637 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
15639 @node GNAT.Directory_Operations (g-dirope.ads)
15640 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
15641 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
15642 @cindex Directory operations
15645 Provides a set of routines for manipulating directories, including changing
15646 the current directory, making new directories, and scanning the files in a
15649 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
15650 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
15651 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
15652 @cindex Directory operations iteration
15655 A child unit of GNAT.Directory_Operations providing additional operations
15656 for iterating through directories.
15658 @node GNAT.Dynamic_HTables (g-dynhta.ads)
15659 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
15660 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
15661 @cindex Hash tables
15664 A generic implementation of hash tables that can be used to hash arbitrary
15665 data. Provided in two forms, a simple form with built in hash functions,
15666 and a more complex form in which the hash function is supplied.
15669 This package provides a facility similar to that of @code{GNAT.HTable},
15670 except that this package declares a type that can be used to define
15671 dynamic instances of the hash table, while an instantiation of
15672 @code{GNAT.HTable} creates a single instance of the hash table.
15674 @node GNAT.Dynamic_Tables (g-dyntab.ads)
15675 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
15676 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
15677 @cindex Table implementation
15678 @cindex Arrays, extendable
15681 A generic package providing a single dimension array abstraction where the
15682 length of the array can be dynamically modified.
15685 This package provides a facility similar to that of @code{GNAT.Table},
15686 except that this package declares a type that can be used to define
15687 dynamic instances of the table, while an instantiation of
15688 @code{GNAT.Table} creates a single instance of the table type.
15690 @node GNAT.Encode_String (g-encstr.ads)
15691 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
15692 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
15693 @cindex Encoding strings
15694 @cindex String encoding
15695 @cindex Wide character encoding
15700 A generic package providing routines for encoding wide character and wide
15701 wide character strings as sequences of 8-bit characters using a specified
15702 encoding method. Useful in conjunction with Unicode character coding.
15703 Note there is a preinstantiation for UTF-8. See next entry.
15705 @node GNAT.Encode_UTF8_String (g-enutst.ads)
15706 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
15707 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
15708 @cindex Encoding strings
15709 @cindex Encoding UTF-8 strings
15710 @cindex UTF-8 string encoding
15711 @cindex Wide character encoding
15716 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
15718 @node GNAT.Exception_Actions (g-excact.ads)
15719 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
15720 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
15721 @cindex Exception actions
15724 Provides callbacks when an exception is raised. Callbacks can be registered
15725 for specific exceptions, or when any exception is raised. This
15726 can be used for instance to force a core dump to ease debugging.
15728 @node GNAT.Exception_Traces (g-exctra.ads)
15729 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
15730 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
15731 @cindex Exception traces
15735 Provides an interface allowing to control automatic output upon exception
15738 @node GNAT.Exceptions (g-except.ads)
15739 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
15740 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
15741 @cindex Exceptions, Pure
15742 @cindex Pure packages, exceptions
15745 Normally it is not possible to raise an exception with
15746 a message from a subprogram in a pure package, since the
15747 necessary types and subprograms are in @code{Ada.Exceptions}
15748 which is not a pure unit. @code{GNAT.Exceptions} provides a
15749 facility for getting around this limitation for a few
15750 predefined exceptions, and for example allow raising
15751 @code{Constraint_Error} with a message from a pure subprogram.
15753 @node GNAT.Expect (g-expect.ads)
15754 @section @code{GNAT.Expect} (@file{g-expect.ads})
15755 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
15758 Provides a set of subprograms similar to what is available
15759 with the standard Tcl Expect tool.
15760 It allows you to easily spawn and communicate with an external process.
15761 You can send commands or inputs to the process, and compare the output
15762 with some expected regular expression. Currently @code{GNAT.Expect}
15763 is implemented on all native GNAT ports except for OpenVMS@.
15764 It is not implemented for cross ports, and in particular is not
15765 implemented for VxWorks or LynxOS@.
15767 @node GNAT.Expect.TTY (g-exptty.ads)
15768 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
15769 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
15772 As GNAT.Expect but using pseudo-terminal.
15773 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
15774 ports except for OpenVMS@. It is not implemented for cross ports, and
15775 in particular is not implemented for VxWorks or LynxOS@.
15777 @node GNAT.Float_Control (g-flocon.ads)
15778 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
15779 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
15780 @cindex Floating-Point Processor
15783 Provides an interface for resetting the floating-point processor into the
15784 mode required for correct semantic operation in Ada. Some third party
15785 library calls may cause this mode to be modified, and the Reset procedure
15786 in this package can be used to reestablish the required mode.
15788 @node GNAT.Heap_Sort (g-heasor.ads)
15789 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15790 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15794 Provides a general implementation of heap sort usable for sorting arbitrary
15795 data items. Exchange and comparison procedures are provided by passing
15796 access-to-procedure values. The algorithm used is a modified heap sort
15797 that performs approximately N*log(N) comparisons in the worst case.
15799 @node GNAT.Heap_Sort_A (g-hesora.ads)
15800 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15801 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15805 Provides a general implementation of heap sort usable for sorting arbitrary
15806 data items. Move and comparison procedures are provided by passing
15807 access-to-procedure values. The algorithm used is a modified heap sort
15808 that performs approximately N*log(N) comparisons in the worst case.
15809 This differs from @code{GNAT.Heap_Sort} in having a less convenient
15810 interface, but may be slightly more efficient.
15812 @node GNAT.Heap_Sort_G (g-hesorg.ads)
15813 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15814 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15818 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
15819 are provided as generic parameters, this improves efficiency, especially
15820 if the procedures can be inlined, at the expense of duplicating code for
15821 multiple instantiations.
15823 @node GNAT.HTable (g-htable.ads)
15824 @section @code{GNAT.HTable} (@file{g-htable.ads})
15825 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
15826 @cindex Hash tables
15829 A generic implementation of hash tables that can be used to hash arbitrary
15830 data. Provides two approaches, one a simple static approach, and the other
15831 allowing arbitrary dynamic hash tables.
15833 @node GNAT.IO (g-io.ads)
15834 @section @code{GNAT.IO} (@file{g-io.ads})
15835 @cindex @code{GNAT.IO} (@file{g-io.ads})
15837 @cindex Input/Output facilities
15840 A simple preelaborable input-output package that provides a subset of
15841 simple Text_IO functions for reading characters and strings from
15842 Standard_Input, and writing characters, strings and integers to either
15843 Standard_Output or Standard_Error.
15845 @node GNAT.IO_Aux (g-io_aux.ads)
15846 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15847 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15849 @cindex Input/Output facilities
15851 Provides some auxiliary functions for use with Text_IO, including a test
15852 for whether a file exists, and functions for reading a line of text.
15854 @node GNAT.Lock_Files (g-locfil.ads)
15855 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15856 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15857 @cindex File locking
15858 @cindex Locking using files
15861 Provides a general interface for using files as locks. Can be used for
15862 providing program level synchronization.
15864 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
15865 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15866 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15867 @cindex Random number generation
15870 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
15871 a modified version of the Blum-Blum-Shub generator.
15873 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
15874 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15875 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15876 @cindex Random number generation
15879 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
15880 a modified version of the Blum-Blum-Shub generator.
15882 @node GNAT.MD5 (g-md5.ads)
15883 @section @code{GNAT.MD5} (@file{g-md5.ads})
15884 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
15885 @cindex Message Digest MD5
15888 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
15890 @node GNAT.Memory_Dump (g-memdum.ads)
15891 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15892 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15893 @cindex Dump Memory
15896 Provides a convenient routine for dumping raw memory to either the
15897 standard output or standard error files. Uses GNAT.IO for actual
15900 @node GNAT.Most_Recent_Exception (g-moreex.ads)
15901 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15902 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15903 @cindex Exception, obtaining most recent
15906 Provides access to the most recently raised exception. Can be used for
15907 various logging purposes, including duplicating functionality of some
15908 Ada 83 implementation dependent extensions.
15910 @node GNAT.OS_Lib (g-os_lib.ads)
15911 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15912 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15913 @cindex Operating System interface
15914 @cindex Spawn capability
15917 Provides a range of target independent operating system interface functions,
15918 including time/date management, file operations, subprocess management,
15919 including a portable spawn procedure, and access to environment variables
15920 and error return codes.
15922 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
15923 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15924 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15925 @cindex Hash functions
15928 Provides a generator of static minimal perfect hash functions. No
15929 collisions occur and each item can be retrieved from the table in one
15930 probe (perfect property). The hash table size corresponds to the exact
15931 size of the key set and no larger (minimal property). The key set has to
15932 be know in advance (static property). The hash functions are also order
15933 preserving. If w2 is inserted after w1 in the generator, their
15934 hashcode are in the same order. These hashing functions are very
15935 convenient for use with realtime applications.
15937 @node GNAT.Random_Numbers (g-rannum.ads)
15938 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15939 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15940 @cindex Random number generation
15943 Provides random number capabilities which extend those available in the
15944 standard Ada library and are more convenient to use.
15946 @node GNAT.Regexp (g-regexp.ads)
15947 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
15948 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
15949 @cindex Regular expressions
15950 @cindex Pattern matching
15953 A simple implementation of regular expressions, using a subset of regular
15954 expression syntax copied from familiar Unix style utilities. This is the
15955 simples of the three pattern matching packages provided, and is particularly
15956 suitable for ``file globbing'' applications.
15958 @node GNAT.Registry (g-regist.ads)
15959 @section @code{GNAT.Registry} (@file{g-regist.ads})
15960 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
15961 @cindex Windows Registry
15964 This is a high level binding to the Windows registry. It is possible to
15965 do simple things like reading a key value, creating a new key. For full
15966 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
15967 package provided with the Win32Ada binding
15969 @node GNAT.Regpat (g-regpat.ads)
15970 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
15971 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
15972 @cindex Regular expressions
15973 @cindex Pattern matching
15976 A complete implementation of Unix-style regular expression matching, copied
15977 from the original V7 style regular expression library written in C by
15978 Henry Spencer (and binary compatible with this C library).
15980 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
15981 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
15982 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
15983 @cindex Secondary Stack Info
15986 Provide the capability to query the high water mark of the current task's
15989 @node GNAT.Semaphores (g-semaph.ads)
15990 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
15991 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
15995 Provides classic counting and binary semaphores using protected types.
15997 @node GNAT.Serial_Communications (g-sercom.ads)
15998 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
15999 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
16000 @cindex Serial_Communications
16003 Provides a simple interface to send and receive data over a serial
16004 port. This is only supported on GNU/Linux and Windows.
16006 @node GNAT.SHA1 (g-sha1.ads)
16007 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
16008 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
16009 @cindex Secure Hash Algorithm SHA-1
16012 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
16015 @node GNAT.SHA224 (g-sha224.ads)
16016 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
16017 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
16018 @cindex Secure Hash Algorithm SHA-224
16021 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
16023 @node GNAT.SHA256 (g-sha256.ads)
16024 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
16025 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
16026 @cindex Secure Hash Algorithm SHA-256
16029 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
16031 @node GNAT.SHA384 (g-sha384.ads)
16032 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
16033 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
16034 @cindex Secure Hash Algorithm SHA-384
16037 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
16039 @node GNAT.SHA512 (g-sha512.ads)
16040 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
16041 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
16042 @cindex Secure Hash Algorithm SHA-512
16045 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
16047 @node GNAT.Signals (g-signal.ads)
16048 @section @code{GNAT.Signals} (@file{g-signal.ads})
16049 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
16053 Provides the ability to manipulate the blocked status of signals on supported
16056 @node GNAT.Sockets (g-socket.ads)
16057 @section @code{GNAT.Sockets} (@file{g-socket.ads})
16058 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
16062 A high level and portable interface to develop sockets based applications.
16063 This package is based on the sockets thin binding found in
16064 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
16065 on all native GNAT ports except for OpenVMS@. It is not implemented
16066 for the LynxOS@ cross port.
16068 @node GNAT.Source_Info (g-souinf.ads)
16069 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
16070 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
16071 @cindex Source Information
16074 Provides subprograms that give access to source code information known at
16075 compile time, such as the current file name and line number.
16077 @node GNAT.Spelling_Checker (g-speche.ads)
16078 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
16079 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
16080 @cindex Spell checking
16083 Provides a function for determining whether one string is a plausible
16084 near misspelling of another string.
16086 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
16087 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
16088 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
16089 @cindex Spell checking
16092 Provides a generic function that can be instantiated with a string type for
16093 determining whether one string is a plausible near misspelling of another
16096 @node GNAT.Spitbol.Patterns (g-spipat.ads)
16097 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
16098 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
16099 @cindex SPITBOL pattern matching
16100 @cindex Pattern matching
16103 A complete implementation of SNOBOL4 style pattern matching. This is the
16104 most elaborate of the pattern matching packages provided. It fully duplicates
16105 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
16106 efficient algorithm developed by Robert Dewar for the SPITBOL system.
16108 @node GNAT.Spitbol (g-spitbo.ads)
16109 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
16110 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
16111 @cindex SPITBOL interface
16114 The top level package of the collection of SPITBOL-style functionality, this
16115 package provides basic SNOBOL4 string manipulation functions, such as
16116 Pad, Reverse, Trim, Substr capability, as well as a generic table function
16117 useful for constructing arbitrary mappings from strings in the style of
16118 the SNOBOL4 TABLE function.
16120 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
16121 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
16122 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
16123 @cindex Sets of strings
16124 @cindex SPITBOL Tables
16127 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16128 for type @code{Standard.Boolean}, giving an implementation of sets of
16131 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
16132 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16133 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16134 @cindex Integer maps
16136 @cindex SPITBOL Tables
16139 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16140 for type @code{Standard.Integer}, giving an implementation of maps
16141 from string to integer values.
16143 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
16144 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16145 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16146 @cindex String maps
16148 @cindex SPITBOL Tables
16151 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
16152 a variable length string type, giving an implementation of general
16153 maps from strings to strings.
16155 @node GNAT.SSE (g-sse.ads)
16156 @section @code{GNAT.SSE} (@file{g-sse.ads})
16157 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
16160 Root of a set of units aimed at offering Ada bindings to a subset of
16161 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
16162 targets. It exposes vector component types together with a general
16163 introduction to the binding contents and use.
16165 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
16166 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16167 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16170 SSE vector types for use with SSE related intrinsics.
16172 @node GNAT.Strings (g-string.ads)
16173 @section @code{GNAT.Strings} (@file{g-string.ads})
16174 @cindex @code{GNAT.Strings} (@file{g-string.ads})
16177 Common String access types and related subprograms. Basically it
16178 defines a string access and an array of string access types.
16180 @node GNAT.String_Split (g-strspl.ads)
16181 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
16182 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
16183 @cindex String splitter
16186 Useful string manipulation routines: given a set of separators, split
16187 a string wherever the separators appear, and provide direct access
16188 to the resulting slices. This package is instantiated from
16189 @code{GNAT.Array_Split}.
16191 @node GNAT.Table (g-table.ads)
16192 @section @code{GNAT.Table} (@file{g-table.ads})
16193 @cindex @code{GNAT.Table} (@file{g-table.ads})
16194 @cindex Table implementation
16195 @cindex Arrays, extendable
16198 A generic package providing a single dimension array abstraction where the
16199 length of the array can be dynamically modified.
16202 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
16203 except that this package declares a single instance of the table type,
16204 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
16205 used to define dynamic instances of the table.
16207 @node GNAT.Task_Lock (g-tasloc.ads)
16208 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16209 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16210 @cindex Task synchronization
16211 @cindex Task locking
16215 A very simple facility for locking and unlocking sections of code using a
16216 single global task lock. Appropriate for use in situations where contention
16217 between tasks is very rarely expected.
16219 @node GNAT.Time_Stamp (g-timsta.ads)
16220 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16221 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16223 @cindex Current time
16226 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
16227 represents the current date and time in ISO 8601 format. This is a very simple
16228 routine with minimal code and there are no dependencies on any other unit.
16230 @node GNAT.Threads (g-thread.ads)
16231 @section @code{GNAT.Threads} (@file{g-thread.ads})
16232 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
16233 @cindex Foreign threads
16234 @cindex Threads, foreign
16237 Provides facilities for dealing with foreign threads which need to be known
16238 by the GNAT run-time system. Consult the documentation of this package for
16239 further details if your program has threads that are created by a non-Ada
16240 environment which then accesses Ada code.
16242 @node GNAT.Traceback (g-traceb.ads)
16243 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
16244 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
16245 @cindex Trace back facilities
16248 Provides a facility for obtaining non-symbolic traceback information, useful
16249 in various debugging situations.
16251 @node GNAT.Traceback.Symbolic (g-trasym.ads)
16252 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16253 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16254 @cindex Trace back facilities
16256 @node GNAT.UTF_32 (g-utf_32.ads)
16257 @section @code{GNAT.UTF_32} (@file{g-table.ads})
16258 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
16259 @cindex Wide character codes
16262 This is a package intended to be used in conjunction with the
16263 @code{Wide_Character} type in Ada 95 and the
16264 @code{Wide_Wide_Character} type in Ada 2005 (available
16265 in @code{GNAT} in Ada 2005 mode). This package contains
16266 Unicode categorization routines, as well as lexical
16267 categorization routines corresponding to the Ada 2005
16268 lexical rules for identifiers and strings, and also a
16269 lower case to upper case fold routine corresponding to
16270 the Ada 2005 rules for identifier equivalence.
16272 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
16273 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16274 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16275 @cindex Spell checking
16278 Provides a function for determining whether one wide wide string is a plausible
16279 near misspelling of another wide wide string, where the strings are represented
16280 using the UTF_32_String type defined in System.Wch_Cnv.
16282 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
16283 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16284 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16285 @cindex Spell checking
16288 Provides a function for determining whether one wide string is a plausible
16289 near misspelling of another wide string.
16291 @node GNAT.Wide_String_Split (g-wistsp.ads)
16292 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16293 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16294 @cindex Wide_String splitter
16297 Useful wide string manipulation routines: given a set of separators, split
16298 a wide string wherever the separators appear, and provide direct access
16299 to the resulting slices. This package is instantiated from
16300 @code{GNAT.Array_Split}.
16302 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
16303 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16304 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16305 @cindex Spell checking
16308 Provides a function for determining whether one wide wide string is a plausible
16309 near misspelling of another wide wide string.
16311 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
16312 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16313 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16314 @cindex Wide_Wide_String splitter
16317 Useful wide wide string manipulation routines: given a set of separators, split
16318 a wide wide string wherever the separators appear, and provide direct access
16319 to the resulting slices. This package is instantiated from
16320 @code{GNAT.Array_Split}.
16322 @node Interfaces.C.Extensions (i-cexten.ads)
16323 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16324 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16327 This package contains additional C-related definitions, intended
16328 for use with either manually or automatically generated bindings
16331 @node Interfaces.C.Streams (i-cstrea.ads)
16332 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16333 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16334 @cindex C streams, interfacing
16337 This package is a binding for the most commonly used operations
16340 @node Interfaces.CPP (i-cpp.ads)
16341 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
16342 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
16343 @cindex C++ interfacing
16344 @cindex Interfacing, to C++
16347 This package provides facilities for use in interfacing to C++. It
16348 is primarily intended to be used in connection with automated tools
16349 for the generation of C++ interfaces.
16351 @node Interfaces.Packed_Decimal (i-pacdec.ads)
16352 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16353 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16354 @cindex IBM Packed Format
16355 @cindex Packed Decimal
16358 This package provides a set of routines for conversions to and
16359 from a packed decimal format compatible with that used on IBM
16362 @node Interfaces.VxWorks (i-vxwork.ads)
16363 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16364 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16365 @cindex Interfacing to VxWorks
16366 @cindex VxWorks, interfacing
16369 This package provides a limited binding to the VxWorks API.
16370 In particular, it interfaces with the
16371 VxWorks hardware interrupt facilities.
16373 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
16374 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16375 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16376 @cindex Interfacing to VxWorks' I/O
16377 @cindex VxWorks, I/O interfacing
16378 @cindex VxWorks, Get_Immediate
16379 @cindex Get_Immediate, VxWorks
16382 This package provides a binding to the ioctl (IO/Control)
16383 function of VxWorks, defining a set of option values and
16384 function codes. A particular use of this package is
16385 to enable the use of Get_Immediate under VxWorks.
16387 @node System.Address_Image (s-addima.ads)
16388 @section @code{System.Address_Image} (@file{s-addima.ads})
16389 @cindex @code{System.Address_Image} (@file{s-addima.ads})
16390 @cindex Address image
16391 @cindex Image, of an address
16394 This function provides a useful debugging
16395 function that gives an (implementation dependent)
16396 string which identifies an address.
16398 @node System.Assertions (s-assert.ads)
16399 @section @code{System.Assertions} (@file{s-assert.ads})
16400 @cindex @code{System.Assertions} (@file{s-assert.ads})
16402 @cindex Assert_Failure, exception
16405 This package provides the declaration of the exception raised
16406 by an run-time assertion failure, as well as the routine that
16407 is used internally to raise this assertion.
16409 @node System.Memory (s-memory.ads)
16410 @section @code{System.Memory} (@file{s-memory.ads})
16411 @cindex @code{System.Memory} (@file{s-memory.ads})
16412 @cindex Memory allocation
16415 This package provides the interface to the low level routines used
16416 by the generated code for allocation and freeing storage for the
16417 default storage pool (analogous to the C routines malloc and free.
16418 It also provides a reallocation interface analogous to the C routine
16419 realloc. The body of this unit may be modified to provide alternative
16420 allocation mechanisms for the default pool, and in addition, direct
16421 calls to this unit may be made for low level allocation uses (for
16422 example see the body of @code{GNAT.Tables}).
16424 @node System.Partition_Interface (s-parint.ads)
16425 @section @code{System.Partition_Interface} (@file{s-parint.ads})
16426 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
16427 @cindex Partition interfacing functions
16430 This package provides facilities for partition interfacing. It
16431 is used primarily in a distribution context when using Annex E
16434 @node System.Pool_Global (s-pooglo.ads)
16435 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
16436 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
16437 @cindex Storage pool, global
16438 @cindex Global storage pool
16441 This package provides a storage pool that is equivalent to the default
16442 storage pool used for access types for which no pool is specifically
16443 declared. It uses malloc/free to allocate/free and does not attempt to
16444 do any automatic reclamation.
16446 @node System.Pool_Local (s-pooloc.ads)
16447 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
16448 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
16449 @cindex Storage pool, local
16450 @cindex Local storage pool
16453 This package provides a storage pool that is intended for use with locally
16454 defined access types. It uses malloc/free for allocate/free, and maintains
16455 a list of allocated blocks, so that all storage allocated for the pool can
16456 be freed automatically when the pool is finalized.
16458 @node System.Restrictions (s-restri.ads)
16459 @section @code{System.Restrictions} (@file{s-restri.ads})
16460 @cindex @code{System.Restrictions} (@file{s-restri.ads})
16461 @cindex Run-time restrictions access
16464 This package provides facilities for accessing at run time
16465 the status of restrictions specified at compile time for
16466 the partition. Information is available both with regard
16467 to actual restrictions specified, and with regard to
16468 compiler determined information on which restrictions
16469 are violated by one or more packages in the partition.
16471 @node System.Rident (s-rident.ads)
16472 @section @code{System.Rident} (@file{s-rident.ads})
16473 @cindex @code{System.Rident} (@file{s-rident.ads})
16474 @cindex Restrictions definitions
16477 This package provides definitions of the restrictions
16478 identifiers supported by GNAT, and also the format of
16479 the restrictions provided in package System.Restrictions.
16480 It is not normally necessary to @code{with} this generic package
16481 since the necessary instantiation is included in
16482 package System.Restrictions.
16484 @node System.Strings.Stream_Ops (s-ststop.ads)
16485 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
16486 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
16487 @cindex Stream operations
16488 @cindex String stream operations
16491 This package provides a set of stream subprograms for standard string types.
16492 It is intended primarily to support implicit use of such subprograms when
16493 stream attributes are applied to string types, but the subprograms in this
16494 package can be used directly by application programs.
16496 @node System.Task_Info (s-tasinf.ads)
16497 @section @code{System.Task_Info} (@file{s-tasinf.ads})
16498 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
16499 @cindex Task_Info pragma
16502 This package provides target dependent functionality that is used
16503 to support the @code{Task_Info} pragma
16505 @node System.Wch_Cnv (s-wchcnv.ads)
16506 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
16507 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
16508 @cindex Wide Character, Representation
16509 @cindex Wide String, Conversion
16510 @cindex Representation of wide characters
16513 This package provides routines for converting between
16514 wide and wide wide characters and a representation as a value of type
16515 @code{Standard.String}, using a specified wide character
16516 encoding method. It uses definitions in
16517 package @code{System.Wch_Con}.
16519 @node System.Wch_Con (s-wchcon.ads)
16520 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
16521 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
16524 This package provides definitions and descriptions of
16525 the various methods used for encoding wide characters
16526 in ordinary strings. These definitions are used by
16527 the package @code{System.Wch_Cnv}.
16529 @node Interfacing to Other Languages
16530 @chapter Interfacing to Other Languages
16532 The facilities in annex B of the Ada Reference Manual are fully
16533 implemented in GNAT, and in addition, a full interface to C++ is
16537 * Interfacing to C::
16538 * Interfacing to C++::
16539 * Interfacing to COBOL::
16540 * Interfacing to Fortran::
16541 * Interfacing to non-GNAT Ada code::
16544 @node Interfacing to C
16545 @section Interfacing to C
16548 Interfacing to C with GNAT can use one of two approaches:
16552 The types in the package @code{Interfaces.C} may be used.
16554 Standard Ada types may be used directly. This may be less portable to
16555 other compilers, but will work on all GNAT compilers, which guarantee
16556 correspondence between the C and Ada types.
16560 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
16561 effect, since this is the default. The following table shows the
16562 correspondence between Ada scalar types and the corresponding C types.
16567 @item Short_Integer
16569 @item Short_Short_Integer
16573 @item Long_Long_Integer
16581 @item Long_Long_Float
16582 This is the longest floating-point type supported by the hardware.
16586 Additionally, there are the following general correspondences between Ada
16590 Ada enumeration types map to C enumeration types directly if pragma
16591 @code{Convention C} is specified, which causes them to have int
16592 length. Without pragma @code{Convention C}, Ada enumeration types map to
16593 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
16594 @code{int}, respectively) depending on the number of values passed.
16595 This is the only case in which pragma @code{Convention C} affects the
16596 representation of an Ada type.
16599 Ada access types map to C pointers, except for the case of pointers to
16600 unconstrained types in Ada, which have no direct C equivalent.
16603 Ada arrays map directly to C arrays.
16606 Ada records map directly to C structures.
16609 Packed Ada records map to C structures where all members are bit fields
16610 of the length corresponding to the @code{@var{type}'Size} value in Ada.
16613 @node Interfacing to C++
16614 @section Interfacing to C++
16617 The interface to C++ makes use of the following pragmas, which are
16618 primarily intended to be constructed automatically using a binding generator
16619 tool, although it is possible to construct them by hand.
16621 Using these pragmas it is possible to achieve complete
16622 inter-operability between Ada tagged types and C++ class definitions.
16623 See @ref{Implementation Defined Pragmas}, for more details.
16626 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
16627 The argument denotes an entity in the current declarative region that is
16628 declared as a tagged or untagged record type. It indicates that the type
16629 corresponds to an externally declared C++ class type, and is to be laid
16630 out the same way that C++ would lay out the type.
16632 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
16633 for backward compatibility but its functionality is available
16634 using pragma @code{Import} with @code{Convention} = @code{CPP}.
16636 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
16637 This pragma identifies an imported function (imported in the usual way
16638 with pragma @code{Import}) as corresponding to a C++ constructor.
16641 In addition, C++ exceptions are propagated and can be handled in an
16642 @code{others} choice of an exception handler. The corresponding Ada
16643 occurrence has no message, and the simple name of the exception identity
16644 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
16645 tasks works properly when such foreign exceptions are propagated.
16647 @node Interfacing to COBOL
16648 @section Interfacing to COBOL
16651 Interfacing to COBOL is achieved as described in section B.4 of
16652 the Ada Reference Manual.
16654 @node Interfacing to Fortran
16655 @section Interfacing to Fortran
16658 Interfacing to Fortran is achieved as described in section B.5 of the
16659 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
16660 multi-dimensional array causes the array to be stored in column-major
16661 order as required for convenient interface to Fortran.
16663 @node Interfacing to non-GNAT Ada code
16664 @section Interfacing to non-GNAT Ada code
16666 It is possible to specify the convention @code{Ada} in a pragma
16667 @code{Import} or pragma @code{Export}. However this refers to
16668 the calling conventions used by GNAT, which may or may not be
16669 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
16670 compiler to allow interoperation.
16672 If arguments types are kept simple, and if the foreign compiler generally
16673 follows system calling conventions, then it may be possible to integrate
16674 files compiled by other Ada compilers, provided that the elaboration
16675 issues are adequately addressed (for example by eliminating the
16676 need for any load time elaboration).
16678 In particular, GNAT running on VMS is designed to
16679 be highly compatible with the DEC Ada 83 compiler, so this is one
16680 case in which it is possible to import foreign units of this type,
16681 provided that the data items passed are restricted to simple scalar
16682 values or simple record types without variants, or simple array
16683 types with fixed bounds.
16685 @node Specialized Needs Annexes
16686 @chapter Specialized Needs Annexes
16689 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
16690 required in all implementations. However, as described in this chapter,
16691 GNAT implements all of these annexes:
16694 @item Systems Programming (Annex C)
16695 The Systems Programming Annex is fully implemented.
16697 @item Real-Time Systems (Annex D)
16698 The Real-Time Systems Annex is fully implemented.
16700 @item Distributed Systems (Annex E)
16701 Stub generation is fully implemented in the GNAT compiler. In addition,
16702 a complete compatible PCS is available as part of the GLADE system,
16703 a separate product. When the two
16704 products are used in conjunction, this annex is fully implemented.
16706 @item Information Systems (Annex F)
16707 The Information Systems annex is fully implemented.
16709 @item Numerics (Annex G)
16710 The Numerics Annex is fully implemented.
16712 @item Safety and Security / High-Integrity Systems (Annex H)
16713 The Safety and Security Annex (termed the High-Integrity Systems Annex
16714 in Ada 2005) is fully implemented.
16717 @node Implementation of Specific Ada Features
16718 @chapter Implementation of Specific Ada Features
16721 This chapter describes the GNAT implementation of several Ada language
16725 * Machine Code Insertions::
16726 * GNAT Implementation of Tasking::
16727 * GNAT Implementation of Shared Passive Packages::
16728 * Code Generation for Array Aggregates::
16729 * The Size of Discriminated Records with Default Discriminants::
16730 * Strict Conformance to the Ada Reference Manual::
16733 @node Machine Code Insertions
16734 @section Machine Code Insertions
16735 @cindex Machine Code insertions
16738 Package @code{Machine_Code} provides machine code support as described
16739 in the Ada Reference Manual in two separate forms:
16742 Machine code statements, consisting of qualified expressions that
16743 fit the requirements of RM section 13.8.
16745 An intrinsic callable procedure, providing an alternative mechanism of
16746 including machine instructions in a subprogram.
16750 The two features are similar, and both are closely related to the mechanism
16751 provided by the asm instruction in the GNU C compiler. Full understanding
16752 and use of the facilities in this package requires understanding the asm
16753 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
16754 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
16756 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
16757 semantic restrictions and effects as described below. Both are provided so
16758 that the procedure call can be used as a statement, and the function call
16759 can be used to form a code_statement.
16761 The first example given in the GCC documentation is the C @code{asm}
16764 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
16768 The equivalent can be written for GNAT as:
16770 @smallexample @c ada
16771 Asm ("fsinx %1 %0",
16772 My_Float'Asm_Output ("=f", result),
16773 My_Float'Asm_Input ("f", angle));
16777 The first argument to @code{Asm} is the assembler template, and is
16778 identical to what is used in GNU C@. This string must be a static
16779 expression. The second argument is the output operand list. It is
16780 either a single @code{Asm_Output} attribute reference, or a list of such
16781 references enclosed in parentheses (technically an array aggregate of
16784 The @code{Asm_Output} attribute denotes a function that takes two
16785 parameters. The first is a string, the second is the name of a variable
16786 of the type designated by the attribute prefix. The first (string)
16787 argument is required to be a static expression and designates the
16788 constraint for the parameter (e.g.@: what kind of register is
16789 required). The second argument is the variable to be updated with the
16790 result. The possible values for constraint are the same as those used in
16791 the RTL, and are dependent on the configuration file used to build the
16792 GCC back end. If there are no output operands, then this argument may
16793 either be omitted, or explicitly given as @code{No_Output_Operands}.
16795 The second argument of @code{@var{my_float}'Asm_Output} functions as
16796 though it were an @code{out} parameter, which is a little curious, but
16797 all names have the form of expressions, so there is no syntactic
16798 irregularity, even though normally functions would not be permitted
16799 @code{out} parameters. The third argument is the list of input
16800 operands. It is either a single @code{Asm_Input} attribute reference, or
16801 a list of such references enclosed in parentheses (technically an array
16802 aggregate of such references).
16804 The @code{Asm_Input} attribute denotes a function that takes two
16805 parameters. The first is a string, the second is an expression of the
16806 type designated by the prefix. The first (string) argument is required
16807 to be a static expression, and is the constraint for the parameter,
16808 (e.g.@: what kind of register is required). The second argument is the
16809 value to be used as the input argument. The possible values for the
16810 constant are the same as those used in the RTL, and are dependent on
16811 the configuration file used to built the GCC back end.
16813 If there are no input operands, this argument may either be omitted, or
16814 explicitly given as @code{No_Input_Operands}. The fourth argument, not
16815 present in the above example, is a list of register names, called the
16816 @dfn{clobber} argument. This argument, if given, must be a static string
16817 expression, and is a space or comma separated list of names of registers
16818 that must be considered destroyed as a result of the @code{Asm} call. If
16819 this argument is the null string (the default value), then the code
16820 generator assumes that no additional registers are destroyed.
16822 The fifth argument, not present in the above example, called the
16823 @dfn{volatile} argument, is by default @code{False}. It can be set to
16824 the literal value @code{True} to indicate to the code generator that all
16825 optimizations with respect to the instruction specified should be
16826 suppressed, and that in particular, for an instruction that has outputs,
16827 the instruction will still be generated, even if none of the outputs are
16828 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
16829 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
16830 Generally it is strongly advisable to use Volatile for any ASM statement
16831 that is missing either input or output operands, or when two or more ASM
16832 statements appear in sequence, to avoid unwanted optimizations. A warning
16833 is generated if this advice is not followed.
16835 The @code{Asm} subprograms may be used in two ways. First the procedure
16836 forms can be used anywhere a procedure call would be valid, and
16837 correspond to what the RM calls ``intrinsic'' routines. Such calls can
16838 be used to intersperse machine instructions with other Ada statements.
16839 Second, the function forms, which return a dummy value of the limited
16840 private type @code{Asm_Insn}, can be used in code statements, and indeed
16841 this is the only context where such calls are allowed. Code statements
16842 appear as aggregates of the form:
16844 @smallexample @c ada
16845 Asm_Insn'(Asm (@dots{}));
16846 Asm_Insn'(Asm_Volatile (@dots{}));
16850 In accordance with RM rules, such code statements are allowed only
16851 within subprograms whose entire body consists of such statements. It is
16852 not permissible to intermix such statements with other Ada statements.
16854 Typically the form using intrinsic procedure calls is more convenient
16855 and more flexible. The code statement form is provided to meet the RM
16856 suggestion that such a facility should be made available. The following
16857 is the exact syntax of the call to @code{Asm}. As usual, if named notation
16858 is used, the arguments may be given in arbitrary order, following the
16859 normal rules for use of positional and named arguments)
16863 [Template =>] static_string_EXPRESSION
16864 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
16865 [,[Inputs =>] INPUT_OPERAND_LIST ]
16866 [,[Clobber =>] static_string_EXPRESSION ]
16867 [,[Volatile =>] static_boolean_EXPRESSION] )
16869 OUTPUT_OPERAND_LIST ::=
16870 [PREFIX.]No_Output_Operands
16871 | OUTPUT_OPERAND_ATTRIBUTE
16872 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
16874 OUTPUT_OPERAND_ATTRIBUTE ::=
16875 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
16877 INPUT_OPERAND_LIST ::=
16878 [PREFIX.]No_Input_Operands
16879 | INPUT_OPERAND_ATTRIBUTE
16880 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
16882 INPUT_OPERAND_ATTRIBUTE ::=
16883 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
16887 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
16888 are declared in the package @code{Machine_Code} and must be referenced
16889 according to normal visibility rules. In particular if there is no
16890 @code{use} clause for this package, then appropriate package name
16891 qualification is required.
16893 @node GNAT Implementation of Tasking
16894 @section GNAT Implementation of Tasking
16897 This chapter outlines the basic GNAT approach to tasking (in particular,
16898 a multi-layered library for portability) and discusses issues related
16899 to compliance with the Real-Time Systems Annex.
16902 * Mapping Ada Tasks onto the Underlying Kernel Threads::
16903 * Ensuring Compliance with the Real-Time Annex::
16906 @node Mapping Ada Tasks onto the Underlying Kernel Threads
16907 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
16910 GNAT's run-time support comprises two layers:
16913 @item GNARL (GNAT Run-time Layer)
16914 @item GNULL (GNAT Low-level Library)
16918 In GNAT, Ada's tasking services rely on a platform and OS independent
16919 layer known as GNARL@. This code is responsible for implementing the
16920 correct semantics of Ada's task creation, rendezvous, protected
16923 GNARL decomposes Ada's tasking semantics into simpler lower level
16924 operations such as create a thread, set the priority of a thread,
16925 yield, create a lock, lock/unlock, etc. The spec for these low-level
16926 operations constitutes GNULLI, the GNULL Interface. This interface is
16927 directly inspired from the POSIX real-time API@.
16929 If the underlying executive or OS implements the POSIX standard
16930 faithfully, the GNULL Interface maps as is to the services offered by
16931 the underlying kernel. Otherwise, some target dependent glue code maps
16932 the services offered by the underlying kernel to the semantics expected
16935 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
16936 key point is that each Ada task is mapped on a thread in the underlying
16937 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
16939 In addition Ada task priorities map onto the underlying thread priorities.
16940 Mapping Ada tasks onto the underlying kernel threads has several advantages:
16944 The underlying scheduler is used to schedule the Ada tasks. This
16945 makes Ada tasks as efficient as kernel threads from a scheduling
16949 Interaction with code written in C containing threads is eased
16950 since at the lowest level Ada tasks and C threads map onto the same
16951 underlying kernel concept.
16954 When an Ada task is blocked during I/O the remaining Ada tasks are
16958 On multiprocessor systems Ada tasks can execute in parallel.
16962 Some threads libraries offer a mechanism to fork a new process, with the
16963 child process duplicating the threads from the parent.
16965 support this functionality when the parent contains more than one task.
16966 @cindex Forking a new process
16968 @node Ensuring Compliance with the Real-Time Annex
16969 @subsection Ensuring Compliance with the Real-Time Annex
16970 @cindex Real-Time Systems Annex compliance
16973 Although mapping Ada tasks onto
16974 the underlying threads has significant advantages, it does create some
16975 complications when it comes to respecting the scheduling semantics
16976 specified in the real-time annex (Annex D).
16978 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
16979 scheduling policy states:
16982 @emph{When the active priority of a ready task that is not running
16983 changes, or the setting of its base priority takes effect, the
16984 task is removed from the ready queue for its old active priority
16985 and is added at the tail of the ready queue for its new active
16986 priority, except in the case where the active priority is lowered
16987 due to the loss of inherited priority, in which case the task is
16988 added at the head of the ready queue for its new active priority.}
16992 While most kernels do put tasks at the end of the priority queue when
16993 a task changes its priority, (which respects the main
16994 FIFO_Within_Priorities requirement), almost none keep a thread at the
16995 beginning of its priority queue when its priority drops from the loss
16996 of inherited priority.
16998 As a result most vendors have provided incomplete Annex D implementations.
17000 The GNAT run-time, has a nice cooperative solution to this problem
17001 which ensures that accurate FIFO_Within_Priorities semantics are
17004 The principle is as follows. When an Ada task T is about to start
17005 running, it checks whether some other Ada task R with the same
17006 priority as T has been suspended due to the loss of priority
17007 inheritance. If this is the case, T yields and is placed at the end of
17008 its priority queue. When R arrives at the front of the queue it
17011 Note that this simple scheme preserves the relative order of the tasks
17012 that were ready to execute in the priority queue where R has been
17015 @node GNAT Implementation of Shared Passive Packages
17016 @section GNAT Implementation of Shared Passive Packages
17017 @cindex Shared passive packages
17020 GNAT fully implements the pragma @code{Shared_Passive} for
17021 @cindex pragma @code{Shared_Passive}
17022 the purpose of designating shared passive packages.
17023 This allows the use of passive partitions in the
17024 context described in the Ada Reference Manual; i.e., for communication
17025 between separate partitions of a distributed application using the
17026 features in Annex E.
17028 @cindex Distribution Systems Annex
17030 However, the implementation approach used by GNAT provides for more
17031 extensive usage as follows:
17034 @item Communication between separate programs
17036 This allows separate programs to access the data in passive
17037 partitions, using protected objects for synchronization where
17038 needed. The only requirement is that the two programs have a
17039 common shared file system. It is even possible for programs
17040 running on different machines with different architectures
17041 (e.g.@: different endianness) to communicate via the data in
17042 a passive partition.
17044 @item Persistence between program runs
17046 The data in a passive package can persist from one run of a
17047 program to another, so that a later program sees the final
17048 values stored by a previous run of the same program.
17053 The implementation approach used is to store the data in files. A
17054 separate stream file is created for each object in the package, and
17055 an access to an object causes the corresponding file to be read or
17058 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
17059 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
17060 set to the directory to be used for these files.
17061 The files in this directory
17062 have names that correspond to their fully qualified names. For
17063 example, if we have the package
17065 @smallexample @c ada
17067 pragma Shared_Passive (X);
17074 and the environment variable is set to @code{/stemp/}, then the files created
17075 will have the names:
17083 These files are created when a value is initially written to the object, and
17084 the files are retained until manually deleted. This provides the persistence
17085 semantics. If no file exists, it means that no partition has assigned a value
17086 to the variable; in this case the initial value declared in the package
17087 will be used. This model ensures that there are no issues in synchronizing
17088 the elaboration process, since elaboration of passive packages elaborates the
17089 initial values, but does not create the files.
17091 The files are written using normal @code{Stream_IO} access.
17092 If you want to be able
17093 to communicate between programs or partitions running on different
17094 architectures, then you should use the XDR versions of the stream attribute
17095 routines, since these are architecture independent.
17097 If active synchronization is required for access to the variables in the
17098 shared passive package, then as described in the Ada Reference Manual, the
17099 package may contain protected objects used for this purpose. In this case
17100 a lock file (whose name is @file{___lock} (three underscores)
17101 is created in the shared memory directory.
17102 @cindex @file{___lock} file (for shared passive packages)
17103 This is used to provide the required locking
17104 semantics for proper protected object synchronization.
17106 As of January 2003, GNAT supports shared passive packages on all platforms
17107 except for OpenVMS.
17109 @node Code Generation for Array Aggregates
17110 @section Code Generation for Array Aggregates
17113 * Static constant aggregates with static bounds::
17114 * Constant aggregates with unconstrained nominal types::
17115 * Aggregates with static bounds::
17116 * Aggregates with non-static bounds::
17117 * Aggregates in assignment statements::
17121 Aggregates have a rich syntax and allow the user to specify the values of
17122 complex data structures by means of a single construct. As a result, the
17123 code generated for aggregates can be quite complex and involve loops, case
17124 statements and multiple assignments. In the simplest cases, however, the
17125 compiler will recognize aggregates whose components and constraints are
17126 fully static, and in those cases the compiler will generate little or no
17127 executable code. The following is an outline of the code that GNAT generates
17128 for various aggregate constructs. For further details, you will find it
17129 useful to examine the output produced by the -gnatG flag to see the expanded
17130 source that is input to the code generator. You may also want to examine
17131 the assembly code generated at various levels of optimization.
17133 The code generated for aggregates depends on the context, the component values,
17134 and the type. In the context of an object declaration the code generated is
17135 generally simpler than in the case of an assignment. As a general rule, static
17136 component values and static subtypes also lead to simpler code.
17138 @node Static constant aggregates with static bounds
17139 @subsection Static constant aggregates with static bounds
17142 For the declarations:
17143 @smallexample @c ada
17144 type One_Dim is array (1..10) of integer;
17145 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
17149 GNAT generates no executable code: the constant ar0 is placed in static memory.
17150 The same is true for constant aggregates with named associations:
17152 @smallexample @c ada
17153 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
17154 Cr3 : constant One_Dim := (others => 7777);
17158 The same is true for multidimensional constant arrays such as:
17160 @smallexample @c ada
17161 type two_dim is array (1..3, 1..3) of integer;
17162 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
17166 The same is true for arrays of one-dimensional arrays: the following are
17169 @smallexample @c ada
17170 type ar1b is array (1..3) of boolean;
17171 type ar_ar is array (1..3) of ar1b;
17172 None : constant ar1b := (others => false); -- fully static
17173 None2 : constant ar_ar := (1..3 => None); -- fully static
17177 However, for multidimensional aggregates with named associations, GNAT will
17178 generate assignments and loops, even if all associations are static. The
17179 following two declarations generate a loop for the first dimension, and
17180 individual component assignments for the second dimension:
17182 @smallexample @c ada
17183 Zero1: constant two_dim := (1..3 => (1..3 => 0));
17184 Zero2: constant two_dim := (others => (others => 0));
17187 @node Constant aggregates with unconstrained nominal types
17188 @subsection Constant aggregates with unconstrained nominal types
17191 In such cases the aggregate itself establishes the subtype, so that
17192 associations with @code{others} cannot be used. GNAT determines the
17193 bounds for the actual subtype of the aggregate, and allocates the
17194 aggregate statically as well. No code is generated for the following:
17196 @smallexample @c ada
17197 type One_Unc is array (natural range <>) of integer;
17198 Cr_Unc : constant One_Unc := (12,24,36);
17201 @node Aggregates with static bounds
17202 @subsection Aggregates with static bounds
17205 In all previous examples the aggregate was the initial (and immutable) value
17206 of a constant. If the aggregate initializes a variable, then code is generated
17207 for it as a combination of individual assignments and loops over the target
17208 object. The declarations
17210 @smallexample @c ada
17211 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
17212 Cr_Var2 : One_Dim := (others > -1);
17216 generate the equivalent of
17218 @smallexample @c ada
17224 for I in Cr_Var2'range loop
17229 @node Aggregates with non-static bounds
17230 @subsection Aggregates with non-static bounds
17233 If the bounds of the aggregate are not statically compatible with the bounds
17234 of the nominal subtype of the target, then constraint checks have to be
17235 generated on the bounds. For a multidimensional array, constraint checks may
17236 have to be applied to sub-arrays individually, if they do not have statically
17237 compatible subtypes.
17239 @node Aggregates in assignment statements
17240 @subsection Aggregates in assignment statements
17243 In general, aggregate assignment requires the construction of a temporary,
17244 and a copy from the temporary to the target of the assignment. This is because
17245 it is not always possible to convert the assignment into a series of individual
17246 component assignments. For example, consider the simple case:
17248 @smallexample @c ada
17253 This cannot be converted into:
17255 @smallexample @c ada
17261 So the aggregate has to be built first in a separate location, and then
17262 copied into the target. GNAT recognizes simple cases where this intermediate
17263 step is not required, and the assignments can be performed in place, directly
17264 into the target. The following sufficient criteria are applied:
17268 The bounds of the aggregate are static, and the associations are static.
17270 The components of the aggregate are static constants, names of
17271 simple variables that are not renamings, or expressions not involving
17272 indexed components whose operands obey these rules.
17276 If any of these conditions are violated, the aggregate will be built in
17277 a temporary (created either by the front-end or the code generator) and then
17278 that temporary will be copied onto the target.
17280 @node The Size of Discriminated Records with Default Discriminants
17281 @section The Size of Discriminated Records with Default Discriminants
17284 If a discriminated type @code{T} has discriminants with default values, it is
17285 possible to declare an object of this type without providing an explicit
17288 @smallexample @c ada
17290 type Size is range 1..100;
17292 type Rec (D : Size := 15) is record
17293 Name : String (1..D);
17301 Such an object is said to be @emph{unconstrained}.
17302 The discriminant of the object
17303 can be modified by a full assignment to the object, as long as it preserves the
17304 relation between the value of the discriminant, and the value of the components
17307 @smallexample @c ada
17309 Word := (3, "yes");
17311 Word := (5, "maybe");
17313 Word := (5, "no"); -- raises Constraint_Error
17318 In order to support this behavior efficiently, an unconstrained object is
17319 given the maximum size that any value of the type requires. In the case
17320 above, @code{Word} has storage for the discriminant and for
17321 a @code{String} of length 100.
17322 It is important to note that unconstrained objects do not require dynamic
17323 allocation. It would be an improper implementation to place on the heap those
17324 components whose size depends on discriminants. (This improper implementation
17325 was used by some Ada83 compilers, where the @code{Name} component above
17327 been stored as a pointer to a dynamic string). Following the principle that
17328 dynamic storage management should never be introduced implicitly,
17329 an Ada compiler should reserve the full size for an unconstrained declared
17330 object, and place it on the stack.
17332 This maximum size approach
17333 has been a source of surprise to some users, who expect the default
17334 values of the discriminants to determine the size reserved for an
17335 unconstrained object: ``If the default is 15, why should the object occupy
17337 The answer, of course, is that the discriminant may be later modified,
17338 and its full range of values must be taken into account. This is why the
17343 type Rec (D : Positive := 15) is record
17344 Name : String (1..D);
17352 is flagged by the compiler with a warning:
17353 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
17354 because the required size includes @code{Positive'Last}
17355 bytes. As the first example indicates, the proper approach is to declare an
17356 index type of ``reasonable'' range so that unconstrained objects are not too
17359 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
17360 created in the heap by means of an allocator, then it is @emph{not}
17362 it is constrained by the default values of the discriminants, and those values
17363 cannot be modified by full assignment. This is because in the presence of
17364 aliasing all views of the object (which may be manipulated by different tasks,
17365 say) must be consistent, so it is imperative that the object, once created,
17368 @node Strict Conformance to the Ada Reference Manual
17369 @section Strict Conformance to the Ada Reference Manual
17372 The dynamic semantics defined by the Ada Reference Manual impose a set of
17373 run-time checks to be generated. By default, the GNAT compiler will insert many
17374 run-time checks into the compiled code, including most of those required by the
17375 Ada Reference Manual. However, there are three checks that are not enabled
17376 in the default mode for efficiency reasons: arithmetic overflow checking for
17377 integer operations (including division by zero), checks for access before
17378 elaboration on subprogram calls, and stack overflow checking (most operating
17379 systems do not perform this check by default).
17381 Strict conformance to the Ada Reference Manual can be achieved by adding
17382 three compiler options for overflow checking for integer operations
17383 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
17384 calls and generic instantiations (@option{-gnatE}), and stack overflow
17385 checking (@option{-fstack-check}).
17387 Note that the result of a floating point arithmetic operation in overflow and
17388 invalid situations, when the @code{Machine_Overflows} attribute of the result
17389 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
17390 case for machines compliant with the IEEE floating-point standard, but on
17391 machines that are not fully compliant with this standard, such as Alpha, the
17392 @option{-mieee} compiler flag must be used for achieving IEEE confirming
17393 behavior (although at the cost of a significant performance penalty), so
17394 infinite and NaN values are properly generated.
17397 @node Implementation of Ada 2012 Features
17398 @chapter Implementation of Ada 2012 Features
17399 @cindex Ada 2012 implementation status
17401 This chapter contains a complete list of Ada 2012 features that have been
17402 implemented as of GNAT version 6.4. Generally, these features are only
17403 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
17404 @cindex @option{-gnat12} option
17405 or if the configuration pragma @code{Ada_2012} is used.
17406 @cindex pragma @code{Ada_2012}
17407 @cindex configuration pragma @code{Ada_2012}
17408 @cindex @code{Ada_2012} configuration pragma
17409 However, new pragmas, attributes, and restrictions are
17410 unconditionally available, since the Ada 95 standard allows the addition of
17411 new pragmas, attributes, and restrictions (there are exceptions, which are
17412 documented in the individual descriptions), and also certain packages
17413 were made available in earlier versions of Ada.
17415 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
17416 This date shows the implementation date of the feature. Any wavefront
17417 subsequent to this date will contain the indicated feature, as will any
17418 subsequent releases. A date of 0000-00-00 means that GNAT has always
17419 implemented the feature, or implemented it as soon as it appeared as a
17420 binding interpretation.
17422 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
17423 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
17424 The features are ordered based on the relevant sections of the Ada
17425 Reference Manual (``RM''). When a given AI relates to multiple points
17426 in the RM, the earliest is used.
17428 A complete description of the AIs may be found in
17429 @url{www.ada-auth.org/ai05-summary.html}.
17434 @emph{AI-0176 Quantified expressions (2010-09-29)}
17435 @cindex AI-0176 (Ada 2012 feature)
17438 Both universally and existentially quantified expressions are implemented.
17439 They use the new syntax for iterators proposed in AI05-139-2, as well as
17440 the standard Ada loop syntax.
17443 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
17446 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
17447 @cindex AI-0079 (Ada 2012 feature)
17450 Wide characters in the unicode category @i{other_format} are now allowed in
17451 source programs between tokens, but not within a token such as an identifier.
17454 RM References: 2.01 (4/2) 2.02 (7)
17457 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
17458 @cindex AI-0091 (Ada 2012 feature)
17461 Wide characters in the unicode category @i{other_format} are not permitted
17462 within an identifier, since this can be a security problem. The error
17463 message for this case has been improved to be more specific, but GNAT has
17464 never allowed such characters to appear in identifiers.
17467 RM References: 2.03 (3.1/2) 2.03 (4/2) 2.03 (5/2) 2.03 (5.1/2) 2.03 (5.2/2) 2.03 (5.3/2) 2.09 (2/2)
17470 @emph{AI-0100 Placement of pragmas (2010-07-01)}
17471 @cindex AI-0100 (Ada 2012 feature)
17474 This AI is an earlier version of AI-163. It simplifies the rules
17475 for legal placement of pragmas. In the case of lists that allow pragmas, if
17476 the list may have no elements, then the list may consist solely of pragmas.
17479 RM References: 2.08 (7)
17482 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
17483 @cindex AI-0163 (Ada 2012 feature)
17486 A statement sequence may be composed entirely of pragmas. It is no longer
17487 necessary to add a dummy @code{null} statement to make the sequence legal.
17490 RM References: 2.08 (7) 2.08 (16)
17494 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
17495 @cindex AI-0080 (Ada 2012 feature)
17498 This is an editorial change only, described as non-testable in the AI.
17501 RM References: 3.01 (7)
17505 @emph{AI-0183 Aspect specifications (2010-08-16)}
17506 @cindex AI-0183 (Ada 2012 feature)
17509 Aspect specifications have been fully implemented except for pre and post-
17510 conditions, and type invariants, which have their own separate AI's. All
17511 forms of declarations listed in the AI are supported. The following is a
17512 list of the aspects supported (with GNAT implementation aspects marked)
17514 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
17515 @item @code{Ada_2005} @tab -- GNAT
17516 @item @code{Ada_2012} @tab -- GNAT
17517 @item @code{Address} @tab
17518 @item @code{Alignment} @tab
17519 @item @code{Atomic} @tab
17520 @item @code{Atomic_Components} @tab
17521 @item @code{Bit_Order} @tab
17522 @item @code{Component_Size} @tab
17523 @item @code{Contract_Case} @tab -- GNAT
17524 @item @code{Discard_Names} @tab
17525 @item @code{External_Tag} @tab
17526 @item @code{Favor_Top_Level} @tab -- GNAT
17527 @item @code{Inline} @tab
17528 @item @code{Inline_Always} @tab -- GNAT
17529 @item @code{Invariant} @tab -- GNAT
17530 @item @code{Machine_Radix} @tab
17531 @item @code{No_Return} @tab
17532 @item @code{Object_Size} @tab -- GNAT
17533 @item @code{Pack} @tab
17534 @item @code{Persistent_BSS} @tab -- GNAT
17535 @item @code{Post} @tab
17536 @item @code{Pre} @tab
17537 @item @code{Predicate} @tab
17538 @item @code{Preelaborable_Initialization} @tab
17539 @item @code{Pure_Function} @tab -- GNAT
17540 @item @code{Remote_Access_Type} @tab -- GNAT
17541 @item @code{Shared} @tab -- GNAT
17542 @item @code{Size} @tab
17543 @item @code{Storage_Pool} @tab
17544 @item @code{Storage_Size} @tab
17545 @item @code{Stream_Size} @tab
17546 @item @code{Suppress} @tab
17547 @item @code{Suppress_Debug_Info} @tab -- GNAT
17548 @item @code{Test_Case} @tab -- GNAT
17549 @item @code{Type_Invariant} @tab
17550 @item @code{Unchecked_Union} @tab
17551 @item @code{Universal_Aliasing} @tab -- GNAT
17552 @item @code{Unmodified} @tab -- GNAT
17553 @item @code{Unreferenced} @tab -- GNAT
17554 @item @code{Unreferenced_Objects} @tab -- GNAT
17555 @item @code{Unsuppress} @tab
17556 @item @code{Value_Size} @tab -- GNAT
17557 @item @code{Volatile} @tab
17558 @item @code{Volatile_Components}
17559 @item @code{Warnings} @tab -- GNAT
17563 Note that for aspects with an expression, e.g. @code{Size}, the expression is
17564 treated like a default expression (visibility is analyzed at the point of
17565 occurrence of the aspect, but evaluation of the expression occurs at the
17566 freeze point of the entity involved.
17569 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
17570 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
17571 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
17572 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
17573 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
17578 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
17579 @cindex AI-0128 (Ada 2012 feature)
17582 If an equality operator ("=") is declared for a type, then the implicitly
17583 declared inequality operator ("/=") is a primitive operation of the type.
17584 This is the only reasonable interpretation, and is the one always implemented
17585 by GNAT, but the RM was not entirely clear in making this point.
17588 RM References: 3.02.03 (6) 6.06 (6)
17591 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
17592 @cindex AI-0003 (Ada 2012 feature)
17595 In Ada 2012, a qualified expression is considered to be syntactically a name,
17596 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
17597 useful in disambiguating some cases of overloading.
17600 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
17604 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
17605 @cindex AI-0120 (Ada 2012 feature)
17608 This is an RM editorial change only. The section that lists objects that are
17609 constant failed to include the current instance of a protected object
17610 within a protected function. This has always been treated as a constant
17614 RM References: 3.03 (21)
17617 @emph{AI-0008 General access to constrained objects (0000-00-00)}
17618 @cindex AI-0008 (Ada 2012 feature)
17621 The wording in the RM implied that if you have a general access to a
17622 constrained object, it could be used to modify the discriminants. This was
17623 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
17624 has always done so in this situation.
17627 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
17631 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
17632 @cindex AI-0093 (Ada 2012 feature)
17635 This is an editorial change only, to make more widespread use of the Ada 2012
17636 ``immutably limited''.
17639 RM References: 3.03 (23.4/3)
17644 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
17645 @cindex AI-0096 (Ada 2012 feature)
17648 In general it is illegal for a type derived from a formal limited type to be
17649 nonlimited. This AI makes an exception to this rule: derivation is legal
17650 if it appears in the private part of the generic, and the formal type is not
17651 tagged. If the type is tagged, the legality check must be applied to the
17652 private part of the package.
17655 RM References: 3.04 (5.1/2) 6.02 (7)
17659 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
17660 @cindex AI-0181 (Ada 2012 feature)
17663 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
17664 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
17665 @code{Image} and @code{Value} attributes for the character types. Strictly
17666 speaking this is an inconsistency with Ada 95, but in practice the use of
17667 these attributes is so obscure that it will not cause problems.
17670 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
17674 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
17675 @cindex AI-0182 (Ada 2012 feature)
17678 This AI allows @code{Character'Value} to accept the string @code{'?'} where
17679 @code{?} is any character including non-graphic control characters. GNAT has
17680 always accepted such strings. It also allows strings such as
17681 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
17682 permission and raises @code{Constraint_Error}, as is certainly still
17686 RM References: 3.05 (56/2)
17690 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
17691 @cindex AI-0214 (Ada 2012 feature)
17694 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
17695 to have default expressions by allowing them when the type is limited. It
17696 is often useful to define a default value for a discriminant even though
17697 it can't be changed by assignment.
17700 RM References: 3.07 (9.1/2) 3.07.02 (3)
17704 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
17705 @cindex AI-0102 (Ada 2012 feature)
17708 It is illegal to assign an anonymous access constant to an anonymous access
17709 variable. The RM did not have a clear rule to prevent this, but GNAT has
17710 always generated an error for this usage.
17713 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
17717 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
17718 @cindex AI-0158 (Ada 2012 feature)
17721 This AI extends the syntax of membership tests to simplify complex conditions
17722 that can be expressed as membership in a subset of values of any type. It
17723 introduces syntax for a list of expressions that may be used in loop contexts
17727 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
17731 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
17732 @cindex AI-0173 (Ada 2012 feature)
17735 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
17736 with the tag of an abstract type, and @code{False} otherwise.
17739 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
17744 @emph{AI-0076 function with controlling result (0000-00-00)}
17745 @cindex AI-0076 (Ada 2012 feature)
17748 This is an editorial change only. The RM defines calls with controlling
17749 results, but uses the term ``function with controlling result'' without an
17750 explicit definition.
17753 RM References: 3.09.02 (2/2)
17757 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
17758 @cindex AI-0126 (Ada 2012 feature)
17761 This AI clarifies dispatching rules, and simply confirms that dispatching
17762 executes the operation of the parent type when there is no explicitly or
17763 implicitly declared operation for the descendant type. This has always been
17764 the case in all versions of GNAT.
17767 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
17771 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
17772 @cindex AI-0097 (Ada 2012 feature)
17775 The RM as written implied that in some cases it was possible to create an
17776 object of an abstract type, by having an abstract extension inherit a non-
17777 abstract constructor from its parent type. This mistake has been corrected
17778 in GNAT and in the RM, and this construct is now illegal.
17781 RM References: 3.09.03 (4/2)
17785 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
17786 @cindex AI-0203 (Ada 2012 feature)
17789 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
17790 permitted such usage.
17793 RM References: 3.09.03 (8/3)
17797 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
17798 @cindex AI-0198 (Ada 2012 feature)
17801 This AI resolves a conflict between two rules involving inherited abstract
17802 operations and predefined operators. If a derived numeric type inherits
17803 an abstract operator, it overrides the predefined one. This interpretation
17804 was always the one implemented in GNAT.
17807 RM References: 3.09.03 (4/3)
17810 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
17811 @cindex AI-0073 (Ada 2012 feature)
17814 This AI covers a number of issues regarding returning abstract types. In
17815 particular generic functions cannot have abstract result types or access
17816 result types designated an abstract type. There are some other cases which
17817 are detailed in the AI. Note that this binding interpretation has not been
17818 retrofitted to operate before Ada 2012 mode, since it caused a significant
17819 number of regressions.
17822 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
17826 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
17827 @cindex AI-0070 (Ada 2012 feature)
17830 This is an editorial change only, there are no testable consequences short of
17831 checking for the absence of generated code for an interface declaration.
17834 RM References: 3.09.04 (18/2)
17838 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
17839 @cindex AI-0208 (Ada 2012 feature)
17842 The wording in the Ada 2005 RM concerning characteristics of incomplete views
17843 was incorrect and implied that some programs intended to be legal were now
17844 illegal. GNAT had never considered such programs illegal, so it has always
17845 implemented the intent of this AI.
17848 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
17852 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
17853 @cindex AI-0162 (Ada 2012 feature)
17856 Incomplete types are made more useful by allowing them to be completed by
17857 private types and private extensions.
17860 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
17865 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
17866 @cindex AI-0098 (Ada 2012 feature)
17869 An unintentional omission in the RM implied some inconsistent restrictions on
17870 the use of anonymous access to subprogram values. These restrictions were not
17871 intentional, and have never been enforced by GNAT.
17874 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
17878 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
17879 @cindex AI-0199 (Ada 2012 feature)
17882 A choice list in a record aggregate can include several components of
17883 (distinct) anonymous access types as long as they have matching designated
17887 RM References: 4.03.01 (16)
17891 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
17892 @cindex AI-0220 (Ada 2012 feature)
17895 This AI addresses a wording problem in the RM that appears to permit some
17896 complex cases of aggregates with non-static discriminants. GNAT has always
17897 implemented the intended semantics.
17900 RM References: 4.03.01 (17)
17903 @emph{AI-0147 Conditional expressions (2009-03-29)}
17904 @cindex AI-0147 (Ada 2012 feature)
17907 Conditional expressions are permitted. The form of such an expression is:
17910 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
17913 The parentheses can be omitted in contexts where parentheses are present
17914 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
17915 clause is omitted, @b{else True} is assumed;
17916 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
17917 @emph{(A implies B)} in standard logic.
17920 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
17921 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
17925 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
17926 @cindex AI-0037 (Ada 2012 feature)
17929 This AI confirms that an association of the form @code{Indx => <>} in an
17930 array aggregate must raise @code{Constraint_Error} if @code{Indx}
17931 is out of range. The RM specified a range check on other associations, but
17932 not when the value of the association was defaulted. GNAT has always inserted
17933 a constraint check on the index value.
17936 RM References: 4.03.03 (29)
17940 @emph{AI-0123 Composability of equality (2010-04-13)}
17941 @cindex AI-0123 (Ada 2012 feature)
17944 Equality of untagged record composes, so that the predefined equality for a
17945 composite type that includes a component of some untagged record type
17946 @code{R} uses the equality operation of @code{R} (which may be user-defined
17947 or predefined). This makes the behavior of untagged records identical to that
17948 of tagged types in this respect.
17950 This change is an incompatibility with previous versions of Ada, but it
17951 corrects a non-uniformity that was often a source of confusion. Analysis of
17952 a large number of industrial programs indicates that in those rare cases
17953 where a composite type had an untagged record component with a user-defined
17954 equality, either there was no use of the composite equality, or else the code
17955 expected the same composability as for tagged types, and thus had a bug that
17956 would be fixed by this change.
17959 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
17964 @emph{AI-0088 The value of exponentiation (0000-00-00)}
17965 @cindex AI-0088 (Ada 2012 feature)
17968 This AI clarifies the equivalence rule given for the dynamic semantics of
17969 exponentiation: the value of the operation can be obtained by repeated
17970 multiplication, but the operation can be implemented otherwise (for example
17971 using the familiar divide-by-two-and-square algorithm, even if this is less
17972 accurate), and does not imply repeated reads of a volatile base.
17975 RM References: 4.05.06 (11)
17978 @emph{AI-0188 Case expressions (2010-01-09)}
17979 @cindex AI-0188 (Ada 2012 feature)
17982 Case expressions are permitted. This allows use of constructs such as:
17984 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
17988 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
17991 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
17992 @cindex AI-0104 (Ada 2012 feature)
17995 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
17996 @code{Constraint_Error} because the default value of the allocated object is
17997 @b{null}. This useless construct is illegal in Ada 2012.
18000 RM References: 4.08 (2)
18003 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
18004 @cindex AI-0157 (Ada 2012 feature)
18007 Allocation and Deallocation from an empty storage pool (i.e. allocation or
18008 deallocation of a pointer for which a static storage size clause of zero
18009 has been given) is now illegal and is detected as such. GNAT
18010 previously gave a warning but not an error.
18013 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
18016 @emph{AI-0179 Statement not required after label (2010-04-10)}
18017 @cindex AI-0179 (Ada 2012 feature)
18020 It is not necessary to have a statement following a label, so a label
18021 can appear at the end of a statement sequence without the need for putting a
18022 null statement afterwards, but it is not allowable to have only labels and
18023 no real statements in a statement sequence.
18026 RM References: 5.01 (2)
18030 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
18031 @cindex AI-139-2 (Ada 2012 feature)
18034 The new syntax for iterating over arrays and containers is now implemented.
18035 Iteration over containers is for now limited to read-only iterators. Only
18036 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
18039 RM References: 5.05
18042 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
18043 @cindex AI-0134 (Ada 2012 feature)
18046 For full conformance, the profiles of anonymous-access-to-subprogram
18047 parameters must match. GNAT has always enforced this rule.
18050 RM References: 6.03.01 (18)
18053 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
18054 @cindex AI-0207 (Ada 2012 feature)
18057 This AI confirms that access_to_constant indication must match for mode
18058 conformance. This was implemented in GNAT when the qualifier was originally
18059 introduced in Ada 2005.
18062 RM References: 6.03.01 (16/2)
18066 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
18067 @cindex AI-0046 (Ada 2012 feature)
18070 For full conformance, in the case of access parameters, the null exclusion
18071 must match (either both or neither must have @code{@b{not null}}).
18074 RM References: 6.03.02 (18)
18078 @emph{AI-0118 The association of parameter associations (0000-00-00)}
18079 @cindex AI-0118 (Ada 2012 feature)
18082 This AI clarifies the rules for named associations in subprogram calls and
18083 generic instantiations. The rules have been in place since Ada 83.
18086 RM References: 6.04.01 (2) 12.03 (9)
18090 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
18091 @cindex AI-0196 (Ada 2012 feature)
18094 Null exclusion checks are not made for @code{@b{out}} parameters when
18095 evaluating the actual parameters. GNAT has never generated these checks.
18098 RM References: 6.04.01 (13)
18101 @emph{AI-0015 Constant return objects (0000-00-00)}
18102 @cindex AI-0015 (Ada 2012 feature)
18105 The return object declared in an @i{extended_return_statement} may be
18106 declared constant. This was always intended, and GNAT has always allowed it.
18109 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
18114 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
18115 @cindex AI-0032 (Ada 2012 feature)
18118 If a function returns a class-wide type, the object of an extended return
18119 statement can be declared with a specific type that is covered by the class-
18120 wide type. This has been implemented in GNAT since the introduction of
18121 extended returns. Note AI-0103 complements this AI by imposing matching
18122 rules for constrained return types.
18125 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
18129 @emph{AI-0103 Static matching for extended return (2010-07-23)}
18130 @cindex AI-0103 (Ada 2012 feature)
18133 If the return subtype of a function is an elementary type or a constrained
18134 type, the subtype indication in an extended return statement must match
18135 statically this return subtype.
18138 RM References: 6.05 (5.2/2)
18142 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
18143 @cindex AI-0058 (Ada 2012 feature)
18146 The RM had some incorrect wording implying wrong treatment of abnormal
18147 completion in an extended return. GNAT has always implemented the intended
18148 correct semantics as described by this AI.
18151 RM References: 6.05 (22/2)
18155 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
18156 @cindex AI-0050 (Ada 2012 feature)
18159 The implementation permissions for raising @code{Constraint_Error} early on a function call when it was clear an exception would be raised were over-permissive and allowed mishandling of discriminants in some cases. GNAT did
18160 not take advantage of these incorrect permissions in any case.
18163 RM References: 6.05 (24/2)
18167 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
18168 @cindex AI-0125 (Ada 2012 feature)
18171 In Ada 2012, the declaration of a primitive operation of a type extension
18172 or private extension can also override an inherited primitive that is not
18173 visible at the point of this declaration.
18176 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
18179 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
18180 @cindex AI-0062 (Ada 2012 feature)
18183 A full constant may have a null exclusion even if its associated deferred
18184 constant does not. GNAT has always allowed this.
18187 RM References: 7.04 (6/2) 7.04 (7.1/2)
18191 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
18192 @cindex AI-0178 (Ada 2012 feature)
18195 This AI clarifies the role of incomplete views and plugs an omission in the
18196 RM. GNAT always correctly restricted the use of incomplete views and types.
18199 RM References: 7.05 (3/2) 7.05 (6/2)
18202 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
18203 @cindex AI-0087 (Ada 2012 feature)
18206 The actual for a formal nonlimited derived type cannot be limited. In
18207 particular, a formal derived type that extends a limited interface but which
18208 is not explicitly limited cannot be instantiated with a limited type.
18211 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
18214 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
18215 @cindex AI-0099 (Ada 2012 feature)
18218 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
18219 and therefore depends on the run-time characteristics of an object (i.e. its
18220 tag) and not on its nominal type. As the AI indicates: ``we do not expect
18221 this to affect any implementation''.
18224 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
18229 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
18230 @cindex AI-0064 (Ada 2012 feature)
18233 This is an editorial change only. The intended behavior is already checked
18234 by an existing ACATS test, which GNAT has always executed correctly.
18237 RM References: 7.06.01 (17.1/1)
18240 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
18241 @cindex AI-0026 (Ada 2012 feature)
18244 Record representation clauses concerning Unchecked_Union types cannot mention
18245 the discriminant of the type. The type of a component declared in the variant
18246 part of an Unchecked_Union cannot be controlled, have controlled components,
18247 nor have protected or task parts. If an Unchecked_Union type is declared
18248 within the body of a generic unit or its descendants, then the type of a
18249 component declared in the variant part cannot be a formal private type or a
18250 formal private extension declared within the same generic unit.
18253 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
18257 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
18258 @cindex AI-0205 (Ada 2012 feature)
18261 This AI corrects a simple omission in the RM. Return objects have always
18262 been visible within an extended return statement.
18265 RM References: 8.03 (17)
18269 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
18270 @cindex AI-0042 (Ada 2012 feature)
18273 This AI fixes a wording gap in the RM. An operation of a synchronized
18274 interface can be implemented by a protected or task entry, but the abstract
18275 operation is not being overridden in the usual sense, and it must be stated
18276 separately that this implementation is legal. This has always been the case
18280 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
18283 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
18284 @cindex AI-0030 (Ada 2012 feature)
18287 Requeue is permitted to a protected, synchronized or task interface primitive
18288 providing it is known that the overriding operation is an entry. Otherwise
18289 the requeue statement has the same effect as a procedure call. Use of pragma
18290 @code{Implemented} provides a way to impose a static requirement on the
18291 overriding operation by adhering to one of the implementation kinds: entry,
18292 protected procedure or any of the above.
18295 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
18296 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
18300 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
18301 @cindex AI-0201 (Ada 2012 feature)
18304 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
18305 attribute, then individual components may not be addressable by independent
18306 tasks. However, if the representation clause has no effect (is confirming),
18307 then independence is not compromised. Furthermore, in GNAT, specification of
18308 other appropriately addressable component sizes (e.g. 16 for 8-bit
18309 characters) also preserves independence. GNAT now gives very clear warnings
18310 both for the declaration of such a type, and for any assignment to its components.
18313 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
18316 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
18317 @cindex AI-0009 (Ada 2012 feature)
18320 This AI introduces the new pragmas @code{Independent} and
18321 @code{Independent_Components},
18322 which control guaranteeing independence of access to objects and components.
18323 The AI also requires independence not unaffected by confirming rep clauses.
18326 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
18327 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
18331 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
18332 @cindex AI-0072 (Ada 2012 feature)
18335 This AI clarifies that task signalling for reading @code{'Terminated} only
18336 occurs if the result is True. GNAT semantics has always been consistent with
18337 this notion of task signalling.
18340 RM References: 9.10 (6.1/1)
18343 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
18344 @cindex AI-0108 (Ada 2012 feature)
18347 This AI confirms that an incomplete type from a limited view does not have
18348 discriminants. This has always been the case in GNAT.
18351 RM References: 10.01.01 (12.3/2)
18354 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
18355 @cindex AI-0129 (Ada 2012 feature)
18358 This AI clarifies the description of limited views: a limited view of a
18359 package includes only one view of a type that has an incomplete declaration
18360 and a full declaration (there is no possible ambiguity in a client package).
18361 This AI also fixes an omission: a nested package in the private part has no
18362 limited view. GNAT always implemented this correctly.
18365 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
18370 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
18371 @cindex AI-0077 (Ada 2012 feature)
18374 This AI clarifies that a declaration does not include a context clause,
18375 and confirms that it is illegal to have a context in which both a limited
18376 and a nonlimited view of a package are accessible. Such double visibility
18377 was always rejected by GNAT.
18380 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
18383 @emph{AI-0122 Private with and children of generics (0000-00-00)}
18384 @cindex AI-0122 (Ada 2012 feature)
18387 This AI clarifies the visibility of private children of generic units within
18388 instantiations of a parent. GNAT has always handled this correctly.
18391 RM References: 10.01.02 (12/2)
18396 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
18397 @cindex AI-0040 (Ada 2012 feature)
18400 This AI confirms that a limited with clause in a child unit cannot name
18401 an ancestor of the unit. This has always been checked in GNAT.
18404 RM References: 10.01.02 (20/2)
18407 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
18408 @cindex AI-0132 (Ada 2012 feature)
18411 This AI fills a gap in the description of library unit pragmas. The pragma
18412 clearly must apply to a library unit, even if it does not carry the name
18413 of the enclosing unit. GNAT has always enforced the required check.
18416 RM References: 10.01.05 (7)
18420 @emph{AI-0034 Categorization of limited views (0000-00-00)}
18421 @cindex AI-0034 (Ada 2012 feature)
18424 The RM makes certain limited with clauses illegal because of categorization
18425 considerations, when the corresponding normal with would be legal. This is
18426 not intended, and GNAT has always implemented the recommended behavior.
18429 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
18433 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
18434 @cindex AI-0035 (Ada 2012 feature)
18437 This AI remedies some inconsistencies in the legality rules for Pure units.
18438 Derived access types are legal in a pure unit (on the assumption that the
18439 rule for a zero storage pool size has been enforced on the ancestor type).
18440 The rules are enforced in generic instances and in subunits. GNAT has always
18441 implemented the recommended behavior.
18444 RM References: 10.02.01 (15.1/2) 10.02.01 (15.4/2) 10.02.01 (15.5/2) 10.02.01 (17/2)
18448 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
18449 @cindex AI-0219 (Ada 2012 feature)
18452 This AI refines the rules for the cases with limited parameters which do not
18453 allow the implementations to omit ``redundant''. GNAT now properly conforms
18454 to the requirements of this binding interpretation.
18457 RM References: 10.02.01 (18/2)
18460 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
18461 @cindex AI-0043 (Ada 2012 feature)
18464 This AI covers various omissions in the RM regarding the raising of
18465 exceptions. GNAT has always implemented the intended semantics.
18468 RM References: 11.04.01 (10.1/2) 11 (2)
18472 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
18473 @cindex AI-0200 (Ada 2012 feature)
18476 This AI plugs a gap in the RM which appeared to allow some obviously intended
18477 illegal instantiations. GNAT has never allowed these instantiations.
18480 RM References: 12.07 (16)
18484 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
18485 @cindex AI-0112 (Ada 2012 feature)
18488 This AI concerns giving names to various representation aspects, but the
18489 practical effect is simply to make the use of duplicate
18490 @code{Atomic}[@code{_Components}],
18491 @code{Volatile}[@code{_Components}] and
18492 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
18493 now performs this required check.
18496 RM References: 13.01 (8)
18499 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
18500 @cindex AI-0106 (Ada 2012 feature)
18503 The RM appeared to allow representation pragmas on generic formal parameters,
18504 but this was not intended, and GNAT has never permitted this usage.
18507 RM References: 13.01 (9.1/1)
18511 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
18512 @cindex AI-0012 (Ada 2012 feature)
18515 It is now illegal to give an inappropriate component size or a pragma
18516 @code{Pack} that attempts to change the component size in the case of atomic
18517 or aliased components. Previously GNAT ignored such an attempt with a
18521 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
18525 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
18526 @cindex AI-0039 (Ada 2012 feature)
18529 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
18530 for stream attributes, but these were never useful and are now illegal. GNAT
18531 has always regarded such expressions as illegal.
18534 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
18538 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
18539 @cindex AI-0095 (Ada 2012 feature)
18542 The prefix of @code{'Address} cannot statically denote a subprogram with
18543 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
18544 @code{Program_Error} if the prefix denotes a subprogram with convention
18548 RM References: 13.03 (11/1)
18552 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
18553 @cindex AI-0116 (Ada 2012 feature)
18556 This AI requires that the alignment of a class-wide object be no greater
18557 than the alignment of any type in the class. GNAT has always followed this
18561 RM References: 13.03 (29) 13.11 (16)
18565 @emph{AI-0146 Type invariants (2009-09-21)}
18566 @cindex AI-0146 (Ada 2012 feature)
18569 Type invariants may be specified for private types using the aspect notation.
18570 Aspect @code{Type_Invariant} may be specified for any private type,
18571 @code{Type_Invariant'Class} can
18572 only be specified for tagged types, and is inherited by any descendent of the
18573 tagged types. The invariant is a boolean expression that is tested for being
18574 true in the following situations: conversions to the private type, object
18575 declarations for the private type that are default initialized, and
18577 parameters and returned result on return from any primitive operation for
18578 the type that is visible to a client.
18579 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
18580 @code{Invariant'Class} for @code{Type_Invariant'Class}.
18583 RM References: 13.03.03 (00)
18586 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
18587 @cindex AI-0078 (Ada 2012 feature)
18590 In Ada 2012, compilers are required to support unchecked conversion where the
18591 target alignment is a multiple of the source alignment. GNAT always supported
18592 this case (and indeed all cases of differing alignments, doing copies where
18593 required if the alignment was reduced).
18596 RM References: 13.09 (7)
18600 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
18601 @cindex AI-0195 (Ada 2012 feature)
18604 The handling of invalid values is now designated to be implementation
18605 defined. This is a documentation change only, requiring Annex M in the GNAT
18606 Reference Manual to document this handling.
18607 In GNAT, checks for invalid values are made
18608 only when necessary to avoid erroneous behavior. Operations like assignments
18609 which cannot cause erroneous behavior ignore the possibility of invalid
18610 values and do not do a check. The date given above applies only to the
18611 documentation change, this behavior has always been implemented by GNAT.
18614 RM References: 13.09.01 (10)
18617 @emph{AI-0193 Alignment of allocators (2010-09-16)}
18618 @cindex AI-0193 (Ada 2012 feature)
18621 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
18622 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
18626 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
18627 13.11.01 (2) 13.11.01 (3)
18631 @emph{AI-0177 Parameterized expressions (2010-07-10)}
18632 @cindex AI-0177 (Ada 2012 feature)
18635 The new Ada 2012 notion of parameterized expressions is implemented. The form
18638 @i{function specification} @b{is} (@i{expression})
18642 This is exactly equivalent to the
18643 corresponding function body that returns the expression, but it can appear
18644 in a package spec. Note that the expression must be parenthesized.
18647 RM References: 13.11.01 (3/2)
18650 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
18651 @cindex AI-0033 (Ada 2012 feature)
18654 Neither of these two pragmas may appear within a generic template, because
18655 the generic might be instantiated at other than the library level.
18658 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
18662 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
18663 @cindex AI-0161 (Ada 2012 feature)
18666 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
18667 of the default stream attributes for elementary types. If this restriction is
18668 in force, then it is necessary to provide explicit subprograms for any
18669 stream attributes used.
18672 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
18675 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
18676 @cindex AI-0194 (Ada 2012 feature)
18679 The @code{Stream_Size} attribute returns the default number of bits in the
18680 stream representation of the given type.
18681 This value is not affected by the presence
18682 of stream subprogram attributes for the type. GNAT has always implemented
18683 this interpretation.
18686 RM References: 13.13.02 (1.2/2)
18689 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
18690 @cindex AI-0109 (Ada 2012 feature)
18693 This AI is an editorial change only. It removes the need for a tag check
18694 that can never fail.
18697 RM References: 13.13.02 (34/2)
18700 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
18701 @cindex AI-0007 (Ada 2012 feature)
18704 The RM as written appeared to limit the possibilities of declaring read
18705 attribute procedures for private scalar types. This limitation was not
18706 intended, and has never been enforced by GNAT.
18709 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
18713 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
18714 @cindex AI-0065 (Ada 2012 feature)
18717 This AI clarifies the fact that all remote access types support external
18718 streaming. This fixes an obvious oversight in the definition of the
18719 language, and GNAT always implemented the intended correct rules.
18722 RM References: 13.13.02 (52/2)
18725 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
18726 @cindex AI-0019 (Ada 2012 feature)
18729 The RM suggests that primitive subprograms of a specific tagged type are
18730 frozen when the tagged type is frozen. This would be an incompatible change
18731 and is not intended. GNAT has never attempted this kind of freezing and its
18732 behavior is consistent with the recommendation of this AI.
18735 RM References: 13.14 (2) 13.14 (3/1) 13.14 (8.1/1) 13.14 (10) 13.14 (14) 13.14 (15.1/2)
18738 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
18739 @cindex AI-0017 (Ada 2012 feature)
18742 So-called ``Taft-amendment types'' (i.e., types that are completed in package
18743 bodies) are not frozen by the occurrence of bodies in the
18744 enclosing declarative part. GNAT always implemented this properly.
18747 RM References: 13.14 (3/1)
18751 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
18752 @cindex AI-0060 (Ada 2012 feature)
18755 This AI extends the definition of remote access types to include access
18756 to limited, synchronized, protected or task class-wide interface types.
18757 GNAT already implemented this extension.
18760 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
18763 @emph{AI-0114 Classification of letters (0000-00-00)}
18764 @cindex AI-0114 (Ada 2012 feature)
18767 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
18768 181 (@code{MICRO SIGN}), and
18769 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
18770 lower case letters by Unicode.
18771 However, they are not allowed in identifiers, and they
18772 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
18773 This behavior is consistent with that defined in Ada 95.
18776 RM References: A.03.02 (59) A.04.06 (7)
18780 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
18781 @cindex AI-0185 (Ada 2012 feature)
18784 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
18785 classification functions for @code{Wide_Character} and
18786 @code{Wide_Wide_Character}, as well as providing
18787 case folding routines for @code{Wide_[Wide_]Character} and
18788 @code{Wide_[Wide_]String}.
18791 RM References: A.03.05 (0) A.03.06 (0)
18795 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
18796 @cindex AI-0031 (Ada 2012 feature)
18799 A new version of @code{Find_Token} is added to all relevant string packages,
18800 with an extra parameter @code{From}. Instead of starting at the first
18801 character of the string, the search for a matching Token starts at the
18802 character indexed by the value of @code{From}.
18803 These procedures are available in all versions of Ada
18804 but if used in versions earlier than Ada 2012 they will generate a warning
18805 that an Ada 2012 subprogram is being used.
18808 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
18813 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
18814 @cindex AI-0056 (Ada 2012 feature)
18817 The wording in the Ada 2005 RM implied an incompatible handling of the
18818 @code{Index} functions, resulting in raising an exception instead of
18819 returning zero in some situations.
18820 This was not intended and has been corrected.
18821 GNAT always returned zero, and is thus consistent with this AI.
18824 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
18828 @emph{AI-0137 String encoding package (2010-03-25)}
18829 @cindex AI-0137 (Ada 2012 feature)
18832 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
18833 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
18834 and @code{Wide_Wide_Strings} have been
18835 implemented. These packages (whose documentation can be found in the spec
18836 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
18837 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
18838 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
18839 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
18840 UTF-16), as well as conversions between the different UTF encodings. With
18841 the exception of @code{Wide_Wide_Strings}, these packages are available in
18842 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
18843 The @code{Wide_Wide_Strings package}
18844 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
18845 mode since it uses @code{Wide_Wide_Character}).
18848 RM References: A.04.11
18851 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
18852 @cindex AI-0038 (Ada 2012 feature)
18855 These are minor errors in the description on three points. The intent on
18856 all these points has always been clear, and GNAT has always implemented the
18857 correct intended semantics.
18860 RM References: A.10.05 (37) A.10.07 (8/1) A.10.07 (10) A.10.07 (12) A.10.08 (10) A.10.08 (24)
18863 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
18864 @cindex AI-0044 (Ada 2012 feature)
18867 This AI places restrictions on allowed instantiations of generic containers.
18868 These restrictions are not checked by the compiler, so there is nothing to
18869 change in the implementation. This affects only the RM documentation.
18872 RM References: A.18 (4/2) A.18.02 (231/2) A.18.03 (145/2) A.18.06 (56/2) A.18.08 (66/2) A.18.09 (79/2) A.18.26 (5/2) A.18.26 (9/2)
18875 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
18876 @cindex AI-0127 (Ada 2012 feature)
18879 This package provides an interface for identifying the current locale.
18882 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
18883 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
18888 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
18889 @cindex AI-0002 (Ada 2012 feature)
18892 The compiler is not required to support exporting an Ada subprogram with
18893 convention C if there are parameters or a return type of an unconstrained
18894 array type (such as @code{String}). GNAT allows such declarations but
18895 generates warnings. It is possible, but complicated, to write the
18896 corresponding C code and certainly such code would be specific to GNAT and
18900 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
18904 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
18905 @cindex AI05-0216 (Ada 2012 feature)
18908 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
18909 forbid tasks declared locally within subprograms, or functions returning task
18910 objects, and that is the implementation that GNAT has always provided.
18911 However the language in the RM was not sufficiently clear on this point.
18912 Thus this is a documentation change in the RM only.
18915 RM References: D.07 (3/3)
18918 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
18919 @cindex AI-0211 (Ada 2012 feature)
18922 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
18923 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
18926 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
18929 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
18930 @cindex AI-0190 (Ada 2012 feature)
18933 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
18934 used to control storage pools globally.
18935 In particular, you can force every access
18936 type that is used for allocation (@b{new}) to have an explicit storage pool,
18937 or you can declare a pool globally to be used for all access types that lack
18941 RM References: D.07 (8)
18944 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
18945 @cindex AI-0189 (Ada 2012 feature)
18948 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
18949 which says that no dynamic allocation will occur once elaboration is
18951 In general this requires a run-time check, which is not required, and which
18952 GNAT does not attempt. But the static cases of allocators in a task body or
18953 in the body of the main program are detected and flagged at compile or bind
18957 RM References: D.07 (19.1/2) H.04 (23.3/2)
18960 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
18961 @cindex AI-0171 (Ada 2012 feature)
18964 A new package @code{System.Multiprocessors} is added, together with the
18965 definition of pragma @code{CPU} for controlling task affinity. A new no
18966 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
18967 is added to the Ravenscar profile.
18970 RM References: D.13.01 (4/2) D.16
18974 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
18975 @cindex AI-0210 (Ada 2012 feature)
18978 This is a documentation only issue regarding wording of metric requirements,
18979 that does not affect the implementation of the compiler.
18982 RM References: D.15 (24/2)
18986 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
18987 @cindex AI-0206 (Ada 2012 feature)
18990 Remote types packages are now allowed to depend on preelaborated packages.
18991 This was formerly considered illegal.
18994 RM References: E.02.02 (6)
18999 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
19000 @cindex AI-0152 (Ada 2012 feature)
19003 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
19004 where the type of the returned value is an anonymous access type.
19007 RM References: H.04 (8/1)
19011 @node Obsolescent Features
19012 @chapter Obsolescent Features
19015 This chapter describes features that are provided by GNAT, but are
19016 considered obsolescent since there are preferred ways of achieving
19017 the same effect. These features are provided solely for historical
19018 compatibility purposes.
19021 * pragma No_Run_Time::
19022 * pragma Ravenscar::
19023 * pragma Restricted_Run_Time::
19026 @node pragma No_Run_Time
19027 @section pragma No_Run_Time
19029 The pragma @code{No_Run_Time} is used to achieve an affect similar
19030 to the use of the "Zero Foot Print" configurable run time, but without
19031 requiring a specially configured run time. The result of using this
19032 pragma, which must be used for all units in a partition, is to restrict
19033 the use of any language features requiring run-time support code. The
19034 preferred usage is to use an appropriately configured run-time that
19035 includes just those features that are to be made accessible.
19037 @node pragma Ravenscar
19038 @section pragma Ravenscar
19040 The pragma @code{Ravenscar} has exactly the same effect as pragma
19041 @code{Profile (Ravenscar)}. The latter usage is preferred since it
19042 is part of the new Ada 2005 standard.
19044 @node pragma Restricted_Run_Time
19045 @section pragma Restricted_Run_Time
19047 The pragma @code{Restricted_Run_Time} has exactly the same effect as
19048 pragma @code{Profile (Restricted)}. The latter usage is
19049 preferred since the Ada 2005 pragma @code{Profile} is intended for
19050 this kind of implementation dependent addition.
19053 @c GNU Free Documentation License
19055 @node Index,,GNU Free Documentation License, Top