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 Aspects::
74 * Implementation Defined Attributes::
75 * Standard and Implementation Defined Restrictions::
76 * Implementation Advice::
77 * Implementation Defined Characteristics::
78 * Intrinsic Subprograms::
79 * Representation Clauses and Pragmas::
80 * Standard Library Routines::
81 * The Implementation of Standard I/O::
83 * Interfacing to Other Languages::
84 * Specialized Needs Annexes::
85 * Implementation of Specific Ada Features::
86 * Implementation of Ada 2012 Features::
87 * Obsolescent Features::
88 * GNU Free Documentation License::
91 --- The Detailed Node Listing ---
95 * What This Reference Manual Contains::
96 * Related Information::
98 Implementation Defined Pragmas
100 * Pragma Abort_Defer::
109 * Pragma Assert_And_Cut::
110 * Pragma Assertion_Policy::
112 * Pragma Assume_No_Invalid_Values::
113 * Pragma Attribute_Definition::
115 * Pragma C_Pass_By_Copy::
117 * Pragma Check_Float_Overflow::
118 * Pragma Check_Name::
119 * Pragma Check_Policy::
121 * Pragma Common_Object::
122 * Pragma Compile_Time_Error::
123 * Pragma Compile_Time_Warning::
124 * Pragma Compiler_Unit::
125 * Pragma Complete_Representation::
126 * Pragma Complex_Representation::
127 * Pragma Component_Alignment::
128 * Pragma Contract_Cases::
129 * Pragma Convention_Identifier::
131 * Pragma CPP_Constructor::
132 * Pragma CPP_Virtual::
133 * Pragma CPP_Vtable::
136 * Pragma Debug_Policy::
137 * Pragma Default_Storage_Pool::
138 * Pragma Detect_Blocking::
139 * Pragma Dispatching_Domain::
140 * Pragma Elaboration_Checks::
142 * Pragma Export_Exception::
143 * Pragma Export_Function::
144 * Pragma Export_Object::
145 * Pragma Export_Procedure::
146 * Pragma Export_Value::
147 * Pragma Export_Valued_Procedure::
148 * Pragma Extend_System::
149 * Pragma Extensions_Allowed::
151 * Pragma External_Name_Casing::
153 * Pragma Favor_Top_Level::
154 * Pragma Finalize_Storage_Only::
155 * Pragma Float_Representation::
157 * Pragma Implementation_Defined::
158 * Pragma Implemented::
159 * Pragma Implicit_Packing::
160 * Pragma Import_Exception::
161 * Pragma Import_Function::
162 * Pragma Import_Object::
163 * Pragma Import_Procedure::
164 * Pragma Import_Valued_Procedure::
165 * Pragma Independent::
166 * Pragma Independent_Components::
167 * Pragma Initialize_Scalars::
168 * Pragma Inline_Always::
169 * Pragma Inline_Generic::
171 * Pragma Interface_Name::
172 * Pragma Interrupt_Handler::
173 * Pragma Interrupt_State::
175 * Pragma Keep_Names::
178 * Pragma Linker_Alias::
179 * Pragma Linker_Constructor::
180 * Pragma Linker_Destructor::
181 * Pragma Linker_Section::
182 * Pragma Long_Float::
183 * Pragma Loop_Invariant::
184 * Pragma Loop_Optimize::
185 * Pragma Loop_Variant::
186 * Pragma Machine_Attribute::
188 * Pragma Main_Storage::
192 * Pragma No_Strict_Aliasing ::
193 * Pragma Normalize_Scalars::
194 * Pragma Obsolescent::
195 * Pragma Optimize_Alignment::
197 * Pragma Overflow_Mode::
198 * Pragma Partition_Elaboration_Policy::
200 * Pragma Persistent_BSS::
202 * Pragma Postcondition::
203 * Pragma Precondition::
204 * Pragma Preelaborable_Initialization::
205 * Pragma Priority_Specific_Dispatching::
206 * Pragma Profile (Ravenscar)::
207 * Pragma Profile (Restricted)::
208 * Pragma Profile (Rational)::
209 * Pragma Psect_Object::
210 * Pragma Pure_Function::
211 * Pragma Relative_Deadline::
212 * Pragma Remote_Access_Type::
213 * Pragma Restriction_Warnings::
215 * Pragma Short_Circuit_And_Or::
216 * Pragma Short_Descriptors::
217 * Pragma Simple_Storage_Pool_Type::
218 * Pragma Source_File_Name::
219 * Pragma Source_File_Name_Project::
220 * Pragma Source_Reference::
221 * Pragma Static_Elaboration_Desired::
222 * Pragma Stream_Convert::
223 * Pragma Style_Checks::
226 * Pragma Suppress_All::
227 * Pragma Suppress_Exception_Locations::
228 * Pragma Suppress_Initialization::
231 * Pragma Task_Storage::
233 * Pragma Thread_Local_Storage::
234 * Pragma Time_Slice::
236 * Pragma Unchecked_Union::
237 * Pragma Unimplemented_Unit::
238 * Pragma Universal_Aliasing ::
239 * Pragma Universal_Data::
240 * Pragma Unmodified::
241 * Pragma Unreferenced::
242 * Pragma Unreferenced_Objects::
243 * Pragma Unreserve_All_Interrupts::
244 * Pragma Unsuppress::
245 * Pragma Use_VADS_Size::
246 * Pragma Validity_Checks::
249 * Pragma Weak_External::
250 * Pragma Wide_Character_Encoding::
252 Implementation Defined Aspects
254 * Aspect Abstract_State::
257 * Aspect Compiler_Unit::
258 * Aspect Contract_Cases::
261 * Aspect Dimension_System::
262 * Aspect Favor_Top_Level::
264 * Aspect Inline_Always::
266 * Aspect Object_Size::
267 * Aspect Persistent_BSS::
269 * Aspect Preelaborate_05::
272 * Aspect Pure_Function::
273 * Aspect Remote_Access_Type::
274 * Aspect Scalar_Storage_Order::
276 * Aspect Simple_Storage_Pool::
277 * Aspect Simple_Storage_Pool_Type::
278 * Aspect Suppress_Debug_Info::
280 * Aspect Universal_Aliasing::
281 * Aspect Universal_Data::
282 * Aspect Unmodified::
283 * Aspect Unreferenced::
284 * Aspect Unreferenced_Objects::
285 * Aspect Value_Size::
288 Implementation Defined Attributes
290 * Attribute Abort_Signal::
291 * Attribute Address_Size::
292 * Attribute Asm_Input::
293 * Attribute Asm_Output::
294 * Attribute AST_Entry::
296 * Attribute Bit_Position::
297 * Attribute Compiler_Version::
298 * Attribute Code_Address::
299 * Attribute Default_Bit_Order::
300 * Attribute Descriptor_Size::
301 * Attribute Elaborated::
302 * Attribute Elab_Body::
303 * Attribute Elab_Spec::
304 * Attribute Elab_Subp_Body::
306 * Attribute Enabled::
307 * Attribute Enum_Rep::
308 * Attribute Enum_Val::
309 * Attribute Epsilon::
310 * Attribute Fixed_Value::
311 * Attribute Has_Access_Values::
312 * Attribute Has_Discriminants::
314 * Attribute Integer_Value::
315 * Attribute Invalid_Value::
317 * Attribute Loop_Entry::
318 * Attribute Machine_Size::
319 * Attribute Mantissa::
320 * Attribute Max_Interrupt_Priority::
321 * Attribute Max_Priority::
322 * Attribute Maximum_Alignment::
323 * Attribute Mechanism_Code::
324 * Attribute Null_Parameter::
325 * Attribute Object_Size::
326 * Attribute Passed_By_Reference::
327 * Attribute Pool_Address::
328 * Attribute Range_Length::
330 * Attribute Safe_Emax::
331 * Attribute Safe_Large::
332 * Attribute Scalar_Storage_Order::
333 * Attribute Simple_Storage_Pool::
335 * Attribute Storage_Unit::
336 * Attribute Stub_Type::
337 * Attribute System_Allocator_Alignment::
338 * Attribute Target_Name::
340 * Attribute To_Address::
341 * Attribute Type_Class::
342 * Attribute UET_Address::
343 * Attribute Unconstrained_Array::
344 * Attribute Universal_Literal_String::
345 * Attribute Unrestricted_Access::
347 * Attribute Valid_Scalars::
348 * Attribute VADS_Size::
349 * Attribute Value_Size::
350 * Attribute Wchar_T_Size::
351 * Attribute Word_Size::
353 Standard and Implementation Defined Restrictions
355 * Partition-Wide Restrictions::
356 * Program Unit Level Restrictions::
358 Partition-Wide Restrictions
360 * Immediate_Reclamation::
361 * Max_Asynchronous_Select_Nesting::
362 * Max_Entry_Queue_Length::
363 * Max_Protected_Entries::
364 * Max_Select_Alternatives::
365 * Max_Storage_At_Blocking::
368 * No_Abort_Statements::
369 * No_Access_Parameter_Allocators::
370 * No_Access_Subprograms::
372 * No_Anonymous_Allocators::
375 * No_Default_Initialization::
378 * No_Direct_Boolean_Operators::
380 * No_Dispatching_Calls::
381 * No_Dynamic_Attachment::
382 * No_Dynamic_Priorities::
383 * No_Entry_Calls_In_Elaboration_Code::
384 * No_Enumeration_Maps::
385 * No_Exception_Handlers::
386 * No_Exception_Propagation::
387 * No_Exception_Registration::
391 * No_Floating_Point::
392 * No_Implicit_Conditionals::
393 * No_Implicit_Dynamic_Code::
394 * No_Implicit_Heap_Allocations::
395 * No_Implicit_Loops::
396 * No_Initialize_Scalars::
398 * No_Local_Allocators::
399 * No_Local_Protected_Objects::
400 * No_Local_Timing_Events::
401 * No_Nested_Finalization::
402 * No_Protected_Type_Allocators::
403 * No_Protected_Types::
406 * No_Relative_Delay::
407 * No_Requeue_Statements::
408 * No_Secondary_Stack::
409 * No_Select_Statements::
410 * No_Specific_Termination_Handlers::
411 * No_Specification_of_Aspect::
412 * No_Standard_Allocators_After_Elaboration::
413 * No_Standard_Storage_Pools::
414 * No_Stream_Optimizations::
416 * No_Task_Allocators::
417 * No_Task_Attributes_Package::
418 * No_Task_Hierarchy::
419 * No_Task_Termination::
421 * No_Terminate_Alternatives::
422 * No_Unchecked_Access::
424 * Static_Priorities::
425 * Static_Storage_Size::
427 Program Unit Level Restrictions
429 * No_Elaboration_Code::
431 * No_Implementation_Aspect_Specifications::
432 * No_Implementation_Attributes::
433 * No_Implementation_Identifiers::
434 * No_Implementation_Pragmas::
435 * No_Implementation_Restrictions::
436 * No_Implementation_Units::
437 * No_Implicit_Aliasing::
438 * No_Obsolescent_Features::
439 * No_Wide_Characters::
442 The Implementation of Standard I/O
444 * Standard I/O Packages::
450 * Wide_Wide_Text_IO::
454 * Filenames encoding::
456 * Operations on C Streams::
457 * Interfacing to C Streams::
461 * Ada.Characters.Latin_9 (a-chlat9.ads)::
462 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
463 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
464 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
465 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
466 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
467 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
468 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
469 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
470 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
471 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
472 * Ada.Command_Line.Environment (a-colien.ads)::
473 * Ada.Command_Line.Remove (a-colire.ads)::
474 * Ada.Command_Line.Response_File (a-clrefi.ads)::
475 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
476 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
477 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
478 * Ada.Exceptions.Traceback (a-exctra.ads)::
479 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
480 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
481 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
482 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
483 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
484 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
485 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
486 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
487 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
488 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
489 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
490 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
491 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
492 * GNAT.Altivec (g-altive.ads)::
493 * GNAT.Altivec.Conversions (g-altcon.ads)::
494 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
495 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
496 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
497 * GNAT.Array_Split (g-arrspl.ads)::
498 * GNAT.AWK (g-awk.ads)::
499 * GNAT.Bounded_Buffers (g-boubuf.ads)::
500 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
501 * GNAT.Bubble_Sort (g-bubsor.ads)::
502 * GNAT.Bubble_Sort_A (g-busora.ads)::
503 * GNAT.Bubble_Sort_G (g-busorg.ads)::
504 * GNAT.Byte_Order_Mark (g-byorma.ads)::
505 * GNAT.Byte_Swapping (g-bytswa.ads)::
506 * GNAT.Calendar (g-calend.ads)::
507 * GNAT.Calendar.Time_IO (g-catiio.ads)::
508 * GNAT.Case_Util (g-casuti.ads)::
509 * GNAT.CGI (g-cgi.ads)::
510 * GNAT.CGI.Cookie (g-cgicoo.ads)::
511 * GNAT.CGI.Debug (g-cgideb.ads)::
512 * GNAT.Command_Line (g-comlin.ads)::
513 * GNAT.Compiler_Version (g-comver.ads)::
514 * GNAT.Ctrl_C (g-ctrl_c.ads)::
515 * GNAT.CRC32 (g-crc32.ads)::
516 * GNAT.Current_Exception (g-curexc.ads)::
517 * GNAT.Debug_Pools (g-debpoo.ads)::
518 * GNAT.Debug_Utilities (g-debuti.ads)::
519 * GNAT.Decode_String (g-decstr.ads)::
520 * GNAT.Decode_UTF8_String (g-deutst.ads)::
521 * GNAT.Directory_Operations (g-dirope.ads)::
522 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
523 * GNAT.Dynamic_HTables (g-dynhta.ads)::
524 * GNAT.Dynamic_Tables (g-dyntab.ads)::
525 * GNAT.Encode_String (g-encstr.ads)::
526 * GNAT.Encode_UTF8_String (g-enutst.ads)::
527 * GNAT.Exception_Actions (g-excact.ads)::
528 * GNAT.Exception_Traces (g-exctra.ads)::
529 * GNAT.Exceptions (g-except.ads)::
530 * GNAT.Expect (g-expect.ads)::
531 * GNAT.Expect.TTY (g-exptty.ads)::
532 * GNAT.Float_Control (g-flocon.ads)::
533 * GNAT.Heap_Sort (g-heasor.ads)::
534 * GNAT.Heap_Sort_A (g-hesora.ads)::
535 * GNAT.Heap_Sort_G (g-hesorg.ads)::
536 * GNAT.HTable (g-htable.ads)::
537 * GNAT.IO (g-io.ads)::
538 * GNAT.IO_Aux (g-io_aux.ads)::
539 * GNAT.Lock_Files (g-locfil.ads)::
540 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
541 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
542 * GNAT.MD5 (g-md5.ads)::
543 * GNAT.Memory_Dump (g-memdum.ads)::
544 * GNAT.Most_Recent_Exception (g-moreex.ads)::
545 * GNAT.OS_Lib (g-os_lib.ads)::
546 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
547 * GNAT.Random_Numbers (g-rannum.ads)::
548 * GNAT.Regexp (g-regexp.ads)::
549 * GNAT.Registry (g-regist.ads)::
550 * GNAT.Regpat (g-regpat.ads)::
551 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
552 * GNAT.Semaphores (g-semaph.ads)::
553 * GNAT.Serial_Communications (g-sercom.ads)::
554 * GNAT.SHA1 (g-sha1.ads)::
555 * GNAT.SHA224 (g-sha224.ads)::
556 * GNAT.SHA256 (g-sha256.ads)::
557 * GNAT.SHA384 (g-sha384.ads)::
558 * GNAT.SHA512 (g-sha512.ads)::
559 * GNAT.Signals (g-signal.ads)::
560 * GNAT.Sockets (g-socket.ads)::
561 * GNAT.Source_Info (g-souinf.ads)::
562 * GNAT.Spelling_Checker (g-speche.ads)::
563 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
564 * GNAT.Spitbol.Patterns (g-spipat.ads)::
565 * GNAT.Spitbol (g-spitbo.ads)::
566 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
567 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
568 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
569 * GNAT.SSE (g-sse.ads)::
570 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
571 * GNAT.Strings (g-string.ads)::
572 * GNAT.String_Split (g-strspl.ads)::
573 * GNAT.Table (g-table.ads)::
574 * GNAT.Task_Lock (g-tasloc.ads)::
575 * GNAT.Threads (g-thread.ads)::
576 * GNAT.Time_Stamp (g-timsta.ads)::
577 * GNAT.Traceback (g-traceb.ads)::
578 * GNAT.Traceback.Symbolic (g-trasym.ads)::
579 * GNAT.UTF_32 (g-utf_32.ads)::
580 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
581 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
582 * GNAT.Wide_String_Split (g-wistsp.ads)::
583 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
584 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
585 * Interfaces.C.Extensions (i-cexten.ads)::
586 * Interfaces.C.Streams (i-cstrea.ads)::
587 * Interfaces.CPP (i-cpp.ads)::
588 * Interfaces.Packed_Decimal (i-pacdec.ads)::
589 * Interfaces.VxWorks (i-vxwork.ads)::
590 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
591 * System.Address_Image (s-addima.ads)::
592 * System.Assertions (s-assert.ads)::
593 * System.Memory (s-memory.ads)::
594 * System.Multiprocessors (s-multip.ads)::
595 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
596 * System.Partition_Interface (s-parint.ads)::
597 * System.Pool_Global (s-pooglo.ads)::
598 * System.Pool_Local (s-pooloc.ads)::
599 * System.Restrictions (s-restri.ads)::
600 * System.Rident (s-rident.ads)::
601 * System.Strings.Stream_Ops (s-ststop.ads)::
602 * System.Task_Info (s-tasinf.ads)::
603 * System.Wch_Cnv (s-wchcnv.ads)::
604 * System.Wch_Con (s-wchcon.ads)::
608 * Text_IO Stream Pointer Positioning::
609 * Text_IO Reading and Writing Non-Regular Files::
611 * Treating Text_IO Files as Streams::
612 * Text_IO Extensions::
613 * Text_IO Facilities for Unbounded Strings::
617 * Wide_Text_IO Stream Pointer Positioning::
618 * Wide_Text_IO Reading and Writing Non-Regular Files::
622 * Wide_Wide_Text_IO Stream Pointer Positioning::
623 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
625 Interfacing to Other Languages
628 * Interfacing to C++::
629 * Interfacing to COBOL::
630 * Interfacing to Fortran::
631 * Interfacing to non-GNAT Ada code::
633 Specialized Needs Annexes
635 Implementation of Specific Ada Features
636 * Machine Code Insertions::
637 * GNAT Implementation of Tasking::
638 * GNAT Implementation of Shared Passive Packages::
639 * Code Generation for Array Aggregates::
640 * The Size of Discriminated Records with Default Discriminants::
641 * Strict Conformance to the Ada Reference Manual::
643 Implementation of Ada 2012 Features
647 GNU Free Documentation License
654 @node About This Guide
655 @unnumbered About This Guide
658 This manual contains useful information in writing programs using the
659 @value{EDITION} compiler. It includes information on implementation dependent
660 characteristics of @value{EDITION}, including all the information required by
661 Annex M of the Ada language standard.
663 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
664 Ada 83 compatibility mode.
665 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
666 but you can override with a compiler switch
667 to explicitly specify the language version.
668 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
669 @value{EDITION} User's Guide}, for details on these switches.)
670 Throughout this manual, references to ``Ada'' without a year suffix
671 apply to both the Ada 95 and Ada 2005 versions of the language.
673 Ada is designed to be highly portable.
674 In general, a program will have the same effect even when compiled by
675 different compilers on different platforms.
676 However, since Ada is designed to be used in a
677 wide variety of applications, it also contains a number of system
678 dependent features to be used in interfacing to the external world.
679 @cindex Implementation-dependent features
682 Note: Any program that makes use of implementation-dependent features
683 may be non-portable. You should follow good programming practice and
684 isolate and clearly document any sections of your program that make use
685 of these features in a non-portable manner.
688 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
689 ``GNAT'' in the remainder of this document.
693 * What This Reference Manual Contains::
695 * Related Information::
698 @node What This Reference Manual Contains
699 @unnumberedsec What This Reference Manual Contains
702 This reference manual contains the following chapters:
706 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
707 pragmas, which can be used to extend and enhance the functionality of the
711 @ref{Implementation Defined Attributes}, lists GNAT
712 implementation-dependent attributes, which can be used to extend and
713 enhance the functionality of the compiler.
716 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
717 implementation-dependent restrictions, which can be used to extend and
718 enhance the functionality of the compiler.
721 @ref{Implementation Advice}, provides information on generally
722 desirable behavior which are not requirements that all compilers must
723 follow since it cannot be provided on all systems, or which may be
724 undesirable on some systems.
727 @ref{Implementation Defined Characteristics}, provides a guide to
728 minimizing implementation dependent features.
731 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
732 implemented by GNAT, and how they can be imported into user
733 application programs.
736 @ref{Representation Clauses and Pragmas}, describes in detail the
737 way that GNAT represents data, and in particular the exact set
738 of representation clauses and pragmas that is accepted.
741 @ref{Standard Library Routines}, provides a listing of packages and a
742 brief description of the functionality that is provided by Ada's
743 extensive set of standard library routines as implemented by GNAT@.
746 @ref{The Implementation of Standard I/O}, details how the GNAT
747 implementation of the input-output facilities.
750 @ref{The GNAT Library}, is a catalog of packages that complement
751 the Ada predefined library.
754 @ref{Interfacing to Other Languages}, describes how programs
755 written in Ada using GNAT can be interfaced to other programming
758 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
759 of the specialized needs annexes.
762 @ref{Implementation of Specific Ada Features}, discusses issues related
763 to GNAT's implementation of machine code insertions, tasking, and several
767 @ref{Implementation of Ada 2012 Features}, describes the status of the
768 GNAT implementation of the Ada 2012 language standard.
771 @ref{Obsolescent Features} documents implementation dependent features,
772 including pragmas and attributes, which are considered obsolescent, since
773 there are other preferred ways of achieving the same results. These
774 obsolescent forms are retained for backwards compatibility.
778 @cindex Ada 95 Language Reference Manual
779 @cindex Ada 2005 Language Reference Manual
781 This reference manual assumes a basic familiarity with the Ada 95 language, as
782 described in the International Standard ANSI/ISO/IEC-8652:1995,
784 It does not require knowledge of the new features introduced by Ada 2005,
785 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
787 Both reference manuals are included in the GNAT documentation
791 @unnumberedsec Conventions
792 @cindex Conventions, typographical
793 @cindex Typographical conventions
796 Following are examples of the typographical and graphic conventions used
801 @code{Functions}, @code{utility program names}, @code{standard names},
808 @file{File names}, @samp{button names}, and @samp{field names}.
811 @code{Variables}, @env{environment variables}, and @var{metasyntactic
818 [optional information or parameters]
821 Examples are described by text
823 and then shown this way.
828 Commands that are entered by the user are preceded in this manual by the
829 characters @samp{$ } (dollar sign followed by space). If your system uses this
830 sequence as a prompt, then the commands will appear exactly as you see them
831 in the manual. If your system uses some other prompt, then the command will
832 appear with the @samp{$} replaced by whatever prompt character you are using.
834 @node Related Information
835 @unnumberedsec Related Information
837 See the following documents for further information on GNAT:
841 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
842 @value{EDITION} User's Guide}, which provides information on how to use the
843 GNAT compiler system.
846 @cite{Ada 95 Reference Manual}, which contains all reference
847 material for the Ada 95 programming language.
850 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
851 of the Ada 95 standard. The annotations describe
852 detailed aspects of the design decision, and in particular contain useful
853 sections on Ada 83 compatibility.
856 @cite{Ada 2005 Reference Manual}, which contains all reference
857 material for the Ada 2005 programming language.
860 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
861 of the Ada 2005 standard. The annotations describe
862 detailed aspects of the design decision, and in particular contain useful
863 sections on Ada 83 and Ada 95 compatibility.
866 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
867 which contains specific information on compatibility between GNAT and
871 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
872 describes in detail the pragmas and attributes provided by the DEC Ada 83
877 @node Implementation Defined Pragmas
878 @chapter Implementation Defined Pragmas
881 Ada defines a set of pragmas that can be used to supply additional
882 information to the compiler. These language defined pragmas are
883 implemented in GNAT and work as described in the Ada Reference Manual.
885 In addition, Ada allows implementations to define additional pragmas
886 whose meaning is defined by the implementation. GNAT provides a number
887 of these implementation-defined pragmas, which can be used to extend
888 and enhance the functionality of the compiler. This section of the GNAT
889 Reference Manual describes these additional pragmas.
891 Note that any program using these pragmas might not be portable to other
892 compilers (although GNAT implements this set of pragmas on all
893 platforms). Therefore if portability to other compilers is an important
894 consideration, the use of these pragmas should be minimized.
897 * Pragma Abort_Defer::
906 * Pragma Assert_And_Cut::
907 * Pragma Assertion_Policy::
909 * Pragma Assume_No_Invalid_Values::
910 * Pragma Attribute_Definition::
912 * Pragma C_Pass_By_Copy::
914 * Pragma Check_Float_Overflow::
915 * Pragma Check_Name::
916 * Pragma Check_Policy::
918 * Pragma Common_Object::
919 * Pragma Compile_Time_Error::
920 * Pragma Compile_Time_Warning::
921 * Pragma Compiler_Unit::
922 * Pragma Complete_Representation::
923 * Pragma Complex_Representation::
924 * Pragma Component_Alignment::
925 * Pragma Contract_Cases::
926 * Pragma Convention_Identifier::
928 * Pragma CPP_Constructor::
929 * Pragma CPP_Virtual::
930 * Pragma CPP_Vtable::
933 * Pragma Debug_Policy::
934 * Pragma Default_Storage_Pool::
935 * Pragma Detect_Blocking::
936 * Pragma Dispatching_Domain::
937 * Pragma Elaboration_Checks::
939 * Pragma Export_Exception::
940 * Pragma Export_Function::
941 * Pragma Export_Object::
942 * Pragma Export_Procedure::
943 * Pragma Export_Value::
944 * Pragma Export_Valued_Procedure::
945 * Pragma Extend_System::
946 * Pragma Extensions_Allowed::
948 * Pragma External_Name_Casing::
950 * Pragma Favor_Top_Level::
951 * Pragma Finalize_Storage_Only::
952 * Pragma Float_Representation::
954 * Pragma Implementation_Defined::
955 * Pragma Implemented::
956 * Pragma Implicit_Packing::
957 * Pragma Import_Exception::
958 * Pragma Import_Function::
959 * Pragma Import_Object::
960 * Pragma Import_Procedure::
961 * Pragma Import_Valued_Procedure::
962 * Pragma Independent::
963 * Pragma Independent_Components::
964 * Pragma Initialize_Scalars::
965 * Pragma Inline_Always::
966 * Pragma Inline_Generic::
968 * Pragma Interface_Name::
969 * Pragma Interrupt_Handler::
970 * Pragma Interrupt_State::
972 * Pragma Keep_Names::
975 * Pragma Linker_Alias::
976 * Pragma Linker_Constructor::
977 * Pragma Linker_Destructor::
978 * Pragma Linker_Section::
979 * Pragma Long_Float::
980 * Pragma Loop_Invariant::
981 * Pragma Loop_Optimize::
982 * Pragma Loop_Variant::
983 * Pragma Machine_Attribute::
985 * Pragma Main_Storage::
989 * Pragma No_Strict_Aliasing::
990 * Pragma Normalize_Scalars::
991 * Pragma Obsolescent::
992 * Pragma Optimize_Alignment::
994 * Pragma Overflow_Mode::
995 * Pragma Overriding_Renamings::
996 * Pragma Partition_Elaboration_Policy::
998 * Pragma Persistent_BSS::
1000 * Pragma Postcondition::
1001 * Pragma Precondition::
1002 * Pragma Preelaborable_Initialization::
1003 * Pragma Priority_Specific_Dispatching::
1004 * Pragma Profile (Ravenscar)::
1005 * Pragma Profile (Restricted)::
1006 * Pragma Profile (Rational)::
1007 * Pragma Psect_Object::
1008 * Pragma Pure_Function::
1009 * Pragma Relative_Deadline::
1010 * Pragma Remote_Access_Type::
1011 * Pragma Restriction_Warnings::
1013 * Pragma Short_Circuit_And_Or::
1014 * Pragma Short_Descriptors::
1015 * Pragma Simple_Storage_Pool_Type::
1016 * Pragma Source_File_Name::
1017 * Pragma Source_File_Name_Project::
1018 * Pragma Source_Reference::
1019 * Pragma Static_Elaboration_Desired::
1020 * Pragma Stream_Convert::
1021 * Pragma Style_Checks::
1024 * Pragma Suppress_All::
1025 * Pragma Suppress_Exception_Locations::
1026 * Pragma Suppress_Initialization::
1027 * Pragma Task_Info::
1028 * Pragma Task_Name::
1029 * Pragma Task_Storage::
1030 * Pragma Test_Case::
1031 * Pragma Thread_Local_Storage::
1032 * Pragma Time_Slice::
1034 * Pragma Unchecked_Union::
1035 * Pragma Unimplemented_Unit::
1036 * Pragma Universal_Aliasing ::
1037 * Pragma Universal_Data::
1038 * Pragma Unmodified::
1039 * Pragma Unreferenced::
1040 * Pragma Unreferenced_Objects::
1041 * Pragma Unreserve_All_Interrupts::
1042 * Pragma Unsuppress::
1043 * Pragma Use_VADS_Size::
1044 * Pragma Validity_Checks::
1047 * Pragma Weak_External::
1048 * Pragma Wide_Character_Encoding::
1051 @node Pragma Abort_Defer
1052 @unnumberedsec Pragma Abort_Defer
1054 @cindex Deferring aborts
1062 This pragma must appear at the start of the statement sequence of a
1063 handled sequence of statements (right after the @code{begin}). It has
1064 the effect of deferring aborts for the sequence of statements (but not
1065 for the declarations or handlers, if any, associated with this statement
1069 @unnumberedsec Pragma Ada_83
1073 @smallexample @c ada
1078 A configuration pragma that establishes Ada 83 mode for the unit to
1079 which it applies, regardless of the mode set by the command line
1080 switches. In Ada 83 mode, GNAT attempts to be as compatible with
1081 the syntax and semantics of Ada 83, as defined in the original Ada
1082 83 Reference Manual as possible. In particular, the keywords added by Ada 95
1083 and Ada 2005 are not recognized, optional package bodies are allowed,
1084 and generics may name types with unknown discriminants without using
1085 the @code{(<>)} notation. In addition, some but not all of the additional
1086 restrictions of Ada 83 are enforced.
1088 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1089 Ada 83 code to be compiled and adapted to GNAT with less effort.
1090 Secondly, it aids in keeping code backwards compatible with Ada 83.
1091 However, there is no guarantee that code that is processed correctly
1092 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1093 83 compiler, since GNAT does not enforce all the additional checks
1097 @unnumberedsec Pragma Ada_95
1101 @smallexample @c ada
1106 A configuration pragma that establishes Ada 95 mode for the unit to which
1107 it applies, regardless of the mode set by the command line switches.
1108 This mode is set automatically for the @code{Ada} and @code{System}
1109 packages and their children, so you need not specify it in these
1110 contexts. This pragma is useful when writing a reusable component that
1111 itself uses Ada 95 features, but which is intended to be usable from
1112 either Ada 83 or Ada 95 programs.
1115 @unnumberedsec Pragma Ada_05
1119 @smallexample @c ada
1124 A configuration pragma that establishes Ada 2005 mode for the unit to which
1125 it applies, regardless of the mode set by the command line switches.
1126 This pragma is useful when writing a reusable component that
1127 itself uses Ada 2005 features, but which is intended to be usable from
1128 either Ada 83 or Ada 95 programs.
1130 @node Pragma Ada_2005
1131 @unnumberedsec Pragma Ada_2005
1135 @smallexample @c ada
1140 This configuration pragma is a synonym for pragma Ada_05 and has the
1141 same syntax and effect.
1144 @unnumberedsec Pragma Ada_12
1148 @smallexample @c ada
1153 A configuration pragma that establishes Ada 2012 mode for the unit to which
1154 it applies, regardless of the mode set by the command line switches.
1155 This mode is set automatically for the @code{Ada} and @code{System}
1156 packages and their children, so you need not specify it in these
1157 contexts. This pragma is useful when writing a reusable component that
1158 itself uses Ada 2012 features, but which is intended to be usable from
1159 Ada 83, Ada 95, or Ada 2005 programs.
1161 @node Pragma Ada_2012
1162 @unnumberedsec Pragma Ada_2012
1166 @smallexample @c ada
1171 This configuration pragma is a synonym for pragma Ada_12 and has the
1172 same syntax and effect.
1174 @node Pragma Annotate
1175 @unnumberedsec Pragma Annotate
1179 @smallexample @c ada
1180 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1182 ARG ::= NAME | EXPRESSION
1186 This pragma is used to annotate programs. @var{identifier} identifies
1187 the type of annotation. GNAT verifies that it is an identifier, but does
1188 not otherwise analyze it. The second optional identifier is also left
1189 unanalyzed, and by convention is used to control the action of the tool to
1190 which the annotation is addressed. The remaining @var{arg} arguments
1191 can be either string literals or more generally expressions.
1192 String literals are assumed to be either of type
1193 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1194 depending on the character literals they contain.
1195 All other kinds of arguments are analyzed as expressions, and must be
1198 The analyzed pragma is retained in the tree, but not otherwise processed
1199 by any part of the GNAT compiler, except to generate corresponding note
1200 lines in the generated ALI file. For the format of these note lines, see
1201 the compiler source file lib-writ.ads. This pragma is intended for use by
1202 external tools, including ASIS@. The use of pragma Annotate does not
1203 affect the compilation process in any way. This pragma may be used as
1204 a configuration pragma.
1207 @unnumberedsec Pragma Assert
1211 @smallexample @c ada
1214 [, string_EXPRESSION]);
1218 The effect of this pragma depends on whether the corresponding command
1219 line switch is set to activate assertions. The pragma expands into code
1220 equivalent to the following:
1222 @smallexample @c ada
1223 if assertions-enabled then
1224 if not boolean_EXPRESSION then
1225 System.Assertions.Raise_Assert_Failure
1226 (string_EXPRESSION);
1232 The string argument, if given, is the message that will be associated
1233 with the exception occurrence if the exception is raised. If no second
1234 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1235 where @var{file} is the name of the source file containing the assert,
1236 and @var{nnn} is the line number of the assert. A pragma is not a
1237 statement, so if a statement sequence contains nothing but a pragma
1238 assert, then a null statement is required in addition, as in:
1240 @smallexample @c ada
1243 pragma Assert (K > 3, "Bad value for K");
1249 Note that, as with the @code{if} statement to which it is equivalent, the
1250 type of the expression is either @code{Standard.Boolean}, or any type derived
1251 from this standard type.
1253 Assert checks can be either checked or ignored. By default they are ignored.
1254 They will be checked if either the command line switch @option{-gnata} is
1255 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1256 to enable @code{Assert_Checks}.
1258 If assertions are ignored, then there
1259 is no run-time effect (and in particular, any side effects from the
1260 expression will not occur at run time). (The expression is still
1261 analyzed at compile time, and may cause types to be frozen if they are
1262 mentioned here for the first time).
1264 If assertions are checked, then the given expression is tested, and if
1265 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1266 which results in the raising of @code{Assert_Failure} with the given message.
1268 You should generally avoid side effects in the expression arguments of
1269 this pragma, because these side effects will turn on and off with the
1270 setting of the assertions mode, resulting in assertions that have an
1271 effect on the program. However, the expressions are analyzed for
1272 semantic correctness whether or not assertions are enabled, so turning
1273 assertions on and off cannot affect the legality of a program.
1275 Note that the implementation defined policy @code{DISABLE}, given in a
1276 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1278 Note: this is a standard language-defined pragma in versions
1279 of Ada from 2005 on. In GNAT, it is implemented in all versions
1280 of Ada, and the DISABLE policy is an implementation-defined
1283 @node Pragma Assert_And_Cut
1284 @unnumberedsec Pragma Assert_And_Cut
1285 @findex Assert_And_Cut
1288 @smallexample @c ada
1289 pragma Assert_And_Cut (
1291 [, string_EXPRESSION]);
1295 The effect of this pragma is identical to that of pragma @code{Assert},
1296 except that in an @code{Assertion_Policy} pragma, the identifier
1297 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1300 The intention is that this be used within a subprogram when the
1301 given test expresion sums up all the work done so far in the
1302 subprogram, so that the rest of the subprogram can be verified
1303 (informally or formally) using only the entry preconditions,
1304 and the expression in this pragma. This allows dividing up
1305 a subprogram into sections for the purposes of testing or
1306 formal verification. The pragma also serves as useful
1309 @node Pragma Assertion_Policy
1310 @unnumberedsec Pragma Assertion_Policy
1311 @findex Assertion_Policy
1314 @smallexample @c ada
1315 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1317 pragma Assertion_Policy (
1318 ASSERTION_KIND => POLICY_IDENTIFIER
1319 @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1321 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1323 RM_ASSERTION_KIND ::= Assert |
1331 Type_Invariant'Class
1333 ID_ASSERTION_KIND ::= Assertions |
1345 Statement_Assertions
1347 POLICY_IDENTIFIER ::= Check | Disable | Ignore
1351 This is a standard Ada 2012 pragma that is available as an
1352 implementation-defined pragma in earlier versions of Ada.
1353 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1354 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1355 are implementation defined additions recognized by the GNAT compiler.
1357 The pragma applies in both cases to pragmas and aspects with matching
1358 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1359 applies to both the @code{Precondition} pragma
1360 and the aspect @code{Precondition}.
1362 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1363 the corresponding pragma or aspect is activated.
1364 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1365 the corresponding pragma or aspect is deactivated.
1366 This pragma overrides the effect of the @option{-gnata} switch on the
1369 The implementation defined policy @code{DISABLE} is like
1370 @code{IGNORE} except that it completely disables semantic
1371 checking of the corresponding pragma or aspect. This is
1372 useful when the pragma or aspect argument references subprograms
1373 in a with'ed package which is replaced by a dummy package
1374 for the final build.
1376 The implementation defined policy @code{Assertions} applies to all
1377 assertion kinds. The form with no assertion kind given implies this
1378 choice, so it applies to all assertion kinds (RM defined, and
1379 implementation defined).
1381 The implementation defined policy @code{Statement_Assertions}
1382 applies to @code{Assert}, @code{Assert_And_Cut},
1383 @code{Assume}, and @code{Loop_Invariant}.
1386 @unnumberedsec Pragma Assume
1390 @smallexample @c ada
1393 [, string_EXPRESSION]);
1397 The effect of this pragma is identical to that of pragma @code{Assert},
1398 except that in an @code{Assertion_Policy} pragma, the identifier
1399 @code{Assume} is used to control whether it is ignored or checked
1402 The intention is that this be used for assumptions about the
1403 external environment. So you cannot expect to verify formally
1404 or informally that the condition is met, this must be
1405 established by examining things outside the program itself.
1406 For example, we may have code that depends on the size of
1407 @code{Long_Long_Integer} being at least 64. So we could write:
1409 @smallexample @c ada
1410 pragma Assume (Long_Long_Integer'Size >= 64);
1414 This assumption cannot be proved from the program itself,
1415 but it acts as a useful run-time check that the assumption
1416 is met, and documents the need to ensure that it is met by
1417 reference to information outside the program.
1419 @node Pragma Assume_No_Invalid_Values
1420 @unnumberedsec Pragma Assume_No_Invalid_Values
1421 @findex Assume_No_Invalid_Values
1422 @cindex Invalid representations
1423 @cindex Invalid values
1426 @smallexample @c ada
1427 pragma Assume_No_Invalid_Values (On | Off);
1431 This is a configuration pragma that controls the assumptions made by the
1432 compiler about the occurrence of invalid representations (invalid values)
1435 The default behavior (corresponding to an Off argument for this pragma), is
1436 to assume that values may in general be invalid unless the compiler can
1437 prove they are valid. Consider the following example:
1439 @smallexample @c ada
1440 V1 : Integer range 1 .. 10;
1441 V2 : Integer range 11 .. 20;
1443 for J in V2 .. V1 loop
1449 if V1 and V2 have valid values, then the loop is known at compile
1450 time not to execute since the lower bound must be greater than the
1451 upper bound. However in default mode, no such assumption is made,
1452 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1453 is given, the compiler will assume that any occurrence of a variable
1454 other than in an explicit @code{'Valid} test always has a valid
1455 value, and the loop above will be optimized away.
1457 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1458 you know your code is free of uninitialized variables and other
1459 possible sources of invalid representations, and may result in
1460 more efficient code. A program that accesses an invalid representation
1461 with this pragma in effect is erroneous, so no guarantees can be made
1464 It is peculiar though permissible to use this pragma in conjunction
1465 with validity checking (-gnatVa). In such cases, accessing invalid
1466 values will generally give an exception, though formally the program
1467 is erroneous so there are no guarantees that this will always be the
1468 case, and it is recommended that these two options not be used together.
1470 @node Pragma Ast_Entry
1471 @unnumberedsec Pragma Ast_Entry
1476 @smallexample @c ada
1477 pragma AST_Entry (entry_IDENTIFIER);
1481 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1482 argument is the simple name of a single entry; at most one @code{AST_Entry}
1483 pragma is allowed for any given entry. This pragma must be used in
1484 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1485 the entry declaration and in the same task type specification or single task
1486 as the entry to which it applies. This pragma specifies that the given entry
1487 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1488 resulting from an OpenVMS system service call. The pragma does not affect
1489 normal use of the entry. For further details on this pragma, see the
1490 DEC Ada Language Reference Manual, section 9.12a.
1492 @node Pragma Attribute_Definition
1493 @unnumberedsec Pragma Attribute_Definition
1494 @findex Attribute_Definition
1497 @smallexample @c ada
1498 pragma Attribute_Definition
1499 ([Attribute =>] ATTRIBUTE_DESIGNATOR,
1500 [Entity =>] LOCAL_NAME,
1501 [Expression =>] EXPRESSION | NAME);
1505 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1506 the attribute definition clause:
1508 @smallexample @c ada
1509 for Entity'Attribute use Expression;
1512 If @code{Attribute} is not a recognized attribute name, the pragma is
1513 ignored, and a warning is emitted. This allows source
1514 code to be written that takes advantage of some new attribute, while remaining
1515 compilable with earlier compilers.
1517 @node Pragma C_Pass_By_Copy
1518 @unnumberedsec Pragma C_Pass_By_Copy
1519 @cindex Passing by copy
1520 @findex C_Pass_By_Copy
1523 @smallexample @c ada
1524 pragma C_Pass_By_Copy
1525 ([Max_Size =>] static_integer_EXPRESSION);
1529 Normally the default mechanism for passing C convention records to C
1530 convention subprograms is to pass them by reference, as suggested by RM
1531 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1532 this default, by requiring that record formal parameters be passed by
1533 copy if all of the following conditions are met:
1537 The size of the record type does not exceed the value specified for
1540 The record type has @code{Convention C}.
1542 The formal parameter has this record type, and the subprogram has a
1543 foreign (non-Ada) convention.
1547 If these conditions are met the argument is passed by copy, i.e.@: in a
1548 manner consistent with what C expects if the corresponding formal in the
1549 C prototype is a struct (rather than a pointer to a struct).
1551 You can also pass records by copy by specifying the convention
1552 @code{C_Pass_By_Copy} for the record type, or by using the extended
1553 @code{Import} and @code{Export} pragmas, which allow specification of
1554 passing mechanisms on a parameter by parameter basis.
1557 @unnumberedsec Pragma Check
1559 @cindex Named assertions
1563 @smallexample @c ada
1565 [Name =>] CHECK_KIND,
1566 [Check =>] Boolean_EXPRESSION
1567 [, [Message =>] string_EXPRESSION] );
1569 CHECK_KIND ::= IDENTIFIER |
1572 Type_Invariant'Class |
1577 This pragma is similar to the predefined pragma @code{Assert} except that an
1578 extra identifier argument is present. In conjunction with pragma
1579 @code{Check_Policy}, this can be used to define groups of assertions that can
1580 be independently controlled. The identifier @code{Assertion} is special, it
1581 refers to the normal set of pragma @code{Assert} statements.
1583 Checks introduced by this pragma are normally deactivated by default. They can
1584 be activated either by the command line option @option{-gnata}, which turns on
1585 all checks, or individually controlled using pragma @code{Check_Policy}.
1587 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
1588 permitted as check kinds, since this would cause confusion with the use
1589 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
1590 pragmas, where they are used to refer to sets of assertions.
1592 @node Pragma Check_Float_Overflow
1593 @unnumberedsec Pragma Check_Float_Overflow
1594 @cindex Floating-point overflow
1595 @findex Check_Float_Overflow
1598 @smallexample @c ada
1599 pragma Check_Float_Overflow;
1603 In Ada, the predefined floating-point types (@code{Short_Float},
1604 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1605 defined to be @emph{unconstrained}. This means that even though each
1606 has a well-defined base range, an operation that delivers a result
1607 outside this base range is not required to raise an exception.
1608 This implementation permission accommodates the notion
1609 of infinities in IEEE floating-point, and corresponds to the
1610 efficient execution mode on most machines. GNAT will not raise
1611 overflow exceptions on these machines; instead it will generate
1612 infinities and NaN's as defined in the IEEE standard.
1614 Generating infinities, although efficient, is not always desirable.
1615 Often the preferable approach is to check for overflow, even at the
1616 (perhaps considerable) expense of run-time performance.
1617 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1618 range constraints -- and indeed such a subtype
1619 can have the same base range as its base type. For example:
1621 @smallexample @c ada
1622 subtype My_Float is Float range Float'Range;
1626 Here @code{My_Float} has the same range as
1627 @code{Float} but is constrained, so operations on
1628 @code{My_Float} values will be checked for overflow
1631 This style will achieve the desired goal, but
1632 it is often more convenient to be able to simply use
1633 the standard predefined floating-point types as long
1634 as overflow checking could be guaranteed.
1635 The @code{Check_Float_Overflow}
1636 configuration pragma achieves this effect. If a unit is compiled
1637 subject to this configuration pragma, then all operations
1638 on predefined floating-point types will be treated as
1639 though those types were constrained, and overflow checks
1640 will be generated. The @code{Constraint_Error}
1641 exception is raised if the result is out of range.
1643 This mode can also be set by use of the compiler
1644 switch @option{-gnateF}.
1646 @node Pragma Check_Name
1647 @unnumberedsec Pragma Check_Name
1648 @cindex Defining check names
1649 @cindex Check names, defining
1653 @smallexample @c ada
1654 pragma Check_Name (check_name_IDENTIFIER);
1658 This is a configuration pragma that defines a new implementation
1659 defined check name (unless IDENTIFIER matches one of the predefined
1660 check names, in which case the pragma has no effect). Check names
1661 are global to a partition, so if two or more configuration pragmas
1662 are present in a partition mentioning the same name, only one new
1663 check name is introduced.
1665 An implementation defined check name introduced with this pragma may
1666 be used in only three contexts: @code{pragma Suppress},
1667 @code{pragma Unsuppress},
1668 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1669 any of these three cases, the check name must be visible. A check
1670 name is visible if it is in the configuration pragmas applying to
1671 the current unit, or if it appears at the start of any unit that
1672 is part of the dependency set of the current unit (e.g., units that
1673 are mentioned in @code{with} clauses).
1675 Check names introduced by this pragma are subject to control by compiler
1676 switches (in particular -gnatp) in the usual manner.
1678 @node Pragma Check_Policy
1679 @unnumberedsec Pragma Check_Policy
1680 @cindex Controlling assertions
1681 @cindex Assertions, control
1682 @cindex Check pragma control
1683 @cindex Named assertions
1687 @smallexample @c ada
1689 ([Name =>] CHECK_KIND,
1690 [Policy =>] POLICY_IDENTIFIER);
1692 pragma Check_Policy (
1693 CHECK_KIND => POLICY_IDENTIFIER
1694 @{, CHECK_KIND => POLICY_IDENTIFIER@});
1696 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1698 CHECK_KIND ::= IDENTIFIER |
1701 Type_Invariant'Class |
1704 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
1705 avoids confusion between the two possible syntax forms for this pragma.
1707 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1711 This pragma is used to set the checking policy for assertions (specified
1712 by aspects or pragmas), the @code{Debug} pragma, or additional checks
1713 to be checked using the @code{Check} pragma. It may appear either as
1714 a configuration pragma, or within a declarative part of package. In the
1715 latter case, it applies from the point where it appears to the end of
1716 the declarative region (like pragma @code{Suppress}).
1718 The @code{Check_Policy} pragma is similar to the
1719 predefined @code{Assertion_Policy} pragma,
1720 and if the check kind corresponds to one of the assertion kinds that
1721 are allowed by @code{Assertion_Policy}, then the effect is identical.
1723 If the first argument is Debug, then the policy applies to Debug pragmas,
1724 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
1725 @code{IGNORE}, and allowing them to execute with normal semantics if
1726 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
1727 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
1728 be totally ignored and not analyzed semantically.
1730 Finally the first argument may be some other identifier than the above
1731 possibilities, in which case it controls a set of named assertions
1732 that can be checked using pragma @code{Check}. For example, if the pragma:
1734 @smallexample @c ada
1735 pragma Check_Policy (Critical_Error, OFF);
1739 is given, then subsequent @code{Check} pragmas whose first argument is also
1740 @code{Critical_Error} will be disabled.
1742 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1743 to turn on corresponding checks. The default for a set of checks for which no
1744 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1745 @option{-gnata} is given, which turns on all checks by default.
1747 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
1748 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1749 compatibility with the standard @code{Assertion_Policy} pragma. The check
1750 policy setting @code{DISABLE} causes the second argument of a corresponding
1751 @code{Check} pragma to be completely ignored and not analyzed.
1753 @node Pragma Comment
1754 @unnumberedsec Pragma Comment
1759 @smallexample @c ada
1760 pragma Comment (static_string_EXPRESSION);
1764 This is almost identical in effect to pragma @code{Ident}. It allows the
1765 placement of a comment into the object file and hence into the
1766 executable file if the operating system permits such usage. The
1767 difference is that @code{Comment}, unlike @code{Ident}, has
1768 no limitations on placement of the pragma (it can be placed
1769 anywhere in the main source unit), and if more than one pragma
1770 is used, all comments are retained.
1772 @node Pragma Common_Object
1773 @unnumberedsec Pragma Common_Object
1774 @findex Common_Object
1778 @smallexample @c ada
1779 pragma Common_Object (
1780 [Internal =>] LOCAL_NAME
1781 [, [External =>] EXTERNAL_SYMBOL]
1782 [, [Size =>] EXTERNAL_SYMBOL] );
1786 | static_string_EXPRESSION
1790 This pragma enables the shared use of variables stored in overlaid
1791 linker areas corresponding to the use of @code{COMMON}
1792 in Fortran. The single
1793 object @var{LOCAL_NAME} is assigned to the area designated by
1794 the @var{External} argument.
1795 You may define a record to correspond to a series
1796 of fields. The @var{Size} argument
1797 is syntax checked in GNAT, but otherwise ignored.
1799 @code{Common_Object} is not supported on all platforms. If no
1800 support is available, then the code generator will issue a message
1801 indicating that the necessary attribute for implementation of this
1802 pragma is not available.
1804 @node Pragma Compile_Time_Error
1805 @unnumberedsec Pragma Compile_Time_Error
1806 @findex Compile_Time_Error
1810 @smallexample @c ada
1811 pragma Compile_Time_Error
1812 (boolean_EXPRESSION, static_string_EXPRESSION);
1816 This pragma can be used to generate additional compile time
1818 is particularly useful in generics, where errors can be issued for
1819 specific problematic instantiations. The first parameter is a boolean
1820 expression. The pragma is effective only if the value of this expression
1821 is known at compile time, and has the value True. The set of expressions
1822 whose values are known at compile time includes all static boolean
1823 expressions, and also other values which the compiler can determine
1824 at compile time (e.g., the size of a record type set by an explicit
1825 size representation clause, or the value of a variable which was
1826 initialized to a constant and is known not to have been modified).
1827 If these conditions are met, an error message is generated using
1828 the value given as the second argument. This string value may contain
1829 embedded ASCII.LF characters to break the message into multiple lines.
1831 @node Pragma Compile_Time_Warning
1832 @unnumberedsec Pragma Compile_Time_Warning
1833 @findex Compile_Time_Warning
1837 @smallexample @c ada
1838 pragma Compile_Time_Warning
1839 (boolean_EXPRESSION, static_string_EXPRESSION);
1843 Same as pragma Compile_Time_Error, except a warning is issued instead
1844 of an error message. Note that if this pragma is used in a package that
1845 is with'ed by a client, the client will get the warning even though it
1846 is issued by a with'ed package (normally warnings in with'ed units are
1847 suppressed, but this is a special exception to that rule).
1849 One typical use is within a generic where compile time known characteristics
1850 of formal parameters are tested, and warnings given appropriately. Another use
1851 with a first parameter of True is to warn a client about use of a package,
1852 for example that it is not fully implemented.
1854 @node Pragma Compiler_Unit
1855 @unnumberedsec Pragma Compiler_Unit
1856 @findex Compiler_Unit
1860 @smallexample @c ada
1861 pragma Compiler_Unit;
1865 This pragma is intended only for internal use in the GNAT run-time library.
1866 It indicates that the unit is used as part of the compiler build. The effect
1867 is to disallow constructs (raise with message, conditional expressions etc)
1868 that would cause trouble when bootstrapping using an older version of GNAT.
1869 For the exact list of restrictions, see the compiler sources and references
1870 to Is_Compiler_Unit.
1872 @node Pragma Complete_Representation
1873 @unnumberedsec Pragma Complete_Representation
1874 @findex Complete_Representation
1878 @smallexample @c ada
1879 pragma Complete_Representation;
1883 This pragma must appear immediately within a record representation
1884 clause. Typical placements are before the first component clause
1885 or after the last component clause. The effect is to give an error
1886 message if any component is missing a component clause. This pragma
1887 may be used to ensure that a record representation clause is
1888 complete, and that this invariant is maintained if fields are
1889 added to the record in the future.
1891 @node Pragma Complex_Representation
1892 @unnumberedsec Pragma Complex_Representation
1893 @findex Complex_Representation
1897 @smallexample @c ada
1898 pragma Complex_Representation
1899 ([Entity =>] LOCAL_NAME);
1903 The @var{Entity} argument must be the name of a record type which has
1904 two fields of the same floating-point type. The effect of this pragma is
1905 to force gcc to use the special internal complex representation form for
1906 this record, which may be more efficient. Note that this may result in
1907 the code for this type not conforming to standard ABI (application
1908 binary interface) requirements for the handling of record types. For
1909 example, in some environments, there is a requirement for passing
1910 records by pointer, and the use of this pragma may result in passing
1911 this type in floating-point registers.
1913 @node Pragma Component_Alignment
1914 @unnumberedsec Pragma Component_Alignment
1915 @cindex Alignments of components
1916 @findex Component_Alignment
1920 @smallexample @c ada
1921 pragma Component_Alignment (
1922 [Form =>] ALIGNMENT_CHOICE
1923 [, [Name =>] type_LOCAL_NAME]);
1925 ALIGNMENT_CHOICE ::=
1933 Specifies the alignment of components in array or record types.
1934 The meaning of the @var{Form} argument is as follows:
1937 @findex Component_Size
1938 @item Component_Size
1939 Aligns scalar components and subcomponents of the array or record type
1940 on boundaries appropriate to their inherent size (naturally
1941 aligned). For example, 1-byte components are aligned on byte boundaries,
1942 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1943 integer components are aligned on 4-byte boundaries and so on. These
1944 alignment rules correspond to the normal rules for C compilers on all
1945 machines except the VAX@.
1947 @findex Component_Size_4
1948 @item Component_Size_4
1949 Naturally aligns components with a size of four or fewer
1950 bytes. Components that are larger than 4 bytes are placed on the next
1953 @findex Storage_Unit
1955 Specifies that array or record components are byte aligned, i.e.@:
1956 aligned on boundaries determined by the value of the constant
1957 @code{System.Storage_Unit}.
1961 Specifies that array or record components are aligned on default
1962 boundaries, appropriate to the underlying hardware or operating system or
1963 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1964 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1965 the @code{Default} choice is the same as @code{Component_Size} (natural
1970 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1971 refer to a local record or array type, and the specified alignment
1972 choice applies to the specified type. The use of
1973 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1974 @code{Component_Alignment} pragma to be ignored. The use of
1975 @code{Component_Alignment} together with a record representation clause
1976 is only effective for fields not specified by the representation clause.
1978 If the @code{Name} parameter is absent, the pragma can be used as either
1979 a configuration pragma, in which case it applies to one or more units in
1980 accordance with the normal rules for configuration pragmas, or it can be
1981 used within a declarative part, in which case it applies to types that
1982 are declared within this declarative part, or within any nested scope
1983 within this declarative part. In either case it specifies the alignment
1984 to be applied to any record or array type which has otherwise standard
1987 If the alignment for a record or array type is not specified (using
1988 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1989 clause), the GNAT uses the default alignment as described previously.
1991 @node Pragma Contract_Cases
1992 @unnumberedsec Pragma Contract_Cases
1993 @cindex Contract cases
1994 @findex Contract_Cases
1998 @smallexample @c ada
1999 pragma Contract_Cases (
2000 Condition => Consequence
2001 @{,Condition => Consequence@});
2005 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2006 that can complement or replace the contract given by a precondition and a
2007 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2008 by testing and formal verification tools. The compiler checks its validity and,
2009 depending on the assertion policy at the point of declaration of the pragma,
2010 it may insert a check in the executable. For code generation, the contract
2013 @smallexample @c ada
2014 pragma Contract_Cases (
2022 @smallexample @c ada
2023 C1 : constant Boolean := Cond1; -- evaluated at subprogram entry
2024 C2 : constant Boolean := Cond2; -- evaluated at subprogram entry
2025 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2026 pragma Postcondition (if C1 then Pred1);
2027 pragma Postcondition (if C2 then Pred2);
2031 The precondition ensures that one and only one of the conditions is
2032 satisfied on entry to the subprogram.
2033 The postcondition ensures that for the condition that was True on entry,
2034 the corrresponding consequence is True on exit. Other consequence expressions
2037 A precondition @code{P} and postcondition @code{Q} can also be
2038 expressed as contract cases:
2040 @smallexample @c ada
2041 pragma Contract_Cases (P => Q);
2044 The placement and visibility rules for @code{Contract_Cases} pragmas are
2045 identical to those described for preconditions and postconditions.
2047 The compiler checks that boolean expressions given in conditions and
2048 consequences are valid, where the rules for conditions are the same as
2049 the rule for an expression in @code{Precondition} and the rules for
2050 consequences are the same as the rule for an expression in
2051 @code{Postcondition}. In particular, attributes @code{'Old} and
2052 @code{'Result} can only be used within consequence expressions.
2053 The condition for the last contract case may be @code{others}, to denote
2054 any case not captured by the previous cases. The
2055 following is an example of use within a package spec:
2057 @smallexample @c ada
2058 package Math_Functions is
2060 function Sqrt (Arg : Float) return Float;
2061 pragma Contract_Cases ((Arg in 0 .. 99) => Sqrt'Result < 10,
2062 Arg >= 100 => Sqrt'Result >= 10,
2063 others => Sqrt'Result = 0);
2069 The meaning of contract cases is that only one case should apply at each
2070 call, as determined by the corresponding condition evaluating to True,
2071 and that the consequence for this case should hold when the subprogram
2074 @node Pragma Convention_Identifier
2075 @unnumberedsec Pragma Convention_Identifier
2076 @findex Convention_Identifier
2077 @cindex Conventions, synonyms
2081 @smallexample @c ada
2082 pragma Convention_Identifier (
2083 [Name =>] IDENTIFIER,
2084 [Convention =>] convention_IDENTIFIER);
2088 This pragma provides a mechanism for supplying synonyms for existing
2089 convention identifiers. The @code{Name} identifier can subsequently
2090 be used as a synonym for the given convention in other pragmas (including
2091 for example pragma @code{Import} or another @code{Convention_Identifier}
2092 pragma). As an example of the use of this, suppose you had legacy code
2093 which used Fortran77 as the identifier for Fortran. Then the pragma:
2095 @smallexample @c ada
2096 pragma Convention_Identifier (Fortran77, Fortran);
2100 would allow the use of the convention identifier @code{Fortran77} in
2101 subsequent code, avoiding the need to modify the sources. As another
2102 example, you could use this to parameterize convention requirements
2103 according to systems. Suppose you needed to use @code{Stdcall} on
2104 windows systems, and @code{C} on some other system, then you could
2105 define a convention identifier @code{Library} and use a single
2106 @code{Convention_Identifier} pragma to specify which convention
2107 would be used system-wide.
2109 @node Pragma CPP_Class
2110 @unnumberedsec Pragma CPP_Class
2112 @cindex Interfacing with C++
2116 @smallexample @c ada
2117 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2121 The argument denotes an entity in the current declarative region that is
2122 declared as a record type. It indicates that the type corresponds to an
2123 externally declared C++ class type, and is to be laid out the same way
2124 that C++ would lay out the type. If the C++ class has virtual primitives
2125 then the record must be declared as a tagged record type.
2127 Types for which @code{CPP_Class} is specified do not have assignment or
2128 equality operators defined (such operations can be imported or declared
2129 as subprograms as required). Initialization is allowed only by constructor
2130 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2131 limited if not explicitly declared as limited or derived from a limited
2132 type, and an error is issued in that case.
2134 See @ref{Interfacing to C++} for related information.
2136 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2137 for backward compatibility but its functionality is available
2138 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2140 @node Pragma CPP_Constructor
2141 @unnumberedsec Pragma CPP_Constructor
2142 @cindex Interfacing with C++
2143 @findex CPP_Constructor
2147 @smallexample @c ada
2148 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2149 [, [External_Name =>] static_string_EXPRESSION ]
2150 [, [Link_Name =>] static_string_EXPRESSION ]);
2154 This pragma identifies an imported function (imported in the usual way
2155 with pragma @code{Import}) as corresponding to a C++ constructor. If
2156 @code{External_Name} and @code{Link_Name} are not specified then the
2157 @code{Entity} argument is a name that must have been previously mentioned
2158 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2159 must be of one of the following forms:
2163 @code{function @var{Fname} return @var{T}}
2167 @code{function @var{Fname} return @var{T}'Class}
2170 @code{function @var{Fname} (@dots{}) return @var{T}}
2174 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2178 where @var{T} is a limited record type imported from C++ with pragma
2179 @code{Import} and @code{Convention} = @code{CPP}.
2181 The first two forms import the default constructor, used when an object
2182 of type @var{T} is created on the Ada side with no explicit constructor.
2183 The latter two forms cover all the non-default constructors of the type.
2184 See the @value{EDITION} User's Guide for details.
2186 If no constructors are imported, it is impossible to create any objects
2187 on the Ada side and the type is implicitly declared abstract.
2189 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2190 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2192 See @ref{Interfacing to C++} for more related information.
2194 Note: The use of functions returning class-wide types for constructors is
2195 currently obsolete. They are supported for backward compatibility. The
2196 use of functions returning the type T leave the Ada sources more clear
2197 because the imported C++ constructors always return an object of type T;
2198 that is, they never return an object whose type is a descendant of type T.
2200 @node Pragma CPP_Virtual
2201 @unnumberedsec Pragma CPP_Virtual
2202 @cindex Interfacing to C++
2205 This pragma is now obsolete has has no effect because GNAT generates
2206 the same object layout than the G++ compiler.
2208 See @ref{Interfacing to C++} for related information.
2210 @node Pragma CPP_Vtable
2211 @unnumberedsec Pragma CPP_Vtable
2212 @cindex Interfacing with C++
2215 This pragma is now obsolete has has no effect because GNAT generates
2216 the same object layout than the G++ compiler.
2218 See @ref{Interfacing to C++} for related information.
2221 @unnumberedsec Pragma CPU
2226 @smallexample @c ada
2227 pragma CPU (EXPRESSSION);
2231 This pragma is standard in Ada 2012, but is available in all earlier
2232 versions of Ada as an implementation-defined pragma.
2233 See Ada 2012 Reference Manual for details.
2236 @unnumberedsec Pragma Debug
2241 @smallexample @c ada
2242 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2244 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2246 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2250 The procedure call argument has the syntactic form of an expression, meeting
2251 the syntactic requirements for pragmas.
2253 If debug pragmas are not enabled or if the condition is present and evaluates
2254 to False, this pragma has no effect. If debug pragmas are enabled, the
2255 semantics of the pragma is exactly equivalent to the procedure call statement
2256 corresponding to the argument with a terminating semicolon. Pragmas are
2257 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2258 intersperse calls to debug procedures in the middle of declarations. Debug
2259 pragmas can be enabled either by use of the command line switch @option{-gnata}
2260 or by use of the pragma @code{Check_Policy} with a first argument of
2263 @node Pragma Debug_Policy
2264 @unnumberedsec Pragma Debug_Policy
2265 @findex Debug_Policy
2269 @smallexample @c ada
2270 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2274 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2275 with a first argument of @code{Debug}. It is retained for historical
2276 compatibility reasons.
2278 @node Pragma Default_Storage_Pool
2279 @unnumberedsec Pragma Default_Storage_Pool
2280 @findex Default_Storage_Pool
2284 @smallexample @c ada
2285 pragma Default_Storage_Pool (storage_pool_NAME | null);
2289 This pragma is standard in Ada 2012, but is available in all earlier
2290 versions of Ada as an implementation-defined pragma.
2291 See Ada 2012 Reference Manual for details.
2293 @node Pragma Detect_Blocking
2294 @unnumberedsec Pragma Detect_Blocking
2295 @findex Detect_Blocking
2299 @smallexample @c ada
2300 pragma Detect_Blocking;
2304 This is a standard pragma in Ada 2005, that is available in all earlier
2305 versions of Ada as an implementation-defined pragma.
2307 This is a configuration pragma that forces the detection of potentially
2308 blocking operations within a protected operation, and to raise Program_Error
2311 @node Pragma Dispatching_Domain
2312 @unnumberedsec Pragma Dispatching_Domain
2313 @findex Dispatching_Domain
2317 @smallexample @c ada
2318 pragma Dispatching_Domain (EXPRESSION);
2322 This pragma is standard in Ada 2012, but is available in all earlier
2323 versions of Ada as an implementation-defined pragma.
2324 See Ada 2012 Reference Manual for details.
2326 @node Pragma Elaboration_Checks
2327 @unnumberedsec Pragma Elaboration_Checks
2328 @cindex Elaboration control
2329 @findex Elaboration_Checks
2333 @smallexample @c ada
2334 pragma Elaboration_Checks (Dynamic | Static);
2338 This is a configuration pragma that provides control over the
2339 elaboration model used by the compilation affected by the
2340 pragma. If the parameter is @code{Dynamic},
2341 then the dynamic elaboration
2342 model described in the Ada Reference Manual is used, as though
2343 the @option{-gnatE} switch had been specified on the command
2344 line. If the parameter is @code{Static}, then the default GNAT static
2345 model is used. This configuration pragma overrides the setting
2346 of the command line. For full details on the elaboration models
2347 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2348 gnat_ugn, @value{EDITION} User's Guide}.
2350 @node Pragma Eliminate
2351 @unnumberedsec Pragma Eliminate
2352 @cindex Elimination of unused subprograms
2357 @smallexample @c ada
2358 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
2359 [Source_Location =>] STRING_LITERAL);
2363 The string literal given for the source location is a string which
2364 specifies the line number of the occurrence of the entity, using
2365 the syntax for SOURCE_TRACE given below:
2367 @smallexample @c ada
2368 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2373 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2375 LINE_NUMBER ::= DIGIT @{DIGIT@}
2379 Spaces around the colon in a @code{Source_Reference} are optional.
2381 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2382 explicit subprogram declaration, where the @code{entity} name in this
2383 designator appears on the source line specified by the source location.
2385 The source trace that is given as the @code{Source_Location} shall obey the
2386 following rules. The @code{FILE_NAME} is the short name (with no directory
2387 information) of an Ada source file, given using exactly the required syntax
2388 for the underlying file system (e.g. case is important if the underlying
2389 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2390 number of the occurrence of the @code{entity}
2391 as a decimal literal without an exponent or point. If an @code{entity} is not
2392 declared in a generic instantiation (this includes generic subprogram
2393 instances), the source trace includes only one source reference. If an entity
2394 is declared inside a generic instantiation, its source trace (when parsing
2395 from left to right) starts with the source location of the declaration of the
2396 entity in the generic unit and ends with the source location of the
2397 instantiation (it is given in square brackets). This approach is recursively
2398 used in case of nested instantiations: the rightmost (nested most deeply in
2399 square brackets) element of the source trace is the location of the outermost
2400 instantiation, the next to left element is the location of the next (first
2401 nested) instantiation in the code of the corresponding generic unit, and so
2402 on, and the leftmost element (that is out of any square brackets) is the
2403 location of the declaration of the entity to eliminate in a generic unit.
2405 Note that the @code{Source_Location} argument specifies which of a set of
2406 similarly named entities is being eliminated, dealing both with overloading,
2407 and also appearence of the same entity name in different scopes.
2409 This pragma indicates that the given entity is not used in the program to be
2410 compiled and built. The effect of the pragma is to allow the compiler to
2411 eliminate the code or data associated with the named entity. Any reference to
2412 an eliminated entity causes a compile-time or link-time error.
2414 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2415 in a system-independent manner, with unused entities eliminated, without
2416 needing to modify the source text. Normally the required set of
2417 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2419 Any source file change that removes, splits, or
2420 adds lines may make the set of Eliminate pragmas invalid because their
2421 @code{Source_Location} argument values may get out of date.
2423 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2424 operation. In this case all the subprograms to which the given operation can
2425 dispatch are considered to be unused (are never called as a result of a direct
2426 or a dispatching call).
2428 @node Pragma Export_Exception
2429 @unnumberedsec Pragma Export_Exception
2431 @findex Export_Exception
2435 @smallexample @c ada
2436 pragma Export_Exception (
2437 [Internal =>] LOCAL_NAME
2438 [, [External =>] EXTERNAL_SYMBOL]
2439 [, [Form =>] Ada | VMS]
2440 [, [Code =>] static_integer_EXPRESSION]);
2444 | static_string_EXPRESSION
2448 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
2449 causes the specified exception to be propagated outside of the Ada program,
2450 so that it can be handled by programs written in other OpenVMS languages.
2451 This pragma establishes an external name for an Ada exception and makes the
2452 name available to the OpenVMS Linker as a global symbol. For further details
2453 on this pragma, see the
2454 DEC Ada Language Reference Manual, section 13.9a3.2.
2456 @node Pragma Export_Function
2457 @unnumberedsec Pragma Export_Function
2458 @cindex Argument passing mechanisms
2459 @findex Export_Function
2464 @smallexample @c ada
2465 pragma Export_Function (
2466 [Internal =>] LOCAL_NAME
2467 [, [External =>] EXTERNAL_SYMBOL]
2468 [, [Parameter_Types =>] PARAMETER_TYPES]
2469 [, [Result_Type =>] result_SUBTYPE_MARK]
2470 [, [Mechanism =>] MECHANISM]
2471 [, [Result_Mechanism =>] MECHANISM_NAME]);
2475 | static_string_EXPRESSION
2480 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2484 | subtype_Name ' Access
2488 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2490 MECHANISM_ASSOCIATION ::=
2491 [formal_parameter_NAME =>] MECHANISM_NAME
2496 | Descriptor [([Class =>] CLASS_NAME)]
2497 | Short_Descriptor [([Class =>] CLASS_NAME)]
2499 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2503 Use this pragma to make a function externally callable and optionally
2504 provide information on mechanisms to be used for passing parameter and
2505 result values. We recommend, for the purposes of improving portability,
2506 this pragma always be used in conjunction with a separate pragma
2507 @code{Export}, which must precede the pragma @code{Export_Function}.
2508 GNAT does not require a separate pragma @code{Export}, but if none is
2509 present, @code{Convention Ada} is assumed, which is usually
2510 not what is wanted, so it is usually appropriate to use this
2511 pragma in conjunction with a @code{Export} or @code{Convention}
2512 pragma that specifies the desired foreign convention.
2513 Pragma @code{Export_Function}
2514 (and @code{Export}, if present) must appear in the same declarative
2515 region as the function to which they apply.
2517 @var{internal_name} must uniquely designate the function to which the
2518 pragma applies. If more than one function name exists of this name in
2519 the declarative part you must use the @code{Parameter_Types} and
2520 @code{Result_Type} parameters is mandatory to achieve the required
2521 unique designation. @var{subtype_mark}s in these parameters must
2522 exactly match the subtypes in the corresponding function specification,
2523 using positional notation to match parameters with subtype marks.
2524 The form with an @code{'Access} attribute can be used to match an
2525 anonymous access parameter.
2528 @cindex Passing by descriptor
2529 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2530 The default behavior for Export_Function is to accept either 64bit or
2531 32bit descriptors unless short_descriptor is specified, then only 32bit
2532 descriptors are accepted.
2534 @cindex Suppressing external name
2535 Special treatment is given if the EXTERNAL is an explicit null
2536 string or a static string expressions that evaluates to the null
2537 string. In this case, no external name is generated. This form
2538 still allows the specification of parameter mechanisms.
2540 @node Pragma Export_Object
2541 @unnumberedsec Pragma Export_Object
2542 @findex Export_Object
2546 @smallexample @c ada
2547 pragma Export_Object
2548 [Internal =>] LOCAL_NAME
2549 [, [External =>] EXTERNAL_SYMBOL]
2550 [, [Size =>] EXTERNAL_SYMBOL]
2554 | static_string_EXPRESSION
2558 This pragma designates an object as exported, and apart from the
2559 extended rules for external symbols, is identical in effect to the use of
2560 the normal @code{Export} pragma applied to an object. You may use a
2561 separate Export pragma (and you probably should from the point of view
2562 of portability), but it is not required. @var{Size} is syntax checked,
2563 but otherwise ignored by GNAT@.
2565 @node Pragma Export_Procedure
2566 @unnumberedsec Pragma Export_Procedure
2567 @findex Export_Procedure
2571 @smallexample @c ada
2572 pragma Export_Procedure (
2573 [Internal =>] LOCAL_NAME
2574 [, [External =>] EXTERNAL_SYMBOL]
2575 [, [Parameter_Types =>] PARAMETER_TYPES]
2576 [, [Mechanism =>] MECHANISM]);
2580 | static_string_EXPRESSION
2585 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2589 | subtype_Name ' Access
2593 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2595 MECHANISM_ASSOCIATION ::=
2596 [formal_parameter_NAME =>] MECHANISM_NAME
2601 | Descriptor [([Class =>] CLASS_NAME)]
2602 | Short_Descriptor [([Class =>] CLASS_NAME)]
2604 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2608 This pragma is identical to @code{Export_Function} except that it
2609 applies to a procedure rather than a function and the parameters
2610 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2611 GNAT does not require a separate pragma @code{Export}, but if none is
2612 present, @code{Convention Ada} is assumed, which is usually
2613 not what is wanted, so it is usually appropriate to use this
2614 pragma in conjunction with a @code{Export} or @code{Convention}
2615 pragma that specifies the desired foreign convention.
2618 @cindex Passing by descriptor
2619 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2620 The default behavior for Export_Procedure is to accept either 64bit or
2621 32bit descriptors unless short_descriptor is specified, then only 32bit
2622 descriptors are accepted.
2624 @cindex Suppressing external name
2625 Special treatment is given if the EXTERNAL is an explicit null
2626 string or a static string expressions that evaluates to the null
2627 string. In this case, no external name is generated. This form
2628 still allows the specification of parameter mechanisms.
2630 @node Pragma Export_Value
2631 @unnumberedsec Pragma Export_Value
2632 @findex Export_Value
2636 @smallexample @c ada
2637 pragma Export_Value (
2638 [Value =>] static_integer_EXPRESSION,
2639 [Link_Name =>] static_string_EXPRESSION);
2643 This pragma serves to export a static integer value for external use.
2644 The first argument specifies the value to be exported. The Link_Name
2645 argument specifies the symbolic name to be associated with the integer
2646 value. This pragma is useful for defining a named static value in Ada
2647 that can be referenced in assembly language units to be linked with
2648 the application. This pragma is currently supported only for the
2649 AAMP target and is ignored for other targets.
2651 @node Pragma Export_Valued_Procedure
2652 @unnumberedsec Pragma Export_Valued_Procedure
2653 @findex Export_Valued_Procedure
2657 @smallexample @c ada
2658 pragma Export_Valued_Procedure (
2659 [Internal =>] LOCAL_NAME
2660 [, [External =>] EXTERNAL_SYMBOL]
2661 [, [Parameter_Types =>] PARAMETER_TYPES]
2662 [, [Mechanism =>] MECHANISM]);
2666 | static_string_EXPRESSION
2671 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2675 | subtype_Name ' Access
2679 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2681 MECHANISM_ASSOCIATION ::=
2682 [formal_parameter_NAME =>] MECHANISM_NAME
2687 | Descriptor [([Class =>] CLASS_NAME)]
2688 | Short_Descriptor [([Class =>] CLASS_NAME)]
2690 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2694 This pragma is identical to @code{Export_Procedure} except that the
2695 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2696 mode @code{OUT}, and externally the subprogram is treated as a function
2697 with this parameter as the result of the function. GNAT provides for
2698 this capability to allow the use of @code{OUT} and @code{IN OUT}
2699 parameters in interfacing to external functions (which are not permitted
2701 GNAT does not require a separate pragma @code{Export}, but if none is
2702 present, @code{Convention Ada} is assumed, which is almost certainly
2703 not what is wanted since the whole point of this pragma is to interface
2704 with foreign language functions, so it is usually appropriate to use this
2705 pragma in conjunction with a @code{Export} or @code{Convention}
2706 pragma that specifies the desired foreign convention.
2709 @cindex Passing by descriptor
2710 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2711 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2712 32bit descriptors unless short_descriptor is specified, then only 32bit
2713 descriptors are accepted.
2715 @cindex Suppressing external name
2716 Special treatment is given if the EXTERNAL is an explicit null
2717 string or a static string expressions that evaluates to the null
2718 string. In this case, no external name is generated. This form
2719 still allows the specification of parameter mechanisms.
2721 @node Pragma Extend_System
2722 @unnumberedsec Pragma Extend_System
2723 @cindex @code{system}, extending
2725 @findex Extend_System
2729 @smallexample @c ada
2730 pragma Extend_System ([Name =>] IDENTIFIER);
2734 This pragma is used to provide backwards compatibility with other
2735 implementations that extend the facilities of package @code{System}. In
2736 GNAT, @code{System} contains only the definitions that are present in
2737 the Ada RM@. However, other implementations, notably the DEC Ada 83
2738 implementation, provide many extensions to package @code{System}.
2740 For each such implementation accommodated by this pragma, GNAT provides a
2741 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2742 implementation, which provides the required additional definitions. You
2743 can use this package in two ways. You can @code{with} it in the normal
2744 way and access entities either by selection or using a @code{use}
2745 clause. In this case no special processing is required.
2747 However, if existing code contains references such as
2748 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2749 definitions provided in package @code{System}, you may use this pragma
2750 to extend visibility in @code{System} in a non-standard way that
2751 provides greater compatibility with the existing code. Pragma
2752 @code{Extend_System} is a configuration pragma whose single argument is
2753 the name of the package containing the extended definition
2754 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2755 control of this pragma will be processed using special visibility
2756 processing that looks in package @code{System.Aux_@var{xxx}} where
2757 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2758 package @code{System}, but not found in package @code{System}.
2760 You can use this pragma either to access a predefined @code{System}
2761 extension supplied with the compiler, for example @code{Aux_DEC} or
2762 you can construct your own extension unit following the above
2763 definition. Note that such a package is a child of @code{System}
2764 and thus is considered part of the implementation. To compile
2765 it you will have to use the appropriate switch for compiling
2767 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2770 @node Pragma Extensions_Allowed
2771 @unnumberedsec Pragma Extensions_Allowed
2772 @cindex Ada Extensions
2773 @cindex GNAT Extensions
2774 @findex Extensions_Allowed
2778 @smallexample @c ada
2779 pragma Extensions_Allowed (On | Off);
2783 This configuration pragma enables or disables the implementation
2784 extension mode (the use of Off as a parameter cancels the effect
2785 of the @option{-gnatX} command switch).
2787 In extension mode, the latest version of the Ada language is
2788 implemented (currently Ada 2012), and in addition a small number
2789 of GNAT specific extensions are recognized as follows:
2792 @item Constrained attribute for generic objects
2793 The @code{Constrained} attribute is permitted for objects of
2794 generic types. The result indicates if the corresponding actual
2799 @node Pragma External
2800 @unnumberedsec Pragma External
2805 @smallexample @c ada
2807 [ Convention =>] convention_IDENTIFIER,
2808 [ Entity =>] LOCAL_NAME
2809 [, [External_Name =>] static_string_EXPRESSION ]
2810 [, [Link_Name =>] static_string_EXPRESSION ]);
2814 This pragma is identical in syntax and semantics to pragma
2815 @code{Export} as defined in the Ada Reference Manual. It is
2816 provided for compatibility with some Ada 83 compilers that
2817 used this pragma for exactly the same purposes as pragma
2818 @code{Export} before the latter was standardized.
2820 @node Pragma External_Name_Casing
2821 @unnumberedsec Pragma External_Name_Casing
2822 @cindex Dec Ada 83 casing compatibility
2823 @cindex External Names, casing
2824 @cindex Casing of External names
2825 @findex External_Name_Casing
2829 @smallexample @c ada
2830 pragma External_Name_Casing (
2831 Uppercase | Lowercase
2832 [, Uppercase | Lowercase | As_Is]);
2836 This pragma provides control over the casing of external names associated
2837 with Import and Export pragmas. There are two cases to consider:
2840 @item Implicit external names
2841 Implicit external names are derived from identifiers. The most common case
2842 arises when a standard Ada Import or Export pragma is used with only two
2845 @smallexample @c ada
2846 pragma Import (C, C_Routine);
2850 Since Ada is a case-insensitive language, the spelling of the identifier in
2851 the Ada source program does not provide any information on the desired
2852 casing of the external name, and so a convention is needed. In GNAT the
2853 default treatment is that such names are converted to all lower case
2854 letters. This corresponds to the normal C style in many environments.
2855 The first argument of pragma @code{External_Name_Casing} can be used to
2856 control this treatment. If @code{Uppercase} is specified, then the name
2857 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2858 then the normal default of all lower case letters will be used.
2860 This same implicit treatment is also used in the case of extended DEC Ada 83
2861 compatible Import and Export pragmas where an external name is explicitly
2862 specified using an identifier rather than a string.
2864 @item Explicit external names
2865 Explicit external names are given as string literals. The most common case
2866 arises when a standard Ada Import or Export pragma is used with three
2869 @smallexample @c ada
2870 pragma Import (C, C_Routine, "C_routine");
2874 In this case, the string literal normally provides the exact casing required
2875 for the external name. The second argument of pragma
2876 @code{External_Name_Casing} may be used to modify this behavior.
2877 If @code{Uppercase} is specified, then the name
2878 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2879 then the name will be forced to all lowercase letters. A specification of
2880 @code{As_Is} provides the normal default behavior in which the casing is
2881 taken from the string provided.
2885 This pragma may appear anywhere that a pragma is valid. In particular, it
2886 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2887 case it applies to all subsequent compilations, or it can be used as a program
2888 unit pragma, in which case it only applies to the current unit, or it can
2889 be used more locally to control individual Import/Export pragmas.
2891 It is primarily intended for use with OpenVMS systems, where many
2892 compilers convert all symbols to upper case by default. For interfacing to
2893 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2896 @smallexample @c ada
2897 pragma External_Name_Casing (Uppercase, Uppercase);
2901 to enforce the upper casing of all external symbols.
2903 @node Pragma Fast_Math
2904 @unnumberedsec Pragma Fast_Math
2909 @smallexample @c ada
2914 This is a configuration pragma which activates a mode in which speed is
2915 considered more important for floating-point operations than absolutely
2916 accurate adherence to the requirements of the standard. Currently the
2917 following operations are affected:
2920 @item Complex Multiplication
2921 The normal simple formula for complex multiplication can result in intermediate
2922 overflows for numbers near the end of the range. The Ada standard requires that
2923 this situation be detected and corrected by scaling, but in Fast_Math mode such
2924 cases will simply result in overflow. Note that to take advantage of this you
2925 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2926 under control of the pragma, rather than use the preinstantiated versions.
2929 @node Pragma Favor_Top_Level
2930 @unnumberedsec Pragma Favor_Top_Level
2931 @findex Favor_Top_Level
2935 @smallexample @c ada
2936 pragma Favor_Top_Level (type_NAME);
2940 The named type must be an access-to-subprogram type. This pragma is an
2941 efficiency hint to the compiler, regarding the use of 'Access or
2942 'Unrestricted_Access on nested (non-library-level) subprograms. The
2943 pragma means that nested subprograms are not used with this type, or
2944 are rare, so that the generated code should be efficient in the
2945 top-level case. When this pragma is used, dynamically generated
2946 trampolines may be used on some targets for nested subprograms.
2947 See also the No_Implicit_Dynamic_Code restriction.
2949 @node Pragma Finalize_Storage_Only
2950 @unnumberedsec Pragma Finalize_Storage_Only
2951 @findex Finalize_Storage_Only
2955 @smallexample @c ada
2956 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2960 This pragma allows the compiler not to emit a Finalize call for objects
2961 defined at the library level. This is mostly useful for types where
2962 finalization is only used to deal with storage reclamation since in most
2963 environments it is not necessary to reclaim memory just before terminating
2964 execution, hence the name.
2966 @node Pragma Float_Representation
2967 @unnumberedsec Pragma Float_Representation
2969 @findex Float_Representation
2973 @smallexample @c ada
2974 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2976 FLOAT_REP ::= VAX_Float | IEEE_Float
2980 In the one argument form, this pragma is a configuration pragma which
2981 allows control over the internal representation chosen for the predefined
2982 floating point types declared in the packages @code{Standard} and
2983 @code{System}. On all systems other than OpenVMS, the argument must
2984 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2985 argument may be @code{VAX_Float} to specify the use of the VAX float
2986 format for the floating-point types in Standard. This requires that
2987 the standard runtime libraries be recompiled.
2989 The two argument form specifies the representation to be used for
2990 the specified floating-point type. On all systems other than OpenVMS,
2992 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
2996 For a digits value of 6, 32-bit IEEE short format will be used.
2998 For a digits value of 15, 64-bit IEEE long format will be used.
3000 No other value of digits is permitted.
3004 argument may be @code{VAX_Float} to specify the use of the VAX float
3009 For digits values up to 6, F float format will be used.
3011 For digits values from 7 to 9, D float format will be used.
3013 For digits values from 10 to 15, G float format will be used.
3015 Digits values above 15 are not allowed.
3019 @unnumberedsec Pragma Ident
3024 @smallexample @c ada
3025 pragma Ident (static_string_EXPRESSION);
3029 This pragma provides a string identification in the generated object file,
3030 if the system supports the concept of this kind of identification string.
3031 This pragma is allowed only in the outermost declarative part or
3032 declarative items of a compilation unit. If more than one @code{Ident}
3033 pragma is given, only the last one processed is effective.
3035 On OpenVMS systems, the effect of the pragma is identical to the effect of
3036 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
3037 maximum allowed length is 31 characters, so if it is important to
3038 maintain compatibility with this compiler, you should obey this length
3041 @node Pragma Implementation_Defined
3042 @unnumberedsec Pragma Implementation_Defined
3043 @findex Implementation_Defined
3047 @smallexample @c ada
3048 pragma Implementation_Defined (local_NAME);
3052 This pragma marks a previously declared entioty as implementation-defined.
3053 For an overloaded entity, applies to the most recent homonym.
3055 @smallexample @c ada
3056 pragma Implementation_Defined;
3060 The form with no arguments appears anywhere within a scope, most
3061 typically a package spec, and indicates that all entities that are
3062 defined within the package spec are Implementation_Defined.
3064 This pragma is used within the GNAT runtime library to identify
3065 implementation-defined entities introduced in language-defined units,
3066 for the purpose of implementing the No_Implementation_Identifiers
3069 @node Pragma Implemented
3070 @unnumberedsec Pragma Implemented
3075 @smallexample @c ada
3076 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
3078 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
3082 This is an Ada 2012 representation pragma which applies to protected, task
3083 and synchronized interface primitives. The use of pragma Implemented provides
3084 a way to impose a static requirement on the overriding operation by adhering
3085 to one of the three implementation kinds: entry, protected procedure or any of
3086 the above. This pragma is available in all earlier versions of Ada as an
3087 implementation-defined pragma.
3089 @smallexample @c ada
3090 type Synch_Iface is synchronized interface;
3091 procedure Prim_Op (Obj : in out Iface) is abstract;
3092 pragma Implemented (Prim_Op, By_Protected_Procedure);
3094 protected type Prot_1 is new Synch_Iface with
3095 procedure Prim_Op; -- Legal
3098 protected type Prot_2 is new Synch_Iface with
3099 entry Prim_Op; -- Illegal
3102 task type Task_Typ is new Synch_Iface with
3103 entry Prim_Op; -- Illegal
3108 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
3109 Implemented determines the runtime behavior of the requeue. Implementation kind
3110 By_Entry guarantees that the action of requeueing will proceed from an entry to
3111 another entry. Implementation kind By_Protected_Procedure transforms the
3112 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
3113 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
3114 the target's overriding subprogram kind.
3116 @node Pragma Implicit_Packing
3117 @unnumberedsec Pragma Implicit_Packing
3118 @findex Implicit_Packing
3119 @cindex Rational Profile
3123 @smallexample @c ada
3124 pragma Implicit_Packing;
3128 This is a configuration pragma that requests implicit packing for packed
3129 arrays for which a size clause is given but no explicit pragma Pack or
3130 specification of Component_Size is present. It also applies to records
3131 where no record representation clause is present. Consider this example:
3133 @smallexample @c ada
3134 type R is array (0 .. 7) of Boolean;
3139 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
3140 does not change the layout of a composite object. So the Size clause in the
3141 above example is normally rejected, since the default layout of the array uses
3142 8-bit components, and thus the array requires a minimum of 64 bits.
3144 If this declaration is compiled in a region of code covered by an occurrence
3145 of the configuration pragma Implicit_Packing, then the Size clause in this
3146 and similar examples will cause implicit packing and thus be accepted. For
3147 this implicit packing to occur, the type in question must be an array of small
3148 components whose size is known at compile time, and the Size clause must
3149 specify the exact size that corresponds to the length of the array multiplied
3150 by the size in bits of the component type.
3151 @cindex Array packing
3153 Similarly, the following example shows the use in the record case
3155 @smallexample @c ada
3157 a, b, c, d, e, f, g, h : boolean;
3164 Without a pragma Pack, each Boolean field requires 8 bits, so the
3165 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3166 sufficient. The use of pragma Implicit_Packing allows this record
3167 declaration to compile without an explicit pragma Pack.
3168 @node Pragma Import_Exception
3169 @unnumberedsec Pragma Import_Exception
3171 @findex Import_Exception
3175 @smallexample @c ada
3176 pragma Import_Exception (
3177 [Internal =>] LOCAL_NAME
3178 [, [External =>] EXTERNAL_SYMBOL]
3179 [, [Form =>] Ada | VMS]
3180 [, [Code =>] static_integer_EXPRESSION]);
3184 | static_string_EXPRESSION
3188 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3189 It allows OpenVMS conditions (for example, from OpenVMS system services or
3190 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3191 The pragma specifies that the exception associated with an exception
3192 declaration in an Ada program be defined externally (in non-Ada code).
3193 For further details on this pragma, see the
3194 DEC Ada Language Reference Manual, section 13.9a.3.1.
3196 @node Pragma Import_Function
3197 @unnumberedsec Pragma Import_Function
3198 @findex Import_Function
3202 @smallexample @c ada
3203 pragma Import_Function (
3204 [Internal =>] LOCAL_NAME,
3205 [, [External =>] EXTERNAL_SYMBOL]
3206 [, [Parameter_Types =>] PARAMETER_TYPES]
3207 [, [Result_Type =>] SUBTYPE_MARK]
3208 [, [Mechanism =>] MECHANISM]
3209 [, [Result_Mechanism =>] MECHANISM_NAME]
3210 [, [First_Optional_Parameter =>] IDENTIFIER]);
3214 | static_string_EXPRESSION
3218 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3222 | subtype_Name ' Access
3226 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3228 MECHANISM_ASSOCIATION ::=
3229 [formal_parameter_NAME =>] MECHANISM_NAME
3234 | Descriptor [([Class =>] CLASS_NAME)]
3235 | Short_Descriptor [([Class =>] CLASS_NAME)]
3237 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3241 This pragma is used in conjunction with a pragma @code{Import} to
3242 specify additional information for an imported function. The pragma
3243 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3244 @code{Import_Function} pragma and both must appear in the same
3245 declarative part as the function specification.
3247 The @var{Internal} argument must uniquely designate
3248 the function to which the
3249 pragma applies. If more than one function name exists of this name in
3250 the declarative part you must use the @code{Parameter_Types} and
3251 @var{Result_Type} parameters to achieve the required unique
3252 designation. Subtype marks in these parameters must exactly match the
3253 subtypes in the corresponding function specification, using positional
3254 notation to match parameters with subtype marks.
3255 The form with an @code{'Access} attribute can be used to match an
3256 anonymous access parameter.
3258 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3259 parameters to specify passing mechanisms for the
3260 parameters and result. If you specify a single mechanism name, it
3261 applies to all parameters. Otherwise you may specify a mechanism on a
3262 parameter by parameter basis using either positional or named
3263 notation. If the mechanism is not specified, the default mechanism
3267 @cindex Passing by descriptor
3268 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3269 The default behavior for Import_Function is to pass a 64bit descriptor
3270 unless short_descriptor is specified, then a 32bit descriptor is passed.
3272 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
3273 It specifies that the designated parameter and all following parameters
3274 are optional, meaning that they are not passed at the generated code
3275 level (this is distinct from the notion of optional parameters in Ada
3276 where the parameters are passed anyway with the designated optional
3277 parameters). All optional parameters must be of mode @code{IN} and have
3278 default parameter values that are either known at compile time
3279 expressions, or uses of the @code{'Null_Parameter} attribute.
3281 @node Pragma Import_Object
3282 @unnumberedsec Pragma Import_Object
3283 @findex Import_Object
3287 @smallexample @c ada
3288 pragma Import_Object
3289 [Internal =>] LOCAL_NAME
3290 [, [External =>] EXTERNAL_SYMBOL]
3291 [, [Size =>] EXTERNAL_SYMBOL]);
3295 | static_string_EXPRESSION
3299 This pragma designates an object as imported, and apart from the
3300 extended rules for external symbols, is identical in effect to the use of
3301 the normal @code{Import} pragma applied to an object. Unlike the
3302 subprogram case, you need not use a separate @code{Import} pragma,
3303 although you may do so (and probably should do so from a portability
3304 point of view). @var{size} is syntax checked, but otherwise ignored by
3307 @node Pragma Import_Procedure
3308 @unnumberedsec Pragma Import_Procedure
3309 @findex Import_Procedure
3313 @smallexample @c ada
3314 pragma Import_Procedure (
3315 [Internal =>] LOCAL_NAME
3316 [, [External =>] EXTERNAL_SYMBOL]
3317 [, [Parameter_Types =>] PARAMETER_TYPES]
3318 [, [Mechanism =>] MECHANISM]
3319 [, [First_Optional_Parameter =>] IDENTIFIER]);
3323 | static_string_EXPRESSION
3327 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3331 | subtype_Name ' Access
3335 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3337 MECHANISM_ASSOCIATION ::=
3338 [formal_parameter_NAME =>] MECHANISM_NAME
3343 | Descriptor [([Class =>] CLASS_NAME)]
3344 | Short_Descriptor [([Class =>] CLASS_NAME)]
3346 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3350 This pragma is identical to @code{Import_Function} except that it
3351 applies to a procedure rather than a function and the parameters
3352 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3354 @node Pragma Import_Valued_Procedure
3355 @unnumberedsec Pragma Import_Valued_Procedure
3356 @findex Import_Valued_Procedure
3360 @smallexample @c ada
3361 pragma Import_Valued_Procedure (
3362 [Internal =>] LOCAL_NAME
3363 [, [External =>] EXTERNAL_SYMBOL]
3364 [, [Parameter_Types =>] PARAMETER_TYPES]
3365 [, [Mechanism =>] MECHANISM]
3366 [, [First_Optional_Parameter =>] IDENTIFIER]);
3370 | static_string_EXPRESSION
3374 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3378 | subtype_Name ' Access
3382 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3384 MECHANISM_ASSOCIATION ::=
3385 [formal_parameter_NAME =>] MECHANISM_NAME
3390 | Descriptor [([Class =>] CLASS_NAME)]
3391 | Short_Descriptor [([Class =>] CLASS_NAME)]
3393 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3397 This pragma is identical to @code{Import_Procedure} except that the
3398 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3399 mode @code{OUT}, and externally the subprogram is treated as a function
3400 with this parameter as the result of the function. The purpose of this
3401 capability is to allow the use of @code{OUT} and @code{IN OUT}
3402 parameters in interfacing to external functions (which are not permitted
3403 in Ada functions). You may optionally use the @code{Mechanism}
3404 parameters to specify passing mechanisms for the parameters.
3405 If you specify a single mechanism name, it applies to all parameters.
3406 Otherwise you may specify a mechanism on a parameter by parameter
3407 basis using either positional or named notation. If the mechanism is not
3408 specified, the default mechanism is used.
3410 Note that it is important to use this pragma in conjunction with a separate
3411 pragma Import that specifies the desired convention, since otherwise the
3412 default convention is Ada, which is almost certainly not what is required.
3414 @node Pragma Independent
3415 @unnumberedsec Pragma Independent
3420 @smallexample @c ada
3421 pragma Independent (Local_NAME);
3425 This pragma is standard in Ada 2012 mode (which also provides an aspect
3426 of the same name). It is also available as an implementation-defined
3427 pragma in all earlier versions. It specifies that the
3428 designated object or all objects of the designated type must be
3429 independently addressable. This means that separate tasks can safely
3430 manipulate such objects. For example, if two components of a record are
3431 independent, then two separate tasks may access these two components.
3433 constraints on the representation of the object (for instance prohibiting
3436 @node Pragma Independent_Components
3437 @unnumberedsec Pragma Independent_Components
3438 @findex Independent_Components
3442 @smallexample @c ada
3443 pragma Independent_Components (Local_NAME);
3447 This pragma is standard in Ada 2012 mode (which also provides an aspect
3448 of the same name). It is also available as an implementation-defined
3449 pragma in all earlier versions. It specifies that the components of the
3450 designated object, or the components of each object of the designated
3452 independently addressable. This means that separate tasks can safely
3453 manipulate separate components in the composite object. This may place
3454 constraints on the representation of the object (for instance prohibiting
3457 @node Pragma Initialize_Scalars
3458 @unnumberedsec Pragma Initialize_Scalars
3459 @findex Initialize_Scalars
3460 @cindex debugging with Initialize_Scalars
3464 @smallexample @c ada
3465 pragma Initialize_Scalars;
3469 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3470 two important differences. First, there is no requirement for the pragma
3471 to be used uniformly in all units of a partition, in particular, it is fine
3472 to use this just for some or all of the application units of a partition,
3473 without needing to recompile the run-time library.
3475 In the case where some units are compiled with the pragma, and some without,
3476 then a declaration of a variable where the type is defined in package
3477 Standard or is locally declared will always be subject to initialization,
3478 as will any declaration of a scalar variable. For composite variables,
3479 whether the variable is initialized may also depend on whether the package
3480 in which the type of the variable is declared is compiled with the pragma.
3482 The other important difference is that you can control the value used
3483 for initializing scalar objects. At bind time, you can select several
3484 options for initialization. You can
3485 initialize with invalid values (similar to Normalize_Scalars, though for
3486 Initialize_Scalars it is not always possible to determine the invalid
3487 values in complex cases like signed component fields with non-standard
3488 sizes). You can also initialize with high or
3489 low values, or with a specified bit pattern. See the @value{EDITION}
3490 User's Guide for binder options for specifying these cases.
3492 This means that you can compile a program, and then without having to
3493 recompile the program, you can run it with different values being used
3494 for initializing otherwise uninitialized values, to test if your program
3495 behavior depends on the choice. Of course the behavior should not change,
3496 and if it does, then most likely you have an erroneous reference to an
3497 uninitialized value.
3499 It is even possible to change the value at execution time eliminating even
3500 the need to rebind with a different switch using an environment variable.
3501 See the @value{EDITION} User's Guide for details.
3503 Note that pragma @code{Initialize_Scalars} is particularly useful in
3504 conjunction with the enhanced validity checking that is now provided
3505 in GNAT, which checks for invalid values under more conditions.
3506 Using this feature (see description of the @option{-gnatV} flag in the
3507 @value{EDITION} User's Guide) in conjunction with
3508 pragma @code{Initialize_Scalars}
3509 provides a powerful new tool to assist in the detection of problems
3510 caused by uninitialized variables.
3512 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3513 effect on the generated code. This may cause your code to be
3514 substantially larger. It may also cause an increase in the amount
3515 of stack required, so it is probably a good idea to turn on stack
3516 checking (see description of stack checking in the @value{EDITION}
3517 User's Guide) when using this pragma.
3519 @node Pragma Inline_Always
3520 @unnumberedsec Pragma Inline_Always
3521 @findex Inline_Always
3525 @smallexample @c ada
3526 pragma Inline_Always (NAME [, NAME]);
3530 Similar to pragma @code{Inline} except that inlining is not subject to
3531 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3532 happens regardless of whether these options are used.
3534 @node Pragma Inline_Generic
3535 @unnumberedsec Pragma Inline_Generic
3536 @findex Inline_Generic
3540 @smallexample @c ada
3541 pragma Inline_Generic (generic_package_NAME);
3545 This is implemented for compatibility with DEC Ada 83 and is recognized,
3546 but otherwise ignored, by GNAT@. All generic instantiations are inlined
3547 by default when using GNAT@.
3549 @node Pragma Interface
3550 @unnumberedsec Pragma Interface
3555 @smallexample @c ada
3557 [Convention =>] convention_identifier,
3558 [Entity =>] local_NAME
3559 [, [External_Name =>] static_string_expression]
3560 [, [Link_Name =>] static_string_expression]);
3564 This pragma is identical in syntax and semantics to
3565 the standard Ada pragma @code{Import}. It is provided for compatibility
3566 with Ada 83. The definition is upwards compatible both with pragma
3567 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3568 with some extended implementations of this pragma in certain Ada 83
3569 implementations. The only difference between pragma @code{Interface}
3570 and pragma @code{Import} is that there is special circuitry to allow
3571 both pragmas to appear for the same subprogram entity (normally it
3572 is illegal to have multiple @code{Import} pragmas. This is useful in
3573 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3576 @node Pragma Interface_Name
3577 @unnumberedsec Pragma Interface_Name
3578 @findex Interface_Name
3582 @smallexample @c ada
3583 pragma Interface_Name (
3584 [Entity =>] LOCAL_NAME
3585 [, [External_Name =>] static_string_EXPRESSION]
3586 [, [Link_Name =>] static_string_EXPRESSION]);
3590 This pragma provides an alternative way of specifying the interface name
3591 for an interfaced subprogram, and is provided for compatibility with Ada
3592 83 compilers that use the pragma for this purpose. You must provide at
3593 least one of @var{External_Name} or @var{Link_Name}.
3595 @node Pragma Interrupt_Handler
3596 @unnumberedsec Pragma Interrupt_Handler
3597 @findex Interrupt_Handler
3601 @smallexample @c ada
3602 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3606 This program unit pragma is supported for parameterless protected procedures
3607 as described in Annex C of the Ada Reference Manual. On the AAMP target
3608 the pragma can also be specified for nonprotected parameterless procedures
3609 that are declared at the library level (which includes procedures
3610 declared at the top level of a library package). In the case of AAMP,
3611 when this pragma is applied to a nonprotected procedure, the instruction
3612 @code{IERET} is generated for returns from the procedure, enabling
3613 maskable interrupts, in place of the normal return instruction.
3615 @node Pragma Interrupt_State
3616 @unnumberedsec Pragma Interrupt_State
3617 @findex Interrupt_State
3621 @smallexample @c ada
3622 pragma Interrupt_State
3624 [State =>] SYSTEM | RUNTIME | USER);
3628 Normally certain interrupts are reserved to the implementation. Any attempt
3629 to attach an interrupt causes Program_Error to be raised, as described in
3630 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3631 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3632 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3633 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3634 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3635 Ada exceptions, or used to implement run-time functions such as the
3636 @code{abort} statement and stack overflow checking.
3638 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3639 such uses of interrupts. It subsumes the functionality of pragma
3640 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3641 available on Windows or VMS. On all other platforms than VxWorks,
3642 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3643 and may be used to mark interrupts required by the board support package
3646 Interrupts can be in one of three states:
3650 The interrupt is reserved (no Ada handler can be installed), and the
3651 Ada run-time may not install a handler. As a result you are guaranteed
3652 standard system default action if this interrupt is raised.
3656 The interrupt is reserved (no Ada handler can be installed). The run time
3657 is allowed to install a handler for internal control purposes, but is
3658 not required to do so.
3662 The interrupt is unreserved. The user may install a handler to provide
3667 These states are the allowed values of the @code{State} parameter of the
3668 pragma. The @code{Name} parameter is a value of the type
3669 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3670 @code{Ada.Interrupts.Names}.
3672 This is a configuration pragma, and the binder will check that there
3673 are no inconsistencies between different units in a partition in how a
3674 given interrupt is specified. It may appear anywhere a pragma is legal.
3676 The effect is to move the interrupt to the specified state.
3678 By declaring interrupts to be SYSTEM, you guarantee the standard system
3679 action, such as a core dump.
3681 By declaring interrupts to be USER, you guarantee that you can install
3684 Note that certain signals on many operating systems cannot be caught and
3685 handled by applications. In such cases, the pragma is ignored. See the
3686 operating system documentation, or the value of the array @code{Reserved}
3687 declared in the spec of package @code{System.OS_Interface}.
3689 Overriding the default state of signals used by the Ada runtime may interfere
3690 with an application's runtime behavior in the cases of the synchronous signals,
3691 and in the case of the signal used to implement the @code{abort} statement.
3693 @node Pragma Invariant
3694 @unnumberedsec Pragma Invariant
3699 @smallexample @c ada
3701 ([Entity =>] private_type_LOCAL_NAME,
3702 [Check =>] EXPRESSION
3703 [,[Message =>] String_Expression]);
3707 This pragma provides exactly the same capabilities as the Type_Invariant aspect
3708 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
3709 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
3710 requires the use of the aspect syntax, which is not available except in 2012
3711 mode, it is not possible to use the Type_Invariant aspect in earlier versions
3712 of Ada. However the Invariant pragma may be used in any version of Ada. Also
3713 note that the aspect Invariant is a synonym in GNAT for the aspect
3714 Type_Invariant, but there is no pragma Type_Invariant.
3716 The pragma must appear within the visible part of the package specification,
3717 after the type to which its Entity argument appears. As with the Invariant
3718 aspect, the Check expression is not analyzed until the end of the visible
3719 part of the package, so it may contain forward references. The Message
3720 argument, if present, provides the exception message used if the invariant
3721 is violated. If no Message parameter is provided, a default message that
3722 identifies the line on which the pragma appears is used.
3724 It is permissible to have multiple Invariants for the same type entity, in
3725 which case they are and'ed together. It is permissible to use this pragma
3726 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3727 invariant pragma for the same entity.
3729 For further details on the use of this pragma, see the Ada 2012 documentation
3730 of the Type_Invariant aspect.
3732 @node Pragma Keep_Names
3733 @unnumberedsec Pragma Keep_Names
3738 @smallexample @c ada
3739 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3743 The @var{LOCAL_NAME} argument
3744 must refer to an enumeration first subtype
3745 in the current declarative part. The effect is to retain the enumeration
3746 literal names for use by @code{Image} and @code{Value} even if a global
3747 @code{Discard_Names} pragma applies. This is useful when you want to
3748 generally suppress enumeration literal names and for example you therefore
3749 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3750 want to retain the names for specific enumeration types.
3752 @node Pragma License
3753 @unnumberedsec Pragma License
3755 @cindex License checking
3759 @smallexample @c ada
3760 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3764 This pragma is provided to allow automated checking for appropriate license
3765 conditions with respect to the standard and modified GPL@. A pragma
3766 @code{License}, which is a configuration pragma that typically appears at
3767 the start of a source file or in a separate @file{gnat.adc} file, specifies
3768 the licensing conditions of a unit as follows:
3772 This is used for a unit that can be freely used with no license restrictions.
3773 Examples of such units are public domain units, and units from the Ada
3777 This is used for a unit that is licensed under the unmodified GPL, and which
3778 therefore cannot be @code{with}'ed by a restricted unit.
3781 This is used for a unit licensed under the GNAT modified GPL that includes
3782 a special exception paragraph that specifically permits the inclusion of
3783 the unit in programs without requiring the entire program to be released
3787 This is used for a unit that is restricted in that it is not permitted to
3788 depend on units that are licensed under the GPL@. Typical examples are
3789 proprietary code that is to be released under more restrictive license
3790 conditions. Note that restricted units are permitted to @code{with} units
3791 which are licensed under the modified GPL (this is the whole point of the
3797 Normally a unit with no @code{License} pragma is considered to have an
3798 unknown license, and no checking is done. However, standard GNAT headers
3799 are recognized, and license information is derived from them as follows.
3803 A GNAT license header starts with a line containing 78 hyphens. The following
3804 comment text is searched for the appearance of any of the following strings.
3806 If the string ``GNU General Public License'' is found, then the unit is assumed
3807 to have GPL license, unless the string ``As a special exception'' follows, in
3808 which case the license is assumed to be modified GPL@.
3810 If one of the strings
3811 ``This specification is adapted from the Ada Semantic Interface'' or
3812 ``This specification is derived from the Ada Reference Manual'' is found
3813 then the unit is assumed to be unrestricted.
3817 These default actions means that a program with a restricted license pragma
3818 will automatically get warnings if a GPL unit is inappropriately
3819 @code{with}'ed. For example, the program:
3821 @smallexample @c ada
3824 procedure Secret_Stuff is
3830 if compiled with pragma @code{License} (@code{Restricted}) in a
3831 @file{gnat.adc} file will generate the warning:
3836 >>> license of withed unit "Sem_Ch3" is incompatible
3838 2. with GNAT.Sockets;
3839 3. procedure Secret_Stuff is
3843 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3844 compiler and is licensed under the
3845 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3846 run time, and is therefore licensed under the modified GPL@.
3848 @node Pragma Link_With
3849 @unnumberedsec Pragma Link_With
3854 @smallexample @c ada
3855 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3859 This pragma is provided for compatibility with certain Ada 83 compilers.
3860 It has exactly the same effect as pragma @code{Linker_Options} except
3861 that spaces occurring within one of the string expressions are treated
3862 as separators. For example, in the following case:
3864 @smallexample @c ada
3865 pragma Link_With ("-labc -ldef");
3869 results in passing the strings @code{-labc} and @code{-ldef} as two
3870 separate arguments to the linker. In addition pragma Link_With allows
3871 multiple arguments, with the same effect as successive pragmas.
3873 @node Pragma Linker_Alias
3874 @unnumberedsec Pragma Linker_Alias
3875 @findex Linker_Alias
3879 @smallexample @c ada
3880 pragma Linker_Alias (
3881 [Entity =>] LOCAL_NAME,
3882 [Target =>] static_string_EXPRESSION);
3886 @var{LOCAL_NAME} must refer to an object that is declared at the library
3887 level. This pragma establishes the given entity as a linker alias for the
3888 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3889 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3890 @var{static_string_EXPRESSION} in the object file, that is to say no space
3891 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3892 to the same address as @var{static_string_EXPRESSION} by the linker.
3894 The actual linker name for the target must be used (e.g.@: the fully
3895 encoded name with qualification in Ada, or the mangled name in C++),
3896 or it must be declared using the C convention with @code{pragma Import}
3897 or @code{pragma Export}.
3899 Not all target machines support this pragma. On some of them it is accepted
3900 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3902 @smallexample @c ada
3903 -- Example of the use of pragma Linker_Alias
3907 pragma Export (C, i);
3909 new_name_for_i : Integer;
3910 pragma Linker_Alias (new_name_for_i, "i");
3914 @node Pragma Linker_Constructor
3915 @unnumberedsec Pragma Linker_Constructor
3916 @findex Linker_Constructor
3920 @smallexample @c ada
3921 pragma Linker_Constructor (procedure_LOCAL_NAME);
3925 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3926 is declared at the library level. A procedure to which this pragma is
3927 applied will be treated as an initialization routine by the linker.
3928 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3929 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3930 of the executable is called (or immediately after the shared library is
3931 loaded if the procedure is linked in a shared library), in particular
3932 before the Ada run-time environment is set up.
3934 Because of these specific contexts, the set of operations such a procedure
3935 can perform is very limited and the type of objects it can manipulate is
3936 essentially restricted to the elementary types. In particular, it must only
3937 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3939 This pragma is used by GNAT to implement auto-initialization of shared Stand
3940 Alone Libraries, which provides a related capability without the restrictions
3941 listed above. Where possible, the use of Stand Alone Libraries is preferable
3942 to the use of this pragma.
3944 @node Pragma Linker_Destructor
3945 @unnumberedsec Pragma Linker_Destructor
3946 @findex Linker_Destructor
3950 @smallexample @c ada
3951 pragma Linker_Destructor (procedure_LOCAL_NAME);
3955 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3956 is declared at the library level. A procedure to which this pragma is
3957 applied will be treated as a finalization routine by the linker.
3958 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3959 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3960 of the executable has exited (or immediately before the shared library
3961 is unloaded if the procedure is linked in a shared library), in particular
3962 after the Ada run-time environment is shut down.
3964 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3965 because of these specific contexts.
3967 @node Pragma Linker_Section
3968 @unnumberedsec Pragma Linker_Section
3969 @findex Linker_Section
3973 @smallexample @c ada
3974 pragma Linker_Section (
3975 [Entity =>] LOCAL_NAME,
3976 [Section =>] static_string_EXPRESSION);
3980 @var{LOCAL_NAME} must refer to an object that is declared at the library
3981 level. This pragma specifies the name of the linker section for the given
3982 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3983 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3984 section of the executable (assuming the linker doesn't rename the section).
3986 The compiler normally places library-level objects in standard sections
3987 depending on their type: procedures and functions generally go in the
3988 @code{.text} section, initialized variables in the @code{.data} section
3989 and uninitialized variables in the @code{.bss} section.
3991 Other, special sections may exist on given target machines to map special
3992 hardware, for example I/O ports or flash memory. This pragma is a means to
3993 defer the final layout of the executable to the linker, thus fully working
3994 at the symbolic level with the compiler.
3996 Some file formats do not support arbitrary sections so not all target
3997 machines support this pragma. The use of this pragma may cause a program
3998 execution to be erroneous if it is used to place an entity into an
3999 inappropriate section (e.g.@: a modified variable into the @code{.text}
4000 section). See also @code{pragma Persistent_BSS}.
4002 @smallexample @c ada
4003 -- Example of the use of pragma Linker_Section
4007 pragma Volatile (Port_A);
4008 pragma Linker_Section (Port_A, ".bss.port_a");
4011 pragma Volatile (Port_B);
4012 pragma Linker_Section (Port_B, ".bss.port_b");
4016 @node Pragma Long_Float
4017 @unnumberedsec Pragma Long_Float
4023 @smallexample @c ada
4024 pragma Long_Float (FLOAT_FORMAT);
4026 FLOAT_FORMAT ::= D_Float | G_Float
4030 This pragma is implemented only in the OpenVMS implementation of GNAT@.
4031 It allows control over the internal representation chosen for the predefined
4032 type @code{Long_Float} and for floating point type representations with
4033 @code{digits} specified in the range 7 through 15.
4034 For further details on this pragma, see the
4035 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
4036 this pragma, the standard runtime libraries must be recompiled.
4038 @node Pragma Loop_Invariant
4039 @unnumberedsec Pragma Loop_Invariant
4040 @findex Loop_Invariant
4043 @smallexample @c ada
4044 pragma Loop_Invariant ( boolean_EXPRESSION );
4049 The effect of this pragma is similar to that of pragma @code{Assert},
4050 except that in an @code{Assertion_Policy} pragma, the identifier
4051 @code{Loop_Invariant} is used to control whether it is ignored or checked
4054 @code{Loop_Invariant} can only appear as one of the items in the sequence
4055 of statements of a loop body. The intention is that it be used to
4056 represent a "loop invariant" assertion, i.e. something that is true each
4057 time through the loop, and which can be used to show that the loop is
4058 achieving its purpose.
4060 To aid in writing such invariants, the special attribute @code{Loop_Entry}
4061 may be used to refer to the value of an expression on entry to the loop. This
4062 attribute can only be used within the expression of a @code{Loop_Invariant}
4063 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
4065 @node Pragma Loop_Optimize
4066 @unnumberedsec Pragma Loop_Optimize
4067 @findex Loop_Optimize
4071 @smallexample @c ada
4072 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
4074 OPTIMIZATION_HINT ::= No_Unroll | Unroll | No_Vector | Vector
4078 This pragma must appear immediately within a loop statement. It allows the
4079 programmer to specify optimization hints for the enclosing loop. The hints
4080 are not mutually exclusive and can be freely mixed, but not all combinations
4081 will yield a sensible outcome.
4083 There are four supported optimization hints for a loop:
4087 The loop must not be unrolled. This is a strong hint: the compiler will not
4088 unroll a loop marked with this hint.
4092 The loop should be unrolled. This is a weak hint: the compiler will try to
4093 apply unrolling to this loop preferably to other optimizations, notably
4094 vectorization, but there is no guarantee that the loop will be unrolled.
4098 The loop must not be vectorized. This is a strong hint: the compiler will not
4099 vectorize a loop marked with this hint.
4103 The loop should be vectorized. This is a weak hint: the compiler will try to
4104 apply vectorization to this loop preferably to other optimizations, notably
4105 unrolling, but there is no guarantee that the loop will be vectorized.
4109 These hints do not void the need to pass the appropriate switches to the
4110 compiler in order to enable the relevant optimizations, that is to say
4111 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
4114 @node Pragma Loop_Variant
4115 @unnumberedsec Pragma Loop_Variant
4116 @findex Loop_Variant
4120 @smallexample @c ada
4121 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
4122 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
4123 CHANGE_DIRECTION ::= Increases | Decreases
4127 This pragma must appear immediately within the sequence of statements of a
4128 loop statement. It allows the specification of quantities which must always
4129 decrease or increase in successive iterations of the loop. In its simplest
4130 form, just one expression is specified, whose value must increase or decrease
4131 on each iteration of the loop.
4133 In a more complex form, multiple arguments can be given which are intepreted
4134 in a nesting lexicographic manner. For example:
4136 @smallexample @c ada
4137 pragma Loop_Variant (Increases => X, Decreases => Y);
4141 specifies that each time through the loop either X increases, or X stays
4142 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
4143 loop is making progress. It can be useful in helping to show informally
4144 or prove formally that the loop always terminates.
4146 @code{Loop_Variant} is an assertion whose effect can be controlled using
4147 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
4148 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
4149 to ignore the check (in which case the pragma has no effect on the program),
4150 or @code{Disable} in which case the pragma is not even checked for correct
4153 The @code{Loop_Entry} attribute may be used within the expressions of the
4154 @code{Loop_Variant} pragma to refer to values on entry to the loop.
4156 @node Pragma Machine_Attribute
4157 @unnumberedsec Pragma Machine_Attribute
4158 @findex Machine_Attribute
4162 @smallexample @c ada
4163 pragma Machine_Attribute (
4164 [Entity =>] LOCAL_NAME,
4165 [Attribute_Name =>] static_string_EXPRESSION
4166 [, [Info =>] static_EXPRESSION] );
4170 Machine-dependent attributes can be specified for types and/or
4171 declarations. This pragma is semantically equivalent to
4172 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
4173 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
4174 in GNU C, where @code{@var{attribute_name}} is recognized by the
4175 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
4176 specific macro. A string literal for the optional parameter @var{info}
4177 is transformed into an identifier, which may make this pragma unusable
4178 for some attributes. @xref{Target Attributes,, Defining target-specific
4179 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
4180 Internals}, further information.
4183 @unnumberedsec Pragma Main
4189 @smallexample @c ada
4191 (MAIN_OPTION [, MAIN_OPTION]);
4194 [Stack_Size =>] static_integer_EXPRESSION
4195 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
4196 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
4200 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4201 no effect in GNAT, other than being syntax checked.
4203 @node Pragma Main_Storage
4204 @unnumberedsec Pragma Main_Storage
4206 @findex Main_Storage
4210 @smallexample @c ada
4212 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
4214 MAIN_STORAGE_OPTION ::=
4215 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
4216 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
4220 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4221 no effect in GNAT, other than being syntax checked. Note that the pragma
4222 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4224 @node Pragma No_Body
4225 @unnumberedsec Pragma No_Body
4230 @smallexample @c ada
4235 There are a number of cases in which a package spec does not require a body,
4236 and in fact a body is not permitted. GNAT will not permit the spec to be
4237 compiled if there is a body around. The pragma No_Body allows you to provide
4238 a body file, even in a case where no body is allowed. The body file must
4239 contain only comments and a single No_Body pragma. This is recognized by
4240 the compiler as indicating that no body is logically present.
4242 This is particularly useful during maintenance when a package is modified in
4243 such a way that a body needed before is no longer needed. The provision of a
4244 dummy body with a No_Body pragma ensures that there is no interference from
4245 earlier versions of the package body.
4247 @node Pragma No_Inline
4248 @unnumberedsec Pragma No_Inline
4253 @smallexample @c ada
4254 pragma No_Inline (NAME @{, NAME@});
4258 This pragma suppresses inlining for the callable entity or the instances of
4259 the generic subprogram designated by @var{NAME}, including inlining that
4260 results from the use of pragma @code{Inline}. This pragma is always active,
4261 in particular it is not subject to the use of option @option{-gnatn} or
4262 @option{-gnatN}. It is illegal to specify both pragma @code{No_Inline} and
4263 pragma @code{Inline_Always} for the same @var{NAME}.
4265 @node Pragma No_Return
4266 @unnumberedsec Pragma No_Return
4271 @smallexample @c ada
4272 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4276 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4277 declarations in the current declarative part. A procedure to which this
4278 pragma is applied may not contain any explicit @code{return} statements.
4279 In addition, if the procedure contains any implicit returns from falling
4280 off the end of a statement sequence, then execution of that implicit
4281 return will cause Program_Error to be raised.
4283 One use of this pragma is to identify procedures whose only purpose is to raise
4284 an exception. Another use of this pragma is to suppress incorrect warnings
4285 about missing returns in functions, where the last statement of a function
4286 statement sequence is a call to such a procedure.
4288 Note that in Ada 2005 mode, this pragma is part of the language. It is
4289 available in all earlier versions of Ada as an implementation-defined
4292 @node Pragma No_Strict_Aliasing
4293 @unnumberedsec Pragma No_Strict_Aliasing
4294 @findex No_Strict_Aliasing
4298 @smallexample @c ada
4299 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4303 @var{type_LOCAL_NAME} must refer to an access type
4304 declaration in the current declarative part. The effect is to inhibit
4305 strict aliasing optimization for the given type. The form with no
4306 arguments is a configuration pragma which applies to all access types
4307 declared in units to which the pragma applies. For a detailed
4308 description of the strict aliasing optimization, and the situations
4309 in which it must be suppressed, see @ref{Optimization and Strict
4310 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4312 This pragma currently has no effects on access to unconstrained array types.
4314 @node Pragma Normalize_Scalars
4315 @unnumberedsec Pragma Normalize_Scalars
4316 @findex Normalize_Scalars
4320 @smallexample @c ada
4321 pragma Normalize_Scalars;
4325 This is a language defined pragma which is fully implemented in GNAT@. The
4326 effect is to cause all scalar objects that are not otherwise initialized
4327 to be initialized. The initial values are implementation dependent and
4331 @item Standard.Character
4333 Objects whose root type is Standard.Character are initialized to
4334 Character'Last unless the subtype range excludes NUL (in which case
4335 NUL is used). This choice will always generate an invalid value if
4338 @item Standard.Wide_Character
4340 Objects whose root type is Standard.Wide_Character are initialized to
4341 Wide_Character'Last unless the subtype range excludes NUL (in which case
4342 NUL is used). This choice will always generate an invalid value if
4345 @item Standard.Wide_Wide_Character
4347 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4348 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4349 which case NUL is used). This choice will always generate an invalid value if
4354 Objects of an integer type are treated differently depending on whether
4355 negative values are present in the subtype. If no negative values are
4356 present, then all one bits is used as the initial value except in the
4357 special case where zero is excluded from the subtype, in which case
4358 all zero bits are used. This choice will always generate an invalid
4359 value if one exists.
4361 For subtypes with negative values present, the largest negative number
4362 is used, except in the unusual case where this largest negative number
4363 is in the subtype, and the largest positive number is not, in which case
4364 the largest positive value is used. This choice will always generate
4365 an invalid value if one exists.
4367 @item Floating-Point Types
4368 Objects of all floating-point types are initialized to all 1-bits. For
4369 standard IEEE format, this corresponds to a NaN (not a number) which is
4370 indeed an invalid value.
4372 @item Fixed-Point Types
4373 Objects of all fixed-point types are treated as described above for integers,
4374 with the rules applying to the underlying integer value used to represent
4375 the fixed-point value.
4378 Objects of a modular type are initialized to all one bits, except in
4379 the special case where zero is excluded from the subtype, in which
4380 case all zero bits are used. This choice will always generate an
4381 invalid value if one exists.
4383 @item Enumeration types
4384 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
4385 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
4386 whose Pos value is zero, in which case a code of zero is used. This choice
4387 will always generate an invalid value if one exists.
4391 @node Pragma Obsolescent
4392 @unnumberedsec Pragma Obsolescent
4397 @smallexample @c ada
4400 pragma Obsolescent (
4401 [Message =>] static_string_EXPRESSION
4402 [,[Version =>] Ada_05]]);
4404 pragma Obsolescent (
4406 [,[Message =>] static_string_EXPRESSION
4407 [,[Version =>] Ada_05]] );
4411 This pragma can occur immediately following a declaration of an entity,
4412 including the case of a record component. If no Entity argument is present,
4413 then this declaration is the one to which the pragma applies. If an Entity
4414 parameter is present, it must either match the name of the entity in this
4415 declaration, or alternatively, the pragma can immediately follow an enumeration
4416 type declaration, where the Entity argument names one of the enumeration
4419 This pragma is used to indicate that the named entity
4420 is considered obsolescent and should not be used. Typically this is
4421 used when an API must be modified by eventually removing or modifying
4422 existing subprograms or other entities. The pragma can be used at an
4423 intermediate stage when the entity is still present, but will be
4426 The effect of this pragma is to output a warning message on a reference to
4427 an entity thus marked that the subprogram is obsolescent if the appropriate
4428 warning option in the compiler is activated. If the Message parameter is
4429 present, then a second warning message is given containing this text. In
4430 addition, a reference to the entity is considered to be a violation of pragma
4431 Restrictions (No_Obsolescent_Features).
4433 This pragma can also be used as a program unit pragma for a package,
4434 in which case the entity name is the name of the package, and the
4435 pragma indicates that the entire package is considered
4436 obsolescent. In this case a client @code{with}'ing such a package
4437 violates the restriction, and the @code{with} statement is
4438 flagged with warnings if the warning option is set.
4440 If the Version parameter is present (which must be exactly
4441 the identifier Ada_05, no other argument is allowed), then the
4442 indication of obsolescence applies only when compiling in Ada 2005
4443 mode. This is primarily intended for dealing with the situations
4444 in the predefined library where subprograms or packages
4445 have become defined as obsolescent in Ada 2005
4446 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
4448 The following examples show typical uses of this pragma:
4450 @smallexample @c ada
4452 pragma Obsolescent (p, Message => "use pp instead of p");
4457 pragma Obsolescent ("use q2new instead");
4459 type R is new integer;
4462 Message => "use RR in Ada 2005",
4472 type E is (a, bc, 'd', quack);
4473 pragma Obsolescent (Entity => bc)
4474 pragma Obsolescent (Entity => 'd')
4477 (a, b : character) return character;
4478 pragma Obsolescent (Entity => "+");
4483 Note that, as for all pragmas, if you use a pragma argument identifier,
4484 then all subsequent parameters must also use a pragma argument identifier.
4485 So if you specify "Entity =>" for the Entity argument, and a Message
4486 argument is present, it must be preceded by "Message =>".
4488 @node Pragma Optimize_Alignment
4489 @unnumberedsec Pragma Optimize_Alignment
4490 @findex Optimize_Alignment
4491 @cindex Alignment, default settings
4495 @smallexample @c ada
4496 pragma Optimize_Alignment (TIME | SPACE | OFF);
4500 This is a configuration pragma which affects the choice of default alignments
4501 for types where no alignment is explicitly specified. There is a time/space
4502 trade-off in the selection of these values. Large alignments result in more
4503 efficient code, at the expense of larger data space, since sizes have to be
4504 increased to match these alignments. Smaller alignments save space, but the
4505 access code is slower. The normal choice of default alignments (which is what
4506 you get if you do not use this pragma, or if you use an argument of OFF),
4507 tries to balance these two requirements.
4509 Specifying SPACE causes smaller default alignments to be chosen in two cases.
4510 First any packed record is given an alignment of 1. Second, if a size is given
4511 for the type, then the alignment is chosen to avoid increasing this size. For
4514 @smallexample @c ada
4524 In the default mode, this type gets an alignment of 4, so that access to the
4525 Integer field X are efficient. But this means that objects of the type end up
4526 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4527 allowed to be bigger than the size of the type, but it can waste space if for
4528 example fields of type R appear in an enclosing record. If the above type is
4529 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4531 However, there is one case in which SPACE is ignored. If a variable length
4532 record (that is a discriminated record with a component which is an array
4533 whose length depends on a discriminant), has a pragma Pack, then it is not
4534 in general possible to set the alignment of such a record to one, so the
4535 pragma is ignored in this case (with a warning).
4537 Specifying TIME causes larger default alignments to be chosen in the case of
4538 small types with sizes that are not a power of 2. For example, consider:
4540 @smallexample @c ada
4552 The default alignment for this record is normally 1, but if this type is
4553 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
4554 to 4, which wastes space for objects of the type, since they are now 4 bytes
4555 long, but results in more efficient access when the whole record is referenced.
4557 As noted above, this is a configuration pragma, and there is a requirement
4558 that all units in a partition be compiled with a consistent setting of the
4559 optimization setting. This would normally be achieved by use of a configuration
4560 pragma file containing the appropriate setting. The exception to this rule is
4561 that units with an explicit configuration pragma in the same file as the source
4562 unit are excluded from the consistency check, as are all predefined units. The
4563 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4564 pragma appears at the start of the file.
4566 @node Pragma Ordered
4567 @unnumberedsec Pragma Ordered
4569 @findex pragma @code{Ordered}
4573 @smallexample @c ada
4574 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4578 Most enumeration types are from a conceptual point of view unordered.
4579 For example, consider:
4581 @smallexample @c ada
4582 type Color is (Red, Blue, Green, Yellow);
4586 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
4587 but really these relations make no sense; the enumeration type merely
4588 specifies a set of possible colors, and the order is unimportant.
4590 For unordered enumeration types, it is generally a good idea if
4591 clients avoid comparisons (other than equality or inequality) and
4592 explicit ranges. (A @emph{client} is a unit where the type is referenced,
4593 other than the unit where the type is declared, its body, and its subunits.)
4594 For example, if code buried in some client says:
4596 @smallexample @c ada
4597 if Current_Color < Yellow then ...
4598 if Current_Color in Blue .. Green then ...
4602 then the client code is relying on the order, which is undesirable.
4603 It makes the code hard to read and creates maintenance difficulties if
4604 entries have to be added to the enumeration type. Instead,
4605 the code in the client should list the possibilities, or an
4606 appropriate subtype should be declared in the unit that declares
4607 the original enumeration type. E.g., the following subtype could
4608 be declared along with the type @code{Color}:
4610 @smallexample @c ada
4611 subtype RBG is Color range Red .. Green;
4615 and then the client could write:
4617 @smallexample @c ada
4618 if Current_Color in RBG then ...
4619 if Current_Color = Blue or Current_Color = Green then ...
4623 However, some enumeration types are legitimately ordered from a conceptual
4624 point of view. For example, if you declare:
4626 @smallexample @c ada
4627 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
4631 then the ordering imposed by the language is reasonable, and
4632 clients can depend on it, writing for example:
4634 @smallexample @c ada
4635 if D in Mon .. Fri then ...
4640 The pragma @option{Ordered} is provided to mark enumeration types that
4641 are conceptually ordered, alerting the reader that clients may depend
4642 on the ordering. GNAT provides a pragma to mark enumerations as ordered
4643 rather than one to mark them as unordered, since in our experience,
4644 the great majority of enumeration types are conceptually unordered.
4646 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
4647 and @code{Wide_Wide_Character}
4648 are considered to be ordered types, so each is declared with a
4649 pragma @code{Ordered} in package @code{Standard}.
4651 Normally pragma @code{Ordered} serves only as documentation and a guide for
4652 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
4653 requests warnings for inappropriate uses (comparisons and explicit
4654 subranges) for unordered types. If this switch is used, then any
4655 enumeration type not marked with pragma @code{Ordered} will be considered
4656 as unordered, and will generate warnings for inappropriate uses.
4658 For additional information please refer to the description of the
4659 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
4661 @node Pragma Overflow_Mode
4662 @unnumberedsec Pragma Overflow_Mode
4663 @findex Overflow checks
4664 @findex Overflow mode
4665 @findex pragma @code{Overflow_Mode}
4669 @smallexample @c ada
4670 pragma Overflow_Mode
4672 [,[Assertions =>] MODE]);
4674 MODE ::= STRICT | MINIMIZED | ELIMINATED
4678 This pragma sets the current overflow mode to the given setting. For details
4679 of the meaning of these modes, please refer to the
4680 ``Overflow Check Handling in GNAT'' appendix in the
4681 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
4682 the given mode applies to all expressions. If both parameters are present,
4683 the @code{General} mode applies to expressions outside assertions, and
4684 the @code{Eliminated} mode applies to expressions within assertions.
4686 The case of the @code{MODE} parameter is ignored,
4687 so @code{MINIMIZED}, @code{Minimized} and
4688 @code{minimized} all have the same effect.
4690 The @code{Overflow_Mode} pragma has the same scoping and placement
4691 rules as pragma @code{Suppress}, so it can occur either as a
4692 configuration pragma, specifying a default for the whole
4693 program, or in a declarative scope, where it applies to the
4694 remaining declarations and statements in that scope.
4696 The pragma @code{Suppress (Overflow_Check)} suppresses
4697 overflow checking, but does not affect the overflow mode.
4699 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
4700 overflow checking, but does not affect the overflow mode.
4702 @node Pragma Overriding_Renamings
4703 @unnumberedsec Pragma Overriding_Renamings
4704 @findex Overriding_Renamings
4705 @cindex Rational profile
4709 @smallexample @c ada
4710 pragma Overriding_Renamings;
4715 This is a GNAT pragma to simplify porting legacy code accepted by the Rational
4716 Ada compiler. In the presence of this pragma, a renaming declaration that
4717 renames an inherited operation declared in the same scope is legal, even though
4718 RM 8.3 (15) stipulates that an overridden operation is not visible within the
4719 declaration of the overriding operation.
4721 @node Pragma Partition_Elaboration_Policy
4722 @unnumberedsec Pragma Partition_Elaboration_Policy
4723 @findex Partition_Elaboration_Policy
4727 @smallexample @c ada
4728 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
4730 POLICY_IDENTIFIER ::= Concurrent | Sequential
4734 This pragma is standard in Ada 2005, but is available in all earlier
4735 versions of Ada as an implementation-defined pragma.
4736 See Ada 2012 Reference Manual for details.
4738 @node Pragma Passive
4739 @unnumberedsec Pragma Passive
4744 @smallexample @c ada
4745 pragma Passive [(Semaphore | No)];
4749 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
4750 compatibility with DEC Ada 83 implementations, where it is used within a
4751 task definition to request that a task be made passive. If the argument
4752 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
4753 treats the pragma as an assertion that the containing task is passive
4754 and that optimization of context switch with this task is permitted and
4755 desired. If the argument @code{No} is present, the task must not be
4756 optimized. GNAT does not attempt to optimize any tasks in this manner
4757 (since protected objects are available in place of passive tasks).
4759 @node Pragma Persistent_BSS
4760 @unnumberedsec Pragma Persistent_BSS
4761 @findex Persistent_BSS
4765 @smallexample @c ada
4766 pragma Persistent_BSS [(LOCAL_NAME)]
4770 This pragma allows selected objects to be placed in the @code{.persistent_bss}
4771 section. On some targets the linker and loader provide for special
4772 treatment of this section, allowing a program to be reloaded without
4773 affecting the contents of this data (hence the name persistent).
4775 There are two forms of usage. If an argument is given, it must be the
4776 local name of a library level object, with no explicit initialization
4777 and whose type is potentially persistent. If no argument is given, then
4778 the pragma is a configuration pragma, and applies to all library level
4779 objects with no explicit initialization of potentially persistent types.
4781 A potentially persistent type is a scalar type, or a non-tagged,
4782 non-discriminated record, all of whose components have no explicit
4783 initialization and are themselves of a potentially persistent type,
4784 or an array, all of whose constraints are static, and whose component
4785 type is potentially persistent.
4787 If this pragma is used on a target where this feature is not supported,
4788 then the pragma will be ignored. See also @code{pragma Linker_Section}.
4790 @node Pragma Polling
4791 @unnumberedsec Pragma Polling
4796 @smallexample @c ada
4797 pragma Polling (ON | OFF);
4801 This pragma controls the generation of polling code. This is normally off.
4802 If @code{pragma Polling (ON)} is used then periodic calls are generated to
4803 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
4804 runtime library, and can be found in file @file{a-excpol.adb}.
4806 Pragma @code{Polling} can appear as a configuration pragma (for example it
4807 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
4808 can be used in the statement or declaration sequence to control polling
4811 A call to the polling routine is generated at the start of every loop and
4812 at the start of every subprogram call. This guarantees that the @code{Poll}
4813 routine is called frequently, and places an upper bound (determined by
4814 the complexity of the code) on the period between two @code{Poll} calls.
4816 The primary purpose of the polling interface is to enable asynchronous
4817 aborts on targets that cannot otherwise support it (for example Windows
4818 NT), but it may be used for any other purpose requiring periodic polling.
4819 The standard version is null, and can be replaced by a user program. This
4820 will require re-compilation of the @code{Ada.Exceptions} package that can
4821 be found in files @file{a-except.ads} and @file{a-except.adb}.
4823 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
4824 distribution) is used to enable the asynchronous abort capability on
4825 targets that do not normally support the capability. The version of
4826 @code{Poll} in this file makes a call to the appropriate runtime routine
4827 to test for an abort condition.
4829 Note that polling can also be enabled by use of the @option{-gnatP} switch.
4830 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
4833 @node Pragma Postcondition
4834 @unnumberedsec Pragma Postcondition
4835 @cindex Postconditions
4836 @cindex Checks, postconditions
4837 @findex Postconditions
4841 @smallexample @c ada
4842 pragma Postcondition (
4843 [Check =>] Boolean_Expression
4844 [,[Message =>] String_Expression]);
4848 The @code{Postcondition} pragma allows specification of automatic
4849 postcondition checks for subprograms. These checks are similar to
4850 assertions, but are automatically inserted just prior to the return
4851 statements of the subprogram with which they are associated (including
4852 implicit returns at the end of procedure bodies and associated
4853 exception handlers).
4855 In addition, the boolean expression which is the condition which
4856 must be true may contain references to function'Result in the case
4857 of a function to refer to the returned value.
4859 @code{Postcondition} pragmas may appear either immediately following the
4860 (separate) declaration of a subprogram, or at the start of the
4861 declarations of a subprogram body. Only other pragmas may intervene
4862 (that is appear between the subprogram declaration and its
4863 postconditions, or appear before the postcondition in the
4864 declaration sequence in a subprogram body). In the case of a
4865 postcondition appearing after a subprogram declaration, the
4866 formal arguments of the subprogram are visible, and can be
4867 referenced in the postcondition expressions.
4869 The postconditions are collected and automatically tested just
4870 before any return (implicit or explicit) in the subprogram body.
4871 A postcondition is only recognized if postconditions are active
4872 at the time the pragma is encountered. The compiler switch @option{gnata}
4873 turns on all postconditions by default, and pragma @code{Check_Policy}
4874 with an identifier of @code{Postcondition} can also be used to
4875 control whether postconditions are active.
4877 The general approach is that postconditions are placed in the spec
4878 if they represent functional aspects which make sense to the client.
4879 For example we might have:
4881 @smallexample @c ada
4882 function Direction return Integer;
4883 pragma Postcondition
4884 (Direction'Result = +1
4886 Direction'Result = -1);
4890 which serves to document that the result must be +1 or -1, and
4891 will test that this is the case at run time if postcondition
4894 Postconditions within the subprogram body can be used to
4895 check that some internal aspect of the implementation,
4896 not visible to the client, is operating as expected.
4897 For instance if a square root routine keeps an internal
4898 counter of the number of times it is called, then we
4899 might have the following postcondition:
4901 @smallexample @c ada
4902 Sqrt_Calls : Natural := 0;
4904 function Sqrt (Arg : Float) return Float is
4905 pragma Postcondition
4906 (Sqrt_Calls = Sqrt_Calls'Old + 1);
4912 As this example, shows, the use of the @code{Old} attribute
4913 is often useful in postconditions to refer to the state on
4914 entry to the subprogram.
4916 Note that postconditions are only checked on normal returns
4917 from the subprogram. If an abnormal return results from
4918 raising an exception, then the postconditions are not checked.
4920 If a postcondition fails, then the exception
4921 @code{System.Assertions.Assert_Failure} is raised. If
4922 a message argument was supplied, then the given string
4923 will be used as the exception message. If no message
4924 argument was supplied, then the default message has
4925 the form "Postcondition failed at file:line". The
4926 exception is raised in the context of the subprogram
4927 body, so it is possible to catch postcondition failures
4928 within the subprogram body itself.
4930 Within a package spec, normal visibility rules
4931 in Ada would prevent forward references within a
4932 postcondition pragma to functions defined later in
4933 the same package. This would introduce undesirable
4934 ordering constraints. To avoid this problem, all
4935 postcondition pragmas are analyzed at the end of
4936 the package spec, allowing forward references.
4938 The following example shows that this even allows
4939 mutually recursive postconditions as in:
4941 @smallexample @c ada
4942 package Parity_Functions is
4943 function Odd (X : Natural) return Boolean;
4944 pragma Postcondition
4948 (x /= 0 and then Even (X - 1))));
4950 function Even (X : Natural) return Boolean;
4951 pragma Postcondition
4955 (x /= 1 and then Odd (X - 1))));
4957 end Parity_Functions;
4961 There are no restrictions on the complexity or form of
4962 conditions used within @code{Postcondition} pragmas.
4963 The following example shows that it is even possible
4964 to verify performance behavior.
4966 @smallexample @c ada
4969 Performance : constant Float;
4970 -- Performance constant set by implementation
4971 -- to match target architecture behavior.
4973 procedure Treesort (Arg : String);
4974 -- Sorts characters of argument using N*logN sort
4975 pragma Postcondition
4976 (Float (Clock - Clock'Old) <=
4977 Float (Arg'Length) *
4978 log (Float (Arg'Length)) *
4984 Note: postcondition pragmas associated with subprograms that are
4985 marked as Inline_Always, or those marked as Inline with front-end
4986 inlining (-gnatN option set) are accepted and legality-checked
4987 by the compiler, but are ignored at run-time even if postcondition
4988 checking is enabled.
4990 @node Pragma Preelaborable_Initialization
4991 @unnumberedsec Pragma Preelaborable_Initialization
4992 @findex Preelaborable_Initialization
4996 @smallexample @c ada
4997 pragma Preelaborable_Initialization (DIRECT_NAME);
5001 This pragma is standard in Ada 2005, but is available in all earlier
5002 versions of Ada as an implementation-defined pragma.
5003 See Ada 2012 Reference Manual for details.
5005 @node Pragma Priority_Specific_Dispatching
5006 @unnumberedsec Pragma Priority_Specific_Dispatching
5007 @findex Priority_Specific_Dispatching
5011 @smallexample @c ada
5012 pragma Priority_Specific_Dispatching (
5014 first_priority_EXPRESSION,
5015 last_priority_EXPRESSION)
5017 POLICY_IDENTIFIER ::=
5018 EDF_Across_Priorities |
5019 FIFO_Within_Priorities |
5020 Non_Preemptive_Within_Priorities |
5021 Round_Robin_Within_Priorities
5025 This pragma is standard in Ada 2005, but is available in all earlier
5026 versions of Ada as an implementation-defined pragma.
5027 See Ada 2012 Reference Manual for details.
5029 @node Pragma Precondition
5030 @unnumberedsec Pragma Precondition
5031 @cindex Preconditions
5032 @cindex Checks, preconditions
5033 @findex Preconditions
5037 @smallexample @c ada
5038 pragma Precondition (
5039 [Check =>] Boolean_Expression
5040 [,[Message =>] String_Expression]);
5044 The @code{Precondition} pragma is similar to @code{Postcondition}
5045 except that the corresponding checks take place immediately upon
5046 entry to the subprogram, and if a precondition fails, the exception
5047 is raised in the context of the caller, and the attribute 'Result
5048 cannot be used within the precondition expression.
5050 Otherwise, the placement and visibility rules are identical to those
5051 described for postconditions. The following is an example of use
5052 within a package spec:
5054 @smallexample @c ada
5055 package Math_Functions is
5057 function Sqrt (Arg : Float) return Float;
5058 pragma Precondition (Arg >= 0.0)
5064 @code{Precondition} pragmas may appear either immediately following the
5065 (separate) declaration of a subprogram, or at the start of the
5066 declarations of a subprogram body. Only other pragmas may intervene
5067 (that is appear between the subprogram declaration and its
5068 postconditions, or appear before the postcondition in the
5069 declaration sequence in a subprogram body).
5071 Note: postcondition pragmas associated with subprograms that are
5072 marked as Inline_Always, or those marked as Inline with front-end
5073 inlining (-gnatN option set) are accepted and legality-checked
5074 by the compiler, but are ignored at run-time even if postcondition
5075 checking is enabled.
5077 @node Pragma Profile (Ravenscar)
5078 @unnumberedsec Pragma Profile (Ravenscar)
5083 @smallexample @c ada
5084 pragma Profile (Ravenscar | Restricted);
5088 This pragma is standard in Ada 2005, but is available in all earlier
5089 versions of Ada as an implementation-defined pragma. This is a
5090 configuration pragma that establishes the following set of configuration
5094 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
5095 [RM D.2.2] Tasks are dispatched following a preemptive
5096 priority-ordered scheduling policy.
5098 @item Locking_Policy (Ceiling_Locking)
5099 [RM D.3] While tasks and interrupts execute a protected action, they inherit
5100 the ceiling priority of the corresponding protected object.
5102 @item Detect_Blocking
5103 This pragma forces the detection of potentially blocking operations within a
5104 protected operation, and to raise Program_Error if that happens.
5108 plus the following set of restrictions:
5111 @item Max_Entry_Queue_Length => 1
5112 No task can be queued on a protected entry.
5113 @item Max_Protected_Entries => 1
5114 @item Max_Task_Entries => 0
5115 No rendezvous statements are allowed.
5116 @item No_Abort_Statements
5117 @item No_Dynamic_Attachment
5118 @item No_Dynamic_Priorities
5119 @item No_Implicit_Heap_Allocations
5120 @item No_Local_Protected_Objects
5121 @item No_Local_Timing_Events
5122 @item No_Protected_Type_Allocators
5123 @item No_Relative_Delay
5124 @item No_Requeue_Statements
5125 @item No_Select_Statements
5126 @item No_Specific_Termination_Handlers
5127 @item No_Task_Allocators
5128 @item No_Task_Hierarchy
5129 @item No_Task_Termination
5130 @item Simple_Barriers
5134 The Ravenscar profile also includes the following restrictions that specify
5135 that there are no semantic dependences on the corresponding predefined
5139 @item No_Dependence => Ada.Asynchronous_Task_Control
5140 @item No_Dependence => Ada.Calendar
5141 @item No_Dependence => Ada.Execution_Time.Group_Budget
5142 @item No_Dependence => Ada.Execution_Time.Timers
5143 @item No_Dependence => Ada.Task_Attributes
5144 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
5149 This set of configuration pragmas and restrictions correspond to the
5150 definition of the ``Ravenscar Profile'' for limited tasking, devised and
5151 published by the @cite{International Real-Time Ada Workshop}, 1997,
5152 and whose most recent description is available at
5153 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
5155 The original definition of the profile was revised at subsequent IRTAW
5156 meetings. It has been included in the ISO
5157 @cite{Guide for the Use of the Ada Programming Language in High
5158 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
5159 the next revision of the standard. The formal definition given by
5160 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
5161 AI-305) available at
5162 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
5163 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
5165 The above set is a superset of the restrictions provided by pragma
5166 @code{Profile (Restricted)}, it includes six additional restrictions
5167 (@code{Simple_Barriers}, @code{No_Select_Statements},
5168 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
5169 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
5170 that pragma @code{Profile (Ravenscar)}, like the pragma
5171 @code{Profile (Restricted)},
5172 automatically causes the use of a simplified,
5173 more efficient version of the tasking run-time system.
5175 @node Pragma Profile (Restricted)
5176 @unnumberedsec Pragma Profile (Restricted)
5177 @findex Restricted Run Time
5181 @smallexample @c ada
5182 pragma Profile (Restricted);
5186 This is an implementation-defined version of the standard pragma defined
5187 in Ada 2005. It is available in all versions of Ada. It is a
5188 configuration pragma that establishes the following set of restrictions:
5191 @item No_Abort_Statements
5192 @item No_Entry_Queue
5193 @item No_Task_Hierarchy
5194 @item No_Task_Allocators
5195 @item No_Dynamic_Priorities
5196 @item No_Terminate_Alternatives
5197 @item No_Dynamic_Attachment
5198 @item No_Protected_Type_Allocators
5199 @item No_Local_Protected_Objects
5200 @item No_Requeue_Statements
5201 @item No_Task_Attributes_Package
5202 @item Max_Asynchronous_Select_Nesting = 0
5203 @item Max_Task_Entries = 0
5204 @item Max_Protected_Entries = 1
5205 @item Max_Select_Alternatives = 0
5209 This set of restrictions causes the automatic selection of a simplified
5210 version of the run time that provides improved performance for the
5211 limited set of tasking functionality permitted by this set of restrictions.
5213 @node Pragma Profile (Rational)
5214 @unnumberedsec Pragma Profile (Rational)
5215 @findex Rational compatibility mode
5219 @smallexample @c ada
5220 pragma Profile (Rational);
5224 The Rational profile is intended to facilitate porting legacy code that
5225 compiles with the Rational APEX compiler, even when the code includes non-
5226 conforming Ada constructs. The profile enables the following three pragmas:
5230 @item pragma Implicit_Packing
5231 @item pragma Overriding_Renamings
5232 @item pragma Use_VADS_Size
5236 @node Pragma Psect_Object
5237 @unnumberedsec Pragma Psect_Object
5238 @findex Psect_Object
5242 @smallexample @c ada
5243 pragma Psect_Object (
5244 [Internal =>] LOCAL_NAME,
5245 [, [External =>] EXTERNAL_SYMBOL]
5246 [, [Size =>] EXTERNAL_SYMBOL]);
5250 | static_string_EXPRESSION
5254 This pragma is identical in effect to pragma @code{Common_Object}.
5256 @node Pragma Pure_Function
5257 @unnumberedsec Pragma Pure_Function
5258 @findex Pure_Function
5262 @smallexample @c ada
5263 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
5267 This pragma appears in the same declarative part as a function
5268 declaration (or a set of function declarations if more than one
5269 overloaded declaration exists, in which case the pragma applies
5270 to all entities). It specifies that the function @code{Entity} is
5271 to be considered pure for the purposes of code generation. This means
5272 that the compiler can assume that there are no side effects, and
5273 in particular that two calls with identical arguments produce the
5274 same result. It also means that the function can be used in an
5277 Note that, quite deliberately, there are no static checks to try
5278 to ensure that this promise is met, so @code{Pure_Function} can be used
5279 with functions that are conceptually pure, even if they do modify
5280 global variables. For example, a square root function that is
5281 instrumented to count the number of times it is called is still
5282 conceptually pure, and can still be optimized, even though it
5283 modifies a global variable (the count). Memo functions are another
5284 example (where a table of previous calls is kept and consulted to
5285 avoid re-computation).
5287 Note also that the normal rules excluding optimization of subprograms
5288 in pure units (when parameter types are descended from System.Address,
5289 or when the full view of a parameter type is limited), do not apply
5290 for the Pure_Function case. If you explicitly specify Pure_Function,
5291 the compiler may optimize away calls with identical arguments, and
5292 if that results in unexpected behavior, the proper action is not to
5293 use the pragma for subprograms that are not (conceptually) pure.
5296 Note: Most functions in a @code{Pure} package are automatically pure, and
5297 there is no need to use pragma @code{Pure_Function} for such functions. One
5298 exception is any function that has at least one formal of type
5299 @code{System.Address} or a type derived from it. Such functions are not
5300 considered pure by default, since the compiler assumes that the
5301 @code{Address} parameter may be functioning as a pointer and that the
5302 referenced data may change even if the address value does not.
5303 Similarly, imported functions are not considered to be pure by default,
5304 since there is no way of checking that they are in fact pure. The use
5305 of pragma @code{Pure_Function} for such a function will override these default
5306 assumption, and cause the compiler to treat a designated subprogram as pure
5309 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
5310 applies to the underlying renamed function. This can be used to
5311 disambiguate cases of overloading where some but not all functions
5312 in a set of overloaded functions are to be designated as pure.
5314 If pragma @code{Pure_Function} is applied to a library level function, the
5315 function is also considered pure from an optimization point of view, but the
5316 unit is not a Pure unit in the categorization sense. So for example, a function
5317 thus marked is free to @code{with} non-pure units.
5319 @node Pragma Relative_Deadline
5320 @unnumberedsec Pragma Relative_Deadline
5321 @findex Relative_Deadline
5325 @smallexample @c ada
5326 pragma Relative_Deadline (time_span_EXPRESSSION);
5330 This pragma is standard in Ada 2005, but is available in all earlier
5331 versions of Ada as an implementation-defined pragma.
5332 See Ada 2012 Reference Manual for details.
5334 @node Pragma Remote_Access_Type
5335 @unnumberedsec Pragma Remote_Access_Type
5336 @findex Remote_Access_Type
5340 @smallexample @c ada
5341 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
5345 This pragma appears in the formal part of a generic declaration.
5346 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
5347 the use of a remote access to class-wide type as actual for a formal
5350 When this pragma applies to a formal access type @code{Entity}, that
5351 type is treated as a remote access to class-wide type in the generic.
5352 It must be a formal general access type, and its designated type must
5353 be the class-wide type of a formal tagged limited private type from the
5354 same generic declaration.
5356 In the generic unit, the formal type is subject to all restrictions
5357 pertaining to remote access to class-wide types. At instantiation, the
5358 actual type must be a remote access to class-wide type.
5360 @node Pragma Restriction_Warnings
5361 @unnumberedsec Pragma Restriction_Warnings
5362 @findex Restriction_Warnings
5366 @smallexample @c ada
5367 pragma Restriction_Warnings
5368 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
5372 This pragma allows a series of restriction identifiers to be
5373 specified (the list of allowed identifiers is the same as for
5374 pragma @code{Restrictions}). For each of these identifiers
5375 the compiler checks for violations of the restriction, but
5376 generates a warning message rather than an error message
5377 if the restriction is violated.
5380 @unnumberedsec Pragma Shared
5384 This pragma is provided for compatibility with Ada 83. The syntax and
5385 semantics are identical to pragma Atomic.
5387 @node Pragma Short_Circuit_And_Or
5388 @unnumberedsec Pragma Short_Circuit_And_Or
5389 @findex Short_Circuit_And_Or
5392 This configuration pragma causes any occurrence of the AND operator applied to
5393 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
5394 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
5395 may be useful in the context of certification protocols requiring the use of
5396 short-circuited logical operators. If this configuration pragma occurs locally
5397 within the file being compiled, it applies only to the file being compiled.
5398 There is no requirement that all units in a partition use this option.
5400 @node Pragma Short_Descriptors
5401 @unnumberedsec Pragma Short_Descriptors
5402 @findex Short_Descriptors
5406 @smallexample @c ada
5407 pragma Short_Descriptors
5411 In VMS versions of the compiler, this configuration pragma causes all
5412 occurrences of the mechanism types Descriptor[_xxx] to be treated as
5413 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
5414 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
5417 @node Pragma Simple_Storage_Pool_Type
5418 @unnumberedsec Pragma Simple_Storage_Pool_Type
5419 @findex Simple_Storage_Pool_Type
5420 @cindex Storage pool, simple
5421 @cindex Simple storage pool
5425 @smallexample @c ada
5426 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
5430 A type can be established as a ``simple storage pool type'' by applying
5431 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
5432 A type named in the pragma must be a library-level immutably limited record
5433 type or limited tagged type declared immediately within a package declaration.
5434 The type can also be a limited private type whose full type is allowed as
5435 a simple storage pool type.
5437 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
5438 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
5439 are subtype conformant with the following subprogram declarations:
5441 @smallexample @c ada
5444 Storage_Address : out System.Address;
5445 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5446 Alignment : System.Storage_Elements.Storage_Count);
5448 procedure Deallocate
5450 Storage_Address : System.Address;
5451 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5452 Alignment : System.Storage_Elements.Storage_Count);
5454 function Storage_Size (Pool : SSP)
5455 return System.Storage_Elements.Storage_Count;
5459 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
5460 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
5461 applying an unchecked deallocation has no effect other than to set its actual
5462 parameter to null. If @code{Storage_Size} is not declared, then the
5463 @code{Storage_Size} attribute applied to an access type associated with
5464 a pool object of type SSP returns zero. Additional operations can be declared
5465 for a simple storage pool type (such as for supporting a mark/release
5466 storage-management discipline).
5468 An object of a simple storage pool type can be associated with an access
5469 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
5471 @smallexample @c ada
5473 My_Pool : My_Simple_Storage_Pool_Type;
5475 type Acc is access My_Data_Type;
5477 for Acc'Simple_Storage_Pool use My_Pool;
5482 See attribute @code{Simple_Storage_Pool} for further details.
5484 @node Pragma Source_File_Name
5485 @unnumberedsec Pragma Source_File_Name
5486 @findex Source_File_Name
5490 @smallexample @c ada
5491 pragma Source_File_Name (
5492 [Unit_Name =>] unit_NAME,
5493 Spec_File_Name => STRING_LITERAL,
5494 [Index => INTEGER_LITERAL]);
5496 pragma Source_File_Name (
5497 [Unit_Name =>] unit_NAME,
5498 Body_File_Name => STRING_LITERAL,
5499 [Index => INTEGER_LITERAL]);
5503 Use this to override the normal naming convention. It is a configuration
5504 pragma, and so has the usual applicability of configuration pragmas
5505 (i.e.@: it applies to either an entire partition, or to all units in a
5506 compilation, or to a single unit, depending on how it is used.
5507 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
5508 the second argument is required, and indicates whether this is the file
5509 name for the spec or for the body.
5511 The optional Index argument should be used when a file contains multiple
5512 units, and when you do not want to use @code{gnatchop} to separate then
5513 into multiple files (which is the recommended procedure to limit the
5514 number of recompilations that are needed when some sources change).
5515 For instance, if the source file @file{source.ada} contains
5517 @smallexample @c ada
5529 you could use the following configuration pragmas:
5531 @smallexample @c ada
5532 pragma Source_File_Name
5533 (B, Spec_File_Name => "source.ada", Index => 1);
5534 pragma Source_File_Name
5535 (A, Body_File_Name => "source.ada", Index => 2);
5538 Note that the @code{gnatname} utility can also be used to generate those
5539 configuration pragmas.
5541 Another form of the @code{Source_File_Name} pragma allows
5542 the specification of patterns defining alternative file naming schemes
5543 to apply to all files.
5545 @smallexample @c ada
5546 pragma Source_File_Name
5547 ( [Spec_File_Name =>] STRING_LITERAL
5548 [,[Casing =>] CASING_SPEC]
5549 [,[Dot_Replacement =>] STRING_LITERAL]);
5551 pragma Source_File_Name
5552 ( [Body_File_Name =>] STRING_LITERAL
5553 [,[Casing =>] CASING_SPEC]
5554 [,[Dot_Replacement =>] STRING_LITERAL]);
5556 pragma Source_File_Name
5557 ( [Subunit_File_Name =>] STRING_LITERAL
5558 [,[Casing =>] CASING_SPEC]
5559 [,[Dot_Replacement =>] STRING_LITERAL]);
5561 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
5565 The first argument is a pattern that contains a single asterisk indicating
5566 the point at which the unit name is to be inserted in the pattern string
5567 to form the file name. The second argument is optional. If present it
5568 specifies the casing of the unit name in the resulting file name string.
5569 The default is lower case. Finally the third argument allows for systematic
5570 replacement of any dots in the unit name by the specified string literal.
5572 Note that Source_File_Name pragmas should not be used if you are using
5573 project files. The reason for this rule is that the project manager is not
5574 aware of these pragmas, and so other tools that use the projet file would not
5575 be aware of the intended naming conventions. If you are using project files,
5576 file naming is controlled by Source_File_Name_Project pragmas, which are
5577 usually supplied automatically by the project manager. A pragma
5578 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
5580 For more details on the use of the @code{Source_File_Name} pragma,
5581 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
5582 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
5585 @node Pragma Source_File_Name_Project
5586 @unnumberedsec Pragma Source_File_Name_Project
5587 @findex Source_File_Name_Project
5590 This pragma has the same syntax and semantics as pragma Source_File_Name.
5591 It is only allowed as a stand alone configuration pragma.
5592 It cannot appear after a @ref{Pragma Source_File_Name}, and
5593 most importantly, once pragma Source_File_Name_Project appears,
5594 no further Source_File_Name pragmas are allowed.
5596 The intention is that Source_File_Name_Project pragmas are always
5597 generated by the Project Manager in a manner consistent with the naming
5598 specified in a project file, and when naming is controlled in this manner,
5599 it is not permissible to attempt to modify this naming scheme using
5600 Source_File_Name or Source_File_Name_Project pragmas (which would not be
5601 known to the project manager).
5603 @node Pragma Source_Reference
5604 @unnumberedsec Pragma Source_Reference
5605 @findex Source_Reference
5609 @smallexample @c ada
5610 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
5614 This pragma must appear as the first line of a source file.
5615 @var{integer_literal} is the logical line number of the line following
5616 the pragma line (for use in error messages and debugging
5617 information). @var{string_literal} is a static string constant that
5618 specifies the file name to be used in error messages and debugging
5619 information. This is most notably used for the output of @code{gnatchop}
5620 with the @option{-r} switch, to make sure that the original unchopped
5621 source file is the one referred to.
5623 The second argument must be a string literal, it cannot be a static
5624 string expression other than a string literal. This is because its value
5625 is needed for error messages issued by all phases of the compiler.
5627 @node Pragma Static_Elaboration_Desired
5628 @unnumberedsec Pragma Static_Elaboration_Desired
5629 @findex Static_Elaboration_Desired
5633 @smallexample @c ada
5634 pragma Static_Elaboration_Desired;
5638 This pragma is used to indicate that the compiler should attempt to initialize
5639 statically the objects declared in the library unit to which the pragma applies,
5640 when these objects are initialized (explicitly or implicitly) by an aggregate.
5641 In the absence of this pragma, aggregates in object declarations are expanded
5642 into assignments and loops, even when the aggregate components are static
5643 constants. When the aggregate is present the compiler builds a static expression
5644 that requires no run-time code, so that the initialized object can be placed in
5645 read-only data space. If the components are not static, or the aggregate has
5646 more that 100 components, the compiler emits a warning that the pragma cannot
5647 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
5648 construction of larger aggregates with static components that include an others
5651 @node Pragma Stream_Convert
5652 @unnumberedsec Pragma Stream_Convert
5653 @findex Stream_Convert
5657 @smallexample @c ada
5658 pragma Stream_Convert (
5659 [Entity =>] type_LOCAL_NAME,
5660 [Read =>] function_NAME,
5661 [Write =>] function_NAME);
5665 This pragma provides an efficient way of providing stream functions for
5666 types defined in packages. Not only is it simpler to use than declaring
5667 the necessary functions with attribute representation clauses, but more
5668 significantly, it allows the declaration to made in such a way that the
5669 stream packages are not loaded unless they are needed. The use of
5670 the Stream_Convert pragma adds no overhead at all, unless the stream
5671 attributes are actually used on the designated type.
5673 The first argument specifies the type for which stream functions are
5674 provided. The second parameter provides a function used to read values
5675 of this type. It must name a function whose argument type may be any
5676 subtype, and whose returned type must be the type given as the first
5677 argument to the pragma.
5679 The meaning of the @var{Read}
5680 parameter is that if a stream attribute directly
5681 or indirectly specifies reading of the type given as the first parameter,
5682 then a value of the type given as the argument to the Read function is
5683 read from the stream, and then the Read function is used to convert this
5684 to the required target type.
5686 Similarly the @var{Write} parameter specifies how to treat write attributes
5687 that directly or indirectly apply to the type given as the first parameter.
5688 It must have an input parameter of the type specified by the first parameter,
5689 and the return type must be the same as the input type of the Read function.
5690 The effect is to first call the Write function to convert to the given stream
5691 type, and then write the result type to the stream.
5693 The Read and Write functions must not be overloaded subprograms. If necessary
5694 renamings can be supplied to meet this requirement.
5695 The usage of this attribute is best illustrated by a simple example, taken
5696 from the GNAT implementation of package Ada.Strings.Unbounded:
5698 @smallexample @c ada
5699 function To_Unbounded (S : String)
5700 return Unbounded_String
5701 renames To_Unbounded_String;
5703 pragma Stream_Convert
5704 (Unbounded_String, To_Unbounded, To_String);
5708 The specifications of the referenced functions, as given in the Ada
5709 Reference Manual are:
5711 @smallexample @c ada
5712 function To_Unbounded_String (Source : String)
5713 return Unbounded_String;
5715 function To_String (Source : Unbounded_String)
5720 The effect is that if the value of an unbounded string is written to a stream,
5721 then the representation of the item in the stream is in the same format that
5722 would be used for @code{Standard.String'Output}, and this same representation
5723 is expected when a value of this type is read from the stream. Note that the
5724 value written always includes the bounds, even for Unbounded_String'Write,
5725 since Unbounded_String is not an array type.
5727 @node Pragma Style_Checks
5728 @unnumberedsec Pragma Style_Checks
5729 @findex Style_Checks
5733 @smallexample @c ada
5734 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
5735 On | Off [, LOCAL_NAME]);
5739 This pragma is used in conjunction with compiler switches to control the
5740 built in style checking provided by GNAT@. The compiler switches, if set,
5741 provide an initial setting for the switches, and this pragma may be used
5742 to modify these settings, or the settings may be provided entirely by
5743 the use of the pragma. This pragma can be used anywhere that a pragma
5744 is legal, including use as a configuration pragma (including use in
5745 the @file{gnat.adc} file).
5747 The form with a string literal specifies which style options are to be
5748 activated. These are additive, so they apply in addition to any previously
5749 set style check options. The codes for the options are the same as those
5750 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
5751 For example the following two methods can be used to enable
5756 @smallexample @c ada
5757 pragma Style_Checks ("l");
5762 gcc -c -gnatyl @dots{}
5767 The form ALL_CHECKS activates all standard checks (its use is equivalent
5768 to the use of the @code{gnaty} switch with no options. @xref{Top,
5769 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
5770 @value{EDITION} User's Guide}, for details.)
5772 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
5773 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
5774 options (i.e. equivalent to -gnatyg).
5776 The forms with @code{Off} and @code{On}
5777 can be used to temporarily disable style checks
5778 as shown in the following example:
5780 @smallexample @c ada
5784 pragma Style_Checks ("k"); -- requires keywords in lower case
5785 pragma Style_Checks (Off); -- turn off style checks
5786 NULL; -- this will not generate an error message
5787 pragma Style_Checks (On); -- turn style checks back on
5788 NULL; -- this will generate an error message
5792 Finally the two argument form is allowed only if the first argument is
5793 @code{On} or @code{Off}. The effect is to turn of semantic style checks
5794 for the specified entity, as shown in the following example:
5796 @smallexample @c ada
5800 pragma Style_Checks ("r"); -- require consistency of identifier casing
5802 Rf1 : Integer := ARG; -- incorrect, wrong case
5803 pragma Style_Checks (Off, Arg);
5804 Rf2 : Integer := ARG; -- OK, no error
5807 @node Pragma Subtitle
5808 @unnumberedsec Pragma Subtitle
5813 @smallexample @c ada
5814 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
5818 This pragma is recognized for compatibility with other Ada compilers
5819 but is ignored by GNAT@.
5821 @node Pragma Suppress
5822 @unnumberedsec Pragma Suppress
5827 @smallexample @c ada
5828 pragma Suppress (Identifier [, [On =>] Name]);
5832 This is a standard pragma, and supports all the check names required in
5833 the RM. It is included here because GNAT recognizes some additional check
5834 names that are implementation defined (as permitted by the RM):
5839 @code{Alignment_Check} can be used to suppress alignment checks
5840 on addresses used in address clauses. Such checks can also be suppressed
5841 by suppressing range checks, but the specific use of @code{Alignment_Check}
5842 allows suppression of alignment checks without suppressing other range checks.
5845 @code{Predicate_Check} can be used to control whether predicate checks are
5846 active. It is applicable only to predicates for which the policy is
5847 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
5848 predicate is ignored or checked for the whole program, the use of
5849 @code{Suppress} and @code{Unsuppress} with this check name allows a given
5850 predicate to be turned on and off at specific points in the program.
5853 @code{Validity_Check} can be used specifically to control validity checks.
5854 If @code{Suppress} is used to suppress validity checks, then no validity
5855 checks are performed, including those specified by the appropriate compiler
5856 switch or the @code{Validity_Checks} pragma.
5859 Additional check names previously introduced by use of the @code{Check_Name}
5860 pragma are also allowed.
5865 Note that pragma Suppress gives the compiler permission to omit
5866 checks, but does not require the compiler to omit checks. The compiler
5867 will generate checks if they are essentially free, even when they are
5868 suppressed. In particular, if the compiler can prove that a certain
5869 check will necessarily fail, it will generate code to do an
5870 unconditional ``raise'', even if checks are suppressed. The compiler
5873 Of course, run-time checks are omitted whenever the compiler can prove
5874 that they will not fail, whether or not checks are suppressed.
5876 @node Pragma Suppress_All
5877 @unnumberedsec Pragma Suppress_All
5878 @findex Suppress_All
5882 @smallexample @c ada
5883 pragma Suppress_All;
5887 This pragma can appear anywhere within a unit.
5888 The effect is to apply @code{Suppress (All_Checks)} to the unit
5889 in which it appears. This pragma is implemented for compatibility with DEC
5890 Ada 83 usage where it appears at the end of a unit, and for compatibility
5891 with Rational Ada, where it appears as a program unit pragma.
5892 The use of the standard Ada pragma @code{Suppress (All_Checks)}
5893 as a normal configuration pragma is the preferred usage in GNAT@.
5895 @node Pragma Suppress_Exception_Locations
5896 @unnumberedsec Pragma Suppress_Exception_Locations
5897 @findex Suppress_Exception_Locations
5901 @smallexample @c ada
5902 pragma Suppress_Exception_Locations;
5906 In normal mode, a raise statement for an exception by default generates
5907 an exception message giving the file name and line number for the location
5908 of the raise. This is useful for debugging and logging purposes, but this
5909 entails extra space for the strings for the messages. The configuration
5910 pragma @code{Suppress_Exception_Locations} can be used to suppress the
5911 generation of these strings, with the result that space is saved, but the
5912 exception message for such raises is null. This configuration pragma may
5913 appear in a global configuration pragma file, or in a specific unit as
5914 usual. It is not required that this pragma be used consistently within
5915 a partition, so it is fine to have some units within a partition compiled
5916 with this pragma and others compiled in normal mode without it.
5918 @node Pragma Suppress_Initialization
5919 @unnumberedsec Pragma Suppress_Initialization
5920 @findex Suppress_Initialization
5921 @cindex Suppressing initialization
5922 @cindex Initialization, suppression of
5926 @smallexample @c ada
5927 pragma Suppress_Initialization ([Entity =>] subtype_Name);
5931 Here subtype_Name is the name introduced by a type declaration
5932 or subtype declaration.
5933 This pragma suppresses any implicit or explicit initialization
5934 for all variables of the given type or subtype,
5935 including initialization resulting from the use of pragmas
5936 Normalize_Scalars or Initialize_Scalars.
5938 This is considered a representation item, so it cannot be given after
5939 the type is frozen. It applies to all subsequent object declarations,
5940 and also any allocator that creates objects of the type.
5942 If the pragma is given for the first subtype, then it is considered
5943 to apply to the base type and all its subtypes. If the pragma is given
5944 for other than a first subtype, then it applies only to the given subtype.
5945 The pragma may not be given after the type is frozen.
5947 @node Pragma Task_Info
5948 @unnumberedsec Pragma Task_Info
5953 @smallexample @c ada
5954 pragma Task_Info (EXPRESSION);
5958 This pragma appears within a task definition (like pragma
5959 @code{Priority}) and applies to the task in which it appears. The
5960 argument must be of type @code{System.Task_Info.Task_Info_Type}.
5961 The @code{Task_Info} pragma provides system dependent control over
5962 aspects of tasking implementation, for example, the ability to map
5963 tasks to specific processors. For details on the facilities available
5964 for the version of GNAT that you are using, see the documentation
5965 in the spec of package System.Task_Info in the runtime
5968 @node Pragma Task_Name
5969 @unnumberedsec Pragma Task_Name
5974 @smallexample @c ada
5975 pragma Task_Name (string_EXPRESSION);
5979 This pragma appears within a task definition (like pragma
5980 @code{Priority}) and applies to the task in which it appears. The
5981 argument must be of type String, and provides a name to be used for
5982 the task instance when the task is created. Note that this expression
5983 is not required to be static, and in particular, it can contain
5984 references to task discriminants. This facility can be used to
5985 provide different names for different tasks as they are created,
5986 as illustrated in the example below.
5988 The task name is recorded internally in the run-time structures
5989 and is accessible to tools like the debugger. In addition the
5990 routine @code{Ada.Task_Identification.Image} will return this
5991 string, with a unique task address appended.
5993 @smallexample @c ada
5994 -- Example of the use of pragma Task_Name
5996 with Ada.Task_Identification;
5997 use Ada.Task_Identification;
5998 with Text_IO; use Text_IO;
6001 type Astring is access String;
6003 task type Task_Typ (Name : access String) is
6004 pragma Task_Name (Name.all);
6007 task body Task_Typ is
6008 Nam : constant String := Image (Current_Task);
6010 Put_Line ("-->" & Nam (1 .. 14) & "<--");
6013 type Ptr_Task is access Task_Typ;
6014 Task_Var : Ptr_Task;
6018 new Task_Typ (new String'("This is task 1"));
6020 new Task_Typ (new String'("This is task 2"));
6024 @node Pragma Task_Storage
6025 @unnumberedsec Pragma Task_Storage
6026 @findex Task_Storage
6029 @smallexample @c ada
6030 pragma Task_Storage (
6031 [Task_Type =>] LOCAL_NAME,
6032 [Top_Guard =>] static_integer_EXPRESSION);
6036 This pragma specifies the length of the guard area for tasks. The guard
6037 area is an additional storage area allocated to a task. A value of zero
6038 means that either no guard area is created or a minimal guard area is
6039 created, depending on the target. This pragma can appear anywhere a
6040 @code{Storage_Size} attribute definition clause is allowed for a task
6043 @node Pragma Test_Case
6044 @unnumberedsec Pragma Test_Case
6050 @smallexample @c ada
6052 [Name =>] static_string_Expression
6053 ,[Mode =>] (Nominal | Robustness)
6054 [, Requires => Boolean_Expression]
6055 [, Ensures => Boolean_Expression]);
6059 The @code{Test_Case} pragma allows defining fine-grain specifications
6060 for use by testing tools.
6061 The compiler checks the validity of the @code{Test_Case} pragma, but its
6062 presence does not lead to any modification of the code generated by the
6065 @code{Test_Case} pragmas may only appear immediately following the
6066 (separate) declaration of a subprogram in a package declaration, inside
6067 a package spec unit. Only other pragmas may intervene (that is appear
6068 between the subprogram declaration and a test case).
6070 The compiler checks that boolean expressions given in @code{Requires} and
6071 @code{Ensures} are valid, where the rules for @code{Requires} are the
6072 same as the rule for an expression in @code{Precondition} and the rules
6073 for @code{Ensures} are the same as the rule for an expression in
6074 @code{Postcondition}. In particular, attributes @code{'Old} and
6075 @code{'Result} can only be used within the @code{Ensures}
6076 expression. The following is an example of use within a package spec:
6078 @smallexample @c ada
6079 package Math_Functions is
6081 function Sqrt (Arg : Float) return Float;
6082 pragma Test_Case (Name => "Test 1",
6084 Requires => Arg < 10000,
6085 Ensures => Sqrt'Result < 10);
6091 The meaning of a test case is that there is at least one context where
6092 @code{Requires} holds such that, if the associated subprogram is executed in
6093 that context, then @code{Ensures} holds when the subprogram returns.
6094 Mode @code{Nominal} indicates that the input context should also satisfy the
6095 precondition of the subprogram, and the output context should also satisfy its
6096 postcondition. More @code{Robustness} indicates that the precondition and
6097 postcondition of the subprogram should be ignored for this test case.
6099 @node Pragma Thread_Local_Storage
6100 @unnumberedsec Pragma Thread_Local_Storage
6101 @findex Thread_Local_Storage
6102 @cindex Task specific storage
6103 @cindex TLS (Thread Local Storage)
6104 @cindex Task_Attributes
6107 @smallexample @c ada
6108 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
6112 This pragma specifies that the specified entity, which must be
6113 a variable declared in a library level package, is to be marked as
6114 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
6115 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
6116 (and hence each Ada task) to see a distinct copy of the variable.
6118 The variable may not have default initialization, and if there is
6119 an explicit initialization, it must be either @code{null} for an
6120 access variable, or a static expression for a scalar variable.
6121 This provides a low level mechanism similar to that provided by
6122 the @code{Ada.Task_Attributes} package, but much more efficient
6123 and is also useful in writing interface code that will interact
6124 with foreign threads.
6126 If this pragma is used on a system where @code{TLS} is not supported,
6127 then an error message will be generated and the program will be rejected.
6129 @node Pragma Time_Slice
6130 @unnumberedsec Pragma Time_Slice
6135 @smallexample @c ada
6136 pragma Time_Slice (static_duration_EXPRESSION);
6140 For implementations of GNAT on operating systems where it is possible
6141 to supply a time slice value, this pragma may be used for this purpose.
6142 It is ignored if it is used in a system that does not allow this control,
6143 or if it appears in other than the main program unit.
6145 Note that the effect of this pragma is identical to the effect of the
6146 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
6149 @unnumberedsec Pragma Title
6154 @smallexample @c ada
6155 pragma Title (TITLING_OPTION [, TITLING OPTION]);
6158 [Title =>] STRING_LITERAL,
6159 | [Subtitle =>] STRING_LITERAL
6163 Syntax checked but otherwise ignored by GNAT@. This is a listing control
6164 pragma used in DEC Ada 83 implementations to provide a title and/or
6165 subtitle for the program listing. The program listing generated by GNAT
6166 does not have titles or subtitles.
6168 Unlike other pragmas, the full flexibility of named notation is allowed
6169 for this pragma, i.e.@: the parameters may be given in any order if named
6170 notation is used, and named and positional notation can be mixed
6171 following the normal rules for procedure calls in Ada.
6173 @node Pragma Unchecked_Union
6174 @unnumberedsec Pragma Unchecked_Union
6176 @findex Unchecked_Union
6180 @smallexample @c ada
6181 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
6185 This pragma is used to specify a representation of a record type that is
6186 equivalent to a C union. It was introduced as a GNAT implementation defined
6187 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
6188 pragma, making it language defined, and GNAT fully implements this extended
6189 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
6190 details, consult the Ada 2012 Reference Manual, section B.3.3.
6192 @node Pragma Unimplemented_Unit
6193 @unnumberedsec Pragma Unimplemented_Unit
6194 @findex Unimplemented_Unit
6198 @smallexample @c ada
6199 pragma Unimplemented_Unit;
6203 If this pragma occurs in a unit that is processed by the compiler, GNAT
6204 aborts with the message @samp{@var{xxx} not implemented}, where
6205 @var{xxx} is the name of the current compilation unit. This pragma is
6206 intended to allow the compiler to handle unimplemented library units in
6209 The abort only happens if code is being generated. Thus you can use
6210 specs of unimplemented packages in syntax or semantic checking mode.
6212 @node Pragma Universal_Aliasing
6213 @unnumberedsec Pragma Universal_Aliasing
6214 @findex Universal_Aliasing
6218 @smallexample @c ada
6219 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
6223 @var{type_LOCAL_NAME} must refer to a type declaration in the current
6224 declarative part. The effect is to inhibit strict type-based aliasing
6225 optimization for the given type. In other words, the effect is as though
6226 access types designating this type were subject to pragma No_Strict_Aliasing.
6227 For a detailed description of the strict aliasing optimization, and the
6228 situations in which it must be suppressed, @xref{Optimization and Strict
6229 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
6231 @node Pragma Universal_Data
6232 @unnumberedsec Pragma Universal_Data
6233 @findex Universal_Data
6237 @smallexample @c ada
6238 pragma Universal_Data [(library_unit_Name)];
6242 This pragma is supported only for the AAMP target and is ignored for
6243 other targets. The pragma specifies that all library-level objects
6244 (Counter 0 data) associated with the library unit are to be accessed
6245 and updated using universal addressing (24-bit addresses for AAMP5)
6246 rather than the default of 16-bit Data Environment (DENV) addressing.
6247 Use of this pragma will generally result in less efficient code for
6248 references to global data associated with the library unit, but
6249 allows such data to be located anywhere in memory. This pragma is
6250 a library unit pragma, but can also be used as a configuration pragma
6251 (including use in the @file{gnat.adc} file). The functionality
6252 of this pragma is also available by applying the -univ switch on the
6253 compilations of units where universal addressing of the data is desired.
6255 @node Pragma Unmodified
6256 @unnumberedsec Pragma Unmodified
6258 @cindex Warnings, unmodified
6262 @smallexample @c ada
6263 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
6267 This pragma signals that the assignable entities (variables,
6268 @code{out} parameters, @code{in out} parameters) whose names are listed are
6269 deliberately not assigned in the current source unit. This
6270 suppresses warnings about the
6271 entities being referenced but not assigned, and in addition a warning will be
6272 generated if one of these entities is in fact assigned in the
6273 same unit as the pragma (or in the corresponding body, or one
6276 This is particularly useful for clearly signaling that a particular
6277 parameter is not modified, even though the spec suggests that it might
6280 @node Pragma Unreferenced
6281 @unnumberedsec Pragma Unreferenced
6282 @findex Unreferenced
6283 @cindex Warnings, unreferenced
6287 @smallexample @c ada
6288 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
6289 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
6293 This pragma signals that the entities whose names are listed are
6294 deliberately not referenced in the current source unit. This
6295 suppresses warnings about the
6296 entities being unreferenced, and in addition a warning will be
6297 generated if one of these entities is in fact subsequently referenced in the
6298 same unit as the pragma (or in the corresponding body, or one
6301 This is particularly useful for clearly signaling that a particular
6302 parameter is not referenced in some particular subprogram implementation
6303 and that this is deliberate. It can also be useful in the case of
6304 objects declared only for their initialization or finalization side
6307 If @code{LOCAL_NAME} identifies more than one matching homonym in the
6308 current scope, then the entity most recently declared is the one to which
6309 the pragma applies. Note that in the case of accept formals, the pragma
6310 Unreferenced may appear immediately after the keyword @code{do} which
6311 allows the indication of whether or not accept formals are referenced
6312 or not to be given individually for each accept statement.
6314 The left hand side of an assignment does not count as a reference for the
6315 purpose of this pragma. Thus it is fine to assign to an entity for which
6316 pragma Unreferenced is given.
6318 Note that if a warning is desired for all calls to a given subprogram,
6319 regardless of whether they occur in the same unit as the subprogram
6320 declaration, then this pragma should not be used (calls from another
6321 unit would not be flagged); pragma Obsolescent can be used instead
6322 for this purpose, see @xref{Pragma Obsolescent}.
6324 The second form of pragma @code{Unreferenced} is used within a context
6325 clause. In this case the arguments must be unit names of units previously
6326 mentioned in @code{with} clauses (similar to the usage of pragma
6327 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
6328 units and unreferenced entities within these units.
6330 @node Pragma Unreferenced_Objects
6331 @unnumberedsec Pragma Unreferenced_Objects
6332 @findex Unreferenced_Objects
6333 @cindex Warnings, unreferenced
6337 @smallexample @c ada
6338 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
6342 This pragma signals that for the types or subtypes whose names are
6343 listed, objects which are declared with one of these types or subtypes may
6344 not be referenced, and if no references appear, no warnings are given.
6346 This is particularly useful for objects which are declared solely for their
6347 initialization and finalization effect. Such variables are sometimes referred
6348 to as RAII variables (Resource Acquisition Is Initialization). Using this
6349 pragma on the relevant type (most typically a limited controlled type), the
6350 compiler will automatically suppress unwanted warnings about these variables
6351 not being referenced.
6353 @node Pragma Unreserve_All_Interrupts
6354 @unnumberedsec Pragma Unreserve_All_Interrupts
6355 @findex Unreserve_All_Interrupts
6359 @smallexample @c ada
6360 pragma Unreserve_All_Interrupts;
6364 Normally certain interrupts are reserved to the implementation. Any attempt
6365 to attach an interrupt causes Program_Error to be raised, as described in
6366 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
6367 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
6368 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
6369 interrupt execution.
6371 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
6372 a program, then all such interrupts are unreserved. This allows the
6373 program to handle these interrupts, but disables their standard
6374 functions. For example, if this pragma is used, then pressing
6375 @kbd{Ctrl-C} will not automatically interrupt execution. However,
6376 a program can then handle the @code{SIGINT} interrupt as it chooses.
6378 For a full list of the interrupts handled in a specific implementation,
6379 see the source code for the spec of @code{Ada.Interrupts.Names} in
6380 file @file{a-intnam.ads}. This is a target dependent file that contains the
6381 list of interrupts recognized for a given target. The documentation in
6382 this file also specifies what interrupts are affected by the use of
6383 the @code{Unreserve_All_Interrupts} pragma.
6385 For a more general facility for controlling what interrupts can be
6386 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
6387 of the @code{Unreserve_All_Interrupts} pragma.
6389 @node Pragma Unsuppress
6390 @unnumberedsec Pragma Unsuppress
6395 @smallexample @c ada
6396 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
6400 This pragma undoes the effect of a previous pragma @code{Suppress}. If
6401 there is no corresponding pragma @code{Suppress} in effect, it has no
6402 effect. The range of the effect is the same as for pragma
6403 @code{Suppress}. The meaning of the arguments is identical to that used
6404 in pragma @code{Suppress}.
6406 One important application is to ensure that checks are on in cases where
6407 code depends on the checks for its correct functioning, so that the code
6408 will compile correctly even if the compiler switches are set to suppress
6411 This pragma is standard in Ada 2005. It is available in all earlier versions
6412 of Ada as an implementation-defined pragma.
6414 Note that in addition to the checks defined in the Ada RM, GNAT recogizes
6415 a number of implementation-defined check names. See description of pragma
6416 @code{Suppress} for full details.
6418 @node Pragma Use_VADS_Size
6419 @unnumberedsec Pragma Use_VADS_Size
6420 @cindex @code{Size}, VADS compatibility
6421 @cindex Rational profile
6422 @findex Use_VADS_Size
6426 @smallexample @c ada
6427 pragma Use_VADS_Size;
6431 This is a configuration pragma. In a unit to which it applies, any use
6432 of the 'Size attribute is automatically interpreted as a use of the
6433 'VADS_Size attribute. Note that this may result in incorrect semantic
6434 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
6435 the handling of existing code which depends on the interpretation of Size
6436 as implemented in the VADS compiler. See description of the VADS_Size
6437 attribute for further details.
6439 @node Pragma Validity_Checks
6440 @unnumberedsec Pragma Validity_Checks
6441 @findex Validity_Checks
6445 @smallexample @c ada
6446 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
6450 This pragma is used in conjunction with compiler switches to control the
6451 built-in validity checking provided by GNAT@. The compiler switches, if set
6452 provide an initial setting for the switches, and this pragma may be used
6453 to modify these settings, or the settings may be provided entirely by
6454 the use of the pragma. This pragma can be used anywhere that a pragma
6455 is legal, including use as a configuration pragma (including use in
6456 the @file{gnat.adc} file).
6458 The form with a string literal specifies which validity options are to be
6459 activated. The validity checks are first set to include only the default
6460 reference manual settings, and then a string of letters in the string
6461 specifies the exact set of options required. The form of this string
6462 is exactly as described for the @option{-gnatVx} compiler switch (see the
6463 @value{EDITION} User's Guide for details). For example the following two
6464 methods can be used to enable validity checking for mode @code{in} and
6465 @code{in out} subprogram parameters:
6469 @smallexample @c ada
6470 pragma Validity_Checks ("im");
6475 gcc -c -gnatVim @dots{}
6480 The form ALL_CHECKS activates all standard checks (its use is equivalent
6481 to the use of the @code{gnatva} switch.
6483 The forms with @code{Off} and @code{On}
6484 can be used to temporarily disable validity checks
6485 as shown in the following example:
6487 @smallexample @c ada
6491 pragma Validity_Checks ("c"); -- validity checks for copies
6492 pragma Validity_Checks (Off); -- turn off validity checks
6493 A := B; -- B will not be validity checked
6494 pragma Validity_Checks (On); -- turn validity checks back on
6495 A := C; -- C will be validity checked
6498 @node Pragma Volatile
6499 @unnumberedsec Pragma Volatile
6504 @smallexample @c ada
6505 pragma Volatile (LOCAL_NAME);
6509 This pragma is defined by the Ada Reference Manual, and the GNAT
6510 implementation is fully conformant with this definition. The reason it
6511 is mentioned in this section is that a pragma of the same name was supplied
6512 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
6513 implementation of pragma Volatile is upwards compatible with the
6514 implementation in DEC Ada 83.
6516 @node Pragma Warnings
6517 @unnumberedsec Pragma Warnings
6522 @smallexample @c ada
6523 pragma Warnings (On | Off [,REASON]);
6524 pragma Warnings (On | Off, LOCAL_NAME [,REASON]);
6525 pragma Warnings (static_string_EXPRESSION [,REASON]);
6526 pragma Warnings (On | Off, static_string_EXPRESSION [,REASON]);
6528 REASON ::= Reason => static_string_EXPRESSION
6532 Normally warnings are enabled, with the output being controlled by
6533 the command line switch. Warnings (@code{Off}) turns off generation of
6534 warnings until a Warnings (@code{On}) is encountered or the end of the
6535 current unit. If generation of warnings is turned off using this
6536 pragma, then some or all of the warning messages are suppressed,
6537 regardless of the setting of the command line switches.
6539 The @code{Reason} parameter may optionally appear as the last argument
6540 in any of the forms of this pragma. It is intended purely for the
6541 purposes of documenting the reason for the @code{Warnings} pragma.
6542 The compiler will check that the argument is a static string but
6543 otherwise ignore this argument. Other tools may provide specialized
6544 processing for this string.
6546 The form with a single argument (or two arguments if Reason present),
6547 where the first argument is @code{ON} or @code{OFF}
6548 may be used as a configuration pragma.
6550 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
6551 the specified entity. This suppression is effective from the point where
6552 it occurs till the end of the extended scope of the variable (similar to
6553 the scope of @code{Suppress}). This form cannot be used as a configuration
6556 The form with a single static_string_EXPRESSION argument (and possible
6557 reason) provides more precise
6558 control over which warnings are active. The string is a list of letters
6559 specifying which warnings are to be activated and which deactivated. The
6560 code for these letters is the same as the string used in the command
6561 line switch controlling warnings. For a brief summary, use the gnatmake
6562 command with no arguments, which will generate usage information containing
6563 the list of warnings switches supported. For
6564 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
6565 User's Guide}. This form can also be used as a configuration pragma.
6568 The warnings controlled by the `-gnatw' switch are generated by the front end
6569 of the compiler. The `GCC' back end can provide additional warnings and they
6570 are controlled by the `-W' switch.
6571 The form with a single static_string_EXPRESSION argument also works for the
6572 latters, but the string must be a single full `-W' switch in this case.
6573 The above reference lists a few examples of these additional warnings.
6576 The specified warnings will be in effect until the end of the program
6577 or another pragma Warnings is encountered. The effect of the pragma is
6578 cumulative. Initially the set of warnings is the standard default set
6579 as possibly modified by compiler switches. Then each pragma Warning
6580 modifies this set of warnings as specified. This form of the pragma may
6581 also be used as a configuration pragma.
6583 The fourth form, with an @code{On|Off} parameter and a string, is used to
6584 control individual messages, based on their text. The string argument
6585 is a pattern that is used to match against the text of individual
6586 warning messages (not including the initial "warning: " tag).
6588 The pattern may contain asterisks, which match zero or more characters in
6589 the message. For example, you can use
6590 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
6591 message @code{warning: 960 bits of "a" unused}. No other regular
6592 expression notations are permitted. All characters other than asterisk in
6593 these three specific cases are treated as literal characters in the match.
6595 The above use of patterns to match the message applies only to warning
6596 messages generated by the front end. This form of the pragma with a
6597 string argument can also be used to control back end warnings controlled
6598 by a "-Wxxx" switch. Such warnings can be identified by the appearence
6599 of a string of the form "[-Wxxx]" in the message which identifies the
6600 "-W" switch that controls the message. By using the text of the
6601 "-W" switch in the pragma, such back end warnings can be turned on and off.
6603 There are two ways to use the pragma in this form. The OFF form can be used as a
6604 configuration pragma. The effect is to suppress all warnings (if any)
6605 that match the pattern string throughout the compilation (or match the
6606 -W switch in the back end case).
6608 The second usage is to suppress a warning locally, and in this case, two
6609 pragmas must appear in sequence:
6611 @smallexample @c ada
6612 pragma Warnings (Off, Pattern);
6613 @dots{} code where given warning is to be suppressed
6614 pragma Warnings (On, Pattern);
6618 In this usage, the pattern string must match in the Off and On pragmas,
6619 and at least one matching warning must be suppressed.
6621 Note: to write a string that will match any warning, use the string
6622 @code{"***"}. It will not work to use a single asterisk or two asterisks
6623 since this looks like an operator name. This form with three asterisks
6624 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
6625 matching @code{pragma Warnings (On, "***")} will be required. This can be
6626 helpful in avoiding forgetting to turn warnings back on.
6628 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
6629 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
6630 be useful in checking whether obsolete pragmas in existing programs are hiding
6633 Note: pragma Warnings does not affect the processing of style messages. See
6634 separate entry for pragma Style_Checks for control of style messages.
6636 @node Pragma Weak_External
6637 @unnumberedsec Pragma Weak_External
6638 @findex Weak_External
6642 @smallexample @c ada
6643 pragma Weak_External ([Entity =>] LOCAL_NAME);
6647 @var{LOCAL_NAME} must refer to an object that is declared at the library
6648 level. This pragma specifies that the given entity should be marked as a
6649 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
6650 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
6651 of a regular symbol, that is to say a symbol that does not have to be
6652 resolved by the linker if used in conjunction with a pragma Import.
6654 When a weak symbol is not resolved by the linker, its address is set to
6655 zero. This is useful in writing interfaces to external modules that may
6656 or may not be linked in the final executable, for example depending on
6657 configuration settings.
6659 If a program references at run time an entity to which this pragma has been
6660 applied, and the corresponding symbol was not resolved at link time, then
6661 the execution of the program is erroneous. It is not erroneous to take the
6662 Address of such an entity, for example to guard potential references,
6663 as shown in the example below.
6665 Some file formats do not support weak symbols so not all target machines
6666 support this pragma.
6668 @smallexample @c ada
6669 -- Example of the use of pragma Weak_External
6671 package External_Module is
6673 pragma Import (C, key);
6674 pragma Weak_External (key);
6675 function Present return boolean;
6676 end External_Module;
6678 with System; use System;
6679 package body External_Module is
6680 function Present return boolean is
6682 return key'Address /= System.Null_Address;
6684 end External_Module;
6687 @node Pragma Wide_Character_Encoding
6688 @unnumberedsec Pragma Wide_Character_Encoding
6689 @findex Wide_Character_Encoding
6693 @smallexample @c ada
6694 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
6698 This pragma specifies the wide character encoding to be used in program
6699 source text appearing subsequently. It is a configuration pragma, but may
6700 also be used at any point that a pragma is allowed, and it is permissible
6701 to have more than one such pragma in a file, allowing multiple encodings
6702 to appear within the same file.
6704 The argument can be an identifier or a character literal. In the identifier
6705 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
6706 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
6707 case it is correspondingly one of the characters @samp{h}, @samp{u},
6708 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
6710 Note that when the pragma is used within a file, it affects only the
6711 encoding within that file, and does not affect withed units, specs,
6714 @node Implementation Defined Aspects
6715 @chapter Implementation Defined Aspects
6716 Ada defines (throughout the Ada 2012 reference manual, summarized
6717 in annex K) a set of aspects that can be specified for certain entities.
6718 These language defined aspects are implemented in GNAT in Ada 2012 mode
6719 and work as described in the Ada 2012 Reference Manual.
6721 In addition, Ada 2012 allows implementations to define additional aspects
6722 whose meaning is defined by the implementation. GNAT provides
6723 a number of these implementation-dependent aspects which can be used
6724 to extend and enhance the functionality of the compiler. This section of
6725 the GNAT reference manual describes these additional attributes.
6727 Note that any program using these aspects may not be portable to
6728 other compilers (although GNAT implements this set of aspects on all
6729 platforms). Therefore if portability to other compilers is an important
6730 consideration, you should minimize the use of these aspects.
6732 Note that for many of these aspects, the effect is essentially similar
6733 to the use of a pragma or attribute specification with the same name
6734 applied to the entity. For example, if we write:
6736 @smallexample @c ada
6737 type R is range 1 .. 100
6738 with Value_Size => 10;
6742 then the effect is the same as:
6744 @smallexample @c ada
6745 type R is range 1 .. 100;
6746 for R'Value_Size use 10;
6752 @smallexample @c ada
6753 type R is new Integer
6754 with Shared => True;
6758 then the effect is the same as:
6760 @smallexample @c ada
6761 type R is new Integer;
6766 In the documentation sections that follow, such cases are simply marked
6767 as being equivalent to the corresponding pragma or attribute definition
6771 * Aspect Abstract_State::
6774 * Aspect Compiler_Unit::
6775 * Aspect Contract_Cases::
6777 * Aspect Dimension::
6778 * Aspect Dimension_System::
6779 * Aspect Favor_Top_Level::
6781 * Aspect Inline_Always::
6782 * Aspect Invariant::
6783 * Aspect Lock_Free::
6784 * Aspect Object_Size::
6785 * Aspect Persistent_BSS::
6786 * Aspect Predicate::
6787 * Aspect Preelaborate_05::
6790 * Aspect Pure_Function::
6791 * Aspect Remote_Access_Type::
6792 * Aspect Scalar_Storage_Order::
6794 * Aspect Simple_Storage_Pool::
6795 * Aspect Simple_Storage_Pool_Type::
6796 * Aspect Suppress_Debug_Info::
6797 * Aspect Test_Case::
6798 * Aspect Universal_Aliasing::
6799 * Aspect Universal_Data::
6800 * Aspect Unmodified::
6801 * Aspect Unreferenced::
6802 * Aspect Unreferenced_Objects::
6803 * Aspect Value_Size::
6807 @node Aspect Abstract_State
6808 @unnumberedsec Aspect Abstract_State
6809 @findex Abstract_State
6811 This aspect is equivalent to pragma @code{Abstract_State}.
6813 @node Aspect Ada_2005
6814 @unnumberedsec Aspect Ada_2005
6817 This aspect is equivalent to the one argument form of pragma @code{Ada_2005}.
6819 @node Aspect Ada_2012
6820 @unnumberedsec Aspect Ada_2012
6823 This aspect is equivalent to the one argument form of pragma @code{Ada_2012}.
6825 @node Aspect Compiler_Unit
6826 @unnumberedsec Aspect Compiler_Unit
6827 @findex Compiler_Unit
6829 This aspect is equivalent to pragma @code{Compiler_Unit}.
6831 @node Aspect Contract_Cases
6832 @unnumberedsec Aspect Contract_Cases
6833 @findex Contract_Cases
6835 This aspect is equivalent to pragma @code{Contract_Cases}, the sequence
6836 of clauses being enclosed in parentheses so that syntactically it is an
6839 @node Aspect Depends
6840 @unnumberedsec Aspect Depends
6843 This aspect is equivalent to pragma @code{Depends}.
6847 @node Aspect Dimension
6848 @unnumberedsec Aspect Dimension
6851 The @code{Dimension} aspect is used to specify the dimensions of a given
6852 subtype of a dimensioned numeric type. The aspect also specifies a symbol
6853 used when doing formatted output of dimensioned quantities. The syntax is:
6855 @smallexample @c ada
6857 ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
6859 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
6863 | others => RATIONAL
6864 | DISCRETE_CHOICE_LIST => RATIONAL
6866 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
6870 This aspect can only be applied to a subtype whose parent type has
6871 a @code{Dimension_Systen} aspect. The aspect must specify values for
6872 all dimensions of the system. The rational values are the powers of the
6873 corresponding dimensions that are used by the compiler to verify that
6874 physical (numeric) computations are dimensionally consistent. For example,
6875 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
6876 For further examples of the usage
6877 of this aspect, see package @code{System.Dim.Mks}.
6878 Note that when the dimensioned type is an integer type, then any
6879 dimension value must be an integer literal.
6881 @node Aspect Dimension_System
6882 @unnumberedsec Aspect Dimension_System
6883 @findex Dimension_System
6885 The @code{Dimension_System} aspect is used to define a system of
6886 dimensions that will be used in subsequent subtype declarations with
6887 @code{Dimension} aspects that reference this system. The syntax is:
6889 @smallexample @c ada
6890 with Dimension_System => (DIMENSION @{, DIMENSION@});
6892 DIMENSION ::= ([Unit_Name =>] IDENTIFIER,
6893 [Unit_Symbol =>] SYMBOL,
6894 [Dim_Symbol =>] SYMBOL)
6896 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
6900 This aspect is applied to a type, which must be a numeric derived type
6901 (typically a floating-point type), that
6902 will represent values within the dimension system. Each @code{DIMENSION}
6903 corresponds to one particular dimension. A maximum of 7 dimensions may
6904 be specified. @code{Unit_Name} is the name of the dimension (for example
6905 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
6906 of this dimension (for example 'm' for Meter). @code{Dim_Symbol} gives
6907 the identification within the dimension system (typically this is a
6908 single letter, e.g. 'L' standing for length for unit name Meter). The
6909 Unit_Smbol is used in formatted output of dimensioned quantities. The
6910 Dim_Symbol is used in error messages when numeric operations have
6911 inconsistent dimensions.
6913 GNAT provides the standard definition of the International MKS system in
6914 the run-time package @code{System.Dim.Mks}. You can easily define
6915 similar packages for cgs units or British units, and define conversion factors
6916 between values in different systems. The MKS system is characterized by the
6919 @smallexample @c ada
6920 type Mks_Type is new Long_Long_Float
6922 Dimension_System => (
6923 (Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'),
6924 (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'),
6925 (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'),
6926 (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'),
6927 (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => "Theta"),
6928 (Unit_Name => Mole, Unit_Symbol => "mol", Dim_Symbol => 'N'),
6929 (Unit_Name => Candela, Unit_Symbol => "cd", Dim_Symbol => 'J'));
6933 See section "Performing Dimensionality Analysis in GNAT" in the GNAT Users
6934 Guide for detailed examples of use of the dimension system.
6936 @node Aspect Favor_Top_Level
6937 @unnumberedsec Aspect Favor_Top_Level
6938 @findex Favor_Top_Level
6940 This aspect is equivalent to pragma @code{Favor_Top_Level}.
6943 @unnumberedsec Aspect Global
6946 This aspect is equivalent pragma @code{Global}.
6948 @node Aspect Inline_Always
6949 @unnumberedsec Aspect Inline_Always
6950 @findex Inline_Always
6952 This aspect is equivalent to pragma @code{Inline_Always}.
6954 @node Aspect Invariant
6955 @unnumberedsec Aspect Invariant
6958 This aspect is equivalent to pragma @code{Invariant}. It is a
6959 synonym for the language defined aspect @code{Type_Invariant} except
6960 that it is separately controllable using pragma @code{Assertion_Policy}.
6962 @node Aspect Lock_Free
6963 @unnumberedsec Aspect Lock_Free
6966 This aspect is equivalent to pragma @code{Lock_Free}.
6968 @node Aspect Object_Size
6969 @unnumberedsec Aspect Object_Size
6972 This aspect is equivalent to an @code{Object_Size} attribute definition
6975 @node Aspect Persistent_BSS
6976 @unnumberedsec Aspect Persistent_BSS
6977 @findex Persistent_BSS
6979 This aspect is equivalent to pragma @code{Persistent_BSS}.
6981 @node Aspect Predicate
6982 @unnumberedsec Aspect Predicate
6985 This aspect is equivalent to pragma @code{Predicate}. It is thus
6986 similar to the language defined aspects @code{Dynamic_Predicate}
6987 and @code{Static_Predicate} except that whether the resulting
6988 predicate is static or dynamic is controlled by the form of the
6989 expression. It is also separately controllable using pragma
6990 @code{Assertion_Policy}.
6992 @node Aspect Preelaborate_05
6993 @unnumberedsec Aspect Preelaborate_05
6994 @findex Preelaborate_05
6996 This aspect is equivalent to pragma @code{Preelaborate_05}.
6998 @node Aspect Pure_05
6999 @unnumberedsec Aspect Pure_05
7002 This aspect is equivalent to pragma @code{Pure_05}.
7004 @node Aspect Pure_12
7005 @unnumberedsec Aspect Pure_12
7008 This aspect is equivalent to pragma @code{Pure_12}.
7010 @node Aspect Pure_Function
7011 @unnumberedsec Aspect Pure_Function
7012 @findex Pure_Function
7014 This aspect is equivalent to pragma @code{Pure_Function}.
7016 @node Aspect Remote_Access_Type
7017 @unnumberedsec Aspect Remote_Access_Type
7018 @findex Remote_Access_Type
7020 This aspect is equivalent to pragma @code{Remote_Access_Type}.
7022 @node Aspect Scalar_Storage_Order
7023 @unnumberedsec Aspect Scalar_Storage_Order
7024 @findex Scalar_Storage_Order
7026 This aspect is equivalent to a @code{Scalar_Storage_Order}
7027 attribute definition clause.
7030 @unnumberedsec Aspect Shared
7033 This aspect is equivalent to pragma @code{Shared}, and is thus a synonym
7034 for aspect @code{Atomic}.
7036 @node Aspect Simple_Storage_Pool
7037 @unnumberedsec Aspect Simple_Storage_Pool
7038 @findex Simple_Storage_Pool
7040 This aspect is equivalent to a @code{Simple_Storage_Pool}
7041 attribute definition clause.
7043 @node Aspect Simple_Storage_Pool_Type
7044 @unnumberedsec Aspect Simple_Storage_Pool_Type
7045 @findex Simple_Storage_Pool_Type
7047 This aspect is equivalent to pragma @code{Simple_Storage_Pool_Type}.
7049 @node Aspect Suppress_Debug_Info
7050 @unnumberedsec Aspect Suppress_Debug_Info
7051 @findex Suppress_Debug_Info
7053 This aspect is equivalent to pragma @code{Suppress_Debug_Info}.
7055 @node Aspect Test_Case
7056 @unnumberedsec Aspect Test_Case
7059 This aspect is equivalent to pragma @code{Test_Case}.
7061 @node Aspect Universal_Aliasing
7062 @unnumberedsec Aspect Universal_Aliasing
7063 @findex Universal_Aliasing
7065 This aspect is equivalent to pragma @code{Universal_Aliasing}.
7067 @node Aspect Universal_Data
7068 @unnumberedsec Aspect Universal_Data
7069 @findex Universal_Data
7071 This aspect is equivalent to pragma @code{Universal_Data}.
7073 @node Aspect Unmodified
7074 @unnumberedsec Aspect Unmodified
7077 This aspect is equivalent to pragma @code{Unmodified}.
7079 @node Aspect Unreferenced
7080 @unnumberedsec Aspect Unreferenced
7081 @findex Unreferenced
7083 This aspect is equivalent to pragma @code{Unreferenced}.
7085 @node Aspect Unreferenced_Objects
7086 @unnumberedsec Aspect Unreferenced_Objects
7087 @findex Unreferenced_Objects
7089 This aspect is equivalent to pragma @code{Unreferenced_Objects}.
7091 @node Aspect Value_Size
7092 @unnumberedsec Aspect Value_Size
7095 This aspect is equivalent to a @code{Value_Size}
7096 attribute definition clause.
7098 @node Aspect Warnings
7099 @unnumberedsec Aspect Warnings
7102 This aspect is equivalent to the two argument form of pragma @code{Warnings},
7103 where the first argument is @code{ON} or @code{OFF} and the second argument
7106 @node Implementation Defined Attributes
7107 @chapter Implementation Defined Attributes
7108 Ada defines (throughout the Ada reference manual,
7109 summarized in Annex K),
7110 a set of attributes that provide useful additional functionality in all
7111 areas of the language. These language defined attributes are implemented
7112 in GNAT and work as described in the Ada Reference Manual.
7114 In addition, Ada allows implementations to define additional
7115 attributes whose meaning is defined by the implementation. GNAT provides
7116 a number of these implementation-dependent attributes which can be used
7117 to extend and enhance the functionality of the compiler. This section of
7118 the GNAT reference manual describes these additional attributes.
7120 Note that any program using these attributes may not be portable to
7121 other compilers (although GNAT implements this set of attributes on all
7122 platforms). Therefore if portability to other compilers is an important
7123 consideration, you should minimize the use of these attributes.
7126 * Attribute Abort_Signal::
7127 * Attribute Address_Size::
7128 * Attribute Asm_Input::
7129 * Attribute Asm_Output::
7130 * Attribute AST_Entry::
7132 * Attribute Bit_Position::
7133 * Attribute Compiler_Version::
7134 * Attribute Code_Address::
7135 * Attribute Default_Bit_Order::
7136 * Attribute Descriptor_Size::
7137 * Attribute Elaborated::
7138 * Attribute Elab_Body::
7139 * Attribute Elab_Spec::
7140 * Attribute Elab_Subp_Body::
7142 * Attribute Enabled::
7143 * Attribute Enum_Rep::
7144 * Attribute Enum_Val::
7145 * Attribute Epsilon::
7146 * Attribute Fixed_Value::
7147 * Attribute Has_Access_Values::
7148 * Attribute Has_Discriminants::
7150 * Attribute Integer_Value::
7151 * Attribute Invalid_Value::
7153 * Attribute Loop_Entry::
7154 * Attribute Machine_Size::
7155 * Attribute Mantissa::
7156 * Attribute Max_Interrupt_Priority::
7157 * Attribute Max_Priority::
7158 * Attribute Maximum_Alignment::
7159 * Attribute Mechanism_Code::
7160 * Attribute Null_Parameter::
7161 * Attribute Object_Size::
7162 * Attribute Passed_By_Reference::
7163 * Attribute Pool_Address::
7164 * Attribute Range_Length::
7166 * Attribute Result::
7167 * Attribute Safe_Emax::
7168 * Attribute Safe_Large::
7169 * Attribute Scalar_Storage_Order::
7170 * Attribute Simple_Storage_Pool::
7172 * Attribute Storage_Unit::
7173 * Attribute Stub_Type::
7174 * Attribute System_Allocator_Alignment::
7175 * Attribute Target_Name::
7177 * Attribute To_Address::
7178 * Attribute Type_Class::
7179 * Attribute UET_Address::
7180 * Attribute Unconstrained_Array::
7181 * Attribute Universal_Literal_String::
7182 * Attribute Unrestricted_Access::
7183 * Attribute Update::
7184 * Attribute Valid_Scalars::
7185 * Attribute VADS_Size::
7186 * Attribute Value_Size::
7187 * Attribute Wchar_T_Size::
7188 * Attribute Word_Size::
7191 @node Attribute Abort_Signal
7192 @unnumberedsec Attribute Abort_Signal
7193 @findex Abort_Signal
7195 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
7196 prefix) provides the entity for the special exception used to signal
7197 task abort or asynchronous transfer of control. Normally this attribute
7198 should only be used in the tasking runtime (it is highly peculiar, and
7199 completely outside the normal semantics of Ada, for a user program to
7200 intercept the abort exception).
7202 @node Attribute Address_Size
7203 @unnumberedsec Attribute Address_Size
7204 @cindex Size of @code{Address}
7205 @findex Address_Size
7207 @code{Standard'Address_Size} (@code{Standard} is the only allowed
7208 prefix) is a static constant giving the number of bits in an
7209 @code{Address}. It is the same value as System.Address'Size,
7210 but has the advantage of being static, while a direct
7211 reference to System.Address'Size is non-static because Address
7214 @node Attribute Asm_Input
7215 @unnumberedsec Attribute Asm_Input
7218 The @code{Asm_Input} attribute denotes a function that takes two
7219 parameters. The first is a string, the second is an expression of the
7220 type designated by the prefix. The first (string) argument is required
7221 to be a static expression, and is the constraint for the parameter,
7222 (e.g.@: what kind of register is required). The second argument is the
7223 value to be used as the input argument. The possible values for the
7224 constant are the same as those used in the RTL, and are dependent on
7225 the configuration file used to built the GCC back end.
7226 @ref{Machine Code Insertions}
7228 @node Attribute Asm_Output
7229 @unnumberedsec Attribute Asm_Output
7232 The @code{Asm_Output} attribute denotes a function that takes two
7233 parameters. The first is a string, the second is the name of a variable
7234 of the type designated by the attribute prefix. The first (string)
7235 argument is required to be a static expression and designates the
7236 constraint for the parameter (e.g.@: what kind of register is
7237 required). The second argument is the variable to be updated with the
7238 result. The possible values for constraint are the same as those used in
7239 the RTL, and are dependent on the configuration file used to build the
7240 GCC back end. If there are no output operands, then this argument may
7241 either be omitted, or explicitly given as @code{No_Output_Operands}.
7242 @ref{Machine Code Insertions}
7244 @node Attribute AST_Entry
7245 @unnumberedsec Attribute AST_Entry
7249 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
7250 the name of an entry, it yields a value of the predefined type AST_Handler
7251 (declared in the predefined package System, as extended by the use of
7252 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
7253 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
7254 Language Reference Manual}, section 9.12a.
7257 @unnumberedsec Attribute Bit
7259 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
7260 offset within the storage unit (byte) that contains the first bit of
7261 storage allocated for the object. The value of this attribute is of the
7262 type @code{Universal_Integer}, and is always a non-negative number not
7263 exceeding the value of @code{System.Storage_Unit}.
7265 For an object that is a variable or a constant allocated in a register,
7266 the value is zero. (The use of this attribute does not force the
7267 allocation of a variable to memory).
7269 For an object that is a formal parameter, this attribute applies
7270 to either the matching actual parameter or to a copy of the
7271 matching actual parameter.
7273 For an access object the value is zero. Note that
7274 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
7275 designated object. Similarly for a record component
7276 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
7277 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
7278 are subject to index checks.
7280 This attribute is designed to be compatible with the DEC Ada 83 definition
7281 and implementation of the @code{Bit} attribute.
7283 @node Attribute Bit_Position
7284 @unnumberedsec Attribute Bit_Position
7285 @findex Bit_Position
7287 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
7288 of the fields of the record type, yields the bit
7289 offset within the record contains the first bit of
7290 storage allocated for the object. The value of this attribute is of the
7291 type @code{Universal_Integer}. The value depends only on the field
7292 @var{C} and is independent of the alignment of
7293 the containing record @var{R}.
7295 @node Attribute Compiler_Version
7296 @unnumberedsec Attribute Compiler_Version
7297 @findex Compiler_Version
7299 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
7300 prefix) yields a static string identifying the version of the compiler
7301 being used to compile the unit containing the attribute reference. A
7302 typical result would be something like "@value{EDITION} @i{version} (20090221)".
7304 @node Attribute Code_Address
7305 @unnumberedsec Attribute Code_Address
7306 @findex Code_Address
7307 @cindex Subprogram address
7308 @cindex Address of subprogram code
7311 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
7312 intended effect seems to be to provide
7313 an address value which can be used to call the subprogram by means of
7314 an address clause as in the following example:
7316 @smallexample @c ada
7317 procedure K is @dots{}
7320 for L'Address use K'Address;
7321 pragma Import (Ada, L);
7325 A call to @code{L} is then expected to result in a call to @code{K}@.
7326 In Ada 83, where there were no access-to-subprogram values, this was
7327 a common work-around for getting the effect of an indirect call.
7328 GNAT implements the above use of @code{Address} and the technique
7329 illustrated by the example code works correctly.
7331 However, for some purposes, it is useful to have the address of the start
7332 of the generated code for the subprogram. On some architectures, this is
7333 not necessarily the same as the @code{Address} value described above.
7334 For example, the @code{Address} value may reference a subprogram
7335 descriptor rather than the subprogram itself.
7337 The @code{'Code_Address} attribute, which can only be applied to
7338 subprogram entities, always returns the address of the start of the
7339 generated code of the specified subprogram, which may or may not be
7340 the same value as is returned by the corresponding @code{'Address}
7343 @node Attribute Default_Bit_Order
7344 @unnumberedsec Attribute Default_Bit_Order
7346 @cindex Little endian
7347 @findex Default_Bit_Order
7349 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
7350 permissible prefix), provides the value @code{System.Default_Bit_Order}
7351 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
7352 @code{Low_Order_First}). This is used to construct the definition of
7353 @code{Default_Bit_Order} in package @code{System}.
7355 @node Attribute Descriptor_Size
7356 @unnumberedsec Attribute Descriptor_Size
7359 @findex Descriptor_Size
7361 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
7362 descriptor allocated for a type. The result is non-zero only for unconstrained
7363 array types and the returned value is of type universal integer. In GNAT, an
7364 array descriptor contains bounds information and is located immediately before
7365 the first element of the array.
7367 @smallexample @c ada
7368 type Unconstr_Array is array (Positive range <>) of Boolean;
7369 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
7373 The attribute takes into account any additional padding due to type alignment.
7374 In the example above, the descriptor contains two values of type
7375 @code{Positive} representing the low and high bound. Since @code{Positive} has
7376 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
7377 Positive'Size + 2} or 64 bits.
7379 @node Attribute Elaborated
7380 @unnumberedsec Attribute Elaborated
7383 The prefix of the @code{'Elaborated} attribute must be a unit name. The
7384 value is a Boolean which indicates whether or not the given unit has been
7385 elaborated. This attribute is primarily intended for internal use by the
7386 generated code for dynamic elaboration checking, but it can also be used
7387 in user programs. The value will always be True once elaboration of all
7388 units has been completed. An exception is for units which need no
7389 elaboration, the value is always False for such units.
7391 @node Attribute Elab_Body
7392 @unnumberedsec Attribute Elab_Body
7395 This attribute can only be applied to a program unit name. It returns
7396 the entity for the corresponding elaboration procedure for elaborating
7397 the body of the referenced unit. This is used in the main generated
7398 elaboration procedure by the binder and is not normally used in any
7399 other context. However, there may be specialized situations in which it
7400 is useful to be able to call this elaboration procedure from Ada code,
7401 e.g.@: if it is necessary to do selective re-elaboration to fix some
7404 @node Attribute Elab_Spec
7405 @unnumberedsec Attribute Elab_Spec
7408 This attribute can only be applied to a program unit name. It returns
7409 the entity for the corresponding elaboration procedure for elaborating
7410 the spec of the referenced unit. This is used in the main
7411 generated elaboration procedure by the binder and is not normally used
7412 in any other context. However, there may be specialized situations in
7413 which it is useful to be able to call this elaboration procedure from
7414 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
7417 @node Attribute Elab_Subp_Body
7418 @unnumberedsec Attribute Elab_Subp_Body
7419 @findex Elab_Subp_Body
7421 This attribute can only be applied to a library level subprogram
7422 name and is only allowed in CodePeer mode. It returns the entity
7423 for the corresponding elaboration procedure for elaborating the body
7424 of the referenced subprogram unit. This is used in the main generated
7425 elaboration procedure by the binder in CodePeer mode only and is unrecognized
7428 @node Attribute Emax
7429 @unnumberedsec Attribute Emax
7430 @cindex Ada 83 attributes
7433 The @code{Emax} attribute is provided for compatibility with Ada 83. See
7434 the Ada 83 reference manual for an exact description of the semantics of
7437 @node Attribute Enabled
7438 @unnumberedsec Attribute Enabled
7441 The @code{Enabled} attribute allows an application program to check at compile
7442 time to see if the designated check is currently enabled. The prefix is a
7443 simple identifier, referencing any predefined check name (other than
7444 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
7445 no argument is given for the attribute, the check is for the general state
7446 of the check, if an argument is given, then it is an entity name, and the
7447 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
7448 given naming the entity (if not, then the argument is ignored).
7450 Note that instantiations inherit the check status at the point of the
7451 instantiation, so a useful idiom is to have a library package that
7452 introduces a check name with @code{pragma Check_Name}, and then contains
7453 generic packages or subprograms which use the @code{Enabled} attribute
7454 to see if the check is enabled. A user of this package can then issue
7455 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
7456 the package or subprogram, controlling whether the check will be present.
7458 @node Attribute Enum_Rep
7459 @unnumberedsec Attribute Enum_Rep
7460 @cindex Representation of enums
7463 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
7464 function with the following spec:
7466 @smallexample @c ada
7467 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
7468 return @i{Universal_Integer};
7472 It is also allowable to apply @code{Enum_Rep} directly to an object of an
7473 enumeration type or to a non-overloaded enumeration
7474 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
7475 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
7476 enumeration literal or object.
7478 The function returns the representation value for the given enumeration
7479 value. This will be equal to value of the @code{Pos} attribute in the
7480 absence of an enumeration representation clause. This is a static
7481 attribute (i.e.@: the result is static if the argument is static).
7483 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
7484 in which case it simply returns the integer value. The reason for this
7485 is to allow it to be used for @code{(<>)} discrete formal arguments in
7486 a generic unit that can be instantiated with either enumeration types
7487 or integer types. Note that if @code{Enum_Rep} is used on a modular
7488 type whose upper bound exceeds the upper bound of the largest signed
7489 integer type, and the argument is a variable, so that the universal
7490 integer calculation is done at run time, then the call to @code{Enum_Rep}
7491 may raise @code{Constraint_Error}.
7493 @node Attribute Enum_Val
7494 @unnumberedsec Attribute Enum_Val
7495 @cindex Representation of enums
7498 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
7499 function with the following spec:
7501 @smallexample @c ada
7502 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
7503 return @var{S}'Base};
7507 The function returns the enumeration value whose representation matches the
7508 argument, or raises Constraint_Error if no enumeration literal of the type
7509 has the matching value.
7510 This will be equal to value of the @code{Val} attribute in the
7511 absence of an enumeration representation clause. This is a static
7512 attribute (i.e.@: the result is static if the argument is static).
7514 @node Attribute Epsilon
7515 @unnumberedsec Attribute Epsilon
7516 @cindex Ada 83 attributes
7519 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
7520 the Ada 83 reference manual for an exact description of the semantics of
7523 @node Attribute Fixed_Value
7524 @unnumberedsec Attribute Fixed_Value
7527 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
7528 function with the following specification:
7530 @smallexample @c ada
7531 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
7536 The value returned is the fixed-point value @var{V} such that
7538 @smallexample @c ada
7539 @var{V} = Arg * @var{S}'Small
7543 The effect is thus similar to first converting the argument to the
7544 integer type used to represent @var{S}, and then doing an unchecked
7545 conversion to the fixed-point type. The difference is
7546 that there are full range checks, to ensure that the result is in range.
7547 This attribute is primarily intended for use in implementation of the
7548 input-output functions for fixed-point values.
7550 @node Attribute Has_Access_Values
7551 @unnumberedsec Attribute Has_Access_Values
7552 @cindex Access values, testing for
7553 @findex Has_Access_Values
7555 The prefix of the @code{Has_Access_Values} attribute is a type. The result
7556 is a Boolean value which is True if the is an access type, or is a composite
7557 type with a component (at any nesting depth) that is an access type, and is
7559 The intended use of this attribute is in conjunction with generic
7560 definitions. If the attribute is applied to a generic private type, it
7561 indicates whether or not the corresponding actual type has access values.
7563 @node Attribute Has_Discriminants
7564 @unnumberedsec Attribute Has_Discriminants
7565 @cindex Discriminants, testing for
7566 @findex Has_Discriminants
7568 The prefix of the @code{Has_Discriminants} attribute is a type. The result
7569 is a Boolean value which is True if the type has discriminants, and False
7570 otherwise. The intended use of this attribute is in conjunction with generic
7571 definitions. If the attribute is applied to a generic private type, it
7572 indicates whether or not the corresponding actual type has discriminants.
7575 @unnumberedsec Attribute Img
7578 The @code{Img} attribute differs from @code{Image} in that it may be
7579 applied to objects as well as types, in which case it gives the
7580 @code{Image} for the subtype of the object. This is convenient for
7583 @smallexample @c ada
7584 Put_Line ("X = " & X'Img);
7588 has the same meaning as the more verbose:
7590 @smallexample @c ada
7591 Put_Line ("X = " & @var{T}'Image (X));
7595 where @var{T} is the (sub)type of the object @code{X}.
7597 @node Attribute Integer_Value
7598 @unnumberedsec Attribute Integer_Value
7599 @findex Integer_Value
7601 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
7602 function with the following spec:
7604 @smallexample @c ada
7605 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
7610 The value returned is the integer value @var{V}, such that
7612 @smallexample @c ada
7613 Arg = @var{V} * @var{T}'Small
7617 where @var{T} is the type of @code{Arg}.
7618 The effect is thus similar to first doing an unchecked conversion from
7619 the fixed-point type to its corresponding implementation type, and then
7620 converting the result to the target integer type. The difference is
7621 that there are full range checks, to ensure that the result is in range.
7622 This attribute is primarily intended for use in implementation of the
7623 standard input-output functions for fixed-point values.
7625 @node Attribute Invalid_Value
7626 @unnumberedsec Attribute Invalid_Value
7627 @findex Invalid_Value
7629 For every scalar type S, S'Invalid_Value returns an undefined value of the
7630 type. If possible this value is an invalid representation for the type. The
7631 value returned is identical to the value used to initialize an otherwise
7632 uninitialized value of the type if pragma Initialize_Scalars is used,
7633 including the ability to modify the value with the binder -Sxx flag and
7634 relevant environment variables at run time.
7636 @node Attribute Large
7637 @unnumberedsec Attribute Large
7638 @cindex Ada 83 attributes
7641 The @code{Large} attribute is provided for compatibility with Ada 83. See
7642 the Ada 83 reference manual for an exact description of the semantics of
7645 @node Attribute Loop_Entry
7646 @unnumberedsec Attribute Loop_Entry
7651 @smallexample @c ada
7652 X'Loop_Entry [(loop_name)]
7656 The @code{Loop_Entry} attribute is used to refer to the value that an
7657 expression had upon entry to a given loop in much the same way that the
7658 @code{Old} attribute in a subprogram postcondition can be used to refer
7659 to the value an expression had upon entry to the subprogram. The
7660 relevant loop is either identified by the given loop name, or it is the
7661 innermost enclosing loop when no loop name is given.
7664 A @code{Loop_Entry} attribute can only occur within a
7665 @code{Loop_Variant} or @code{Loop_Invariant} pragma. A common use of
7666 @code{Loop_Entry} is to compare the current value of objects with their
7667 initial value at loop entry, in a @code{Loop_Invariant} pragma.
7670 The effect of using @code{X'Loop_Entry} is the same as declaring
7671 a constant initialized with the initial value of @code{X} at loop
7672 entry. This copy is not performed if the loop is not entered, or if the
7673 corresponding pragmas are ignored or disabled.
7675 @node Attribute Machine_Size
7676 @unnumberedsec Attribute Machine_Size
7677 @findex Machine_Size
7679 This attribute is identical to the @code{Object_Size} attribute. It is
7680 provided for compatibility with the DEC Ada 83 attribute of this name.
7682 @node Attribute Mantissa
7683 @unnumberedsec Attribute Mantissa
7684 @cindex Ada 83 attributes
7687 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
7688 the Ada 83 reference manual for an exact description of the semantics of
7691 @node Attribute Max_Interrupt_Priority
7692 @unnumberedsec Attribute Max_Interrupt_Priority
7693 @cindex Interrupt priority, maximum
7694 @findex Max_Interrupt_Priority
7696 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
7697 permissible prefix), provides the same value as
7698 @code{System.Max_Interrupt_Priority}.
7700 @node Attribute Max_Priority
7701 @unnumberedsec Attribute Max_Priority
7702 @cindex Priority, maximum
7703 @findex Max_Priority
7705 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
7706 prefix) provides the same value as @code{System.Max_Priority}.
7708 @node Attribute Maximum_Alignment
7709 @unnumberedsec Attribute Maximum_Alignment
7710 @cindex Alignment, maximum
7711 @findex Maximum_Alignment
7713 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
7714 permissible prefix) provides the maximum useful alignment value for the
7715 target. This is a static value that can be used to specify the alignment
7716 for an object, guaranteeing that it is properly aligned in all
7719 @node Attribute Mechanism_Code
7720 @unnumberedsec Attribute Mechanism_Code
7721 @cindex Return values, passing mechanism
7722 @cindex Parameters, passing mechanism
7723 @findex Mechanism_Code
7725 @code{@var{function}'Mechanism_Code} yields an integer code for the
7726 mechanism used for the result of function, and
7727 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
7728 used for formal parameter number @var{n} (a static integer value with 1
7729 meaning the first parameter) of @var{subprogram}. The code returned is:
7737 by descriptor (default descriptor class)
7739 by descriptor (UBS: unaligned bit string)
7741 by descriptor (UBSB: aligned bit string with arbitrary bounds)
7743 by descriptor (UBA: unaligned bit array)
7745 by descriptor (S: string, also scalar access type parameter)
7747 by descriptor (SB: string with arbitrary bounds)
7749 by descriptor (A: contiguous array)
7751 by descriptor (NCA: non-contiguous array)
7755 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
7758 @node Attribute Null_Parameter
7759 @unnumberedsec Attribute Null_Parameter
7760 @cindex Zero address, passing
7761 @findex Null_Parameter
7763 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
7764 type or subtype @var{T} allocated at machine address zero. The attribute
7765 is allowed only as the default expression of a formal parameter, or as
7766 an actual expression of a subprogram call. In either case, the
7767 subprogram must be imported.
7769 The identity of the object is represented by the address zero in the
7770 argument list, independent of the passing mechanism (explicit or
7773 This capability is needed to specify that a zero address should be
7774 passed for a record or other composite object passed by reference.
7775 There is no way of indicating this without the @code{Null_Parameter}
7778 @node Attribute Object_Size
7779 @unnumberedsec Attribute Object_Size
7780 @cindex Size, used for objects
7783 The size of an object is not necessarily the same as the size of the type
7784 of an object. This is because by default object sizes are increased to be
7785 a multiple of the alignment of the object. For example,
7786 @code{Natural'Size} is
7787 31, but by default objects of type @code{Natural} will have a size of 32 bits.
7788 Similarly, a record containing an integer and a character:
7790 @smallexample @c ada
7798 will have a size of 40 (that is @code{Rec'Size} will be 40). The
7799 alignment will be 4, because of the
7800 integer field, and so the default size of record objects for this type
7801 will be 64 (8 bytes).
7803 @node Attribute Passed_By_Reference
7804 @unnumberedsec Attribute Passed_By_Reference
7805 @cindex Parameters, when passed by reference
7806 @findex Passed_By_Reference
7808 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
7809 a value of type @code{Boolean} value that is @code{True} if the type is
7810 normally passed by reference and @code{False} if the type is normally
7811 passed by copy in calls. For scalar types, the result is always @code{False}
7812 and is static. For non-scalar types, the result is non-static.
7814 @node Attribute Pool_Address
7815 @unnumberedsec Attribute Pool_Address
7816 @cindex Parameters, when passed by reference
7817 @findex Pool_Address
7819 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
7820 of X within its storage pool. This is the same as
7821 @code{@var{X}'Address}, except that for an unconstrained array whose
7822 bounds are allocated just before the first component,
7823 @code{@var{X}'Pool_Address} returns the address of those bounds,
7824 whereas @code{@var{X}'Address} returns the address of the first
7827 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
7828 the object is allocated'', which could be a user-defined storage pool,
7829 the global heap, on the stack, or in a static memory area. For an
7830 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
7831 what is passed to @code{Allocate} and returned from @code{Deallocate}.
7833 @node Attribute Range_Length
7834 @unnumberedsec Attribute Range_Length
7835 @findex Range_Length
7837 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
7838 the number of values represented by the subtype (zero for a null
7839 range). The result is static for static subtypes. @code{Range_Length}
7840 applied to the index subtype of a one dimensional array always gives the
7841 same result as @code{Length} applied to the array itself.
7844 @unnumberedsec Attribute Ref
7847 The @code{System.Address'Ref}
7848 (@code{System.Address} is the only permissible prefix)
7849 denotes a function identical to
7850 @code{System.Storage_Elements.To_Address} except that
7851 it is a static attribute. See @ref{Attribute To_Address} for more details.
7853 @node Attribute Result
7854 @unnumberedsec Attribute Result
7857 @code{@var{function}'Result} can only be used with in a Postcondition pragma
7858 for a function. The prefix must be the name of the corresponding function. This
7859 is used to refer to the result of the function in the postcondition expression.
7860 For a further discussion of the use of this attribute and examples of its use,
7861 see the description of pragma Postcondition.
7863 @node Attribute Safe_Emax
7864 @unnumberedsec Attribute Safe_Emax
7865 @cindex Ada 83 attributes
7868 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
7869 the Ada 83 reference manual for an exact description of the semantics of
7872 @node Attribute Safe_Large
7873 @unnumberedsec Attribute Safe_Large
7874 @cindex Ada 83 attributes
7877 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
7878 the Ada 83 reference manual for an exact description of the semantics of
7881 @node Attribute Scalar_Storage_Order
7882 @unnumberedsec Attribute Scalar_Storage_Order
7884 @cindex Scalar storage order
7885 @findex Scalar_Storage_Order
7887 For every array or record type @var{S}, the representation attribute
7888 @code{Scalar_Storage_Order} denotes the order in which storage elements
7889 that make up scalar components are ordered within S:
7891 @smallexample @c ada
7892 -- Component type definitions
7894 subtype Yr_Type is Natural range 0 .. 127;
7895 subtype Mo_Type is Natural range 1 .. 12;
7896 subtype Da_Type is Natural range 1 .. 31;
7898 -- Record declaration
7901 Years_Since_1980 : Yr_Type;
7903 Day_Of_Month : Da_Type;
7906 -- Record representation clause
7909 Years_Since_1980 at 0 range 0 .. 6;
7910 Month at 0 range 7 .. 10;
7911 Day_Of_Month at 0 range 11 .. 15;
7914 -- Attribute definition clauses
7916 for Date'Bit_Order use System.High_Order_First;
7917 for Date'Scalar_Storage_Order use System.High_Order_First;
7918 -- If Scalar_Storage_Order is specified, it must be consistent with
7919 -- Bit_Order, so it's best to always define the latter explicitly if
7920 -- the former is used.
7923 Other properties are
7924 as for standard representation attribute @code{Bit_Order}, as defined by
7925 Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
7927 For a record type @var{S}, if @code{@var{S}'Scalar_Storage_Order} is
7928 specified explicitly, it shall be equal to @code{@var{S}'Bit_Order}. Note:
7929 this means that if a @code{Scalar_Storage_Order} attribute definition
7930 clause is not confirming, then the type's @code{Bit_Order} shall be
7931 specified explicitly and set to the same value.
7933 For a record extension, the derived type shall have the same scalar storage
7934 order as the parent type.
7936 If a component of @var{S} has itself a record or array type, then it shall also
7937 have a @code{Scalar_Storage_Order} attribute definition clause. In addition,
7938 if the component does not start on a byte boundary, then the scalar storage
7939 order specified for S and for the nested component type shall be identical.
7941 No component of a type that has a @code{Scalar_Storage_Order} attribute
7942 definition may be aliased.
7944 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
7945 with a value equal to @code{System.Default_Bit_Order}) has no effect.
7947 If the opposite storage order is specified, then whenever the value of
7948 a scalar component of an object of type @var{S} is read, the storage
7949 elements of the enclosing machine scalar are first reversed (before
7950 retrieving the component value, possibly applying some shift and mask
7951 operatings on the enclosing machine scalar), and the opposite operation
7954 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
7955 are relaxed. Instead, the following rules apply:
7958 @item the underlying storage elements are those at positions
7959 @code{(position + first_bit / storage_element_size) ..
7960 (position + (last_bit + storage_element_size - 1) /
7961 storage_element_size)}
7962 @item the sequence of underlying storage elements shall have
7963 a size no greater than the largest machine scalar
7964 @item the enclosing machine scalar is defined as the smallest machine
7965 scalar starting at a position no greater than
7966 @code{position + first_bit / storage_element_size} and covering
7967 storage elements at least up to @code{position + (last_bit +
7968 storage_element_size - 1) / storage_element_size}
7969 @item the position of the component is interpreted relative to that machine
7974 @node Attribute Simple_Storage_Pool
7975 @unnumberedsec Attribute Simple_Storage_Pool
7976 @cindex Storage pool, simple
7977 @cindex Simple storage pool
7978 @findex Simple_Storage_Pool
7980 For every nonformal, nonderived access-to-object type @var{Acc}, the
7981 representation attribute @code{Simple_Storage_Pool} may be specified
7982 via an attribute_definition_clause (or by specifying the equivalent aspect):
7984 @smallexample @c ada
7986 My_Pool : My_Simple_Storage_Pool_Type;
7988 type Acc is access My_Data_Type;
7990 for Acc'Simple_Storage_Pool use My_Pool;
7995 The name given in an attribute_definition_clause for the
7996 @code{Simple_Storage_Pool} attribute shall denote a variable of
7997 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
7999 The use of this attribute is only allowed for a prefix denoting a type
8000 for which it has been specified. The type of the attribute is the type
8001 of the variable specified as the simple storage pool of the access type,
8002 and the attribute denotes that variable.
8004 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
8005 for the same access type.
8007 If the @code{Simple_Storage_Pool} attribute has been specified for an access
8008 type, then applying the @code{Storage_Pool} attribute to the type is flagged
8009 with a warning and its evaluation raises the exception @code{Program_Error}.
8011 If the Simple_Storage_Pool attribute has been specified for an access
8012 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
8013 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
8014 which is intended to indicate the number of storage elements reserved for
8015 the simple storage pool. If the Storage_Size function has not been defined
8016 for the simple storage pool type, then this attribute returns zero.
8018 If an access type @var{S} has a specified simple storage pool of type
8019 @var{SSP}, then the evaluation of an allocator for that access type calls
8020 the primitive @code{Allocate} procedure for type @var{SSP}, passing
8021 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
8022 semantics of such allocators is the same as those defined for allocators
8023 in section 13.11 of the Ada Reference Manual, with the term
8024 ``simple storage pool'' substituted for ``storage pool''.
8026 If an access type @var{S} has a specified simple storage pool of type
8027 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
8028 for that access type invokes the primitive @code{Deallocate} procedure
8029 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
8030 parameter. The detailed semantics of such unchecked deallocations is the same
8031 as defined in section 13.11.2 of the Ada Reference Manual, except that the
8032 term ``simple storage pool'' is substituted for ``storage pool''.
8034 @node Attribute Small
8035 @unnumberedsec Attribute Small
8036 @cindex Ada 83 attributes
8039 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
8041 GNAT also allows this attribute to be applied to floating-point types
8042 for compatibility with Ada 83. See
8043 the Ada 83 reference manual for an exact description of the semantics of
8044 this attribute when applied to floating-point types.
8046 @node Attribute Storage_Unit
8047 @unnumberedsec Attribute Storage_Unit
8048 @findex Storage_Unit
8050 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
8051 prefix) provides the same value as @code{System.Storage_Unit}.
8053 @node Attribute Stub_Type
8054 @unnumberedsec Attribute Stub_Type
8057 The GNAT implementation of remote access-to-classwide types is
8058 organized as described in AARM section E.4 (20.t): a value of an RACW type
8059 (designating a remote object) is represented as a normal access
8060 value, pointing to a "stub" object which in turn contains the
8061 necessary information to contact the designated remote object. A
8062 call on any dispatching operation of such a stub object does the
8063 remote call, if necessary, using the information in the stub object
8064 to locate the target partition, etc.
8066 For a prefix @code{T} that denotes a remote access-to-classwide type,
8067 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
8069 By construction, the layout of @code{T'Stub_Type} is identical to that of
8070 type @code{RACW_Stub_Type} declared in the internal implementation-defined
8071 unit @code{System.Partition_Interface}. Use of this attribute will create
8072 an implicit dependency on this unit.
8074 @node Attribute System_Allocator_Alignment
8075 @unnumberedsec Attribute System_Allocator_Alignment
8076 @cindex Alignment, allocator
8077 @findex System_Allocator_Alignment
8079 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
8080 permissible prefix) provides the observable guaranted to be honored by
8081 the system allocator (malloc). This is a static value that can be used
8082 in user storage pools based on malloc either to reject allocation
8083 with alignment too large or to enable a realignment circuitry if the
8084 alignment request is larger than this value.
8086 @node Attribute Target_Name
8087 @unnumberedsec Attribute Target_Name
8090 @code{Standard'Target_Name} (@code{Standard} is the only permissible
8091 prefix) provides a static string value that identifies the target
8092 for the current compilation. For GCC implementations, this is the
8093 standard gcc target name without the terminating slash (for
8094 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
8096 @node Attribute Tick
8097 @unnumberedsec Attribute Tick
8100 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
8101 provides the same value as @code{System.Tick},
8103 @node Attribute To_Address
8104 @unnumberedsec Attribute To_Address
8107 The @code{System'To_Address}
8108 (@code{System} is the only permissible prefix)
8109 denotes a function identical to
8110 @code{System.Storage_Elements.To_Address} except that
8111 it is a static attribute. This means that if its argument is
8112 a static expression, then the result of the attribute is a
8113 static expression. The result is that such an expression can be
8114 used in contexts (e.g.@: preelaborable packages) which require a
8115 static expression and where the function call could not be used
8116 (since the function call is always non-static, even if its
8117 argument is static).
8119 @node Attribute Type_Class
8120 @unnumberedsec Attribute Type_Class
8123 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
8124 the value of the type class for the full type of @var{type}. If
8125 @var{type} is a generic formal type, the value is the value for the
8126 corresponding actual subtype. The value of this attribute is of type
8127 @code{System.Aux_DEC.Type_Class}, which has the following definition:
8129 @smallexample @c ada
8131 (Type_Class_Enumeration,
8133 Type_Class_Fixed_Point,
8134 Type_Class_Floating_Point,
8139 Type_Class_Address);
8143 Protected types yield the value @code{Type_Class_Task}, which thus
8144 applies to all concurrent types. This attribute is designed to
8145 be compatible with the DEC Ada 83 attribute of the same name.
8147 @node Attribute UET_Address
8148 @unnumberedsec Attribute UET_Address
8151 The @code{UET_Address} attribute can only be used for a prefix which
8152 denotes a library package. It yields the address of the unit exception
8153 table when zero cost exception handling is used. This attribute is
8154 intended only for use within the GNAT implementation. See the unit
8155 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
8156 for details on how this attribute is used in the implementation.
8158 @node Attribute Unconstrained_Array
8159 @unnumberedsec Attribute Unconstrained_Array
8160 @findex Unconstrained_Array
8162 The @code{Unconstrained_Array} attribute can be used with a prefix that
8163 denotes any type or subtype. It is a static attribute that yields
8164 @code{True} if the prefix designates an unconstrained array,
8165 and @code{False} otherwise. In a generic instance, the result is
8166 still static, and yields the result of applying this test to the
8169 @node Attribute Universal_Literal_String
8170 @unnumberedsec Attribute Universal_Literal_String
8171 @cindex Named numbers, representation of
8172 @findex Universal_Literal_String
8174 The prefix of @code{Universal_Literal_String} must be a named
8175 number. The static result is the string consisting of the characters of
8176 the number as defined in the original source. This allows the user
8177 program to access the actual text of named numbers without intermediate
8178 conversions and without the need to enclose the strings in quotes (which
8179 would preclude their use as numbers).
8181 For example, the following program prints the first 50 digits of pi:
8183 @smallexample @c ada
8184 with Text_IO; use Text_IO;
8188 Put (Ada.Numerics.Pi'Universal_Literal_String);
8192 @node Attribute Unrestricted_Access
8193 @unnumberedsec Attribute Unrestricted_Access
8194 @cindex @code{Access}, unrestricted
8195 @findex Unrestricted_Access
8197 The @code{Unrestricted_Access} attribute is similar to @code{Access}
8198 except that all accessibility and aliased view checks are omitted. This
8199 is a user-beware attribute. It is similar to
8200 @code{Address}, for which it is a desirable replacement where the value
8201 desired is an access type. In other words, its effect is identical to
8202 first applying the @code{Address} attribute and then doing an unchecked
8203 conversion to a desired access type. In GNAT, but not necessarily in
8204 other implementations, the use of static chains for inner level
8205 subprograms means that @code{Unrestricted_Access} applied to a
8206 subprogram yields a value that can be called as long as the subprogram
8207 is in scope (normal Ada accessibility rules restrict this usage).
8209 It is possible to use @code{Unrestricted_Access} for any type, but care
8210 must be exercised if it is used to create pointers to unconstrained
8211 objects. In this case, the resulting pointer has the same scope as the
8212 context of the attribute, and may not be returned to some enclosing
8213 scope. For instance, a function cannot use @code{Unrestricted_Access}
8214 to create a unconstrained pointer and then return that value to the
8217 @node Attribute Update
8218 @unnumberedsec Attribute Update
8221 The @code{Update} attribute creates a copy of an array or record value
8222 with one or more modified components. The syntax is:
8224 @smallexample @c ada
8225 PREFIX'Update (AGGREGATE);
8229 where @code{PREFIX} is the name of an array or record object, and
8230 @code{AGGREGATE} is a named aggregate that does not contain an @code{others}
8231 choice. The effect is to yield a copy of the array or record value which
8232 is unchanged apart from the components mentioned in the aggregate, which
8233 are changed to the indicated value. The original value of the array or
8234 record value is not affected. For example:
8236 @smallexample @c ada
8237 type Arr is Array (1 .. 5) of Integer;
8239 Avar1 : Arr := (1,2,3,4,5);
8240 Avar2 : Arr := Avar1'Update ((2 => 10, 3 .. 4 => 20));
8244 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
8245 begin unmodified. Similarly:
8247 @smallexample @c ada
8248 type Rec is A, B, C : Integer;
8250 Rvar1 : Rec := (A => 1, B => 2, C => 3);
8251 Rvar2 : Rec := Rvar1'Update ((B => 20));
8255 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
8256 with @code{Rvar1} being unmodifed.
8257 Note that the value of the attribute reference is computed
8258 completely before it is used. This means that if you write:
8260 @smallexample @c ada
8261 Avar1 := Avar1'Update ((1 => 10, 2 => Function_Call));
8265 then the value of @code{Avar1} is not modified if @code{Function_Call}
8266 raises an exception, unlike the effect of a series of direct assignments
8267 to elements of @code{Avar1}. In general this requires that
8268 two extra complete copies of the object are required, which should be
8269 kept in mind when considering efficiency.
8271 The @code{Update} attribute cannot be applied to prefixes of a limited
8272 type, and cannot reference discriminants in the case of a record type.
8274 In the record case, no component can be mentioned more than once. In
8275 the array case, two overlapping ranges can appear in the aggregate,
8276 in which case the modifications are processed left to right.
8278 Multi-dimensional arrays can be modified, as shown by this example:
8280 @smallexample @c ada
8281 A : array (1 .. 10, 1 .. 10) of Integer;
8283 A := A'Update (1 => (2 => 20), 3 => (4 => 30));
8287 which changes element (1,2) to 20 and (3,4) to 30.
8289 @node Attribute Valid_Scalars
8290 @unnumberedsec Attribute Valid_Scalars
8291 @findex Valid_Scalars
8293 The @code{'Valid_Scalars} attribute is intended to make it easier to
8294 check the validity of scalar subcomponents of composite objects. It
8295 is defined for any prefix @code{X} that denotes an object.
8296 The value of this attribute is of the predefined type Boolean.
8297 @code{X'Valid_Scalars} yields True if and only if evaluation of
8298 @code{P'Valid} yields True for every scalar part P of X or if X has
8299 no scalar parts. It is not specified in what order the scalar parts
8300 are checked, nor whether any more are checked after any one of them
8301 is determined to be invalid. If the prefix @code{X} is of a class-wide
8302 type @code{T'Class} (where @code{T} is the associated specific type),
8303 or if the prefix @code{X} is of a specific tagged type @code{T}, then
8304 only the scalar parts of components of @code{T} are traversed; in other
8305 words, components of extensions of @code{T} are not traversed even if
8306 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
8307 be determined at compile time that the prefix of the attribute has no
8308 scalar parts (e.g., if the prefix is of an access type, an interface type,
8309 an undiscriminated task type, or an undiscriminated protected type).
8311 @node Attribute VADS_Size
8312 @unnumberedsec Attribute VADS_Size
8313 @cindex @code{Size}, VADS compatibility
8316 The @code{'VADS_Size} attribute is intended to make it easier to port
8317 legacy code which relies on the semantics of @code{'Size} as implemented
8318 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
8319 same semantic interpretation. In particular, @code{'VADS_Size} applied
8320 to a predefined or other primitive type with no Size clause yields the
8321 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
8322 typical machines). In addition @code{'VADS_Size} applied to an object
8323 gives the result that would be obtained by applying the attribute to
8324 the corresponding type.
8326 @node Attribute Value_Size
8327 @unnumberedsec Attribute Value_Size
8328 @cindex @code{Size}, setting for not-first subtype
8330 @code{@var{type}'Value_Size} is the number of bits required to represent
8331 a value of the given subtype. It is the same as @code{@var{type}'Size},
8332 but, unlike @code{Size}, may be set for non-first subtypes.
8334 @node Attribute Wchar_T_Size
8335 @unnumberedsec Attribute Wchar_T_Size
8336 @findex Wchar_T_Size
8337 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
8338 prefix) provides the size in bits of the C @code{wchar_t} type
8339 primarily for constructing the definition of this type in
8340 package @code{Interfaces.C}.
8342 @node Attribute Word_Size
8343 @unnumberedsec Attribute Word_Size
8345 @code{Standard'Word_Size} (@code{Standard} is the only permissible
8346 prefix) provides the value @code{System.Word_Size}.
8348 @node Standard and Implementation Defined Restrictions
8349 @chapter Standard and Implementation Defined Restrictions
8352 All RM defined Restriction identifiers are implemented:
8355 @item language-defined restrictions (see 13.12.1)
8356 @item tasking restrictions (see D.7)
8357 @item high integrity restrictions (see H.4)
8361 GNAT implements additional restriction identifiers. All restrictions, whether
8362 language defined or GNAT-specific, are listed in the following.
8365 * Partition-Wide Restrictions::
8366 * Program Unit Level Restrictions::
8369 @node Partition-Wide Restrictions
8370 @section Partition-Wide Restrictions
8372 There are two separate lists of restriction identifiers. The first
8373 set requires consistency throughout a partition (in other words, if the
8374 restriction identifier is used for any compilation unit in the partition,
8375 then all compilation units in the partition must obey the restriction).
8378 * Immediate_Reclamation::
8379 * Max_Asynchronous_Select_Nesting::
8380 * Max_Entry_Queue_Length::
8381 * Max_Protected_Entries::
8382 * Max_Select_Alternatives::
8383 * Max_Storage_At_Blocking::
8384 * Max_Task_Entries::
8386 * No_Abort_Statements::
8387 * No_Access_Parameter_Allocators::
8388 * No_Access_Subprograms::
8390 * No_Anonymous_Allocators::
8393 * No_Default_Initialization::
8396 * No_Direct_Boolean_Operators::
8398 * No_Dispatching_Calls::
8399 * No_Dynamic_Attachment::
8400 * No_Dynamic_Priorities::
8401 * No_Entry_Calls_In_Elaboration_Code::
8402 * No_Enumeration_Maps::
8403 * No_Exception_Handlers::
8404 * No_Exception_Propagation::
8405 * No_Exception_Registration::
8409 * No_Floating_Point::
8410 * No_Implicit_Conditionals::
8411 * No_Implicit_Dynamic_Code::
8412 * No_Implicit_Heap_Allocations::
8413 * No_Implicit_Loops::
8414 * No_Initialize_Scalars::
8416 * No_Local_Allocators::
8417 * No_Local_Protected_Objects::
8418 * No_Local_Timing_Events::
8419 * No_Nested_Finalization::
8420 * No_Protected_Type_Allocators::
8421 * No_Protected_Types::
8424 * No_Relative_Delay::
8425 * No_Requeue_Statements::
8426 * No_Secondary_Stack::
8427 * No_Select_Statements::
8428 * No_Specific_Termination_Handlers::
8429 * No_Specification_of_Aspect::
8430 * No_Standard_Allocators_After_Elaboration::
8431 * No_Standard_Storage_Pools::
8432 * No_Stream_Optimizations::
8434 * No_Task_Allocators::
8435 * No_Task_Attributes_Package::
8436 * No_Task_Hierarchy::
8437 * No_Task_Termination::
8439 * No_Terminate_Alternatives::
8440 * No_Unchecked_Access::
8442 * Static_Priorities::
8443 * Static_Storage_Size::
8446 @node Immediate_Reclamation
8447 @unnumberedsubsec Immediate_Reclamation
8448 @findex Immediate_Reclamation
8449 [RM H.4] This restriction ensures that, except for storage occupied by
8450 objects created by allocators and not deallocated via unchecked
8451 deallocation, any storage reserved at run time for an object is
8452 immediately reclaimed when the object no longer exists.
8454 @node Max_Asynchronous_Select_Nesting
8455 @unnumberedsubsec Max_Asynchronous_Select_Nesting
8456 @findex Max_Asynchronous_Select_Nesting
8457 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
8458 selects. Violations of this restriction with a value of zero are
8459 detected at compile time. Violations of this restriction with values
8460 other than zero cause Storage_Error to be raised.
8462 @node Max_Entry_Queue_Length
8463 @unnumberedsubsec Max_Entry_Queue_Length
8464 @findex Max_Entry_Queue_Length
8465 [RM D.7] This restriction is a declaration that any protected entry compiled in
8466 the scope of the restriction has at most the specified number of
8467 tasks waiting on the entry at any one time, and so no queue is required.
8468 Note that this restriction is checked at run time. Violation of this
8469 restriction results in the raising of Program_Error exception at the point of
8472 @node Max_Protected_Entries
8473 @unnumberedsubsec Max_Protected_Entries
8474 @findex Max_Protected_Entries
8475 [RM D.7] Specifies the maximum number of entries per protected type. The
8476 bounds of every entry family of a protected unit shall be static, or shall be
8477 defined by a discriminant of a subtype whose corresponding bound is static.
8479 @node Max_Select_Alternatives
8480 @unnumberedsubsec Max_Select_Alternatives
8481 @findex Max_Select_Alternatives
8482 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
8484 @node Max_Storage_At_Blocking
8485 @unnumberedsubsec Max_Storage_At_Blocking
8486 @findex Max_Storage_At_Blocking
8487 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
8488 Storage_Size that can be retained by a blocked task. A violation of this
8489 restriction causes Storage_Error to be raised.
8491 @node Max_Task_Entries
8492 @unnumberedsubsec Max_Task_Entries
8493 @findex Max_Task_Entries
8494 [RM D.7] Specifies the maximum number of entries
8495 per task. The bounds of every entry family
8496 of a task unit shall be static, or shall be
8497 defined by a discriminant of a subtype whose
8498 corresponding bound is static.
8501 @unnumberedsubsec Max_Tasks
8503 [RM D.7] Specifies the maximum number of task that may be created, not
8504 counting the creation of the environment task. Violations of this
8505 restriction with a value of zero are detected at compile
8506 time. Violations of this restriction with values other than zero cause
8507 Storage_Error to be raised.
8509 @node No_Abort_Statements
8510 @unnumberedsubsec No_Abort_Statements
8511 @findex No_Abort_Statements
8512 [RM D.7] There are no abort_statements, and there are
8513 no calls to Task_Identification.Abort_Task.
8515 @node No_Access_Parameter_Allocators
8516 @unnumberedsubsec No_Access_Parameter_Allocators
8517 @findex No_Access_Parameter_Allocators
8518 [RM H.4] This restriction ensures at compile time that there are no
8519 occurrences of an allocator as the actual parameter to an access
8522 @node No_Access_Subprograms
8523 @unnumberedsubsec No_Access_Subprograms
8524 @findex No_Access_Subprograms
8525 [RM H.4] This restriction ensures at compile time that there are no
8526 declarations of access-to-subprogram types.
8529 @unnumberedsubsec No_Allocators
8530 @findex No_Allocators
8531 [RM H.4] This restriction ensures at compile time that there are no
8532 occurrences of an allocator.
8534 @node No_Anonymous_Allocators
8535 @unnumberedsubsec No_Anonymous_Allocators
8536 @findex No_Anonymous_Allocators
8537 [RM H.4] This restriction ensures at compile time that there are no
8538 occurrences of an allocator of anonymous access type.
8541 @unnumberedsubsec No_Calendar
8543 [GNAT] This restriction ensures at compile time that there is no implicit or
8544 explicit dependence on the package @code{Ada.Calendar}.
8546 @node No_Coextensions
8547 @unnumberedsubsec No_Coextensions
8548 @findex No_Coextensions
8549 [RM H.4] This restriction ensures at compile time that there are no
8550 coextensions. See 3.10.2.
8552 @node No_Default_Initialization
8553 @unnumberedsubsec No_Default_Initialization
8554 @findex No_Default_Initialization
8556 [GNAT] This restriction prohibits any instance of default initialization
8557 of variables. The binder implements a consistency rule which prevents
8558 any unit compiled without the restriction from with'ing a unit with the
8559 restriction (this allows the generation of initialization procedures to
8560 be skipped, since you can be sure that no call is ever generated to an
8561 initialization procedure in a unit with the restriction active). If used
8562 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
8563 is to prohibit all cases of variables declared without a specific
8564 initializer (including the case of OUT scalar parameters).
8567 @unnumberedsubsec No_Delay
8569 [RM H.4] This restriction ensures at compile time that there are no
8570 delay statements and no dependences on package Calendar.
8573 @unnumberedsubsec No_Dependence
8574 @findex No_Dependence
8575 [RM 13.12.1] This restriction checks at compile time that there are no
8576 dependence on a library unit.
8578 @node No_Direct_Boolean_Operators
8579 @unnumberedsubsec No_Direct_Boolean_Operators
8580 @findex No_Direct_Boolean_Operators
8581 [GNAT] This restriction ensures that no logical (and/or/xor) are used on
8582 operands of type Boolean (or any type derived
8583 from Boolean). This is intended for use in safety critical programs
8584 where the certification protocol requires the use of short-circuit
8585 (and then, or else) forms for all composite boolean operations.
8588 @unnumberedsubsec No_Dispatch
8590 [RM H.4] This restriction ensures at compile time that there are no
8591 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
8593 @node No_Dispatching_Calls
8594 @unnumberedsubsec No_Dispatching_Calls
8595 @findex No_Dispatching_Calls
8596 [GNAT] This restriction ensures at compile time that the code generated by the
8597 compiler involves no dispatching calls. The use of this restriction allows the
8598 safe use of record extensions, classwide membership tests and other classwide
8599 features not involving implicit dispatching. This restriction ensures that
8600 the code contains no indirect calls through a dispatching mechanism. Note that
8601 this includes internally-generated calls created by the compiler, for example
8602 in the implementation of class-wide objects assignments. The
8603 membership test is allowed in the presence of this restriction, because its
8604 implementation requires no dispatching.
8605 This restriction is comparable to the official Ada restriction
8606 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8607 all classwide constructs that do not imply dispatching.
8608 The following example indicates constructs that violate this restriction.
8612 type T is tagged record
8615 procedure P (X : T);
8617 type DT is new T with record
8618 More_Data : Natural;
8620 procedure Q (X : DT);
8624 procedure Example is
8625 procedure Test (O : T'Class) is
8626 N : Natural := O'Size;-- Error: Dispatching call
8627 C : T'Class := O; -- Error: implicit Dispatching Call
8629 if O in DT'Class then -- OK : Membership test
8630 Q (DT (O)); -- OK : Type conversion plus direct call
8632 P (O); -- Error: Dispatching call
8638 P (Obj); -- OK : Direct call
8639 P (T (Obj)); -- OK : Type conversion plus direct call
8640 P (T'Class (Obj)); -- Error: Dispatching call
8642 Test (Obj); -- OK : Type conversion
8644 if Obj in T'Class then -- OK : Membership test
8650 @node No_Dynamic_Attachment
8651 @unnumberedsubsec No_Dynamic_Attachment
8652 @findex No_Dynamic_Attachment
8653 [RM D.7] This restriction ensures that there is no call to any of the
8654 operations defined in package Ada.Interrupts
8655 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
8656 Detach_Handler, and Reference).
8658 @node No_Dynamic_Priorities
8659 @unnumberedsubsec No_Dynamic_Priorities
8660 @findex No_Dynamic_Priorities
8661 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
8663 @node No_Entry_Calls_In_Elaboration_Code
8664 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
8665 @findex No_Entry_Calls_In_Elaboration_Code
8666 [GNAT] This restriction ensures at compile time that no task or protected entry
8667 calls are made during elaboration code. As a result of the use of this
8668 restriction, the compiler can assume that no code past an accept statement
8669 in a task can be executed at elaboration time.
8671 @node No_Enumeration_Maps
8672 @unnumberedsubsec No_Enumeration_Maps
8673 @findex No_Enumeration_Maps
8674 [GNAT] This restriction ensures at compile time that no operations requiring
8675 enumeration maps are used (that is Image and Value attributes applied
8676 to enumeration types).
8678 @node No_Exception_Handlers
8679 @unnumberedsubsec No_Exception_Handlers
8680 @findex No_Exception_Handlers
8681 [GNAT] This restriction ensures at compile time that there are no explicit
8682 exception handlers. It also indicates that no exception propagation will
8683 be provided. In this mode, exceptions may be raised but will result in
8684 an immediate call to the last chance handler, a routine that the user
8685 must define with the following profile:
8687 @smallexample @c ada
8688 procedure Last_Chance_Handler
8689 (Source_Location : System.Address; Line : Integer);
8690 pragma Export (C, Last_Chance_Handler,
8691 "__gnat_last_chance_handler");
8694 The parameter is a C null-terminated string representing a message to be
8695 associated with the exception (typically the source location of the raise
8696 statement generated by the compiler). The Line parameter when nonzero
8697 represents the line number in the source program where the raise occurs.
8699 @node No_Exception_Propagation
8700 @unnumberedsubsec No_Exception_Propagation
8701 @findex No_Exception_Propagation
8702 [GNAT] This restriction guarantees that exceptions are never propagated
8703 to an outer subprogram scope. The only case in which an exception may
8704 be raised is when the handler is statically in the same subprogram, so
8705 that the effect of a raise is essentially like a goto statement. Any
8706 other raise statement (implicit or explicit) will be considered
8707 unhandled. Exception handlers are allowed, but may not contain an
8708 exception occurrence identifier (exception choice). In addition, use of
8709 the package GNAT.Current_Exception is not permitted, and reraise
8710 statements (raise with no operand) are not permitted.
8712 @node No_Exception_Registration
8713 @unnumberedsubsec No_Exception_Registration
8714 @findex No_Exception_Registration
8715 [GNAT] This restriction ensures at compile time that no stream operations for
8716 types Exception_Id or Exception_Occurrence are used. This also makes it
8717 impossible to pass exceptions to or from a partition with this restriction
8718 in a distributed environment. If this exception is active, then the generated
8719 code is simplified by omitting the otherwise-required global registration
8720 of exceptions when they are declared.
8723 @unnumberedsubsec No_Exceptions
8724 @findex No_Exceptions
8725 [RM H.4] This restriction ensures at compile time that there are no
8726 raise statements and no exception handlers.
8728 @node No_Finalization
8729 @unnumberedsubsec No_Finalization
8730 @findex No_Finalization
8731 [GNAT] This restriction disables the language features described in
8732 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
8733 performed by the compiler to support these features. The following types
8734 are no longer considered controlled when this restriction is in effect:
8737 @code{Ada.Finalization.Controlled}
8739 @code{Ada.Finalization.Limited_Controlled}
8741 Derivations from @code{Controlled} or @code{Limited_Controlled}
8749 Array and record types with controlled components
8751 The compiler no longer generates code to initialize, finalize or adjust an
8752 object or a nested component, either declared on the stack or on the heap. The
8753 deallocation of a controlled object no longer finalizes its contents.
8755 @node No_Fixed_Point
8756 @unnumberedsubsec No_Fixed_Point
8757 @findex No_Fixed_Point
8758 [RM H.4] This restriction ensures at compile time that there are no
8759 occurrences of fixed point types and operations.
8761 @node No_Floating_Point
8762 @unnumberedsubsec No_Floating_Point
8763 @findex No_Floating_Point
8764 [RM H.4] This restriction ensures at compile time that there are no
8765 occurrences of floating point types and operations.
8767 @node No_Implicit_Conditionals
8768 @unnumberedsubsec No_Implicit_Conditionals
8769 @findex No_Implicit_Conditionals
8770 [GNAT] This restriction ensures that the generated code does not contain any
8771 implicit conditionals, either by modifying the generated code where possible,
8772 or by rejecting any construct that would otherwise generate an implicit
8773 conditional. Note that this check does not include run time constraint
8774 checks, which on some targets may generate implicit conditionals as
8775 well. To control the latter, constraint checks can be suppressed in the
8776 normal manner. Constructs generating implicit conditionals include comparisons
8777 of composite objects and the Max/Min attributes.
8779 @node No_Implicit_Dynamic_Code
8780 @unnumberedsubsec No_Implicit_Dynamic_Code
8781 @findex No_Implicit_Dynamic_Code
8783 [GNAT] This restriction prevents the compiler from building ``trampolines''.
8784 This is a structure that is built on the stack and contains dynamic
8785 code to be executed at run time. On some targets, a trampoline is
8786 built for the following features: @code{Access},
8787 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8788 nested task bodies; primitive operations of nested tagged types.
8789 Trampolines do not work on machines that prevent execution of stack
8790 data. For example, on windows systems, enabling DEP (data execution
8791 protection) will cause trampolines to raise an exception.
8792 Trampolines are also quite slow at run time.
8794 On many targets, trampolines have been largely eliminated. Look at the
8795 version of system.ads for your target --- if it has
8796 Always_Compatible_Rep equal to False, then trampolines are largely
8797 eliminated. In particular, a trampoline is built for the following
8798 features: @code{Address} of a nested subprogram;
8799 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8800 but only if pragma Favor_Top_Level applies, or the access type has a
8801 foreign-language convention; primitive operations of nested tagged
8804 @node No_Implicit_Heap_Allocations
8805 @unnumberedsubsec No_Implicit_Heap_Allocations
8806 @findex No_Implicit_Heap_Allocations
8807 [RM D.7] No constructs are allowed to cause implicit heap allocation.
8809 @node No_Implicit_Loops
8810 @unnumberedsubsec No_Implicit_Loops
8811 @findex No_Implicit_Loops
8812 [GNAT] This restriction ensures that the generated code does not contain any
8813 implicit @code{for} loops, either by modifying
8814 the generated code where possible,
8815 or by rejecting any construct that would otherwise generate an implicit
8816 @code{for} loop. If this restriction is active, it is possible to build
8817 large array aggregates with all static components without generating an
8818 intermediate temporary, and without generating a loop to initialize individual
8819 components. Otherwise, a loop is created for arrays larger than about 5000
8822 @node No_Initialize_Scalars
8823 @unnumberedsubsec No_Initialize_Scalars
8824 @findex No_Initialize_Scalars
8825 [GNAT] This restriction ensures that no unit in the partition is compiled with
8826 pragma Initialize_Scalars. This allows the generation of more efficient
8827 code, and in particular eliminates dummy null initialization routines that
8828 are otherwise generated for some record and array types.
8831 @unnumberedsubsec No_IO
8833 [RM H.4] This restriction ensures at compile time that there are no
8834 dependences on any of the library units Sequential_IO, Direct_IO,
8835 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
8837 @node No_Local_Allocators
8838 @unnumberedsubsec No_Local_Allocators
8839 @findex No_Local_Allocators
8840 [RM H.4] This restriction ensures at compile time that there are no
8841 occurrences of an allocator in subprograms, generic subprograms, tasks,
8844 @node No_Local_Protected_Objects
8845 @unnumberedsubsec No_Local_Protected_Objects
8846 @findex No_Local_Protected_Objects
8847 [RM D.7] This restriction ensures at compile time that protected objects are
8848 only declared at the library level.
8850 @node No_Local_Timing_Events
8851 @unnumberedsubsec No_Local_Timing_Events
8852 @findex No_Local_Timing_Events
8853 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
8854 declared at the library level.
8856 @node No_Nested_Finalization
8857 @unnumberedsubsec No_Nested_Finalization
8858 @findex No_Nested_Finalization
8859 [RM D.7] All objects requiring finalization are declared at the library level.
8861 @node No_Protected_Type_Allocators
8862 @unnumberedsubsec No_Protected_Type_Allocators
8863 @findex No_Protected_Type_Allocators
8864 [RM D.7] This restriction ensures at compile time that there are no allocator
8865 expressions that attempt to allocate protected objects.
8867 @node No_Protected_Types
8868 @unnumberedsubsec No_Protected_Types
8869 @findex No_Protected_Types
8870 [RM H.4] This restriction ensures at compile time that there are no
8871 declarations of protected types or protected objects.
8874 @unnumberedsubsec No_Recursion
8875 @findex No_Recursion
8876 [RM H.4] A program execution is erroneous if a subprogram is invoked as
8877 part of its execution.
8880 @unnumberedsubsec No_Reentrancy
8881 @findex No_Reentrancy
8882 [RM H.4] A program execution is erroneous if a subprogram is executed by
8883 two tasks at the same time.
8885 @node No_Relative_Delay
8886 @unnumberedsubsec No_Relative_Delay
8887 @findex No_Relative_Delay
8888 [RM D.7] This restriction ensures at compile time that there are no delay
8889 relative statements and prevents expressions such as @code{delay 1.23;} from
8890 appearing in source code.
8892 @node No_Requeue_Statements
8893 @unnumberedsubsec No_Requeue_Statements
8894 @findex No_Requeue_Statements
8895 [RM D.7] This restriction ensures at compile time that no requeue statements
8896 are permitted and prevents keyword @code{requeue} from being used in source
8899 @node No_Secondary_Stack
8900 @unnumberedsubsec No_Secondary_Stack
8901 @findex No_Secondary_Stack
8902 [GNAT] This restriction ensures at compile time that the generated code
8903 does not contain any reference to the secondary stack. The secondary
8904 stack is used to implement functions returning unconstrained objects
8905 (arrays or records) on some targets.
8907 @node No_Select_Statements
8908 @unnumberedsubsec No_Select_Statements
8909 @findex No_Select_Statements
8910 [RM D.7] This restriction ensures at compile time no select statements of any
8911 kind are permitted, that is the keyword @code{select} may not appear.
8913 @node No_Specific_Termination_Handlers
8914 @unnumberedsubsec No_Specific_Termination_Handlers
8915 @findex No_Specific_Termination_Handlers
8916 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
8917 or to Ada.Task_Termination.Specific_Handler.
8919 @node No_Specification_of_Aspect
8920 @unnumberedsubsec No_Specification_of_Aspect
8921 @findex No_Specification_of_Aspect
8922 [RM 13.12.1] This restriction checks at compile time that no aspect
8923 specification, attribute definition clause, or pragma is given for a
8926 @node No_Standard_Allocators_After_Elaboration
8927 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
8928 @findex No_Standard_Allocators_After_Elaboration
8929 [RM D.7] Specifies that an allocator using a standard storage pool
8930 should never be evaluated at run time after the elaboration of the
8931 library items of the partition has completed. Otherwise, Storage_Error
8934 @node No_Standard_Storage_Pools
8935 @unnumberedsubsec No_Standard_Storage_Pools
8936 @findex No_Standard_Storage_Pools
8937 [GNAT] This restriction ensures at compile time that no access types
8938 use the standard default storage pool. Any access type declared must
8939 have an explicit Storage_Pool attribute defined specifying a
8940 user-defined storage pool.
8942 @node No_Stream_Optimizations
8943 @unnumberedsubsec No_Stream_Optimizations
8944 @findex No_Stream_Optimizations
8945 [GNAT] This restriction affects the performance of stream operations on types
8946 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
8947 compiler uses block reads and writes when manipulating @code{String} objects
8948 due to their supperior performance. When this restriction is in effect, the
8949 compiler performs all IO operations on a per-character basis.
8952 @unnumberedsubsec No_Streams
8954 [GNAT] This restriction ensures at compile/bind time that there are no
8955 stream objects created and no use of stream attributes.
8956 This restriction does not forbid dependences on the package
8957 @code{Ada.Streams}. So it is permissible to with
8958 @code{Ada.Streams} (or another package that does so itself)
8959 as long as no actual stream objects are created and no
8960 stream attributes are used.
8962 Note that the use of restriction allows optimization of tagged types,
8963 since they do not need to worry about dispatching stream operations.
8964 To take maximum advantage of this space-saving optimization, any
8965 unit declaring a tagged type should be compiled with the restriction,
8966 though this is not required.
8968 @node No_Task_Allocators
8969 @unnumberedsubsec No_Task_Allocators
8970 @findex No_Task_Allocators
8971 [RM D.7] There are no allocators for task types
8972 or types containing task subcomponents.
8974 @node No_Task_Attributes_Package
8975 @unnumberedsubsec No_Task_Attributes_Package
8976 @findex No_Task_Attributes_Package
8977 [GNAT] This restriction ensures at compile time that there are no implicit or
8978 explicit dependencies on the package @code{Ada.Task_Attributes}.
8980 @node No_Task_Hierarchy
8981 @unnumberedsubsec No_Task_Hierarchy
8982 @findex No_Task_Hierarchy
8983 [RM D.7] All (non-environment) tasks depend
8984 directly on the environment task of the partition.
8986 @node No_Task_Termination
8987 @unnumberedsubsec No_Task_Termination
8988 @findex No_Task_Termination
8989 [RM D.7] Tasks which terminate are erroneous.
8992 @unnumberedsubsec No_Tasking
8994 [GNAT] This restriction prevents the declaration of tasks or task types
8995 throughout the partition. It is similar in effect to the use of
8996 @code{Max_Tasks => 0} except that violations are caught at compile time
8997 and cause an error message to be output either by the compiler or
9000 @node No_Terminate_Alternatives
9001 @unnumberedsubsec No_Terminate_Alternatives
9002 @findex No_Terminate_Alternatives
9003 [RM D.7] There are no selective accepts with terminate alternatives.
9005 @node No_Unchecked_Access
9006 @unnumberedsubsec No_Unchecked_Access
9007 @findex No_Unchecked_Access
9008 [RM H.4] This restriction ensures at compile time that there are no
9009 occurrences of the Unchecked_Access attribute.
9011 @node Simple_Barriers
9012 @unnumberedsubsec Simple_Barriers
9013 @findex Simple_Barriers
9014 [RM D.7] This restriction ensures at compile time that barriers in entry
9015 declarations for protected types are restricted to either static boolean
9016 expressions or references to simple boolean variables defined in the private
9017 part of the protected type. No other form of entry barriers is permitted.
9019 @node Static_Priorities
9020 @unnumberedsubsec Static_Priorities
9021 @findex Static_Priorities
9022 [GNAT] This restriction ensures at compile time that all priority expressions
9023 are static, and that there are no dependences on the package
9024 @code{Ada.Dynamic_Priorities}.
9026 @node Static_Storage_Size
9027 @unnumberedsubsec Static_Storage_Size
9028 @findex Static_Storage_Size
9029 [GNAT] This restriction ensures at compile time that any expression appearing
9030 in a Storage_Size pragma or attribute definition clause is static.
9032 @node Program Unit Level Restrictions
9033 @section Program Unit Level Restrictions
9036 The second set of restriction identifiers
9037 does not require partition-wide consistency.
9038 The restriction may be enforced for a single
9039 compilation unit without any effect on any of the
9040 other compilation units in the partition.
9043 * No_Elaboration_Code::
9045 * No_Implementation_Aspect_Specifications::
9046 * No_Implementation_Attributes::
9047 * No_Implementation_Identifiers::
9048 * No_Implementation_Pragmas::
9049 * No_Implementation_Restrictions::
9050 * No_Implementation_Units::
9051 * No_Implicit_Aliasing::
9052 * No_Obsolescent_Features::
9053 * No_Wide_Characters::
9057 @node No_Elaboration_Code
9058 @unnumberedsubsec No_Elaboration_Code
9059 @findex No_Elaboration_Code
9060 [GNAT] This restriction ensures at compile time that no elaboration code is
9061 generated. Note that this is not the same condition as is enforced
9062 by pragma @code{Preelaborate}. There are cases in which pragma
9063 @code{Preelaborate} still permits code to be generated (e.g.@: code
9064 to initialize a large array to all zeroes), and there are cases of units
9065 which do not meet the requirements for pragma @code{Preelaborate},
9066 but for which no elaboration code is generated. Generally, it is
9067 the case that preelaborable units will meet the restrictions, with
9068 the exception of large aggregates initialized with an others_clause,
9069 and exception declarations (which generate calls to a run-time
9070 registry procedure). This restriction is enforced on
9071 a unit by unit basis, it need not be obeyed consistently
9072 throughout a partition.
9074 In the case of aggregates with others, if the aggregate has a dynamic
9075 size, there is no way to eliminate the elaboration code (such dynamic
9076 bounds would be incompatible with @code{Preelaborate} in any case). If
9077 the bounds are static, then use of this restriction actually modifies
9078 the code choice of the compiler to avoid generating a loop, and instead
9079 generate the aggregate statically if possible, no matter how many times
9080 the data for the others clause must be repeatedly generated.
9082 It is not possible to precisely document
9083 the constructs which are compatible with this restriction, since,
9084 unlike most other restrictions, this is not a restriction on the
9085 source code, but a restriction on the generated object code. For
9086 example, if the source contains a declaration:
9089 Val : constant Integer := X;
9093 where X is not a static constant, it may be possible, depending
9094 on complex optimization circuitry, for the compiler to figure
9095 out the value of X at compile time, in which case this initialization
9096 can be done by the loader, and requires no initialization code. It
9097 is not possible to document the precise conditions under which the
9098 optimizer can figure this out.
9100 Note that this the implementation of this restriction requires full
9101 code generation. If it is used in conjunction with "semantics only"
9102 checking, then some cases of violations may be missed.
9104 @node No_Entry_Queue
9105 @unnumberedsubsec No_Entry_Queue
9106 @findex No_Entry_Queue
9107 [GNAT] This restriction is a declaration that any protected entry compiled in
9108 the scope of the restriction has at most one task waiting on the entry
9109 at any one time, and so no queue is required. This restriction is not
9110 checked at compile time. A program execution is erroneous if an attempt
9111 is made to queue a second task on such an entry.
9113 @node No_Implementation_Aspect_Specifications
9114 @unnumberedsubsec No_Implementation_Aspect_Specifications
9115 @findex No_Implementation_Aspect_Specifications
9116 [RM 13.12.1] This restriction checks at compile time that no
9117 GNAT-defined aspects are present. With this restriction, the only
9118 aspects that can be used are those defined in the Ada Reference Manual.
9120 @node No_Implementation_Attributes
9121 @unnumberedsubsec No_Implementation_Attributes
9122 @findex No_Implementation_Attributes
9123 [RM 13.12.1] This restriction checks at compile time that no
9124 GNAT-defined attributes are present. With this restriction, the only
9125 attributes that can be used are those defined in the Ada Reference
9128 @node No_Implementation_Identifiers
9129 @unnumberedsubsec No_Implementation_Identifiers
9130 @findex No_Implementation_Identifiers
9131 [RM 13.12.1] This restriction checks at compile time that no
9132 implementation-defined identifiers (marked with pragma Implementation_Defined)
9133 occur within language-defined packages.
9135 @node No_Implementation_Pragmas
9136 @unnumberedsubsec No_Implementation_Pragmas
9137 @findex No_Implementation_Pragmas
9138 [RM 13.12.1] This restriction checks at compile time that no
9139 GNAT-defined pragmas are present. With this restriction, the only
9140 pragmas that can be used are those defined in the Ada Reference Manual.
9142 @node No_Implementation_Restrictions
9143 @unnumberedsubsec No_Implementation_Restrictions
9144 @findex No_Implementation_Restrictions
9145 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
9146 identifiers (other than @code{No_Implementation_Restrictions} itself)
9147 are present. With this restriction, the only other restriction identifiers
9148 that can be used are those defined in the Ada Reference Manual.
9150 @node No_Implementation_Units
9151 @unnumberedsubsec No_Implementation_Units
9152 @findex No_Implementation_Units
9153 [RM 13.12.1] This restriction checks at compile time that there is no
9154 mention in the context clause of any implementation-defined descendants
9155 of packages Ada, Interfaces, or System.
9157 @node No_Implicit_Aliasing
9158 @unnumberedsubsec No_Implicit_Aliasing
9159 @findex No_Implicit_Aliasing
9160 [GNAT] This restriction, which is not required to be partition-wide consistent,
9161 requires an explicit aliased keyword for an object to which 'Access,
9162 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
9163 the 'Unrestricted_Access attribute for objects. Note: the reason that
9164 Unrestricted_Access is forbidden is that it would require the prefix
9165 to be aliased, and in such cases, it can always be replaced by
9166 the standard attribute Unchecked_Access which is preferable.
9168 @node No_Obsolescent_Features
9169 @unnumberedsubsec No_Obsolescent_Features
9170 @findex No_Obsolescent_Features
9171 [RM 13.12.1] This restriction checks at compile time that no obsolescent
9172 features are used, as defined in Annex J of the Ada Reference Manual.
9174 @node No_Wide_Characters
9175 @unnumberedsubsec No_Wide_Characters
9176 @findex No_Wide_Characters
9177 [GNAT] This restriction ensures at compile time that no uses of the types
9178 @code{Wide_Character} or @code{Wide_String} or corresponding wide
9180 appear, and that no wide or wide wide string or character literals
9181 appear in the program (that is literals representing characters not in
9182 type @code{Character}).
9185 @unnumberedsubsec SPARK
9187 [GNAT] This restriction checks at compile time that some constructs
9188 forbidden in SPARK are not present. The SPARK version used as a
9189 reference is the same as the Ada mode for the unit, so a unit compiled
9190 in Ada 95 mode with SPARK restrictions will be checked for constructs
9191 forbidden in SPARK 95. Error messages related to SPARK restriction have
9195 violation of restriction "SPARK" at <file>
9199 This is not a replacement for the semantic checks performed by the
9200 SPARK Examiner tool, as the compiler only deals currently with code,
9201 not at all with SPARK annotations and does not guarantee catching all
9202 cases of constructs forbidden by SPARK.
9204 Thus it may well be the case that code which
9205 passes the compiler in SPARK mode is rejected by the SPARK Examiner,
9206 e.g. due to the different visibility rules of the Examiner based on
9207 SPARK @code{inherit} annotations.
9209 This restriction can be useful in providing an initial filter for
9210 code developed using SPARK, or in examining legacy code to see how far
9211 it is from meeting SPARK restrictions.
9213 @c ------------------------
9214 @node Implementation Advice
9215 @chapter Implementation Advice
9217 The main text of the Ada Reference Manual describes the required
9218 behavior of all Ada compilers, and the GNAT compiler conforms to
9221 In addition, there are sections throughout the Ada Reference Manual headed
9222 by the phrase ``Implementation advice''. These sections are not normative,
9223 i.e., they do not specify requirements that all compilers must
9224 follow. Rather they provide advice on generally desirable behavior. You
9225 may wonder why they are not requirements. The most typical answer is
9226 that they describe behavior that seems generally desirable, but cannot
9227 be provided on all systems, or which may be undesirable on some systems.
9229 As far as practical, GNAT follows the implementation advice sections in
9230 the Ada Reference Manual. This chapter contains a table giving the
9231 reference manual section number, paragraph number and several keywords
9232 for each advice. Each entry consists of the text of the advice followed
9233 by the GNAT interpretation of this advice. Most often, this simply says
9234 ``followed'', which means that GNAT follows the advice. However, in a
9235 number of cases, GNAT deliberately deviates from this advice, in which
9236 case the text describes what GNAT does and why.
9238 @cindex Error detection
9239 @unnumberedsec 1.1.3(20): Error Detection
9242 If an implementation detects the use of an unsupported Specialized Needs
9243 Annex feature at run time, it should raise @code{Program_Error} if
9246 Not relevant. All specialized needs annex features are either supported,
9247 or diagnosed at compile time.
9250 @unnumberedsec 1.1.3(31): Child Units
9253 If an implementation wishes to provide implementation-defined
9254 extensions to the functionality of a language-defined library unit, it
9255 should normally do so by adding children to the library unit.
9259 @cindex Bounded errors
9260 @unnumberedsec 1.1.5(12): Bounded Errors
9263 If an implementation detects a bounded error or erroneous
9264 execution, it should raise @code{Program_Error}.
9266 Followed in all cases in which the implementation detects a bounded
9267 error or erroneous execution. Not all such situations are detected at
9271 @unnumberedsec 2.8(16): Pragmas
9274 Normally, implementation-defined pragmas should have no semantic effect
9275 for error-free programs; that is, if the implementation-defined pragmas
9276 are removed from a working program, the program should still be legal,
9277 and should still have the same semantics.
9279 The following implementation defined pragmas are exceptions to this
9291 @item CPP_Constructor
9295 @item Interface_Name
9297 @item Machine_Attribute
9299 @item Unimplemented_Unit
9301 @item Unchecked_Union
9306 In each of the above cases, it is essential to the purpose of the pragma
9307 that this advice not be followed. For details see the separate section
9308 on implementation defined pragmas.
9310 @unnumberedsec 2.8(17-19): Pragmas
9313 Normally, an implementation should not define pragmas that can
9314 make an illegal program legal, except as follows:
9318 A pragma used to complete a declaration, such as a pragma @code{Import};
9322 A pragma used to configure the environment by adding, removing, or
9323 replacing @code{library_items}.
9325 See response to paragraph 16 of this same section.
9327 @cindex Character Sets
9328 @cindex Alternative Character Sets
9329 @unnumberedsec 3.5.2(5): Alternative Character Sets
9332 If an implementation supports a mode with alternative interpretations
9333 for @code{Character} and @code{Wide_Character}, the set of graphic
9334 characters of @code{Character} should nevertheless remain a proper
9335 subset of the set of graphic characters of @code{Wide_Character}. Any
9336 character set ``localizations'' should be reflected in the results of
9337 the subprograms defined in the language-defined package
9338 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
9339 an alternative interpretation of @code{Character}, the implementation should
9340 also support a corresponding change in what is a legal
9341 @code{identifier_letter}.
9343 Not all wide character modes follow this advice, in particular the JIS
9344 and IEC modes reflect standard usage in Japan, and in these encoding,
9345 the upper half of the Latin-1 set is not part of the wide-character
9346 subset, since the most significant bit is used for wide character
9347 encoding. However, this only applies to the external forms. Internally
9348 there is no such restriction.
9350 @cindex Integer types
9351 @unnumberedsec 3.5.4(28): Integer Types
9355 An implementation should support @code{Long_Integer} in addition to
9356 @code{Integer} if the target machine supports 32-bit (or longer)
9357 arithmetic. No other named integer subtypes are recommended for package
9358 @code{Standard}. Instead, appropriate named integer subtypes should be
9359 provided in the library package @code{Interfaces} (see B.2).
9361 @code{Long_Integer} is supported. Other standard integer types are supported
9362 so this advice is not fully followed. These types
9363 are supported for convenient interface to C, and so that all hardware
9364 types of the machine are easily available.
9365 @unnumberedsec 3.5.4(29): Integer Types
9369 An implementation for a two's complement machine should support
9370 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
9371 implementation should support a non-binary modules up to @code{Integer'Last}.
9375 @cindex Enumeration values
9376 @unnumberedsec 3.5.5(8): Enumeration Values
9379 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
9380 subtype, if the value of the operand does not correspond to the internal
9381 code for any enumeration literal of its type (perhaps due to an
9382 un-initialized variable), then the implementation should raise
9383 @code{Program_Error}. This is particularly important for enumeration
9384 types with noncontiguous internal codes specified by an
9385 enumeration_representation_clause.
9390 @unnumberedsec 3.5.7(17): Float Types
9393 An implementation should support @code{Long_Float} in addition to
9394 @code{Float} if the target machine supports 11 or more digits of
9395 precision. No other named floating point subtypes are recommended for
9396 package @code{Standard}. Instead, appropriate named floating point subtypes
9397 should be provided in the library package @code{Interfaces} (see B.2).
9399 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
9400 former provides improved compatibility with other implementations
9401 supporting this type. The latter corresponds to the highest precision
9402 floating-point type supported by the hardware. On most machines, this
9403 will be the same as @code{Long_Float}, but on some machines, it will
9404 correspond to the IEEE extended form. The notable case is all ia32
9405 (x86) implementations, where @code{Long_Long_Float} corresponds to
9406 the 80-bit extended precision format supported in hardware on this
9407 processor. Note that the 128-bit format on SPARC is not supported,
9408 since this is a software rather than a hardware format.
9410 @cindex Multidimensional arrays
9411 @cindex Arrays, multidimensional
9412 @unnumberedsec 3.6.2(11): Multidimensional Arrays
9415 An implementation should normally represent multidimensional arrays in
9416 row-major order, consistent with the notation used for multidimensional
9417 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
9418 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
9419 column-major order should be used instead (see B.5, ``Interfacing with
9424 @findex Duration'Small
9425 @unnumberedsec 9.6(30-31): Duration'Small
9428 Whenever possible in an implementation, the value of @code{Duration'Small}
9429 should be no greater than 100 microseconds.
9431 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
9435 The time base for @code{delay_relative_statements} should be monotonic;
9436 it need not be the same time base as used for @code{Calendar.Clock}.
9440 @unnumberedsec 10.2.1(12): Consistent Representation
9443 In an implementation, a type declared in a pre-elaborated package should
9444 have the same representation in every elaboration of a given version of
9445 the package, whether the elaborations occur in distinct executions of
9446 the same program, or in executions of distinct programs or partitions
9447 that include the given version.
9449 Followed, except in the case of tagged types. Tagged types involve
9450 implicit pointers to a local copy of a dispatch table, and these pointers
9451 have representations which thus depend on a particular elaboration of the
9452 package. It is not easy to see how it would be possible to follow this
9453 advice without severely impacting efficiency of execution.
9455 @cindex Exception information
9456 @unnumberedsec 11.4.1(19): Exception Information
9459 @code{Exception_Message} by default and @code{Exception_Information}
9460 should produce information useful for
9461 debugging. @code{Exception_Message} should be short, about one
9462 line. @code{Exception_Information} can be long. @code{Exception_Message}
9463 should not include the
9464 @code{Exception_Name}. @code{Exception_Information} should include both
9465 the @code{Exception_Name} and the @code{Exception_Message}.
9467 Followed. For each exception that doesn't have a specified
9468 @code{Exception_Message}, the compiler generates one containing the location
9469 of the raise statement. This location has the form ``file:line'', where
9470 file is the short file name (without path information) and line is the line
9471 number in the file. Note that in the case of the Zero Cost Exception
9472 mechanism, these messages become redundant with the Exception_Information that
9473 contains a full backtrace of the calling sequence, so they are disabled.
9474 To disable explicitly the generation of the source location message, use the
9475 Pragma @code{Discard_Names}.
9477 @cindex Suppression of checks
9478 @cindex Checks, suppression of
9479 @unnumberedsec 11.5(28): Suppression of Checks
9482 The implementation should minimize the code executed for checks that
9483 have been suppressed.
9487 @cindex Representation clauses
9488 @unnumberedsec 13.1 (21-24): Representation Clauses
9491 The recommended level of support for all representation items is
9492 qualified as follows:
9496 An implementation need not support representation items containing
9497 non-static expressions, except that an implementation should support a
9498 representation item for a given entity if each non-static expression in
9499 the representation item is a name that statically denotes a constant
9500 declared before the entity.
9502 Followed. In fact, GNAT goes beyond the recommended level of support
9503 by allowing nonstatic expressions in some representation clauses even
9504 without the need to declare constants initialized with the values of
9508 @smallexample @c ada
9511 for Y'Address use X'Address;>>
9516 An implementation need not support a specification for the @code{Size}
9517 for a given composite subtype, nor the size or storage place for an
9518 object (including a component) of a given composite subtype, unless the
9519 constraints on the subtype and its composite subcomponents (if any) are
9520 all static constraints.
9522 Followed. Size Clauses are not permitted on non-static components, as
9527 An aliased component, or a component whose type is by-reference, should
9528 always be allocated at an addressable location.
9532 @cindex Packed types
9533 @unnumberedsec 13.2(6-8): Packed Types
9536 If a type is packed, then the implementation should try to minimize
9537 storage allocated to objects of the type, possibly at the expense of
9538 speed of accessing components, subject to reasonable complexity in
9539 addressing calculations.
9543 The recommended level of support pragma @code{Pack} is:
9545 For a packed record type, the components should be packed as tightly as
9546 possible subject to the Sizes of the component subtypes, and subject to
9547 any @code{record_representation_clause} that applies to the type; the
9548 implementation may, but need not, reorder components or cross aligned
9549 word boundaries to improve the packing. A component whose @code{Size} is
9550 greater than the word size may be allocated an integral number of words.
9552 Followed. Tight packing of arrays is supported for all component sizes
9553 up to 64-bits. If the array component size is 1 (that is to say, if
9554 the component is a boolean type or an enumeration type with two values)
9555 then values of the type are implicitly initialized to zero. This
9556 happens both for objects of the packed type, and for objects that have a
9557 subcomponent of the packed type.
9561 An implementation should support Address clauses for imported
9565 @cindex @code{Address} clauses
9566 @unnumberedsec 13.3(14-19): Address Clauses
9570 For an array @var{X}, @code{@var{X}'Address} should point at the first
9571 component of the array, and not at the array bounds.
9577 The recommended level of support for the @code{Address} attribute is:
9579 @code{@var{X}'Address} should produce a useful result if @var{X} is an
9580 object that is aliased or of a by-reference type, or is an entity whose
9581 @code{Address} has been specified.
9583 Followed. A valid address will be produced even if none of those
9584 conditions have been met. If necessary, the object is forced into
9585 memory to ensure the address is valid.
9589 An implementation should support @code{Address} clauses for imported
9596 Objects (including subcomponents) that are aliased or of a by-reference
9597 type should be allocated on storage element boundaries.
9603 If the @code{Address} of an object is specified, or it is imported or exported,
9604 then the implementation should not perform optimizations based on
9605 assumptions of no aliases.
9609 @cindex @code{Alignment} clauses
9610 @unnumberedsec 13.3(29-35): Alignment Clauses
9613 The recommended level of support for the @code{Alignment} attribute for
9616 An implementation should support specified Alignments that are factors
9617 and multiples of the number of storage elements per word, subject to the
9624 An implementation need not support specified @code{Alignment}s for
9625 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
9626 loaded and stored by available machine instructions.
9632 An implementation need not support specified @code{Alignment}s that are
9633 greater than the maximum @code{Alignment} the implementation ever returns by
9640 The recommended level of support for the @code{Alignment} attribute for
9643 Same as above, for subtypes, but in addition:
9649 For stand-alone library-level objects of statically constrained
9650 subtypes, the implementation should support all @code{Alignment}s
9651 supported by the target linker. For example, page alignment is likely to
9652 be supported for such objects, but not for subtypes.
9656 @cindex @code{Size} clauses
9657 @unnumberedsec 13.3(42-43): Size Clauses
9660 The recommended level of support for the @code{Size} attribute of
9663 A @code{Size} clause should be supported for an object if the specified
9664 @code{Size} is at least as large as its subtype's @code{Size}, and
9665 corresponds to a size in storage elements that is a multiple of the
9666 object's @code{Alignment} (if the @code{Alignment} is nonzero).
9670 @unnumberedsec 13.3(50-56): Size Clauses
9673 If the @code{Size} of a subtype is specified, and allows for efficient
9674 independent addressability (see 9.10) on the target architecture, then
9675 the @code{Size} of the following objects of the subtype should equal the
9676 @code{Size} of the subtype:
9678 Aliased objects (including components).
9684 @code{Size} clause on a composite subtype should not affect the
9685 internal layout of components.
9687 Followed. But note that this can be overridden by use of the implementation
9688 pragma Implicit_Packing in the case of packed arrays.
9692 The recommended level of support for the @code{Size} attribute of subtypes is:
9696 The @code{Size} (if not specified) of a static discrete or fixed point
9697 subtype should be the number of bits needed to represent each value
9698 belonging to the subtype using an unbiased representation, leaving space
9699 for a sign bit only if the subtype contains negative values. If such a
9700 subtype is a first subtype, then an implementation should support a
9701 specified @code{Size} for it that reflects this representation.
9707 For a subtype implemented with levels of indirection, the @code{Size}
9708 should include the size of the pointers, but not the size of what they
9713 @cindex @code{Component_Size} clauses
9714 @unnumberedsec 13.3(71-73): Component Size Clauses
9717 The recommended level of support for the @code{Component_Size}
9722 An implementation need not support specified @code{Component_Sizes} that are
9723 less than the @code{Size} of the component subtype.
9729 An implementation should support specified @code{Component_Size}s that
9730 are factors and multiples of the word size. For such
9731 @code{Component_Size}s, the array should contain no gaps between
9732 components. For other @code{Component_Size}s (if supported), the array
9733 should contain no gaps between components when packing is also
9734 specified; the implementation should forbid this combination in cases
9735 where it cannot support a no-gaps representation.
9739 @cindex Enumeration representation clauses
9740 @cindex Representation clauses, enumeration
9741 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
9744 The recommended level of support for enumeration representation clauses
9747 An implementation need not support enumeration representation clauses
9748 for boolean types, but should at minimum support the internal codes in
9749 the range @code{System.Min_Int.System.Max_Int}.
9753 @cindex Record representation clauses
9754 @cindex Representation clauses, records
9755 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
9758 The recommended level of support for
9759 @*@code{record_representation_clauses} is:
9761 An implementation should support storage places that can be extracted
9762 with a load, mask, shift sequence of machine code, and set with a load,
9763 shift, mask, store sequence, given the available machine instructions
9770 A storage place should be supported if its size is equal to the
9771 @code{Size} of the component subtype, and it starts and ends on a
9772 boundary that obeys the @code{Alignment} of the component subtype.
9778 If the default bit ordering applies to the declaration of a given type,
9779 then for a component whose subtype's @code{Size} is less than the word
9780 size, any storage place that does not cross an aligned word boundary
9781 should be supported.
9787 An implementation may reserve a storage place for the tag field of a
9788 tagged type, and disallow other components from overlapping that place.
9790 Followed. The storage place for the tag field is the beginning of the tagged
9791 record, and its size is Address'Size. GNAT will reject an explicit component
9792 clause for the tag field.
9796 An implementation need not support a @code{component_clause} for a
9797 component of an extension part if the storage place is not after the
9798 storage places of all components of the parent type, whether or not
9799 those storage places had been specified.
9801 Followed. The above advice on record representation clauses is followed,
9802 and all mentioned features are implemented.
9804 @cindex Storage place attributes
9805 @unnumberedsec 13.5.2(5): Storage Place Attributes
9808 If a component is represented using some form of pointer (such as an
9809 offset) to the actual data of the component, and this data is contiguous
9810 with the rest of the object, then the storage place attributes should
9811 reflect the place of the actual data, not the pointer. If a component is
9812 allocated discontinuously from the rest of the object, then a warning
9813 should be generated upon reference to one of its storage place
9816 Followed. There are no such components in GNAT@.
9818 @cindex Bit ordering
9819 @unnumberedsec 13.5.3(7-8): Bit Ordering
9822 The recommended level of support for the non-default bit ordering is:
9826 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
9827 should support the non-default bit ordering in addition to the default
9830 Followed. Word size does not equal storage size in this implementation.
9831 Thus non-default bit ordering is not supported.
9833 @cindex @code{Address}, as private type
9834 @unnumberedsec 13.7(37): Address as Private
9837 @code{Address} should be of a private type.
9841 @cindex Operations, on @code{Address}
9842 @cindex @code{Address}, operations of
9843 @unnumberedsec 13.7.1(16): Address Operations
9846 Operations in @code{System} and its children should reflect the target
9847 environment semantics as closely as is reasonable. For example, on most
9848 machines, it makes sense for address arithmetic to ``wrap around''.
9849 Operations that do not make sense should raise @code{Program_Error}.
9851 Followed. Address arithmetic is modular arithmetic that wraps around. No
9852 operation raises @code{Program_Error}, since all operations make sense.
9854 @cindex Unchecked conversion
9855 @unnumberedsec 13.9(14-17): Unchecked Conversion
9858 The @code{Size} of an array object should not include its bounds; hence,
9859 the bounds should not be part of the converted data.
9865 The implementation should not generate unnecessary run-time checks to
9866 ensure that the representation of @var{S} is a representation of the
9867 target type. It should take advantage of the permission to return by
9868 reference when possible. Restrictions on unchecked conversions should be
9869 avoided unless required by the target environment.
9871 Followed. There are no restrictions on unchecked conversion. A warning is
9872 generated if the source and target types do not have the same size since
9873 the semantics in this case may be target dependent.
9877 The recommended level of support for unchecked conversions is:
9881 Unchecked conversions should be supported and should be reversible in
9882 the cases where this clause defines the result. To enable meaningful use
9883 of unchecked conversion, a contiguous representation should be used for
9884 elementary subtypes, for statically constrained array subtypes whose
9885 component subtype is one of the subtypes described in this paragraph,
9886 and for record subtypes without discriminants whose component subtypes
9887 are described in this paragraph.
9891 @cindex Heap usage, implicit
9892 @unnumberedsec 13.11(23-25): Implicit Heap Usage
9895 An implementation should document any cases in which it dynamically
9896 allocates heap storage for a purpose other than the evaluation of an
9899 Followed, the only other points at which heap storage is dynamically
9900 allocated are as follows:
9904 At initial elaboration time, to allocate dynamically sized global
9908 To allocate space for a task when a task is created.
9911 To extend the secondary stack dynamically when needed. The secondary
9912 stack is used for returning variable length results.
9917 A default (implementation-provided) storage pool for an
9918 access-to-constant type should not have overhead to support deallocation of
9925 A storage pool for an anonymous access type should be created at the
9926 point of an allocator for the type, and be reclaimed when the designated
9927 object becomes inaccessible.
9931 @cindex Unchecked deallocation
9932 @unnumberedsec 13.11.2(17): Unchecked De-allocation
9935 For a standard storage pool, @code{Free} should actually reclaim the
9940 @cindex Stream oriented attributes
9941 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
9944 If a stream element is the same size as a storage element, then the
9945 normal in-memory representation should be used by @code{Read} and
9946 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
9947 should use the smallest number of stream elements needed to represent
9948 all values in the base range of the scalar type.
9951 Followed. By default, GNAT uses the interpretation suggested by AI-195,
9952 which specifies using the size of the first subtype.
9953 However, such an implementation is based on direct binary
9954 representations and is therefore target- and endianness-dependent.
9955 To address this issue, GNAT also supplies an alternate implementation
9956 of the stream attributes @code{Read} and @code{Write},
9957 which uses the target-independent XDR standard representation
9959 @cindex XDR representation
9960 @cindex @code{Read} attribute
9961 @cindex @code{Write} attribute
9962 @cindex Stream oriented attributes
9963 The XDR implementation is provided as an alternative body of the
9964 @code{System.Stream_Attributes} package, in the file
9965 @file{s-stratt-xdr.adb} in the GNAT library.
9966 There is no @file{s-stratt-xdr.ads} file.
9967 In order to install the XDR implementation, do the following:
9969 @item Replace the default implementation of the
9970 @code{System.Stream_Attributes} package with the XDR implementation.
9971 For example on a Unix platform issue the commands:
9973 $ mv s-stratt.adb s-stratt-default.adb
9974 $ mv s-stratt-xdr.adb s-stratt.adb
9978 Rebuild the GNAT run-time library as documented in
9979 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
9982 @unnumberedsec A.1(52): Names of Predefined Numeric Types
9985 If an implementation provides additional named predefined integer types,
9986 then the names should end with @samp{Integer} as in
9987 @samp{Long_Integer}. If an implementation provides additional named
9988 predefined floating point types, then the names should end with
9989 @samp{Float} as in @samp{Long_Float}.
9993 @findex Ada.Characters.Handling
9994 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
9997 If an implementation provides a localized definition of @code{Character}
9998 or @code{Wide_Character}, then the effects of the subprograms in
9999 @code{Characters.Handling} should reflect the localizations. See also
10002 Followed. GNAT provides no such localized definitions.
10004 @cindex Bounded-length strings
10005 @unnumberedsec A.4.4(106): Bounded-Length String Handling
10008 Bounded string objects should not be implemented by implicit pointers
10009 and dynamic allocation.
10011 Followed. No implicit pointers or dynamic allocation are used.
10013 @cindex Random number generation
10014 @unnumberedsec A.5.2(46-47): Random Number Generation
10017 Any storage associated with an object of type @code{Generator} should be
10018 reclaimed on exit from the scope of the object.
10024 If the generator period is sufficiently long in relation to the number
10025 of distinct initiator values, then each possible value of
10026 @code{Initiator} passed to @code{Reset} should initiate a sequence of
10027 random numbers that does not, in a practical sense, overlap the sequence
10028 initiated by any other value. If this is not possible, then the mapping
10029 between initiator values and generator states should be a rapidly
10030 varying function of the initiator value.
10032 Followed. The generator period is sufficiently long for the first
10033 condition here to hold true.
10035 @findex Get_Immediate
10036 @unnumberedsec A.10.7(23): @code{Get_Immediate}
10039 The @code{Get_Immediate} procedures should be implemented with
10040 unbuffered input. For a device such as a keyboard, input should be
10041 @dfn{available} if a key has already been typed, whereas for a disk
10042 file, input should always be available except at end of file. For a file
10043 associated with a keyboard-like device, any line-editing features of the
10044 underlying operating system should be disabled during the execution of
10045 @code{Get_Immediate}.
10047 Followed on all targets except VxWorks. For VxWorks, there is no way to
10048 provide this functionality that does not result in the input buffer being
10049 flushed before the @code{Get_Immediate} call. A special unit
10050 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
10051 this functionality.
10054 @unnumberedsec B.1(39-41): Pragma @code{Export}
10057 If an implementation supports pragma @code{Export} to a given language,
10058 then it should also allow the main subprogram to be written in that
10059 language. It should support some mechanism for invoking the elaboration
10060 of the Ada library units included in the system, and for invoking the
10061 finalization of the environment task. On typical systems, the
10062 recommended mechanism is to provide two subprograms whose link names are
10063 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
10064 elaboration code for library units. @code{adafinal} should contain the
10065 finalization code. These subprograms should have no effect the second
10066 and subsequent time they are called.
10072 Automatic elaboration of pre-elaborated packages should be
10073 provided when pragma @code{Export} is supported.
10075 Followed when the main program is in Ada. If the main program is in a
10076 foreign language, then
10077 @code{adainit} must be called to elaborate pre-elaborated
10082 For each supported convention @var{L} other than @code{Intrinsic}, an
10083 implementation should support @code{Import} and @code{Export} pragmas
10084 for objects of @var{L}-compatible types and for subprograms, and pragma
10085 @code{Convention} for @var{L}-eligible types and for subprograms,
10086 presuming the other language has corresponding features. Pragma
10087 @code{Convention} need not be supported for scalar types.
10091 @cindex Package @code{Interfaces}
10093 @unnumberedsec B.2(12-13): Package @code{Interfaces}
10096 For each implementation-defined convention identifier, there should be a
10097 child package of package Interfaces with the corresponding name. This
10098 package should contain any declarations that would be useful for
10099 interfacing to the language (implementation) represented by the
10100 convention. Any declarations useful for interfacing to any language on
10101 the given hardware architecture should be provided directly in
10104 Followed. An additional package not defined
10105 in the Ada Reference Manual is @code{Interfaces.CPP}, used
10106 for interfacing to C++.
10110 An implementation supporting an interface to C, COBOL, or Fortran should
10111 provide the corresponding package or packages described in the following
10114 Followed. GNAT provides all the packages described in this section.
10116 @cindex C, interfacing with
10117 @unnumberedsec B.3(63-71): Interfacing with C
10120 An implementation should support the following interface correspondences
10121 between Ada and C@.
10127 An Ada procedure corresponds to a void-returning C function.
10133 An Ada function corresponds to a non-void C function.
10139 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
10146 An Ada @code{in} parameter of an access-to-object type with designated
10147 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
10148 where @var{t} is the C type corresponding to the Ada type @var{T}.
10154 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
10155 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
10156 argument to a C function, where @var{t} is the C type corresponding to
10157 the Ada type @var{T}. In the case of an elementary @code{out} or
10158 @code{in out} parameter, a pointer to a temporary copy is used to
10159 preserve by-copy semantics.
10165 An Ada parameter of a record type @var{T}, of any mode, is passed as a
10166 @code{@var{t}*} argument to a C function, where @var{t} is the C
10167 structure corresponding to the Ada type @var{T}.
10169 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
10170 pragma, or Convention, or by explicitly specifying the mechanism for a given
10171 call using an extended import or export pragma.
10175 An Ada parameter of an array type with component type @var{T}, of any
10176 mode, is passed as a @code{@var{t}*} argument to a C function, where
10177 @var{t} is the C type corresponding to the Ada type @var{T}.
10183 An Ada parameter of an access-to-subprogram type is passed as a pointer
10184 to a C function whose prototype corresponds to the designated
10185 subprogram's specification.
10189 @cindex COBOL, interfacing with
10190 @unnumberedsec B.4(95-98): Interfacing with COBOL
10193 An Ada implementation should support the following interface
10194 correspondences between Ada and COBOL@.
10200 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
10201 the COBOL type corresponding to @var{T}.
10207 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
10208 the corresponding COBOL type.
10214 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
10215 COBOL type corresponding to the Ada parameter type; for scalars, a local
10216 copy is used if necessary to ensure by-copy semantics.
10220 @cindex Fortran, interfacing with
10221 @unnumberedsec B.5(22-26): Interfacing with Fortran
10224 An Ada implementation should support the following interface
10225 correspondences between Ada and Fortran:
10231 An Ada procedure corresponds to a Fortran subroutine.
10237 An Ada function corresponds to a Fortran function.
10243 An Ada parameter of an elementary, array, or record type @var{T} is
10244 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
10245 the Fortran type corresponding to the Ada type @var{T}, and where the
10246 INTENT attribute of the corresponding dummy argument matches the Ada
10247 formal parameter mode; the Fortran implementation's parameter passing
10248 conventions are used. For elementary types, a local copy is used if
10249 necessary to ensure by-copy semantics.
10255 An Ada parameter of an access-to-subprogram type is passed as a
10256 reference to a Fortran procedure whose interface corresponds to the
10257 designated subprogram's specification.
10261 @cindex Machine operations
10262 @unnumberedsec C.1(3-5): Access to Machine Operations
10265 The machine code or intrinsic support should allow access to all
10266 operations normally available to assembly language programmers for the
10267 target environment, including privileged instructions, if any.
10273 The interfacing pragmas (see Annex B) should support interface to
10274 assembler; the default assembler should be associated with the
10275 convention identifier @code{Assembler}.
10281 If an entity is exported to assembly language, then the implementation
10282 should allocate it at an addressable location, and should ensure that it
10283 is retained by the linking process, even if not otherwise referenced
10284 from the Ada code. The implementation should assume that any call to a
10285 machine code or assembler subprogram is allowed to read or update every
10286 object that is specified as exported.
10290 @unnumberedsec C.1(10-16): Access to Machine Operations
10293 The implementation should ensure that little or no overhead is
10294 associated with calling intrinsic and machine-code subprograms.
10296 Followed for both intrinsics and machine-code subprograms.
10300 It is recommended that intrinsic subprograms be provided for convenient
10301 access to any machine operations that provide special capabilities or
10302 efficiency and that are not otherwise available through the language
10305 Followed. A full set of machine operation intrinsic subprograms is provided.
10309 Atomic read-modify-write operations---e.g.@:, test and set, compare and
10310 swap, decrement and test, enqueue/dequeue.
10312 Followed on any target supporting such operations.
10316 Standard numeric functions---e.g.@:, sin, log.
10318 Followed on any target supporting such operations.
10322 String manipulation operations---e.g.@:, translate and test.
10324 Followed on any target supporting such operations.
10328 Vector operations---e.g.@:, compare vector against thresholds.
10330 Followed on any target supporting such operations.
10334 Direct operations on I/O ports.
10336 Followed on any target supporting such operations.
10338 @cindex Interrupt support
10339 @unnumberedsec C.3(28): Interrupt Support
10342 If the @code{Ceiling_Locking} policy is not in effect, the
10343 implementation should provide means for the application to specify which
10344 interrupts are to be blocked during protected actions, if the underlying
10345 system allows for a finer-grain control of interrupt blocking.
10347 Followed. The underlying system does not allow for finer-grain control
10348 of interrupt blocking.
10350 @cindex Protected procedure handlers
10351 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
10354 Whenever possible, the implementation should allow interrupt handlers to
10355 be called directly by the hardware.
10357 Followed on any target where the underlying operating system permits
10362 Whenever practical, violations of any
10363 implementation-defined restrictions should be detected before run time.
10365 Followed. Compile time warnings are given when possible.
10367 @cindex Package @code{Interrupts}
10369 @unnumberedsec C.3.2(25): Package @code{Interrupts}
10373 If implementation-defined forms of interrupt handler procedures are
10374 supported, such as protected procedures with parameters, then for each
10375 such form of a handler, a type analogous to @code{Parameterless_Handler}
10376 should be specified in a child package of @code{Interrupts}, with the
10377 same operations as in the predefined package Interrupts.
10381 @cindex Pre-elaboration requirements
10382 @unnumberedsec C.4(14): Pre-elaboration Requirements
10385 It is recommended that pre-elaborated packages be implemented in such a
10386 way that there should be little or no code executed at run time for the
10387 elaboration of entities not already covered by the Implementation
10390 Followed. Executable code is generated in some cases, e.g.@: loops
10391 to initialize large arrays.
10393 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
10396 If the pragma applies to an entity, then the implementation should
10397 reduce the amount of storage used for storing names associated with that
10402 @cindex Package @code{Task_Attributes}
10403 @findex Task_Attributes
10404 @unnumberedsec C.7.2(30): The Package Task_Attributes
10407 Some implementations are targeted to domains in which memory use at run
10408 time must be completely deterministic. For such implementations, it is
10409 recommended that the storage for task attributes will be pre-allocated
10410 statically and not from the heap. This can be accomplished by either
10411 placing restrictions on the number and the size of the task's
10412 attributes, or by using the pre-allocated storage for the first @var{N}
10413 attribute objects, and the heap for the others. In the latter case,
10414 @var{N} should be documented.
10416 Not followed. This implementation is not targeted to such a domain.
10418 @cindex Locking Policies
10419 @unnumberedsec D.3(17): Locking Policies
10423 The implementation should use names that end with @samp{_Locking} for
10424 locking policies defined by the implementation.
10426 Followed. Two implementation-defined locking policies are defined,
10427 whose names (@code{Inheritance_Locking} and
10428 @code{Concurrent_Readers_Locking}) follow this suggestion.
10430 @cindex Entry queuing policies
10431 @unnumberedsec D.4(16): Entry Queuing Policies
10434 Names that end with @samp{_Queuing} should be used
10435 for all implementation-defined queuing policies.
10437 Followed. No such implementation-defined queuing policies exist.
10439 @cindex Preemptive abort
10440 @unnumberedsec D.6(9-10): Preemptive Abort
10443 Even though the @code{abort_statement} is included in the list of
10444 potentially blocking operations (see 9.5.1), it is recommended that this
10445 statement be implemented in a way that never requires the task executing
10446 the @code{abort_statement} to block.
10452 On a multi-processor, the delay associated with aborting a task on
10453 another processor should be bounded; the implementation should use
10454 periodic polling, if necessary, to achieve this.
10458 @cindex Tasking restrictions
10459 @unnumberedsec D.7(21): Tasking Restrictions
10462 When feasible, the implementation should take advantage of the specified
10463 restrictions to produce a more efficient implementation.
10465 GNAT currently takes advantage of these restrictions by providing an optimized
10466 run time when the Ravenscar profile and the GNAT restricted run time set
10467 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
10468 pragma @code{Profile (Restricted)} for more details.
10470 @cindex Time, monotonic
10471 @unnumberedsec D.8(47-49): Monotonic Time
10474 When appropriate, implementations should provide configuration
10475 mechanisms to change the value of @code{Tick}.
10477 Such configuration mechanisms are not appropriate to this implementation
10478 and are thus not supported.
10482 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
10483 be implemented as transformations of the same time base.
10489 It is recommended that the @dfn{best} time base which exists in
10490 the underlying system be available to the application through
10491 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
10495 @cindex Partition communication subsystem
10497 @unnumberedsec E.5(28-29): Partition Communication Subsystem
10500 Whenever possible, the PCS on the called partition should allow for
10501 multiple tasks to call the RPC-receiver with different messages and
10502 should allow them to block until the corresponding subprogram body
10505 Followed by GLADE, a separately supplied PCS that can be used with
10510 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
10511 should raise @code{Storage_Error} if it runs out of space trying to
10512 write the @code{Item} into the stream.
10514 Followed by GLADE, a separately supplied PCS that can be used with
10517 @cindex COBOL support
10518 @unnumberedsec F(7): COBOL Support
10521 If COBOL (respectively, C) is widely supported in the target
10522 environment, implementations supporting the Information Systems Annex
10523 should provide the child package @code{Interfaces.COBOL} (respectively,
10524 @code{Interfaces.C}) specified in Annex B and should support a
10525 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
10526 pragmas (see Annex B), thus allowing Ada programs to interface with
10527 programs written in that language.
10531 @cindex Decimal radix support
10532 @unnumberedsec F.1(2): Decimal Radix Support
10535 Packed decimal should be used as the internal representation for objects
10536 of subtype @var{S} when @var{S}'Machine_Radix = 10.
10538 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
10542 @unnumberedsec G: Numerics
10545 If Fortran (respectively, C) is widely supported in the target
10546 environment, implementations supporting the Numerics Annex
10547 should provide the child package @code{Interfaces.Fortran} (respectively,
10548 @code{Interfaces.C}) specified in Annex B and should support a
10549 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
10550 pragmas (see Annex B), thus allowing Ada programs to interface with
10551 programs written in that language.
10555 @cindex Complex types
10556 @unnumberedsec G.1.1(56-58): Complex Types
10559 Because the usual mathematical meaning of multiplication of a complex
10560 operand and a real operand is that of the scaling of both components of
10561 the former by the latter, an implementation should not perform this
10562 operation by first promoting the real operand to complex type and then
10563 performing a full complex multiplication. In systems that, in the
10564 future, support an Ada binding to IEC 559:1989, the latter technique
10565 will not generate the required result when one of the components of the
10566 complex operand is infinite. (Explicit multiplication of the infinite
10567 component by the zero component obtained during promotion yields a NaN
10568 that propagates into the final result.) Analogous advice applies in the
10569 case of multiplication of a complex operand and a pure-imaginary
10570 operand, and in the case of division of a complex operand by a real or
10571 pure-imaginary operand.
10577 Similarly, because the usual mathematical meaning of addition of a
10578 complex operand and a real operand is that the imaginary operand remains
10579 unchanged, an implementation should not perform this operation by first
10580 promoting the real operand to complex type and then performing a full
10581 complex addition. In implementations in which the @code{Signed_Zeros}
10582 attribute of the component type is @code{True} (and which therefore
10583 conform to IEC 559:1989 in regard to the handling of the sign of zero in
10584 predefined arithmetic operations), the latter technique will not
10585 generate the required result when the imaginary component of the complex
10586 operand is a negatively signed zero. (Explicit addition of the negative
10587 zero to the zero obtained during promotion yields a positive zero.)
10588 Analogous advice applies in the case of addition of a complex operand
10589 and a pure-imaginary operand, and in the case of subtraction of a
10590 complex operand and a real or pure-imaginary operand.
10596 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
10597 attempt to provide a rational treatment of the signs of zero results and
10598 result components. As one example, the result of the @code{Argument}
10599 function should have the sign of the imaginary component of the
10600 parameter @code{X} when the point represented by that parameter lies on
10601 the positive real axis; as another, the sign of the imaginary component
10602 of the @code{Compose_From_Polar} function should be the same as
10603 (respectively, the opposite of) that of the @code{Argument} parameter when that
10604 parameter has a value of zero and the @code{Modulus} parameter has a
10605 nonnegative (respectively, negative) value.
10609 @cindex Complex elementary functions
10610 @unnumberedsec G.1.2(49): Complex Elementary Functions
10613 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
10614 @code{True} should attempt to provide a rational treatment of the signs
10615 of zero results and result components. For example, many of the complex
10616 elementary functions have components that are odd functions of one of
10617 the parameter components; in these cases, the result component should
10618 have the sign of the parameter component at the origin. Other complex
10619 elementary functions have zero components whose sign is opposite that of
10620 a parameter component at the origin, or is always positive or always
10625 @cindex Accuracy requirements
10626 @unnumberedsec G.2.4(19): Accuracy Requirements
10629 The versions of the forward trigonometric functions without a
10630 @code{Cycle} parameter should not be implemented by calling the
10631 corresponding version with a @code{Cycle} parameter of
10632 @code{2.0*Numerics.Pi}, since this will not provide the required
10633 accuracy in some portions of the domain. For the same reason, the
10634 version of @code{Log} without a @code{Base} parameter should not be
10635 implemented by calling the corresponding version with a @code{Base}
10636 parameter of @code{Numerics.e}.
10640 @cindex Complex arithmetic accuracy
10641 @cindex Accuracy, complex arithmetic
10642 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
10646 The version of the @code{Compose_From_Polar} function without a
10647 @code{Cycle} parameter should not be implemented by calling the
10648 corresponding version with a @code{Cycle} parameter of
10649 @code{2.0*Numerics.Pi}, since this will not provide the required
10650 accuracy in some portions of the domain.
10654 @cindex Sequential elaboration policy
10655 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
10659 If the partition elaboration policy is @code{Sequential} and the
10660 Environment task becomes permanently blocked during elaboration then the
10661 partition is deadlocked and it is recommended that the partition be
10662 immediately terminated.
10666 @c -----------------------------------------
10667 @node Implementation Defined Characteristics
10668 @chapter Implementation Defined Characteristics
10671 In addition to the implementation dependent pragmas and attributes, and the
10672 implementation advice, there are a number of other Ada features that are
10673 potentially implementation dependent and are designated as
10674 implementation-defined. These are mentioned throughout the Ada Reference
10675 Manual, and are summarized in Annex M@.
10677 A requirement for conforming Ada compilers is that they provide
10678 documentation describing how the implementation deals with each of these
10679 issues. In this chapter, you will find each point in Annex M listed
10680 followed by a description in italic font of how GNAT
10681 handles the implementation dependence.
10683 You can use this chapter as a guide to minimizing implementation
10684 dependent features in your programs if portability to other compilers
10685 and other operating systems is an important consideration. The numbers
10686 in each section below correspond to the paragraph number in the Ada
10692 @strong{2}. Whether or not each recommendation given in Implementation
10693 Advice is followed. See 1.1.2(37).
10696 @xref{Implementation Advice}.
10701 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
10704 The complexity of programs that can be processed is limited only by the
10705 total amount of available virtual memory, and disk space for the
10706 generated object files.
10711 @strong{4}. Variations from the standard that are impractical to avoid
10712 given the implementation's execution environment. See 1.1.3(6).
10715 There are no variations from the standard.
10720 @strong{5}. Which @code{code_statement}s cause external
10721 interactions. See 1.1.3(10).
10724 Any @code{code_statement} can potentially cause external interactions.
10729 @strong{6}. The coded representation for the text of an Ada
10730 program. See 2.1(4).
10733 See separate section on source representation.
10738 @strong{7}. The control functions allowed in comments. See 2.1(14).
10741 See separate section on source representation.
10746 @strong{8}. The representation for an end of line. See 2.2(2).
10749 See separate section on source representation.
10754 @strong{9}. Maximum supported line length and lexical element
10755 length. See 2.2(15).
10758 The maximum line length is 255 characters and the maximum length of
10759 a lexical element is also 255 characters. This is the default setting
10760 if not overridden by the use of compiler switch @option{-gnaty} (which
10761 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
10762 line length to be specified to be any value up to 32767. The maximum
10763 length of a lexical element is the same as the maximum line length.
10768 @strong{10}. Implementation defined pragmas. See 2.8(14).
10772 @xref{Implementation Defined Pragmas}.
10777 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
10780 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
10781 parameter, checks that the optimization flag is set, and aborts if it is
10787 @strong{12}. The sequence of characters of the value returned by
10788 @code{@var{S}'Image} when some of the graphic characters of
10789 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
10793 The sequence of characters is as defined by the wide character encoding
10794 method used for the source. See section on source representation for
10800 @strong{13}. The predefined integer types declared in
10801 @code{Standard}. See 3.5.4(25).
10805 @item Short_Short_Integer
10807 @item Short_Integer
10808 (Short) 16 bit signed
10812 64 bit signed (on most 64 bit targets, depending on the C definition of long).
10813 32 bit signed (all other targets)
10814 @item Long_Long_Integer
10821 @strong{14}. Any nonstandard integer types and the operators defined
10822 for them. See 3.5.4(26).
10825 There are no nonstandard integer types.
10830 @strong{15}. Any nonstandard real types and the operators defined for
10831 them. See 3.5.6(8).
10834 There are no nonstandard real types.
10839 @strong{16}. What combinations of requested decimal precision and range
10840 are supported for floating point types. See 3.5.7(7).
10843 The precision and range is as defined by the IEEE standard.
10848 @strong{17}. The predefined floating point types declared in
10849 @code{Standard}. See 3.5.7(16).
10856 (Short) 32 bit IEEE short
10859 @item Long_Long_Float
10860 64 bit IEEE long (80 bit IEEE long on x86 processors)
10866 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
10869 @code{Fine_Delta} is 2**(@minus{}63)
10874 @strong{19}. What combinations of small, range, and digits are
10875 supported for fixed point types. See 3.5.9(10).
10878 Any combinations are permitted that do not result in a small less than
10879 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
10880 If the mantissa is larger than 53 bits on machines where Long_Long_Float
10881 is 64 bits (true of all architectures except ia32), then the output from
10882 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
10883 is because floating-point conversions are used to convert fixed point.
10888 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
10889 within an unnamed @code{block_statement}. See 3.9(10).
10892 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
10893 decimal integer are allocated.
10898 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
10901 @xref{Implementation Defined Attributes}.
10906 @strong{22}. Any implementation-defined time types. See 9.6(6).
10909 There are no implementation-defined time types.
10914 @strong{23}. The time base associated with relative delays.
10917 See 9.6(20). The time base used is that provided by the C library
10918 function @code{gettimeofday}.
10923 @strong{24}. The time base of the type @code{Calendar.Time}. See
10927 The time base used is that provided by the C library function
10928 @code{gettimeofday}.
10933 @strong{25}. The time zone used for package @code{Calendar}
10934 operations. See 9.6(24).
10937 The time zone used by package @code{Calendar} is the current system time zone
10938 setting for local time, as accessed by the C library function
10944 @strong{26}. Any limit on @code{delay_until_statements} of
10945 @code{select_statements}. See 9.6(29).
10948 There are no such limits.
10953 @strong{27}. Whether or not two non-overlapping parts of a composite
10954 object are independently addressable, in the case where packing, record
10955 layout, or @code{Component_Size} is specified for the object. See
10959 Separate components are independently addressable if they do not share
10960 overlapping storage units.
10965 @strong{28}. The representation for a compilation. See 10.1(2).
10968 A compilation is represented by a sequence of files presented to the
10969 compiler in a single invocation of the @command{gcc} command.
10974 @strong{29}. Any restrictions on compilations that contain multiple
10975 compilation_units. See 10.1(4).
10978 No single file can contain more than one compilation unit, but any
10979 sequence of files can be presented to the compiler as a single
10985 @strong{30}. The mechanisms for creating an environment and for adding
10986 and replacing compilation units. See 10.1.4(3).
10989 See separate section on compilation model.
10994 @strong{31}. The manner of explicitly assigning library units to a
10995 partition. See 10.2(2).
10998 If a unit contains an Ada main program, then the Ada units for the partition
10999 are determined by recursive application of the rules in the Ada Reference
11000 Manual section 10.2(2-6). In other words, the Ada units will be those that
11001 are needed by the main program, and then this definition of need is applied
11002 recursively to those units, and the partition contains the transitive
11003 closure determined by this relationship. In short, all the necessary units
11004 are included, with no need to explicitly specify the list. If additional
11005 units are required, e.g.@: by foreign language units, then all units must be
11006 mentioned in the context clause of one of the needed Ada units.
11008 If the partition contains no main program, or if the main program is in
11009 a language other than Ada, then GNAT
11010 provides the binder options @option{-z} and @option{-n} respectively, and in
11011 this case a list of units can be explicitly supplied to the binder for
11012 inclusion in the partition (all units needed by these units will also
11013 be included automatically). For full details on the use of these
11014 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
11015 @value{EDITION} User's Guide}.
11020 @strong{32}. The implementation-defined means, if any, of specifying
11021 which compilation units are needed by a given compilation unit. See
11025 The units needed by a given compilation unit are as defined in
11026 the Ada Reference Manual section 10.2(2-6). There are no
11027 implementation-defined pragmas or other implementation-defined
11028 means for specifying needed units.
11033 @strong{33}. The manner of designating the main subprogram of a
11034 partition. See 10.2(7).
11037 The main program is designated by providing the name of the
11038 corresponding @file{ALI} file as the input parameter to the binder.
11043 @strong{34}. The order of elaboration of @code{library_items}. See
11047 The first constraint on ordering is that it meets the requirements of
11048 Chapter 10 of the Ada Reference Manual. This still leaves some
11049 implementation dependent choices, which are resolved by first
11050 elaborating bodies as early as possible (i.e., in preference to specs
11051 where there is a choice), and second by evaluating the immediate with
11052 clauses of a unit to determine the probably best choice, and
11053 third by elaborating in alphabetical order of unit names
11054 where a choice still remains.
11059 @strong{35}. Parameter passing and function return for the main
11060 subprogram. See 10.2(21).
11063 The main program has no parameters. It may be a procedure, or a function
11064 returning an integer type. In the latter case, the returned integer
11065 value is the return code of the program (overriding any value that
11066 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
11071 @strong{36}. The mechanisms for building and running partitions. See
11075 GNAT itself supports programs with only a single partition. The GNATDIST
11076 tool provided with the GLADE package (which also includes an implementation
11077 of the PCS) provides a completely flexible method for building and running
11078 programs consisting of multiple partitions. See the separate GLADE manual
11084 @strong{37}. The details of program execution, including program
11085 termination. See 10.2(25).
11088 See separate section on compilation model.
11093 @strong{38}. The semantics of any non-active partitions supported by the
11094 implementation. See 10.2(28).
11097 Passive partitions are supported on targets where shared memory is
11098 provided by the operating system. See the GLADE reference manual for
11104 @strong{39}. The information returned by @code{Exception_Message}. See
11108 Exception message returns the null string unless a specific message has
11109 been passed by the program.
11114 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
11115 declared within an unnamed @code{block_statement}. See 11.4.1(12).
11118 Blocks have implementation defined names of the form @code{B@var{nnn}}
11119 where @var{nnn} is an integer.
11124 @strong{41}. The information returned by
11125 @code{Exception_Information}. See 11.4.1(13).
11128 @code{Exception_Information} returns a string in the following format:
11131 @emph{Exception_Name:} nnnnn
11132 @emph{Message:} mmmmm
11134 @emph{Call stack traceback locations:}
11135 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
11143 @code{nnnn} is the fully qualified name of the exception in all upper
11144 case letters. This line is always present.
11147 @code{mmmm} is the message (this line present only if message is non-null)
11150 @code{ppp} is the Process Id value as a decimal integer (this line is
11151 present only if the Process Id is nonzero). Currently we are
11152 not making use of this field.
11155 The Call stack traceback locations line and the following values
11156 are present only if at least one traceback location was recorded.
11157 The values are given in C style format, with lower case letters
11158 for a-f, and only as many digits present as are necessary.
11162 The line terminator sequence at the end of each line, including
11163 the last line is a single @code{LF} character (@code{16#0A#}).
11168 @strong{42}. Implementation-defined check names. See 11.5(27).
11171 The implementation defined check name Alignment_Check controls checking of
11172 address clause values for proper alignment (that is, the address supplied
11173 must be consistent with the alignment of the type).
11175 The implementation defined check name Predicate_Check controls whether
11176 predicate checks are generated.
11178 The implementation defined check name Validity_Check controls whether
11179 validity checks are generated.
11181 In addition, a user program can add implementation-defined check names
11182 by means of the pragma Check_Name.
11187 @strong{43}. The interpretation of each aspect of representation. See
11191 See separate section on data representations.
11196 @strong{44}. Any restrictions placed upon representation items. See
11200 See separate section on data representations.
11205 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
11209 Size for an indefinite subtype is the maximum possible size, except that
11210 for the case of a subprogram parameter, the size of the parameter object
11211 is the actual size.
11216 @strong{46}. The default external representation for a type tag. See
11220 The default external representation for a type tag is the fully expanded
11221 name of the type in upper case letters.
11226 @strong{47}. What determines whether a compilation unit is the same in
11227 two different partitions. See 13.3(76).
11230 A compilation unit is the same in two different partitions if and only
11231 if it derives from the same source file.
11236 @strong{48}. Implementation-defined components. See 13.5.1(15).
11239 The only implementation defined component is the tag for a tagged type,
11240 which contains a pointer to the dispatching table.
11245 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
11246 ordering. See 13.5.3(5).
11249 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
11250 implementation, so no non-default bit ordering is supported. The default
11251 bit ordering corresponds to the natural endianness of the target architecture.
11256 @strong{50}. The contents of the visible part of package @code{System}
11257 and its language-defined children. See 13.7(2).
11260 See the definition of these packages in files @file{system.ads} and
11261 @file{s-stoele.ads}.
11266 @strong{51}. The contents of the visible part of package
11267 @code{System.Machine_Code}, and the meaning of
11268 @code{code_statements}. See 13.8(7).
11271 See the definition and documentation in file @file{s-maccod.ads}.
11276 @strong{52}. The effect of unchecked conversion. See 13.9(11).
11279 Unchecked conversion between types of the same size
11280 results in an uninterpreted transmission of the bits from one type
11281 to the other. If the types are of unequal sizes, then in the case of
11282 discrete types, a shorter source is first zero or sign extended as
11283 necessary, and a shorter target is simply truncated on the left.
11284 For all non-discrete types, the source is first copied if necessary
11285 to ensure that the alignment requirements of the target are met, then
11286 a pointer is constructed to the source value, and the result is obtained
11287 by dereferencing this pointer after converting it to be a pointer to the
11288 target type. Unchecked conversions where the target subtype is an
11289 unconstrained array are not permitted. If the target alignment is
11290 greater than the source alignment, then a copy of the result is
11291 made with appropriate alignment
11296 @strong{53}. The semantics of operations on invalid representations.
11300 For assignments and other operations where the use of invalid values cannot
11301 result in erroneous behavior, the compiler ignores the possibility of invalid
11302 values. An exception is raised at the point where an invalid value would
11303 result in erroneous behavior. For example executing:
11305 @smallexample @c ada
11306 procedure invalidvals is
11308 Y : Natural range 1 .. 10;
11309 for Y'Address use X'Address;
11310 Z : Natural range 1 .. 10;
11311 A : array (Natural range 1 .. 10) of Integer;
11313 Z := Y; -- no exception
11314 A (Z) := 3; -- exception raised;
11319 As indicated, an exception is raised on the array assignment, but not
11320 on the simple assignment of the invalid negative value from Y to Z.
11325 @strong{53}. The manner of choosing a storage pool for an access type
11326 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
11329 There are 3 different standard pools used by the compiler when
11330 @code{Storage_Pool} is not specified depending whether the type is local
11331 to a subprogram or defined at the library level and whether
11332 @code{Storage_Size}is specified or not. See documentation in the runtime
11333 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
11334 @code{System.Pool_Local} in files @file{s-poosiz.ads},
11335 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
11336 default pools used.
11341 @strong{54}. Whether or not the implementation provides user-accessible
11342 names for the standard pool type(s). See 13.11(17).
11346 See documentation in the sources of the run time mentioned in paragraph
11347 @strong{53} . All these pools are accessible by means of @code{with}'ing
11353 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
11356 @code{Storage_Size} is measured in storage units, and refers to the
11357 total space available for an access type collection, or to the primary
11358 stack space for a task.
11363 @strong{56}. Implementation-defined aspects of storage pools. See
11367 See documentation in the sources of the run time mentioned in paragraph
11368 @strong{53} for details on GNAT-defined aspects of storage pools.
11373 @strong{57}. The set of restrictions allowed in a pragma
11374 @code{Restrictions}. See 13.12(7).
11377 @xref{Standard and Implementation Defined Restrictions}.
11382 @strong{58}. The consequences of violating limitations on
11383 @code{Restrictions} pragmas. See 13.12(9).
11386 Restrictions that can be checked at compile time result in illegalities
11387 if violated. Currently there are no other consequences of violating
11393 @strong{59}. The representation used by the @code{Read} and
11394 @code{Write} attributes of elementary types in terms of stream
11395 elements. See 13.13.2(9).
11398 The representation is the in-memory representation of the base type of
11399 the type, using the number of bits corresponding to the
11400 @code{@var{type}'Size} value, and the natural ordering of the machine.
11405 @strong{60}. The names and characteristics of the numeric subtypes
11406 declared in the visible part of package @code{Standard}. See A.1(3).
11409 See items describing the integer and floating-point types supported.
11414 @strong{61}. The accuracy actually achieved by the elementary
11415 functions. See A.5.1(1).
11418 The elementary functions correspond to the functions available in the C
11419 library. Only fast math mode is implemented.
11424 @strong{62}. The sign of a zero result from some of the operators or
11425 functions in @code{Numerics.Generic_Elementary_Functions}, when
11426 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
11429 The sign of zeroes follows the requirements of the IEEE 754 standard on
11435 @strong{63}. The value of
11436 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
11439 Maximum image width is 6864, see library file @file{s-rannum.ads}.
11444 @strong{64}. The value of
11445 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
11448 Maximum image width is 6864, see library file @file{s-rannum.ads}.
11453 @strong{65}. The algorithms for random number generation. See
11457 The algorithm is the Mersenne Twister, as documented in the source file
11458 @file{s-rannum.adb}. This version of the algorithm has a period of
11464 @strong{66}. The string representation of a random number generator's
11465 state. See A.5.2(38).
11468 The value returned by the Image function is the concatenation of
11469 the fixed-width decimal representations of the 624 32-bit integers
11470 of the state vector.
11475 @strong{67}. The minimum time interval between calls to the
11476 time-dependent Reset procedure that are guaranteed to initiate different
11477 random number sequences. See A.5.2(45).
11480 The minimum period between reset calls to guarantee distinct series of
11481 random numbers is one microsecond.
11486 @strong{68}. The values of the @code{Model_Mantissa},
11487 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
11488 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
11489 Annex is not supported. See A.5.3(72).
11492 Run the compiler with @option{-gnatS} to produce a listing of package
11493 @code{Standard}, has the values of all numeric attributes.
11498 @strong{69}. Any implementation-defined characteristics of the
11499 input-output packages. See A.7(14).
11502 There are no special implementation defined characteristics for these
11508 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
11512 All type representations are contiguous, and the @code{Buffer_Size} is
11513 the value of @code{@var{type}'Size} rounded up to the next storage unit
11519 @strong{71}. External files for standard input, standard output, and
11520 standard error See A.10(5).
11523 These files are mapped onto the files provided by the C streams
11524 libraries. See source file @file{i-cstrea.ads} for further details.
11529 @strong{72}. The accuracy of the value produced by @code{Put}. See
11533 If more digits are requested in the output than are represented by the
11534 precision of the value, zeroes are output in the corresponding least
11535 significant digit positions.
11540 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
11541 @code{Command_Name}. See A.15(1).
11544 These are mapped onto the @code{argv} and @code{argc} parameters of the
11545 main program in the natural manner.
11550 @strong{74}. The interpretation of the @code{Form} parameter in procedure
11551 @code{Create_Directory}. See A.16(56).
11554 The @code{Form} parameter is not used.
11559 @strong{75}. The interpretation of the @code{Form} parameter in procedure
11560 @code{Create_Path}. See A.16(60).
11563 The @code{Form} parameter is not used.
11568 @strong{76}. The interpretation of the @code{Form} parameter in procedure
11569 @code{Copy_File}. See A.16(68).
11572 The @code{Form} parameter is case-insensitive.
11574 Two fields are recognized in the @code{Form} parameter:
11578 @item preserve=<value>
11585 <value> starts immediately after the character '=' and ends with the
11586 character immediately preceding the next comma (',') or with the last
11587 character of the parameter.
11589 The only possible values for preserve= are:
11593 @item no_attributes
11594 Do not try to preserve any file attributes. This is the default if no
11595 preserve= is found in Form.
11597 @item all_attributes
11598 Try to preserve all file attributes (timestamps, access rights).
11601 Preserve the timestamp of the copied file, but not the other file attributes.
11606 The only possible values for mode= are:
11611 Only do the copy if the destination file does not already exist. If it already
11612 exists, Copy_File fails.
11615 Copy the file in all cases. Overwrite an already existing destination file.
11618 Append the original file to the destination file. If the destination file does
11619 not exist, the destination file is a copy of the source file. When mode=append,
11620 the field preserve=, if it exists, is not taken into account.
11625 If the Form parameter includes one or both of the fields and the value or
11626 values are incorrect, Copy_file fails with Use_Error.
11628 Examples of correct Forms:
11631 Form => "preserve=no_attributes,mode=overwrite" (the default)
11632 Form => "mode=append"
11633 Form => "mode=copy, preserve=all_attributes"
11637 Examples of incorrect Forms
11640 Form => "preserve=junk"
11641 Form => "mode=internal, preserve=timestamps"
11647 @strong{77}. Implementation-defined convention names. See B.1(11).
11650 The following convention names are supported
11655 @item Ada_Pass_By_Copy
11656 Allowed for any types except by-reference types such as limited
11657 records. Compatible with convention Ada, but causes any parameters
11658 with this convention to be passed by copy.
11659 @item Ada_Pass_By_Reference
11660 Allowed for any types except by-copy types such as scalars.
11661 Compatible with convention Ada, but causes any parameters
11662 with this convention to be passed by reference.
11666 Synonym for Assembler
11668 Synonym for Assembler
11671 @item C_Pass_By_Copy
11672 Allowed only for record types, like C, but also notes that record
11673 is to be passed by copy rather than reference.
11676 @item C_Plus_Plus (or CPP)
11679 Treated the same as C
11681 Treated the same as C
11685 For support of pragma @code{Import} with convention Intrinsic, see
11686 separate section on Intrinsic Subprograms.
11688 Stdcall (used for Windows implementations only). This convention correspond
11689 to the WINAPI (previously called Pascal convention) C/C++ convention under
11690 Windows. A routine with this convention cleans the stack before
11691 exit. This pragma cannot be applied to a dispatching call.
11693 Synonym for Stdcall
11695 Synonym for Stdcall
11697 Stubbed is a special convention used to indicate that the body of the
11698 subprogram will be entirely ignored. Any call to the subprogram
11699 is converted into a raise of the @code{Program_Error} exception. If a
11700 pragma @code{Import} specifies convention @code{stubbed} then no body need
11701 be present at all. This convention is useful during development for the
11702 inclusion of subprograms whose body has not yet been written.
11706 In addition, all otherwise unrecognized convention names are also
11707 treated as being synonymous with convention C@. In all implementations
11708 except for VMS, use of such other names results in a warning. In VMS
11709 implementations, these names are accepted silently.
11714 @strong{78}. The meaning of link names. See B.1(36).
11717 Link names are the actual names used by the linker.
11722 @strong{79}. The manner of choosing link names when neither the link
11723 name nor the address of an imported or exported entity is specified. See
11727 The default linker name is that which would be assigned by the relevant
11728 external language, interpreting the Ada name as being in all lower case
11734 @strong{80}. The effect of pragma @code{Linker_Options}. See B.1(37).
11737 The string passed to @code{Linker_Options} is presented uninterpreted as
11738 an argument to the link command, unless it contains ASCII.NUL characters.
11739 NUL characters if they appear act as argument separators, so for example
11741 @smallexample @c ada
11742 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
11746 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
11747 linker. The order of linker options is preserved for a given unit. The final
11748 list of options passed to the linker is in reverse order of the elaboration
11749 order. For example, linker options for a body always appear before the options
11750 from the corresponding package spec.
11755 @strong{81}. The contents of the visible part of package
11756 @code{Interfaces} and its language-defined descendants. See B.2(1).
11759 See files with prefix @file{i-} in the distributed library.
11764 @strong{82}. Implementation-defined children of package
11765 @code{Interfaces}. The contents of the visible part of package
11766 @code{Interfaces}. See B.2(11).
11769 See files with prefix @file{i-} in the distributed library.
11774 @strong{83}. The types @code{Floating}, @code{Long_Floating},
11775 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
11776 @code{COBOL_Character}; and the initialization of the variables
11777 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
11778 @code{Interfaces.COBOL}. See B.4(50).
11784 @item Long_Floating
11785 (Floating) Long_Float
11790 @item Decimal_Element
11792 @item COBOL_Character
11797 For initialization, see the file @file{i-cobol.ads} in the distributed library.
11802 @strong{84}. Support for access to machine instructions. See C.1(1).
11805 See documentation in file @file{s-maccod.ads} in the distributed library.
11810 @strong{85}. Implementation-defined aspects of access to machine
11811 operations. See C.1(9).
11814 See documentation in file @file{s-maccod.ads} in the distributed library.
11819 @strong{86}. Implementation-defined aspects of interrupts. See C.3(2).
11822 Interrupts are mapped to signals or conditions as appropriate. See
11824 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
11825 on the interrupts supported on a particular target.
11830 @strong{87}. Implementation-defined aspects of pre-elaboration. See
11834 GNAT does not permit a partition to be restarted without reloading,
11835 except under control of the debugger.
11840 @strong{88}. The semantics of pragma @code{Discard_Names}. See C.5(7).
11843 Pragma @code{Discard_Names} causes names of enumeration literals to
11844 be suppressed. In the presence of this pragma, the Image attribute
11845 provides the image of the Pos of the literal, and Value accepts
11851 @strong{89}. The result of the @code{Task_Identification.Image}
11852 attribute. See C.7.1(7).
11855 The result of this attribute is a string that identifies
11856 the object or component that denotes a given task. If a variable @code{Var}
11857 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
11859 is the hexadecimal representation of the virtual address of the corresponding
11860 task control block. If the variable is an array of tasks, the image of each
11861 task will have the form of an indexed component indicating the position of a
11862 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
11863 component of a record, the image of the task will have the form of a selected
11864 component. These rules are fully recursive, so that the image of a task that
11865 is a subcomponent of a composite object corresponds to the expression that
11866 designates this task.
11868 If a task is created by an allocator, its image depends on the context. If the
11869 allocator is part of an object declaration, the rules described above are used
11870 to construct its image, and this image is not affected by subsequent
11871 assignments. If the allocator appears within an expression, the image
11872 includes only the name of the task type.
11874 If the configuration pragma Discard_Names is present, or if the restriction
11875 No_Implicit_Heap_Allocation is in effect, the image reduces to
11876 the numeric suffix, that is to say the hexadecimal representation of the
11877 virtual address of the control block of the task.
11881 @strong{90}. The value of @code{Current_Task} when in a protected entry
11882 or interrupt handler. See C.7.1(17).
11885 Protected entries or interrupt handlers can be executed by any
11886 convenient thread, so the value of @code{Current_Task} is undefined.
11891 @strong{91}. The effect of calling @code{Current_Task} from an entry
11892 body or interrupt handler. See C.7.1(19).
11895 The effect of calling @code{Current_Task} from an entry body or
11896 interrupt handler is to return the identification of the task currently
11897 executing the code.
11902 @strong{92}. Implementation-defined aspects of
11903 @code{Task_Attributes}. See C.7.2(19).
11906 There are no implementation-defined aspects of @code{Task_Attributes}.
11911 @strong{93}. Values of all @code{Metrics}. See D(2).
11914 The metrics information for GNAT depends on the performance of the
11915 underlying operating system. The sources of the run-time for tasking
11916 implementation, together with the output from @option{-gnatG} can be
11917 used to determine the exact sequence of operating systems calls made
11918 to implement various tasking constructs. Together with appropriate
11919 information on the performance of the underlying operating system,
11920 on the exact target in use, this information can be used to determine
11921 the required metrics.
11926 @strong{94}. The declarations of @code{Any_Priority} and
11927 @code{Priority}. See D.1(11).
11930 See declarations in file @file{system.ads}.
11935 @strong{95}. Implementation-defined execution resources. See D.1(15).
11938 There are no implementation-defined execution resources.
11943 @strong{96}. Whether, on a multiprocessor, a task that is waiting for
11944 access to a protected object keeps its processor busy. See D.2.1(3).
11947 On a multi-processor, a task that is waiting for access to a protected
11948 object does not keep its processor busy.
11953 @strong{97}. The affect of implementation defined execution resources
11954 on task dispatching. See D.2.1(9).
11957 Tasks map to threads in the threads package used by GNAT@. Where possible
11958 and appropriate, these threads correspond to native threads of the
11959 underlying operating system.
11964 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
11965 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
11968 There are no implementation-defined policy-identifiers allowed in this
11974 @strong{99}. Implementation-defined aspects of priority inversion. See
11978 Execution of a task cannot be preempted by the implementation processing
11979 of delay expirations for lower priority tasks.
11984 @strong{100}. Implementation-defined task dispatching. See D.2.2(18).
11987 The policy is the same as that of the underlying threads implementation.
11992 @strong{101}. Implementation-defined @code{policy_identifiers} allowed
11993 in a pragma @code{Locking_Policy}. See D.3(4).
11996 The two implementation defined policies permitted in GNAT are
11997 @code{Inheritance_Locking} and @code{Conccurent_Readers_Locking}. On
11998 targets that support the @code{Inheritance_Locking} policy, locking is
11999 implemented by inheritance, i.e.@: the task owning the lock operates
12000 at a priority equal to the highest priority of any task currently
12001 requesting the lock. On targets that support the
12002 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
12003 read/write lock allowing multiple propected object functions to enter
12009 @strong{102}. Default ceiling priorities. See D.3(10).
12012 The ceiling priority of protected objects of the type
12013 @code{System.Interrupt_Priority'Last} as described in the Ada
12014 Reference Manual D.3(10),
12019 @strong{103}. The ceiling of any protected object used internally by
12020 the implementation. See D.3(16).
12023 The ceiling priority of internal protected objects is
12024 @code{System.Priority'Last}.
12029 @strong{104}. Implementation-defined queuing policies. See D.4(1).
12032 There are no implementation-defined queuing policies.
12037 @strong{105}. On a multiprocessor, any conditions that cause the
12038 completion of an aborted construct to be delayed later than what is
12039 specified for a single processor. See D.6(3).
12042 The semantics for abort on a multi-processor is the same as on a single
12043 processor, there are no further delays.
12048 @strong{106}. Any operations that implicitly require heap storage
12049 allocation. See D.7(8).
12052 The only operation that implicitly requires heap storage allocation is
12058 @strong{107}. Implementation-defined aspects of pragma
12059 @code{Restrictions}. See D.7(20).
12062 There are no such implementation-defined aspects.
12067 @strong{108}. Implementation-defined aspects of package
12068 @code{Real_Time}. See D.8(17).
12071 There are no implementation defined aspects of package @code{Real_Time}.
12076 @strong{109}. Implementation-defined aspects of
12077 @code{delay_statements}. See D.9(8).
12080 Any difference greater than one microsecond will cause the task to be
12081 delayed (see D.9(7)).
12086 @strong{110}. The upper bound on the duration of interrupt blocking
12087 caused by the implementation. See D.12(5).
12090 The upper bound is determined by the underlying operating system. In
12091 no cases is it more than 10 milliseconds.
12096 @strong{111}. The means for creating and executing distributed
12097 programs. See E(5).
12100 The GLADE package provides a utility GNATDIST for creating and executing
12101 distributed programs. See the GLADE reference manual for further details.
12106 @strong{112}. Any events that can result in a partition becoming
12107 inaccessible. See E.1(7).
12110 See the GLADE reference manual for full details on such events.
12115 @strong{113}. The scheduling policies, treatment of priorities, and
12116 management of shared resources between partitions in certain cases. See
12120 See the GLADE reference manual for full details on these aspects of
12121 multi-partition execution.
12126 @strong{114}. Events that cause the version of a compilation unit to
12127 change. See E.3(5).
12130 Editing the source file of a compilation unit, or the source files of
12131 any units on which it is dependent in a significant way cause the version
12132 to change. No other actions cause the version number to change. All changes
12133 are significant except those which affect only layout, capitalization or
12139 @strong{115}. Whether the execution of the remote subprogram is
12140 immediately aborted as a result of cancellation. See E.4(13).
12143 See the GLADE reference manual for details on the effect of abort in
12144 a distributed application.
12149 @strong{116}. Implementation-defined aspects of the PCS@. See E.5(25).
12152 See the GLADE reference manual for a full description of all implementation
12153 defined aspects of the PCS@.
12158 @strong{117}. Implementation-defined interfaces in the PCS@. See
12162 See the GLADE reference manual for a full description of all
12163 implementation defined interfaces.
12168 @strong{118}. The values of named numbers in the package
12169 @code{Decimal}. See F.2(7).
12181 @item Max_Decimal_Digits
12188 @strong{119}. The value of @code{Max_Picture_Length} in the package
12189 @code{Text_IO.Editing}. See F.3.3(16).
12197 @strong{120}. The value of @code{Max_Picture_Length} in the package
12198 @code{Wide_Text_IO.Editing}. See F.3.4(5).
12206 @strong{121}. The accuracy actually achieved by the complex elementary
12207 functions and by other complex arithmetic operations. See G.1(1).
12210 Standard library functions are used for the complex arithmetic
12211 operations. Only fast math mode is currently supported.
12216 @strong{122}. The sign of a zero result (or a component thereof) from
12217 any operator or function in @code{Numerics.Generic_Complex_Types}, when
12218 @code{Real'Signed_Zeros} is True. See G.1.1(53).
12221 The signs of zero values are as recommended by the relevant
12222 implementation advice.
12227 @strong{123}. The sign of a zero result (or a component thereof) from
12228 any operator or function in
12229 @code{Numerics.Generic_Complex_Elementary_Functions}, when
12230 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
12233 The signs of zero values are as recommended by the relevant
12234 implementation advice.
12239 @strong{124}. Whether the strict mode or the relaxed mode is the
12240 default. See G.2(2).
12243 The strict mode is the default. There is no separate relaxed mode. GNAT
12244 provides a highly efficient implementation of strict mode.
12249 @strong{125}. The result interval in certain cases of fixed-to-float
12250 conversion. See G.2.1(10).
12253 For cases where the result interval is implementation dependent, the
12254 accuracy is that provided by performing all operations in 64-bit IEEE
12255 floating-point format.
12260 @strong{126}. The result of a floating point arithmetic operation in
12261 overflow situations, when the @code{Machine_Overflows} attribute of the
12262 result type is @code{False}. See G.2.1(13).
12265 Infinite and NaN values are produced as dictated by the IEEE
12266 floating-point standard.
12268 Note that on machines that are not fully compliant with the IEEE
12269 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
12270 must be used for achieving IEEE conforming behavior (although at the cost
12271 of a significant performance penalty), so infinite and NaN values are
12272 properly generated.
12277 @strong{127}. The result interval for division (or exponentiation by a
12278 negative exponent), when the floating point hardware implements division
12279 as multiplication by a reciprocal. See G.2.1(16).
12282 Not relevant, division is IEEE exact.
12287 @strong{128}. The definition of close result set, which determines the
12288 accuracy of certain fixed point multiplications and divisions. See
12292 Operations in the close result set are performed using IEEE long format
12293 floating-point arithmetic. The input operands are converted to
12294 floating-point, the operation is done in floating-point, and the result
12295 is converted to the target type.
12300 @strong{129}. Conditions on a @code{universal_real} operand of a fixed
12301 point multiplication or division for which the result shall be in the
12302 perfect result set. See G.2.3(22).
12305 The result is only defined to be in the perfect result set if the result
12306 can be computed by a single scaling operation involving a scale factor
12307 representable in 64-bits.
12312 @strong{130}. The result of a fixed point arithmetic operation in
12313 overflow situations, when the @code{Machine_Overflows} attribute of the
12314 result type is @code{False}. See G.2.3(27).
12317 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
12323 @strong{131}. The result of an elementary function reference in
12324 overflow situations, when the @code{Machine_Overflows} attribute of the
12325 result type is @code{False}. See G.2.4(4).
12328 IEEE infinite and Nan values are produced as appropriate.
12333 @strong{132}. The value of the angle threshold, within which certain
12334 elementary functions, complex arithmetic operations, and complex
12335 elementary functions yield results conforming to a maximum relative
12336 error bound. See G.2.4(10).
12339 Information on this subject is not yet available.
12344 @strong{133}. The accuracy of certain elementary functions for
12345 parameters beyond the angle threshold. See G.2.4(10).
12348 Information on this subject is not yet available.
12353 @strong{134}. The result of a complex arithmetic operation or complex
12354 elementary function reference in overflow situations, when the
12355 @code{Machine_Overflows} attribute of the corresponding real type is
12356 @code{False}. See G.2.6(5).
12359 IEEE infinite and Nan values are produced as appropriate.
12364 @strong{135}. The accuracy of certain complex arithmetic operations and
12365 certain complex elementary functions for parameters (or components
12366 thereof) beyond the angle threshold. See G.2.6(8).
12369 Information on those subjects is not yet available.
12374 @strong{136}. Information regarding bounded errors and erroneous
12375 execution. See H.2(1).
12378 Information on this subject is not yet available.
12383 @strong{137}. Implementation-defined aspects of pragma
12384 @code{Inspection_Point}. See H.3.2(8).
12387 Pragma @code{Inspection_Point} ensures that the variable is live and can
12388 be examined by the debugger at the inspection point.
12393 @strong{138}. Implementation-defined aspects of pragma
12394 @code{Restrictions}. See H.4(25).
12397 There are no implementation-defined aspects of pragma @code{Restrictions}. The
12398 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
12399 generated code. Checks must suppressed by use of pragma @code{Suppress}.
12404 @strong{139}. Any restrictions on pragma @code{Restrictions}. See
12408 There are no restrictions on pragma @code{Restrictions}.
12410 @node Intrinsic Subprograms
12411 @chapter Intrinsic Subprograms
12412 @cindex Intrinsic Subprograms
12415 * Intrinsic Operators::
12416 * Enclosing_Entity::
12417 * Exception_Information::
12418 * Exception_Message::
12422 * Shifts and Rotates::
12423 * Source_Location::
12427 GNAT allows a user application program to write the declaration:
12429 @smallexample @c ada
12430 pragma Import (Intrinsic, name);
12434 providing that the name corresponds to one of the implemented intrinsic
12435 subprograms in GNAT, and that the parameter profile of the referenced
12436 subprogram meets the requirements. This chapter describes the set of
12437 implemented intrinsic subprograms, and the requirements on parameter profiles.
12438 Note that no body is supplied; as with other uses of pragma Import, the
12439 body is supplied elsewhere (in this case by the compiler itself). Note
12440 that any use of this feature is potentially non-portable, since the
12441 Ada standard does not require Ada compilers to implement this feature.
12443 @node Intrinsic Operators
12444 @section Intrinsic Operators
12445 @cindex Intrinsic operator
12448 All the predefined numeric operators in package Standard
12449 in @code{pragma Import (Intrinsic,..)}
12450 declarations. In the binary operator case, the operands must have the same
12451 size. The operand or operands must also be appropriate for
12452 the operator. For example, for addition, the operands must
12453 both be floating-point or both be fixed-point, and the
12454 right operand for @code{"**"} must have a root type of
12455 @code{Standard.Integer'Base}.
12456 You can use an intrinsic operator declaration as in the following example:
12458 @smallexample @c ada
12459 type Int1 is new Integer;
12460 type Int2 is new Integer;
12462 function "+" (X1 : Int1; X2 : Int2) return Int1;
12463 function "+" (X1 : Int1; X2 : Int2) return Int2;
12464 pragma Import (Intrinsic, "+");
12468 This declaration would permit ``mixed mode'' arithmetic on items
12469 of the differing types @code{Int1} and @code{Int2}.
12470 It is also possible to specify such operators for private types, if the
12471 full views are appropriate arithmetic types.
12473 @node Enclosing_Entity
12474 @section Enclosing_Entity
12475 @cindex Enclosing_Entity
12477 This intrinsic subprogram is used in the implementation of the
12478 library routine @code{GNAT.Source_Info}. The only useful use of the
12479 intrinsic import in this case is the one in this unit, so an
12480 application program should simply call the function
12481 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
12482 the current subprogram, package, task, entry, or protected subprogram.
12484 @node Exception_Information
12485 @section Exception_Information
12486 @cindex Exception_Information'
12488 This intrinsic subprogram is used in the implementation of the
12489 library routine @code{GNAT.Current_Exception}. The only useful
12490 use of the intrinsic import in this case is the one in this unit,
12491 so an application program should simply call the function
12492 @code{GNAT.Current_Exception.Exception_Information} to obtain
12493 the exception information associated with the current exception.
12495 @node Exception_Message
12496 @section Exception_Message
12497 @cindex Exception_Message
12499 This intrinsic subprogram is used in the implementation of the
12500 library routine @code{GNAT.Current_Exception}. The only useful
12501 use of the intrinsic import in this case is the one in this unit,
12502 so an application program should simply call the function
12503 @code{GNAT.Current_Exception.Exception_Message} to obtain
12504 the message associated with the current exception.
12506 @node Exception_Name
12507 @section Exception_Name
12508 @cindex Exception_Name
12510 This intrinsic subprogram is used in the implementation of the
12511 library routine @code{GNAT.Current_Exception}. The only useful
12512 use of the intrinsic import in this case is the one in this unit,
12513 so an application program should simply call the function
12514 @code{GNAT.Current_Exception.Exception_Name} to obtain
12515 the name of the current exception.
12521 This intrinsic subprogram is used in the implementation of the
12522 library routine @code{GNAT.Source_Info}. The only useful use of the
12523 intrinsic import in this case is the one in this unit, so an
12524 application program should simply call the function
12525 @code{GNAT.Source_Info.File} to obtain the name of the current
12532 This intrinsic subprogram is used in the implementation of the
12533 library routine @code{GNAT.Source_Info}. The only useful use of the
12534 intrinsic import in this case is the one in this unit, so an
12535 application program should simply call the function
12536 @code{GNAT.Source_Info.Line} to obtain the number of the current
12539 @node Shifts and Rotates
12540 @section Shifts and Rotates
12542 @cindex Shift_Right
12543 @cindex Shift_Right_Arithmetic
12544 @cindex Rotate_Left
12545 @cindex Rotate_Right
12547 In standard Ada, the shift and rotate functions are available only
12548 for the predefined modular types in package @code{Interfaces}. However, in
12549 GNAT it is possible to define these functions for any integer
12550 type (signed or modular), as in this example:
12552 @smallexample @c ada
12553 function Shift_Left
12560 The function name must be one of
12561 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
12562 Rotate_Right. T must be an integer type. T'Size must be
12563 8, 16, 32 or 64 bits; if T is modular, the modulus
12564 must be 2**8, 2**16, 2**32 or 2**64.
12565 The result type must be the same as the type of @code{Value}.
12566 The shift amount must be Natural.
12567 The formal parameter names can be anything.
12569 @node Source_Location
12570 @section Source_Location
12571 @cindex Source_Location
12573 This intrinsic subprogram is used in the implementation of the
12574 library routine @code{GNAT.Source_Info}. The only useful use of the
12575 intrinsic import in this case is the one in this unit, so an
12576 application program should simply call the function
12577 @code{GNAT.Source_Info.Source_Location} to obtain the current
12578 source file location.
12580 @node Representation Clauses and Pragmas
12581 @chapter Representation Clauses and Pragmas
12582 @cindex Representation Clauses
12585 * Alignment Clauses::
12587 * Storage_Size Clauses::
12588 * Size of Variant Record Objects::
12589 * Biased Representation ::
12590 * Value_Size and Object_Size Clauses::
12591 * Component_Size Clauses::
12592 * Bit_Order Clauses::
12593 * Effect of Bit_Order on Byte Ordering::
12594 * Pragma Pack for Arrays::
12595 * Pragma Pack for Records::
12596 * Record Representation Clauses::
12597 * Enumeration Clauses::
12598 * Address Clauses::
12599 * Effect of Convention on Representation::
12600 * Determining the Representations chosen by GNAT::
12604 @cindex Representation Clause
12605 @cindex Representation Pragma
12606 @cindex Pragma, representation
12607 This section describes the representation clauses accepted by GNAT, and
12608 their effect on the representation of corresponding data objects.
12610 GNAT fully implements Annex C (Systems Programming). This means that all
12611 the implementation advice sections in chapter 13 are fully implemented.
12612 However, these sections only require a minimal level of support for
12613 representation clauses. GNAT provides much more extensive capabilities,
12614 and this section describes the additional capabilities provided.
12616 @node Alignment Clauses
12617 @section Alignment Clauses
12618 @cindex Alignment Clause
12621 GNAT requires that all alignment clauses specify a power of 2, and all
12622 default alignments are always a power of 2. The default alignment
12623 values are as follows:
12626 @item @emph{Primitive Types}.
12627 For primitive types, the alignment is the minimum of the actual size of
12628 objects of the type divided by @code{Storage_Unit},
12629 and the maximum alignment supported by the target.
12630 (This maximum alignment is given by the GNAT-specific attribute
12631 @code{Standard'Maximum_Alignment}; see @ref{Attribute Maximum_Alignment}.)
12632 @cindex @code{Maximum_Alignment} attribute
12633 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
12634 default alignment will be 8 on any target that supports alignments
12635 this large, but on some targets, the maximum alignment may be smaller
12636 than 8, in which case objects of type @code{Long_Float} will be maximally
12639 @item @emph{Arrays}.
12640 For arrays, the alignment is equal to the alignment of the component type
12641 for the normal case where no packing or component size is given. If the
12642 array is packed, and the packing is effective (see separate section on
12643 packed arrays), then the alignment will be one for long packed arrays,
12644 or arrays whose length is not known at compile time. For short packed
12645 arrays, which are handled internally as modular types, the alignment
12646 will be as described for primitive types, e.g.@: a packed array of length
12647 31 bits will have an object size of four bytes, and an alignment of 4.
12649 @item @emph{Records}.
12650 For the normal non-packed case, the alignment of a record is equal to
12651 the maximum alignment of any of its components. For tagged records, this
12652 includes the implicit access type used for the tag. If a pragma @code{Pack}
12653 is used and all components are packable (see separate section on pragma
12654 @code{Pack}), then the resulting alignment is 1, unless the layout of the
12655 record makes it profitable to increase it.
12657 A special case is when:
12660 the size of the record is given explicitly, or a
12661 full record representation clause is given, and
12663 the size of the record is 2, 4, or 8 bytes.
12666 In this case, an alignment is chosen to match the
12667 size of the record. For example, if we have:
12669 @smallexample @c ada
12670 type Small is record
12673 for Small'Size use 16;
12677 then the default alignment of the record type @code{Small} is 2, not 1. This
12678 leads to more efficient code when the record is treated as a unit, and also
12679 allows the type to specified as @code{Atomic} on architectures requiring
12685 An alignment clause may specify a larger alignment than the default value
12686 up to some maximum value dependent on the target (obtainable by using the
12687 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
12688 a smaller alignment than the default value for enumeration, integer and
12689 fixed point types, as well as for record types, for example
12691 @smallexample @c ada
12696 for V'alignment use 1;
12700 @cindex Alignment, default
12701 The default alignment for the type @code{V} is 4, as a result of the
12702 Integer field in the record, but it is permissible, as shown, to
12703 override the default alignment of the record with a smaller value.
12705 @cindex Alignment, subtypes
12706 Note that according to the Ada standard, an alignment clause applies only
12707 to the first named subtype. If additional subtypes are declared, then the
12708 compiler is allowed to choose any alignment it likes, and there is no way
12709 to control this choice. Consider:
12711 @smallexample @c ada
12712 type R is range 1 .. 10_000;
12713 for R'Alignment use 1;
12714 subtype RS is R range 1 .. 1000;
12718 The alignment clause specifies an alignment of 1 for the first named subtype
12719 @code{R} but this does not necessarily apply to @code{RS}. When writing
12720 portable Ada code, you should avoid writing code that explicitly or
12721 implicitly relies on the alignment of such subtypes.
12723 For the GNAT compiler, if an explicit alignment clause is given, this
12724 value is also used for any subsequent subtypes. So for GNAT, in the
12725 above example, you can count on the alignment of @code{RS} being 1. But this
12726 assumption is non-portable, and other compilers may choose different
12727 alignments for the subtype @code{RS}.
12730 @section Size Clauses
12731 @cindex Size Clause
12734 The default size for a type @code{T} is obtainable through the
12735 language-defined attribute @code{T'Size} and also through the
12736 equivalent GNAT-defined attribute @code{T'Value_Size}.
12737 For objects of type @code{T}, GNAT will generally increase the type size
12738 so that the object size (obtainable through the GNAT-defined attribute
12739 @code{T'Object_Size})
12740 is a multiple of @code{T'Alignment * Storage_Unit}.
12743 @smallexample @c ada
12744 type Smallint is range 1 .. 6;
12753 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
12754 as specified by the RM rules,
12755 but objects of this type will have a size of 8
12756 (@code{Smallint'Object_Size} = 8),
12757 since objects by default occupy an integral number
12758 of storage units. On some targets, notably older
12759 versions of the Digital Alpha, the size of stand
12760 alone objects of this type may be 32, reflecting
12761 the inability of the hardware to do byte load/stores.
12763 Similarly, the size of type @code{Rec} is 40 bits
12764 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
12765 the alignment is 4, so objects of this type will have
12766 their size increased to 64 bits so that it is a multiple
12767 of the alignment (in bits). This decision is
12768 in accordance with the specific Implementation Advice in RM 13.3(43):
12771 A @code{Size} clause should be supported for an object if the specified
12772 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
12773 to a size in storage elements that is a multiple of the object's
12774 @code{Alignment} (if the @code{Alignment} is nonzero).
12778 An explicit size clause may be used to override the default size by
12779 increasing it. For example, if we have:
12781 @smallexample @c ada
12782 type My_Boolean is new Boolean;
12783 for My_Boolean'Size use 32;
12787 then values of this type will always be 32 bits long. In the case of
12788 discrete types, the size can be increased up to 64 bits, with the effect
12789 that the entire specified field is used to hold the value, sign- or
12790 zero-extended as appropriate. If more than 64 bits is specified, then
12791 padding space is allocated after the value, and a warning is issued that
12792 there are unused bits.
12794 Similarly the size of records and arrays may be increased, and the effect
12795 is to add padding bits after the value. This also causes a warning message
12798 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
12799 Size in bits, this corresponds to an object of size 256 megabytes (minus
12800 one). This limitation is true on all targets. The reason for this
12801 limitation is that it improves the quality of the code in many cases
12802 if it is known that a Size value can be accommodated in an object of
12805 @node Storage_Size Clauses
12806 @section Storage_Size Clauses
12807 @cindex Storage_Size Clause
12810 For tasks, the @code{Storage_Size} clause specifies the amount of space
12811 to be allocated for the task stack. This cannot be extended, and if the
12812 stack is exhausted, then @code{Storage_Error} will be raised (if stack
12813 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
12814 or a @code{Storage_Size} pragma in the task definition to set the
12815 appropriate required size. A useful technique is to include in every
12816 task definition a pragma of the form:
12818 @smallexample @c ada
12819 pragma Storage_Size (Default_Stack_Size);
12823 Then @code{Default_Stack_Size} can be defined in a global package, and
12824 modified as required. Any tasks requiring stack sizes different from the
12825 default can have an appropriate alternative reference in the pragma.
12827 You can also use the @option{-d} binder switch to modify the default stack
12830 For access types, the @code{Storage_Size} clause specifies the maximum
12831 space available for allocation of objects of the type. If this space is
12832 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
12833 In the case where the access type is declared local to a subprogram, the
12834 use of a @code{Storage_Size} clause triggers automatic use of a special
12835 predefined storage pool (@code{System.Pool_Size}) that ensures that all
12836 space for the pool is automatically reclaimed on exit from the scope in
12837 which the type is declared.
12839 A special case recognized by the compiler is the specification of a
12840 @code{Storage_Size} of zero for an access type. This means that no
12841 items can be allocated from the pool, and this is recognized at compile
12842 time, and all the overhead normally associated with maintaining a fixed
12843 size storage pool is eliminated. Consider the following example:
12845 @smallexample @c ada
12847 type R is array (Natural) of Character;
12848 type P is access all R;
12849 for P'Storage_Size use 0;
12850 -- Above access type intended only for interfacing purposes
12854 procedure g (m : P);
12855 pragma Import (C, g);
12866 As indicated in this example, these dummy storage pools are often useful in
12867 connection with interfacing where no object will ever be allocated. If you
12868 compile the above example, you get the warning:
12871 p.adb:16:09: warning: allocation from empty storage pool
12872 p.adb:16:09: warning: Storage_Error will be raised at run time
12876 Of course in practice, there will not be any explicit allocators in the
12877 case of such an access declaration.
12879 @node Size of Variant Record Objects
12880 @section Size of Variant Record Objects
12881 @cindex Size, variant record objects
12882 @cindex Variant record objects, size
12885 In the case of variant record objects, there is a question whether Size gives
12886 information about a particular variant, or the maximum size required
12887 for any variant. Consider the following program
12889 @smallexample @c ada
12890 with Text_IO; use Text_IO;
12892 type R1 (A : Boolean := False) is record
12894 when True => X : Character;
12895 when False => null;
12903 Put_Line (Integer'Image (V1'Size));
12904 Put_Line (Integer'Image (V2'Size));
12909 Here we are dealing with a variant record, where the True variant
12910 requires 16 bits, and the False variant requires 8 bits.
12911 In the above example, both V1 and V2 contain the False variant,
12912 which is only 8 bits long. However, the result of running the
12921 The reason for the difference here is that the discriminant value of
12922 V1 is fixed, and will always be False. It is not possible to assign
12923 a True variant value to V1, therefore 8 bits is sufficient. On the
12924 other hand, in the case of V2, the initial discriminant value is
12925 False (from the default), but it is possible to assign a True
12926 variant value to V2, therefore 16 bits must be allocated for V2
12927 in the general case, even fewer bits may be needed at any particular
12928 point during the program execution.
12930 As can be seen from the output of this program, the @code{'Size}
12931 attribute applied to such an object in GNAT gives the actual allocated
12932 size of the variable, which is the largest size of any of the variants.
12933 The Ada Reference Manual is not completely clear on what choice should
12934 be made here, but the GNAT behavior seems most consistent with the
12935 language in the RM@.
12937 In some cases, it may be desirable to obtain the size of the current
12938 variant, rather than the size of the largest variant. This can be
12939 achieved in GNAT by making use of the fact that in the case of a
12940 subprogram parameter, GNAT does indeed return the size of the current
12941 variant (because a subprogram has no way of knowing how much space
12942 is actually allocated for the actual).
12944 Consider the following modified version of the above program:
12946 @smallexample @c ada
12947 with Text_IO; use Text_IO;
12949 type R1 (A : Boolean := False) is record
12951 when True => X : Character;
12952 when False => null;
12958 function Size (V : R1) return Integer is
12964 Put_Line (Integer'Image (V2'Size));
12965 Put_Line (Integer'IMage (Size (V2)));
12967 Put_Line (Integer'Image (V2'Size));
12968 Put_Line (Integer'IMage (Size (V2)));
12973 The output from this program is
12983 Here we see that while the @code{'Size} attribute always returns
12984 the maximum size, regardless of the current variant value, the
12985 @code{Size} function does indeed return the size of the current
12988 @node Biased Representation
12989 @section Biased Representation
12990 @cindex Size for biased representation
12991 @cindex Biased representation
12994 In the case of scalars with a range starting at other than zero, it is
12995 possible in some cases to specify a size smaller than the default minimum
12996 value, and in such cases, GNAT uses an unsigned biased representation,
12997 in which zero is used to represent the lower bound, and successive values
12998 represent successive values of the type.
13000 For example, suppose we have the declaration:
13002 @smallexample @c ada
13003 type Small is range -7 .. -4;
13004 for Small'Size use 2;
13008 Although the default size of type @code{Small} is 4, the @code{Size}
13009 clause is accepted by GNAT and results in the following representation
13013 -7 is represented as 2#00#
13014 -6 is represented as 2#01#
13015 -5 is represented as 2#10#
13016 -4 is represented as 2#11#
13020 Biased representation is only used if the specified @code{Size} clause
13021 cannot be accepted in any other manner. These reduced sizes that force
13022 biased representation can be used for all discrete types except for
13023 enumeration types for which a representation clause is given.
13025 @node Value_Size and Object_Size Clauses
13026 @section Value_Size and Object_Size Clauses
13028 @findex Object_Size
13029 @cindex Size, of objects
13032 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
13033 number of bits required to hold values of type @code{T}.
13034 Although this interpretation was allowed in Ada 83, it was not required,
13035 and this requirement in practice can cause some significant difficulties.
13036 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
13037 However, in Ada 95 and Ada 2005,
13038 @code{Natural'Size} is
13039 typically 31. This means that code may change in behavior when moving
13040 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
13042 @smallexample @c ada
13043 type Rec is record;
13049 at 0 range 0 .. Natural'Size - 1;
13050 at 0 range Natural'Size .. 2 * Natural'Size - 1;
13055 In the above code, since the typical size of @code{Natural} objects
13056 is 32 bits and @code{Natural'Size} is 31, the above code can cause
13057 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
13058 there are cases where the fact that the object size can exceed the
13059 size of the type causes surprises.
13061 To help get around this problem GNAT provides two implementation
13062 defined attributes, @code{Value_Size} and @code{Object_Size}. When
13063 applied to a type, these attributes yield the size of the type
13064 (corresponding to the RM defined size attribute), and the size of
13065 objects of the type respectively.
13067 The @code{Object_Size} is used for determining the default size of
13068 objects and components. This size value can be referred to using the
13069 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
13070 the basis of the determination of the size. The backend is free to
13071 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
13072 character might be stored in 32 bits on a machine with no efficient
13073 byte access instructions such as the Alpha.
13075 The default rules for the value of @code{Object_Size} for
13076 discrete types are as follows:
13080 The @code{Object_Size} for base subtypes reflect the natural hardware
13081 size in bits (run the compiler with @option{-gnatS} to find those values
13082 for numeric types). Enumeration types and fixed-point base subtypes have
13083 8, 16, 32 or 64 bits for this size, depending on the range of values
13087 The @code{Object_Size} of a subtype is the same as the
13088 @code{Object_Size} of
13089 the type from which it is obtained.
13092 The @code{Object_Size} of a derived base type is copied from the parent
13093 base type, and the @code{Object_Size} of a derived first subtype is copied
13094 from the parent first subtype.
13098 The @code{Value_Size} attribute
13099 is the (minimum) number of bits required to store a value
13101 This value is used to determine how tightly to pack
13102 records or arrays with components of this type, and also affects
13103 the semantics of unchecked conversion (unchecked conversions where
13104 the @code{Value_Size} values differ generate a warning, and are potentially
13107 The default rules for the value of @code{Value_Size} are as follows:
13111 The @code{Value_Size} for a base subtype is the minimum number of bits
13112 required to store all values of the type (including the sign bit
13113 only if negative values are possible).
13116 If a subtype statically matches the first subtype of a given type, then it has
13117 by default the same @code{Value_Size} as the first subtype. This is a
13118 consequence of RM 13.1(14) (``if two subtypes statically match,
13119 then their subtype-specific aspects are the same''.)
13122 All other subtypes have a @code{Value_Size} corresponding to the minimum
13123 number of bits required to store all values of the subtype. For
13124 dynamic bounds, it is assumed that the value can range down or up
13125 to the corresponding bound of the ancestor
13129 The RM defined attribute @code{Size} corresponds to the
13130 @code{Value_Size} attribute.
13132 The @code{Size} attribute may be defined for a first-named subtype. This sets
13133 the @code{Value_Size} of
13134 the first-named subtype to the given value, and the
13135 @code{Object_Size} of this first-named subtype to the given value padded up
13136 to an appropriate boundary. It is a consequence of the default rules
13137 above that this @code{Object_Size} will apply to all further subtypes. On the
13138 other hand, @code{Value_Size} is affected only for the first subtype, any
13139 dynamic subtypes obtained from it directly, and any statically matching
13140 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
13142 @code{Value_Size} and
13143 @code{Object_Size} may be explicitly set for any subtype using
13144 an attribute definition clause. Note that the use of these attributes
13145 can cause the RM 13.1(14) rule to be violated. If two access types
13146 reference aliased objects whose subtypes have differing @code{Object_Size}
13147 values as a result of explicit attribute definition clauses, then it
13148 is erroneous to convert from one access subtype to the other.
13150 At the implementation level, Esize stores the Object_Size and the
13151 RM_Size field stores the @code{Value_Size} (and hence the value of the
13152 @code{Size} attribute,
13153 which, as noted above, is equivalent to @code{Value_Size}).
13155 To get a feel for the difference, consider the following examples (note
13156 that in each case the base is @code{Short_Short_Integer} with a size of 8):
13159 Object_Size Value_Size
13161 type x1 is range 0 .. 5; 8 3
13163 type x2 is range 0 .. 5;
13164 for x2'size use 12; 16 12
13166 subtype x3 is x2 range 0 .. 3; 16 2
13168 subtype x4 is x2'base range 0 .. 10; 8 4
13170 subtype x5 is x2 range 0 .. dynamic; 16 3*
13172 subtype x6 is x2'base range 0 .. dynamic; 8 3*
13177 Note: the entries marked ``3*'' are not actually specified by the Ada
13178 Reference Manual, but it seems in the spirit of the RM rules to allocate
13179 the minimum number of bits (here 3, given the range for @code{x2})
13180 known to be large enough to hold the given range of values.
13182 So far, so good, but GNAT has to obey the RM rules, so the question is
13183 under what conditions must the RM @code{Size} be used.
13184 The following is a list
13185 of the occasions on which the RM @code{Size} must be used:
13189 Component size for packed arrays or records
13192 Value of the attribute @code{Size} for a type
13195 Warning about sizes not matching for unchecked conversion
13199 For record types, the @code{Object_Size} is always a multiple of the
13200 alignment of the type (this is true for all types). In some cases the
13201 @code{Value_Size} can be smaller. Consider:
13211 On a typical 32-bit architecture, the X component will be four bytes, and
13212 require four-byte alignment, and the Y component will be one byte. In this
13213 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
13214 required to store a value of this type, and for example, it is permissible
13215 to have a component of type R in an outer array whose component size is
13216 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
13217 since it must be rounded up so that this value is a multiple of the
13218 alignment (4 bytes = 32 bits).
13221 For all other types, the @code{Object_Size}
13222 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
13223 Only @code{Size} may be specified for such types.
13225 @node Component_Size Clauses
13226 @section Component_Size Clauses
13227 @cindex Component_Size Clause
13230 Normally, the value specified in a component size clause must be consistent
13231 with the subtype of the array component with regard to size and alignment.
13232 In other words, the value specified must be at least equal to the size
13233 of this subtype, and must be a multiple of the alignment value.
13235 In addition, component size clauses are allowed which cause the array
13236 to be packed, by specifying a smaller value. A first case is for
13237 component size values in the range 1 through 63. The value specified
13238 must not be smaller than the Size of the subtype. GNAT will accurately
13239 honor all packing requests in this range. For example, if we have:
13241 @smallexample @c ada
13242 type r is array (1 .. 8) of Natural;
13243 for r'Component_Size use 31;
13247 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
13248 Of course access to the components of such an array is considerably
13249 less efficient than if the natural component size of 32 is used.
13250 A second case is when the subtype of the component is a record type
13251 padded because of its default alignment. For example, if we have:
13253 @smallexample @c ada
13260 type a is array (1 .. 8) of r;
13261 for a'Component_Size use 72;
13265 then the resulting array has a length of 72 bytes, instead of 96 bytes
13266 if the alignment of the record (4) was obeyed.
13268 Note that there is no point in giving both a component size clause
13269 and a pragma Pack for the same array type. if such duplicate
13270 clauses are given, the pragma Pack will be ignored.
13272 @node Bit_Order Clauses
13273 @section Bit_Order Clauses
13274 @cindex Bit_Order Clause
13275 @cindex bit ordering
13276 @cindex ordering, of bits
13279 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
13280 attribute. The specification may either correspond to the default bit
13281 order for the target, in which case the specification has no effect and
13282 places no additional restrictions, or it may be for the non-standard
13283 setting (that is the opposite of the default).
13285 In the case where the non-standard value is specified, the effect is
13286 to renumber bits within each byte, but the ordering of bytes is not
13287 affected. There are certain
13288 restrictions placed on component clauses as follows:
13292 @item Components fitting within a single storage unit.
13294 These are unrestricted, and the effect is merely to renumber bits. For
13295 example if we are on a little-endian machine with @code{Low_Order_First}
13296 being the default, then the following two declarations have exactly
13299 @smallexample @c ada
13302 B : Integer range 1 .. 120;
13306 A at 0 range 0 .. 0;
13307 B at 0 range 1 .. 7;
13312 B : Integer range 1 .. 120;
13315 for R2'Bit_Order use High_Order_First;
13318 A at 0 range 7 .. 7;
13319 B at 0 range 0 .. 6;
13324 The useful application here is to write the second declaration with the
13325 @code{Bit_Order} attribute definition clause, and know that it will be treated
13326 the same, regardless of whether the target is little-endian or big-endian.
13328 @item Components occupying an integral number of bytes.
13330 These are components that exactly fit in two or more bytes. Such component
13331 declarations are allowed, but have no effect, since it is important to realize
13332 that the @code{Bit_Order} specification does not affect the ordering of bytes.
13333 In particular, the following attempt at getting an endian-independent integer
13336 @smallexample @c ada
13341 for R2'Bit_Order use High_Order_First;
13344 A at 0 range 0 .. 31;
13349 This declaration will result in a little-endian integer on a
13350 little-endian machine, and a big-endian integer on a big-endian machine.
13351 If byte flipping is required for interoperability between big- and
13352 little-endian machines, this must be explicitly programmed. This capability
13353 is not provided by @code{Bit_Order}.
13355 @item Components that are positioned across byte boundaries
13357 but do not occupy an integral number of bytes. Given that bytes are not
13358 reordered, such fields would occupy a non-contiguous sequence of bits
13359 in memory, requiring non-trivial code to reassemble. They are for this
13360 reason not permitted, and any component clause specifying such a layout
13361 will be flagged as illegal by GNAT@.
13366 Since the misconception that Bit_Order automatically deals with all
13367 endian-related incompatibilities is a common one, the specification of
13368 a component field that is an integral number of bytes will always
13369 generate a warning. This warning may be suppressed using @code{pragma
13370 Warnings (Off)} if desired. The following section contains additional
13371 details regarding the issue of byte ordering.
13373 @node Effect of Bit_Order on Byte Ordering
13374 @section Effect of Bit_Order on Byte Ordering
13375 @cindex byte ordering
13376 @cindex ordering, of bytes
13379 In this section we will review the effect of the @code{Bit_Order} attribute
13380 definition clause on byte ordering. Briefly, it has no effect at all, but
13381 a detailed example will be helpful. Before giving this
13382 example, let us review the precise
13383 definition of the effect of defining @code{Bit_Order}. The effect of a
13384 non-standard bit order is described in section 15.5.3 of the Ada
13388 2 A bit ordering is a method of interpreting the meaning of
13389 the storage place attributes.
13393 To understand the precise definition of storage place attributes in
13394 this context, we visit section 13.5.1 of the manual:
13397 13 A record_representation_clause (without the mod_clause)
13398 specifies the layout. The storage place attributes (see 13.5.2)
13399 are taken from the values of the position, first_bit, and last_bit
13400 expressions after normalizing those values so that first_bit is
13401 less than Storage_Unit.
13405 The critical point here is that storage places are taken from
13406 the values after normalization, not before. So the @code{Bit_Order}
13407 interpretation applies to normalized values. The interpretation
13408 is described in the later part of the 15.5.3 paragraph:
13411 2 A bit ordering is a method of interpreting the meaning of
13412 the storage place attributes. High_Order_First (known in the
13413 vernacular as ``big endian'') means that the first bit of a
13414 storage element (bit 0) is the most significant bit (interpreting
13415 the sequence of bits that represent a component as an unsigned
13416 integer value). Low_Order_First (known in the vernacular as
13417 ``little endian'') means the opposite: the first bit is the
13422 Note that the numbering is with respect to the bits of a storage
13423 unit. In other words, the specification affects only the numbering
13424 of bits within a single storage unit.
13426 We can make the effect clearer by giving an example.
13428 Suppose that we have an external device which presents two bytes, the first
13429 byte presented, which is the first (low addressed byte) of the two byte
13430 record is called Master, and the second byte is called Slave.
13432 The left most (most significant bit is called Control for each byte, and
13433 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
13434 (least significant) bit.
13436 On a big-endian machine, we can write the following representation clause
13438 @smallexample @c ada
13439 type Data is record
13440 Master_Control : Bit;
13448 Slave_Control : Bit;
13458 for Data use record
13459 Master_Control at 0 range 0 .. 0;
13460 Master_V1 at 0 range 1 .. 1;
13461 Master_V2 at 0 range 2 .. 2;
13462 Master_V3 at 0 range 3 .. 3;
13463 Master_V4 at 0 range 4 .. 4;
13464 Master_V5 at 0 range 5 .. 5;
13465 Master_V6 at 0 range 6 .. 6;
13466 Master_V7 at 0 range 7 .. 7;
13467 Slave_Control at 1 range 0 .. 0;
13468 Slave_V1 at 1 range 1 .. 1;
13469 Slave_V2 at 1 range 2 .. 2;
13470 Slave_V3 at 1 range 3 .. 3;
13471 Slave_V4 at 1 range 4 .. 4;
13472 Slave_V5 at 1 range 5 .. 5;
13473 Slave_V6 at 1 range 6 .. 6;
13474 Slave_V7 at 1 range 7 .. 7;
13479 Now if we move this to a little endian machine, then the bit ordering within
13480 the byte is backwards, so we have to rewrite the record rep clause as:
13482 @smallexample @c ada
13483 for Data use record
13484 Master_Control at 0 range 7 .. 7;
13485 Master_V1 at 0 range 6 .. 6;
13486 Master_V2 at 0 range 5 .. 5;
13487 Master_V3 at 0 range 4 .. 4;
13488 Master_V4 at 0 range 3 .. 3;
13489 Master_V5 at 0 range 2 .. 2;
13490 Master_V6 at 0 range 1 .. 1;
13491 Master_V7 at 0 range 0 .. 0;
13492 Slave_Control at 1 range 7 .. 7;
13493 Slave_V1 at 1 range 6 .. 6;
13494 Slave_V2 at 1 range 5 .. 5;
13495 Slave_V3 at 1 range 4 .. 4;
13496 Slave_V4 at 1 range 3 .. 3;
13497 Slave_V5 at 1 range 2 .. 2;
13498 Slave_V6 at 1 range 1 .. 1;
13499 Slave_V7 at 1 range 0 .. 0;
13504 It is a nuisance to have to rewrite the clause, especially if
13505 the code has to be maintained on both machines. However,
13506 this is a case that we can handle with the
13507 @code{Bit_Order} attribute if it is implemented.
13508 Note that the implementation is not required on byte addressed
13509 machines, but it is indeed implemented in GNAT.
13510 This means that we can simply use the
13511 first record clause, together with the declaration
13513 @smallexample @c ada
13514 for Data'Bit_Order use High_Order_First;
13518 and the effect is what is desired, namely the layout is exactly the same,
13519 independent of whether the code is compiled on a big-endian or little-endian
13522 The important point to understand is that byte ordering is not affected.
13523 A @code{Bit_Order} attribute definition never affects which byte a field
13524 ends up in, only where it ends up in that byte.
13525 To make this clear, let us rewrite the record rep clause of the previous
13528 @smallexample @c ada
13529 for Data'Bit_Order use High_Order_First;
13530 for Data use record
13531 Master_Control at 0 range 0 .. 0;
13532 Master_V1 at 0 range 1 .. 1;
13533 Master_V2 at 0 range 2 .. 2;
13534 Master_V3 at 0 range 3 .. 3;
13535 Master_V4 at 0 range 4 .. 4;
13536 Master_V5 at 0 range 5 .. 5;
13537 Master_V6 at 0 range 6 .. 6;
13538 Master_V7 at 0 range 7 .. 7;
13539 Slave_Control at 0 range 8 .. 8;
13540 Slave_V1 at 0 range 9 .. 9;
13541 Slave_V2 at 0 range 10 .. 10;
13542 Slave_V3 at 0 range 11 .. 11;
13543 Slave_V4 at 0 range 12 .. 12;
13544 Slave_V5 at 0 range 13 .. 13;
13545 Slave_V6 at 0 range 14 .. 14;
13546 Slave_V7 at 0 range 15 .. 15;
13551 This is exactly equivalent to saying (a repeat of the first example):
13553 @smallexample @c ada
13554 for Data'Bit_Order use High_Order_First;
13555 for Data use record
13556 Master_Control at 0 range 0 .. 0;
13557 Master_V1 at 0 range 1 .. 1;
13558 Master_V2 at 0 range 2 .. 2;
13559 Master_V3 at 0 range 3 .. 3;
13560 Master_V4 at 0 range 4 .. 4;
13561 Master_V5 at 0 range 5 .. 5;
13562 Master_V6 at 0 range 6 .. 6;
13563 Master_V7 at 0 range 7 .. 7;
13564 Slave_Control at 1 range 0 .. 0;
13565 Slave_V1 at 1 range 1 .. 1;
13566 Slave_V2 at 1 range 2 .. 2;
13567 Slave_V3 at 1 range 3 .. 3;
13568 Slave_V4 at 1 range 4 .. 4;
13569 Slave_V5 at 1 range 5 .. 5;
13570 Slave_V6 at 1 range 6 .. 6;
13571 Slave_V7 at 1 range 7 .. 7;
13576 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
13577 field. The storage place attributes are obtained by normalizing the
13578 values given so that the @code{First_Bit} value is less than 8. After
13579 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
13580 we specified in the other case.
13582 Now one might expect that the @code{Bit_Order} attribute might affect
13583 bit numbering within the entire record component (two bytes in this
13584 case, thus affecting which byte fields end up in), but that is not
13585 the way this feature is defined, it only affects numbering of bits,
13586 not which byte they end up in.
13588 Consequently it never makes sense to specify a starting bit number
13589 greater than 7 (for a byte addressable field) if an attribute
13590 definition for @code{Bit_Order} has been given, and indeed it
13591 may be actively confusing to specify such a value, so the compiler
13592 generates a warning for such usage.
13594 If you do need to control byte ordering then appropriate conditional
13595 values must be used. If in our example, the slave byte came first on
13596 some machines we might write:
13598 @smallexample @c ada
13599 Master_Byte_First constant Boolean := @dots{};
13601 Master_Byte : constant Natural :=
13602 1 - Boolean'Pos (Master_Byte_First);
13603 Slave_Byte : constant Natural :=
13604 Boolean'Pos (Master_Byte_First);
13606 for Data'Bit_Order use High_Order_First;
13607 for Data use record
13608 Master_Control at Master_Byte range 0 .. 0;
13609 Master_V1 at Master_Byte range 1 .. 1;
13610 Master_V2 at Master_Byte range 2 .. 2;
13611 Master_V3 at Master_Byte range 3 .. 3;
13612 Master_V4 at Master_Byte range 4 .. 4;
13613 Master_V5 at Master_Byte range 5 .. 5;
13614 Master_V6 at Master_Byte range 6 .. 6;
13615 Master_V7 at Master_Byte range 7 .. 7;
13616 Slave_Control at Slave_Byte range 0 .. 0;
13617 Slave_V1 at Slave_Byte range 1 .. 1;
13618 Slave_V2 at Slave_Byte range 2 .. 2;
13619 Slave_V3 at Slave_Byte range 3 .. 3;
13620 Slave_V4 at Slave_Byte range 4 .. 4;
13621 Slave_V5 at Slave_Byte range 5 .. 5;
13622 Slave_V6 at Slave_Byte range 6 .. 6;
13623 Slave_V7 at Slave_Byte range 7 .. 7;
13628 Now to switch between machines, all that is necessary is
13629 to set the boolean constant @code{Master_Byte_First} in
13630 an appropriate manner.
13632 @node Pragma Pack for Arrays
13633 @section Pragma Pack for Arrays
13634 @cindex Pragma Pack (for arrays)
13637 Pragma @code{Pack} applied to an array has no effect unless the component type
13638 is packable. For a component type to be packable, it must be one of the
13645 Any type whose size is specified with a size clause
13647 Any packed array type with a static size
13649 Any record type padded because of its default alignment
13653 For all these cases, if the component subtype size is in the range
13654 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
13655 component size were specified giving the component subtype size.
13656 For example if we have:
13658 @smallexample @c ada
13659 type r is range 0 .. 17;
13661 type ar is array (1 .. 8) of r;
13666 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
13667 and the size of the array @code{ar} will be exactly 40 bits.
13669 Note that in some cases this rather fierce approach to packing can produce
13670 unexpected effects. For example, in Ada 95 and Ada 2005,
13671 subtype @code{Natural} typically has a size of 31, meaning that if you
13672 pack an array of @code{Natural}, you get 31-bit
13673 close packing, which saves a few bits, but results in far less efficient
13674 access. Since many other Ada compilers will ignore such a packing request,
13675 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
13676 might not be what is intended. You can easily remove this warning by
13677 using an explicit @code{Component_Size} setting instead, which never generates
13678 a warning, since the intention of the programmer is clear in this case.
13680 GNAT treats packed arrays in one of two ways. If the size of the array is
13681 known at compile time and is less than 64 bits, then internally the array
13682 is represented as a single modular type, of exactly the appropriate number
13683 of bits. If the length is greater than 63 bits, or is not known at compile
13684 time, then the packed array is represented as an array of bytes, and the
13685 length is always a multiple of 8 bits.
13687 Note that to represent a packed array as a modular type, the alignment must
13688 be suitable for the modular type involved. For example, on typical machines
13689 a 32-bit packed array will be represented by a 32-bit modular integer with
13690 an alignment of four bytes. If you explicitly override the default alignment
13691 with an alignment clause that is too small, the modular representation
13692 cannot be used. For example, consider the following set of declarations:
13694 @smallexample @c ada
13695 type R is range 1 .. 3;
13696 type S is array (1 .. 31) of R;
13697 for S'Component_Size use 2;
13699 for S'Alignment use 1;
13703 If the alignment clause were not present, then a 62-bit modular
13704 representation would be chosen (typically with an alignment of 4 or 8
13705 bytes depending on the target). But the default alignment is overridden
13706 with the explicit alignment clause. This means that the modular
13707 representation cannot be used, and instead the array of bytes
13708 representation must be used, meaning that the length must be a multiple
13709 of 8. Thus the above set of declarations will result in a diagnostic
13710 rejecting the size clause and noting that the minimum size allowed is 64.
13712 @cindex Pragma Pack (for type Natural)
13713 @cindex Pragma Pack warning
13715 One special case that is worth noting occurs when the base type of the
13716 component size is 8/16/32 and the subtype is one bit less. Notably this
13717 occurs with subtype @code{Natural}. Consider:
13719 @smallexample @c ada
13720 type Arr is array (1 .. 32) of Natural;
13725 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
13726 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
13727 Ada 83 compilers did not attempt 31 bit packing.
13729 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
13730 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
13731 substantial unintended performance penalty when porting legacy Ada 83 code.
13732 To help prevent this, GNAT generates a warning in such cases. If you really
13733 want 31 bit packing in a case like this, you can set the component size
13736 @smallexample @c ada
13737 type Arr is array (1 .. 32) of Natural;
13738 for Arr'Component_Size use 31;
13742 Here 31-bit packing is achieved as required, and no warning is generated,
13743 since in this case the programmer intention is clear.
13745 @node Pragma Pack for Records
13746 @section Pragma Pack for Records
13747 @cindex Pragma Pack (for records)
13750 Pragma @code{Pack} applied to a record will pack the components to reduce
13751 wasted space from alignment gaps and by reducing the amount of space
13752 taken by components. We distinguish between @emph{packable} components and
13753 @emph{non-packable} components.
13754 Components of the following types are considered packable:
13757 All primitive types are packable.
13760 Small packed arrays, whose size does not exceed 64 bits, and where the
13761 size is statically known at compile time, are represented internally
13762 as modular integers, and so they are also packable.
13767 All packable components occupy the exact number of bits corresponding to
13768 their @code{Size} value, and are packed with no padding bits, i.e.@: they
13769 can start on an arbitrary bit boundary.
13771 All other types are non-packable, they occupy an integral number of
13773 are placed at a boundary corresponding to their alignment requirements.
13775 For example, consider the record
13777 @smallexample @c ada
13778 type Rb1 is array (1 .. 13) of Boolean;
13781 type Rb2 is array (1 .. 65) of Boolean;
13796 The representation for the record x2 is as follows:
13798 @smallexample @c ada
13799 for x2'Size use 224;
13801 l1 at 0 range 0 .. 0;
13802 l2 at 0 range 1 .. 64;
13803 l3 at 12 range 0 .. 31;
13804 l4 at 16 range 0 .. 0;
13805 l5 at 16 range 1 .. 13;
13806 l6 at 18 range 0 .. 71;
13811 Studying this example, we see that the packable fields @code{l1}
13813 of length equal to their sizes, and placed at specific bit boundaries (and
13814 not byte boundaries) to
13815 eliminate padding. But @code{l3} is of a non-packable float type, so
13816 it is on the next appropriate alignment boundary.
13818 The next two fields are fully packable, so @code{l4} and @code{l5} are
13819 minimally packed with no gaps. However, type @code{Rb2} is a packed
13820 array that is longer than 64 bits, so it is itself non-packable. Thus
13821 the @code{l6} field is aligned to the next byte boundary, and takes an
13822 integral number of bytes, i.e.@: 72 bits.
13824 @node Record Representation Clauses
13825 @section Record Representation Clauses
13826 @cindex Record Representation Clause
13829 Record representation clauses may be given for all record types, including
13830 types obtained by record extension. Component clauses are allowed for any
13831 static component. The restrictions on component clauses depend on the type
13834 @cindex Component Clause
13835 For all components of an elementary type, the only restriction on component
13836 clauses is that the size must be at least the 'Size value of the type
13837 (actually the Value_Size). There are no restrictions due to alignment,
13838 and such components may freely cross storage boundaries.
13840 Packed arrays with a size up to and including 64 bits are represented
13841 internally using a modular type with the appropriate number of bits, and
13842 thus the same lack of restriction applies. For example, if you declare:
13844 @smallexample @c ada
13845 type R is array (1 .. 49) of Boolean;
13851 then a component clause for a component of type R may start on any
13852 specified bit boundary, and may specify a value of 49 bits or greater.
13854 For packed bit arrays that are longer than 64 bits, there are two
13855 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
13856 including the important case of single bits or boolean values, then
13857 there are no limitations on placement of such components, and they
13858 may start and end at arbitrary bit boundaries.
13860 If the component size is not a power of 2 (e.g.@: 3 or 5), then
13861 an array of this type longer than 64 bits must always be placed on
13862 on a storage unit (byte) boundary and occupy an integral number
13863 of storage units (bytes). Any component clause that does not
13864 meet this requirement will be rejected.
13866 Any aliased component, or component of an aliased type, must
13867 have its normal alignment and size. A component clause that
13868 does not meet this requirement will be rejected.
13870 The tag field of a tagged type always occupies an address sized field at
13871 the start of the record. No component clause may attempt to overlay this
13872 tag. When a tagged type appears as a component, the tag field must have
13875 In the case of a record extension T1, of a type T, no component clause applied
13876 to the type T1 can specify a storage location that would overlap the first
13877 T'Size bytes of the record.
13879 For all other component types, including non-bit-packed arrays,
13880 the component can be placed at an arbitrary bit boundary,
13881 so for example, the following is permitted:
13883 @smallexample @c ada
13884 type R is array (1 .. 10) of Boolean;
13893 G at 0 range 0 .. 0;
13894 H at 0 range 1 .. 1;
13895 L at 0 range 2 .. 81;
13896 R at 0 range 82 .. 161;
13901 Note: the above rules apply to recent releases of GNAT 5.
13902 In GNAT 3, there are more severe restrictions on larger components.
13903 For non-primitive types, including packed arrays with a size greater than
13904 64 bits, component clauses must respect the alignment requirement of the
13905 type, in particular, always starting on a byte boundary, and the length
13906 must be a multiple of the storage unit.
13908 @node Enumeration Clauses
13909 @section Enumeration Clauses
13911 The only restriction on enumeration clauses is that the range of values
13912 must be representable. For the signed case, if one or more of the
13913 representation values are negative, all values must be in the range:
13915 @smallexample @c ada
13916 System.Min_Int .. System.Max_Int
13920 For the unsigned case, where all values are nonnegative, the values must
13923 @smallexample @c ada
13924 0 .. System.Max_Binary_Modulus;
13928 A @emph{confirming} representation clause is one in which the values range
13929 from 0 in sequence, i.e.@: a clause that confirms the default representation
13930 for an enumeration type.
13931 Such a confirming representation
13932 is permitted by these rules, and is specially recognized by the compiler so
13933 that no extra overhead results from the use of such a clause.
13935 If an array has an index type which is an enumeration type to which an
13936 enumeration clause has been applied, then the array is stored in a compact
13937 manner. Consider the declarations:
13939 @smallexample @c ada
13940 type r is (A, B, C);
13941 for r use (A => 1, B => 5, C => 10);
13942 type t is array (r) of Character;
13946 The array type t corresponds to a vector with exactly three elements and
13947 has a default size equal to @code{3*Character'Size}. This ensures efficient
13948 use of space, but means that accesses to elements of the array will incur
13949 the overhead of converting representation values to the corresponding
13950 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
13952 @node Address Clauses
13953 @section Address Clauses
13954 @cindex Address Clause
13956 The reference manual allows a general restriction on representation clauses,
13957 as found in RM 13.1(22):
13960 An implementation need not support representation
13961 items containing nonstatic expressions, except that
13962 an implementation should support a representation item
13963 for a given entity if each nonstatic expression in the
13964 representation item is a name that statically denotes
13965 a constant declared before the entity.
13969 In practice this is applicable only to address clauses, since this is the
13970 only case in which a non-static expression is permitted by the syntax. As
13971 the AARM notes in sections 13.1 (22.a-22.h):
13974 22.a Reason: This is to avoid the following sort of thing:
13976 22.b X : Integer := F(@dots{});
13977 Y : Address := G(@dots{});
13978 for X'Address use Y;
13980 22.c In the above, we have to evaluate the
13981 initialization expression for X before we
13982 know where to put the result. This seems
13983 like an unreasonable implementation burden.
13985 22.d The above code should instead be written
13988 22.e Y : constant Address := G(@dots{});
13989 X : Integer := F(@dots{});
13990 for X'Address use Y;
13992 22.f This allows the expression ``Y'' to be safely
13993 evaluated before X is created.
13995 22.g The constant could be a formal parameter of mode in.
13997 22.h An implementation can support other nonstatic
13998 expressions if it wants to. Expressions of type
13999 Address are hardly ever static, but their value
14000 might be known at compile time anyway in many
14005 GNAT does indeed permit many additional cases of non-static expressions. In
14006 particular, if the type involved is elementary there are no restrictions
14007 (since in this case, holding a temporary copy of the initialization value,
14008 if one is present, is inexpensive). In addition, if there is no implicit or
14009 explicit initialization, then there are no restrictions. GNAT will reject
14010 only the case where all three of these conditions hold:
14015 The type of the item is non-elementary (e.g.@: a record or array).
14018 There is explicit or implicit initialization required for the object.
14019 Note that access values are always implicitly initialized.
14022 The address value is non-static. Here GNAT is more permissive than the
14023 RM, and allows the address value to be the address of a previously declared
14024 stand-alone variable, as long as it does not itself have an address clause.
14026 @smallexample @c ada
14027 Anchor : Some_Initialized_Type;
14028 Overlay : Some_Initialized_Type;
14029 for Overlay'Address use Anchor'Address;
14033 However, the prefix of the address clause cannot be an array component, or
14034 a component of a discriminated record.
14039 As noted above in section 22.h, address values are typically non-static. In
14040 particular the To_Address function, even if applied to a literal value, is
14041 a non-static function call. To avoid this minor annoyance, GNAT provides
14042 the implementation defined attribute 'To_Address. The following two
14043 expressions have identical values:
14047 @smallexample @c ada
14048 To_Address (16#1234_0000#)
14049 System'To_Address (16#1234_0000#);
14053 except that the second form is considered to be a static expression, and
14054 thus when used as an address clause value is always permitted.
14057 Additionally, GNAT treats as static an address clause that is an
14058 unchecked_conversion of a static integer value. This simplifies the porting
14059 of legacy code, and provides a portable equivalent to the GNAT attribute
14062 Another issue with address clauses is the interaction with alignment
14063 requirements. When an address clause is given for an object, the address
14064 value must be consistent with the alignment of the object (which is usually
14065 the same as the alignment of the type of the object). If an address clause
14066 is given that specifies an inappropriately aligned address value, then the
14067 program execution is erroneous.
14069 Since this source of erroneous behavior can have unfortunate effects, GNAT
14070 checks (at compile time if possible, generating a warning, or at execution
14071 time with a run-time check) that the alignment is appropriate. If the
14072 run-time check fails, then @code{Program_Error} is raised. This run-time
14073 check is suppressed if range checks are suppressed, or if the special GNAT
14074 check Alignment_Check is suppressed, or if
14075 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
14077 Finally, GNAT does not permit overlaying of objects of controlled types or
14078 composite types containing a controlled component. In most cases, the compiler
14079 can detect an attempt at such overlays and will generate a warning at compile
14080 time and a Program_Error exception at run time.
14083 An address clause cannot be given for an exported object. More
14084 understandably the real restriction is that objects with an address
14085 clause cannot be exported. This is because such variables are not
14086 defined by the Ada program, so there is no external object to export.
14089 It is permissible to give an address clause and a pragma Import for the
14090 same object. In this case, the variable is not really defined by the
14091 Ada program, so there is no external symbol to be linked. The link name
14092 and the external name are ignored in this case. The reason that we allow this
14093 combination is that it provides a useful idiom to avoid unwanted
14094 initializations on objects with address clauses.
14096 When an address clause is given for an object that has implicit or
14097 explicit initialization, then by default initialization takes place. This
14098 means that the effect of the object declaration is to overwrite the
14099 memory at the specified address. This is almost always not what the
14100 programmer wants, so GNAT will output a warning:
14110 for Ext'Address use System'To_Address (16#1234_1234#);
14112 >>> warning: implicit initialization of "Ext" may
14113 modify overlaid storage
14114 >>> warning: use pragma Import for "Ext" to suppress
14115 initialization (RM B(24))
14121 As indicated by the warning message, the solution is to use a (dummy) pragma
14122 Import to suppress this initialization. The pragma tell the compiler that the
14123 object is declared and initialized elsewhere. The following package compiles
14124 without warnings (and the initialization is suppressed):
14126 @smallexample @c ada
14134 for Ext'Address use System'To_Address (16#1234_1234#);
14135 pragma Import (Ada, Ext);
14140 A final issue with address clauses involves their use for overlaying
14141 variables, as in the following example:
14142 @cindex Overlaying of objects
14144 @smallexample @c ada
14147 for B'Address use A'Address;
14151 or alternatively, using the form recommended by the RM:
14153 @smallexample @c ada
14155 Addr : constant Address := A'Address;
14157 for B'Address use Addr;
14161 In both of these cases, @code{A}
14162 and @code{B} become aliased to one another via the
14163 address clause. This use of address clauses to overlay
14164 variables, achieving an effect similar to unchecked
14165 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
14166 the effect is implementation defined. Furthermore, the
14167 Ada RM specifically recommends that in a situation
14168 like this, @code{B} should be subject to the following
14169 implementation advice (RM 13.3(19)):
14172 19 If the Address of an object is specified, or it is imported
14173 or exported, then the implementation should not perform
14174 optimizations based on assumptions of no aliases.
14178 GNAT follows this recommendation, and goes further by also applying
14179 this recommendation to the overlaid variable (@code{A}
14180 in the above example) in this case. This means that the overlay
14181 works "as expected", in that a modification to one of the variables
14182 will affect the value of the other.
14184 @node Effect of Convention on Representation
14185 @section Effect of Convention on Representation
14186 @cindex Convention, effect on representation
14189 Normally the specification of a foreign language convention for a type or
14190 an object has no effect on the chosen representation. In particular, the
14191 representation chosen for data in GNAT generally meets the standard system
14192 conventions, and for example records are laid out in a manner that is
14193 consistent with C@. This means that specifying convention C (for example)
14196 There are four exceptions to this general rule:
14200 @item Convention Fortran and array subtypes
14201 If pragma Convention Fortran is specified for an array subtype, then in
14202 accordance with the implementation advice in section 3.6.2(11) of the
14203 Ada Reference Manual, the array will be stored in a Fortran-compatible
14204 column-major manner, instead of the normal default row-major order.
14206 @item Convention C and enumeration types
14207 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
14208 to accommodate all values of the type. For example, for the enumeration
14211 @smallexample @c ada
14212 type Color is (Red, Green, Blue);
14216 8 bits is sufficient to store all values of the type, so by default, objects
14217 of type @code{Color} will be represented using 8 bits. However, normal C
14218 convention is to use 32 bits for all enum values in C, since enum values
14219 are essentially of type int. If pragma @code{Convention C} is specified for an
14220 Ada enumeration type, then the size is modified as necessary (usually to
14221 32 bits) to be consistent with the C convention for enum values.
14223 Note that this treatment applies only to types. If Convention C is given for
14224 an enumeration object, where the enumeration type is not Convention C, then
14225 Object_Size bits are allocated. For example, for a normal enumeration type,
14226 with less than 256 elements, only 8 bits will be allocated for the object.
14227 Since this may be a surprise in terms of what C expects, GNAT will issue a
14228 warning in this situation. The warning can be suppressed by giving an explicit
14229 size clause specifying the desired size.
14231 @item Convention C/Fortran and Boolean types
14232 In C, the usual convention for boolean values, that is values used for
14233 conditions, is that zero represents false, and nonzero values represent
14234 true. In Ada, the normal convention is that two specific values, typically
14235 0/1, are used to represent false/true respectively.
14237 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
14238 value represents true).
14240 To accommodate the Fortran and C conventions, if a pragma Convention specifies
14241 C or Fortran convention for a derived Boolean, as in the following example:
14243 @smallexample @c ada
14244 type C_Switch is new Boolean;
14245 pragma Convention (C, C_Switch);
14249 then the GNAT generated code will treat any nonzero value as true. For truth
14250 values generated by GNAT, the conventional value 1 will be used for True, but
14251 when one of these values is read, any nonzero value is treated as True.
14253 @item Access types on OpenVMS
14254 For 64-bit OpenVMS systems, access types (other than those for unconstrained
14255 arrays) are 64-bits long. An exception to this rule is for the case of
14256 C-convention access types where there is no explicit size clause present (or
14257 inherited for derived types). In this case, GNAT chooses to make these
14258 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
14259 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
14263 @node Determining the Representations chosen by GNAT
14264 @section Determining the Representations chosen by GNAT
14265 @cindex Representation, determination of
14266 @cindex @option{-gnatR} switch
14269 Although the descriptions in this section are intended to be complete, it is
14270 often easier to simply experiment to see what GNAT accepts and what the
14271 effect is on the layout of types and objects.
14273 As required by the Ada RM, if a representation clause is not accepted, then
14274 it must be rejected as illegal by the compiler. However, when a
14275 representation clause or pragma is accepted, there can still be questions
14276 of what the compiler actually does. For example, if a partial record
14277 representation clause specifies the location of some components and not
14278 others, then where are the non-specified components placed? Or if pragma
14279 @code{Pack} is used on a record, then exactly where are the resulting
14280 fields placed? The section on pragma @code{Pack} in this chapter can be
14281 used to answer the second question, but it is often easier to just see
14282 what the compiler does.
14284 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
14285 with this option, then the compiler will output information on the actual
14286 representations chosen, in a format similar to source representation
14287 clauses. For example, if we compile the package:
14289 @smallexample @c ada
14291 type r (x : boolean) is tagged record
14293 when True => S : String (1 .. 100);
14294 when False => null;
14298 type r2 is new r (false) with record
14303 y2 at 16 range 0 .. 31;
14310 type x1 is array (1 .. 10) of x;
14311 for x1'component_size use 11;
14313 type ia is access integer;
14315 type Rb1 is array (1 .. 13) of Boolean;
14318 type Rb2 is array (1 .. 65) of Boolean;
14334 using the switch @option{-gnatR} we obtain the following output:
14337 Representation information for unit q
14338 -------------------------------------
14341 for r'Alignment use 4;
14343 x at 4 range 0 .. 7;
14344 _tag at 0 range 0 .. 31;
14345 s at 5 range 0 .. 799;
14348 for r2'Size use 160;
14349 for r2'Alignment use 4;
14351 x at 4 range 0 .. 7;
14352 _tag at 0 range 0 .. 31;
14353 _parent at 0 range 0 .. 63;
14354 y2 at 16 range 0 .. 31;
14358 for x'Alignment use 1;
14360 y at 0 range 0 .. 7;
14363 for x1'Size use 112;
14364 for x1'Alignment use 1;
14365 for x1'Component_Size use 11;
14367 for rb1'Size use 13;
14368 for rb1'Alignment use 2;
14369 for rb1'Component_Size use 1;
14371 for rb2'Size use 72;
14372 for rb2'Alignment use 1;
14373 for rb2'Component_Size use 1;
14375 for x2'Size use 224;
14376 for x2'Alignment use 4;
14378 l1 at 0 range 0 .. 0;
14379 l2 at 0 range 1 .. 64;
14380 l3 at 12 range 0 .. 31;
14381 l4 at 16 range 0 .. 0;
14382 l5 at 16 range 1 .. 13;
14383 l6 at 18 range 0 .. 71;
14388 The Size values are actually the Object_Size, i.e.@: the default size that
14389 will be allocated for objects of the type.
14390 The ?? size for type r indicates that we have a variant record, and the
14391 actual size of objects will depend on the discriminant value.
14393 The Alignment values show the actual alignment chosen by the compiler
14394 for each record or array type.
14396 The record representation clause for type r shows where all fields
14397 are placed, including the compiler generated tag field (whose location
14398 cannot be controlled by the programmer).
14400 The record representation clause for the type extension r2 shows all the
14401 fields present, including the parent field, which is a copy of the fields
14402 of the parent type of r2, i.e.@: r1.
14404 The component size and size clauses for types rb1 and rb2 show
14405 the exact effect of pragma @code{Pack} on these arrays, and the record
14406 representation clause for type x2 shows how pragma @code{Pack} affects
14409 In some cases, it may be useful to cut and paste the representation clauses
14410 generated by the compiler into the original source to fix and guarantee
14411 the actual representation to be used.
14413 @node Standard Library Routines
14414 @chapter Standard Library Routines
14417 The Ada Reference Manual contains in Annex A a full description of an
14418 extensive set of standard library routines that can be used in any Ada
14419 program, and which must be provided by all Ada compilers. They are
14420 analogous to the standard C library used by C programs.
14422 GNAT implements all of the facilities described in annex A, and for most
14423 purposes the description in the Ada Reference Manual, or appropriate Ada
14424 text book, will be sufficient for making use of these facilities.
14426 In the case of the input-output facilities,
14427 @xref{The Implementation of Standard I/O},
14428 gives details on exactly how GNAT interfaces to the
14429 file system. For the remaining packages, the Ada Reference Manual
14430 should be sufficient. The following is a list of the packages included,
14431 together with a brief description of the functionality that is provided.
14433 For completeness, references are included to other predefined library
14434 routines defined in other sections of the Ada Reference Manual (these are
14435 cross-indexed from Annex A).
14439 This is a parent package for all the standard library packages. It is
14440 usually included implicitly in your program, and itself contains no
14441 useful data or routines.
14443 @item Ada.Calendar (9.6)
14444 @code{Calendar} provides time of day access, and routines for
14445 manipulating times and durations.
14447 @item Ada.Characters (A.3.1)
14448 This is a dummy parent package that contains no useful entities
14450 @item Ada.Characters.Handling (A.3.2)
14451 This package provides some basic character handling capabilities,
14452 including classification functions for classes of characters (e.g.@: test
14453 for letters, or digits).
14455 @item Ada.Characters.Latin_1 (A.3.3)
14456 This package includes a complete set of definitions of the characters
14457 that appear in type CHARACTER@. It is useful for writing programs that
14458 will run in international environments. For example, if you want an
14459 upper case E with an acute accent in a string, it is often better to use
14460 the definition of @code{UC_E_Acute} in this package. Then your program
14461 will print in an understandable manner even if your environment does not
14462 support these extended characters.
14464 @item Ada.Command_Line (A.15)
14465 This package provides access to the command line parameters and the name
14466 of the current program (analogous to the use of @code{argc} and @code{argv}
14467 in C), and also allows the exit status for the program to be set in a
14468 system-independent manner.
14470 @item Ada.Decimal (F.2)
14471 This package provides constants describing the range of decimal numbers
14472 implemented, and also a decimal divide routine (analogous to the COBOL
14473 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
14475 @item Ada.Direct_IO (A.8.4)
14476 This package provides input-output using a model of a set of records of
14477 fixed-length, containing an arbitrary definite Ada type, indexed by an
14478 integer record number.
14480 @item Ada.Dynamic_Priorities (D.5)
14481 This package allows the priorities of a task to be adjusted dynamically
14482 as the task is running.
14484 @item Ada.Exceptions (11.4.1)
14485 This package provides additional information on exceptions, and also
14486 contains facilities for treating exceptions as data objects, and raising
14487 exceptions with associated messages.
14489 @item Ada.Finalization (7.6)
14490 This package contains the declarations and subprograms to support the
14491 use of controlled types, providing for automatic initialization and
14492 finalization (analogous to the constructors and destructors of C++)
14494 @item Ada.Interrupts (C.3.2)
14495 This package provides facilities for interfacing to interrupts, which
14496 includes the set of signals or conditions that can be raised and
14497 recognized as interrupts.
14499 @item Ada.Interrupts.Names (C.3.2)
14500 This package provides the set of interrupt names (actually signal
14501 or condition names) that can be handled by GNAT@.
14503 @item Ada.IO_Exceptions (A.13)
14504 This package defines the set of exceptions that can be raised by use of
14505 the standard IO packages.
14508 This package contains some standard constants and exceptions used
14509 throughout the numerics packages. Note that the constants pi and e are
14510 defined here, and it is better to use these definitions than rolling
14513 @item Ada.Numerics.Complex_Elementary_Functions
14514 Provides the implementation of standard elementary functions (such as
14515 log and trigonometric functions) operating on complex numbers using the
14516 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
14517 created by the package @code{Numerics.Complex_Types}.
14519 @item Ada.Numerics.Complex_Types
14520 This is a predefined instantiation of
14521 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
14522 build the type @code{Complex} and @code{Imaginary}.
14524 @item Ada.Numerics.Discrete_Random
14525 This generic package provides a random number generator suitable for generating
14526 uniformly distributed values of a specified discrete subtype.
14528 @item Ada.Numerics.Float_Random
14529 This package provides a random number generator suitable for generating
14530 uniformly distributed floating point values in the unit interval.
14532 @item Ada.Numerics.Generic_Complex_Elementary_Functions
14533 This is a generic version of the package that provides the
14534 implementation of standard elementary functions (such as log and
14535 trigonometric functions) for an arbitrary complex type.
14537 The following predefined instantiations of this package are provided:
14541 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
14543 @code{Ada.Numerics.Complex_Elementary_Functions}
14545 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
14548 @item Ada.Numerics.Generic_Complex_Types
14549 This is a generic package that allows the creation of complex types,
14550 with associated complex arithmetic operations.
14552 The following predefined instantiations of this package exist
14555 @code{Ada.Numerics.Short_Complex_Complex_Types}
14557 @code{Ada.Numerics.Complex_Complex_Types}
14559 @code{Ada.Numerics.Long_Complex_Complex_Types}
14562 @item Ada.Numerics.Generic_Elementary_Functions
14563 This is a generic package that provides the implementation of standard
14564 elementary functions (such as log an trigonometric functions) for an
14565 arbitrary float type.
14567 The following predefined instantiations of this package exist
14571 @code{Ada.Numerics.Short_Elementary_Functions}
14573 @code{Ada.Numerics.Elementary_Functions}
14575 @code{Ada.Numerics.Long_Elementary_Functions}
14578 @item Ada.Real_Time (D.8)
14579 This package provides facilities similar to those of @code{Calendar}, but
14580 operating with a finer clock suitable for real time control. Note that
14581 annex D requires that there be no backward clock jumps, and GNAT generally
14582 guarantees this behavior, but of course if the external clock on which
14583 the GNAT runtime depends is deliberately reset by some external event,
14584 then such a backward jump may occur.
14586 @item Ada.Sequential_IO (A.8.1)
14587 This package provides input-output facilities for sequential files,
14588 which can contain a sequence of values of a single type, which can be
14589 any Ada type, including indefinite (unconstrained) types.
14591 @item Ada.Storage_IO (A.9)
14592 This package provides a facility for mapping arbitrary Ada types to and
14593 from a storage buffer. It is primarily intended for the creation of new
14596 @item Ada.Streams (13.13.1)
14597 This is a generic package that provides the basic support for the
14598 concept of streams as used by the stream attributes (@code{Input},
14599 @code{Output}, @code{Read} and @code{Write}).
14601 @item Ada.Streams.Stream_IO (A.12.1)
14602 This package is a specialization of the type @code{Streams} defined in
14603 package @code{Streams} together with a set of operations providing
14604 Stream_IO capability. The Stream_IO model permits both random and
14605 sequential access to a file which can contain an arbitrary set of values
14606 of one or more Ada types.
14608 @item Ada.Strings (A.4.1)
14609 This package provides some basic constants used by the string handling
14612 @item Ada.Strings.Bounded (A.4.4)
14613 This package provides facilities for handling variable length
14614 strings. The bounded model requires a maximum length. It is thus
14615 somewhat more limited than the unbounded model, but avoids the use of
14616 dynamic allocation or finalization.
14618 @item Ada.Strings.Fixed (A.4.3)
14619 This package provides facilities for handling fixed length strings.
14621 @item Ada.Strings.Maps (A.4.2)
14622 This package provides facilities for handling character mappings and
14623 arbitrarily defined subsets of characters. For instance it is useful in
14624 defining specialized translation tables.
14626 @item Ada.Strings.Maps.Constants (A.4.6)
14627 This package provides a standard set of predefined mappings and
14628 predefined character sets. For example, the standard upper to lower case
14629 conversion table is found in this package. Note that upper to lower case
14630 conversion is non-trivial if you want to take the entire set of
14631 characters, including extended characters like E with an acute accent,
14632 into account. You should use the mappings in this package (rather than
14633 adding 32 yourself) to do case mappings.
14635 @item Ada.Strings.Unbounded (A.4.5)
14636 This package provides facilities for handling variable length
14637 strings. The unbounded model allows arbitrary length strings, but
14638 requires the use of dynamic allocation and finalization.
14640 @item Ada.Strings.Wide_Bounded (A.4.7)
14641 @itemx Ada.Strings.Wide_Fixed (A.4.7)
14642 @itemx Ada.Strings.Wide_Maps (A.4.7)
14643 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
14644 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
14645 These packages provide analogous capabilities to the corresponding
14646 packages without @samp{Wide_} in the name, but operate with the types
14647 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
14648 and @code{Character}.
14650 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
14651 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
14652 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
14653 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
14654 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
14655 These packages provide analogous capabilities to the corresponding
14656 packages without @samp{Wide_} in the name, but operate with the types
14657 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
14658 of @code{String} and @code{Character}.
14660 @item Ada.Synchronous_Task_Control (D.10)
14661 This package provides some standard facilities for controlling task
14662 communication in a synchronous manner.
14665 This package contains definitions for manipulation of the tags of tagged
14668 @item Ada.Task_Attributes
14669 This package provides the capability of associating arbitrary
14670 task-specific data with separate tasks.
14673 This package provides basic text input-output capabilities for
14674 character, string and numeric data. The subpackages of this
14675 package are listed next.
14677 @item Ada.Text_IO.Decimal_IO
14678 Provides input-output facilities for decimal fixed-point types
14680 @item Ada.Text_IO.Enumeration_IO
14681 Provides input-output facilities for enumeration types.
14683 @item Ada.Text_IO.Fixed_IO
14684 Provides input-output facilities for ordinary fixed-point types.
14686 @item Ada.Text_IO.Float_IO
14687 Provides input-output facilities for float types. The following
14688 predefined instantiations of this generic package are available:
14692 @code{Short_Float_Text_IO}
14694 @code{Float_Text_IO}
14696 @code{Long_Float_Text_IO}
14699 @item Ada.Text_IO.Integer_IO
14700 Provides input-output facilities for integer types. The following
14701 predefined instantiations of this generic package are available:
14704 @item Short_Short_Integer
14705 @code{Ada.Short_Short_Integer_Text_IO}
14706 @item Short_Integer
14707 @code{Ada.Short_Integer_Text_IO}
14709 @code{Ada.Integer_Text_IO}
14711 @code{Ada.Long_Integer_Text_IO}
14712 @item Long_Long_Integer
14713 @code{Ada.Long_Long_Integer_Text_IO}
14716 @item Ada.Text_IO.Modular_IO
14717 Provides input-output facilities for modular (unsigned) types
14719 @item Ada.Text_IO.Complex_IO (G.1.3)
14720 This package provides basic text input-output capabilities for complex
14723 @item Ada.Text_IO.Editing (F.3.3)
14724 This package contains routines for edited output, analogous to the use
14725 of pictures in COBOL@. The picture formats used by this package are a
14726 close copy of the facility in COBOL@.
14728 @item Ada.Text_IO.Text_Streams (A.12.2)
14729 This package provides a facility that allows Text_IO files to be treated
14730 as streams, so that the stream attributes can be used for writing
14731 arbitrary data, including binary data, to Text_IO files.
14733 @item Ada.Unchecked_Conversion (13.9)
14734 This generic package allows arbitrary conversion from one type to
14735 another of the same size, providing for breaking the type safety in
14736 special circumstances.
14738 If the types have the same Size (more accurately the same Value_Size),
14739 then the effect is simply to transfer the bits from the source to the
14740 target type without any modification. This usage is well defined, and
14741 for simple types whose representation is typically the same across
14742 all implementations, gives a portable method of performing such
14745 If the types do not have the same size, then the result is implementation
14746 defined, and thus may be non-portable. The following describes how GNAT
14747 handles such unchecked conversion cases.
14749 If the types are of different sizes, and are both discrete types, then
14750 the effect is of a normal type conversion without any constraint checking.
14751 In particular if the result type has a larger size, the result will be
14752 zero or sign extended. If the result type has a smaller size, the result
14753 will be truncated by ignoring high order bits.
14755 If the types are of different sizes, and are not both discrete types,
14756 then the conversion works as though pointers were created to the source
14757 and target, and the pointer value is converted. The effect is that bits
14758 are copied from successive low order storage units and bits of the source
14759 up to the length of the target type.
14761 A warning is issued if the lengths differ, since the effect in this
14762 case is implementation dependent, and the above behavior may not match
14763 that of some other compiler.
14765 A pointer to one type may be converted to a pointer to another type using
14766 unchecked conversion. The only case in which the effect is undefined is
14767 when one or both pointers are pointers to unconstrained array types. In
14768 this case, the bounds information may get incorrectly transferred, and in
14769 particular, GNAT uses double size pointers for such types, and it is
14770 meaningless to convert between such pointer types. GNAT will issue a
14771 warning if the alignment of the target designated type is more strict
14772 than the alignment of the source designated type (since the result may
14773 be unaligned in this case).
14775 A pointer other than a pointer to an unconstrained array type may be
14776 converted to and from System.Address. Such usage is common in Ada 83
14777 programs, but note that Ada.Address_To_Access_Conversions is the
14778 preferred method of performing such conversions in Ada 95 and Ada 2005.
14780 unchecked conversion nor Ada.Address_To_Access_Conversions should be
14781 used in conjunction with pointers to unconstrained objects, since
14782 the bounds information cannot be handled correctly in this case.
14784 @item Ada.Unchecked_Deallocation (13.11.2)
14785 This generic package allows explicit freeing of storage previously
14786 allocated by use of an allocator.
14788 @item Ada.Wide_Text_IO (A.11)
14789 This package is similar to @code{Ada.Text_IO}, except that the external
14790 file supports wide character representations, and the internal types are
14791 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
14792 and @code{String}. It contains generic subpackages listed next.
14794 @item Ada.Wide_Text_IO.Decimal_IO
14795 Provides input-output facilities for decimal fixed-point types
14797 @item Ada.Wide_Text_IO.Enumeration_IO
14798 Provides input-output facilities for enumeration types.
14800 @item Ada.Wide_Text_IO.Fixed_IO
14801 Provides input-output facilities for ordinary fixed-point types.
14803 @item Ada.Wide_Text_IO.Float_IO
14804 Provides input-output facilities for float types. The following
14805 predefined instantiations of this generic package are available:
14809 @code{Short_Float_Wide_Text_IO}
14811 @code{Float_Wide_Text_IO}
14813 @code{Long_Float_Wide_Text_IO}
14816 @item Ada.Wide_Text_IO.Integer_IO
14817 Provides input-output facilities for integer types. The following
14818 predefined instantiations of this generic package are available:
14821 @item Short_Short_Integer
14822 @code{Ada.Short_Short_Integer_Wide_Text_IO}
14823 @item Short_Integer
14824 @code{Ada.Short_Integer_Wide_Text_IO}
14826 @code{Ada.Integer_Wide_Text_IO}
14828 @code{Ada.Long_Integer_Wide_Text_IO}
14829 @item Long_Long_Integer
14830 @code{Ada.Long_Long_Integer_Wide_Text_IO}
14833 @item Ada.Wide_Text_IO.Modular_IO
14834 Provides input-output facilities for modular (unsigned) types
14836 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
14837 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
14838 external file supports wide character representations.
14840 @item Ada.Wide_Text_IO.Editing (F.3.4)
14841 This package is similar to @code{Ada.Text_IO.Editing}, except that the
14842 types are @code{Wide_Character} and @code{Wide_String} instead of
14843 @code{Character} and @code{String}.
14845 @item Ada.Wide_Text_IO.Streams (A.12.3)
14846 This package is similar to @code{Ada.Text_IO.Streams}, except that the
14847 types are @code{Wide_Character} and @code{Wide_String} instead of
14848 @code{Character} and @code{String}.
14850 @item Ada.Wide_Wide_Text_IO (A.11)
14851 This package is similar to @code{Ada.Text_IO}, except that the external
14852 file supports wide character representations, and the internal types are
14853 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
14854 and @code{String}. It contains generic subpackages listed next.
14856 @item Ada.Wide_Wide_Text_IO.Decimal_IO
14857 Provides input-output facilities for decimal fixed-point types
14859 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
14860 Provides input-output facilities for enumeration types.
14862 @item Ada.Wide_Wide_Text_IO.Fixed_IO
14863 Provides input-output facilities for ordinary fixed-point types.
14865 @item Ada.Wide_Wide_Text_IO.Float_IO
14866 Provides input-output facilities for float types. The following
14867 predefined instantiations of this generic package are available:
14871 @code{Short_Float_Wide_Wide_Text_IO}
14873 @code{Float_Wide_Wide_Text_IO}
14875 @code{Long_Float_Wide_Wide_Text_IO}
14878 @item Ada.Wide_Wide_Text_IO.Integer_IO
14879 Provides input-output facilities for integer types. The following
14880 predefined instantiations of this generic package are available:
14883 @item Short_Short_Integer
14884 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
14885 @item Short_Integer
14886 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
14888 @code{Ada.Integer_Wide_Wide_Text_IO}
14890 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
14891 @item Long_Long_Integer
14892 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
14895 @item Ada.Wide_Wide_Text_IO.Modular_IO
14896 Provides input-output facilities for modular (unsigned) types
14898 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
14899 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
14900 external file supports wide character representations.
14902 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
14903 This package is similar to @code{Ada.Text_IO.Editing}, except that the
14904 types are @code{Wide_Character} and @code{Wide_String} instead of
14905 @code{Character} and @code{String}.
14907 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
14908 This package is similar to @code{Ada.Text_IO.Streams}, except that the
14909 types are @code{Wide_Character} and @code{Wide_String} instead of
14910 @code{Character} and @code{String}.
14913 @node The Implementation of Standard I/O
14914 @chapter The Implementation of Standard I/O
14917 GNAT implements all the required input-output facilities described in
14918 A.6 through A.14. These sections of the Ada Reference Manual describe the
14919 required behavior of these packages from the Ada point of view, and if
14920 you are writing a portable Ada program that does not need to know the
14921 exact manner in which Ada maps to the outside world when it comes to
14922 reading or writing external files, then you do not need to read this
14923 chapter. As long as your files are all regular files (not pipes or
14924 devices), and as long as you write and read the files only from Ada, the
14925 description in the Ada Reference Manual is sufficient.
14927 However, if you want to do input-output to pipes or other devices, such
14928 as the keyboard or screen, or if the files you are dealing with are
14929 either generated by some other language, or to be read by some other
14930 language, then you need to know more about the details of how the GNAT
14931 implementation of these input-output facilities behaves.
14933 In this chapter we give a detailed description of exactly how GNAT
14934 interfaces to the file system. As always, the sources of the system are
14935 available to you for answering questions at an even more detailed level,
14936 but for most purposes the information in this chapter will suffice.
14938 Another reason that you may need to know more about how input-output is
14939 implemented arises when you have a program written in mixed languages
14940 where, for example, files are shared between the C and Ada sections of
14941 the same program. GNAT provides some additional facilities, in the form
14942 of additional child library packages, that facilitate this sharing, and
14943 these additional facilities are also described in this chapter.
14946 * Standard I/O Packages::
14952 * Wide_Wide_Text_IO::
14954 * Text Translation::
14956 * Filenames encoding::
14958 * Operations on C Streams::
14959 * Interfacing to C Streams::
14962 @node Standard I/O Packages
14963 @section Standard I/O Packages
14966 The Standard I/O packages described in Annex A for
14972 Ada.Text_IO.Complex_IO
14974 Ada.Text_IO.Text_Streams
14978 Ada.Wide_Text_IO.Complex_IO
14980 Ada.Wide_Text_IO.Text_Streams
14982 Ada.Wide_Wide_Text_IO
14984 Ada.Wide_Wide_Text_IO.Complex_IO
14986 Ada.Wide_Wide_Text_IO.Text_Streams
14996 are implemented using the C
14997 library streams facility; where
15001 All files are opened using @code{fopen}.
15003 All input/output operations use @code{fread}/@code{fwrite}.
15007 There is no internal buffering of any kind at the Ada library level. The only
15008 buffering is that provided at the system level in the implementation of the
15009 library routines that support streams. This facilitates shared use of these
15010 streams by mixed language programs. Note though that system level buffering is
15011 explicitly enabled at elaboration of the standard I/O packages and that can
15012 have an impact on mixed language programs, in particular those using I/O before
15013 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
15014 the Ada elaboration routine before performing any I/O or when impractical,
15015 flush the common I/O streams and in particular Standard_Output before
15016 elaborating the Ada code.
15019 @section FORM Strings
15022 The format of a FORM string in GNAT is:
15025 "keyword=value,keyword=value,@dots{},keyword=value"
15029 where letters may be in upper or lower case, and there are no spaces
15030 between values. The order of the entries is not important. Currently
15031 the following keywords defined.
15034 TEXT_TRANSLATION=[YES|NO]
15036 WCEM=[n|h|u|s|e|8|b]
15037 ENCODING=[UTF8|8BITS]
15041 The use of these parameters is described later in this section. If an
15042 unrecognized keyword appears in a form string, it is silently ignored
15043 and not considered invalid.
15046 For OpenVMS additional FORM string keywords are available for use with
15047 RMS services. The syntax is:
15050 VMS_RMS_Keys=(keyword=value,@dots{},keyword=value)
15054 The following RMS keywords and values are currently defined:
15057 Context=Force_Stream_Mode|Force_Record_Mode
15061 VMS RMS keys are silently ignored on non-VMS systems. On OpenVMS
15062 unimplented RMS keywords, values, or invalid syntax will raise Use_Error.
15068 Direct_IO can only be instantiated for definite types. This is a
15069 restriction of the Ada language, which means that the records are fixed
15070 length (the length being determined by @code{@var{type}'Size}, rounded
15071 up to the next storage unit boundary if necessary).
15073 The records of a Direct_IO file are simply written to the file in index
15074 sequence, with the first record starting at offset zero, and subsequent
15075 records following. There is no control information of any kind. For
15076 example, if 32-bit integers are being written, each record takes
15077 4-bytes, so the record at index @var{K} starts at offset
15078 (@var{K}@minus{}1)*4.
15080 There is no limit on the size of Direct_IO files, they are expanded as
15081 necessary to accommodate whatever records are written to the file.
15083 @node Sequential_IO
15084 @section Sequential_IO
15087 Sequential_IO may be instantiated with either a definite (constrained)
15088 or indefinite (unconstrained) type.
15090 For the definite type case, the elements written to the file are simply
15091 the memory images of the data values with no control information of any
15092 kind. The resulting file should be read using the same type, no validity
15093 checking is performed on input.
15095 For the indefinite type case, the elements written consist of two
15096 parts. First is the size of the data item, written as the memory image
15097 of a @code{Interfaces.C.size_t} value, followed by the memory image of
15098 the data value. The resulting file can only be read using the same
15099 (unconstrained) type. Normal assignment checks are performed on these
15100 read operations, and if these checks fail, @code{Data_Error} is
15101 raised. In particular, in the array case, the lengths must match, and in
15102 the variant record case, if the variable for a particular read operation
15103 is constrained, the discriminants must match.
15105 Note that it is not possible to use Sequential_IO to write variable
15106 length array items, and then read the data back into different length
15107 arrays. For example, the following will raise @code{Data_Error}:
15109 @smallexample @c ada
15110 package IO is new Sequential_IO (String);
15115 IO.Write (F, "hello!")
15116 IO.Reset (F, Mode=>In_File);
15123 On some Ada implementations, this will print @code{hell}, but the program is
15124 clearly incorrect, since there is only one element in the file, and that
15125 element is the string @code{hello!}.
15127 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
15128 using Stream_IO, and this is the preferred mechanism. In particular, the
15129 above program fragment rewritten to use Stream_IO will work correctly.
15135 Text_IO files consist of a stream of characters containing the following
15136 special control characters:
15139 LF (line feed, 16#0A#) Line Mark
15140 FF (form feed, 16#0C#) Page Mark
15144 A canonical Text_IO file is defined as one in which the following
15145 conditions are met:
15149 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
15153 The character @code{FF} is used only as a page mark, i.e.@: to mark the
15154 end of a page and consequently can appear only immediately following a
15155 @code{LF} (line mark) character.
15158 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
15159 (line mark, page mark). In the former case, the page mark is implicitly
15160 assumed to be present.
15164 A file written using Text_IO will be in canonical form provided that no
15165 explicit @code{LF} or @code{FF} characters are written using @code{Put}
15166 or @code{Put_Line}. There will be no @code{FF} character at the end of
15167 the file unless an explicit @code{New_Page} operation was performed
15168 before closing the file.
15170 A canonical Text_IO file that is a regular file (i.e., not a device or a
15171 pipe) can be read using any of the routines in Text_IO@. The
15172 semantics in this case will be exactly as defined in the Ada Reference
15173 Manual, and all the routines in Text_IO are fully implemented.
15175 A text file that does not meet the requirements for a canonical Text_IO
15176 file has one of the following:
15180 The file contains @code{FF} characters not immediately following a
15181 @code{LF} character.
15184 The file contains @code{LF} or @code{FF} characters written by
15185 @code{Put} or @code{Put_Line}, which are not logically considered to be
15186 line marks or page marks.
15189 The file ends in a character other than @code{LF} or @code{FF},
15190 i.e.@: there is no explicit line mark or page mark at the end of the file.
15194 Text_IO can be used to read such non-standard text files but subprograms
15195 to do with line or page numbers do not have defined meanings. In
15196 particular, a @code{FF} character that does not follow a @code{LF}
15197 character may or may not be treated as a page mark from the point of
15198 view of page and line numbering. Every @code{LF} character is considered
15199 to end a line, and there is an implied @code{LF} character at the end of
15203 * Text_IO Stream Pointer Positioning::
15204 * Text_IO Reading and Writing Non-Regular Files::
15206 * Treating Text_IO Files as Streams::
15207 * Text_IO Extensions::
15208 * Text_IO Facilities for Unbounded Strings::
15211 @node Text_IO Stream Pointer Positioning
15212 @subsection Stream Pointer Positioning
15215 @code{Ada.Text_IO} has a definition of current position for a file that
15216 is being read. No internal buffering occurs in Text_IO, and usually the
15217 physical position in the stream used to implement the file corresponds
15218 to this logical position defined by Text_IO@. There are two exceptions:
15222 After a call to @code{End_Of_Page} that returns @code{True}, the stream
15223 is positioned past the @code{LF} (line mark) that precedes the page
15224 mark. Text_IO maintains an internal flag so that subsequent read
15225 operations properly handle the logical position which is unchanged by
15226 the @code{End_Of_Page} call.
15229 After a call to @code{End_Of_File} that returns @code{True}, if the
15230 Text_IO file was positioned before the line mark at the end of file
15231 before the call, then the logical position is unchanged, but the stream
15232 is physically positioned right at the end of file (past the line mark,
15233 and past a possible page mark following the line mark. Again Text_IO
15234 maintains internal flags so that subsequent read operations properly
15235 handle the logical position.
15239 These discrepancies have no effect on the observable behavior of
15240 Text_IO, but if a single Ada stream is shared between a C program and
15241 Ada program, or shared (using @samp{shared=yes} in the form string)
15242 between two Ada files, then the difference may be observable in some
15245 @node Text_IO Reading and Writing Non-Regular Files
15246 @subsection Reading and Writing Non-Regular Files
15249 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
15250 can be used for reading and writing. Writing is not affected and the
15251 sequence of characters output is identical to the normal file case, but
15252 for reading, the behavior of Text_IO is modified to avoid undesirable
15253 look-ahead as follows:
15255 An input file that is not a regular file is considered to have no page
15256 marks. Any @code{Ascii.FF} characters (the character normally used for a
15257 page mark) appearing in the file are considered to be data
15258 characters. In particular:
15262 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
15263 following a line mark. If a page mark appears, it will be treated as a
15267 This avoids the need to wait for an extra character to be typed or
15268 entered from the pipe to complete one of these operations.
15271 @code{End_Of_Page} always returns @code{False}
15274 @code{End_Of_File} will return @code{False} if there is a page mark at
15275 the end of the file.
15279 Output to non-regular files is the same as for regular files. Page marks
15280 may be written to non-regular files using @code{New_Page}, but as noted
15281 above they will not be treated as page marks on input if the output is
15282 piped to another Ada program.
15284 Another important discrepancy when reading non-regular files is that the end
15285 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
15286 pressing the @key{EOT} key,
15288 is signaled once (i.e.@: the test @code{End_Of_File}
15289 will yield @code{True}, or a read will
15290 raise @code{End_Error}), but then reading can resume
15291 to read data past that end of
15292 file indication, until another end of file indication is entered.
15294 @node Get_Immediate
15295 @subsection Get_Immediate
15296 @cindex Get_Immediate
15299 Get_Immediate returns the next character (including control characters)
15300 from the input file. In particular, Get_Immediate will return LF or FF
15301 characters used as line marks or page marks. Such operations leave the
15302 file positioned past the control character, and it is thus not treated
15303 as having its normal function. This means that page, line and column
15304 counts after this kind of Get_Immediate call are set as though the mark
15305 did not occur. In the case where a Get_Immediate leaves the file
15306 positioned between the line mark and page mark (which is not normally
15307 possible), it is undefined whether the FF character will be treated as a
15310 @node Treating Text_IO Files as Streams
15311 @subsection Treating Text_IO Files as Streams
15312 @cindex Stream files
15315 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
15316 as a stream. Data written to a Text_IO file in this stream mode is
15317 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
15318 16#0C# (@code{FF}), the resulting file may have non-standard
15319 format. Similarly if read operations are used to read from a Text_IO
15320 file treated as a stream, then @code{LF} and @code{FF} characters may be
15321 skipped and the effect is similar to that described above for
15322 @code{Get_Immediate}.
15324 @node Text_IO Extensions
15325 @subsection Text_IO Extensions
15326 @cindex Text_IO extensions
15329 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
15330 to the standard @code{Text_IO} package:
15333 @item function File_Exists (Name : String) return Boolean;
15334 Determines if a file of the given name exists.
15336 @item function Get_Line return String;
15337 Reads a string from the standard input file. The value returned is exactly
15338 the length of the line that was read.
15340 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
15341 Similar, except that the parameter File specifies the file from which
15342 the string is to be read.
15346 @node Text_IO Facilities for Unbounded Strings
15347 @subsection Text_IO Facilities for Unbounded Strings
15348 @cindex Text_IO for unbounded strings
15349 @cindex Unbounded_String, Text_IO operations
15352 The package @code{Ada.Strings.Unbounded.Text_IO}
15353 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
15354 subprograms useful for Text_IO operations on unbounded strings:
15358 @item function Get_Line (File : File_Type) return Unbounded_String;
15359 Reads a line from the specified file
15360 and returns the result as an unbounded string.
15362 @item procedure Put (File : File_Type; U : Unbounded_String);
15363 Writes the value of the given unbounded string to the specified file
15364 Similar to the effect of
15365 @code{Put (To_String (U))} except that an extra copy is avoided.
15367 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
15368 Writes the value of the given unbounded string to the specified file,
15369 followed by a @code{New_Line}.
15370 Similar to the effect of @code{Put_Line (To_String (U))} except
15371 that an extra copy is avoided.
15375 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
15376 and is optional. If the parameter is omitted, then the standard input or
15377 output file is referenced as appropriate.
15379 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
15380 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
15381 @code{Wide_Text_IO} functionality for unbounded wide strings.
15383 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
15384 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
15385 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
15388 @section Wide_Text_IO
15391 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
15392 both input and output files may contain special sequences that represent
15393 wide character values. The encoding scheme for a given file may be
15394 specified using a FORM parameter:
15401 as part of the FORM string (WCEM = wide character encoding method),
15402 where @var{x} is one of the following characters
15408 Upper half encoding
15420 The encoding methods match those that
15421 can be used in a source
15422 program, but there is no requirement that the encoding method used for
15423 the source program be the same as the encoding method used for files,
15424 and different files may use different encoding methods.
15426 The default encoding method for the standard files, and for opened files
15427 for which no WCEM parameter is given in the FORM string matches the
15428 wide character encoding specified for the main program (the default
15429 being brackets encoding if no coding method was specified with -gnatW).
15433 In this encoding, a wide character is represented by a five character
15441 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
15442 characters (using upper case letters) of the wide character code. For
15443 example, ESC A345 is used to represent the wide character with code
15444 16#A345#. This scheme is compatible with use of the full
15445 @code{Wide_Character} set.
15447 @item Upper Half Coding
15448 The wide character with encoding 16#abcd#, where the upper bit is on
15449 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
15450 16#cd#. The second byte may never be a format control character, but is
15451 not required to be in the upper half. This method can be also used for
15452 shift-JIS or EUC where the internal coding matches the external coding.
15454 @item Shift JIS Coding
15455 A wide character is represented by a two character sequence 16#ab# and
15456 16#cd#, with the restrictions described for upper half encoding as
15457 described above. The internal character code is the corresponding JIS
15458 character according to the standard algorithm for Shift-JIS
15459 conversion. Only characters defined in the JIS code set table can be
15460 used with this encoding method.
15463 A wide character is represented by a two character sequence 16#ab# and
15464 16#cd#, with both characters being in the upper half. The internal
15465 character code is the corresponding JIS character according to the EUC
15466 encoding algorithm. Only characters defined in the JIS code set table
15467 can be used with this encoding method.
15470 A wide character is represented using
15471 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
15472 10646-1/Am.2. Depending on the character value, the representation
15473 is a one, two, or three byte sequence:
15476 16#0000#-16#007f#: 2#0xxxxxxx#
15477 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
15478 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
15482 where the @var{xxx} bits correspond to the left-padded bits of the
15483 16-bit character value. Note that all lower half ASCII characters
15484 are represented as ASCII bytes and all upper half characters and
15485 other wide characters are represented as sequences of upper-half
15486 (The full UTF-8 scheme allows for encoding 31-bit characters as
15487 6-byte sequences, but in this implementation, all UTF-8 sequences
15488 of four or more bytes length will raise a Constraint_Error, as
15489 will all invalid UTF-8 sequences.)
15491 @item Brackets Coding
15492 In this encoding, a wide character is represented by the following eight
15493 character sequence:
15500 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
15501 characters (using uppercase letters) of the wide character code. For
15502 example, @code{["A345"]} is used to represent the wide character with code
15504 This scheme is compatible with use of the full Wide_Character set.
15505 On input, brackets coding can also be used for upper half characters,
15506 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
15507 is only used for wide characters with a code greater than @code{16#FF#}.
15509 Note that brackets coding is not normally used in the context of
15510 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
15511 a portable way of encoding source files. In the context of Wide_Text_IO
15512 or Wide_Wide_Text_IO, it can only be used if the file does not contain
15513 any instance of the left bracket character other than to encode wide
15514 character values using the brackets encoding method. In practice it is
15515 expected that some standard wide character encoding method such
15516 as UTF-8 will be used for text input output.
15518 If brackets notation is used, then any occurrence of a left bracket
15519 in the input file which is not the start of a valid wide character
15520 sequence will cause Constraint_Error to be raised. It is possible to
15521 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
15522 input will interpret this as a left bracket.
15524 However, when a left bracket is output, it will be output as a left bracket
15525 and not as ["5B"]. We make this decision because for normal use of
15526 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
15527 brackets. For example, if we write:
15530 Put_Line ("Start of output [first run]");
15534 we really do not want to have the left bracket in this message clobbered so
15535 that the output reads:
15538 Start of output ["5B"]first run]
15542 In practice brackets encoding is reasonably useful for normal Put_Line use
15543 since we won't get confused between left brackets and wide character
15544 sequences in the output. But for input, or when files are written out
15545 and read back in, it really makes better sense to use one of the standard
15546 encoding methods such as UTF-8.
15551 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
15552 not all wide character
15553 values can be represented. An attempt to output a character that cannot
15554 be represented using the encoding scheme for the file causes
15555 Constraint_Error to be raised. An invalid wide character sequence on
15556 input also causes Constraint_Error to be raised.
15559 * Wide_Text_IO Stream Pointer Positioning::
15560 * Wide_Text_IO Reading and Writing Non-Regular Files::
15563 @node Wide_Text_IO Stream Pointer Positioning
15564 @subsection Stream Pointer Positioning
15567 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
15568 of stream pointer positioning (@pxref{Text_IO}). There is one additional
15571 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
15572 normal lower ASCII set (i.e.@: a character in the range:
15574 @smallexample @c ada
15575 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
15579 then although the logical position of the file pointer is unchanged by
15580 the @code{Look_Ahead} call, the stream is physically positioned past the
15581 wide character sequence. Again this is to avoid the need for buffering
15582 or backup, and all @code{Wide_Text_IO} routines check the internal
15583 indication that this situation has occurred so that this is not visible
15584 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
15585 can be observed if the wide text file shares a stream with another file.
15587 @node Wide_Text_IO Reading and Writing Non-Regular Files
15588 @subsection Reading and Writing Non-Regular Files
15591 As in the case of Text_IO, when a non-regular file is read, it is
15592 assumed that the file contains no page marks (any form characters are
15593 treated as data characters), and @code{End_Of_Page} always returns
15594 @code{False}. Similarly, the end of file indication is not sticky, so
15595 it is possible to read beyond an end of file.
15597 @node Wide_Wide_Text_IO
15598 @section Wide_Wide_Text_IO
15601 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
15602 both input and output files may contain special sequences that represent
15603 wide wide character values. The encoding scheme for a given file may be
15604 specified using a FORM parameter:
15611 as part of the FORM string (WCEM = wide character encoding method),
15612 where @var{x} is one of the following characters
15618 Upper half encoding
15630 The encoding methods match those that
15631 can be used in a source
15632 program, but there is no requirement that the encoding method used for
15633 the source program be the same as the encoding method used for files,
15634 and different files may use different encoding methods.
15636 The default encoding method for the standard files, and for opened files
15637 for which no WCEM parameter is given in the FORM string matches the
15638 wide character encoding specified for the main program (the default
15639 being brackets encoding if no coding method was specified with -gnatW).
15644 A wide character is represented using
15645 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
15646 10646-1/Am.2. Depending on the character value, the representation
15647 is a one, two, three, or four byte sequence:
15650 16#000000#-16#00007f#: 2#0xxxxxxx#
15651 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
15652 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
15653 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
15657 where the @var{xxx} bits correspond to the left-padded bits of the
15658 21-bit character value. Note that all lower half ASCII characters
15659 are represented as ASCII bytes and all upper half characters and
15660 other wide characters are represented as sequences of upper-half
15663 @item Brackets Coding
15664 In this encoding, a wide wide character is represented by the following eight
15665 character sequence if is in wide character range
15671 and by the following ten character sequence if not
15674 [ " a b c d e f " ]
15678 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
15679 are the four or six hexadecimal
15680 characters (using uppercase letters) of the wide wide character code. For
15681 example, @code{["01A345"]} is used to represent the wide wide character
15682 with code @code{16#01A345#}.
15684 This scheme is compatible with use of the full Wide_Wide_Character set.
15685 On input, brackets coding can also be used for upper half characters,
15686 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
15687 is only used for wide characters with a code greater than @code{16#FF#}.
15692 If is also possible to use the other Wide_Character encoding methods,
15693 such as Shift-JIS, but the other schemes cannot support the full range
15694 of wide wide characters.
15695 An attempt to output a character that cannot
15696 be represented using the encoding scheme for the file causes
15697 Constraint_Error to be raised. An invalid wide character sequence on
15698 input also causes Constraint_Error to be raised.
15701 * Wide_Wide_Text_IO Stream Pointer Positioning::
15702 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
15705 @node Wide_Wide_Text_IO Stream Pointer Positioning
15706 @subsection Stream Pointer Positioning
15709 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
15710 of stream pointer positioning (@pxref{Text_IO}). There is one additional
15713 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
15714 normal lower ASCII set (i.e.@: a character in the range:
15716 @smallexample @c ada
15717 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
15721 then although the logical position of the file pointer is unchanged by
15722 the @code{Look_Ahead} call, the stream is physically positioned past the
15723 wide character sequence. Again this is to avoid the need for buffering
15724 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
15725 indication that this situation has occurred so that this is not visible
15726 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
15727 can be observed if the wide text file shares a stream with another file.
15729 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
15730 @subsection Reading and Writing Non-Regular Files
15733 As in the case of Text_IO, when a non-regular file is read, it is
15734 assumed that the file contains no page marks (any form characters are
15735 treated as data characters), and @code{End_Of_Page} always returns
15736 @code{False}. Similarly, the end of file indication is not sticky, so
15737 it is possible to read beyond an end of file.
15743 A stream file is a sequence of bytes, where individual elements are
15744 written to the file as described in the Ada Reference Manual. The type
15745 @code{Stream_Element} is simply a byte. There are two ways to read or
15746 write a stream file.
15750 The operations @code{Read} and @code{Write} directly read or write a
15751 sequence of stream elements with no control information.
15754 The stream attributes applied to a stream file transfer data in the
15755 manner described for stream attributes.
15758 @node Text Translation
15759 @section Text Translation
15762 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
15763 passed to Text_IO.Create and Text_IO.Open:
15764 @samp{Text_Translation=@var{Yes}} is the default, which means to
15765 translate LF to/from CR/LF on Windows systems.
15766 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
15767 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
15768 may be used to create Unix-style files on
15769 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
15773 @section Shared Files
15776 Section A.14 of the Ada Reference Manual allows implementations to
15777 provide a wide variety of behavior if an attempt is made to access the
15778 same external file with two or more internal files.
15780 To provide a full range of functionality, while at the same time
15781 minimizing the problems of portability caused by this implementation
15782 dependence, GNAT handles file sharing as follows:
15786 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
15787 to open two or more files with the same full name is considered an error
15788 and is not supported. The exception @code{Use_Error} will be
15789 raised. Note that a file that is not explicitly closed by the program
15790 remains open until the program terminates.
15793 If the form parameter @samp{shared=no} appears in the form string, the
15794 file can be opened or created with its own separate stream identifier,
15795 regardless of whether other files sharing the same external file are
15796 opened. The exact effect depends on how the C stream routines handle
15797 multiple accesses to the same external files using separate streams.
15800 If the form parameter @samp{shared=yes} appears in the form string for
15801 each of two or more files opened using the same full name, the same
15802 stream is shared between these files, and the semantics are as described
15803 in Ada Reference Manual, Section A.14.
15807 When a program that opens multiple files with the same name is ported
15808 from another Ada compiler to GNAT, the effect will be that
15809 @code{Use_Error} is raised.
15811 The documentation of the original compiler and the documentation of the
15812 program should then be examined to determine if file sharing was
15813 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
15814 and @code{Create} calls as required.
15816 When a program is ported from GNAT to some other Ada compiler, no
15817 special attention is required unless the @samp{shared=@var{xxx}} form
15818 parameter is used in the program. In this case, you must examine the
15819 documentation of the new compiler to see if it supports the required
15820 file sharing semantics, and form strings modified appropriately. Of
15821 course it may be the case that the program cannot be ported if the
15822 target compiler does not support the required functionality. The best
15823 approach in writing portable code is to avoid file sharing (and hence
15824 the use of the @samp{shared=@var{xxx}} parameter in the form string)
15827 One common use of file sharing in Ada 83 is the use of instantiations of
15828 Sequential_IO on the same file with different types, to achieve
15829 heterogeneous input-output. Although this approach will work in GNAT if
15830 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
15831 for this purpose (using the stream attributes)
15833 @node Filenames encoding
15834 @section Filenames encoding
15837 An encoding form parameter can be used to specify the filename
15838 encoding @samp{encoding=@var{xxx}}.
15842 If the form parameter @samp{encoding=utf8} appears in the form string, the
15843 filename must be encoded in UTF-8.
15846 If the form parameter @samp{encoding=8bits} appears in the form
15847 string, the filename must be a standard 8bits string.
15850 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
15851 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
15852 variable. And if not set @samp{utf8} is assumed.
15856 The current system Windows ANSI code page.
15861 This encoding form parameter is only supported on the Windows
15862 platform. On the other Operating Systems the run-time is supporting
15866 @section Open Modes
15869 @code{Open} and @code{Create} calls result in a call to @code{fopen}
15870 using the mode shown in the following table:
15873 @center @code{Open} and @code{Create} Call Modes
15875 @b{OPEN } @b{CREATE}
15876 Append_File "r+" "w+"
15878 Out_File (Direct_IO) "r+" "w"
15879 Out_File (all other cases) "w" "w"
15880 Inout_File "r+" "w+"
15884 If text file translation is required, then either @samp{b} or @samp{t}
15885 is added to the mode, depending on the setting of Text. Text file
15886 translation refers to the mapping of CR/LF sequences in an external file
15887 to LF characters internally. This mapping only occurs in DOS and
15888 DOS-like systems, and is not relevant to other systems.
15890 A special case occurs with Stream_IO@. As shown in the above table, the
15891 file is initially opened in @samp{r} or @samp{w} mode for the
15892 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
15893 subsequently requires switching from reading to writing or vice-versa,
15894 then the file is reopened in @samp{r+} mode to permit the required operation.
15896 @node Operations on C Streams
15897 @section Operations on C Streams
15898 The package @code{Interfaces.C_Streams} provides an Ada program with direct
15899 access to the C library functions for operations on C streams:
15901 @smallexample @c adanocomment
15902 package Interfaces.C_Streams is
15903 -- Note: the reason we do not use the types that are in
15904 -- Interfaces.C is that we want to avoid dragging in the
15905 -- code in this unit if possible.
15906 subtype chars is System.Address;
15907 -- Pointer to null-terminated array of characters
15908 subtype FILEs is System.Address;
15909 -- Corresponds to the C type FILE*
15910 subtype voids is System.Address;
15911 -- Corresponds to the C type void*
15912 subtype int is Integer;
15913 subtype long is Long_Integer;
15914 -- Note: the above types are subtypes deliberately, and it
15915 -- is part of this spec that the above correspondences are
15916 -- guaranteed. This means that it is legitimate to, for
15917 -- example, use Integer instead of int. We provide these
15918 -- synonyms for clarity, but in some cases it may be
15919 -- convenient to use the underlying types (for example to
15920 -- avoid an unnecessary dependency of a spec on the spec
15922 type size_t is mod 2 ** Standard'Address_Size;
15923 NULL_Stream : constant FILEs;
15924 -- Value returned (NULL in C) to indicate an
15925 -- fdopen/fopen/tmpfile error
15926 ----------------------------------
15927 -- Constants Defined in stdio.h --
15928 ----------------------------------
15929 EOF : constant int;
15930 -- Used by a number of routines to indicate error or
15932 IOFBF : constant int;
15933 IOLBF : constant int;
15934 IONBF : constant int;
15935 -- Used to indicate buffering mode for setvbuf call
15936 SEEK_CUR : constant int;
15937 SEEK_END : constant int;
15938 SEEK_SET : constant int;
15939 -- Used to indicate origin for fseek call
15940 function stdin return FILEs;
15941 function stdout return FILEs;
15942 function stderr return FILEs;
15943 -- Streams associated with standard files
15944 --------------------------
15945 -- Standard C functions --
15946 --------------------------
15947 -- The functions selected below are ones that are
15948 -- available in UNIX (but not necessarily in ANSI C).
15949 -- These are very thin interfaces
15950 -- which copy exactly the C headers. For more
15951 -- documentation on these functions, see the Microsoft C
15952 -- "Run-Time Library Reference" (Microsoft Press, 1990,
15953 -- ISBN 1-55615-225-6), which includes useful information
15954 -- on system compatibility.
15955 procedure clearerr (stream : FILEs);
15956 function fclose (stream : FILEs) return int;
15957 function fdopen (handle : int; mode : chars) return FILEs;
15958 function feof (stream : FILEs) return int;
15959 function ferror (stream : FILEs) return int;
15960 function fflush (stream : FILEs) return int;
15961 function fgetc (stream : FILEs) return int;
15962 function fgets (strng : chars; n : int; stream : FILEs)
15964 function fileno (stream : FILEs) return int;
15965 function fopen (filename : chars; Mode : chars)
15967 -- Note: to maintain target independence, use
15968 -- text_translation_required, a boolean variable defined in
15969 -- a-sysdep.c to deal with the target dependent text
15970 -- translation requirement. If this variable is set,
15971 -- then b/t should be appended to the standard mode
15972 -- argument to set the text translation mode off or on
15974 function fputc (C : int; stream : FILEs) return int;
15975 function fputs (Strng : chars; Stream : FILEs) return int;
15992 function ftell (stream : FILEs) return long;
15999 function isatty (handle : int) return int;
16000 procedure mktemp (template : chars);
16001 -- The return value (which is just a pointer to template)
16003 procedure rewind (stream : FILEs);
16004 function rmtmp return int;
16012 function tmpfile return FILEs;
16013 function ungetc (c : int; stream : FILEs) return int;
16014 function unlink (filename : chars) return int;
16015 ---------------------
16016 -- Extra functions --
16017 ---------------------
16018 -- These functions supply slightly thicker bindings than
16019 -- those above. They are derived from functions in the
16020 -- C Run-Time Library, but may do a bit more work than
16021 -- just directly calling one of the Library functions.
16022 function is_regular_file (handle : int) return int;
16023 -- Tests if given handle is for a regular file (result 1)
16024 -- or for a non-regular file (pipe or device, result 0).
16025 ---------------------------------
16026 -- Control of Text/Binary Mode --
16027 ---------------------------------
16028 -- If text_translation_required is true, then the following
16029 -- functions may be used to dynamically switch a file from
16030 -- binary to text mode or vice versa. These functions have
16031 -- no effect if text_translation_required is false (i.e.@: in
16032 -- normal UNIX mode). Use fileno to get a stream handle.
16033 procedure set_binary_mode (handle : int);
16034 procedure set_text_mode (handle : int);
16035 ----------------------------
16036 -- Full Path Name support --
16037 ----------------------------
16038 procedure full_name (nam : chars; buffer : chars);
16039 -- Given a NUL terminated string representing a file
16040 -- name, returns in buffer a NUL terminated string
16041 -- representing the full path name for the file name.
16042 -- On systems where it is relevant the drive is also
16043 -- part of the full path name. It is the responsibility
16044 -- of the caller to pass an actual parameter for buffer
16045 -- that is big enough for any full path name. Use
16046 -- max_path_len given below as the size of buffer.
16047 max_path_len : integer;
16048 -- Maximum length of an allowable full path name on the
16049 -- system, including a terminating NUL character.
16050 end Interfaces.C_Streams;
16053 @node Interfacing to C Streams
16054 @section Interfacing to C Streams
16057 The packages in this section permit interfacing Ada files to C Stream
16060 @smallexample @c ada
16061 with Interfaces.C_Streams;
16062 package Ada.Sequential_IO.C_Streams is
16063 function C_Stream (F : File_Type)
16064 return Interfaces.C_Streams.FILEs;
16066 (File : in out File_Type;
16067 Mode : in File_Mode;
16068 C_Stream : in Interfaces.C_Streams.FILEs;
16069 Form : in String := "");
16070 end Ada.Sequential_IO.C_Streams;
16072 with Interfaces.C_Streams;
16073 package Ada.Direct_IO.C_Streams is
16074 function C_Stream (F : File_Type)
16075 return Interfaces.C_Streams.FILEs;
16077 (File : in out File_Type;
16078 Mode : in File_Mode;
16079 C_Stream : in Interfaces.C_Streams.FILEs;
16080 Form : in String := "");
16081 end Ada.Direct_IO.C_Streams;
16083 with Interfaces.C_Streams;
16084 package Ada.Text_IO.C_Streams is
16085 function C_Stream (F : File_Type)
16086 return Interfaces.C_Streams.FILEs;
16088 (File : in out File_Type;
16089 Mode : in File_Mode;
16090 C_Stream : in Interfaces.C_Streams.FILEs;
16091 Form : in String := "");
16092 end Ada.Text_IO.C_Streams;
16094 with Interfaces.C_Streams;
16095 package Ada.Wide_Text_IO.C_Streams is
16096 function C_Stream (F : File_Type)
16097 return Interfaces.C_Streams.FILEs;
16099 (File : in out File_Type;
16100 Mode : in File_Mode;
16101 C_Stream : in Interfaces.C_Streams.FILEs;
16102 Form : in String := "");
16103 end Ada.Wide_Text_IO.C_Streams;
16105 with Interfaces.C_Streams;
16106 package Ada.Wide_Wide_Text_IO.C_Streams is
16107 function C_Stream (F : File_Type)
16108 return Interfaces.C_Streams.FILEs;
16110 (File : in out File_Type;
16111 Mode : in File_Mode;
16112 C_Stream : in Interfaces.C_Streams.FILEs;
16113 Form : in String := "");
16114 end Ada.Wide_Wide_Text_IO.C_Streams;
16116 with Interfaces.C_Streams;
16117 package Ada.Stream_IO.C_Streams is
16118 function C_Stream (F : File_Type)
16119 return Interfaces.C_Streams.FILEs;
16121 (File : in out File_Type;
16122 Mode : in File_Mode;
16123 C_Stream : in Interfaces.C_Streams.FILEs;
16124 Form : in String := "");
16125 end Ada.Stream_IO.C_Streams;
16129 In each of these six packages, the @code{C_Stream} function obtains the
16130 @code{FILE} pointer from a currently opened Ada file. It is then
16131 possible to use the @code{Interfaces.C_Streams} package to operate on
16132 this stream, or the stream can be passed to a C program which can
16133 operate on it directly. Of course the program is responsible for
16134 ensuring that only appropriate sequences of operations are executed.
16136 One particular use of relevance to an Ada program is that the
16137 @code{setvbuf} function can be used to control the buffering of the
16138 stream used by an Ada file. In the absence of such a call the standard
16139 default buffering is used.
16141 The @code{Open} procedures in these packages open a file giving an
16142 existing C Stream instead of a file name. Typically this stream is
16143 imported from a C program, allowing an Ada file to operate on an
16146 @node The GNAT Library
16147 @chapter The GNAT Library
16150 The GNAT library contains a number of general and special purpose packages.
16151 It represents functionality that the GNAT developers have found useful, and
16152 which is made available to GNAT users. The packages described here are fully
16153 supported, and upwards compatibility will be maintained in future releases,
16154 so you can use these facilities with the confidence that the same functionality
16155 will be available in future releases.
16157 The chapter here simply gives a brief summary of the facilities available.
16158 The full documentation is found in the spec file for the package. The full
16159 sources of these library packages, including both spec and body, are provided
16160 with all GNAT releases. For example, to find out the full specifications of
16161 the SPITBOL pattern matching capability, including a full tutorial and
16162 extensive examples, look in the @file{g-spipat.ads} file in the library.
16164 For each entry here, the package name (as it would appear in a @code{with}
16165 clause) is given, followed by the name of the corresponding spec file in
16166 parentheses. The packages are children in four hierarchies, @code{Ada},
16167 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
16168 GNAT-specific hierarchy.
16170 Note that an application program should only use packages in one of these
16171 four hierarchies if the package is defined in the Ada Reference Manual,
16172 or is listed in this section of the GNAT Programmers Reference Manual.
16173 All other units should be considered internal implementation units and
16174 should not be directly @code{with}'ed by application code. The use of
16175 a @code{with} statement that references one of these internal implementation
16176 units makes an application potentially dependent on changes in versions
16177 of GNAT, and will generate a warning message.
16180 * Ada.Characters.Latin_9 (a-chlat9.ads)::
16181 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
16182 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
16183 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
16184 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
16185 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
16186 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
16187 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
16188 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
16189 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
16190 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
16191 * Ada.Command_Line.Environment (a-colien.ads)::
16192 * Ada.Command_Line.Remove (a-colire.ads)::
16193 * Ada.Command_Line.Response_File (a-clrefi.ads)::
16194 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
16195 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
16196 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
16197 * Ada.Exceptions.Traceback (a-exctra.ads)::
16198 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
16199 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
16200 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
16201 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
16202 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
16203 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
16204 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
16205 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
16206 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
16207 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
16208 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
16209 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
16210 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
16211 * GNAT.Altivec (g-altive.ads)::
16212 * GNAT.Altivec.Conversions (g-altcon.ads)::
16213 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
16214 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
16215 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
16216 * GNAT.Array_Split (g-arrspl.ads)::
16217 * GNAT.AWK (g-awk.ads)::
16218 * GNAT.Bounded_Buffers (g-boubuf.ads)::
16219 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
16220 * GNAT.Bubble_Sort (g-bubsor.ads)::
16221 * GNAT.Bubble_Sort_A (g-busora.ads)::
16222 * GNAT.Bubble_Sort_G (g-busorg.ads)::
16223 * GNAT.Byte_Order_Mark (g-byorma.ads)::
16224 * GNAT.Byte_Swapping (g-bytswa.ads)::
16225 * GNAT.Calendar (g-calend.ads)::
16226 * GNAT.Calendar.Time_IO (g-catiio.ads)::
16227 * GNAT.Case_Util (g-casuti.ads)::
16228 * GNAT.CGI (g-cgi.ads)::
16229 * GNAT.CGI.Cookie (g-cgicoo.ads)::
16230 * GNAT.CGI.Debug (g-cgideb.ads)::
16231 * GNAT.Command_Line (g-comlin.ads)::
16232 * GNAT.Compiler_Version (g-comver.ads)::
16233 * GNAT.Ctrl_C (g-ctrl_c.ads)::
16234 * GNAT.CRC32 (g-crc32.ads)::
16235 * GNAT.Current_Exception (g-curexc.ads)::
16236 * GNAT.Debug_Pools (g-debpoo.ads)::
16237 * GNAT.Debug_Utilities (g-debuti.ads)::
16238 * GNAT.Decode_String (g-decstr.ads)::
16239 * GNAT.Decode_UTF8_String (g-deutst.ads)::
16240 * GNAT.Directory_Operations (g-dirope.ads)::
16241 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
16242 * GNAT.Dynamic_HTables (g-dynhta.ads)::
16243 * GNAT.Dynamic_Tables (g-dyntab.ads)::
16244 * GNAT.Encode_String (g-encstr.ads)::
16245 * GNAT.Encode_UTF8_String (g-enutst.ads)::
16246 * GNAT.Exception_Actions (g-excact.ads)::
16247 * GNAT.Exception_Traces (g-exctra.ads)::
16248 * GNAT.Exceptions (g-except.ads)::
16249 * GNAT.Expect (g-expect.ads)::
16250 * GNAT.Expect.TTY (g-exptty.ads)::
16251 * GNAT.Float_Control (g-flocon.ads)::
16252 * GNAT.Heap_Sort (g-heasor.ads)::
16253 * GNAT.Heap_Sort_A (g-hesora.ads)::
16254 * GNAT.Heap_Sort_G (g-hesorg.ads)::
16255 * GNAT.HTable (g-htable.ads)::
16256 * GNAT.IO (g-io.ads)::
16257 * GNAT.IO_Aux (g-io_aux.ads)::
16258 * GNAT.Lock_Files (g-locfil.ads)::
16259 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
16260 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
16261 * GNAT.MD5 (g-md5.ads)::
16262 * GNAT.Memory_Dump (g-memdum.ads)::
16263 * GNAT.Most_Recent_Exception (g-moreex.ads)::
16264 * GNAT.OS_Lib (g-os_lib.ads)::
16265 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
16266 * GNAT.Random_Numbers (g-rannum.ads)::
16267 * GNAT.Regexp (g-regexp.ads)::
16268 * GNAT.Registry (g-regist.ads)::
16269 * GNAT.Regpat (g-regpat.ads)::
16270 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
16271 * GNAT.Semaphores (g-semaph.ads)::
16272 * GNAT.Serial_Communications (g-sercom.ads)::
16273 * GNAT.SHA1 (g-sha1.ads)::
16274 * GNAT.SHA224 (g-sha224.ads)::
16275 * GNAT.SHA256 (g-sha256.ads)::
16276 * GNAT.SHA384 (g-sha384.ads)::
16277 * GNAT.SHA512 (g-sha512.ads)::
16278 * GNAT.Signals (g-signal.ads)::
16279 * GNAT.Sockets (g-socket.ads)::
16280 * GNAT.Source_Info (g-souinf.ads)::
16281 * GNAT.Spelling_Checker (g-speche.ads)::
16282 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
16283 * GNAT.Spitbol.Patterns (g-spipat.ads)::
16284 * GNAT.Spitbol (g-spitbo.ads)::
16285 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
16286 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
16287 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
16288 * GNAT.SSE (g-sse.ads)::
16289 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
16290 * GNAT.Strings (g-string.ads)::
16291 * GNAT.String_Split (g-strspl.ads)::
16292 * GNAT.Table (g-table.ads)::
16293 * GNAT.Task_Lock (g-tasloc.ads)::
16294 * GNAT.Threads (g-thread.ads)::
16295 * GNAT.Time_Stamp (g-timsta.ads)::
16296 * GNAT.Traceback (g-traceb.ads)::
16297 * GNAT.Traceback.Symbolic (g-trasym.ads)::
16298 * GNAT.UTF_32 (g-utf_32.ads)::
16299 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
16300 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
16301 * GNAT.Wide_String_Split (g-wistsp.ads)::
16302 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
16303 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
16304 * Interfaces.C.Extensions (i-cexten.ads)::
16305 * Interfaces.C.Streams (i-cstrea.ads)::
16306 * Interfaces.CPP (i-cpp.ads)::
16307 * Interfaces.Packed_Decimal (i-pacdec.ads)::
16308 * Interfaces.VxWorks (i-vxwork.ads)::
16309 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
16310 * System.Address_Image (s-addima.ads)::
16311 * System.Assertions (s-assert.ads)::
16312 * System.Memory (s-memory.ads)::
16313 * System.Multiprocessors (s-multip.ads)::
16314 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
16315 * System.Partition_Interface (s-parint.ads)::
16316 * System.Pool_Global (s-pooglo.ads)::
16317 * System.Pool_Local (s-pooloc.ads)::
16318 * System.Restrictions (s-restri.ads)::
16319 * System.Rident (s-rident.ads)::
16320 * System.Strings.Stream_Ops (s-ststop.ads)::
16321 * System.Task_Info (s-tasinf.ads)::
16322 * System.Wch_Cnv (s-wchcnv.ads)::
16323 * System.Wch_Con (s-wchcon.ads)::
16326 @node Ada.Characters.Latin_9 (a-chlat9.ads)
16327 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
16328 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
16329 @cindex Latin_9 constants for Character
16332 This child of @code{Ada.Characters}
16333 provides a set of definitions corresponding to those in the
16334 RM-defined package @code{Ada.Characters.Latin_1} but with the
16335 few modifications required for @code{Latin-9}
16336 The provision of such a package
16337 is specifically authorized by the Ada Reference Manual
16340 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
16341 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
16342 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
16343 @cindex Latin_1 constants for Wide_Character
16346 This child of @code{Ada.Characters}
16347 provides a set of definitions corresponding to those in the
16348 RM-defined package @code{Ada.Characters.Latin_1} but with the
16349 types of the constants being @code{Wide_Character}
16350 instead of @code{Character}. The provision of such a package
16351 is specifically authorized by the Ada Reference Manual
16354 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
16355 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
16356 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
16357 @cindex Latin_9 constants for Wide_Character
16360 This child of @code{Ada.Characters}
16361 provides a set of definitions corresponding to those in the
16362 GNAT defined package @code{Ada.Characters.Latin_9} but with the
16363 types of the constants being @code{Wide_Character}
16364 instead of @code{Character}. The provision of such a package
16365 is specifically authorized by the Ada Reference Manual
16368 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
16369 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
16370 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
16371 @cindex Latin_1 constants for Wide_Wide_Character
16374 This child of @code{Ada.Characters}
16375 provides a set of definitions corresponding to those in the
16376 RM-defined package @code{Ada.Characters.Latin_1} but with the
16377 types of the constants being @code{Wide_Wide_Character}
16378 instead of @code{Character}. The provision of such a package
16379 is specifically authorized by the Ada Reference Manual
16382 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
16383 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
16384 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
16385 @cindex Latin_9 constants for Wide_Wide_Character
16388 This child of @code{Ada.Characters}
16389 provides a set of definitions corresponding to those in the
16390 GNAT defined package @code{Ada.Characters.Latin_9} but with the
16391 types of the constants being @code{Wide_Wide_Character}
16392 instead of @code{Character}. The provision of such a package
16393 is specifically authorized by the Ada Reference Manual
16396 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
16397 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
16398 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
16399 @cindex Formal container for doubly linked lists
16402 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16403 container for doubly linked lists, meant to facilitate formal verification of
16404 code using such containers.
16406 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
16407 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
16408 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
16409 @cindex Formal container for hashed maps
16412 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16413 container for hashed maps, meant to facilitate formal verification of
16414 code using such containers.
16416 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
16417 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
16418 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
16419 @cindex Formal container for hashed sets
16422 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16423 container for hashed sets, meant to facilitate formal verification of
16424 code using such containers.
16426 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
16427 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
16428 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
16429 @cindex Formal container for ordered maps
16432 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16433 container for ordered maps, meant to facilitate formal verification of
16434 code using such containers.
16436 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
16437 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
16438 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
16439 @cindex Formal container for ordered sets
16442 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16443 container for ordered sets, meant to facilitate formal verification of
16444 code using such containers.
16446 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
16447 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
16448 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
16449 @cindex Formal container for vectors
16452 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16453 container for vectors, meant to facilitate formal verification of
16454 code using such containers.
16456 @node Ada.Command_Line.Environment (a-colien.ads)
16457 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
16458 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
16459 @cindex Environment entries
16462 This child of @code{Ada.Command_Line}
16463 provides a mechanism for obtaining environment values on systems
16464 where this concept makes sense.
16466 @node Ada.Command_Line.Remove (a-colire.ads)
16467 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
16468 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
16469 @cindex Removing command line arguments
16470 @cindex Command line, argument removal
16473 This child of @code{Ada.Command_Line}
16474 provides a mechanism for logically removing
16475 arguments from the argument list. Once removed, an argument is not visible
16476 to further calls on the subprograms in @code{Ada.Command_Line} will not
16477 see the removed argument.
16479 @node Ada.Command_Line.Response_File (a-clrefi.ads)
16480 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
16481 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
16482 @cindex Response file for command line
16483 @cindex Command line, response file
16484 @cindex Command line, handling long command lines
16487 This child of @code{Ada.Command_Line} provides a mechanism facilities for
16488 getting command line arguments from a text file, called a "response file".
16489 Using a response file allow passing a set of arguments to an executable longer
16490 than the maximum allowed by the system on the command line.
16492 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
16493 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
16494 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
16495 @cindex C Streams, Interfacing with Direct_IO
16498 This package provides subprograms that allow interfacing between
16499 C streams and @code{Direct_IO}. The stream identifier can be
16500 extracted from a file opened on the Ada side, and an Ada file
16501 can be constructed from a stream opened on the C side.
16503 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
16504 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
16505 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
16506 @cindex Null_Occurrence, testing for
16509 This child subprogram provides a way of testing for the null
16510 exception occurrence (@code{Null_Occurrence}) without raising
16513 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
16514 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
16515 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
16516 @cindex Null_Occurrence, testing for
16519 This child subprogram is used for handling otherwise unhandled
16520 exceptions (hence the name last chance), and perform clean ups before
16521 terminating the program. Note that this subprogram never returns.
16523 @node Ada.Exceptions.Traceback (a-exctra.ads)
16524 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
16525 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
16526 @cindex Traceback for Exception Occurrence
16529 This child package provides the subprogram (@code{Tracebacks}) to
16530 give a traceback array of addresses based on an exception
16533 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
16534 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
16535 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
16536 @cindex C Streams, Interfacing with Sequential_IO
16539 This package provides subprograms that allow interfacing between
16540 C streams and @code{Sequential_IO}. The stream identifier can be
16541 extracted from a file opened on the Ada side, and an Ada file
16542 can be constructed from a stream opened on the C side.
16544 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
16545 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
16546 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
16547 @cindex C Streams, Interfacing with Stream_IO
16550 This package provides subprograms that allow interfacing between
16551 C streams and @code{Stream_IO}. The stream identifier can be
16552 extracted from a file opened on the Ada side, and an Ada file
16553 can be constructed from a stream opened on the C side.
16555 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
16556 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
16557 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
16558 @cindex @code{Unbounded_String}, IO support
16559 @cindex @code{Text_IO}, extensions for unbounded strings
16562 This package provides subprograms for Text_IO for unbounded
16563 strings, avoiding the necessity for an intermediate operation
16564 with ordinary strings.
16566 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
16567 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
16568 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
16569 @cindex @code{Unbounded_Wide_String}, IO support
16570 @cindex @code{Text_IO}, extensions for unbounded wide strings
16573 This package provides subprograms for Text_IO for unbounded
16574 wide strings, avoiding the necessity for an intermediate operation
16575 with ordinary wide strings.
16577 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
16578 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
16579 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
16580 @cindex @code{Unbounded_Wide_Wide_String}, IO support
16581 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
16584 This package provides subprograms for Text_IO for unbounded
16585 wide wide strings, avoiding the necessity for an intermediate operation
16586 with ordinary wide wide strings.
16588 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
16589 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
16590 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
16591 @cindex C Streams, Interfacing with @code{Text_IO}
16594 This package provides subprograms that allow interfacing between
16595 C streams and @code{Text_IO}. The stream identifier can be
16596 extracted from a file opened on the Ada side, and an Ada file
16597 can be constructed from a stream opened on the C side.
16599 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
16600 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
16601 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
16602 @cindex @code{Text_IO} resetting standard files
16605 This procedure is used to reset the status of the standard files used
16606 by Ada.Text_IO. This is useful in a situation (such as a restart in an
16607 embedded application) where the status of the files may change during
16608 execution (for example a standard input file may be redefined to be
16611 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
16612 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
16613 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
16614 @cindex Unicode categorization, Wide_Character
16617 This package provides subprograms that allow categorization of
16618 Wide_Character values according to Unicode categories.
16620 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
16621 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
16622 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
16623 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
16626 This package provides subprograms that allow interfacing between
16627 C streams and @code{Wide_Text_IO}. The stream identifier can be
16628 extracted from a file opened on the Ada side, and an Ada file
16629 can be constructed from a stream opened on the C side.
16631 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
16632 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
16633 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
16634 @cindex @code{Wide_Text_IO} resetting standard files
16637 This procedure is used to reset the status of the standard files used
16638 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
16639 embedded application) where the status of the files may change during
16640 execution (for example a standard input file may be redefined to be
16643 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
16644 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
16645 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
16646 @cindex Unicode categorization, Wide_Wide_Character
16649 This package provides subprograms that allow categorization of
16650 Wide_Wide_Character values according to Unicode categories.
16652 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
16653 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
16654 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
16655 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
16658 This package provides subprograms that allow interfacing between
16659 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
16660 extracted from a file opened on the Ada side, and an Ada file
16661 can be constructed from a stream opened on the C side.
16663 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
16664 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
16665 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
16666 @cindex @code{Wide_Wide_Text_IO} resetting standard files
16669 This procedure is used to reset the status of the standard files used
16670 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
16671 restart in an embedded application) where the status of the files may
16672 change during execution (for example a standard input file may be
16673 redefined to be interactive).
16675 @node GNAT.Altivec (g-altive.ads)
16676 @section @code{GNAT.Altivec} (@file{g-altive.ads})
16677 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
16681 This is the root package of the GNAT AltiVec binding. It provides
16682 definitions of constants and types common to all the versions of the
16685 @node GNAT.Altivec.Conversions (g-altcon.ads)
16686 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
16687 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
16691 This package provides the Vector/View conversion routines.
16693 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
16694 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
16695 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
16699 This package exposes the Ada interface to the AltiVec operations on
16700 vector objects. A soft emulation is included by default in the GNAT
16701 library. The hard binding is provided as a separate package. This unit
16702 is common to both bindings.
16704 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
16705 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
16706 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
16710 This package exposes the various vector types part of the Ada binding
16711 to AltiVec facilities.
16713 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
16714 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
16715 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
16719 This package provides public 'View' data types from/to which private
16720 vector representations can be converted via
16721 GNAT.Altivec.Conversions. This allows convenient access to individual
16722 vector elements and provides a simple way to initialize vector
16725 @node GNAT.Array_Split (g-arrspl.ads)
16726 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
16727 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
16728 @cindex Array splitter
16731 Useful array-manipulation routines: given a set of separators, split
16732 an array wherever the separators appear, and provide direct access
16733 to the resulting slices.
16735 @node GNAT.AWK (g-awk.ads)
16736 @section @code{GNAT.AWK} (@file{g-awk.ads})
16737 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
16742 Provides AWK-like parsing functions, with an easy interface for parsing one
16743 or more files containing formatted data. The file is viewed as a database
16744 where each record is a line and a field is a data element in this line.
16746 @node GNAT.Bounded_Buffers (g-boubuf.ads)
16747 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
16748 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
16750 @cindex Bounded Buffers
16753 Provides a concurrent generic bounded buffer abstraction. Instances are
16754 useful directly or as parts of the implementations of other abstractions,
16757 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
16758 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
16759 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
16764 Provides a thread-safe asynchronous intertask mailbox communication facility.
16766 @node GNAT.Bubble_Sort (g-bubsor.ads)
16767 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
16768 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
16770 @cindex Bubble sort
16773 Provides a general implementation of bubble sort usable for sorting arbitrary
16774 data items. Exchange and comparison procedures are provided by passing
16775 access-to-procedure values.
16777 @node GNAT.Bubble_Sort_A (g-busora.ads)
16778 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
16779 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
16781 @cindex Bubble sort
16784 Provides a general implementation of bubble sort usable for sorting arbitrary
16785 data items. Move and comparison procedures are provided by passing
16786 access-to-procedure values. This is an older version, retained for
16787 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
16789 @node GNAT.Bubble_Sort_G (g-busorg.ads)
16790 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
16791 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
16793 @cindex Bubble sort
16796 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
16797 are provided as generic parameters, this improves efficiency, especially
16798 if the procedures can be inlined, at the expense of duplicating code for
16799 multiple instantiations.
16801 @node GNAT.Byte_Order_Mark (g-byorma.ads)
16802 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
16803 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
16804 @cindex UTF-8 representation
16805 @cindex Wide characte representations
16808 Provides a routine which given a string, reads the start of the string to
16809 see whether it is one of the standard byte order marks (BOM's) which signal
16810 the encoding of the string. The routine includes detection of special XML
16811 sequences for various UCS input formats.
16813 @node GNAT.Byte_Swapping (g-bytswa.ads)
16814 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
16815 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
16816 @cindex Byte swapping
16820 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
16821 Machine-specific implementations are available in some cases.
16823 @node GNAT.Calendar (g-calend.ads)
16824 @section @code{GNAT.Calendar} (@file{g-calend.ads})
16825 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
16826 @cindex @code{Calendar}
16829 Extends the facilities provided by @code{Ada.Calendar} to include handling
16830 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
16831 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
16832 C @code{timeval} format.
16834 @node GNAT.Calendar.Time_IO (g-catiio.ads)
16835 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
16836 @cindex @code{Calendar}
16838 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
16840 @node GNAT.CRC32 (g-crc32.ads)
16841 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
16842 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
16844 @cindex Cyclic Redundancy Check
16847 This package implements the CRC-32 algorithm. For a full description
16848 of this algorithm see
16849 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
16850 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
16851 Aug.@: 1988. Sarwate, D.V@.
16853 @node GNAT.Case_Util (g-casuti.ads)
16854 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
16855 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
16856 @cindex Casing utilities
16857 @cindex Character handling (@code{GNAT.Case_Util})
16860 A set of simple routines for handling upper and lower casing of strings
16861 without the overhead of the full casing tables
16862 in @code{Ada.Characters.Handling}.
16864 @node GNAT.CGI (g-cgi.ads)
16865 @section @code{GNAT.CGI} (@file{g-cgi.ads})
16866 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
16867 @cindex CGI (Common Gateway Interface)
16870 This is a package for interfacing a GNAT program with a Web server via the
16871 Common Gateway Interface (CGI)@. Basically this package parses the CGI
16872 parameters, which are a set of key/value pairs sent by the Web server. It
16873 builds a table whose index is the key and provides some services to deal
16876 @node GNAT.CGI.Cookie (g-cgicoo.ads)
16877 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
16878 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
16879 @cindex CGI (Common Gateway Interface) cookie support
16880 @cindex Cookie support in CGI
16883 This is a package to interface a GNAT program with a Web server via the
16884 Common Gateway Interface (CGI). It exports services to deal with Web
16885 cookies (piece of information kept in the Web client software).
16887 @node GNAT.CGI.Debug (g-cgideb.ads)
16888 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
16889 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
16890 @cindex CGI (Common Gateway Interface) debugging
16893 This is a package to help debugging CGI (Common Gateway Interface)
16894 programs written in Ada.
16896 @node GNAT.Command_Line (g-comlin.ads)
16897 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
16898 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
16899 @cindex Command line
16902 Provides a high level interface to @code{Ada.Command_Line} facilities,
16903 including the ability to scan for named switches with optional parameters
16904 and expand file names using wild card notations.
16906 @node GNAT.Compiler_Version (g-comver.ads)
16907 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
16908 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
16909 @cindex Compiler Version
16910 @cindex Version, of compiler
16913 Provides a routine for obtaining the version of the compiler used to
16914 compile the program. More accurately this is the version of the binder
16915 used to bind the program (this will normally be the same as the version
16916 of the compiler if a consistent tool set is used to compile all units
16919 @node GNAT.Ctrl_C (g-ctrl_c.ads)
16920 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
16921 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
16925 Provides a simple interface to handle Ctrl-C keyboard events.
16927 @node GNAT.Current_Exception (g-curexc.ads)
16928 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
16929 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
16930 @cindex Current exception
16931 @cindex Exception retrieval
16934 Provides access to information on the current exception that has been raised
16935 without the need for using the Ada 95 / Ada 2005 exception choice parameter
16936 specification syntax.
16937 This is particularly useful in simulating typical facilities for
16938 obtaining information about exceptions provided by Ada 83 compilers.
16940 @node GNAT.Debug_Pools (g-debpoo.ads)
16941 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
16942 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
16944 @cindex Debug pools
16945 @cindex Memory corruption debugging
16948 Provide a debugging storage pools that helps tracking memory corruption
16949 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
16950 @value{EDITION} User's Guide}.
16952 @node GNAT.Debug_Utilities (g-debuti.ads)
16953 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
16954 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
16958 Provides a few useful utilities for debugging purposes, including conversion
16959 to and from string images of address values. Supports both C and Ada formats
16960 for hexadecimal literals.
16962 @node GNAT.Decode_String (g-decstr.ads)
16963 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
16964 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
16965 @cindex Decoding strings
16966 @cindex String decoding
16967 @cindex Wide character encoding
16972 A generic package providing routines for decoding wide character and wide wide
16973 character strings encoded as sequences of 8-bit characters using a specified
16974 encoding method. Includes validation routines, and also routines for stepping
16975 to next or previous encoded character in an encoded string.
16976 Useful in conjunction with Unicode character coding. Note there is a
16977 preinstantiation for UTF-8. See next entry.
16979 @node GNAT.Decode_UTF8_String (g-deutst.ads)
16980 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
16981 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
16982 @cindex Decoding strings
16983 @cindex Decoding UTF-8 strings
16984 @cindex UTF-8 string decoding
16985 @cindex Wide character decoding
16990 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
16992 @node GNAT.Directory_Operations (g-dirope.ads)
16993 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
16994 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
16995 @cindex Directory operations
16998 Provides a set of routines for manipulating directories, including changing
16999 the current directory, making new directories, and scanning the files in a
17002 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
17003 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
17004 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
17005 @cindex Directory operations iteration
17008 A child unit of GNAT.Directory_Operations providing additional operations
17009 for iterating through directories.
17011 @node GNAT.Dynamic_HTables (g-dynhta.ads)
17012 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
17013 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
17014 @cindex Hash tables
17017 A generic implementation of hash tables that can be used to hash arbitrary
17018 data. Provided in two forms, a simple form with built in hash functions,
17019 and a more complex form in which the hash function is supplied.
17022 This package provides a facility similar to that of @code{GNAT.HTable},
17023 except that this package declares a type that can be used to define
17024 dynamic instances of the hash table, while an instantiation of
17025 @code{GNAT.HTable} creates a single instance of the hash table.
17027 @node GNAT.Dynamic_Tables (g-dyntab.ads)
17028 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
17029 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
17030 @cindex Table implementation
17031 @cindex Arrays, extendable
17034 A generic package providing a single dimension array abstraction where the
17035 length of the array can be dynamically modified.
17038 This package provides a facility similar to that of @code{GNAT.Table},
17039 except that this package declares a type that can be used to define
17040 dynamic instances of the table, while an instantiation of
17041 @code{GNAT.Table} creates a single instance of the table type.
17043 @node GNAT.Encode_String (g-encstr.ads)
17044 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
17045 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
17046 @cindex Encoding strings
17047 @cindex String encoding
17048 @cindex Wide character encoding
17053 A generic package providing routines for encoding wide character and wide
17054 wide character strings as sequences of 8-bit characters using a specified
17055 encoding method. Useful in conjunction with Unicode character coding.
17056 Note there is a preinstantiation for UTF-8. See next entry.
17058 @node GNAT.Encode_UTF8_String (g-enutst.ads)
17059 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
17060 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
17061 @cindex Encoding strings
17062 @cindex Encoding UTF-8 strings
17063 @cindex UTF-8 string encoding
17064 @cindex Wide character encoding
17069 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
17071 @node GNAT.Exception_Actions (g-excact.ads)
17072 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
17073 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
17074 @cindex Exception actions
17077 Provides callbacks when an exception is raised. Callbacks can be registered
17078 for specific exceptions, or when any exception is raised. This
17079 can be used for instance to force a core dump to ease debugging.
17081 @node GNAT.Exception_Traces (g-exctra.ads)
17082 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
17083 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
17084 @cindex Exception traces
17088 Provides an interface allowing to control automatic output upon exception
17091 @node GNAT.Exceptions (g-except.ads)
17092 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
17093 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
17094 @cindex Exceptions, Pure
17095 @cindex Pure packages, exceptions
17098 Normally it is not possible to raise an exception with
17099 a message from a subprogram in a pure package, since the
17100 necessary types and subprograms are in @code{Ada.Exceptions}
17101 which is not a pure unit. @code{GNAT.Exceptions} provides a
17102 facility for getting around this limitation for a few
17103 predefined exceptions, and for example allow raising
17104 @code{Constraint_Error} with a message from a pure subprogram.
17106 @node GNAT.Expect (g-expect.ads)
17107 @section @code{GNAT.Expect} (@file{g-expect.ads})
17108 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
17111 Provides a set of subprograms similar to what is available
17112 with the standard Tcl Expect tool.
17113 It allows you to easily spawn and communicate with an external process.
17114 You can send commands or inputs to the process, and compare the output
17115 with some expected regular expression. Currently @code{GNAT.Expect}
17116 is implemented on all native GNAT ports except for OpenVMS@.
17117 It is not implemented for cross ports, and in particular is not
17118 implemented for VxWorks or LynxOS@.
17120 @node GNAT.Expect.TTY (g-exptty.ads)
17121 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
17122 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
17125 As GNAT.Expect but using pseudo-terminal.
17126 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
17127 ports except for OpenVMS@. It is not implemented for cross ports, and
17128 in particular is not implemented for VxWorks or LynxOS@.
17130 @node GNAT.Float_Control (g-flocon.ads)
17131 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
17132 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
17133 @cindex Floating-Point Processor
17136 Provides an interface for resetting the floating-point processor into the
17137 mode required for correct semantic operation in Ada. Some third party
17138 library calls may cause this mode to be modified, and the Reset procedure
17139 in this package can be used to reestablish the required mode.
17141 @node GNAT.Heap_Sort (g-heasor.ads)
17142 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
17143 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
17147 Provides a general implementation of heap sort usable for sorting arbitrary
17148 data items. Exchange and comparison procedures are provided by passing
17149 access-to-procedure values. The algorithm used is a modified heap sort
17150 that performs approximately N*log(N) comparisons in the worst case.
17152 @node GNAT.Heap_Sort_A (g-hesora.ads)
17153 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
17154 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
17158 Provides a general implementation of heap sort usable for sorting arbitrary
17159 data items. Move and comparison procedures are provided by passing
17160 access-to-procedure values. The algorithm used is a modified heap sort
17161 that performs approximately N*log(N) comparisons in the worst case.
17162 This differs from @code{GNAT.Heap_Sort} in having a less convenient
17163 interface, but may be slightly more efficient.
17165 @node GNAT.Heap_Sort_G (g-hesorg.ads)
17166 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
17167 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
17171 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
17172 are provided as generic parameters, this improves efficiency, especially
17173 if the procedures can be inlined, at the expense of duplicating code for
17174 multiple instantiations.
17176 @node GNAT.HTable (g-htable.ads)
17177 @section @code{GNAT.HTable} (@file{g-htable.ads})
17178 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
17179 @cindex Hash tables
17182 A generic implementation of hash tables that can be used to hash arbitrary
17183 data. Provides two approaches, one a simple static approach, and the other
17184 allowing arbitrary dynamic hash tables.
17186 @node GNAT.IO (g-io.ads)
17187 @section @code{GNAT.IO} (@file{g-io.ads})
17188 @cindex @code{GNAT.IO} (@file{g-io.ads})
17190 @cindex Input/Output facilities
17193 A simple preelaborable input-output package that provides a subset of
17194 simple Text_IO functions for reading characters and strings from
17195 Standard_Input, and writing characters, strings and integers to either
17196 Standard_Output or Standard_Error.
17198 @node GNAT.IO_Aux (g-io_aux.ads)
17199 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
17200 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
17202 @cindex Input/Output facilities
17204 Provides some auxiliary functions for use with Text_IO, including a test
17205 for whether a file exists, and functions for reading a line of text.
17207 @node GNAT.Lock_Files (g-locfil.ads)
17208 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
17209 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
17210 @cindex File locking
17211 @cindex Locking using files
17214 Provides a general interface for using files as locks. Can be used for
17215 providing program level synchronization.
17217 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
17218 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
17219 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
17220 @cindex Random number generation
17223 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
17224 a modified version of the Blum-Blum-Shub generator.
17226 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
17227 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
17228 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
17229 @cindex Random number generation
17232 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
17233 a modified version of the Blum-Blum-Shub generator.
17235 @node GNAT.MD5 (g-md5.ads)
17236 @section @code{GNAT.MD5} (@file{g-md5.ads})
17237 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
17238 @cindex Message Digest MD5
17241 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
17243 @node GNAT.Memory_Dump (g-memdum.ads)
17244 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
17245 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
17246 @cindex Dump Memory
17249 Provides a convenient routine for dumping raw memory to either the
17250 standard output or standard error files. Uses GNAT.IO for actual
17253 @node GNAT.Most_Recent_Exception (g-moreex.ads)
17254 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
17255 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
17256 @cindex Exception, obtaining most recent
17259 Provides access to the most recently raised exception. Can be used for
17260 various logging purposes, including duplicating functionality of some
17261 Ada 83 implementation dependent extensions.
17263 @node GNAT.OS_Lib (g-os_lib.ads)
17264 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
17265 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
17266 @cindex Operating System interface
17267 @cindex Spawn capability
17270 Provides a range of target independent operating system interface functions,
17271 including time/date management, file operations, subprocess management,
17272 including a portable spawn procedure, and access to environment variables
17273 and error return codes.
17275 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
17276 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
17277 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
17278 @cindex Hash functions
17281 Provides a generator of static minimal perfect hash functions. No
17282 collisions occur and each item can be retrieved from the table in one
17283 probe (perfect property). The hash table size corresponds to the exact
17284 size of the key set and no larger (minimal property). The key set has to
17285 be know in advance (static property). The hash functions are also order
17286 preserving. If w2 is inserted after w1 in the generator, their
17287 hashcode are in the same order. These hashing functions are very
17288 convenient for use with realtime applications.
17290 @node GNAT.Random_Numbers (g-rannum.ads)
17291 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
17292 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
17293 @cindex Random number generation
17296 Provides random number capabilities which extend those available in the
17297 standard Ada library and are more convenient to use.
17299 @node GNAT.Regexp (g-regexp.ads)
17300 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
17301 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
17302 @cindex Regular expressions
17303 @cindex Pattern matching
17306 A simple implementation of regular expressions, using a subset of regular
17307 expression syntax copied from familiar Unix style utilities. This is the
17308 simples of the three pattern matching packages provided, and is particularly
17309 suitable for ``file globbing'' applications.
17311 @node GNAT.Registry (g-regist.ads)
17312 @section @code{GNAT.Registry} (@file{g-regist.ads})
17313 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
17314 @cindex Windows Registry
17317 This is a high level binding to the Windows registry. It is possible to
17318 do simple things like reading a key value, creating a new key. For full
17319 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
17320 package provided with the Win32Ada binding
17322 @node GNAT.Regpat (g-regpat.ads)
17323 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
17324 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
17325 @cindex Regular expressions
17326 @cindex Pattern matching
17329 A complete implementation of Unix-style regular expression matching, copied
17330 from the original V7 style regular expression library written in C by
17331 Henry Spencer (and binary compatible with this C library).
17333 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
17334 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
17335 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
17336 @cindex Secondary Stack Info
17339 Provide the capability to query the high water mark of the current task's
17342 @node GNAT.Semaphores (g-semaph.ads)
17343 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
17344 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
17348 Provides classic counting and binary semaphores using protected types.
17350 @node GNAT.Serial_Communications (g-sercom.ads)
17351 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
17352 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
17353 @cindex Serial_Communications
17356 Provides a simple interface to send and receive data over a serial
17357 port. This is only supported on GNU/Linux and Windows.
17359 @node GNAT.SHA1 (g-sha1.ads)
17360 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
17361 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
17362 @cindex Secure Hash Algorithm SHA-1
17365 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
17368 @node GNAT.SHA224 (g-sha224.ads)
17369 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
17370 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
17371 @cindex Secure Hash Algorithm SHA-224
17374 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
17376 @node GNAT.SHA256 (g-sha256.ads)
17377 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
17378 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
17379 @cindex Secure Hash Algorithm SHA-256
17382 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
17384 @node GNAT.SHA384 (g-sha384.ads)
17385 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
17386 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
17387 @cindex Secure Hash Algorithm SHA-384
17390 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
17392 @node GNAT.SHA512 (g-sha512.ads)
17393 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
17394 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
17395 @cindex Secure Hash Algorithm SHA-512
17398 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
17400 @node GNAT.Signals (g-signal.ads)
17401 @section @code{GNAT.Signals} (@file{g-signal.ads})
17402 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
17406 Provides the ability to manipulate the blocked status of signals on supported
17409 @node GNAT.Sockets (g-socket.ads)
17410 @section @code{GNAT.Sockets} (@file{g-socket.ads})
17411 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
17415 A high level and portable interface to develop sockets based applications.
17416 This package is based on the sockets thin binding found in
17417 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
17418 on all native GNAT ports except for OpenVMS@. It is not implemented
17419 for the LynxOS@ cross port.
17421 @node GNAT.Source_Info (g-souinf.ads)
17422 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
17423 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
17424 @cindex Source Information
17427 Provides subprograms that give access to source code information known at
17428 compile time, such as the current file name and line number.
17430 @node GNAT.Spelling_Checker (g-speche.ads)
17431 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
17432 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
17433 @cindex Spell checking
17436 Provides a function for determining whether one string is a plausible
17437 near misspelling of another string.
17439 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
17440 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
17441 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
17442 @cindex Spell checking
17445 Provides a generic function that can be instantiated with a string type for
17446 determining whether one string is a plausible near misspelling of another
17449 @node GNAT.Spitbol.Patterns (g-spipat.ads)
17450 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
17451 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
17452 @cindex SPITBOL pattern matching
17453 @cindex Pattern matching
17456 A complete implementation of SNOBOL4 style pattern matching. This is the
17457 most elaborate of the pattern matching packages provided. It fully duplicates
17458 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
17459 efficient algorithm developed by Robert Dewar for the SPITBOL system.
17461 @node GNAT.Spitbol (g-spitbo.ads)
17462 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
17463 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
17464 @cindex SPITBOL interface
17467 The top level package of the collection of SPITBOL-style functionality, this
17468 package provides basic SNOBOL4 string manipulation functions, such as
17469 Pad, Reverse, Trim, Substr capability, as well as a generic table function
17470 useful for constructing arbitrary mappings from strings in the style of
17471 the SNOBOL4 TABLE function.
17473 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
17474 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
17475 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
17476 @cindex Sets of strings
17477 @cindex SPITBOL Tables
17480 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
17481 for type @code{Standard.Boolean}, giving an implementation of sets of
17484 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
17485 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
17486 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
17487 @cindex Integer maps
17489 @cindex SPITBOL Tables
17492 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
17493 for type @code{Standard.Integer}, giving an implementation of maps
17494 from string to integer values.
17496 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
17497 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
17498 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
17499 @cindex String maps
17501 @cindex SPITBOL Tables
17504 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
17505 a variable length string type, giving an implementation of general
17506 maps from strings to strings.
17508 @node GNAT.SSE (g-sse.ads)
17509 @section @code{GNAT.SSE} (@file{g-sse.ads})
17510 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
17513 Root of a set of units aimed at offering Ada bindings to a subset of
17514 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
17515 targets. It exposes vector component types together with a general
17516 introduction to the binding contents and use.
17518 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
17519 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
17520 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
17523 SSE vector types for use with SSE related intrinsics.
17525 @node GNAT.Strings (g-string.ads)
17526 @section @code{GNAT.Strings} (@file{g-string.ads})
17527 @cindex @code{GNAT.Strings} (@file{g-string.ads})
17530 Common String access types and related subprograms. Basically it
17531 defines a string access and an array of string access types.
17533 @node GNAT.String_Split (g-strspl.ads)
17534 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
17535 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
17536 @cindex String splitter
17539 Useful string manipulation routines: given a set of separators, split
17540 a string wherever the separators appear, and provide direct access
17541 to the resulting slices. This package is instantiated from
17542 @code{GNAT.Array_Split}.
17544 @node GNAT.Table (g-table.ads)
17545 @section @code{GNAT.Table} (@file{g-table.ads})
17546 @cindex @code{GNAT.Table} (@file{g-table.ads})
17547 @cindex Table implementation
17548 @cindex Arrays, extendable
17551 A generic package providing a single dimension array abstraction where the
17552 length of the array can be dynamically modified.
17555 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
17556 except that this package declares a single instance of the table type,
17557 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
17558 used to define dynamic instances of the table.
17560 @node GNAT.Task_Lock (g-tasloc.ads)
17561 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
17562 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
17563 @cindex Task synchronization
17564 @cindex Task locking
17568 A very simple facility for locking and unlocking sections of code using a
17569 single global task lock. Appropriate for use in situations where contention
17570 between tasks is very rarely expected.
17572 @node GNAT.Time_Stamp (g-timsta.ads)
17573 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
17574 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
17576 @cindex Current time
17579 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
17580 represents the current date and time in ISO 8601 format. This is a very simple
17581 routine with minimal code and there are no dependencies on any other unit.
17583 @node GNAT.Threads (g-thread.ads)
17584 @section @code{GNAT.Threads} (@file{g-thread.ads})
17585 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
17586 @cindex Foreign threads
17587 @cindex Threads, foreign
17590 Provides facilities for dealing with foreign threads which need to be known
17591 by the GNAT run-time system. Consult the documentation of this package for
17592 further details if your program has threads that are created by a non-Ada
17593 environment which then accesses Ada code.
17595 @node GNAT.Traceback (g-traceb.ads)
17596 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
17597 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
17598 @cindex Trace back facilities
17601 Provides a facility for obtaining non-symbolic traceback information, useful
17602 in various debugging situations.
17604 @node GNAT.Traceback.Symbolic (g-trasym.ads)
17605 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
17606 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
17607 @cindex Trace back facilities
17609 @node GNAT.UTF_32 (g-utf_32.ads)
17610 @section @code{GNAT.UTF_32} (@file{g-table.ads})
17611 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
17612 @cindex Wide character codes
17615 This is a package intended to be used in conjunction with the
17616 @code{Wide_Character} type in Ada 95 and the
17617 @code{Wide_Wide_Character} type in Ada 2005 (available
17618 in @code{GNAT} in Ada 2005 mode). This package contains
17619 Unicode categorization routines, as well as lexical
17620 categorization routines corresponding to the Ada 2005
17621 lexical rules for identifiers and strings, and also a
17622 lower case to upper case fold routine corresponding to
17623 the Ada 2005 rules for identifier equivalence.
17625 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
17626 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
17627 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
17628 @cindex Spell checking
17631 Provides a function for determining whether one wide wide string is a plausible
17632 near misspelling of another wide wide string, where the strings are represented
17633 using the UTF_32_String type defined in System.Wch_Cnv.
17635 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
17636 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
17637 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
17638 @cindex Spell checking
17641 Provides a function for determining whether one wide string is a plausible
17642 near misspelling of another wide string.
17644 @node GNAT.Wide_String_Split (g-wistsp.ads)
17645 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
17646 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
17647 @cindex Wide_String splitter
17650 Useful wide string manipulation routines: given a set of separators, split
17651 a wide string wherever the separators appear, and provide direct access
17652 to the resulting slices. This package is instantiated from
17653 @code{GNAT.Array_Split}.
17655 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
17656 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
17657 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
17658 @cindex Spell checking
17661 Provides a function for determining whether one wide wide string is a plausible
17662 near misspelling of another wide wide string.
17664 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
17665 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
17666 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
17667 @cindex Wide_Wide_String splitter
17670 Useful wide wide string manipulation routines: given a set of separators, split
17671 a wide wide string wherever the separators appear, and provide direct access
17672 to the resulting slices. This package is instantiated from
17673 @code{GNAT.Array_Split}.
17675 @node Interfaces.C.Extensions (i-cexten.ads)
17676 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
17677 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
17680 This package contains additional C-related definitions, intended
17681 for use with either manually or automatically generated bindings
17684 @node Interfaces.C.Streams (i-cstrea.ads)
17685 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
17686 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
17687 @cindex C streams, interfacing
17690 This package is a binding for the most commonly used operations
17693 @node Interfaces.CPP (i-cpp.ads)
17694 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
17695 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
17696 @cindex C++ interfacing
17697 @cindex Interfacing, to C++
17700 This package provides facilities for use in interfacing to C++. It
17701 is primarily intended to be used in connection with automated tools
17702 for the generation of C++ interfaces.
17704 @node Interfaces.Packed_Decimal (i-pacdec.ads)
17705 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
17706 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
17707 @cindex IBM Packed Format
17708 @cindex Packed Decimal
17711 This package provides a set of routines for conversions to and
17712 from a packed decimal format compatible with that used on IBM
17715 @node Interfaces.VxWorks (i-vxwork.ads)
17716 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
17717 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
17718 @cindex Interfacing to VxWorks
17719 @cindex VxWorks, interfacing
17722 This package provides a limited binding to the VxWorks API.
17723 In particular, it interfaces with the
17724 VxWorks hardware interrupt facilities.
17726 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
17727 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
17728 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
17729 @cindex Interfacing to VxWorks' I/O
17730 @cindex VxWorks, I/O interfacing
17731 @cindex VxWorks, Get_Immediate
17732 @cindex Get_Immediate, VxWorks
17735 This package provides a binding to the ioctl (IO/Control)
17736 function of VxWorks, defining a set of option values and
17737 function codes. A particular use of this package is
17738 to enable the use of Get_Immediate under VxWorks.
17740 @node System.Address_Image (s-addima.ads)
17741 @section @code{System.Address_Image} (@file{s-addima.ads})
17742 @cindex @code{System.Address_Image} (@file{s-addima.ads})
17743 @cindex Address image
17744 @cindex Image, of an address
17747 This function provides a useful debugging
17748 function that gives an (implementation dependent)
17749 string which identifies an address.
17751 @node System.Assertions (s-assert.ads)
17752 @section @code{System.Assertions} (@file{s-assert.ads})
17753 @cindex @code{System.Assertions} (@file{s-assert.ads})
17755 @cindex Assert_Failure, exception
17758 This package provides the declaration of the exception raised
17759 by an run-time assertion failure, as well as the routine that
17760 is used internally to raise this assertion.
17762 @node System.Memory (s-memory.ads)
17763 @section @code{System.Memory} (@file{s-memory.ads})
17764 @cindex @code{System.Memory} (@file{s-memory.ads})
17765 @cindex Memory allocation
17768 This package provides the interface to the low level routines used
17769 by the generated code for allocation and freeing storage for the
17770 default storage pool (analogous to the C routines malloc and free.
17771 It also provides a reallocation interface analogous to the C routine
17772 realloc. The body of this unit may be modified to provide alternative
17773 allocation mechanisms for the default pool, and in addition, direct
17774 calls to this unit may be made for low level allocation uses (for
17775 example see the body of @code{GNAT.Tables}).
17777 @node System.Multiprocessors (s-multip.ads)
17778 @section @code{System.Multiprocessors} (@file{s-multip.ads})
17779 @cindex @code{System.Multiprocessors} (@file{s-multip.ads})
17780 @cindex Multiprocessor interface
17781 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
17782 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
17783 technically an implementation-defined addition).
17785 @node System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
17786 @section @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
17787 @cindex @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
17788 @cindex Multiprocessor interface
17789 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
17790 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
17791 technically an implementation-defined addition).
17793 @node System.Partition_Interface (s-parint.ads)
17794 @section @code{System.Partition_Interface} (@file{s-parint.ads})
17795 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
17796 @cindex Partition interfacing functions
17799 This package provides facilities for partition interfacing. It
17800 is used primarily in a distribution context when using Annex E
17803 @node System.Pool_Global (s-pooglo.ads)
17804 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
17805 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
17806 @cindex Storage pool, global
17807 @cindex Global storage pool
17810 This package provides a storage pool that is equivalent to the default
17811 storage pool used for access types for which no pool is specifically
17812 declared. It uses malloc/free to allocate/free and does not attempt to
17813 do any automatic reclamation.
17815 @node System.Pool_Local (s-pooloc.ads)
17816 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
17817 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
17818 @cindex Storage pool, local
17819 @cindex Local storage pool
17822 This package provides a storage pool that is intended for use with locally
17823 defined access types. It uses malloc/free for allocate/free, and maintains
17824 a list of allocated blocks, so that all storage allocated for the pool can
17825 be freed automatically when the pool is finalized.
17827 @node System.Restrictions (s-restri.ads)
17828 @section @code{System.Restrictions} (@file{s-restri.ads})
17829 @cindex @code{System.Restrictions} (@file{s-restri.ads})
17830 @cindex Run-time restrictions access
17833 This package provides facilities for accessing at run time
17834 the status of restrictions specified at compile time for
17835 the partition. Information is available both with regard
17836 to actual restrictions specified, and with regard to
17837 compiler determined information on which restrictions
17838 are violated by one or more packages in the partition.
17840 @node System.Rident (s-rident.ads)
17841 @section @code{System.Rident} (@file{s-rident.ads})
17842 @cindex @code{System.Rident} (@file{s-rident.ads})
17843 @cindex Restrictions definitions
17846 This package provides definitions of the restrictions
17847 identifiers supported by GNAT, and also the format of
17848 the restrictions provided in package System.Restrictions.
17849 It is not normally necessary to @code{with} this generic package
17850 since the necessary instantiation is included in
17851 package System.Restrictions.
17853 @node System.Strings.Stream_Ops (s-ststop.ads)
17854 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
17855 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
17856 @cindex Stream operations
17857 @cindex String stream operations
17860 This package provides a set of stream subprograms for standard string types.
17861 It is intended primarily to support implicit use of such subprograms when
17862 stream attributes are applied to string types, but the subprograms in this
17863 package can be used directly by application programs.
17865 @node System.Task_Info (s-tasinf.ads)
17866 @section @code{System.Task_Info} (@file{s-tasinf.ads})
17867 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
17868 @cindex Task_Info pragma
17871 This package provides target dependent functionality that is used
17872 to support the @code{Task_Info} pragma
17874 @node System.Wch_Cnv (s-wchcnv.ads)
17875 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
17876 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
17877 @cindex Wide Character, Representation
17878 @cindex Wide String, Conversion
17879 @cindex Representation of wide characters
17882 This package provides routines for converting between
17883 wide and wide wide characters and a representation as a value of type
17884 @code{Standard.String}, using a specified wide character
17885 encoding method. It uses definitions in
17886 package @code{System.Wch_Con}.
17888 @node System.Wch_Con (s-wchcon.ads)
17889 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
17890 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
17893 This package provides definitions and descriptions of
17894 the various methods used for encoding wide characters
17895 in ordinary strings. These definitions are used by
17896 the package @code{System.Wch_Cnv}.
17898 @node Interfacing to Other Languages
17899 @chapter Interfacing to Other Languages
17901 The facilities in annex B of the Ada Reference Manual are fully
17902 implemented in GNAT, and in addition, a full interface to C++ is
17906 * Interfacing to C::
17907 * Interfacing to C++::
17908 * Interfacing to COBOL::
17909 * Interfacing to Fortran::
17910 * Interfacing to non-GNAT Ada code::
17913 @node Interfacing to C
17914 @section Interfacing to C
17917 Interfacing to C with GNAT can use one of two approaches:
17921 The types in the package @code{Interfaces.C} may be used.
17923 Standard Ada types may be used directly. This may be less portable to
17924 other compilers, but will work on all GNAT compilers, which guarantee
17925 correspondence between the C and Ada types.
17929 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
17930 effect, since this is the default. The following table shows the
17931 correspondence between Ada scalar types and the corresponding C types.
17936 @item Short_Integer
17938 @item Short_Short_Integer
17942 @item Long_Long_Integer
17950 @item Long_Long_Float
17951 This is the longest floating-point type supported by the hardware.
17955 Additionally, there are the following general correspondences between Ada
17959 Ada enumeration types map to C enumeration types directly if pragma
17960 @code{Convention C} is specified, which causes them to have int
17961 length. Without pragma @code{Convention C}, Ada enumeration types map to
17962 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
17963 @code{int}, respectively) depending on the number of values passed.
17964 This is the only case in which pragma @code{Convention C} affects the
17965 representation of an Ada type.
17968 Ada access types map to C pointers, except for the case of pointers to
17969 unconstrained types in Ada, which have no direct C equivalent.
17972 Ada arrays map directly to C arrays.
17975 Ada records map directly to C structures.
17978 Packed Ada records map to C structures where all members are bit fields
17979 of the length corresponding to the @code{@var{type}'Size} value in Ada.
17982 @node Interfacing to C++
17983 @section Interfacing to C++
17986 The interface to C++ makes use of the following pragmas, which are
17987 primarily intended to be constructed automatically using a binding generator
17988 tool, although it is possible to construct them by hand.
17990 Using these pragmas it is possible to achieve complete
17991 inter-operability between Ada tagged types and C++ class definitions.
17992 See @ref{Implementation Defined Pragmas}, for more details.
17995 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
17996 The argument denotes an entity in the current declarative region that is
17997 declared as a tagged or untagged record type. It indicates that the type
17998 corresponds to an externally declared C++ class type, and is to be laid
17999 out the same way that C++ would lay out the type.
18001 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
18002 for backward compatibility but its functionality is available
18003 using pragma @code{Import} with @code{Convention} = @code{CPP}.
18005 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
18006 This pragma identifies an imported function (imported in the usual way
18007 with pragma @code{Import}) as corresponding to a C++ constructor.
18010 A few restrictions are placed on the use of the @code{Access} attribute
18011 in conjunction with subprograms subject to convention @code{CPP}: the
18012 attribute may be used neither on primitive operations of a tagged
18013 record type with convention @code{CPP}, imported or not, nor on
18014 subprograms imported with pragma @code{CPP_Constructor}.
18016 In addition, C++ exceptions are propagated and can be handled in an
18017 @code{others} choice of an exception handler. The corresponding Ada
18018 occurrence has no message, and the simple name of the exception identity
18019 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
18020 tasks works properly when such foreign exceptions are propagated.
18022 @node Interfacing to COBOL
18023 @section Interfacing to COBOL
18026 Interfacing to COBOL is achieved as described in section B.4 of
18027 the Ada Reference Manual.
18029 @node Interfacing to Fortran
18030 @section Interfacing to Fortran
18033 Interfacing to Fortran is achieved as described in section B.5 of the
18034 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
18035 multi-dimensional array causes the array to be stored in column-major
18036 order as required for convenient interface to Fortran.
18038 @node Interfacing to non-GNAT Ada code
18039 @section Interfacing to non-GNAT Ada code
18041 It is possible to specify the convention @code{Ada} in a pragma
18042 @code{Import} or pragma @code{Export}. However this refers to
18043 the calling conventions used by GNAT, which may or may not be
18044 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
18045 compiler to allow interoperation.
18047 If arguments types are kept simple, and if the foreign compiler generally
18048 follows system calling conventions, then it may be possible to integrate
18049 files compiled by other Ada compilers, provided that the elaboration
18050 issues are adequately addressed (for example by eliminating the
18051 need for any load time elaboration).
18053 In particular, GNAT running on VMS is designed to
18054 be highly compatible with the DEC Ada 83 compiler, so this is one
18055 case in which it is possible to import foreign units of this type,
18056 provided that the data items passed are restricted to simple scalar
18057 values or simple record types without variants, or simple array
18058 types with fixed bounds.
18060 @node Specialized Needs Annexes
18061 @chapter Specialized Needs Annexes
18064 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
18065 required in all implementations. However, as described in this chapter,
18066 GNAT implements all of these annexes:
18069 @item Systems Programming (Annex C)
18070 The Systems Programming Annex is fully implemented.
18072 @item Real-Time Systems (Annex D)
18073 The Real-Time Systems Annex is fully implemented.
18075 @item Distributed Systems (Annex E)
18076 Stub generation is fully implemented in the GNAT compiler. In addition,
18077 a complete compatible PCS is available as part of the GLADE system,
18078 a separate product. When the two
18079 products are used in conjunction, this annex is fully implemented.
18081 @item Information Systems (Annex F)
18082 The Information Systems annex is fully implemented.
18084 @item Numerics (Annex G)
18085 The Numerics Annex is fully implemented.
18087 @item Safety and Security / High-Integrity Systems (Annex H)
18088 The Safety and Security Annex (termed the High-Integrity Systems Annex
18089 in Ada 2005) is fully implemented.
18092 @node Implementation of Specific Ada Features
18093 @chapter Implementation of Specific Ada Features
18096 This chapter describes the GNAT implementation of several Ada language
18100 * Machine Code Insertions::
18101 * GNAT Implementation of Tasking::
18102 * GNAT Implementation of Shared Passive Packages::
18103 * Code Generation for Array Aggregates::
18104 * The Size of Discriminated Records with Default Discriminants::
18105 * Strict Conformance to the Ada Reference Manual::
18108 @node Machine Code Insertions
18109 @section Machine Code Insertions
18110 @cindex Machine Code insertions
18113 Package @code{Machine_Code} provides machine code support as described
18114 in the Ada Reference Manual in two separate forms:
18117 Machine code statements, consisting of qualified expressions that
18118 fit the requirements of RM section 13.8.
18120 An intrinsic callable procedure, providing an alternative mechanism of
18121 including machine instructions in a subprogram.
18125 The two features are similar, and both are closely related to the mechanism
18126 provided by the asm instruction in the GNU C compiler. Full understanding
18127 and use of the facilities in this package requires understanding the asm
18128 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
18129 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
18131 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
18132 semantic restrictions and effects as described below. Both are provided so
18133 that the procedure call can be used as a statement, and the function call
18134 can be used to form a code_statement.
18136 The first example given in the GCC documentation is the C @code{asm}
18139 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
18143 The equivalent can be written for GNAT as:
18145 @smallexample @c ada
18146 Asm ("fsinx %1 %0",
18147 My_Float'Asm_Output ("=f", result),
18148 My_Float'Asm_Input ("f", angle));
18152 The first argument to @code{Asm} is the assembler template, and is
18153 identical to what is used in GNU C@. This string must be a static
18154 expression. The second argument is the output operand list. It is
18155 either a single @code{Asm_Output} attribute reference, or a list of such
18156 references enclosed in parentheses (technically an array aggregate of
18159 The @code{Asm_Output} attribute denotes a function that takes two
18160 parameters. The first is a string, the second is the name of a variable
18161 of the type designated by the attribute prefix. The first (string)
18162 argument is required to be a static expression and designates the
18163 constraint for the parameter (e.g.@: what kind of register is
18164 required). The second argument is the variable to be updated with the
18165 result. The possible values for constraint are the same as those used in
18166 the RTL, and are dependent on the configuration file used to build the
18167 GCC back end. If there are no output operands, then this argument may
18168 either be omitted, or explicitly given as @code{No_Output_Operands}.
18170 The second argument of @code{@var{my_float}'Asm_Output} functions as
18171 though it were an @code{out} parameter, which is a little curious, but
18172 all names have the form of expressions, so there is no syntactic
18173 irregularity, even though normally functions would not be permitted
18174 @code{out} parameters. The third argument is the list of input
18175 operands. It is either a single @code{Asm_Input} attribute reference, or
18176 a list of such references enclosed in parentheses (technically an array
18177 aggregate of such references).
18179 The @code{Asm_Input} attribute denotes a function that takes two
18180 parameters. The first is a string, the second is an expression of the
18181 type designated by the prefix. The first (string) argument is required
18182 to be a static expression, and is the constraint for the parameter,
18183 (e.g.@: what kind of register is required). The second argument is the
18184 value to be used as the input argument. The possible values for the
18185 constant are the same as those used in the RTL, and are dependent on
18186 the configuration file used to built the GCC back end.
18188 If there are no input operands, this argument may either be omitted, or
18189 explicitly given as @code{No_Input_Operands}. The fourth argument, not
18190 present in the above example, is a list of register names, called the
18191 @dfn{clobber} argument. This argument, if given, must be a static string
18192 expression, and is a space or comma separated list of names of registers
18193 that must be considered destroyed as a result of the @code{Asm} call. If
18194 this argument is the null string (the default value), then the code
18195 generator assumes that no additional registers are destroyed.
18197 The fifth argument, not present in the above example, called the
18198 @dfn{volatile} argument, is by default @code{False}. It can be set to
18199 the literal value @code{True} to indicate to the code generator that all
18200 optimizations with respect to the instruction specified should be
18201 suppressed, and that in particular, for an instruction that has outputs,
18202 the instruction will still be generated, even if none of the outputs are
18203 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
18204 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
18205 Generally it is strongly advisable to use Volatile for any ASM statement
18206 that is missing either input or output operands, or when two or more ASM
18207 statements appear in sequence, to avoid unwanted optimizations. A warning
18208 is generated if this advice is not followed.
18210 The @code{Asm} subprograms may be used in two ways. First the procedure
18211 forms can be used anywhere a procedure call would be valid, and
18212 correspond to what the RM calls ``intrinsic'' routines. Such calls can
18213 be used to intersperse machine instructions with other Ada statements.
18214 Second, the function forms, which return a dummy value of the limited
18215 private type @code{Asm_Insn}, can be used in code statements, and indeed
18216 this is the only context where such calls are allowed. Code statements
18217 appear as aggregates of the form:
18219 @smallexample @c ada
18220 Asm_Insn'(Asm (@dots{}));
18221 Asm_Insn'(Asm_Volatile (@dots{}));
18225 In accordance with RM rules, such code statements are allowed only
18226 within subprograms whose entire body consists of such statements. It is
18227 not permissible to intermix such statements with other Ada statements.
18229 Typically the form using intrinsic procedure calls is more convenient
18230 and more flexible. The code statement form is provided to meet the RM
18231 suggestion that such a facility should be made available. The following
18232 is the exact syntax of the call to @code{Asm}. As usual, if named notation
18233 is used, the arguments may be given in arbitrary order, following the
18234 normal rules for use of positional and named arguments)
18238 [Template =>] static_string_EXPRESSION
18239 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
18240 [,[Inputs =>] INPUT_OPERAND_LIST ]
18241 [,[Clobber =>] static_string_EXPRESSION ]
18242 [,[Volatile =>] static_boolean_EXPRESSION] )
18244 OUTPUT_OPERAND_LIST ::=
18245 [PREFIX.]No_Output_Operands
18246 | OUTPUT_OPERAND_ATTRIBUTE
18247 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
18249 OUTPUT_OPERAND_ATTRIBUTE ::=
18250 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
18252 INPUT_OPERAND_LIST ::=
18253 [PREFIX.]No_Input_Operands
18254 | INPUT_OPERAND_ATTRIBUTE
18255 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
18257 INPUT_OPERAND_ATTRIBUTE ::=
18258 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
18262 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
18263 are declared in the package @code{Machine_Code} and must be referenced
18264 according to normal visibility rules. In particular if there is no
18265 @code{use} clause for this package, then appropriate package name
18266 qualification is required.
18268 @node GNAT Implementation of Tasking
18269 @section GNAT Implementation of Tasking
18272 This chapter outlines the basic GNAT approach to tasking (in particular,
18273 a multi-layered library for portability) and discusses issues related
18274 to compliance with the Real-Time Systems Annex.
18277 * Mapping Ada Tasks onto the Underlying Kernel Threads::
18278 * Ensuring Compliance with the Real-Time Annex::
18281 @node Mapping Ada Tasks onto the Underlying Kernel Threads
18282 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
18285 GNAT's run-time support comprises two layers:
18288 @item GNARL (GNAT Run-time Layer)
18289 @item GNULL (GNAT Low-level Library)
18293 In GNAT, Ada's tasking services rely on a platform and OS independent
18294 layer known as GNARL@. This code is responsible for implementing the
18295 correct semantics of Ada's task creation, rendezvous, protected
18298 GNARL decomposes Ada's tasking semantics into simpler lower level
18299 operations such as create a thread, set the priority of a thread,
18300 yield, create a lock, lock/unlock, etc. The spec for these low-level
18301 operations constitutes GNULLI, the GNULL Interface. This interface is
18302 directly inspired from the POSIX real-time API@.
18304 If the underlying executive or OS implements the POSIX standard
18305 faithfully, the GNULL Interface maps as is to the services offered by
18306 the underlying kernel. Otherwise, some target dependent glue code maps
18307 the services offered by the underlying kernel to the semantics expected
18310 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
18311 key point is that each Ada task is mapped on a thread in the underlying
18312 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
18314 In addition Ada task priorities map onto the underlying thread priorities.
18315 Mapping Ada tasks onto the underlying kernel threads has several advantages:
18319 The underlying scheduler is used to schedule the Ada tasks. This
18320 makes Ada tasks as efficient as kernel threads from a scheduling
18324 Interaction with code written in C containing threads is eased
18325 since at the lowest level Ada tasks and C threads map onto the same
18326 underlying kernel concept.
18329 When an Ada task is blocked during I/O the remaining Ada tasks are
18333 On multiprocessor systems Ada tasks can execute in parallel.
18337 Some threads libraries offer a mechanism to fork a new process, with the
18338 child process duplicating the threads from the parent.
18340 support this functionality when the parent contains more than one task.
18341 @cindex Forking a new process
18343 @node Ensuring Compliance with the Real-Time Annex
18344 @subsection Ensuring Compliance with the Real-Time Annex
18345 @cindex Real-Time Systems Annex compliance
18348 Although mapping Ada tasks onto
18349 the underlying threads has significant advantages, it does create some
18350 complications when it comes to respecting the scheduling semantics
18351 specified in the real-time annex (Annex D).
18353 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
18354 scheduling policy states:
18357 @emph{When the active priority of a ready task that is not running
18358 changes, or the setting of its base priority takes effect, the
18359 task is removed from the ready queue for its old active priority
18360 and is added at the tail of the ready queue for its new active
18361 priority, except in the case where the active priority is lowered
18362 due to the loss of inherited priority, in which case the task is
18363 added at the head of the ready queue for its new active priority.}
18367 While most kernels do put tasks at the end of the priority queue when
18368 a task changes its priority, (which respects the main
18369 FIFO_Within_Priorities requirement), almost none keep a thread at the
18370 beginning of its priority queue when its priority drops from the loss
18371 of inherited priority.
18373 As a result most vendors have provided incomplete Annex D implementations.
18375 The GNAT run-time, has a nice cooperative solution to this problem
18376 which ensures that accurate FIFO_Within_Priorities semantics are
18379 The principle is as follows. When an Ada task T is about to start
18380 running, it checks whether some other Ada task R with the same
18381 priority as T has been suspended due to the loss of priority
18382 inheritance. If this is the case, T yields and is placed at the end of
18383 its priority queue. When R arrives at the front of the queue it
18386 Note that this simple scheme preserves the relative order of the tasks
18387 that were ready to execute in the priority queue where R has been
18390 @node GNAT Implementation of Shared Passive Packages
18391 @section GNAT Implementation of Shared Passive Packages
18392 @cindex Shared passive packages
18395 GNAT fully implements the pragma @code{Shared_Passive} for
18396 @cindex pragma @code{Shared_Passive}
18397 the purpose of designating shared passive packages.
18398 This allows the use of passive partitions in the
18399 context described in the Ada Reference Manual; i.e., for communication
18400 between separate partitions of a distributed application using the
18401 features in Annex E.
18403 @cindex Distribution Systems Annex
18405 However, the implementation approach used by GNAT provides for more
18406 extensive usage as follows:
18409 @item Communication between separate programs
18411 This allows separate programs to access the data in passive
18412 partitions, using protected objects for synchronization where
18413 needed. The only requirement is that the two programs have a
18414 common shared file system. It is even possible for programs
18415 running on different machines with different architectures
18416 (e.g.@: different endianness) to communicate via the data in
18417 a passive partition.
18419 @item Persistence between program runs
18421 The data in a passive package can persist from one run of a
18422 program to another, so that a later program sees the final
18423 values stored by a previous run of the same program.
18428 The implementation approach used is to store the data in files. A
18429 separate stream file is created for each object in the package, and
18430 an access to an object causes the corresponding file to be read or
18433 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
18434 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
18435 set to the directory to be used for these files.
18436 The files in this directory
18437 have names that correspond to their fully qualified names. For
18438 example, if we have the package
18440 @smallexample @c ada
18442 pragma Shared_Passive (X);
18449 and the environment variable is set to @code{/stemp/}, then the files created
18450 will have the names:
18458 These files are created when a value is initially written to the object, and
18459 the files are retained until manually deleted. This provides the persistence
18460 semantics. If no file exists, it means that no partition has assigned a value
18461 to the variable; in this case the initial value declared in the package
18462 will be used. This model ensures that there are no issues in synchronizing
18463 the elaboration process, since elaboration of passive packages elaborates the
18464 initial values, but does not create the files.
18466 The files are written using normal @code{Stream_IO} access.
18467 If you want to be able
18468 to communicate between programs or partitions running on different
18469 architectures, then you should use the XDR versions of the stream attribute
18470 routines, since these are architecture independent.
18472 If active synchronization is required for access to the variables in the
18473 shared passive package, then as described in the Ada Reference Manual, the
18474 package may contain protected objects used for this purpose. In this case
18475 a lock file (whose name is @file{___lock} (three underscores)
18476 is created in the shared memory directory.
18477 @cindex @file{___lock} file (for shared passive packages)
18478 This is used to provide the required locking
18479 semantics for proper protected object synchronization.
18481 As of January 2003, GNAT supports shared passive packages on all platforms
18482 except for OpenVMS.
18484 @node Code Generation for Array Aggregates
18485 @section Code Generation for Array Aggregates
18488 * Static constant aggregates with static bounds::
18489 * Constant aggregates with unconstrained nominal types::
18490 * Aggregates with static bounds::
18491 * Aggregates with non-static bounds::
18492 * Aggregates in assignment statements::
18496 Aggregates have a rich syntax and allow the user to specify the values of
18497 complex data structures by means of a single construct. As a result, the
18498 code generated for aggregates can be quite complex and involve loops, case
18499 statements and multiple assignments. In the simplest cases, however, the
18500 compiler will recognize aggregates whose components and constraints are
18501 fully static, and in those cases the compiler will generate little or no
18502 executable code. The following is an outline of the code that GNAT generates
18503 for various aggregate constructs. For further details, you will find it
18504 useful to examine the output produced by the -gnatG flag to see the expanded
18505 source that is input to the code generator. You may also want to examine
18506 the assembly code generated at various levels of optimization.
18508 The code generated for aggregates depends on the context, the component values,
18509 and the type. In the context of an object declaration the code generated is
18510 generally simpler than in the case of an assignment. As a general rule, static
18511 component values and static subtypes also lead to simpler code.
18513 @node Static constant aggregates with static bounds
18514 @subsection Static constant aggregates with static bounds
18517 For the declarations:
18518 @smallexample @c ada
18519 type One_Dim is array (1..10) of integer;
18520 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
18524 GNAT generates no executable code: the constant ar0 is placed in static memory.
18525 The same is true for constant aggregates with named associations:
18527 @smallexample @c ada
18528 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
18529 Cr3 : constant One_Dim := (others => 7777);
18533 The same is true for multidimensional constant arrays such as:
18535 @smallexample @c ada
18536 type two_dim is array (1..3, 1..3) of integer;
18537 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
18541 The same is true for arrays of one-dimensional arrays: the following are
18544 @smallexample @c ada
18545 type ar1b is array (1..3) of boolean;
18546 type ar_ar is array (1..3) of ar1b;
18547 None : constant ar1b := (others => false); -- fully static
18548 None2 : constant ar_ar := (1..3 => None); -- fully static
18552 However, for multidimensional aggregates with named associations, GNAT will
18553 generate assignments and loops, even if all associations are static. The
18554 following two declarations generate a loop for the first dimension, and
18555 individual component assignments for the second dimension:
18557 @smallexample @c ada
18558 Zero1: constant two_dim := (1..3 => (1..3 => 0));
18559 Zero2: constant two_dim := (others => (others => 0));
18562 @node Constant aggregates with unconstrained nominal types
18563 @subsection Constant aggregates with unconstrained nominal types
18566 In such cases the aggregate itself establishes the subtype, so that
18567 associations with @code{others} cannot be used. GNAT determines the
18568 bounds for the actual subtype of the aggregate, and allocates the
18569 aggregate statically as well. No code is generated for the following:
18571 @smallexample @c ada
18572 type One_Unc is array (natural range <>) of integer;
18573 Cr_Unc : constant One_Unc := (12,24,36);
18576 @node Aggregates with static bounds
18577 @subsection Aggregates with static bounds
18580 In all previous examples the aggregate was the initial (and immutable) value
18581 of a constant. If the aggregate initializes a variable, then code is generated
18582 for it as a combination of individual assignments and loops over the target
18583 object. The declarations
18585 @smallexample @c ada
18586 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
18587 Cr_Var2 : One_Dim := (others > -1);
18591 generate the equivalent of
18593 @smallexample @c ada
18599 for I in Cr_Var2'range loop
18604 @node Aggregates with non-static bounds
18605 @subsection Aggregates with non-static bounds
18608 If the bounds of the aggregate are not statically compatible with the bounds
18609 of the nominal subtype of the target, then constraint checks have to be
18610 generated on the bounds. For a multidimensional array, constraint checks may
18611 have to be applied to sub-arrays individually, if they do not have statically
18612 compatible subtypes.
18614 @node Aggregates in assignment statements
18615 @subsection Aggregates in assignment statements
18618 In general, aggregate assignment requires the construction of a temporary,
18619 and a copy from the temporary to the target of the assignment. This is because
18620 it is not always possible to convert the assignment into a series of individual
18621 component assignments. For example, consider the simple case:
18623 @smallexample @c ada
18628 This cannot be converted into:
18630 @smallexample @c ada
18636 So the aggregate has to be built first in a separate location, and then
18637 copied into the target. GNAT recognizes simple cases where this intermediate
18638 step is not required, and the assignments can be performed in place, directly
18639 into the target. The following sufficient criteria are applied:
18643 The bounds of the aggregate are static, and the associations are static.
18645 The components of the aggregate are static constants, names of
18646 simple variables that are not renamings, or expressions not involving
18647 indexed components whose operands obey these rules.
18651 If any of these conditions are violated, the aggregate will be built in
18652 a temporary (created either by the front-end or the code generator) and then
18653 that temporary will be copied onto the target.
18655 @node The Size of Discriminated Records with Default Discriminants
18656 @section The Size of Discriminated Records with Default Discriminants
18659 If a discriminated type @code{T} has discriminants with default values, it is
18660 possible to declare an object of this type without providing an explicit
18663 @smallexample @c ada
18665 type Size is range 1..100;
18667 type Rec (D : Size := 15) is record
18668 Name : String (1..D);
18676 Such an object is said to be @emph{unconstrained}.
18677 The discriminant of the object
18678 can be modified by a full assignment to the object, as long as it preserves the
18679 relation between the value of the discriminant, and the value of the components
18682 @smallexample @c ada
18684 Word := (3, "yes");
18686 Word := (5, "maybe");
18688 Word := (5, "no"); -- raises Constraint_Error
18693 In order to support this behavior efficiently, an unconstrained object is
18694 given the maximum size that any value of the type requires. In the case
18695 above, @code{Word} has storage for the discriminant and for
18696 a @code{String} of length 100.
18697 It is important to note that unconstrained objects do not require dynamic
18698 allocation. It would be an improper implementation to place on the heap those
18699 components whose size depends on discriminants. (This improper implementation
18700 was used by some Ada83 compilers, where the @code{Name} component above
18702 been stored as a pointer to a dynamic string). Following the principle that
18703 dynamic storage management should never be introduced implicitly,
18704 an Ada compiler should reserve the full size for an unconstrained declared
18705 object, and place it on the stack.
18707 This maximum size approach
18708 has been a source of surprise to some users, who expect the default
18709 values of the discriminants to determine the size reserved for an
18710 unconstrained object: ``If the default is 15, why should the object occupy
18712 The answer, of course, is that the discriminant may be later modified,
18713 and its full range of values must be taken into account. This is why the
18718 type Rec (D : Positive := 15) is record
18719 Name : String (1..D);
18727 is flagged by the compiler with a warning:
18728 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
18729 because the required size includes @code{Positive'Last}
18730 bytes. As the first example indicates, the proper approach is to declare an
18731 index type of ``reasonable'' range so that unconstrained objects are not too
18734 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
18735 created in the heap by means of an allocator, then it is @emph{not}
18737 it is constrained by the default values of the discriminants, and those values
18738 cannot be modified by full assignment. This is because in the presence of
18739 aliasing all views of the object (which may be manipulated by different tasks,
18740 say) must be consistent, so it is imperative that the object, once created,
18743 @node Strict Conformance to the Ada Reference Manual
18744 @section Strict Conformance to the Ada Reference Manual
18747 The dynamic semantics defined by the Ada Reference Manual impose a set of
18748 run-time checks to be generated. By default, the GNAT compiler will insert many
18749 run-time checks into the compiled code, including most of those required by the
18750 Ada Reference Manual. However, there are three checks that are not enabled
18751 in the default mode for efficiency reasons: arithmetic overflow checking for
18752 integer operations (including division by zero), checks for access before
18753 elaboration on subprogram calls, and stack overflow checking (most operating
18754 systems do not perform this check by default).
18756 Strict conformance to the Ada Reference Manual can be achieved by adding
18757 three compiler options for overflow checking for integer operations
18758 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
18759 calls and generic instantiations (@option{-gnatE}), and stack overflow
18760 checking (@option{-fstack-check}).
18762 Note that the result of a floating point arithmetic operation in overflow and
18763 invalid situations, when the @code{Machine_Overflows} attribute of the result
18764 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
18765 case for machines compliant with the IEEE floating-point standard, but on
18766 machines that are not fully compliant with this standard, such as Alpha, the
18767 @option{-mieee} compiler flag must be used for achieving IEEE confirming
18768 behavior (although at the cost of a significant performance penalty), so
18769 infinite and NaN values are properly generated.
18772 @node Implementation of Ada 2012 Features
18773 @chapter Implementation of Ada 2012 Features
18774 @cindex Ada 2012 implementation status
18776 This chapter contains a complete list of Ada 2012 features that have been
18777 implemented as of GNAT version 6.4. Generally, these features are only
18778 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
18779 @cindex @option{-gnat12} option
18780 or if the configuration pragma @code{Ada_2012} is used.
18781 @cindex pragma @code{Ada_2012}
18782 @cindex configuration pragma @code{Ada_2012}
18783 @cindex @code{Ada_2012} configuration pragma
18784 However, new pragmas, attributes, and restrictions are
18785 unconditionally available, since the Ada 95 standard allows the addition of
18786 new pragmas, attributes, and restrictions (there are exceptions, which are
18787 documented in the individual descriptions), and also certain packages
18788 were made available in earlier versions of Ada.
18790 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
18791 This date shows the implementation date of the feature. Any wavefront
18792 subsequent to this date will contain the indicated feature, as will any
18793 subsequent releases. A date of 0000-00-00 means that GNAT has always
18794 implemented the feature, or implemented it as soon as it appeared as a
18795 binding interpretation.
18797 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
18798 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
18799 The features are ordered based on the relevant sections of the Ada
18800 Reference Manual (``RM''). When a given AI relates to multiple points
18801 in the RM, the earliest is used.
18803 A complete description of the AIs may be found in
18804 @url{www.ada-auth.org/ai05-summary.html}.
18809 @emph{AI-0176 Quantified expressions (2010-09-29)}
18810 @cindex AI-0176 (Ada 2012 feature)
18813 Both universally and existentially quantified expressions are implemented.
18814 They use the new syntax for iterators proposed in AI05-139-2, as well as
18815 the standard Ada loop syntax.
18818 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
18821 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
18822 @cindex AI-0079 (Ada 2012 feature)
18825 Wide characters in the unicode category @i{other_format} are now allowed in
18826 source programs between tokens, but not within a token such as an identifier.
18829 RM References: 2.01 (4/2) 2.02 (7)
18832 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
18833 @cindex AI-0091 (Ada 2012 feature)
18836 Wide characters in the unicode category @i{other_format} are not permitted
18837 within an identifier, since this can be a security problem. The error
18838 message for this case has been improved to be more specific, but GNAT has
18839 never allowed such characters to appear in identifiers.
18842 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)
18845 @emph{AI-0100 Placement of pragmas (2010-07-01)}
18846 @cindex AI-0100 (Ada 2012 feature)
18849 This AI is an earlier version of AI-163. It simplifies the rules
18850 for legal placement of pragmas. In the case of lists that allow pragmas, if
18851 the list may have no elements, then the list may consist solely of pragmas.
18854 RM References: 2.08 (7)
18857 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
18858 @cindex AI-0163 (Ada 2012 feature)
18861 A statement sequence may be composed entirely of pragmas. It is no longer
18862 necessary to add a dummy @code{null} statement to make the sequence legal.
18865 RM References: 2.08 (7) 2.08 (16)
18869 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
18870 @cindex AI-0080 (Ada 2012 feature)
18873 This is an editorial change only, described as non-testable in the AI.
18876 RM References: 3.01 (7)
18880 @emph{AI-0183 Aspect specifications (2010-08-16)}
18881 @cindex AI-0183 (Ada 2012 feature)
18884 Aspect specifications have been fully implemented except for pre and post-
18885 conditions, and type invariants, which have their own separate AI's. All
18886 forms of declarations listed in the AI are supported. The following is a
18887 list of the aspects supported (with GNAT implementation aspects marked)
18889 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
18890 @item @code{Ada_2005} @tab -- GNAT
18891 @item @code{Ada_2012} @tab -- GNAT
18892 @item @code{Address} @tab
18893 @item @code{Alignment} @tab
18894 @item @code{Atomic} @tab
18895 @item @code{Atomic_Components} @tab
18896 @item @code{Bit_Order} @tab
18897 @item @code{Component_Size} @tab
18898 @item @code{Contract_Cases} @tab -- GNAT
18899 @item @code{Discard_Names} @tab
18900 @item @code{External_Tag} @tab
18901 @item @code{Favor_Top_Level} @tab -- GNAT
18902 @item @code{Inline} @tab
18903 @item @code{Inline_Always} @tab -- GNAT
18904 @item @code{Invariant} @tab -- GNAT
18905 @item @code{Machine_Radix} @tab
18906 @item @code{No_Return} @tab
18907 @item @code{Object_Size} @tab -- GNAT
18908 @item @code{Pack} @tab
18909 @item @code{Persistent_BSS} @tab -- GNAT
18910 @item @code{Post} @tab
18911 @item @code{Pre} @tab
18912 @item @code{Predicate} @tab
18913 @item @code{Preelaborable_Initialization} @tab
18914 @item @code{Pure_Function} @tab -- GNAT
18915 @item @code{Remote_Access_Type} @tab -- GNAT
18916 @item @code{Shared} @tab -- GNAT
18917 @item @code{Size} @tab
18918 @item @code{Storage_Pool} @tab
18919 @item @code{Storage_Size} @tab
18920 @item @code{Stream_Size} @tab
18921 @item @code{Suppress} @tab
18922 @item @code{Suppress_Debug_Info} @tab -- GNAT
18923 @item @code{Test_Case} @tab -- GNAT
18924 @item @code{Type_Invariant} @tab
18925 @item @code{Unchecked_Union} @tab
18926 @item @code{Universal_Aliasing} @tab -- GNAT
18927 @item @code{Unmodified} @tab -- GNAT
18928 @item @code{Unreferenced} @tab -- GNAT
18929 @item @code{Unreferenced_Objects} @tab -- GNAT
18930 @item @code{Unsuppress} @tab
18931 @item @code{Value_Size} @tab -- GNAT
18932 @item @code{Volatile} @tab
18933 @item @code{Volatile_Components}
18934 @item @code{Warnings} @tab -- GNAT
18938 Note that for aspects with an expression, e.g. @code{Size}, the expression is
18939 treated like a default expression (visibility is analyzed at the point of
18940 occurrence of the aspect, but evaluation of the expression occurs at the
18941 freeze point of the entity involved).
18944 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
18945 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
18946 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
18947 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
18948 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
18953 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
18954 @cindex AI-0128 (Ada 2012 feature)
18957 If an equality operator ("=") is declared for a type, then the implicitly
18958 declared inequality operator ("/=") is a primitive operation of the type.
18959 This is the only reasonable interpretation, and is the one always implemented
18960 by GNAT, but the RM was not entirely clear in making this point.
18963 RM References: 3.02.03 (6) 6.06 (6)
18966 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
18967 @cindex AI-0003 (Ada 2012 feature)
18970 In Ada 2012, a qualified expression is considered to be syntactically a name,
18971 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
18972 useful in disambiguating some cases of overloading.
18975 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
18979 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
18980 @cindex AI-0120 (Ada 2012 feature)
18983 This is an RM editorial change only. The section that lists objects that are
18984 constant failed to include the current instance of a protected object
18985 within a protected function. This has always been treated as a constant
18989 RM References: 3.03 (21)
18992 @emph{AI-0008 General access to constrained objects (0000-00-00)}
18993 @cindex AI-0008 (Ada 2012 feature)
18996 The wording in the RM implied that if you have a general access to a
18997 constrained object, it could be used to modify the discriminants. This was
18998 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
18999 has always done so in this situation.
19002 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
19006 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
19007 @cindex AI-0093 (Ada 2012 feature)
19010 This is an editorial change only, to make more widespread use of the Ada 2012
19011 ``immutably limited''.
19014 RM References: 3.03 (23.4/3)
19019 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
19020 @cindex AI-0096 (Ada 2012 feature)
19023 In general it is illegal for a type derived from a formal limited type to be
19024 nonlimited. This AI makes an exception to this rule: derivation is legal
19025 if it appears in the private part of the generic, and the formal type is not
19026 tagged. If the type is tagged, the legality check must be applied to the
19027 private part of the package.
19030 RM References: 3.04 (5.1/2) 6.02 (7)
19034 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
19035 @cindex AI-0181 (Ada 2012 feature)
19038 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
19039 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
19040 @code{Image} and @code{Value} attributes for the character types. Strictly
19041 speaking this is an inconsistency with Ada 95, but in practice the use of
19042 these attributes is so obscure that it will not cause problems.
19045 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
19049 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
19050 @cindex AI-0182 (Ada 2012 feature)
19053 This AI allows @code{Character'Value} to accept the string @code{'?'} where
19054 @code{?} is any character including non-graphic control characters. GNAT has
19055 always accepted such strings. It also allows strings such as
19056 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
19057 permission and raises @code{Constraint_Error}, as is certainly still
19061 RM References: 3.05 (56/2)
19065 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
19066 @cindex AI-0214 (Ada 2012 feature)
19069 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
19070 to have default expressions by allowing them when the type is limited. It
19071 is often useful to define a default value for a discriminant even though
19072 it can't be changed by assignment.
19075 RM References: 3.07 (9.1/2) 3.07.02 (3)
19079 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
19080 @cindex AI-0102 (Ada 2012 feature)
19083 It is illegal to assign an anonymous access constant to an anonymous access
19084 variable. The RM did not have a clear rule to prevent this, but GNAT has
19085 always generated an error for this usage.
19088 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
19092 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
19093 @cindex AI-0158 (Ada 2012 feature)
19096 This AI extends the syntax of membership tests to simplify complex conditions
19097 that can be expressed as membership in a subset of values of any type. It
19098 introduces syntax for a list of expressions that may be used in loop contexts
19102 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
19106 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
19107 @cindex AI-0173 (Ada 2012 feature)
19110 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
19111 with the tag of an abstract type, and @code{False} otherwise.
19114 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
19119 @emph{AI-0076 function with controlling result (0000-00-00)}
19120 @cindex AI-0076 (Ada 2012 feature)
19123 This is an editorial change only. The RM defines calls with controlling
19124 results, but uses the term ``function with controlling result'' without an
19125 explicit definition.
19128 RM References: 3.09.02 (2/2)
19132 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
19133 @cindex AI-0126 (Ada 2012 feature)
19136 This AI clarifies dispatching rules, and simply confirms that dispatching
19137 executes the operation of the parent type when there is no explicitly or
19138 implicitly declared operation for the descendant type. This has always been
19139 the case in all versions of GNAT.
19142 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
19146 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
19147 @cindex AI-0097 (Ada 2012 feature)
19150 The RM as written implied that in some cases it was possible to create an
19151 object of an abstract type, by having an abstract extension inherit a non-
19152 abstract constructor from its parent type. This mistake has been corrected
19153 in GNAT and in the RM, and this construct is now illegal.
19156 RM References: 3.09.03 (4/2)
19160 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
19161 @cindex AI-0203 (Ada 2012 feature)
19164 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
19165 permitted such usage.
19168 RM References: 3.09.03 (8/3)
19172 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
19173 @cindex AI-0198 (Ada 2012 feature)
19176 This AI resolves a conflict between two rules involving inherited abstract
19177 operations and predefined operators. If a derived numeric type inherits
19178 an abstract operator, it overrides the predefined one. This interpretation
19179 was always the one implemented in GNAT.
19182 RM References: 3.09.03 (4/3)
19185 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
19186 @cindex AI-0073 (Ada 2012 feature)
19189 This AI covers a number of issues regarding returning abstract types. In
19190 particular generic functions cannot have abstract result types or access
19191 result types designated an abstract type. There are some other cases which
19192 are detailed in the AI. Note that this binding interpretation has not been
19193 retrofitted to operate before Ada 2012 mode, since it caused a significant
19194 number of regressions.
19197 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
19201 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
19202 @cindex AI-0070 (Ada 2012 feature)
19205 This is an editorial change only, there are no testable consequences short of
19206 checking for the absence of generated code for an interface declaration.
19209 RM References: 3.09.04 (18/2)
19213 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
19214 @cindex AI-0208 (Ada 2012 feature)
19217 The wording in the Ada 2005 RM concerning characteristics of incomplete views
19218 was incorrect and implied that some programs intended to be legal were now
19219 illegal. GNAT had never considered such programs illegal, so it has always
19220 implemented the intent of this AI.
19223 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
19227 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
19228 @cindex AI-0162 (Ada 2012 feature)
19231 Incomplete types are made more useful by allowing them to be completed by
19232 private types and private extensions.
19235 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
19240 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
19241 @cindex AI-0098 (Ada 2012 feature)
19244 An unintentional omission in the RM implied some inconsistent restrictions on
19245 the use of anonymous access to subprogram values. These restrictions were not
19246 intentional, and have never been enforced by GNAT.
19249 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
19253 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
19254 @cindex AI-0199 (Ada 2012 feature)
19257 A choice list in a record aggregate can include several components of
19258 (distinct) anonymous access types as long as they have matching designated
19262 RM References: 4.03.01 (16)
19266 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
19267 @cindex AI-0220 (Ada 2012 feature)
19270 This AI addresses a wording problem in the RM that appears to permit some
19271 complex cases of aggregates with non-static discriminants. GNAT has always
19272 implemented the intended semantics.
19275 RM References: 4.03.01 (17)
19278 @emph{AI-0147 Conditional expressions (2009-03-29)}
19279 @cindex AI-0147 (Ada 2012 feature)
19282 Conditional expressions are permitted. The form of such an expression is:
19285 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
19288 The parentheses can be omitted in contexts where parentheses are present
19289 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
19290 clause is omitted, @b{else True} is assumed;
19291 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
19292 @emph{(A implies B)} in standard logic.
19295 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
19296 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
19300 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
19301 @cindex AI-0037 (Ada 2012 feature)
19304 This AI confirms that an association of the form @code{Indx => <>} in an
19305 array aggregate must raise @code{Constraint_Error} if @code{Indx}
19306 is out of range. The RM specified a range check on other associations, but
19307 not when the value of the association was defaulted. GNAT has always inserted
19308 a constraint check on the index value.
19311 RM References: 4.03.03 (29)
19315 @emph{AI-0123 Composability of equality (2010-04-13)}
19316 @cindex AI-0123 (Ada 2012 feature)
19319 Equality of untagged record composes, so that the predefined equality for a
19320 composite type that includes a component of some untagged record type
19321 @code{R} uses the equality operation of @code{R} (which may be user-defined
19322 or predefined). This makes the behavior of untagged records identical to that
19323 of tagged types in this respect.
19325 This change is an incompatibility with previous versions of Ada, but it
19326 corrects a non-uniformity that was often a source of confusion. Analysis of
19327 a large number of industrial programs indicates that in those rare cases
19328 where a composite type had an untagged record component with a user-defined
19329 equality, either there was no use of the composite equality, or else the code
19330 expected the same composability as for tagged types, and thus had a bug that
19331 would be fixed by this change.
19334 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
19339 @emph{AI-0088 The value of exponentiation (0000-00-00)}
19340 @cindex AI-0088 (Ada 2012 feature)
19343 This AI clarifies the equivalence rule given for the dynamic semantics of
19344 exponentiation: the value of the operation can be obtained by repeated
19345 multiplication, but the operation can be implemented otherwise (for example
19346 using the familiar divide-by-two-and-square algorithm, even if this is less
19347 accurate), and does not imply repeated reads of a volatile base.
19350 RM References: 4.05.06 (11)
19353 @emph{AI-0188 Case expressions (2010-01-09)}
19354 @cindex AI-0188 (Ada 2012 feature)
19357 Case expressions are permitted. This allows use of constructs such as:
19359 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
19363 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
19366 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
19367 @cindex AI-0104 (Ada 2012 feature)
19370 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
19371 @code{Constraint_Error} because the default value of the allocated object is
19372 @b{null}. This useless construct is illegal in Ada 2012.
19375 RM References: 4.08 (2)
19378 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
19379 @cindex AI-0157 (Ada 2012 feature)
19382 Allocation and Deallocation from an empty storage pool (i.e. allocation or
19383 deallocation of a pointer for which a static storage size clause of zero
19384 has been given) is now illegal and is detected as such. GNAT
19385 previously gave a warning but not an error.
19388 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
19391 @emph{AI-0179 Statement not required after label (2010-04-10)}
19392 @cindex AI-0179 (Ada 2012 feature)
19395 It is not necessary to have a statement following a label, so a label
19396 can appear at the end of a statement sequence without the need for putting a
19397 null statement afterwards, but it is not allowable to have only labels and
19398 no real statements in a statement sequence.
19401 RM References: 5.01 (2)
19405 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
19406 @cindex AI-139-2 (Ada 2012 feature)
19409 The new syntax for iterating over arrays and containers is now implemented.
19410 Iteration over containers is for now limited to read-only iterators. Only
19411 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
19414 RM References: 5.05
19417 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
19418 @cindex AI-0134 (Ada 2012 feature)
19421 For full conformance, the profiles of anonymous-access-to-subprogram
19422 parameters must match. GNAT has always enforced this rule.
19425 RM References: 6.03.01 (18)
19428 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
19429 @cindex AI-0207 (Ada 2012 feature)
19432 This AI confirms that access_to_constant indication must match for mode
19433 conformance. This was implemented in GNAT when the qualifier was originally
19434 introduced in Ada 2005.
19437 RM References: 6.03.01 (16/2)
19441 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
19442 @cindex AI-0046 (Ada 2012 feature)
19445 For full conformance, in the case of access parameters, the null exclusion
19446 must match (either both or neither must have @code{@b{not null}}).
19449 RM References: 6.03.02 (18)
19453 @emph{AI-0118 The association of parameter associations (0000-00-00)}
19454 @cindex AI-0118 (Ada 2012 feature)
19457 This AI clarifies the rules for named associations in subprogram calls and
19458 generic instantiations. The rules have been in place since Ada 83.
19461 RM References: 6.04.01 (2) 12.03 (9)
19465 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
19466 @cindex AI-0196 (Ada 2012 feature)
19469 Null exclusion checks are not made for @code{@b{out}} parameters when
19470 evaluating the actual parameters. GNAT has never generated these checks.
19473 RM References: 6.04.01 (13)
19476 @emph{AI-0015 Constant return objects (0000-00-00)}
19477 @cindex AI-0015 (Ada 2012 feature)
19480 The return object declared in an @i{extended_return_statement} may be
19481 declared constant. This was always intended, and GNAT has always allowed it.
19484 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
19489 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
19490 @cindex AI-0032 (Ada 2012 feature)
19493 If a function returns a class-wide type, the object of an extended return
19494 statement can be declared with a specific type that is covered by the class-
19495 wide type. This has been implemented in GNAT since the introduction of
19496 extended returns. Note AI-0103 complements this AI by imposing matching
19497 rules for constrained return types.
19500 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
19504 @emph{AI-0103 Static matching for extended return (2010-07-23)}
19505 @cindex AI-0103 (Ada 2012 feature)
19508 If the return subtype of a function is an elementary type or a constrained
19509 type, the subtype indication in an extended return statement must match
19510 statically this return subtype.
19513 RM References: 6.05 (5.2/2)
19517 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
19518 @cindex AI-0058 (Ada 2012 feature)
19521 The RM had some incorrect wording implying wrong treatment of abnormal
19522 completion in an extended return. GNAT has always implemented the intended
19523 correct semantics as described by this AI.
19526 RM References: 6.05 (22/2)
19530 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
19531 @cindex AI-0050 (Ada 2012 feature)
19534 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
19535 not take advantage of these incorrect permissions in any case.
19538 RM References: 6.05 (24/2)
19542 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
19543 @cindex AI-0125 (Ada 2012 feature)
19546 In Ada 2012, the declaration of a primitive operation of a type extension
19547 or private extension can also override an inherited primitive that is not
19548 visible at the point of this declaration.
19551 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
19554 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
19555 @cindex AI-0062 (Ada 2012 feature)
19558 A full constant may have a null exclusion even if its associated deferred
19559 constant does not. GNAT has always allowed this.
19562 RM References: 7.04 (6/2) 7.04 (7.1/2)
19566 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
19567 @cindex AI-0178 (Ada 2012 feature)
19570 This AI clarifies the role of incomplete views and plugs an omission in the
19571 RM. GNAT always correctly restricted the use of incomplete views and types.
19574 RM References: 7.05 (3/2) 7.05 (6/2)
19577 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
19578 @cindex AI-0087 (Ada 2012 feature)
19581 The actual for a formal nonlimited derived type cannot be limited. In
19582 particular, a formal derived type that extends a limited interface but which
19583 is not explicitly limited cannot be instantiated with a limited type.
19586 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
19589 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
19590 @cindex AI-0099 (Ada 2012 feature)
19593 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
19594 and therefore depends on the run-time characteristics of an object (i.e. its
19595 tag) and not on its nominal type. As the AI indicates: ``we do not expect
19596 this to affect any implementation''.
19599 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
19604 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
19605 @cindex AI-0064 (Ada 2012 feature)
19608 This is an editorial change only. The intended behavior is already checked
19609 by an existing ACATS test, which GNAT has always executed correctly.
19612 RM References: 7.06.01 (17.1/1)
19615 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
19616 @cindex AI-0026 (Ada 2012 feature)
19619 Record representation clauses concerning Unchecked_Union types cannot mention
19620 the discriminant of the type. The type of a component declared in the variant
19621 part of an Unchecked_Union cannot be controlled, have controlled components,
19622 nor have protected or task parts. If an Unchecked_Union type is declared
19623 within the body of a generic unit or its descendants, then the type of a
19624 component declared in the variant part cannot be a formal private type or a
19625 formal private extension declared within the same generic unit.
19628 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
19632 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
19633 @cindex AI-0205 (Ada 2012 feature)
19636 This AI corrects a simple omission in the RM. Return objects have always
19637 been visible within an extended return statement.
19640 RM References: 8.03 (17)
19644 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
19645 @cindex AI-0042 (Ada 2012 feature)
19648 This AI fixes a wording gap in the RM. An operation of a synchronized
19649 interface can be implemented by a protected or task entry, but the abstract
19650 operation is not being overridden in the usual sense, and it must be stated
19651 separately that this implementation is legal. This has always been the case
19655 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
19658 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
19659 @cindex AI-0030 (Ada 2012 feature)
19662 Requeue is permitted to a protected, synchronized or task interface primitive
19663 providing it is known that the overriding operation is an entry. Otherwise
19664 the requeue statement has the same effect as a procedure call. Use of pragma
19665 @code{Implemented} provides a way to impose a static requirement on the
19666 overriding operation by adhering to one of the implementation kinds: entry,
19667 protected procedure or any of the above.
19670 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
19671 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
19675 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
19676 @cindex AI-0201 (Ada 2012 feature)
19679 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
19680 attribute, then individual components may not be addressable by independent
19681 tasks. However, if the representation clause has no effect (is confirming),
19682 then independence is not compromised. Furthermore, in GNAT, specification of
19683 other appropriately addressable component sizes (e.g. 16 for 8-bit
19684 characters) also preserves independence. GNAT now gives very clear warnings
19685 both for the declaration of such a type, and for any assignment to its components.
19688 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
19691 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
19692 @cindex AI-0009 (Ada 2012 feature)
19695 This AI introduces the new pragmas @code{Independent} and
19696 @code{Independent_Components},
19697 which control guaranteeing independence of access to objects and components.
19698 The AI also requires independence not unaffected by confirming rep clauses.
19701 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
19702 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
19706 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
19707 @cindex AI-0072 (Ada 2012 feature)
19710 This AI clarifies that task signalling for reading @code{'Terminated} only
19711 occurs if the result is True. GNAT semantics has always been consistent with
19712 this notion of task signalling.
19715 RM References: 9.10 (6.1/1)
19718 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
19719 @cindex AI-0108 (Ada 2012 feature)
19722 This AI confirms that an incomplete type from a limited view does not have
19723 discriminants. This has always been the case in GNAT.
19726 RM References: 10.01.01 (12.3/2)
19729 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
19730 @cindex AI-0129 (Ada 2012 feature)
19733 This AI clarifies the description of limited views: a limited view of a
19734 package includes only one view of a type that has an incomplete declaration
19735 and a full declaration (there is no possible ambiguity in a client package).
19736 This AI also fixes an omission: a nested package in the private part has no
19737 limited view. GNAT always implemented this correctly.
19740 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
19745 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
19746 @cindex AI-0077 (Ada 2012 feature)
19749 This AI clarifies that a declaration does not include a context clause,
19750 and confirms that it is illegal to have a context in which both a limited
19751 and a nonlimited view of a package are accessible. Such double visibility
19752 was always rejected by GNAT.
19755 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
19758 @emph{AI-0122 Private with and children of generics (0000-00-00)}
19759 @cindex AI-0122 (Ada 2012 feature)
19762 This AI clarifies the visibility of private children of generic units within
19763 instantiations of a parent. GNAT has always handled this correctly.
19766 RM References: 10.01.02 (12/2)
19771 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
19772 @cindex AI-0040 (Ada 2012 feature)
19775 This AI confirms that a limited with clause in a child unit cannot name
19776 an ancestor of the unit. This has always been checked in GNAT.
19779 RM References: 10.01.02 (20/2)
19782 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
19783 @cindex AI-0132 (Ada 2012 feature)
19786 This AI fills a gap in the description of library unit pragmas. The pragma
19787 clearly must apply to a library unit, even if it does not carry the name
19788 of the enclosing unit. GNAT has always enforced the required check.
19791 RM References: 10.01.05 (7)
19795 @emph{AI-0034 Categorization of limited views (0000-00-00)}
19796 @cindex AI-0034 (Ada 2012 feature)
19799 The RM makes certain limited with clauses illegal because of categorization
19800 considerations, when the corresponding normal with would be legal. This is
19801 not intended, and GNAT has always implemented the recommended behavior.
19804 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
19808 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
19809 @cindex AI-0035 (Ada 2012 feature)
19812 This AI remedies some inconsistencies in the legality rules for Pure units.
19813 Derived access types are legal in a pure unit (on the assumption that the
19814 rule for a zero storage pool size has been enforced on the ancestor type).
19815 The rules are enforced in generic instances and in subunits. GNAT has always
19816 implemented the recommended behavior.
19819 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)
19823 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
19824 @cindex AI-0219 (Ada 2012 feature)
19827 This AI refines the rules for the cases with limited parameters which do not
19828 allow the implementations to omit ``redundant''. GNAT now properly conforms
19829 to the requirements of this binding interpretation.
19832 RM References: 10.02.01 (18/2)
19835 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
19836 @cindex AI-0043 (Ada 2012 feature)
19839 This AI covers various omissions in the RM regarding the raising of
19840 exceptions. GNAT has always implemented the intended semantics.
19843 RM References: 11.04.01 (10.1/2) 11 (2)
19847 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
19848 @cindex AI-0200 (Ada 2012 feature)
19851 This AI plugs a gap in the RM which appeared to allow some obviously intended
19852 illegal instantiations. GNAT has never allowed these instantiations.
19855 RM References: 12.07 (16)
19859 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
19860 @cindex AI-0112 (Ada 2012 feature)
19863 This AI concerns giving names to various representation aspects, but the
19864 practical effect is simply to make the use of duplicate
19865 @code{Atomic}[@code{_Components}],
19866 @code{Volatile}[@code{_Components}] and
19867 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
19868 now performs this required check.
19871 RM References: 13.01 (8)
19874 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
19875 @cindex AI-0106 (Ada 2012 feature)
19878 The RM appeared to allow representation pragmas on generic formal parameters,
19879 but this was not intended, and GNAT has never permitted this usage.
19882 RM References: 13.01 (9.1/1)
19886 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
19887 @cindex AI-0012 (Ada 2012 feature)
19890 It is now illegal to give an inappropriate component size or a pragma
19891 @code{Pack} that attempts to change the component size in the case of atomic
19892 or aliased components. Previously GNAT ignored such an attempt with a
19896 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
19900 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
19901 @cindex AI-0039 (Ada 2012 feature)
19904 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
19905 for stream attributes, but these were never useful and are now illegal. GNAT
19906 has always regarded such expressions as illegal.
19909 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
19913 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
19914 @cindex AI-0095 (Ada 2012 feature)
19917 The prefix of @code{'Address} cannot statically denote a subprogram with
19918 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
19919 @code{Program_Error} if the prefix denotes a subprogram with convention
19923 RM References: 13.03 (11/1)
19927 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
19928 @cindex AI-0116 (Ada 2012 feature)
19931 This AI requires that the alignment of a class-wide object be no greater
19932 than the alignment of any type in the class. GNAT has always followed this
19936 RM References: 13.03 (29) 13.11 (16)
19940 @emph{AI-0146 Type invariants (2009-09-21)}
19941 @cindex AI-0146 (Ada 2012 feature)
19944 Type invariants may be specified for private types using the aspect notation.
19945 Aspect @code{Type_Invariant} may be specified for any private type,
19946 @code{Type_Invariant'Class} can
19947 only be specified for tagged types, and is inherited by any descendent of the
19948 tagged types. The invariant is a boolean expression that is tested for being
19949 true in the following situations: conversions to the private type, object
19950 declarations for the private type that are default initialized, and
19952 parameters and returned result on return from any primitive operation for
19953 the type that is visible to a client.
19954 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
19955 @code{Invariant'Class} for @code{Type_Invariant'Class}.
19958 RM References: 13.03.03 (00)
19961 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
19962 @cindex AI-0078 (Ada 2012 feature)
19965 In Ada 2012, compilers are required to support unchecked conversion where the
19966 target alignment is a multiple of the source alignment. GNAT always supported
19967 this case (and indeed all cases of differing alignments, doing copies where
19968 required if the alignment was reduced).
19971 RM References: 13.09 (7)
19975 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
19976 @cindex AI-0195 (Ada 2012 feature)
19979 The handling of invalid values is now designated to be implementation
19980 defined. This is a documentation change only, requiring Annex M in the GNAT
19981 Reference Manual to document this handling.
19982 In GNAT, checks for invalid values are made
19983 only when necessary to avoid erroneous behavior. Operations like assignments
19984 which cannot cause erroneous behavior ignore the possibility of invalid
19985 values and do not do a check. The date given above applies only to the
19986 documentation change, this behavior has always been implemented by GNAT.
19989 RM References: 13.09.01 (10)
19992 @emph{AI-0193 Alignment of allocators (2010-09-16)}
19993 @cindex AI-0193 (Ada 2012 feature)
19996 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
19997 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
20001 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
20002 13.11.01 (2) 13.11.01 (3)
20006 @emph{AI-0177 Parameterized expressions (2010-07-10)}
20007 @cindex AI-0177 (Ada 2012 feature)
20010 The new Ada 2012 notion of parameterized expressions is implemented. The form
20013 @i{function specification} @b{is} (@i{expression})
20017 This is exactly equivalent to the
20018 corresponding function body that returns the expression, but it can appear
20019 in a package spec. Note that the expression must be parenthesized.
20022 RM References: 13.11.01 (3/2)
20025 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
20026 @cindex AI-0033 (Ada 2012 feature)
20029 Neither of these two pragmas may appear within a generic template, because
20030 the generic might be instantiated at other than the library level.
20033 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
20037 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
20038 @cindex AI-0161 (Ada 2012 feature)
20041 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
20042 of the default stream attributes for elementary types. If this restriction is
20043 in force, then it is necessary to provide explicit subprograms for any
20044 stream attributes used.
20047 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
20050 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
20051 @cindex AI-0194 (Ada 2012 feature)
20054 The @code{Stream_Size} attribute returns the default number of bits in the
20055 stream representation of the given type.
20056 This value is not affected by the presence
20057 of stream subprogram attributes for the type. GNAT has always implemented
20058 this interpretation.
20061 RM References: 13.13.02 (1.2/2)
20064 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
20065 @cindex AI-0109 (Ada 2012 feature)
20068 This AI is an editorial change only. It removes the need for a tag check
20069 that can never fail.
20072 RM References: 13.13.02 (34/2)
20075 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
20076 @cindex AI-0007 (Ada 2012 feature)
20079 The RM as written appeared to limit the possibilities of declaring read
20080 attribute procedures for private scalar types. This limitation was not
20081 intended, and has never been enforced by GNAT.
20084 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
20088 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
20089 @cindex AI-0065 (Ada 2012 feature)
20092 This AI clarifies the fact that all remote access types support external
20093 streaming. This fixes an obvious oversight in the definition of the
20094 language, and GNAT always implemented the intended correct rules.
20097 RM References: 13.13.02 (52/2)
20100 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
20101 @cindex AI-0019 (Ada 2012 feature)
20104 The RM suggests that primitive subprograms of a specific tagged type are
20105 frozen when the tagged type is frozen. This would be an incompatible change
20106 and is not intended. GNAT has never attempted this kind of freezing and its
20107 behavior is consistent with the recommendation of this AI.
20110 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)
20113 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
20114 @cindex AI-0017 (Ada 2012 feature)
20117 So-called ``Taft-amendment types'' (i.e., types that are completed in package
20118 bodies) are not frozen by the occurrence of bodies in the
20119 enclosing declarative part. GNAT always implemented this properly.
20122 RM References: 13.14 (3/1)
20126 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
20127 @cindex AI-0060 (Ada 2012 feature)
20130 This AI extends the definition of remote access types to include access
20131 to limited, synchronized, protected or task class-wide interface types.
20132 GNAT already implemented this extension.
20135 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
20138 @emph{AI-0114 Classification of letters (0000-00-00)}
20139 @cindex AI-0114 (Ada 2012 feature)
20142 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
20143 181 (@code{MICRO SIGN}), and
20144 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
20145 lower case letters by Unicode.
20146 However, they are not allowed in identifiers, and they
20147 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
20148 This behavior is consistent with that defined in Ada 95.
20151 RM References: A.03.02 (59) A.04.06 (7)
20155 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
20156 @cindex AI-0185 (Ada 2012 feature)
20159 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
20160 classification functions for @code{Wide_Character} and
20161 @code{Wide_Wide_Character}, as well as providing
20162 case folding routines for @code{Wide_[Wide_]Character} and
20163 @code{Wide_[Wide_]String}.
20166 RM References: A.03.05 (0) A.03.06 (0)
20170 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
20171 @cindex AI-0031 (Ada 2012 feature)
20174 A new version of @code{Find_Token} is added to all relevant string packages,
20175 with an extra parameter @code{From}. Instead of starting at the first
20176 character of the string, the search for a matching Token starts at the
20177 character indexed by the value of @code{From}.
20178 These procedures are available in all versions of Ada
20179 but if used in versions earlier than Ada 2012 they will generate a warning
20180 that an Ada 2012 subprogram is being used.
20183 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
20188 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
20189 @cindex AI-0056 (Ada 2012 feature)
20192 The wording in the Ada 2005 RM implied an incompatible handling of the
20193 @code{Index} functions, resulting in raising an exception instead of
20194 returning zero in some situations.
20195 This was not intended and has been corrected.
20196 GNAT always returned zero, and is thus consistent with this AI.
20199 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
20203 @emph{AI-0137 String encoding package (2010-03-25)}
20204 @cindex AI-0137 (Ada 2012 feature)
20207 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
20208 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
20209 and @code{Wide_Wide_Strings} have been
20210 implemented. These packages (whose documentation can be found in the spec
20211 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
20212 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
20213 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
20214 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
20215 UTF-16), as well as conversions between the different UTF encodings. With
20216 the exception of @code{Wide_Wide_Strings}, these packages are available in
20217 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
20218 The @code{Wide_Wide_Strings package}
20219 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
20220 mode since it uses @code{Wide_Wide_Character}).
20223 RM References: A.04.11
20226 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
20227 @cindex AI-0038 (Ada 2012 feature)
20230 These are minor errors in the description on three points. The intent on
20231 all these points has always been clear, and GNAT has always implemented the
20232 correct intended semantics.
20235 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)
20238 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
20239 @cindex AI-0044 (Ada 2012 feature)
20242 This AI places restrictions on allowed instantiations of generic containers.
20243 These restrictions are not checked by the compiler, so there is nothing to
20244 change in the implementation. This affects only the RM documentation.
20247 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)
20250 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
20251 @cindex AI-0127 (Ada 2012 feature)
20254 This package provides an interface for identifying the current locale.
20257 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
20258 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
20263 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
20264 @cindex AI-0002 (Ada 2012 feature)
20267 The compiler is not required to support exporting an Ada subprogram with
20268 convention C if there are parameters or a return type of an unconstrained
20269 array type (such as @code{String}). GNAT allows such declarations but
20270 generates warnings. It is possible, but complicated, to write the
20271 corresponding C code and certainly such code would be specific to GNAT and
20275 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
20279 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
20280 @cindex AI05-0216 (Ada 2012 feature)
20283 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
20284 forbid tasks declared locally within subprograms, or functions returning task
20285 objects, and that is the implementation that GNAT has always provided.
20286 However the language in the RM was not sufficiently clear on this point.
20287 Thus this is a documentation change in the RM only.
20290 RM References: D.07 (3/3)
20293 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
20294 @cindex AI-0211 (Ada 2012 feature)
20297 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
20298 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
20301 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
20304 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
20305 @cindex AI-0190 (Ada 2012 feature)
20308 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
20309 used to control storage pools globally.
20310 In particular, you can force every access
20311 type that is used for allocation (@b{new}) to have an explicit storage pool,
20312 or you can declare a pool globally to be used for all access types that lack
20316 RM References: D.07 (8)
20319 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
20320 @cindex AI-0189 (Ada 2012 feature)
20323 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
20324 which says that no dynamic allocation will occur once elaboration is
20326 In general this requires a run-time check, which is not required, and which
20327 GNAT does not attempt. But the static cases of allocators in a task body or
20328 in the body of the main program are detected and flagged at compile or bind
20332 RM References: D.07 (19.1/2) H.04 (23.3/2)
20335 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
20336 @cindex AI-0171 (Ada 2012 feature)
20339 A new package @code{System.Multiprocessors} is added, together with the
20340 definition of pragma @code{CPU} for controlling task affinity. A new no
20341 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
20342 is added to the Ravenscar profile.
20345 RM References: D.13.01 (4/2) D.16
20349 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
20350 @cindex AI-0210 (Ada 2012 feature)
20353 This is a documentation only issue regarding wording of metric requirements,
20354 that does not affect the implementation of the compiler.
20357 RM References: D.15 (24/2)
20361 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
20362 @cindex AI-0206 (Ada 2012 feature)
20365 Remote types packages are now allowed to depend on preelaborated packages.
20366 This was formerly considered illegal.
20369 RM References: E.02.02 (6)
20374 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
20375 @cindex AI-0152 (Ada 2012 feature)
20378 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
20379 where the type of the returned value is an anonymous access type.
20382 RM References: H.04 (8/1)
20386 @node Obsolescent Features
20387 @chapter Obsolescent Features
20390 This chapter describes features that are provided by GNAT, but are
20391 considered obsolescent since there are preferred ways of achieving
20392 the same effect. These features are provided solely for historical
20393 compatibility purposes.
20396 * pragma No_Run_Time::
20397 * pragma Ravenscar::
20398 * pragma Restricted_Run_Time::
20401 @node pragma No_Run_Time
20402 @section pragma No_Run_Time
20404 The pragma @code{No_Run_Time} is used to achieve an affect similar
20405 to the use of the "Zero Foot Print" configurable run time, but without
20406 requiring a specially configured run time. The result of using this
20407 pragma, which must be used for all units in a partition, is to restrict
20408 the use of any language features requiring run-time support code. The
20409 preferred usage is to use an appropriately configured run-time that
20410 includes just those features that are to be made accessible.
20412 @node pragma Ravenscar
20413 @section pragma Ravenscar
20415 The pragma @code{Ravenscar} has exactly the same effect as pragma
20416 @code{Profile (Ravenscar)}. The latter usage is preferred since it
20417 is part of the new Ada 2005 standard.
20419 @node pragma Restricted_Run_Time
20420 @section pragma Restricted_Run_Time
20422 The pragma @code{Restricted_Run_Time} has exactly the same effect as
20423 pragma @code{Profile (Restricted)}. The latter usage is
20424 preferred since the Ada 2005 pragma @code{Profile} is intended for
20425 this kind of implementation dependent addition.
20428 @c GNU Free Documentation License
20430 @node Index,,GNU Free Documentation License, Top