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::
120 * Pragma CIL_Constructor::
122 * Pragma Common_Object::
123 * Pragma Compile_Time_Error::
124 * Pragma Compile_Time_Warning::
125 * Pragma Compiler_Unit::
126 * Pragma Complete_Representation::
127 * Pragma Complex_Representation::
128 * Pragma Component_Alignment::
129 * Pragma Contract_Cases::
130 * Pragma Convention_Identifier::
132 * Pragma CPP_Constructor::
133 * Pragma CPP_Virtual::
134 * Pragma CPP_Vtable::
137 * Pragma Debug_Policy::
138 * Pragma Default_Storage_Pool::
139 * Pragma Detect_Blocking::
140 * Pragma Disable_Atomic_Synchronization::
141 * Pragma Dispatching_Domain::
142 * Pragma Elaboration_Checks::
144 * Pragma Enable_Atomic_Synchronization::
145 * Pragma Export_Exception::
146 * Pragma Export_Function::
147 * Pragma Export_Object::
148 * Pragma Export_Procedure::
149 * Pragma Export_Value::
150 * Pragma Export_Valued_Procedure::
151 * Pragma Extend_System::
152 * Pragma Extensions_Allowed::
154 * Pragma External_Name_Casing::
156 * Pragma Favor_Top_Level::
157 * Pragma Finalize_Storage_Only::
158 * Pragma Float_Representation::
160 * Pragma Implementation_Defined::
161 * Pragma Implemented::
162 * Pragma Implicit_Packing::
163 * Pragma Import_Exception::
164 * Pragma Import_Function::
165 * Pragma Import_Object::
166 * Pragma Import_Procedure::
167 * Pragma Import_Valued_Procedure::
168 * Pragma Independent::
169 * Pragma Independent_Components::
170 * Pragma Initialize_Scalars::
171 * Pragma Inline_Always::
172 * Pragma Inline_Generic::
174 * Pragma Interface_Name::
175 * Pragma Interrupt_Handler::
176 * Pragma Interrupt_State::
178 * Pragma Java_Constructor::
179 * Pragma Java_Interface::
180 * Pragma Keep_Names::
183 * Pragma Linker_Alias::
184 * Pragma Linker_Constructor::
185 * Pragma Linker_Destructor::
186 * Pragma Linker_Section::
187 * Pragma Long_Float::
188 * Pragma Loop_Invariant::
189 * Pragma Loop_Optimize::
190 * Pragma Loop_Variant::
191 * Pragma Machine_Attribute::
193 * Pragma Main_Storage::
197 * Pragma No_Run_Time::
198 * Pragma No_Strict_Aliasing ::
199 * Pragma Normalize_Scalars::
200 * Pragma Obsolescent::
201 * Pragma Optimize_Alignment::
203 * Pragma Overflow_Mode::
204 * Pragma Overriding_Renamings::
205 * Pragma Partition_Elaboration_Policy::
207 * Pragma Persistent_BSS::
209 * Pragma Postcondition::
210 * Pragma Precondition::
212 * Pragma Preelaborable_Initialization::
213 * Pragma Preelaborate_05::
214 * Pragma Priority_Specific_Dispatching::
216 * Pragma Profile_Warnings::
217 * Pragma Propagate_Exceptions::
218 * Pragma Psect_Object::
221 * Pragma Pure_Function::
223 * Pragma Relative_Deadline::
224 * Pragma Remote_Access_Type::
225 * Pragma Restricted_Run_Time::
226 * Pragma Restriction_Warnings::
227 * Pragma Share_Generic::
229 * Pragma Short_Circuit_And_Or::
230 * Pragma Short_Descriptors::
231 * Pragma Simple_Storage_Pool_Type::
232 * Pragma Source_File_Name::
233 * Pragma Source_File_Name_Project::
234 * Pragma Source_Reference::
235 * Pragma SPARK_Mode::
236 * Pragma Static_Elaboration_Desired::
237 * Pragma Stream_Convert::
238 * Pragma Style_Checks::
241 * Pragma Suppress_All::
242 * Pragma Suppress_Debug_Info::
243 * Pragma Suppress_Exception_Locations::
244 * Pragma Suppress_Initialization::
247 * Pragma Task_Storage::
249 * Pragma Thread_Local_Storage::
250 * Pragma Time_Slice::
252 * Pragma Unchecked_Union::
253 * Pragma Unimplemented_Unit::
254 * Pragma Universal_Aliasing ::
255 * Pragma Universal_Data::
256 * Pragma Unmodified::
257 * Pragma Unreferenced::
258 * Pragma Unreferenced_Objects::
259 * Pragma Unreserve_All_Interrupts::
260 * Pragma Unsuppress::
261 * Pragma Use_VADS_Size::
262 * Pragma Validity_Checks::
265 * Pragma Weak_External::
266 * Pragma Wide_Character_Encoding::
268 Implementation Defined Aspects
270 * Aspect Abstract_State::
273 * Aspect Compiler_Unit::
274 * Aspect Contract_Cases::
277 * Aspect Dimension_System::
278 * Aspect Favor_Top_Level::
280 * Aspect Inline_Always::
282 * Aspect Object_Size::
283 * Aspect Persistent_BSS::
285 * Aspect Preelaborate_05::
288 * Aspect Pure_Function::
289 * Aspect Remote_Access_Type::
290 * Aspect Scalar_Storage_Order::
292 * Aspect Simple_Storage_Pool::
293 * Aspect Simple_Storage_Pool_Type::
294 * Aspect SPARK_Mode::
295 * Aspect Suppress_Debug_Info::
297 * Aspect Universal_Aliasing::
298 * Aspect Universal_Data::
299 * Aspect Unmodified::
300 * Aspect Unreferenced::
301 * Aspect Unreferenced_Objects::
302 * Aspect Value_Size::
305 Implementation Defined Attributes
307 * Attribute Abort_Signal::
308 * Attribute Address_Size::
309 * Attribute Asm_Input::
310 * Attribute Asm_Output::
311 * Attribute AST_Entry::
313 * Attribute Bit_Position::
314 * Attribute Compiler_Version::
315 * Attribute Code_Address::
316 * Attribute Default_Bit_Order::
317 * Attribute Descriptor_Size::
318 * Attribute Elaborated::
319 * Attribute Elab_Body::
320 * Attribute Elab_Spec::
321 * Attribute Elab_Subp_Body::
323 * Attribute Enabled::
324 * Attribute Enum_Rep::
325 * Attribute Enum_Val::
326 * Attribute Epsilon::
327 * Attribute Fixed_Value::
328 * Attribute Has_Access_Values::
329 * Attribute Has_Discriminants::
331 * Attribute Integer_Value::
332 * Attribute Invalid_Value::
334 * Attribute Loop_Entry::
335 * Attribute Machine_Size::
336 * Attribute Mantissa::
337 * Attribute Max_Interrupt_Priority::
338 * Attribute Max_Priority::
339 * Attribute Maximum_Alignment::
340 * Attribute Mechanism_Code::
341 * Attribute Null_Parameter::
342 * Attribute Object_Size::
343 * Attribute Passed_By_Reference::
344 * Attribute Pool_Address::
345 * Attribute Range_Length::
347 * Attribute Restriction_Set::
349 * Attribute Safe_Emax::
350 * Attribute Safe_Large::
351 * Attribute Scalar_Storage_Order::
352 * Attribute Simple_Storage_Pool::
354 * Attribute Storage_Unit::
355 * Attribute Stub_Type::
356 * Attribute System_Allocator_Alignment::
357 * Attribute Target_Name::
359 * Attribute To_Address::
360 * Attribute Type_Class::
361 * Attribute UET_Address::
362 * Attribute Unconstrained_Array::
363 * Attribute Universal_Literal_String::
364 * Attribute Unrestricted_Access::
366 * Attribute Valid_Scalars::
367 * Attribute VADS_Size::
368 * Attribute Value_Size::
369 * Attribute Wchar_T_Size::
370 * Attribute Word_Size::
372 Standard and Implementation Defined Restrictions
374 * Partition-Wide Restrictions::
375 * Program Unit Level Restrictions::
377 Partition-Wide Restrictions
379 * Immediate_Reclamation::
380 * Max_Asynchronous_Select_Nesting::
381 * Max_Entry_Queue_Length::
382 * Max_Protected_Entries::
383 * Max_Select_Alternatives::
384 * Max_Storage_At_Blocking::
387 * No_Abort_Statements::
388 * No_Access_Parameter_Allocators::
389 * No_Access_Subprograms::
391 * No_Anonymous_Allocators::
394 * No_Default_Initialization::
397 * No_Direct_Boolean_Operators::
399 * No_Dispatching_Calls::
400 * No_Dynamic_Attachment::
401 * No_Dynamic_Priorities::
402 * No_Entry_Calls_In_Elaboration_Code::
403 * No_Enumeration_Maps::
404 * No_Exception_Handlers::
405 * No_Exception_Propagation::
406 * No_Exception_Registration::
410 * No_Floating_Point::
411 * No_Implicit_Conditionals::
412 * No_Implicit_Dynamic_Code::
413 * No_Implicit_Heap_Allocations::
414 * No_Implicit_Loops::
415 * No_Initialize_Scalars::
417 * No_Local_Allocators::
418 * No_Local_Protected_Objects::
419 * No_Local_Timing_Events::
420 * No_Nested_Finalization::
421 * No_Protected_Type_Allocators::
422 * No_Protected_Types::
425 * No_Relative_Delay::
426 * No_Requeue_Statements::
427 * No_Secondary_Stack::
428 * No_Select_Statements::
429 * No_Specific_Termination_Handlers::
430 * No_Specification_of_Aspect::
431 * No_Standard_Allocators_After_Elaboration::
432 * No_Standard_Storage_Pools::
433 * No_Stream_Optimizations::
435 * No_Task_Allocators::
436 * No_Task_Attributes_Package::
437 * No_Task_Hierarchy::
438 * No_Task_Termination::
440 * No_Terminate_Alternatives::
441 * No_Unchecked_Access::
443 * Static_Priorities::
444 * Static_Storage_Size::
446 Program Unit Level Restrictions
448 * No_Elaboration_Code::
450 * No_Implementation_Aspect_Specifications::
451 * No_Implementation_Attributes::
452 * No_Implementation_Identifiers::
453 * No_Implementation_Pragmas::
454 * No_Implementation_Restrictions::
455 * No_Implementation_Units::
456 * No_Implicit_Aliasing::
457 * No_Obsolescent_Features::
458 * No_Wide_Characters::
461 The Implementation of Standard I/O
463 * Standard I/O Packages::
469 * Wide_Wide_Text_IO::
473 * Filenames encoding::
475 * Operations on C Streams::
476 * Interfacing to C Streams::
480 * Ada.Characters.Latin_9 (a-chlat9.ads)::
481 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
482 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
483 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
484 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
485 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
486 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
487 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
488 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
489 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
490 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
491 * Ada.Command_Line.Environment (a-colien.ads)::
492 * Ada.Command_Line.Remove (a-colire.ads)::
493 * Ada.Command_Line.Response_File (a-clrefi.ads)::
494 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
495 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
496 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
497 * Ada.Exceptions.Traceback (a-exctra.ads)::
498 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
499 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
500 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
501 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
502 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
503 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
504 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
505 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
506 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
507 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
508 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
509 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
510 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
511 * GNAT.Altivec (g-altive.ads)::
512 * GNAT.Altivec.Conversions (g-altcon.ads)::
513 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
514 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
515 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
516 * GNAT.Array_Split (g-arrspl.ads)::
517 * GNAT.AWK (g-awk.ads)::
518 * GNAT.Bounded_Buffers (g-boubuf.ads)::
519 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
520 * GNAT.Bubble_Sort (g-bubsor.ads)::
521 * GNAT.Bubble_Sort_A (g-busora.ads)::
522 * GNAT.Bubble_Sort_G (g-busorg.ads)::
523 * GNAT.Byte_Order_Mark (g-byorma.ads)::
524 * GNAT.Byte_Swapping (g-bytswa.ads)::
525 * GNAT.Calendar (g-calend.ads)::
526 * GNAT.Calendar.Time_IO (g-catiio.ads)::
527 * GNAT.Case_Util (g-casuti.ads)::
528 * GNAT.CGI (g-cgi.ads)::
529 * GNAT.CGI.Cookie (g-cgicoo.ads)::
530 * GNAT.CGI.Debug (g-cgideb.ads)::
531 * GNAT.Command_Line (g-comlin.ads)::
532 * GNAT.Compiler_Version (g-comver.ads)::
533 * GNAT.Ctrl_C (g-ctrl_c.ads)::
534 * GNAT.CRC32 (g-crc32.ads)::
535 * GNAT.Current_Exception (g-curexc.ads)::
536 * GNAT.Debug_Pools (g-debpoo.ads)::
537 * GNAT.Debug_Utilities (g-debuti.ads)::
538 * GNAT.Decode_String (g-decstr.ads)::
539 * GNAT.Decode_UTF8_String (g-deutst.ads)::
540 * GNAT.Directory_Operations (g-dirope.ads)::
541 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
542 * GNAT.Dynamic_HTables (g-dynhta.ads)::
543 * GNAT.Dynamic_Tables (g-dyntab.ads)::
544 * GNAT.Encode_String (g-encstr.ads)::
545 * GNAT.Encode_UTF8_String (g-enutst.ads)::
546 * GNAT.Exception_Actions (g-excact.ads)::
547 * GNAT.Exception_Traces (g-exctra.ads)::
548 * GNAT.Exceptions (g-except.ads)::
549 * GNAT.Expect (g-expect.ads)::
550 * GNAT.Expect.TTY (g-exptty.ads)::
551 * GNAT.Float_Control (g-flocon.ads)::
552 * GNAT.Heap_Sort (g-heasor.ads)::
553 * GNAT.Heap_Sort_A (g-hesora.ads)::
554 * GNAT.Heap_Sort_G (g-hesorg.ads)::
555 * GNAT.HTable (g-htable.ads)::
556 * GNAT.IO (g-io.ads)::
557 * GNAT.IO_Aux (g-io_aux.ads)::
558 * GNAT.Lock_Files (g-locfil.ads)::
559 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
560 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
561 * GNAT.MD5 (g-md5.ads)::
562 * GNAT.Memory_Dump (g-memdum.ads)::
563 * GNAT.Most_Recent_Exception (g-moreex.ads)::
564 * GNAT.OS_Lib (g-os_lib.ads)::
565 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
566 * GNAT.Random_Numbers (g-rannum.ads)::
567 * GNAT.Regexp (g-regexp.ads)::
568 * GNAT.Registry (g-regist.ads)::
569 * GNAT.Regpat (g-regpat.ads)::
570 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
571 * GNAT.Semaphores (g-semaph.ads)::
572 * GNAT.Serial_Communications (g-sercom.ads)::
573 * GNAT.SHA1 (g-sha1.ads)::
574 * GNAT.SHA224 (g-sha224.ads)::
575 * GNAT.SHA256 (g-sha256.ads)::
576 * GNAT.SHA384 (g-sha384.ads)::
577 * GNAT.SHA512 (g-sha512.ads)::
578 * GNAT.Signals (g-signal.ads)::
579 * GNAT.Sockets (g-socket.ads)::
580 * GNAT.Source_Info (g-souinf.ads)::
581 * GNAT.Spelling_Checker (g-speche.ads)::
582 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
583 * GNAT.Spitbol.Patterns (g-spipat.ads)::
584 * GNAT.Spitbol (g-spitbo.ads)::
585 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
586 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
587 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
588 * GNAT.SSE (g-sse.ads)::
589 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
590 * GNAT.Strings (g-string.ads)::
591 * GNAT.String_Split (g-strspl.ads)::
592 * GNAT.Table (g-table.ads)::
593 * GNAT.Task_Lock (g-tasloc.ads)::
594 * GNAT.Threads (g-thread.ads)::
595 * GNAT.Time_Stamp (g-timsta.ads)::
596 * GNAT.Traceback (g-traceb.ads)::
597 * GNAT.Traceback.Symbolic (g-trasym.ads)::
598 * GNAT.UTF_32 (g-utf_32.ads)::
599 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
600 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
601 * GNAT.Wide_String_Split (g-wistsp.ads)::
602 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
603 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
604 * Interfaces.C.Extensions (i-cexten.ads)::
605 * Interfaces.C.Streams (i-cstrea.ads)::
606 * Interfaces.CPP (i-cpp.ads)::
607 * Interfaces.Packed_Decimal (i-pacdec.ads)::
608 * Interfaces.VxWorks (i-vxwork.ads)::
609 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
610 * System.Address_Image (s-addima.ads)::
611 * System.Assertions (s-assert.ads)::
612 * System.Memory (s-memory.ads)::
613 * System.Multiprocessors (s-multip.ads)::
614 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
615 * System.Partition_Interface (s-parint.ads)::
616 * System.Pool_Global (s-pooglo.ads)::
617 * System.Pool_Local (s-pooloc.ads)::
618 * System.Restrictions (s-restri.ads)::
619 * System.Rident (s-rident.ads)::
620 * System.Strings.Stream_Ops (s-ststop.ads)::
621 * System.Task_Info (s-tasinf.ads)::
622 * System.Wch_Cnv (s-wchcnv.ads)::
623 * System.Wch_Con (s-wchcon.ads)::
627 * Text_IO Stream Pointer Positioning::
628 * Text_IO Reading and Writing Non-Regular Files::
630 * Treating Text_IO Files as Streams::
631 * Text_IO Extensions::
632 * Text_IO Facilities for Unbounded Strings::
636 * Wide_Text_IO Stream Pointer Positioning::
637 * Wide_Text_IO Reading and Writing Non-Regular Files::
641 * Wide_Wide_Text_IO Stream Pointer Positioning::
642 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
644 Interfacing to Other Languages
647 * Interfacing to C++::
648 * Interfacing to COBOL::
649 * Interfacing to Fortran::
650 * Interfacing to non-GNAT Ada code::
652 Specialized Needs Annexes
654 Implementation of Specific Ada Features
655 * Machine Code Insertions::
656 * GNAT Implementation of Tasking::
657 * GNAT Implementation of Shared Passive Packages::
658 * Code Generation for Array Aggregates::
659 * The Size of Discriminated Records with Default Discriminants::
660 * Strict Conformance to the Ada Reference Manual::
662 Implementation of Ada 2012 Features
666 GNU Free Documentation License
673 @node About This Guide
674 @unnumbered About This Guide
677 This manual contains useful information in writing programs using the
678 @value{EDITION} compiler. It includes information on implementation dependent
679 characteristics of @value{EDITION}, including all the information required by
680 Annex M of the Ada language standard.
682 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
683 Ada 83 compatibility mode.
684 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
685 but you can override with a compiler switch
686 to explicitly specify the language version.
687 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
688 @value{EDITION} User's Guide}, for details on these switches.)
689 Throughout this manual, references to ``Ada'' without a year suffix
690 apply to both the Ada 95 and Ada 2005 versions of the language.
692 Ada is designed to be highly portable.
693 In general, a program will have the same effect even when compiled by
694 different compilers on different platforms.
695 However, since Ada is designed to be used in a
696 wide variety of applications, it also contains a number of system
697 dependent features to be used in interfacing to the external world.
698 @cindex Implementation-dependent features
701 Note: Any program that makes use of implementation-dependent features
702 may be non-portable. You should follow good programming practice and
703 isolate and clearly document any sections of your program that make use
704 of these features in a non-portable manner.
707 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
708 ``GNAT'' in the remainder of this document.
712 * What This Reference Manual Contains::
714 * Related Information::
717 @node What This Reference Manual Contains
718 @unnumberedsec What This Reference Manual Contains
721 This reference manual contains the following chapters:
725 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
726 pragmas, which can be used to extend and enhance the functionality of the
730 @ref{Implementation Defined Attributes}, lists GNAT
731 implementation-dependent attributes, which can be used to extend and
732 enhance the functionality of the compiler.
735 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
736 implementation-dependent restrictions, which can be used to extend and
737 enhance the functionality of the compiler.
740 @ref{Implementation Advice}, provides information on generally
741 desirable behavior which are not requirements that all compilers must
742 follow since it cannot be provided on all systems, or which may be
743 undesirable on some systems.
746 @ref{Implementation Defined Characteristics}, provides a guide to
747 minimizing implementation dependent features.
750 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
751 implemented by GNAT, and how they can be imported into user
752 application programs.
755 @ref{Representation Clauses and Pragmas}, describes in detail the
756 way that GNAT represents data, and in particular the exact set
757 of representation clauses and pragmas that is accepted.
760 @ref{Standard Library Routines}, provides a listing of packages and a
761 brief description of the functionality that is provided by Ada's
762 extensive set of standard library routines as implemented by GNAT@.
765 @ref{The Implementation of Standard I/O}, details how the GNAT
766 implementation of the input-output facilities.
769 @ref{The GNAT Library}, is a catalog of packages that complement
770 the Ada predefined library.
773 @ref{Interfacing to Other Languages}, describes how programs
774 written in Ada using GNAT can be interfaced to other programming
777 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
778 of the specialized needs annexes.
781 @ref{Implementation of Specific Ada Features}, discusses issues related
782 to GNAT's implementation of machine code insertions, tasking, and several
786 @ref{Implementation of Ada 2012 Features}, describes the status of the
787 GNAT implementation of the Ada 2012 language standard.
790 @ref{Obsolescent Features} documents implementation dependent features,
791 including pragmas and attributes, which are considered obsolescent, since
792 there are other preferred ways of achieving the same results. These
793 obsolescent forms are retained for backwards compatibility.
797 @cindex Ada 95 Language Reference Manual
798 @cindex Ada 2005 Language Reference Manual
800 This reference manual assumes a basic familiarity with the Ada 95 language, as
801 described in the International Standard ANSI/ISO/IEC-8652:1995,
803 It does not require knowledge of the new features introduced by Ada 2005,
804 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
806 Both reference manuals are included in the GNAT documentation
810 @unnumberedsec Conventions
811 @cindex Conventions, typographical
812 @cindex Typographical conventions
815 Following are examples of the typographical and graphic conventions used
820 @code{Functions}, @code{utility program names}, @code{standard names},
827 @file{File names}, @samp{button names}, and @samp{field names}.
830 @code{Variables}, @env{environment variables}, and @var{metasyntactic
837 [optional information or parameters]
840 Examples are described by text
842 and then shown this way.
847 Commands that are entered by the user are preceded in this manual by the
848 characters @samp{$ } (dollar sign followed by space). If your system uses this
849 sequence as a prompt, then the commands will appear exactly as you see them
850 in the manual. If your system uses some other prompt, then the command will
851 appear with the @samp{$} replaced by whatever prompt character you are using.
853 @node Related Information
854 @unnumberedsec Related Information
856 See the following documents for further information on GNAT:
860 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
861 @value{EDITION} User's Guide}, which provides information on how to use the
862 GNAT compiler system.
865 @cite{Ada 95 Reference Manual}, which contains all reference
866 material for the Ada 95 programming language.
869 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
870 of the Ada 95 standard. The annotations describe
871 detailed aspects of the design decision, and in particular contain useful
872 sections on Ada 83 compatibility.
875 @cite{Ada 2005 Reference Manual}, which contains all reference
876 material for the Ada 2005 programming language.
879 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
880 of the Ada 2005 standard. The annotations describe
881 detailed aspects of the design decision, and in particular contain useful
882 sections on Ada 83 and Ada 95 compatibility.
885 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
886 which contains specific information on compatibility between GNAT and
890 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
891 describes in detail the pragmas and attributes provided by the DEC Ada 83
896 @node Implementation Defined Pragmas
897 @chapter Implementation Defined Pragmas
900 Ada defines a set of pragmas that can be used to supply additional
901 information to the compiler. These language defined pragmas are
902 implemented in GNAT and work as described in the Ada Reference Manual.
904 In addition, Ada allows implementations to define additional pragmas
905 whose meaning is defined by the implementation. GNAT provides a number
906 of these implementation-defined pragmas, which can be used to extend
907 and enhance the functionality of the compiler. This section of the GNAT
908 Reference Manual describes these additional pragmas.
910 Note that any program using these pragmas might not be portable to other
911 compilers (although GNAT implements this set of pragmas on all
912 platforms). Therefore if portability to other compilers is an important
913 consideration, the use of these pragmas should be minimized.
916 * Pragma Abort_Defer::
925 * Pragma Assert_And_Cut::
926 * Pragma Assertion_Policy::
928 * Pragma Assume_No_Invalid_Values::
929 * Pragma Attribute_Definition::
931 * Pragma C_Pass_By_Copy::
933 * Pragma Check_Float_Overflow::
934 * Pragma Check_Name::
935 * Pragma Check_Policy::
936 * Pragma CIL_Constructor::
938 * Pragma Common_Object::
939 * Pragma Compile_Time_Error::
940 * Pragma Compile_Time_Warning::
941 * Pragma Compiler_Unit::
942 * Pragma Complete_Representation::
943 * Pragma Complex_Representation::
944 * Pragma Component_Alignment::
945 * Pragma Contract_Cases::
946 * Pragma Convention_Identifier::
948 * Pragma CPP_Constructor::
949 * Pragma CPP_Virtual::
950 * Pragma CPP_Vtable::
953 * Pragma Debug_Policy::
954 * Pragma Default_Storage_Pool::
955 * Pragma Detect_Blocking::
956 * Pragma Disable_Atomic_Synchronization::
957 * Pragma Dispatching_Domain::
958 * Pragma Elaboration_Checks::
960 * Pragma Enable_Atomic_Synchronization::
961 * Pragma Export_Exception::
962 * Pragma Export_Function::
963 * Pragma Export_Object::
964 * Pragma Export_Procedure::
965 * Pragma Export_Value::
966 * Pragma Export_Valued_Procedure::
967 * Pragma Extend_System::
968 * Pragma Extensions_Allowed::
970 * Pragma External_Name_Casing::
972 * Pragma Favor_Top_Level::
973 * Pragma Finalize_Storage_Only::
974 * Pragma Float_Representation::
976 * Pragma Implementation_Defined::
977 * Pragma Implemented::
978 * Pragma Implicit_Packing::
979 * Pragma Import_Exception::
980 * Pragma Import_Function::
981 * Pragma Import_Object::
982 * Pragma Import_Procedure::
983 * Pragma Import_Valued_Procedure::
984 * Pragma Independent::
985 * Pragma Independent_Components::
986 * Pragma Initialize_Scalars::
987 * Pragma Inline_Always::
988 * Pragma Inline_Generic::
990 * Pragma Interface_Name::
991 * Pragma Interrupt_Handler::
992 * Pragma Interrupt_State::
994 * Pragma Java_Constructor::
995 * Pragma Java_Interface::
996 * Pragma Keep_Names::
999 * Pragma Linker_Alias::
1000 * Pragma Linker_Constructor::
1001 * Pragma Linker_Destructor::
1002 * Pragma Linker_Section::
1003 * Pragma Long_Float::
1004 * Pragma Loop_Invariant::
1005 * Pragma Loop_Optimize::
1006 * Pragma Loop_Variant::
1007 * Pragma Machine_Attribute::
1009 * Pragma Main_Storage::
1011 * Pragma No_Inline::
1012 * Pragma No_Return::
1013 * Pragma No_Run_Time::
1014 * Pragma No_Strict_Aliasing::
1015 * Pragma Normalize_Scalars::
1016 * Pragma Obsolescent::
1017 * Pragma Optimize_Alignment::
1019 * Pragma Overflow_Mode::
1020 * Pragma Overriding_Renamings::
1021 * Pragma Partition_Elaboration_Policy::
1023 * Pragma Persistent_BSS::
1025 * Pragma Postcondition::
1026 * Pragma Precondition::
1027 * Pragma Predicate::
1028 * Pragma Preelaborable_Initialization::
1029 * Pragma Preelaborate_05::
1030 * Pragma Priority_Specific_Dispatching::
1032 * Pragma Profile_Warnings::
1033 * Pragma Propagate_Exceptions::
1034 * Pragma Psect_Object::
1037 * Pragma Pure_Function::
1038 * Pragma Ravenscar::
1039 * Pragma Relative_Deadline::
1040 * Pragma Remote_Access_Type::
1041 * Pragma Restricted_Run_Time::
1042 * Pragma Restriction_Warnings::
1043 * Pragma Share_Generic::
1045 * Pragma Short_Circuit_And_Or::
1046 * Pragma Short_Descriptors::
1047 * Pragma Simple_Storage_Pool_Type::
1048 * Pragma Source_File_Name::
1049 * Pragma Source_File_Name_Project::
1050 * Pragma Source_Reference::
1051 * Pragma SPARK_Mode::
1052 * Pragma Static_Elaboration_Desired::
1053 * Pragma Stream_Convert::
1054 * Pragma Style_Checks::
1057 * Pragma Suppress_All::
1058 * Pragma Suppress_Debug_Info::
1059 * Pragma Suppress_Exception_Locations::
1060 * Pragma Suppress_Initialization::
1061 * Pragma Task_Info::
1062 * Pragma Task_Name::
1063 * Pragma Task_Storage::
1064 * Pragma Test_Case::
1065 * Pragma Thread_Local_Storage::
1066 * Pragma Time_Slice::
1068 * Pragma Unchecked_Union::
1069 * Pragma Unimplemented_Unit::
1070 * Pragma Universal_Aliasing ::
1071 * Pragma Universal_Data::
1072 * Pragma Unmodified::
1073 * Pragma Unreferenced::
1074 * Pragma Unreferenced_Objects::
1075 * Pragma Unreserve_All_Interrupts::
1076 * Pragma Unsuppress::
1077 * Pragma Use_VADS_Size::
1078 * Pragma Validity_Checks::
1081 * Pragma Weak_External::
1082 * Pragma Wide_Character_Encoding::
1085 @node Pragma Abort_Defer
1086 @unnumberedsec Pragma Abort_Defer
1088 @cindex Deferring aborts
1096 This pragma must appear at the start of the statement sequence of a
1097 handled sequence of statements (right after the @code{begin}). It has
1098 the effect of deferring aborts for the sequence of statements (but not
1099 for the declarations or handlers, if any, associated with this statement
1103 @unnumberedsec Pragma Ada_83
1107 @smallexample @c ada
1112 A configuration pragma that establishes Ada 83 mode for the unit to
1113 which it applies, regardless of the mode set by the command line
1114 switches. In Ada 83 mode, GNAT attempts to be as compatible with
1115 the syntax and semantics of Ada 83, as defined in the original Ada
1116 83 Reference Manual as possible. In particular, the keywords added by Ada 95
1117 and Ada 2005 are not recognized, optional package bodies are allowed,
1118 and generics may name types with unknown discriminants without using
1119 the @code{(<>)} notation. In addition, some but not all of the additional
1120 restrictions of Ada 83 are enforced.
1122 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1123 Ada 83 code to be compiled and adapted to GNAT with less effort.
1124 Secondly, it aids in keeping code backwards compatible with Ada 83.
1125 However, there is no guarantee that code that is processed correctly
1126 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1127 83 compiler, since GNAT does not enforce all the additional checks
1131 @unnumberedsec Pragma Ada_95
1135 @smallexample @c ada
1140 A configuration pragma that establishes Ada 95 mode for the unit to which
1141 it applies, regardless of the mode set by the command line switches.
1142 This mode is set automatically for the @code{Ada} and @code{System}
1143 packages and their children, so you need not specify it in these
1144 contexts. This pragma is useful when writing a reusable component that
1145 itself uses Ada 95 features, but which is intended to be usable from
1146 either Ada 83 or Ada 95 programs.
1149 @unnumberedsec Pragma Ada_05
1153 @smallexample @c ada
1158 A configuration pragma that establishes Ada 2005 mode for the unit to which
1159 it applies, regardless of the mode set by the command line switches.
1160 This pragma is useful when writing a reusable component that
1161 itself uses Ada 2005 features, but which is intended to be usable from
1162 either Ada 83 or Ada 95 programs.
1164 @node Pragma Ada_2005
1165 @unnumberedsec Pragma Ada_2005
1169 @smallexample @c ada
1174 This configuration pragma is a synonym for pragma Ada_05 and has the
1175 same syntax and effect.
1178 @unnumberedsec Pragma Ada_12
1182 @smallexample @c ada
1187 A configuration pragma that establishes Ada 2012 mode for the unit to which
1188 it applies, regardless of the mode set by the command line switches.
1189 This mode is set automatically for the @code{Ada} and @code{System}
1190 packages and their children, so you need not specify it in these
1191 contexts. This pragma is useful when writing a reusable component that
1192 itself uses Ada 2012 features, but which is intended to be usable from
1193 Ada 83, Ada 95, or Ada 2005 programs.
1195 @node Pragma Ada_2012
1196 @unnumberedsec Pragma Ada_2012
1200 @smallexample @c ada
1205 This configuration pragma is a synonym for pragma Ada_12 and has the
1206 same syntax and effect.
1208 @node Pragma Annotate
1209 @unnumberedsec Pragma Annotate
1213 @smallexample @c ada
1214 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1216 ARG ::= NAME | EXPRESSION
1220 This pragma is used to annotate programs. @var{identifier} identifies
1221 the type of annotation. GNAT verifies that it is an identifier, but does
1222 not otherwise analyze it. The second optional identifier is also left
1223 unanalyzed, and by convention is used to control the action of the tool to
1224 which the annotation is addressed. The remaining @var{arg} arguments
1225 can be either string literals or more generally expressions.
1226 String literals are assumed to be either of type
1227 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1228 depending on the character literals they contain.
1229 All other kinds of arguments are analyzed as expressions, and must be
1232 The analyzed pragma is retained in the tree, but not otherwise processed
1233 by any part of the GNAT compiler, except to generate corresponding note
1234 lines in the generated ALI file. For the format of these note lines, see
1235 the compiler source file lib-writ.ads. This pragma is intended for use by
1236 external tools, including ASIS@. The use of pragma Annotate does not
1237 affect the compilation process in any way. This pragma may be used as
1238 a configuration pragma.
1241 @unnumberedsec Pragma Assert
1245 @smallexample @c ada
1248 [, string_EXPRESSION]);
1252 The effect of this pragma depends on whether the corresponding command
1253 line switch is set to activate assertions. The pragma expands into code
1254 equivalent to the following:
1256 @smallexample @c ada
1257 if assertions-enabled then
1258 if not boolean_EXPRESSION then
1259 System.Assertions.Raise_Assert_Failure
1260 (string_EXPRESSION);
1266 The string argument, if given, is the message that will be associated
1267 with the exception occurrence if the exception is raised. If no second
1268 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1269 where @var{file} is the name of the source file containing the assert,
1270 and @var{nnn} is the line number of the assert. A pragma is not a
1271 statement, so if a statement sequence contains nothing but a pragma
1272 assert, then a null statement is required in addition, as in:
1274 @smallexample @c ada
1277 pragma Assert (K > 3, "Bad value for K");
1283 Note that, as with the @code{if} statement to which it is equivalent, the
1284 type of the expression is either @code{Standard.Boolean}, or any type derived
1285 from this standard type.
1287 Assert checks can be either checked or ignored. By default they are ignored.
1288 They will be checked if either the command line switch @option{-gnata} is
1289 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1290 to enable @code{Assert_Checks}.
1292 If assertions are ignored, then there
1293 is no run-time effect (and in particular, any side effects from the
1294 expression will not occur at run time). (The expression is still
1295 analyzed at compile time, and may cause types to be frozen if they are
1296 mentioned here for the first time).
1298 If assertions are checked, then the given expression is tested, and if
1299 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1300 which results in the raising of @code{Assert_Failure} with the given message.
1302 You should generally avoid side effects in the expression arguments of
1303 this pragma, because these side effects will turn on and off with the
1304 setting of the assertions mode, resulting in assertions that have an
1305 effect on the program. However, the expressions are analyzed for
1306 semantic correctness whether or not assertions are enabled, so turning
1307 assertions on and off cannot affect the legality of a program.
1309 Note that the implementation defined policy @code{DISABLE}, given in a
1310 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1312 Note: this is a standard language-defined pragma in versions
1313 of Ada from 2005 on. In GNAT, it is implemented in all versions
1314 of Ada, and the DISABLE policy is an implementation-defined
1317 @node Pragma Assert_And_Cut
1318 @unnumberedsec Pragma Assert_And_Cut
1319 @findex Assert_And_Cut
1322 @smallexample @c ada
1323 pragma Assert_And_Cut (
1325 [, string_EXPRESSION]);
1329 The effect of this pragma is identical to that of pragma @code{Assert},
1330 except that in an @code{Assertion_Policy} pragma, the identifier
1331 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1334 The intention is that this be used within a subprogram when the
1335 given test expresion sums up all the work done so far in the
1336 subprogram, so that the rest of the subprogram can be verified
1337 (informally or formally) using only the entry preconditions,
1338 and the expression in this pragma. This allows dividing up
1339 a subprogram into sections for the purposes of testing or
1340 formal verification. The pragma also serves as useful
1343 @node Pragma Assertion_Policy
1344 @unnumberedsec Pragma Assertion_Policy
1345 @findex Assertion_Policy
1348 @smallexample @c ada
1349 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1351 pragma Assertion_Policy (
1352 ASSERTION_KIND => POLICY_IDENTIFIER
1353 @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1355 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1357 RM_ASSERTION_KIND ::= Assert |
1365 Type_Invariant'Class
1367 ID_ASSERTION_KIND ::= Assertions |
1379 Statement_Assertions
1381 POLICY_IDENTIFIER ::= Check | Disable | Ignore
1385 This is a standard Ada 2012 pragma that is available as an
1386 implementation-defined pragma in earlier versions of Ada.
1387 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1388 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1389 are implementation defined additions recognized by the GNAT compiler.
1391 The pragma applies in both cases to pragmas and aspects with matching
1392 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1393 applies to both the @code{Precondition} pragma
1394 and the aspect @code{Precondition}.
1396 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1397 the corresponding pragma or aspect is activated.
1398 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1399 the corresponding pragma or aspect is deactivated.
1400 This pragma overrides the effect of the @option{-gnata} switch on the
1403 The implementation defined policy @code{DISABLE} is like
1404 @code{IGNORE} except that it completely disables semantic
1405 checking of the corresponding pragma or aspect. This is
1406 useful when the pragma or aspect argument references subprograms
1407 in a with'ed package which is replaced by a dummy package
1408 for the final build.
1410 The implementation defined policy @code{Assertions} applies to all
1411 assertion kinds. The form with no assertion kind given implies this
1412 choice, so it applies to all assertion kinds (RM defined, and
1413 implementation defined).
1415 The implementation defined policy @code{Statement_Assertions}
1416 applies to @code{Assert}, @code{Assert_And_Cut},
1417 @code{Assume}, and @code{Loop_Invariant}.
1420 @unnumberedsec Pragma Assume
1424 @smallexample @c ada
1427 [, string_EXPRESSION]);
1431 The effect of this pragma is identical to that of pragma @code{Assert},
1432 except that in an @code{Assertion_Policy} pragma, the identifier
1433 @code{Assume} is used to control whether it is ignored or checked
1436 The intention is that this be used for assumptions about the
1437 external environment. So you cannot expect to verify formally
1438 or informally that the condition is met, this must be
1439 established by examining things outside the program itself.
1440 For example, we may have code that depends on the size of
1441 @code{Long_Long_Integer} being at least 64. So we could write:
1443 @smallexample @c ada
1444 pragma Assume (Long_Long_Integer'Size >= 64);
1448 This assumption cannot be proved from the program itself,
1449 but it acts as a useful run-time check that the assumption
1450 is met, and documents the need to ensure that it is met by
1451 reference to information outside the program.
1453 @node Pragma Assume_No_Invalid_Values
1454 @unnumberedsec Pragma Assume_No_Invalid_Values
1455 @findex Assume_No_Invalid_Values
1456 @cindex Invalid representations
1457 @cindex Invalid values
1460 @smallexample @c ada
1461 pragma Assume_No_Invalid_Values (On | Off);
1465 This is a configuration pragma that controls the assumptions made by the
1466 compiler about the occurrence of invalid representations (invalid values)
1469 The default behavior (corresponding to an Off argument for this pragma), is
1470 to assume that values may in general be invalid unless the compiler can
1471 prove they are valid. Consider the following example:
1473 @smallexample @c ada
1474 V1 : Integer range 1 .. 10;
1475 V2 : Integer range 11 .. 20;
1477 for J in V2 .. V1 loop
1483 if V1 and V2 have valid values, then the loop is known at compile
1484 time not to execute since the lower bound must be greater than the
1485 upper bound. However in default mode, no such assumption is made,
1486 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1487 is given, the compiler will assume that any occurrence of a variable
1488 other than in an explicit @code{'Valid} test always has a valid
1489 value, and the loop above will be optimized away.
1491 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1492 you know your code is free of uninitialized variables and other
1493 possible sources of invalid representations, and may result in
1494 more efficient code. A program that accesses an invalid representation
1495 with this pragma in effect is erroneous, so no guarantees can be made
1498 It is peculiar though permissible to use this pragma in conjunction
1499 with validity checking (-gnatVa). In such cases, accessing invalid
1500 values will generally give an exception, though formally the program
1501 is erroneous so there are no guarantees that this will always be the
1502 case, and it is recommended that these two options not be used together.
1504 @node Pragma Ast_Entry
1505 @unnumberedsec Pragma Ast_Entry
1510 @smallexample @c ada
1511 pragma AST_Entry (entry_IDENTIFIER);
1515 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1516 argument is the simple name of a single entry; at most one @code{AST_Entry}
1517 pragma is allowed for any given entry. This pragma must be used in
1518 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1519 the entry declaration and in the same task type specification or single task
1520 as the entry to which it applies. This pragma specifies that the given entry
1521 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1522 resulting from an OpenVMS system service call. The pragma does not affect
1523 normal use of the entry. For further details on this pragma, see the
1524 DEC Ada Language Reference Manual, section 9.12a.
1526 @node Pragma Attribute_Definition
1527 @unnumberedsec Pragma Attribute_Definition
1528 @findex Attribute_Definition
1531 @smallexample @c ada
1532 pragma Attribute_Definition
1533 ([Attribute =>] ATTRIBUTE_DESIGNATOR,
1534 [Entity =>] LOCAL_NAME,
1535 [Expression =>] EXPRESSION | NAME);
1539 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1540 the attribute definition clause:
1542 @smallexample @c ada
1543 for Entity'Attribute use Expression;
1546 If @code{Attribute} is not a recognized attribute name, the pragma is
1547 ignored, and a warning is emitted. This allows source
1548 code to be written that takes advantage of some new attribute, while remaining
1549 compilable with earlier compilers.
1551 @node Pragma C_Pass_By_Copy
1552 @unnumberedsec Pragma C_Pass_By_Copy
1553 @cindex Passing by copy
1554 @findex C_Pass_By_Copy
1557 @smallexample @c ada
1558 pragma C_Pass_By_Copy
1559 ([Max_Size =>] static_integer_EXPRESSION);
1563 Normally the default mechanism for passing C convention records to C
1564 convention subprograms is to pass them by reference, as suggested by RM
1565 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1566 this default, by requiring that record formal parameters be passed by
1567 copy if all of the following conditions are met:
1571 The size of the record type does not exceed the value specified for
1574 The record type has @code{Convention C}.
1576 The formal parameter has this record type, and the subprogram has a
1577 foreign (non-Ada) convention.
1581 If these conditions are met the argument is passed by copy, i.e.@: in a
1582 manner consistent with what C expects if the corresponding formal in the
1583 C prototype is a struct (rather than a pointer to a struct).
1585 You can also pass records by copy by specifying the convention
1586 @code{C_Pass_By_Copy} for the record type, or by using the extended
1587 @code{Import} and @code{Export} pragmas, which allow specification of
1588 passing mechanisms on a parameter by parameter basis.
1591 @unnumberedsec Pragma Check
1593 @cindex Named assertions
1597 @smallexample @c ada
1599 [Name =>] CHECK_KIND,
1600 [Check =>] Boolean_EXPRESSION
1601 [, [Message =>] string_EXPRESSION] );
1603 CHECK_KIND ::= IDENTIFIER |
1606 Type_Invariant'Class |
1611 This pragma is similar to the predefined pragma @code{Assert} except that an
1612 extra identifier argument is present. In conjunction with pragma
1613 @code{Check_Policy}, this can be used to define groups of assertions that can
1614 be independently controlled. The identifier @code{Assertion} is special, it
1615 refers to the normal set of pragma @code{Assert} statements.
1617 Checks introduced by this pragma are normally deactivated by default. They can
1618 be activated either by the command line option @option{-gnata}, which turns on
1619 all checks, or individually controlled using pragma @code{Check_Policy}.
1621 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
1622 permitted as check kinds, since this would cause confusion with the use
1623 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
1624 pragmas, where they are used to refer to sets of assertions.
1626 @node Pragma Check_Float_Overflow
1627 @unnumberedsec Pragma Check_Float_Overflow
1628 @cindex Floating-point overflow
1629 @findex Check_Float_Overflow
1632 @smallexample @c ada
1633 pragma Check_Float_Overflow;
1637 In Ada, the predefined floating-point types (@code{Short_Float},
1638 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1639 defined to be @emph{unconstrained}. This means that even though each
1640 has a well-defined base range, an operation that delivers a result
1641 outside this base range is not required to raise an exception.
1642 This implementation permission accommodates the notion
1643 of infinities in IEEE floating-point, and corresponds to the
1644 efficient execution mode on most machines. GNAT will not raise
1645 overflow exceptions on these machines; instead it will generate
1646 infinities and NaN's as defined in the IEEE standard.
1648 Generating infinities, although efficient, is not always desirable.
1649 Often the preferable approach is to check for overflow, even at the
1650 (perhaps considerable) expense of run-time performance.
1651 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1652 range constraints -- and indeed such a subtype
1653 can have the same base range as its base type. For example:
1655 @smallexample @c ada
1656 subtype My_Float is Float range Float'Range;
1660 Here @code{My_Float} has the same range as
1661 @code{Float} but is constrained, so operations on
1662 @code{My_Float} values will be checked for overflow
1665 This style will achieve the desired goal, but
1666 it is often more convenient to be able to simply use
1667 the standard predefined floating-point types as long
1668 as overflow checking could be guaranteed.
1669 The @code{Check_Float_Overflow}
1670 configuration pragma achieves this effect. If a unit is compiled
1671 subject to this configuration pragma, then all operations
1672 on predefined floating-point types will be treated as
1673 though those types were constrained, and overflow checks
1674 will be generated. The @code{Constraint_Error}
1675 exception is raised if the result is out of range.
1677 This mode can also be set by use of the compiler
1678 switch @option{-gnateF}.
1680 @node Pragma Check_Name
1681 @unnumberedsec Pragma Check_Name
1682 @cindex Defining check names
1683 @cindex Check names, defining
1687 @smallexample @c ada
1688 pragma Check_Name (check_name_IDENTIFIER);
1692 This is a configuration pragma that defines a new implementation
1693 defined check name (unless IDENTIFIER matches one of the predefined
1694 check names, in which case the pragma has no effect). Check names
1695 are global to a partition, so if two or more configuration pragmas
1696 are present in a partition mentioning the same name, only one new
1697 check name is introduced.
1699 An implementation defined check name introduced with this pragma may
1700 be used in only three contexts: @code{pragma Suppress},
1701 @code{pragma Unsuppress},
1702 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1703 any of these three cases, the check name must be visible. A check
1704 name is visible if it is in the configuration pragmas applying to
1705 the current unit, or if it appears at the start of any unit that
1706 is part of the dependency set of the current unit (e.g., units that
1707 are mentioned in @code{with} clauses).
1709 Check names introduced by this pragma are subject to control by compiler
1710 switches (in particular -gnatp) in the usual manner.
1712 @node Pragma Check_Policy
1713 @unnumberedsec Pragma Check_Policy
1714 @cindex Controlling assertions
1715 @cindex Assertions, control
1716 @cindex Check pragma control
1717 @cindex Named assertions
1721 @smallexample @c ada
1723 ([Name =>] CHECK_KIND,
1724 [Policy =>] POLICY_IDENTIFIER);
1726 pragma Check_Policy (
1727 CHECK_KIND => POLICY_IDENTIFIER
1728 @{, CHECK_KIND => POLICY_IDENTIFIER@});
1730 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1732 CHECK_KIND ::= IDENTIFIER |
1735 Type_Invariant'Class |
1738 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
1739 avoids confusion between the two possible syntax forms for this pragma.
1741 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1745 This pragma is used to set the checking policy for assertions (specified
1746 by aspects or pragmas), the @code{Debug} pragma, or additional checks
1747 to be checked using the @code{Check} pragma. It may appear either as
1748 a configuration pragma, or within a declarative part of package. In the
1749 latter case, it applies from the point where it appears to the end of
1750 the declarative region (like pragma @code{Suppress}).
1752 The @code{Check_Policy} pragma is similar to the
1753 predefined @code{Assertion_Policy} pragma,
1754 and if the check kind corresponds to one of the assertion kinds that
1755 are allowed by @code{Assertion_Policy}, then the effect is identical.
1757 If the first argument is Debug, then the policy applies to Debug pragmas,
1758 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
1759 @code{IGNORE}, and allowing them to execute with normal semantics if
1760 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
1761 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
1762 be totally ignored and not analyzed semantically.
1764 Finally the first argument may be some other identifier than the above
1765 possibilities, in which case it controls a set of named assertions
1766 that can be checked using pragma @code{Check}. For example, if the pragma:
1768 @smallexample @c ada
1769 pragma Check_Policy (Critical_Error, OFF);
1773 is given, then subsequent @code{Check} pragmas whose first argument is also
1774 @code{Critical_Error} will be disabled.
1776 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1777 to turn on corresponding checks. The default for a set of checks for which no
1778 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1779 @option{-gnata} is given, which turns on all checks by default.
1781 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
1782 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1783 compatibility with the standard @code{Assertion_Policy} pragma. The check
1784 policy setting @code{DISABLE} causes the second argument of a corresponding
1785 @code{Check} pragma to be completely ignored and not analyzed.
1787 @node Pragma CIL_Constructor
1788 @unnumberedsec Pragma CIL_Constructor
1789 @findex CIL_Constructor
1793 @smallexample @c ada
1794 pragma CIL_Constructor ([Entity =>] function_LOCAL_NAME);
1798 This pragma is used to assert that the specified Ada function should be
1799 mapped to the .NET constructor for some Ada tagged record type.
1801 See section 4.1 of the
1802 @code{GNAT User's Guide: Supplement for the .NET Platform.}
1803 for related information.
1805 @node Pragma Comment
1806 @unnumberedsec Pragma Comment
1811 @smallexample @c ada
1812 pragma Comment (static_string_EXPRESSION);
1816 This is almost identical in effect to pragma @code{Ident}. It allows the
1817 placement of a comment into the object file and hence into the
1818 executable file if the operating system permits such usage. The
1819 difference is that @code{Comment}, unlike @code{Ident}, has
1820 no limitations on placement of the pragma (it can be placed
1821 anywhere in the main source unit), and if more than one pragma
1822 is used, all comments are retained.
1824 @node Pragma Common_Object
1825 @unnumberedsec Pragma Common_Object
1826 @findex Common_Object
1830 @smallexample @c ada
1831 pragma Common_Object (
1832 [Internal =>] LOCAL_NAME
1833 [, [External =>] EXTERNAL_SYMBOL]
1834 [, [Size =>] EXTERNAL_SYMBOL] );
1838 | static_string_EXPRESSION
1842 This pragma enables the shared use of variables stored in overlaid
1843 linker areas corresponding to the use of @code{COMMON}
1844 in Fortran. The single
1845 object @var{LOCAL_NAME} is assigned to the area designated by
1846 the @var{External} argument.
1847 You may define a record to correspond to a series
1848 of fields. The @var{Size} argument
1849 is syntax checked in GNAT, but otherwise ignored.
1851 @code{Common_Object} is not supported on all platforms. If no
1852 support is available, then the code generator will issue a message
1853 indicating that the necessary attribute for implementation of this
1854 pragma is not available.
1856 @node Pragma Compile_Time_Error
1857 @unnumberedsec Pragma Compile_Time_Error
1858 @findex Compile_Time_Error
1862 @smallexample @c ada
1863 pragma Compile_Time_Error
1864 (boolean_EXPRESSION, static_string_EXPRESSION);
1868 This pragma can be used to generate additional compile time
1870 is particularly useful in generics, where errors can be issued for
1871 specific problematic instantiations. The first parameter is a boolean
1872 expression. The pragma is effective only if the value of this expression
1873 is known at compile time, and has the value True. The set of expressions
1874 whose values are known at compile time includes all static boolean
1875 expressions, and also other values which the compiler can determine
1876 at compile time (e.g., the size of a record type set by an explicit
1877 size representation clause, or the value of a variable which was
1878 initialized to a constant and is known not to have been modified).
1879 If these conditions are met, an error message is generated using
1880 the value given as the second argument. This string value may contain
1881 embedded ASCII.LF characters to break the message into multiple lines.
1883 @node Pragma Compile_Time_Warning
1884 @unnumberedsec Pragma Compile_Time_Warning
1885 @findex Compile_Time_Warning
1889 @smallexample @c ada
1890 pragma Compile_Time_Warning
1891 (boolean_EXPRESSION, static_string_EXPRESSION);
1895 Same as pragma Compile_Time_Error, except a warning is issued instead
1896 of an error message. Note that if this pragma is used in a package that
1897 is with'ed by a client, the client will get the warning even though it
1898 is issued by a with'ed package (normally warnings in with'ed units are
1899 suppressed, but this is a special exception to that rule).
1901 One typical use is within a generic where compile time known characteristics
1902 of formal parameters are tested, and warnings given appropriately. Another use
1903 with a first parameter of True is to warn a client about use of a package,
1904 for example that it is not fully implemented.
1906 @node Pragma Compiler_Unit
1907 @unnumberedsec Pragma Compiler_Unit
1908 @findex Compiler_Unit
1912 @smallexample @c ada
1913 pragma Compiler_Unit;
1917 This pragma is intended only for internal use in the GNAT run-time library.
1918 It indicates that the unit is used as part of the compiler build. The effect
1919 is to disallow constructs (raise with message, conditional expressions etc)
1920 that would cause trouble when bootstrapping using an older version of GNAT.
1921 For the exact list of restrictions, see the compiler sources and references
1922 to Is_Compiler_Unit.
1924 @node Pragma Complete_Representation
1925 @unnumberedsec Pragma Complete_Representation
1926 @findex Complete_Representation
1930 @smallexample @c ada
1931 pragma Complete_Representation;
1935 This pragma must appear immediately within a record representation
1936 clause. Typical placements are before the first component clause
1937 or after the last component clause. The effect is to give an error
1938 message if any component is missing a component clause. This pragma
1939 may be used to ensure that a record representation clause is
1940 complete, and that this invariant is maintained if fields are
1941 added to the record in the future.
1943 @node Pragma Complex_Representation
1944 @unnumberedsec Pragma Complex_Representation
1945 @findex Complex_Representation
1949 @smallexample @c ada
1950 pragma Complex_Representation
1951 ([Entity =>] LOCAL_NAME);
1955 The @var{Entity} argument must be the name of a record type which has
1956 two fields of the same floating-point type. The effect of this pragma is
1957 to force gcc to use the special internal complex representation form for
1958 this record, which may be more efficient. Note that this may result in
1959 the code for this type not conforming to standard ABI (application
1960 binary interface) requirements for the handling of record types. For
1961 example, in some environments, there is a requirement for passing
1962 records by pointer, and the use of this pragma may result in passing
1963 this type in floating-point registers.
1965 @node Pragma Component_Alignment
1966 @unnumberedsec Pragma Component_Alignment
1967 @cindex Alignments of components
1968 @findex Component_Alignment
1972 @smallexample @c ada
1973 pragma Component_Alignment (
1974 [Form =>] ALIGNMENT_CHOICE
1975 [, [Name =>] type_LOCAL_NAME]);
1977 ALIGNMENT_CHOICE ::=
1985 Specifies the alignment of components in array or record types.
1986 The meaning of the @var{Form} argument is as follows:
1989 @findex Component_Size
1990 @item Component_Size
1991 Aligns scalar components and subcomponents of the array or record type
1992 on boundaries appropriate to their inherent size (naturally
1993 aligned). For example, 1-byte components are aligned on byte boundaries,
1994 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1995 integer components are aligned on 4-byte boundaries and so on. These
1996 alignment rules correspond to the normal rules for C compilers on all
1997 machines except the VAX@.
1999 @findex Component_Size_4
2000 @item Component_Size_4
2001 Naturally aligns components with a size of four or fewer
2002 bytes. Components that are larger than 4 bytes are placed on the next
2005 @findex Storage_Unit
2007 Specifies that array or record components are byte aligned, i.e.@:
2008 aligned on boundaries determined by the value of the constant
2009 @code{System.Storage_Unit}.
2013 Specifies that array or record components are aligned on default
2014 boundaries, appropriate to the underlying hardware or operating system or
2015 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
2016 the @code{Storage_Unit} choice (byte alignment). For all other systems,
2017 the @code{Default} choice is the same as @code{Component_Size} (natural
2022 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
2023 refer to a local record or array type, and the specified alignment
2024 choice applies to the specified type. The use of
2025 @code{Component_Alignment} together with a pragma @code{Pack} causes the
2026 @code{Component_Alignment} pragma to be ignored. The use of
2027 @code{Component_Alignment} together with a record representation clause
2028 is only effective for fields not specified by the representation clause.
2030 If the @code{Name} parameter is absent, the pragma can be used as either
2031 a configuration pragma, in which case it applies to one or more units in
2032 accordance with the normal rules for configuration pragmas, or it can be
2033 used within a declarative part, in which case it applies to types that
2034 are declared within this declarative part, or within any nested scope
2035 within this declarative part. In either case it specifies the alignment
2036 to be applied to any record or array type which has otherwise standard
2039 If the alignment for a record or array type is not specified (using
2040 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
2041 clause), the GNAT uses the default alignment as described previously.
2043 @node Pragma Contract_Cases
2044 @unnumberedsec Pragma Contract_Cases
2045 @cindex Contract cases
2046 @findex Contract_Cases
2050 @smallexample @c ada
2051 pragma Contract_Cases (
2052 Condition => Consequence
2053 @{,Condition => Consequence@});
2057 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2058 that can complement or replace the contract given by a precondition and a
2059 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2060 by testing and formal verification tools. The compiler checks its validity and,
2061 depending on the assertion policy at the point of declaration of the pragma,
2062 it may insert a check in the executable. For code generation, the contract
2065 @smallexample @c ada
2066 pragma Contract_Cases (
2074 @smallexample @c ada
2075 C1 : constant Boolean := Cond1; -- evaluated at subprogram entry
2076 C2 : constant Boolean := Cond2; -- evaluated at subprogram entry
2077 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2078 pragma Postcondition (if C1 then Pred1);
2079 pragma Postcondition (if C2 then Pred2);
2083 The precondition ensures that one and only one of the conditions is
2084 satisfied on entry to the subprogram.
2085 The postcondition ensures that for the condition that was True on entry,
2086 the corrresponding consequence is True on exit. Other consequence expressions
2089 A precondition @code{P} and postcondition @code{Q} can also be
2090 expressed as contract cases:
2092 @smallexample @c ada
2093 pragma Contract_Cases (P => Q);
2096 The placement and visibility rules for @code{Contract_Cases} pragmas are
2097 identical to those described for preconditions and postconditions.
2099 The compiler checks that boolean expressions given in conditions and
2100 consequences are valid, where the rules for conditions are the same as
2101 the rule for an expression in @code{Precondition} and the rules for
2102 consequences are the same as the rule for an expression in
2103 @code{Postcondition}. In particular, attributes @code{'Old} and
2104 @code{'Result} can only be used within consequence expressions.
2105 The condition for the last contract case may be @code{others}, to denote
2106 any case not captured by the previous cases. The
2107 following is an example of use within a package spec:
2109 @smallexample @c ada
2110 package Math_Functions is
2112 function Sqrt (Arg : Float) return Float;
2113 pragma Contract_Cases ((Arg in 0 .. 99) => Sqrt'Result < 10,
2114 Arg >= 100 => Sqrt'Result >= 10,
2115 others => Sqrt'Result = 0);
2121 The meaning of contract cases is that only one case should apply at each
2122 call, as determined by the corresponding condition evaluating to True,
2123 and that the consequence for this case should hold when the subprogram
2126 @node Pragma Convention_Identifier
2127 @unnumberedsec Pragma Convention_Identifier
2128 @findex Convention_Identifier
2129 @cindex Conventions, synonyms
2133 @smallexample @c ada
2134 pragma Convention_Identifier (
2135 [Name =>] IDENTIFIER,
2136 [Convention =>] convention_IDENTIFIER);
2140 This pragma provides a mechanism for supplying synonyms for existing
2141 convention identifiers. The @code{Name} identifier can subsequently
2142 be used as a synonym for the given convention in other pragmas (including
2143 for example pragma @code{Import} or another @code{Convention_Identifier}
2144 pragma). As an example of the use of this, suppose you had legacy code
2145 which used Fortran77 as the identifier for Fortran. Then the pragma:
2147 @smallexample @c ada
2148 pragma Convention_Identifier (Fortran77, Fortran);
2152 would allow the use of the convention identifier @code{Fortran77} in
2153 subsequent code, avoiding the need to modify the sources. As another
2154 example, you could use this to parameterize convention requirements
2155 according to systems. Suppose you needed to use @code{Stdcall} on
2156 windows systems, and @code{C} on some other system, then you could
2157 define a convention identifier @code{Library} and use a single
2158 @code{Convention_Identifier} pragma to specify which convention
2159 would be used system-wide.
2161 @node Pragma CPP_Class
2162 @unnumberedsec Pragma CPP_Class
2164 @cindex Interfacing with C++
2168 @smallexample @c ada
2169 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2173 The argument denotes an entity in the current declarative region that is
2174 declared as a record type. It indicates that the type corresponds to an
2175 externally declared C++ class type, and is to be laid out the same way
2176 that C++ would lay out the type. If the C++ class has virtual primitives
2177 then the record must be declared as a tagged record type.
2179 Types for which @code{CPP_Class} is specified do not have assignment or
2180 equality operators defined (such operations can be imported or declared
2181 as subprograms as required). Initialization is allowed only by constructor
2182 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2183 limited if not explicitly declared as limited or derived from a limited
2184 type, and an error is issued in that case.
2186 See @ref{Interfacing to C++} for related information.
2188 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2189 for backward compatibility but its functionality is available
2190 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2192 @node Pragma CPP_Constructor
2193 @unnumberedsec Pragma CPP_Constructor
2194 @cindex Interfacing with C++
2195 @findex CPP_Constructor
2199 @smallexample @c ada
2200 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2201 [, [External_Name =>] static_string_EXPRESSION ]
2202 [, [Link_Name =>] static_string_EXPRESSION ]);
2206 This pragma identifies an imported function (imported in the usual way
2207 with pragma @code{Import}) as corresponding to a C++ constructor. If
2208 @code{External_Name} and @code{Link_Name} are not specified then the
2209 @code{Entity} argument is a name that must have been previously mentioned
2210 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2211 must be of one of the following forms:
2215 @code{function @var{Fname} return @var{T}}
2219 @code{function @var{Fname} return @var{T}'Class}
2222 @code{function @var{Fname} (@dots{}) return @var{T}}
2226 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2230 where @var{T} is a limited record type imported from C++ with pragma
2231 @code{Import} and @code{Convention} = @code{CPP}.
2233 The first two forms import the default constructor, used when an object
2234 of type @var{T} is created on the Ada side with no explicit constructor.
2235 The latter two forms cover all the non-default constructors of the type.
2236 See the @value{EDITION} User's Guide for details.
2238 If no constructors are imported, it is impossible to create any objects
2239 on the Ada side and the type is implicitly declared abstract.
2241 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2242 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2244 See @ref{Interfacing to C++} for more related information.
2246 Note: The use of functions returning class-wide types for constructors is
2247 currently obsolete. They are supported for backward compatibility. The
2248 use of functions returning the type T leave the Ada sources more clear
2249 because the imported C++ constructors always return an object of type T;
2250 that is, they never return an object whose type is a descendant of type T.
2252 @node Pragma CPP_Virtual
2253 @unnumberedsec Pragma CPP_Virtual
2254 @cindex Interfacing to C++
2257 This pragma is now obsolete and, other than generating a warning if warnings
2258 on obsolescent features are enabled, is completely ignored.
2259 It is retained for compatibility
2260 purposes. It used to be required to ensure compoatibility with C++, but
2261 is no longer required for that purpose because GNAT generates
2262 the same object layout as the G++ compiler by default.
2264 See @ref{Interfacing to C++} for related information.
2266 @node Pragma CPP_Vtable
2267 @unnumberedsec Pragma CPP_Vtable
2268 @cindex Interfacing with C++
2271 This pragma is now obsolete and, other than generating a warning if warnings
2272 on obsolescent features are enabled, is completely ignored.
2273 It used to be required to ensure compatibility with C++, but
2274 is no longer required for that purpose because GNAT generates
2275 the same object layout than the G++ compiler by default.
2277 See @ref{Interfacing to C++} for related information.
2280 @unnumberedsec Pragma CPU
2285 @smallexample @c ada
2286 pragma CPU (EXPRESSSION);
2290 This pragma is standard in Ada 2012, but is available in all earlier
2291 versions of Ada as an implementation-defined pragma.
2292 See Ada 2012 Reference Manual for details.
2295 @unnumberedsec Pragma Debug
2300 @smallexample @c ada
2301 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2303 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2305 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2309 The procedure call argument has the syntactic form of an expression, meeting
2310 the syntactic requirements for pragmas.
2312 If debug pragmas are not enabled or if the condition is present and evaluates
2313 to False, this pragma has no effect. If debug pragmas are enabled, the
2314 semantics of the pragma is exactly equivalent to the procedure call statement
2315 corresponding to the argument with a terminating semicolon. Pragmas are
2316 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2317 intersperse calls to debug procedures in the middle of declarations. Debug
2318 pragmas can be enabled either by use of the command line switch @option{-gnata}
2319 or by use of the pragma @code{Check_Policy} with a first argument of
2322 @node Pragma Debug_Policy
2323 @unnumberedsec Pragma Debug_Policy
2324 @findex Debug_Policy
2328 @smallexample @c ada
2329 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2333 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2334 with a first argument of @code{Debug}. It is retained for historical
2335 compatibility reasons.
2337 @node Pragma Default_Storage_Pool
2338 @unnumberedsec Pragma Default_Storage_Pool
2339 @findex Default_Storage_Pool
2343 @smallexample @c ada
2344 pragma Default_Storage_Pool (storage_pool_NAME | null);
2348 This pragma is standard in Ada 2012, but is available in all earlier
2349 versions of Ada as an implementation-defined pragma.
2350 See Ada 2012 Reference Manual for details.
2352 @node Pragma Detect_Blocking
2353 @unnumberedsec Pragma Detect_Blocking
2354 @findex Detect_Blocking
2358 @smallexample @c ada
2359 pragma Detect_Blocking;
2363 This is a standard pragma in Ada 2005, that is available in all earlier
2364 versions of Ada as an implementation-defined pragma.
2366 This is a configuration pragma that forces the detection of potentially
2367 blocking operations within a protected operation, and to raise Program_Error
2370 @node Pragma Disable_Atomic_Synchronization
2371 @unnumberedsec Pragma Disable_Atomic_Synchronization
2372 @cindex Atomic Synchronization
2373 @findex Disable_Atomic_Synchronization
2377 @smallexample @c ada
2378 pragma Disable_Atomic_Synchronization [(Entity)];
2382 Ada requires that accesses (reads or writes) of an atomic variable be
2383 regarded as synchronization points in the case of multiple tasks.
2384 Particularly in the case of multi-processors this may require special
2385 handling, e.g. the generation of memory barriers. This capability may
2386 be turned off using this pragma in cases where it is known not to be
2389 The placement and scope rules for this pragma are the same as those
2390 for @code{pragma Suppress}. In particular it can be used as a
2391 configuration pragma, or in a declaration sequence where it applies
2392 till the end of the scope. If an @code{Entity} argument is present,
2393 the action applies only to that entity.
2395 @node Pragma Dispatching_Domain
2396 @unnumberedsec Pragma Dispatching_Domain
2397 @findex Dispatching_Domain
2401 @smallexample @c ada
2402 pragma Dispatching_Domain (EXPRESSION);
2406 This pragma is standard in Ada 2012, but is available in all earlier
2407 versions of Ada as an implementation-defined pragma.
2408 See Ada 2012 Reference Manual for details.
2410 @node Pragma Elaboration_Checks
2411 @unnumberedsec Pragma Elaboration_Checks
2412 @cindex Elaboration control
2413 @findex Elaboration_Checks
2417 @smallexample @c ada
2418 pragma Elaboration_Checks (Dynamic | Static);
2422 This is a configuration pragma that provides control over the
2423 elaboration model used by the compilation affected by the
2424 pragma. If the parameter is @code{Dynamic},
2425 then the dynamic elaboration
2426 model described in the Ada Reference Manual is used, as though
2427 the @option{-gnatE} switch had been specified on the command
2428 line. If the parameter is @code{Static}, then the default GNAT static
2429 model is used. This configuration pragma overrides the setting
2430 of the command line. For full details on the elaboration models
2431 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2432 gnat_ugn, @value{EDITION} User's Guide}.
2434 @node Pragma Eliminate
2435 @unnumberedsec Pragma Eliminate
2436 @cindex Elimination of unused subprograms
2441 @smallexample @c ada
2442 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
2443 [Source_Location =>] STRING_LITERAL);
2447 The string literal given for the source location is a string which
2448 specifies the line number of the occurrence of the entity, using
2449 the syntax for SOURCE_TRACE given below:
2451 @smallexample @c ada
2452 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2457 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2459 LINE_NUMBER ::= DIGIT @{DIGIT@}
2463 Spaces around the colon in a @code{Source_Reference} are optional.
2465 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2466 explicit subprogram declaration, where the @code{entity} name in this
2467 designator appears on the source line specified by the source location.
2469 The source trace that is given as the @code{Source_Location} shall obey the
2470 following rules. The @code{FILE_NAME} is the short name (with no directory
2471 information) of an Ada source file, given using exactly the required syntax
2472 for the underlying file system (e.g. case is important if the underlying
2473 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2474 number of the occurrence of the @code{entity}
2475 as a decimal literal without an exponent or point. If an @code{entity} is not
2476 declared in a generic instantiation (this includes generic subprogram
2477 instances), the source trace includes only one source reference. If an entity
2478 is declared inside a generic instantiation, its source trace (when parsing
2479 from left to right) starts with the source location of the declaration of the
2480 entity in the generic unit and ends with the source location of the
2481 instantiation (it is given in square brackets). This approach is recursively
2482 used in case of nested instantiations: the rightmost (nested most deeply in
2483 square brackets) element of the source trace is the location of the outermost
2484 instantiation, the next to left element is the location of the next (first
2485 nested) instantiation in the code of the corresponding generic unit, and so
2486 on, and the leftmost element (that is out of any square brackets) is the
2487 location of the declaration of the entity to eliminate in a generic unit.
2489 Note that the @code{Source_Location} argument specifies which of a set of
2490 similarly named entities is being eliminated, dealing both with overloading,
2491 and also appearance of the same entity name in different scopes.
2493 This pragma indicates that the given entity is not used in the program to be
2494 compiled and built. The effect of the pragma is to allow the compiler to
2495 eliminate the code or data associated with the named entity. Any reference to
2496 an eliminated entity causes a compile-time or link-time error.
2498 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2499 in a system-independent manner, with unused entities eliminated, without
2500 needing to modify the source text. Normally the required set of
2501 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2503 Any source file change that removes, splits, or
2504 adds lines may make the set of Eliminate pragmas invalid because their
2505 @code{Source_Location} argument values may get out of date.
2507 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2508 operation. In this case all the subprograms to which the given operation can
2509 dispatch are considered to be unused (are never called as a result of a direct
2510 or a dispatching call).
2512 @node Pragma Enable_Atomic_Synchronization
2513 @unnumberedsec Pragma Enable_Atomic_Synchronization
2514 @cindex Atomic Synchronization
2515 @findex Enable_Atomic_Synchronization
2519 @smallexample @c ada
2520 pragma Enable_Atomic_Synchronization [(Entity)];
2524 Ada requires that accesses (reads or writes) of an atomic variable be
2525 regarded as synchronization points in the case of multiple tasks.
2526 Particularly in the case of multi-processors this may require special
2527 handling, e.g. the generation of memory barriers. This synchronization
2528 is performed by default, but can be turned off using
2529 @code{pragma Disable_Atomic_Synchronization}. The
2530 @code{Enable_Atomic_Synchronization} pragma can be used to turn
2533 The placement and scope rules for this pragma are the same as those
2534 for @code{pragma Unsuppress}. In particular it can be used as a
2535 configuration pragma, or in a declaration sequence where it applies
2536 till the end of the scope. If an @code{Entity} argument is present,
2537 the action applies only to that entity.
2539 @node Pragma Export_Exception
2540 @unnumberedsec Pragma Export_Exception
2542 @findex Export_Exception
2546 @smallexample @c ada
2547 pragma Export_Exception (
2548 [Internal =>] LOCAL_NAME
2549 [, [External =>] EXTERNAL_SYMBOL]
2550 [, [Form =>] Ada | VMS]
2551 [, [Code =>] static_integer_EXPRESSION]);
2555 | static_string_EXPRESSION
2559 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
2560 causes the specified exception to be propagated outside of the Ada program,
2561 so that it can be handled by programs written in other OpenVMS languages.
2562 This pragma establishes an external name for an Ada exception and makes the
2563 name available to the OpenVMS Linker as a global symbol. For further details
2564 on this pragma, see the
2565 DEC Ada Language Reference Manual, section 13.9a3.2.
2567 @node Pragma Export_Function
2568 @unnumberedsec Pragma Export_Function
2569 @cindex Argument passing mechanisms
2570 @findex Export_Function
2575 @smallexample @c ada
2576 pragma Export_Function (
2577 [Internal =>] LOCAL_NAME
2578 [, [External =>] EXTERNAL_SYMBOL]
2579 [, [Parameter_Types =>] PARAMETER_TYPES]
2580 [, [Result_Type =>] result_SUBTYPE_MARK]
2581 [, [Mechanism =>] MECHANISM]
2582 [, [Result_Mechanism =>] MECHANISM_NAME]);
2586 | static_string_EXPRESSION
2591 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2595 | subtype_Name ' Access
2599 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2601 MECHANISM_ASSOCIATION ::=
2602 [formal_parameter_NAME =>] MECHANISM_NAME
2607 | Descriptor [([Class =>] CLASS_NAME)]
2608 | Short_Descriptor [([Class =>] CLASS_NAME)]
2610 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2614 Use this pragma to make a function externally callable and optionally
2615 provide information on mechanisms to be used for passing parameter and
2616 result values. We recommend, for the purposes of improving portability,
2617 this pragma always be used in conjunction with a separate pragma
2618 @code{Export}, which must precede the pragma @code{Export_Function}.
2619 GNAT does not require a separate pragma @code{Export}, but if none is
2620 present, @code{Convention Ada} is assumed, which is usually
2621 not what is wanted, so it is usually appropriate to use this
2622 pragma in conjunction with a @code{Export} or @code{Convention}
2623 pragma that specifies the desired foreign convention.
2624 Pragma @code{Export_Function}
2625 (and @code{Export}, if present) must appear in the same declarative
2626 region as the function to which they apply.
2628 @var{internal_name} must uniquely designate the function to which the
2629 pragma applies. If more than one function name exists of this name in
2630 the declarative part you must use the @code{Parameter_Types} and
2631 @code{Result_Type} parameters is mandatory to achieve the required
2632 unique designation. @var{subtype_mark}s in these parameters must
2633 exactly match the subtypes in the corresponding function specification,
2634 using positional notation to match parameters with subtype marks.
2635 The form with an @code{'Access} attribute can be used to match an
2636 anonymous access parameter.
2639 @cindex Passing by descriptor
2640 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2641 The default behavior for Export_Function is to accept either 64bit or
2642 32bit descriptors unless short_descriptor is specified, then only 32bit
2643 descriptors are accepted.
2645 @cindex Suppressing external name
2646 Special treatment is given if the EXTERNAL is an explicit null
2647 string or a static string expressions that evaluates to the null
2648 string. In this case, no external name is generated. This form
2649 still allows the specification of parameter mechanisms.
2651 @node Pragma Export_Object
2652 @unnumberedsec Pragma Export_Object
2653 @findex Export_Object
2657 @smallexample @c ada
2658 pragma Export_Object
2659 [Internal =>] LOCAL_NAME
2660 [, [External =>] EXTERNAL_SYMBOL]
2661 [, [Size =>] EXTERNAL_SYMBOL]
2665 | static_string_EXPRESSION
2669 This pragma designates an object as exported, and apart from the
2670 extended rules for external symbols, is identical in effect to the use of
2671 the normal @code{Export} pragma applied to an object. You may use a
2672 separate Export pragma (and you probably should from the point of view
2673 of portability), but it is not required. @var{Size} is syntax checked,
2674 but otherwise ignored by GNAT@.
2676 @node Pragma Export_Procedure
2677 @unnumberedsec Pragma Export_Procedure
2678 @findex Export_Procedure
2682 @smallexample @c ada
2683 pragma Export_Procedure (
2684 [Internal =>] LOCAL_NAME
2685 [, [External =>] EXTERNAL_SYMBOL]
2686 [, [Parameter_Types =>] PARAMETER_TYPES]
2687 [, [Mechanism =>] MECHANISM]);
2691 | static_string_EXPRESSION
2696 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2700 | subtype_Name ' Access
2704 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2706 MECHANISM_ASSOCIATION ::=
2707 [formal_parameter_NAME =>] MECHANISM_NAME
2712 | Descriptor [([Class =>] CLASS_NAME)]
2713 | Short_Descriptor [([Class =>] CLASS_NAME)]
2715 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2719 This pragma is identical to @code{Export_Function} except that it
2720 applies to a procedure rather than a function and the parameters
2721 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2722 GNAT does not require a separate pragma @code{Export}, but if none is
2723 present, @code{Convention Ada} is assumed, which is usually
2724 not what is wanted, so it is usually appropriate to use this
2725 pragma in conjunction with a @code{Export} or @code{Convention}
2726 pragma that specifies the desired foreign convention.
2729 @cindex Passing by descriptor
2730 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2731 The default behavior for Export_Procedure is to accept either 64bit or
2732 32bit descriptors unless short_descriptor is specified, then only 32bit
2733 descriptors are accepted.
2735 @cindex Suppressing external name
2736 Special treatment is given if the EXTERNAL is an explicit null
2737 string or a static string expressions that evaluates to the null
2738 string. In this case, no external name is generated. This form
2739 still allows the specification of parameter mechanisms.
2741 @node Pragma Export_Value
2742 @unnumberedsec Pragma Export_Value
2743 @findex Export_Value
2747 @smallexample @c ada
2748 pragma Export_Value (
2749 [Value =>] static_integer_EXPRESSION,
2750 [Link_Name =>] static_string_EXPRESSION);
2754 This pragma serves to export a static integer value for external use.
2755 The first argument specifies the value to be exported. The Link_Name
2756 argument specifies the symbolic name to be associated with the integer
2757 value. This pragma is useful for defining a named static value in Ada
2758 that can be referenced in assembly language units to be linked with
2759 the application. This pragma is currently supported only for the
2760 AAMP target and is ignored for other targets.
2762 @node Pragma Export_Valued_Procedure
2763 @unnumberedsec Pragma Export_Valued_Procedure
2764 @findex Export_Valued_Procedure
2768 @smallexample @c ada
2769 pragma Export_Valued_Procedure (
2770 [Internal =>] LOCAL_NAME
2771 [, [External =>] EXTERNAL_SYMBOL]
2772 [, [Parameter_Types =>] PARAMETER_TYPES]
2773 [, [Mechanism =>] MECHANISM]);
2777 | static_string_EXPRESSION
2782 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2786 | subtype_Name ' Access
2790 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2792 MECHANISM_ASSOCIATION ::=
2793 [formal_parameter_NAME =>] MECHANISM_NAME
2798 | Descriptor [([Class =>] CLASS_NAME)]
2799 | Short_Descriptor [([Class =>] CLASS_NAME)]
2801 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2805 This pragma is identical to @code{Export_Procedure} except that the
2806 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2807 mode @code{OUT}, and externally the subprogram is treated as a function
2808 with this parameter as the result of the function. GNAT provides for
2809 this capability to allow the use of @code{OUT} and @code{IN OUT}
2810 parameters in interfacing to external functions (which are not permitted
2812 GNAT does not require a separate pragma @code{Export}, but if none is
2813 present, @code{Convention Ada} is assumed, which is almost certainly
2814 not what is wanted since the whole point of this pragma is to interface
2815 with foreign language functions, so it is usually appropriate to use this
2816 pragma in conjunction with a @code{Export} or @code{Convention}
2817 pragma that specifies the desired foreign convention.
2820 @cindex Passing by descriptor
2821 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2822 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2823 32bit descriptors unless short_descriptor is specified, then only 32bit
2824 descriptors are accepted.
2826 @cindex Suppressing external name
2827 Special treatment is given if the EXTERNAL is an explicit null
2828 string or a static string expressions that evaluates to the null
2829 string. In this case, no external name is generated. This form
2830 still allows the specification of parameter mechanisms.
2832 @node Pragma Extend_System
2833 @unnumberedsec Pragma Extend_System
2834 @cindex @code{system}, extending
2836 @findex Extend_System
2840 @smallexample @c ada
2841 pragma Extend_System ([Name =>] IDENTIFIER);
2845 This pragma is used to provide backwards compatibility with other
2846 implementations that extend the facilities of package @code{System}. In
2847 GNAT, @code{System} contains only the definitions that are present in
2848 the Ada RM@. However, other implementations, notably the DEC Ada 83
2849 implementation, provide many extensions to package @code{System}.
2851 For each such implementation accommodated by this pragma, GNAT provides a
2852 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2853 implementation, which provides the required additional definitions. You
2854 can use this package in two ways. You can @code{with} it in the normal
2855 way and access entities either by selection or using a @code{use}
2856 clause. In this case no special processing is required.
2858 However, if existing code contains references such as
2859 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2860 definitions provided in package @code{System}, you may use this pragma
2861 to extend visibility in @code{System} in a non-standard way that
2862 provides greater compatibility with the existing code. Pragma
2863 @code{Extend_System} is a configuration pragma whose single argument is
2864 the name of the package containing the extended definition
2865 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2866 control of this pragma will be processed using special visibility
2867 processing that looks in package @code{System.Aux_@var{xxx}} where
2868 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2869 package @code{System}, but not found in package @code{System}.
2871 You can use this pragma either to access a predefined @code{System}
2872 extension supplied with the compiler, for example @code{Aux_DEC} or
2873 you can construct your own extension unit following the above
2874 definition. Note that such a package is a child of @code{System}
2875 and thus is considered part of the implementation. To compile
2876 it you will have to use the appropriate switch for compiling
2878 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2881 @node Pragma Extensions_Allowed
2882 @unnumberedsec Pragma Extensions_Allowed
2883 @cindex Ada Extensions
2884 @cindex GNAT Extensions
2885 @findex Extensions_Allowed
2889 @smallexample @c ada
2890 pragma Extensions_Allowed (On | Off);
2894 This configuration pragma enables or disables the implementation
2895 extension mode (the use of Off as a parameter cancels the effect
2896 of the @option{-gnatX} command switch).
2898 In extension mode, the latest version of the Ada language is
2899 implemented (currently Ada 2012), and in addition a small number
2900 of GNAT specific extensions are recognized as follows:
2903 @item Constrained attribute for generic objects
2904 The @code{Constrained} attribute is permitted for objects of
2905 generic types. The result indicates if the corresponding actual
2910 @node Pragma External
2911 @unnumberedsec Pragma External
2916 @smallexample @c ada
2918 [ Convention =>] convention_IDENTIFIER,
2919 [ Entity =>] LOCAL_NAME
2920 [, [External_Name =>] static_string_EXPRESSION ]
2921 [, [Link_Name =>] static_string_EXPRESSION ]);
2925 This pragma is identical in syntax and semantics to pragma
2926 @code{Export} as defined in the Ada Reference Manual. It is
2927 provided for compatibility with some Ada 83 compilers that
2928 used this pragma for exactly the same purposes as pragma
2929 @code{Export} before the latter was standardized.
2931 @node Pragma External_Name_Casing
2932 @unnumberedsec Pragma External_Name_Casing
2933 @cindex Dec Ada 83 casing compatibility
2934 @cindex External Names, casing
2935 @cindex Casing of External names
2936 @findex External_Name_Casing
2940 @smallexample @c ada
2941 pragma External_Name_Casing (
2942 Uppercase | Lowercase
2943 [, Uppercase | Lowercase | As_Is]);
2947 This pragma provides control over the casing of external names associated
2948 with Import and Export pragmas. There are two cases to consider:
2951 @item Implicit external names
2952 Implicit external names are derived from identifiers. The most common case
2953 arises when a standard Ada Import or Export pragma is used with only two
2956 @smallexample @c ada
2957 pragma Import (C, C_Routine);
2961 Since Ada is a case-insensitive language, the spelling of the identifier in
2962 the Ada source program does not provide any information on the desired
2963 casing of the external name, and so a convention is needed. In GNAT the
2964 default treatment is that such names are converted to all lower case
2965 letters. This corresponds to the normal C style in many environments.
2966 The first argument of pragma @code{External_Name_Casing} can be used to
2967 control this treatment. If @code{Uppercase} is specified, then the name
2968 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2969 then the normal default of all lower case letters will be used.
2971 This same implicit treatment is also used in the case of extended DEC Ada 83
2972 compatible Import and Export pragmas where an external name is explicitly
2973 specified using an identifier rather than a string.
2975 @item Explicit external names
2976 Explicit external names are given as string literals. The most common case
2977 arises when a standard Ada Import or Export pragma is used with three
2980 @smallexample @c ada
2981 pragma Import (C, C_Routine, "C_routine");
2985 In this case, the string literal normally provides the exact casing required
2986 for the external name. The second argument of pragma
2987 @code{External_Name_Casing} may be used to modify this behavior.
2988 If @code{Uppercase} is specified, then the name
2989 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2990 then the name will be forced to all lowercase letters. A specification of
2991 @code{As_Is} provides the normal default behavior in which the casing is
2992 taken from the string provided.
2996 This pragma may appear anywhere that a pragma is valid. In particular, it
2997 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2998 case it applies to all subsequent compilations, or it can be used as a program
2999 unit pragma, in which case it only applies to the current unit, or it can
3000 be used more locally to control individual Import/Export pragmas.
3002 It is primarily intended for use with OpenVMS systems, where many
3003 compilers convert all symbols to upper case by default. For interfacing to
3004 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
3007 @smallexample @c ada
3008 pragma External_Name_Casing (Uppercase, Uppercase);
3012 to enforce the upper casing of all external symbols.
3014 @node Pragma Fast_Math
3015 @unnumberedsec Pragma Fast_Math
3020 @smallexample @c ada
3025 This is a configuration pragma which activates a mode in which speed is
3026 considered more important for floating-point operations than absolutely
3027 accurate adherence to the requirements of the standard. Currently the
3028 following operations are affected:
3031 @item Complex Multiplication
3032 The normal simple formula for complex multiplication can result in intermediate
3033 overflows for numbers near the end of the range. The Ada standard requires that
3034 this situation be detected and corrected by scaling, but in Fast_Math mode such
3035 cases will simply result in overflow. Note that to take advantage of this you
3036 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
3037 under control of the pragma, rather than use the preinstantiated versions.
3040 @node Pragma Favor_Top_Level
3041 @unnumberedsec Pragma Favor_Top_Level
3042 @findex Favor_Top_Level
3046 @smallexample @c ada
3047 pragma Favor_Top_Level (type_NAME);
3051 The named type must be an access-to-subprogram type. This pragma is an
3052 efficiency hint to the compiler, regarding the use of 'Access or
3053 'Unrestricted_Access on nested (non-library-level) subprograms. The
3054 pragma means that nested subprograms are not used with this type, or
3055 are rare, so that the generated code should be efficient in the
3056 top-level case. When this pragma is used, dynamically generated
3057 trampolines may be used on some targets for nested subprograms.
3058 See also the No_Implicit_Dynamic_Code restriction.
3060 @node Pragma Finalize_Storage_Only
3061 @unnumberedsec Pragma Finalize_Storage_Only
3062 @findex Finalize_Storage_Only
3066 @smallexample @c ada
3067 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
3071 This pragma allows the compiler not to emit a Finalize call for objects
3072 defined at the library level. This is mostly useful for types where
3073 finalization is only used to deal with storage reclamation since in most
3074 environments it is not necessary to reclaim memory just before terminating
3075 execution, hence the name.
3077 @node Pragma Float_Representation
3078 @unnumberedsec Pragma Float_Representation
3080 @findex Float_Representation
3084 @smallexample @c ada
3085 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
3087 FLOAT_REP ::= VAX_Float | IEEE_Float
3091 In the one argument form, this pragma is a configuration pragma which
3092 allows control over the internal representation chosen for the predefined
3093 floating point types declared in the packages @code{Standard} and
3094 @code{System}. On all systems other than OpenVMS, the argument must
3095 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
3096 argument may be @code{VAX_Float} to specify the use of the VAX float
3097 format for the floating-point types in Standard. This requires that
3098 the standard runtime libraries be recompiled.
3100 The two argument form specifies the representation to be used for
3101 the specified floating-point type. On all systems other than OpenVMS,
3103 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
3107 For a digits value of 6, 32-bit IEEE short format will be used.
3109 For a digits value of 15, 64-bit IEEE long format will be used.
3111 No other value of digits is permitted.
3115 argument may be @code{VAX_Float} to specify the use of the VAX float
3120 For digits values up to 6, F float format will be used.
3122 For digits values from 7 to 9, D float format will be used.
3124 For digits values from 10 to 15, G float format will be used.
3126 Digits values above 15 are not allowed.
3130 @unnumberedsec Pragma Ident
3135 @smallexample @c ada
3136 pragma Ident (static_string_EXPRESSION);
3140 This pragma provides a string identification in the generated object file,
3141 if the system supports the concept of this kind of identification string.
3142 This pragma is allowed only in the outermost declarative part or
3143 declarative items of a compilation unit. If more than one @code{Ident}
3144 pragma is given, only the last one processed is effective.
3146 On OpenVMS systems, the effect of the pragma is identical to the effect of
3147 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
3148 maximum allowed length is 31 characters, so if it is important to
3149 maintain compatibility with this compiler, you should obey this length
3152 @node Pragma Implementation_Defined
3153 @unnumberedsec Pragma Implementation_Defined
3154 @findex Implementation_Defined
3158 @smallexample @c ada
3159 pragma Implementation_Defined (local_NAME);
3163 This pragma marks a previously declared entioty as implementation-defined.
3164 For an overloaded entity, applies to the most recent homonym.
3166 @smallexample @c ada
3167 pragma Implementation_Defined;
3171 The form with no arguments appears anywhere within a scope, most
3172 typically a package spec, and indicates that all entities that are
3173 defined within the package spec are Implementation_Defined.
3175 This pragma is used within the GNAT runtime library to identify
3176 implementation-defined entities introduced in language-defined units,
3177 for the purpose of implementing the No_Implementation_Identifiers
3180 @node Pragma Implemented
3181 @unnumberedsec Pragma Implemented
3186 @smallexample @c ada
3187 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
3189 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
3193 This is an Ada 2012 representation pragma which applies to protected, task
3194 and synchronized interface primitives. The use of pragma Implemented provides
3195 a way to impose a static requirement on the overriding operation by adhering
3196 to one of the three implementation kinds: entry, protected procedure or any of
3197 the above. This pragma is available in all earlier versions of Ada as an
3198 implementation-defined pragma.
3200 @smallexample @c ada
3201 type Synch_Iface is synchronized interface;
3202 procedure Prim_Op (Obj : in out Iface) is abstract;
3203 pragma Implemented (Prim_Op, By_Protected_Procedure);
3205 protected type Prot_1 is new Synch_Iface with
3206 procedure Prim_Op; -- Legal
3209 protected type Prot_2 is new Synch_Iface with
3210 entry Prim_Op; -- Illegal
3213 task type Task_Typ is new Synch_Iface with
3214 entry Prim_Op; -- Illegal
3219 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
3220 Implemented determines the runtime behavior of the requeue. Implementation kind
3221 By_Entry guarantees that the action of requeueing will proceed from an entry to
3222 another entry. Implementation kind By_Protected_Procedure transforms the
3223 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
3224 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
3225 the target's overriding subprogram kind.
3227 @node Pragma Implicit_Packing
3228 @unnumberedsec Pragma Implicit_Packing
3229 @findex Implicit_Packing
3230 @cindex Rational Profile
3234 @smallexample @c ada
3235 pragma Implicit_Packing;
3239 This is a configuration pragma that requests implicit packing for packed
3240 arrays for which a size clause is given but no explicit pragma Pack or
3241 specification of Component_Size is present. It also applies to records
3242 where no record representation clause is present. Consider this example:
3244 @smallexample @c ada
3245 type R is array (0 .. 7) of Boolean;
3250 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
3251 does not change the layout of a composite object. So the Size clause in the
3252 above example is normally rejected, since the default layout of the array uses
3253 8-bit components, and thus the array requires a minimum of 64 bits.
3255 If this declaration is compiled in a region of code covered by an occurrence
3256 of the configuration pragma Implicit_Packing, then the Size clause in this
3257 and similar examples will cause implicit packing and thus be accepted. For
3258 this implicit packing to occur, the type in question must be an array of small
3259 components whose size is known at compile time, and the Size clause must
3260 specify the exact size that corresponds to the number of elements in the array
3261 multiplied by the size in bits of the component type (both single and
3262 multi-dimensioned arrays can be controlled with this pragma).
3264 @cindex Array packing
3266 Similarly, the following example shows the use in the record case
3268 @smallexample @c ada
3270 a, b, c, d, e, f, g, h : boolean;
3277 Without a pragma Pack, each Boolean field requires 8 bits, so the
3278 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3279 sufficient. The use of pragma Implicit_Packing allows this record
3280 declaration to compile without an explicit pragma Pack.
3281 @node Pragma Import_Exception
3282 @unnumberedsec Pragma Import_Exception
3284 @findex Import_Exception
3288 @smallexample @c ada
3289 pragma Import_Exception (
3290 [Internal =>] LOCAL_NAME
3291 [, [External =>] EXTERNAL_SYMBOL]
3292 [, [Form =>] Ada | VMS]
3293 [, [Code =>] static_integer_EXPRESSION]);
3297 | static_string_EXPRESSION
3301 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3302 It allows OpenVMS conditions (for example, from OpenVMS system services or
3303 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3304 The pragma specifies that the exception associated with an exception
3305 declaration in an Ada program be defined externally (in non-Ada code).
3306 For further details on this pragma, see the
3307 DEC Ada Language Reference Manual, section 13.9a.3.1.
3309 @node Pragma Import_Function
3310 @unnumberedsec Pragma Import_Function
3311 @findex Import_Function
3315 @smallexample @c ada
3316 pragma Import_Function (
3317 [Internal =>] LOCAL_NAME,
3318 [, [External =>] EXTERNAL_SYMBOL]
3319 [, [Parameter_Types =>] PARAMETER_TYPES]
3320 [, [Result_Type =>] SUBTYPE_MARK]
3321 [, [Mechanism =>] MECHANISM]
3322 [, [Result_Mechanism =>] MECHANISM_NAME]
3323 [, [First_Optional_Parameter =>] IDENTIFIER]);
3327 | static_string_EXPRESSION
3331 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3335 | subtype_Name ' Access
3339 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3341 MECHANISM_ASSOCIATION ::=
3342 [formal_parameter_NAME =>] MECHANISM_NAME
3347 | Descriptor [([Class =>] CLASS_NAME)]
3348 | Short_Descriptor [([Class =>] CLASS_NAME)]
3350 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3354 This pragma is used in conjunction with a pragma @code{Import} to
3355 specify additional information for an imported function. The pragma
3356 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3357 @code{Import_Function} pragma and both must appear in the same
3358 declarative part as the function specification.
3360 The @var{Internal} argument must uniquely designate
3361 the function to which the
3362 pragma applies. If more than one function name exists of this name in
3363 the declarative part you must use the @code{Parameter_Types} and
3364 @var{Result_Type} parameters to achieve the required unique
3365 designation. Subtype marks in these parameters must exactly match the
3366 subtypes in the corresponding function specification, using positional
3367 notation to match parameters with subtype marks.
3368 The form with an @code{'Access} attribute can be used to match an
3369 anonymous access parameter.
3371 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3372 parameters to specify passing mechanisms for the
3373 parameters and result. If you specify a single mechanism name, it
3374 applies to all parameters. Otherwise you may specify a mechanism on a
3375 parameter by parameter basis using either positional or named
3376 notation. If the mechanism is not specified, the default mechanism
3380 @cindex Passing by descriptor
3381 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3382 The default behavior for Import_Function is to pass a 64bit descriptor
3383 unless short_descriptor is specified, then a 32bit descriptor is passed.
3385 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
3386 It specifies that the designated parameter and all following parameters
3387 are optional, meaning that they are not passed at the generated code
3388 level (this is distinct from the notion of optional parameters in Ada
3389 where the parameters are passed anyway with the designated optional
3390 parameters). All optional parameters must be of mode @code{IN} and have
3391 default parameter values that are either known at compile time
3392 expressions, or uses of the @code{'Null_Parameter} attribute.
3394 @node Pragma Import_Object
3395 @unnumberedsec Pragma Import_Object
3396 @findex Import_Object
3400 @smallexample @c ada
3401 pragma Import_Object
3402 [Internal =>] LOCAL_NAME
3403 [, [External =>] EXTERNAL_SYMBOL]
3404 [, [Size =>] EXTERNAL_SYMBOL]);
3408 | static_string_EXPRESSION
3412 This pragma designates an object as imported, and apart from the
3413 extended rules for external symbols, is identical in effect to the use of
3414 the normal @code{Import} pragma applied to an object. Unlike the
3415 subprogram case, you need not use a separate @code{Import} pragma,
3416 although you may do so (and probably should do so from a portability
3417 point of view). @var{size} is syntax checked, but otherwise ignored by
3420 @node Pragma Import_Procedure
3421 @unnumberedsec Pragma Import_Procedure
3422 @findex Import_Procedure
3426 @smallexample @c ada
3427 pragma Import_Procedure (
3428 [Internal =>] LOCAL_NAME
3429 [, [External =>] EXTERNAL_SYMBOL]
3430 [, [Parameter_Types =>] PARAMETER_TYPES]
3431 [, [Mechanism =>] MECHANISM]
3432 [, [First_Optional_Parameter =>] IDENTIFIER]);
3436 | static_string_EXPRESSION
3440 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3444 | subtype_Name ' Access
3448 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3450 MECHANISM_ASSOCIATION ::=
3451 [formal_parameter_NAME =>] MECHANISM_NAME
3456 | Descriptor [([Class =>] CLASS_NAME)]
3457 | Short_Descriptor [([Class =>] CLASS_NAME)]
3459 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3463 This pragma is identical to @code{Import_Function} except that it
3464 applies to a procedure rather than a function and the parameters
3465 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3467 @node Pragma Import_Valued_Procedure
3468 @unnumberedsec Pragma Import_Valued_Procedure
3469 @findex Import_Valued_Procedure
3473 @smallexample @c ada
3474 pragma Import_Valued_Procedure (
3475 [Internal =>] LOCAL_NAME
3476 [, [External =>] EXTERNAL_SYMBOL]
3477 [, [Parameter_Types =>] PARAMETER_TYPES]
3478 [, [Mechanism =>] MECHANISM]
3479 [, [First_Optional_Parameter =>] IDENTIFIER]);
3483 | static_string_EXPRESSION
3487 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3491 | subtype_Name ' Access
3495 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3497 MECHANISM_ASSOCIATION ::=
3498 [formal_parameter_NAME =>] MECHANISM_NAME
3503 | Descriptor [([Class =>] CLASS_NAME)]
3504 | Short_Descriptor [([Class =>] CLASS_NAME)]
3506 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3510 This pragma is identical to @code{Import_Procedure} except that the
3511 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3512 mode @code{OUT}, and externally the subprogram is treated as a function
3513 with this parameter as the result of the function. The purpose of this
3514 capability is to allow the use of @code{OUT} and @code{IN OUT}
3515 parameters in interfacing to external functions (which are not permitted
3516 in Ada functions). You may optionally use the @code{Mechanism}
3517 parameters to specify passing mechanisms for the parameters.
3518 If you specify a single mechanism name, it applies to all parameters.
3519 Otherwise you may specify a mechanism on a parameter by parameter
3520 basis using either positional or named notation. If the mechanism is not
3521 specified, the default mechanism is used.
3523 Note that it is important to use this pragma in conjunction with a separate
3524 pragma Import that specifies the desired convention, since otherwise the
3525 default convention is Ada, which is almost certainly not what is required.
3527 @node Pragma Independent
3528 @unnumberedsec Pragma Independent
3533 @smallexample @c ada
3534 pragma Independent (Local_NAME);
3538 This pragma is standard in Ada 2012 mode (which also provides an aspect
3539 of the same name). It is also available as an implementation-defined
3540 pragma in all earlier versions. It specifies that the
3541 designated object or all objects of the designated type must be
3542 independently addressable. This means that separate tasks can safely
3543 manipulate such objects. For example, if two components of a record are
3544 independent, then two separate tasks may access these two components.
3546 constraints on the representation of the object (for instance prohibiting
3549 @node Pragma Independent_Components
3550 @unnumberedsec Pragma Independent_Components
3551 @findex Independent_Components
3555 @smallexample @c ada
3556 pragma Independent_Components (Local_NAME);
3560 This pragma is standard in Ada 2012 mode (which also provides an aspect
3561 of the same name). It is also available as an implementation-defined
3562 pragma in all earlier versions. It specifies that the components of the
3563 designated object, or the components of each object of the designated
3565 independently addressable. This means that separate tasks can safely
3566 manipulate separate components in the composite object. This may place
3567 constraints on the representation of the object (for instance prohibiting
3570 @node Pragma Initialize_Scalars
3571 @unnumberedsec Pragma Initialize_Scalars
3572 @findex Initialize_Scalars
3573 @cindex debugging with Initialize_Scalars
3577 @smallexample @c ada
3578 pragma Initialize_Scalars;
3582 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3583 two important differences. First, there is no requirement for the pragma
3584 to be used uniformly in all units of a partition, in particular, it is fine
3585 to use this just for some or all of the application units of a partition,
3586 without needing to recompile the run-time library.
3588 In the case where some units are compiled with the pragma, and some without,
3589 then a declaration of a variable where the type is defined in package
3590 Standard or is locally declared will always be subject to initialization,
3591 as will any declaration of a scalar variable. For composite variables,
3592 whether the variable is initialized may also depend on whether the package
3593 in which the type of the variable is declared is compiled with the pragma.
3595 The other important difference is that you can control the value used
3596 for initializing scalar objects. At bind time, you can select several
3597 options for initialization. You can
3598 initialize with invalid values (similar to Normalize_Scalars, though for
3599 Initialize_Scalars it is not always possible to determine the invalid
3600 values in complex cases like signed component fields with non-standard
3601 sizes). You can also initialize with high or
3602 low values, or with a specified bit pattern. See the @value{EDITION}
3603 User's Guide for binder options for specifying these cases.
3605 This means that you can compile a program, and then without having to
3606 recompile the program, you can run it with different values being used
3607 for initializing otherwise uninitialized values, to test if your program
3608 behavior depends on the choice. Of course the behavior should not change,
3609 and if it does, then most likely you have an erroneous reference to an
3610 uninitialized value.
3612 It is even possible to change the value at execution time eliminating even
3613 the need to rebind with a different switch using an environment variable.
3614 See the @value{EDITION} User's Guide for details.
3616 Note that pragma @code{Initialize_Scalars} is particularly useful in
3617 conjunction with the enhanced validity checking that is now provided
3618 in GNAT, which checks for invalid values under more conditions.
3619 Using this feature (see description of the @option{-gnatV} flag in the
3620 @value{EDITION} User's Guide) in conjunction with
3621 pragma @code{Initialize_Scalars}
3622 provides a powerful new tool to assist in the detection of problems
3623 caused by uninitialized variables.
3625 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3626 effect on the generated code. This may cause your code to be
3627 substantially larger. It may also cause an increase in the amount
3628 of stack required, so it is probably a good idea to turn on stack
3629 checking (see description of stack checking in the @value{EDITION}
3630 User's Guide) when using this pragma.
3632 @node Pragma Inline_Always
3633 @unnumberedsec Pragma Inline_Always
3634 @findex Inline_Always
3638 @smallexample @c ada
3639 pragma Inline_Always (NAME [, NAME]);
3643 Similar to pragma @code{Inline} except that inlining is not subject to
3644 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3645 happens regardless of whether these options are used.
3647 @node Pragma Inline_Generic
3648 @unnumberedsec Pragma Inline_Generic
3649 @findex Inline_Generic
3653 @smallexample @c ada
3654 pragma Inline_Generic (GNAME @{, GNAME@});
3656 GNAME ::= generic_unit_NAME | generic_instance_NAME
3660 This pragma is provided for compatibility with Dec Ada 83. It has
3661 no effect in @code{GNAT} (which always inlines generics), other
3662 than to check that the given names are all names of generic units or
3665 @node Pragma Interface
3666 @unnumberedsec Pragma Interface
3671 @smallexample @c ada
3673 [Convention =>] convention_identifier,
3674 [Entity =>] local_NAME
3675 [, [External_Name =>] static_string_expression]
3676 [, [Link_Name =>] static_string_expression]);
3680 This pragma is identical in syntax and semantics to
3681 the standard Ada pragma @code{Import}. It is provided for compatibility
3682 with Ada 83. The definition is upwards compatible both with pragma
3683 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3684 with some extended implementations of this pragma in certain Ada 83
3685 implementations. The only difference between pragma @code{Interface}
3686 and pragma @code{Import} is that there is special circuitry to allow
3687 both pragmas to appear for the same subprogram entity (normally it
3688 is illegal to have multiple @code{Import} pragmas. This is useful in
3689 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3692 @node Pragma Interface_Name
3693 @unnumberedsec Pragma Interface_Name
3694 @findex Interface_Name
3698 @smallexample @c ada
3699 pragma Interface_Name (
3700 [Entity =>] LOCAL_NAME
3701 [, [External_Name =>] static_string_EXPRESSION]
3702 [, [Link_Name =>] static_string_EXPRESSION]);
3706 This pragma provides an alternative way of specifying the interface name
3707 for an interfaced subprogram, and is provided for compatibility with Ada
3708 83 compilers that use the pragma for this purpose. You must provide at
3709 least one of @var{External_Name} or @var{Link_Name}.
3711 @node Pragma Interrupt_Handler
3712 @unnumberedsec Pragma Interrupt_Handler
3713 @findex Interrupt_Handler
3717 @smallexample @c ada
3718 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3722 This program unit pragma is supported for parameterless protected procedures
3723 as described in Annex C of the Ada Reference Manual. On the AAMP target
3724 the pragma can also be specified for nonprotected parameterless procedures
3725 that are declared at the library level (which includes procedures
3726 declared at the top level of a library package). In the case of AAMP,
3727 when this pragma is applied to a nonprotected procedure, the instruction
3728 @code{IERET} is generated for returns from the procedure, enabling
3729 maskable interrupts, in place of the normal return instruction.
3731 @node Pragma Interrupt_State
3732 @unnumberedsec Pragma Interrupt_State
3733 @findex Interrupt_State
3737 @smallexample @c ada
3738 pragma Interrupt_State
3740 [State =>] SYSTEM | RUNTIME | USER);
3744 Normally certain interrupts are reserved to the implementation. Any attempt
3745 to attach an interrupt causes Program_Error to be raised, as described in
3746 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3747 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3748 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3749 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3750 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3751 Ada exceptions, or used to implement run-time functions such as the
3752 @code{abort} statement and stack overflow checking.
3754 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3755 such uses of interrupts. It subsumes the functionality of pragma
3756 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3757 available on Windows or VMS. On all other platforms than VxWorks,
3758 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3759 and may be used to mark interrupts required by the board support package
3762 Interrupts can be in one of three states:
3766 The interrupt is reserved (no Ada handler can be installed), and the
3767 Ada run-time may not install a handler. As a result you are guaranteed
3768 standard system default action if this interrupt is raised.
3772 The interrupt is reserved (no Ada handler can be installed). The run time
3773 is allowed to install a handler for internal control purposes, but is
3774 not required to do so.
3778 The interrupt is unreserved. The user may install a handler to provide
3783 These states are the allowed values of the @code{State} parameter of the
3784 pragma. The @code{Name} parameter is a value of the type
3785 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3786 @code{Ada.Interrupts.Names}.
3788 This is a configuration pragma, and the binder will check that there
3789 are no inconsistencies between different units in a partition in how a
3790 given interrupt is specified. It may appear anywhere a pragma is legal.
3792 The effect is to move the interrupt to the specified state.
3794 By declaring interrupts to be SYSTEM, you guarantee the standard system
3795 action, such as a core dump.
3797 By declaring interrupts to be USER, you guarantee that you can install
3800 Note that certain signals on many operating systems cannot be caught and
3801 handled by applications. In such cases, the pragma is ignored. See the
3802 operating system documentation, or the value of the array @code{Reserved}
3803 declared in the spec of package @code{System.OS_Interface}.
3805 Overriding the default state of signals used by the Ada runtime may interfere
3806 with an application's runtime behavior in the cases of the synchronous signals,
3807 and in the case of the signal used to implement the @code{abort} statement.
3809 @node Pragma Invariant
3810 @unnumberedsec Pragma Invariant
3815 @smallexample @c ada
3817 ([Entity =>] private_type_LOCAL_NAME,
3818 [Check =>] EXPRESSION
3819 [,[Message =>] String_Expression]);
3823 This pragma provides exactly the same capabilities as the Type_Invariant aspect
3824 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
3825 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
3826 requires the use of the aspect syntax, which is not available except in 2012
3827 mode, it is not possible to use the Type_Invariant aspect in earlier versions
3828 of Ada. However the Invariant pragma may be used in any version of Ada. Also
3829 note that the aspect Invariant is a synonym in GNAT for the aspect
3830 Type_Invariant, but there is no pragma Type_Invariant.
3832 The pragma must appear within the visible part of the package specification,
3833 after the type to which its Entity argument appears. As with the Invariant
3834 aspect, the Check expression is not analyzed until the end of the visible
3835 part of the package, so it may contain forward references. The Message
3836 argument, if present, provides the exception message used if the invariant
3837 is violated. If no Message parameter is provided, a default message that
3838 identifies the line on which the pragma appears is used.
3840 It is permissible to have multiple Invariants for the same type entity, in
3841 which case they are and'ed together. It is permissible to use this pragma
3842 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3843 invariant pragma for the same entity.
3845 For further details on the use of this pragma, see the Ada 2012 documentation
3846 of the Type_Invariant aspect.
3848 @node Pragma Java_Constructor
3849 @unnumberedsec Pragma Java_Constructor
3850 @findex Java_Constructor
3854 @smallexample @c ada
3855 pragma Java_Constructor ([Entity =>] function_LOCAL_NAME);
3859 This pragma is used to assert that the specified Ada function should be
3860 mapped to the Java constructor for some Ada tagged record type.
3862 See section 7.3.2 of the
3863 @code{GNAT User's Guide: Supplement for the JVM Platform.}
3864 for related information.
3866 @node Pragma Java_Interface
3867 @unnumberedsec Pragma Java_Interface
3868 @findex Java_Interface
3872 @smallexample @c ada
3873 pragma Java_Interface ([Entity =>] abstract_tagged_type_LOCAL_NAME);
3877 This pragma is used to assert that the specified Ada abstract tagged type
3878 is to be mapped to a Java interface name.
3880 See sections 7.1 and 7.2 of the
3881 @code{GNAT User's Guide: Supplement for the JVM Platform.}
3882 for related information.
3884 @node Pragma Keep_Names
3885 @unnumberedsec Pragma Keep_Names
3890 @smallexample @c ada
3891 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3895 The @var{LOCAL_NAME} argument
3896 must refer to an enumeration first subtype
3897 in the current declarative part. The effect is to retain the enumeration
3898 literal names for use by @code{Image} and @code{Value} even if a global
3899 @code{Discard_Names} pragma applies. This is useful when you want to
3900 generally suppress enumeration literal names and for example you therefore
3901 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3902 want to retain the names for specific enumeration types.
3904 @node Pragma License
3905 @unnumberedsec Pragma License
3907 @cindex License checking
3911 @smallexample @c ada
3912 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3916 This pragma is provided to allow automated checking for appropriate license
3917 conditions with respect to the standard and modified GPL@. A pragma
3918 @code{License}, which is a configuration pragma that typically appears at
3919 the start of a source file or in a separate @file{gnat.adc} file, specifies
3920 the licensing conditions of a unit as follows:
3924 This is used for a unit that can be freely used with no license restrictions.
3925 Examples of such units are public domain units, and units from the Ada
3929 This is used for a unit that is licensed under the unmodified GPL, and which
3930 therefore cannot be @code{with}'ed by a restricted unit.
3933 This is used for a unit licensed under the GNAT modified GPL that includes
3934 a special exception paragraph that specifically permits the inclusion of
3935 the unit in programs without requiring the entire program to be released
3939 This is used for a unit that is restricted in that it is not permitted to
3940 depend on units that are licensed under the GPL@. Typical examples are
3941 proprietary code that is to be released under more restrictive license
3942 conditions. Note that restricted units are permitted to @code{with} units
3943 which are licensed under the modified GPL (this is the whole point of the
3949 Normally a unit with no @code{License} pragma is considered to have an
3950 unknown license, and no checking is done. However, standard GNAT headers
3951 are recognized, and license information is derived from them as follows.
3955 A GNAT license header starts with a line containing 78 hyphens. The following
3956 comment text is searched for the appearance of any of the following strings.
3958 If the string ``GNU General Public License'' is found, then the unit is assumed
3959 to have GPL license, unless the string ``As a special exception'' follows, in
3960 which case the license is assumed to be modified GPL@.
3962 If one of the strings
3963 ``This specification is adapted from the Ada Semantic Interface'' or
3964 ``This specification is derived from the Ada Reference Manual'' is found
3965 then the unit is assumed to be unrestricted.
3969 These default actions means that a program with a restricted license pragma
3970 will automatically get warnings if a GPL unit is inappropriately
3971 @code{with}'ed. For example, the program:
3973 @smallexample @c ada
3976 procedure Secret_Stuff is
3982 if compiled with pragma @code{License} (@code{Restricted}) in a
3983 @file{gnat.adc} file will generate the warning:
3988 >>> license of withed unit "Sem_Ch3" is incompatible
3990 2. with GNAT.Sockets;
3991 3. procedure Secret_Stuff is
3995 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3996 compiler and is licensed under the
3997 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3998 run time, and is therefore licensed under the modified GPL@.
4000 @node Pragma Link_With
4001 @unnumberedsec Pragma Link_With
4006 @smallexample @c ada
4007 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
4011 This pragma is provided for compatibility with certain Ada 83 compilers.
4012 It has exactly the same effect as pragma @code{Linker_Options} except
4013 that spaces occurring within one of the string expressions are treated
4014 as separators. For example, in the following case:
4016 @smallexample @c ada
4017 pragma Link_With ("-labc -ldef");
4021 results in passing the strings @code{-labc} and @code{-ldef} as two
4022 separate arguments to the linker. In addition pragma Link_With allows
4023 multiple arguments, with the same effect as successive pragmas.
4025 @node Pragma Linker_Alias
4026 @unnumberedsec Pragma Linker_Alias
4027 @findex Linker_Alias
4031 @smallexample @c ada
4032 pragma Linker_Alias (
4033 [Entity =>] LOCAL_NAME,
4034 [Target =>] static_string_EXPRESSION);
4038 @var{LOCAL_NAME} must refer to an object that is declared at the library
4039 level. This pragma establishes the given entity as a linker alias for the
4040 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
4041 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
4042 @var{static_string_EXPRESSION} in the object file, that is to say no space
4043 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
4044 to the same address as @var{static_string_EXPRESSION} by the linker.
4046 The actual linker name for the target must be used (e.g.@: the fully
4047 encoded name with qualification in Ada, or the mangled name in C++),
4048 or it must be declared using the C convention with @code{pragma Import}
4049 or @code{pragma Export}.
4051 Not all target machines support this pragma. On some of them it is accepted
4052 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
4054 @smallexample @c ada
4055 -- Example of the use of pragma Linker_Alias
4059 pragma Export (C, i);
4061 new_name_for_i : Integer;
4062 pragma Linker_Alias (new_name_for_i, "i");
4066 @node Pragma Linker_Constructor
4067 @unnumberedsec Pragma Linker_Constructor
4068 @findex Linker_Constructor
4072 @smallexample @c ada
4073 pragma Linker_Constructor (procedure_LOCAL_NAME);
4077 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4078 is declared at the library level. A procedure to which this pragma is
4079 applied will be treated as an initialization routine by the linker.
4080 It is equivalent to @code{__attribute__((constructor))} in GNU C and
4081 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
4082 of the executable is called (or immediately after the shared library is
4083 loaded if the procedure is linked in a shared library), in particular
4084 before the Ada run-time environment is set up.
4086 Because of these specific contexts, the set of operations such a procedure
4087 can perform is very limited and the type of objects it can manipulate is
4088 essentially restricted to the elementary types. In particular, it must only
4089 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
4091 This pragma is used by GNAT to implement auto-initialization of shared Stand
4092 Alone Libraries, which provides a related capability without the restrictions
4093 listed above. Where possible, the use of Stand Alone Libraries is preferable
4094 to the use of this pragma.
4096 @node Pragma Linker_Destructor
4097 @unnumberedsec Pragma Linker_Destructor
4098 @findex Linker_Destructor
4102 @smallexample @c ada
4103 pragma Linker_Destructor (procedure_LOCAL_NAME);
4107 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4108 is declared at the library level. A procedure to which this pragma is
4109 applied will be treated as a finalization routine by the linker.
4110 It is equivalent to @code{__attribute__((destructor))} in GNU C and
4111 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
4112 of the executable has exited (or immediately before the shared library
4113 is unloaded if the procedure is linked in a shared library), in particular
4114 after the Ada run-time environment is shut down.
4116 See @code{pragma Linker_Constructor} for the set of restrictions that apply
4117 because of these specific contexts.
4119 @node Pragma Linker_Section
4120 @unnumberedsec Pragma Linker_Section
4121 @findex Linker_Section
4125 @smallexample @c ada
4126 pragma Linker_Section (
4127 [Entity =>] LOCAL_NAME,
4128 [Section =>] static_string_EXPRESSION);
4132 @var{LOCAL_NAME} must refer to an object that is declared at the library
4133 level. This pragma specifies the name of the linker section for the given
4134 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
4135 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
4136 section of the executable (assuming the linker doesn't rename the section).
4138 The compiler normally places library-level objects in standard sections
4139 depending on their type: procedures and functions generally go in the
4140 @code{.text} section, initialized variables in the @code{.data} section
4141 and uninitialized variables in the @code{.bss} section.
4143 Other, special sections may exist on given target machines to map special
4144 hardware, for example I/O ports or flash memory. This pragma is a means to
4145 defer the final layout of the executable to the linker, thus fully working
4146 at the symbolic level with the compiler.
4148 Some file formats do not support arbitrary sections so not all target
4149 machines support this pragma. The use of this pragma may cause a program
4150 execution to be erroneous if it is used to place an entity into an
4151 inappropriate section (e.g.@: a modified variable into the @code{.text}
4152 section). See also @code{pragma Persistent_BSS}.
4154 @smallexample @c ada
4155 -- Example of the use of pragma Linker_Section
4159 pragma Volatile (Port_A);
4160 pragma Linker_Section (Port_A, ".bss.port_a");
4163 pragma Volatile (Port_B);
4164 pragma Linker_Section (Port_B, ".bss.port_b");
4168 @node Pragma Long_Float
4169 @unnumberedsec Pragma Long_Float
4175 @smallexample @c ada
4176 pragma Long_Float (FLOAT_FORMAT);
4178 FLOAT_FORMAT ::= D_Float | G_Float
4182 This pragma is implemented only in the OpenVMS implementation of GNAT@.
4183 It allows control over the internal representation chosen for the predefined
4184 type @code{Long_Float} and for floating point type representations with
4185 @code{digits} specified in the range 7 through 15.
4186 For further details on this pragma, see the
4187 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
4188 this pragma, the standard runtime libraries must be recompiled.
4190 @node Pragma Loop_Invariant
4191 @unnumberedsec Pragma Loop_Invariant
4192 @findex Loop_Invariant
4196 @smallexample @c ada
4197 pragma Loop_Invariant ( boolean_EXPRESSION );
4201 The effect of this pragma is similar to that of pragma @code{Assert},
4202 except that in an @code{Assertion_Policy} pragma, the identifier
4203 @code{Loop_Invariant} is used to control whether it is ignored or checked
4206 @code{Loop_Invariant} can only appear as one of the items in the sequence
4207 of statements of a loop body. The intention is that it be used to
4208 represent a "loop invariant" assertion, i.e. something that is true each
4209 time through the loop, and which can be used to show that the loop is
4210 achieving its purpose.
4212 To aid in writing such invariants, the special attribute @code{Loop_Entry}
4213 may be used to refer to the value of an expression on entry to the loop. This
4214 attribute can only be used within the expression of a @code{Loop_Invariant}
4215 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
4217 @node Pragma Loop_Optimize
4218 @unnumberedsec Pragma Loop_Optimize
4219 @findex Loop_Optimize
4223 @smallexample @c ada
4224 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
4226 OPTIMIZATION_HINT ::= No_Unroll | Unroll | No_Vector | Vector
4230 This pragma must appear immediately within a loop statement. It allows the
4231 programmer to specify optimization hints for the enclosing loop. The hints
4232 are not mutually exclusive and can be freely mixed, but not all combinations
4233 will yield a sensible outcome.
4235 There are four supported optimization hints for a loop:
4239 The loop must not be unrolled. This is a strong hint: the compiler will not
4240 unroll a loop marked with this hint.
4244 The loop should be unrolled. This is a weak hint: the compiler will try to
4245 apply unrolling to this loop preferably to other optimizations, notably
4246 vectorization, but there is no guarantee that the loop will be unrolled.
4250 The loop must not be vectorized. This is a strong hint: the compiler will not
4251 vectorize a loop marked with this hint.
4255 The loop should be vectorized. This is a weak hint: the compiler will try to
4256 apply vectorization to this loop preferably to other optimizations, notably
4257 unrolling, but there is no guarantee that the loop will be vectorized.
4261 These hints do not void the need to pass the appropriate switches to the
4262 compiler in order to enable the relevant optimizations, that is to say
4263 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
4266 @node Pragma Loop_Variant
4267 @unnumberedsec Pragma Loop_Variant
4268 @findex Loop_Variant
4272 @smallexample @c ada
4273 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
4274 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
4275 CHANGE_DIRECTION ::= Increases | Decreases
4279 This pragma must appear immediately within the sequence of statements of a
4280 loop statement. It allows the specification of quantities which must always
4281 decrease or increase in successive iterations of the loop. In its simplest
4282 form, just one expression is specified, whose value must increase or decrease
4283 on each iteration of the loop.
4285 In a more complex form, multiple arguments can be given which are intepreted
4286 in a nesting lexicographic manner. For example:
4288 @smallexample @c ada
4289 pragma Loop_Variant (Increases => X, Decreases => Y);
4293 specifies that each time through the loop either X increases, or X stays
4294 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
4295 loop is making progress. It can be useful in helping to show informally
4296 or prove formally that the loop always terminates.
4298 @code{Loop_Variant} is an assertion whose effect can be controlled using
4299 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
4300 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
4301 to ignore the check (in which case the pragma has no effect on the program),
4302 or @code{Disable} in which case the pragma is not even checked for correct
4305 The @code{Loop_Entry} attribute may be used within the expressions of the
4306 @code{Loop_Variant} pragma to refer to values on entry to the loop.
4308 @node Pragma Machine_Attribute
4309 @unnumberedsec Pragma Machine_Attribute
4310 @findex Machine_Attribute
4314 @smallexample @c ada
4315 pragma Machine_Attribute (
4316 [Entity =>] LOCAL_NAME,
4317 [Attribute_Name =>] static_string_EXPRESSION
4318 [, [Info =>] static_EXPRESSION] );
4322 Machine-dependent attributes can be specified for types and/or
4323 declarations. This pragma is semantically equivalent to
4324 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
4325 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
4326 in GNU C, where @code{@var{attribute_name}} is recognized by the
4327 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
4328 specific macro. A string literal for the optional parameter @var{info}
4329 is transformed into an identifier, which may make this pragma unusable
4330 for some attributes. @xref{Target Attributes,, Defining target-specific
4331 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
4332 Internals}, further information.
4335 @unnumberedsec Pragma Main
4341 @smallexample @c ada
4343 (MAIN_OPTION [, MAIN_OPTION]);
4346 [Stack_Size =>] static_integer_EXPRESSION
4347 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
4348 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
4352 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4353 no effect in GNAT, other than being syntax checked.
4355 @node Pragma Main_Storage
4356 @unnumberedsec Pragma Main_Storage
4358 @findex Main_Storage
4362 @smallexample @c ada
4364 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
4366 MAIN_STORAGE_OPTION ::=
4367 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
4368 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
4372 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4373 no effect in GNAT, other than being syntax checked. Note that the pragma
4374 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4376 @node Pragma No_Body
4377 @unnumberedsec Pragma No_Body
4382 @smallexample @c ada
4387 There are a number of cases in which a package spec does not require a body,
4388 and in fact a body is not permitted. GNAT will not permit the spec to be
4389 compiled if there is a body around. The pragma No_Body allows you to provide
4390 a body file, even in a case where no body is allowed. The body file must
4391 contain only comments and a single No_Body pragma. This is recognized by
4392 the compiler as indicating that no body is logically present.
4394 This is particularly useful during maintenance when a package is modified in
4395 such a way that a body needed before is no longer needed. The provision of a
4396 dummy body with a No_Body pragma ensures that there is no interference from
4397 earlier versions of the package body.
4399 @node Pragma No_Inline
4400 @unnumberedsec Pragma No_Inline
4405 @smallexample @c ada
4406 pragma No_Inline (NAME @{, NAME@});
4410 This pragma suppresses inlining for the callable entity or the instances of
4411 the generic subprogram designated by @var{NAME}, including inlining that
4412 results from the use of pragma @code{Inline}. This pragma is always active,
4413 in particular it is not subject to the use of option @option{-gnatn} or
4414 @option{-gnatN}. It is illegal to specify both pragma @code{No_Inline} and
4415 pragma @code{Inline_Always} for the same @var{NAME}.
4417 @node Pragma No_Return
4418 @unnumberedsec Pragma No_Return
4423 @smallexample @c ada
4424 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4428 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4429 declarations in the current declarative part. A procedure to which this
4430 pragma is applied may not contain any explicit @code{return} statements.
4431 In addition, if the procedure contains any implicit returns from falling
4432 off the end of a statement sequence, then execution of that implicit
4433 return will cause Program_Error to be raised.
4435 One use of this pragma is to identify procedures whose only purpose is to raise
4436 an exception. Another use of this pragma is to suppress incorrect warnings
4437 about missing returns in functions, where the last statement of a function
4438 statement sequence is a call to such a procedure.
4440 Note that in Ada 2005 mode, this pragma is part of the language. It is
4441 available in all earlier versions of Ada as an implementation-defined
4444 @node Pragma No_Run_Time
4445 @unnumberedsec Pragma No_Run_Time
4450 @smallexample @c ada
4455 This is an obsolete configuration pragma that historically was used to
4456 setup what is now called the "zero footprint" library. It causes any
4457 library units outside this basic library to be ignored. The use of
4458 this pragma has been superseded by the general configurable run-time
4459 capability of @code{GNAT} where the compiler takes into account whatever
4460 units happen to be accessible in the library.
4462 @node Pragma No_Strict_Aliasing
4463 @unnumberedsec Pragma No_Strict_Aliasing
4464 @findex No_Strict_Aliasing
4468 @smallexample @c ada
4469 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4473 @var{type_LOCAL_NAME} must refer to an access type
4474 declaration in the current declarative part. The effect is to inhibit
4475 strict aliasing optimization for the given type. The form with no
4476 arguments is a configuration pragma which applies to all access types
4477 declared in units to which the pragma applies. For a detailed
4478 description of the strict aliasing optimization, and the situations
4479 in which it must be suppressed, see @ref{Optimization and Strict
4480 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4482 This pragma currently has no effects on access to unconstrained array types.
4484 @node Pragma Normalize_Scalars
4485 @unnumberedsec Pragma Normalize_Scalars
4486 @findex Normalize_Scalars
4490 @smallexample @c ada
4491 pragma Normalize_Scalars;
4495 This is a language defined pragma which is fully implemented in GNAT@. The
4496 effect is to cause all scalar objects that are not otherwise initialized
4497 to be initialized. The initial values are implementation dependent and
4501 @item Standard.Character
4503 Objects whose root type is Standard.Character are initialized to
4504 Character'Last unless the subtype range excludes NUL (in which case
4505 NUL is used). This choice will always generate an invalid value if
4508 @item Standard.Wide_Character
4510 Objects whose root type is Standard.Wide_Character are initialized to
4511 Wide_Character'Last unless the subtype range excludes NUL (in which case
4512 NUL is used). This choice will always generate an invalid value if
4515 @item Standard.Wide_Wide_Character
4517 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4518 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4519 which case NUL is used). This choice will always generate an invalid value if
4524 Objects of an integer type are treated differently depending on whether
4525 negative values are present in the subtype. If no negative values are
4526 present, then all one bits is used as the initial value except in the
4527 special case where zero is excluded from the subtype, in which case
4528 all zero bits are used. This choice will always generate an invalid
4529 value if one exists.
4531 For subtypes with negative values present, the largest negative number
4532 is used, except in the unusual case where this largest negative number
4533 is in the subtype, and the largest positive number is not, in which case
4534 the largest positive value is used. This choice will always generate
4535 an invalid value if one exists.
4537 @item Floating-Point Types
4538 Objects of all floating-point types are initialized to all 1-bits. For
4539 standard IEEE format, this corresponds to a NaN (not a number) which is
4540 indeed an invalid value.
4542 @item Fixed-Point Types
4543 Objects of all fixed-point types are treated as described above for integers,
4544 with the rules applying to the underlying integer value used to represent
4545 the fixed-point value.
4548 Objects of a modular type are initialized to all one bits, except in
4549 the special case where zero is excluded from the subtype, in which
4550 case all zero bits are used. This choice will always generate an
4551 invalid value if one exists.
4553 @item Enumeration types
4554 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
4555 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
4556 whose Pos value is zero, in which case a code of zero is used. This choice
4557 will always generate an invalid value if one exists.
4561 @node Pragma Obsolescent
4562 @unnumberedsec Pragma Obsolescent
4567 @smallexample @c ada
4570 pragma Obsolescent (
4571 [Message =>] static_string_EXPRESSION
4572 [,[Version =>] Ada_05]]);
4574 pragma Obsolescent (
4576 [,[Message =>] static_string_EXPRESSION
4577 [,[Version =>] Ada_05]] );
4581 This pragma can occur immediately following a declaration of an entity,
4582 including the case of a record component. If no Entity argument is present,
4583 then this declaration is the one to which the pragma applies. If an Entity
4584 parameter is present, it must either match the name of the entity in this
4585 declaration, or alternatively, the pragma can immediately follow an enumeration
4586 type declaration, where the Entity argument names one of the enumeration
4589 This pragma is used to indicate that the named entity
4590 is considered obsolescent and should not be used. Typically this is
4591 used when an API must be modified by eventually removing or modifying
4592 existing subprograms or other entities. The pragma can be used at an
4593 intermediate stage when the entity is still present, but will be
4596 The effect of this pragma is to output a warning message on a reference to
4597 an entity thus marked that the subprogram is obsolescent if the appropriate
4598 warning option in the compiler is activated. If the Message parameter is
4599 present, then a second warning message is given containing this text. In
4600 addition, a reference to the entity is considered to be a violation of pragma
4601 Restrictions (No_Obsolescent_Features).
4603 This pragma can also be used as a program unit pragma for a package,
4604 in which case the entity name is the name of the package, and the
4605 pragma indicates that the entire package is considered
4606 obsolescent. In this case a client @code{with}'ing such a package
4607 violates the restriction, and the @code{with} statement is
4608 flagged with warnings if the warning option is set.
4610 If the Version parameter is present (which must be exactly
4611 the identifier Ada_05, no other argument is allowed), then the
4612 indication of obsolescence applies only when compiling in Ada 2005
4613 mode. This is primarily intended for dealing with the situations
4614 in the predefined library where subprograms or packages
4615 have become defined as obsolescent in Ada 2005
4616 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
4618 The following examples show typical uses of this pragma:
4620 @smallexample @c ada
4622 pragma Obsolescent (p, Message => "use pp instead of p");
4627 pragma Obsolescent ("use q2new instead");
4629 type R is new integer;
4632 Message => "use RR in Ada 2005",
4642 type E is (a, bc, 'd', quack);
4643 pragma Obsolescent (Entity => bc)
4644 pragma Obsolescent (Entity => 'd')
4647 (a, b : character) return character;
4648 pragma Obsolescent (Entity => "+");
4653 Note that, as for all pragmas, if you use a pragma argument identifier,
4654 then all subsequent parameters must also use a pragma argument identifier.
4655 So if you specify "Entity =>" for the Entity argument, and a Message
4656 argument is present, it must be preceded by "Message =>".
4658 @node Pragma Optimize_Alignment
4659 @unnumberedsec Pragma Optimize_Alignment
4660 @findex Optimize_Alignment
4661 @cindex Alignment, default settings
4665 @smallexample @c ada
4666 pragma Optimize_Alignment (TIME | SPACE | OFF);
4670 This is a configuration pragma which affects the choice of default alignments
4671 for types where no alignment is explicitly specified. There is a time/space
4672 trade-off in the selection of these values. Large alignments result in more
4673 efficient code, at the expense of larger data space, since sizes have to be
4674 increased to match these alignments. Smaller alignments save space, but the
4675 access code is slower. The normal choice of default alignments (which is what
4676 you get if you do not use this pragma, or if you use an argument of OFF),
4677 tries to balance these two requirements.
4679 Specifying SPACE causes smaller default alignments to be chosen in two cases.
4680 First any packed record is given an alignment of 1. Second, if a size is given
4681 for the type, then the alignment is chosen to avoid increasing this size. For
4684 @smallexample @c ada
4694 In the default mode, this type gets an alignment of 4, so that access to the
4695 Integer field X are efficient. But this means that objects of the type end up
4696 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4697 allowed to be bigger than the size of the type, but it can waste space if for
4698 example fields of type R appear in an enclosing record. If the above type is
4699 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4701 However, there is one case in which SPACE is ignored. If a variable length
4702 record (that is a discriminated record with a component which is an array
4703 whose length depends on a discriminant), has a pragma Pack, then it is not
4704 in general possible to set the alignment of such a record to one, so the
4705 pragma is ignored in this case (with a warning).
4707 Specifying TIME causes larger default alignments to be chosen in the case of
4708 small types with sizes that are not a power of 2. For example, consider:
4710 @smallexample @c ada
4722 The default alignment for this record is normally 1, but if this type is
4723 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
4724 to 4, which wastes space for objects of the type, since they are now 4 bytes
4725 long, but results in more efficient access when the whole record is referenced.
4727 As noted above, this is a configuration pragma, and there is a requirement
4728 that all units in a partition be compiled with a consistent setting of the
4729 optimization setting. This would normally be achieved by use of a configuration
4730 pragma file containing the appropriate setting. The exception to this rule is
4731 that units with an explicit configuration pragma in the same file as the source
4732 unit are excluded from the consistency check, as are all predefined units. The
4733 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4734 pragma appears at the start of the file.
4736 @node Pragma Ordered
4737 @unnumberedsec Pragma Ordered
4739 @findex pragma @code{Ordered}
4743 @smallexample @c ada
4744 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4748 Most enumeration types are from a conceptual point of view unordered.
4749 For example, consider:
4751 @smallexample @c ada
4752 type Color is (Red, Blue, Green, Yellow);
4756 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
4757 but really these relations make no sense; the enumeration type merely
4758 specifies a set of possible colors, and the order is unimportant.
4760 For unordered enumeration types, it is generally a good idea if
4761 clients avoid comparisons (other than equality or inequality) and
4762 explicit ranges. (A @emph{client} is a unit where the type is referenced,
4763 other than the unit where the type is declared, its body, and its subunits.)
4764 For example, if code buried in some client says:
4766 @smallexample @c ada
4767 if Current_Color < Yellow then ...
4768 if Current_Color in Blue .. Green then ...
4772 then the client code is relying on the order, which is undesirable.
4773 It makes the code hard to read and creates maintenance difficulties if
4774 entries have to be added to the enumeration type. Instead,
4775 the code in the client should list the possibilities, or an
4776 appropriate subtype should be declared in the unit that declares
4777 the original enumeration type. E.g., the following subtype could
4778 be declared along with the type @code{Color}:
4780 @smallexample @c ada
4781 subtype RBG is Color range Red .. Green;
4785 and then the client could write:
4787 @smallexample @c ada
4788 if Current_Color in RBG then ...
4789 if Current_Color = Blue or Current_Color = Green then ...
4793 However, some enumeration types are legitimately ordered from a conceptual
4794 point of view. For example, if you declare:
4796 @smallexample @c ada
4797 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
4801 then the ordering imposed by the language is reasonable, and
4802 clients can depend on it, writing for example:
4804 @smallexample @c ada
4805 if D in Mon .. Fri then ...
4810 The pragma @option{Ordered} is provided to mark enumeration types that
4811 are conceptually ordered, alerting the reader that clients may depend
4812 on the ordering. GNAT provides a pragma to mark enumerations as ordered
4813 rather than one to mark them as unordered, since in our experience,
4814 the great majority of enumeration types are conceptually unordered.
4816 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
4817 and @code{Wide_Wide_Character}
4818 are considered to be ordered types, so each is declared with a
4819 pragma @code{Ordered} in package @code{Standard}.
4821 Normally pragma @code{Ordered} serves only as documentation and a guide for
4822 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
4823 requests warnings for inappropriate uses (comparisons and explicit
4824 subranges) for unordered types. If this switch is used, then any
4825 enumeration type not marked with pragma @code{Ordered} will be considered
4826 as unordered, and will generate warnings for inappropriate uses.
4828 For additional information please refer to the description of the
4829 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
4831 @node Pragma Overflow_Mode
4832 @unnumberedsec Pragma Overflow_Mode
4833 @findex Overflow checks
4834 @findex Overflow mode
4835 @findex pragma @code{Overflow_Mode}
4839 @smallexample @c ada
4840 pragma Overflow_Mode
4842 [,[Assertions =>] MODE]);
4844 MODE ::= STRICT | MINIMIZED | ELIMINATED
4848 This pragma sets the current overflow mode to the given setting. For details
4849 of the meaning of these modes, please refer to the
4850 ``Overflow Check Handling in GNAT'' appendix in the
4851 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
4852 the given mode applies to all expressions. If both parameters are present,
4853 the @code{General} mode applies to expressions outside assertions, and
4854 the @code{Eliminated} mode applies to expressions within assertions.
4856 The case of the @code{MODE} parameter is ignored,
4857 so @code{MINIMIZED}, @code{Minimized} and
4858 @code{minimized} all have the same effect.
4860 The @code{Overflow_Mode} pragma has the same scoping and placement
4861 rules as pragma @code{Suppress}, so it can occur either as a
4862 configuration pragma, specifying a default for the whole
4863 program, or in a declarative scope, where it applies to the
4864 remaining declarations and statements in that scope.
4866 The pragma @code{Suppress (Overflow_Check)} suppresses
4867 overflow checking, but does not affect the overflow mode.
4869 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
4870 overflow checking, but does not affect the overflow mode.
4872 @node Pragma Overriding_Renamings
4873 @unnumberedsec Pragma Overriding_Renamings
4874 @findex Overriding_Renamings
4875 @cindex Rational profile
4876 @cindex Rational compatibility
4880 @smallexample @c ada
4881 pragma Overriding_Renamings;
4885 This is a GNAT configuration pragma to simplify porting
4886 legacy code accepted by the Rational
4887 Ada compiler. In the presence of this pragma, a renaming declaration that
4888 renames an inherited operation declared in the same scope is legal if selected
4889 notation is used as in:
4891 @smallexample @c ada
4892 pragma Overriding_Renamings;
4897 function F (..) renames R.F;
4902 RM 8.3 (15) stipulates that an overridden operation is not visible within the
4903 declaration of the overriding operation.
4905 @node Pragma Partition_Elaboration_Policy
4906 @unnumberedsec Pragma Partition_Elaboration_Policy
4907 @findex Partition_Elaboration_Policy
4911 @smallexample @c ada
4912 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
4914 POLICY_IDENTIFIER ::= Concurrent | Sequential
4918 This pragma is standard in Ada 2005, but is available in all earlier
4919 versions of Ada as an implementation-defined pragma.
4920 See Ada 2012 Reference Manual for details.
4922 @node Pragma Passive
4923 @unnumberedsec Pragma Passive
4928 @smallexample @c ada
4929 pragma Passive [(Semaphore | No)];
4933 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
4934 compatibility with DEC Ada 83 implementations, where it is used within a
4935 task definition to request that a task be made passive. If the argument
4936 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
4937 treats the pragma as an assertion that the containing task is passive
4938 and that optimization of context switch with this task is permitted and
4939 desired. If the argument @code{No} is present, the task must not be
4940 optimized. GNAT does not attempt to optimize any tasks in this manner
4941 (since protected objects are available in place of passive tasks).
4943 @node Pragma Persistent_BSS
4944 @unnumberedsec Pragma Persistent_BSS
4945 @findex Persistent_BSS
4949 @smallexample @c ada
4950 pragma Persistent_BSS [(LOCAL_NAME)]
4954 This pragma allows selected objects to be placed in the @code{.persistent_bss}
4955 section. On some targets the linker and loader provide for special
4956 treatment of this section, allowing a program to be reloaded without
4957 affecting the contents of this data (hence the name persistent).
4959 There are two forms of usage. If an argument is given, it must be the
4960 local name of a library level object, with no explicit initialization
4961 and whose type is potentially persistent. If no argument is given, then
4962 the pragma is a configuration pragma, and applies to all library level
4963 objects with no explicit initialization of potentially persistent types.
4965 A potentially persistent type is a scalar type, or a non-tagged,
4966 non-discriminated record, all of whose components have no explicit
4967 initialization and are themselves of a potentially persistent type,
4968 or an array, all of whose constraints are static, and whose component
4969 type is potentially persistent.
4971 If this pragma is used on a target where this feature is not supported,
4972 then the pragma will be ignored. See also @code{pragma Linker_Section}.
4974 @node Pragma Polling
4975 @unnumberedsec Pragma Polling
4980 @smallexample @c ada
4981 pragma Polling (ON | OFF);
4985 This pragma controls the generation of polling code. This is normally off.
4986 If @code{pragma Polling (ON)} is used then periodic calls are generated to
4987 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
4988 runtime library, and can be found in file @file{a-excpol.adb}.
4990 Pragma @code{Polling} can appear as a configuration pragma (for example it
4991 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
4992 can be used in the statement or declaration sequence to control polling
4995 A call to the polling routine is generated at the start of every loop and
4996 at the start of every subprogram call. This guarantees that the @code{Poll}
4997 routine is called frequently, and places an upper bound (determined by
4998 the complexity of the code) on the period between two @code{Poll} calls.
5000 The primary purpose of the polling interface is to enable asynchronous
5001 aborts on targets that cannot otherwise support it (for example Windows
5002 NT), but it may be used for any other purpose requiring periodic polling.
5003 The standard version is null, and can be replaced by a user program. This
5004 will require re-compilation of the @code{Ada.Exceptions} package that can
5005 be found in files @file{a-except.ads} and @file{a-except.adb}.
5007 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
5008 distribution) is used to enable the asynchronous abort capability on
5009 targets that do not normally support the capability. The version of
5010 @code{Poll} in this file makes a call to the appropriate runtime routine
5011 to test for an abort condition.
5013 Note that polling can also be enabled by use of the @option{-gnatP} switch.
5014 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
5017 @node Pragma Postcondition
5018 @unnumberedsec Pragma Postcondition
5019 @cindex Postcondition
5020 @cindex Checks, postconditions
5021 @findex Postconditions
5025 @smallexample @c ada
5026 pragma Postcondition (
5027 [Check =>] Boolean_Expression
5028 [,[Message =>] String_Expression]);
5032 The @code{Postcondition} pragma allows specification of automatic
5033 postcondition checks for subprograms. These checks are similar to
5034 assertions, but are automatically inserted just prior to the return
5035 statements of the subprogram with which they are associated (including
5036 implicit returns at the end of procedure bodies and associated
5037 exception handlers).
5039 In addition, the boolean expression which is the condition which
5040 must be true may contain references to function'Result in the case
5041 of a function to refer to the returned value.
5043 @code{Postcondition} pragmas may appear either immediately following the
5044 (separate) declaration of a subprogram, or at the start of the
5045 declarations of a subprogram body. Only other pragmas may intervene
5046 (that is appear between the subprogram declaration and its
5047 postconditions, or appear before the postcondition in the
5048 declaration sequence in a subprogram body). In the case of a
5049 postcondition appearing after a subprogram declaration, the
5050 formal arguments of the subprogram are visible, and can be
5051 referenced in the postcondition expressions.
5053 The postconditions are collected and automatically tested just
5054 before any return (implicit or explicit) in the subprogram body.
5055 A postcondition is only recognized if postconditions are active
5056 at the time the pragma is encountered. The compiler switch @option{gnata}
5057 turns on all postconditions by default, and pragma @code{Check_Policy}
5058 with an identifier of @code{Postcondition} can also be used to
5059 control whether postconditions are active.
5061 The general approach is that postconditions are placed in the spec
5062 if they represent functional aspects which make sense to the client.
5063 For example we might have:
5065 @smallexample @c ada
5066 function Direction return Integer;
5067 pragma Postcondition
5068 (Direction'Result = +1
5070 Direction'Result = -1);
5074 which serves to document that the result must be +1 or -1, and
5075 will test that this is the case at run time if postcondition
5078 Postconditions within the subprogram body can be used to
5079 check that some internal aspect of the implementation,
5080 not visible to the client, is operating as expected.
5081 For instance if a square root routine keeps an internal
5082 counter of the number of times it is called, then we
5083 might have the following postcondition:
5085 @smallexample @c ada
5086 Sqrt_Calls : Natural := 0;
5088 function Sqrt (Arg : Float) return Float is
5089 pragma Postcondition
5090 (Sqrt_Calls = Sqrt_Calls'Old + 1);
5096 As this example, shows, the use of the @code{Old} attribute
5097 is often useful in postconditions to refer to the state on
5098 entry to the subprogram.
5100 Note that postconditions are only checked on normal returns
5101 from the subprogram. If an abnormal return results from
5102 raising an exception, then the postconditions are not checked.
5104 If a postcondition fails, then the exception
5105 @code{System.Assertions.Assert_Failure} is raised. If
5106 a message argument was supplied, then the given string
5107 will be used as the exception message. If no message
5108 argument was supplied, then the default message has
5109 the form "Postcondition failed at file:line". The
5110 exception is raised in the context of the subprogram
5111 body, so it is possible to catch postcondition failures
5112 within the subprogram body itself.
5114 Within a package spec, normal visibility rules
5115 in Ada would prevent forward references within a
5116 postcondition pragma to functions defined later in
5117 the same package. This would introduce undesirable
5118 ordering constraints. To avoid this problem, all
5119 postcondition pragmas are analyzed at the end of
5120 the package spec, allowing forward references.
5122 The following example shows that this even allows
5123 mutually recursive postconditions as in:
5125 @smallexample @c ada
5126 package Parity_Functions is
5127 function Odd (X : Natural) return Boolean;
5128 pragma Postcondition
5132 (x /= 0 and then Even (X - 1))));
5134 function Even (X : Natural) return Boolean;
5135 pragma Postcondition
5139 (x /= 1 and then Odd (X - 1))));
5141 end Parity_Functions;
5145 There are no restrictions on the complexity or form of
5146 conditions used within @code{Postcondition} pragmas.
5147 The following example shows that it is even possible
5148 to verify performance behavior.
5150 @smallexample @c ada
5153 Performance : constant Float;
5154 -- Performance constant set by implementation
5155 -- to match target architecture behavior.
5157 procedure Treesort (Arg : String);
5158 -- Sorts characters of argument using N*logN sort
5159 pragma Postcondition
5160 (Float (Clock - Clock'Old) <=
5161 Float (Arg'Length) *
5162 log (Float (Arg'Length)) *
5168 Note: postcondition pragmas associated with subprograms that are
5169 marked as Inline_Always, or those marked as Inline with front-end
5170 inlining (-gnatN option set) are accepted and legality-checked
5171 by the compiler, but are ignored at run-time even if postcondition
5172 checking is enabled.
5174 @node Pragma Precondition
5175 @unnumberedsec Pragma Precondition
5176 @cindex Preconditions
5177 @cindex Checks, preconditions
5178 @findex Preconditions
5182 @smallexample @c ada
5183 pragma Precondition (
5184 [Check =>] Boolean_Expression
5185 [,[Message =>] String_Expression]);
5189 The @code{Precondition} pragma is similar to @code{Postcondition}
5190 except that the corresponding checks take place immediately upon
5191 entry to the subprogram, and if a precondition fails, the exception
5192 is raised in the context of the caller, and the attribute 'Result
5193 cannot be used within the precondition expression.
5195 Otherwise, the placement and visibility rules are identical to those
5196 described for postconditions. The following is an example of use
5197 within a package spec:
5199 @smallexample @c ada
5200 package Math_Functions is
5202 function Sqrt (Arg : Float) return Float;
5203 pragma Precondition (Arg >= 0.0)
5209 @code{Precondition} pragmas may appear either immediately following the
5210 (separate) declaration of a subprogram, or at the start of the
5211 declarations of a subprogram body. Only other pragmas may intervene
5212 (that is appear between the subprogram declaration and its
5213 postconditions, or appear before the postcondition in the
5214 declaration sequence in a subprogram body).
5216 Note: precondition pragmas associated with subprograms that are
5217 marked as Inline_Always, or those marked as Inline with front-end
5218 inlining (-gnatN option set) are accepted and legality-checked
5219 by the compiler, but are ignored at run-time even if precondition
5220 checking is enabled.
5222 @node Pragma Predicate
5223 @unnumberedsec Pragma Predicate
5225 @findex Predicate pragma
5229 @smallexample @c ada
5231 ([Entity =>] type_LOCAL_NAME,
5232 [Check =>] EXPRESSION);
5236 This pragma (available in all versions of Ada in GNAT) encompasses both
5237 the @code{Static_Predicate} and @code{Dynamic_Predicate} aspects in
5238 Ada 2012. A predicate is regarded as static if it has an allowed form
5239 for @code{Static_Predicate} and is otherwise treated as a
5240 @code{Dynamic_Predicate}. Otherwise, predicates specified by this
5241 pragma behave exactly as described in the Ada 2012 reference manual.
5242 For example, if we have
5244 @smallexample @c ada
5245 type R is range 1 .. 10;
5247 pragma Predicate (Entity => S, Check => S not in 4 .. 6);
5249 pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
5253 the effect is identical to the following Ada 2012 code:
5255 @smallexample @c ada
5256 type R is range 1 .. 10;
5258 Static_Predicate => S not in 4 .. 6;
5260 Dynamic_Predicate => F(Q) or G(Q);
5263 @node Pragma Preelaborable_Initialization
5264 @unnumberedsec Pragma Preelaborable_Initialization
5265 @findex Preelaborable_Initialization
5269 @smallexample @c ada
5270 pragma Preelaborable_Initialization (DIRECT_NAME);
5274 This pragma is standard in Ada 2005, but is available in all earlier
5275 versions of Ada as an implementation-defined pragma.
5276 See Ada 2012 Reference Manual for details.
5278 @node Pragma Preelaborate_05
5279 @unnumberedsec Pragma Preelaborate_05
5280 @findex Preelaborate_05
5284 @smallexample @c ada
5285 pragma Preelaborate_05 [(library_unit_NAME)];
5289 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5290 and is intended for use in the standard run-time library only. It has
5291 no effect in Ada 83 or Ada 95 mode, but is
5292 equivalent to @code{pragma Prelaborate} when operating in later
5293 Ada versions. This is used to handle some cases where packages
5294 not previously preelaborable became so in Ada 2005.
5296 @node Pragma Priority_Specific_Dispatching
5297 @unnumberedsec Pragma Priority_Specific_Dispatching
5298 @findex Priority_Specific_Dispatching
5302 @smallexample @c ada
5303 pragma Priority_Specific_Dispatching (
5305 first_priority_EXPRESSION,
5306 last_priority_EXPRESSION)
5308 POLICY_IDENTIFIER ::=
5309 EDF_Across_Priorities |
5310 FIFO_Within_Priorities |
5311 Non_Preemptive_Within_Priorities |
5312 Round_Robin_Within_Priorities
5316 This pragma is standard in Ada 2005, but is available in all earlier
5317 versions of Ada as an implementation-defined pragma.
5318 See Ada 2012 Reference Manual for details.
5320 @node Pragma Profile
5321 @unnumberedsec Pragma Profile
5326 @smallexample @c ada
5327 pragma Profile (Ravenscar | Restricted | Rational);
5331 This pragma is standard in Ada 2005, but is available in all earlier
5332 versions of Ada as an implementation-defined pragma. This is a
5333 configuration pragma that establishes a set of configiuration pragmas
5334 that depend on the argument. @code{Ravenscar} is standard in Ada 2005.
5335 The other two possibilities (@code{Restricted} or @code{Rational})
5336 are implementation-defined. The set of configuration pragmas
5337 is defined in the following sections.
5341 @item Pragma Profile (Ravenscar)
5345 The @code{Ravenscar} profile is standard in Ada 2005,
5346 but is available in all earlier
5347 versions of Ada as an implementation-defined pragma. This profile
5348 establishes the following set of configuration pragmas:
5351 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
5352 [RM D.2.2] Tasks are dispatched following a preemptive
5353 priority-ordered scheduling policy.
5355 @item Locking_Policy (Ceiling_Locking)
5356 [RM D.3] While tasks and interrupts execute a protected action, they inherit
5357 the ceiling priority of the corresponding protected object.
5359 @item Detect_Blocking
5360 This pragma forces the detection of potentially blocking operations within a
5361 protected operation, and to raise Program_Error if that happens.
5365 plus the following set of restrictions:
5368 @item Max_Entry_Queue_Length => 1
5369 No task can be queued on a protected entry.
5370 @item Max_Protected_Entries => 1
5371 @item Max_Task_Entries => 0
5372 No rendezvous statements are allowed.
5373 @item No_Abort_Statements
5374 @item No_Dynamic_Attachment
5375 @item No_Dynamic_Priorities
5376 @item No_Implicit_Heap_Allocations
5377 @item No_Local_Protected_Objects
5378 @item No_Local_Timing_Events
5379 @item No_Protected_Type_Allocators
5380 @item No_Relative_Delay
5381 @item No_Requeue_Statements
5382 @item No_Select_Statements
5383 @item No_Specific_Termination_Handlers
5384 @item No_Task_Allocators
5385 @item No_Task_Hierarchy
5386 @item No_Task_Termination
5387 @item Simple_Barriers
5391 The Ravenscar profile also includes the following restrictions that specify
5392 that there are no semantic dependences on the corresponding predefined
5396 @item No_Dependence => Ada.Asynchronous_Task_Control
5397 @item No_Dependence => Ada.Calendar
5398 @item No_Dependence => Ada.Execution_Time.Group_Budget
5399 @item No_Dependence => Ada.Execution_Time.Timers
5400 @item No_Dependence => Ada.Task_Attributes
5401 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
5406 This set of configuration pragmas and restrictions correspond to the
5407 definition of the ``Ravenscar Profile'' for limited tasking, devised and
5408 published by the @cite{International Real-Time Ada Workshop}, 1997,
5409 and whose most recent description is available at
5410 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
5412 The original definition of the profile was revised at subsequent IRTAW
5413 meetings. It has been included in the ISO
5414 @cite{Guide for the Use of the Ada Programming Language in High
5415 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
5416 the next revision of the standard. The formal definition given by
5417 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
5418 AI-305) available at
5419 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
5420 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
5422 The above set is a superset of the restrictions provided by pragma
5423 @code{Profile (Restricted)}, it includes six additional restrictions
5424 (@code{Simple_Barriers}, @code{No_Select_Statements},
5425 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
5426 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
5427 that pragma @code{Profile (Ravenscar)}, like the pragma
5428 @code{Profile (Restricted)},
5429 automatically causes the use of a simplified,
5430 more efficient version of the tasking run-time system.
5432 @item Pragma Profile (Restricted)
5433 @findex Restricted Run Time
5435 This profile corresponds to the GNAT restricted run time. It
5436 establishes the following set of restrictions:
5439 @item No_Abort_Statements
5440 @item No_Entry_Queue
5441 @item No_Task_Hierarchy
5442 @item No_Task_Allocators
5443 @item No_Dynamic_Priorities
5444 @item No_Terminate_Alternatives
5445 @item No_Dynamic_Attachment
5446 @item No_Protected_Type_Allocators
5447 @item No_Local_Protected_Objects
5448 @item No_Requeue_Statements
5449 @item No_Task_Attributes_Package
5450 @item Max_Asynchronous_Select_Nesting = 0
5451 @item Max_Task_Entries = 0
5452 @item Max_Protected_Entries = 1
5453 @item Max_Select_Alternatives = 0
5457 This set of restrictions causes the automatic selection of a simplified
5458 version of the run time that provides improved performance for the
5459 limited set of tasking functionality permitted by this set of restrictions.
5461 @item Pragma Profile (Rational)
5462 @findex Rational compatibility mode
5464 The Rational profile is intended to facilitate porting legacy code that
5465 compiles with the Rational APEX compiler, even when the code includes non-
5466 conforming Ada constructs. The profile enables the following three pragmas:
5469 @item pragma Implicit_Packing
5470 @item pragma Overriding_Renamings
5471 @item pragma Use_VADS_Size
5476 @node Pragma Profile_Warnings
5477 @unnumberedsec Pragma Profile_Warnings
5478 @findex Profile_Warnings
5482 @smallexample @c ada
5483 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
5487 This is an implementation-defined pragma that is similar in
5488 effect to @code{pragma Profile} except that instead of
5489 generating @code{Restrictions} pragmas, it generates
5490 @code{Restriction_Warnings} pragmas. The result is that
5491 violations of the profile generate warning messages instead
5494 @node Pragma Propagate_Exceptions
5495 @unnumberedsec Pragma Propagate_Exceptions
5496 @cindex Interfacing to C++
5497 @findex Propagate_Exceptions
5501 @smallexample @c ada
5502 pragma Propagate_Exceptions;
5506 This pragma is now obsolete and, other than generating a warning if warnings
5507 on obsolescent features are enabled, is ignored.
5508 It is retained for compatibility
5509 purposes. It used to be used in connection with optimization of
5510 a now-obsolete mechanism for implementation of exceptions.
5512 @node Pragma Psect_Object
5513 @unnumberedsec Pragma Psect_Object
5514 @findex Psect_Object
5518 @smallexample @c ada
5519 pragma Psect_Object (
5520 [Internal =>] LOCAL_NAME,
5521 [, [External =>] EXTERNAL_SYMBOL]
5522 [, [Size =>] EXTERNAL_SYMBOL]);
5526 | static_string_EXPRESSION
5530 This pragma is identical in effect to pragma @code{Common_Object}.
5532 @node Pragma Pure_05
5533 @unnumberedsec Pragma Pure_05
5538 @smallexample @c ada
5539 pragma Pure_05 [(library_unit_NAME)];
5543 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5544 and is intended for use in the standard run-time library only. It has
5545 no effect in Ada 83 or Ada 95 mode, but is
5546 equivalent to @code{pragma Pure} when operating in later
5547 Ada versions. This is used to handle some cases where packages
5548 not previously pure became so in Ada 2005.
5550 @node Pragma Pure_12
5551 @unnumberedsec Pragma Pure_12
5556 @smallexample @c ada
5557 pragma Pure_12 [(library_unit_NAME)];
5561 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5562 and is intended for use in the standard run-time library only. It has
5563 no effect in Ada 83, Ada 95, or Ada 2005 modes, but is
5564 equivalent to @code{pragma Pure} when operating in later
5565 Ada versions. This is used to handle some cases where packages
5566 not previously pure became so in Ada 2012.
5568 @node Pragma Pure_Function
5569 @unnumberedsec Pragma Pure_Function
5570 @findex Pure_Function
5574 @smallexample @c ada
5575 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
5579 This pragma appears in the same declarative part as a function
5580 declaration (or a set of function declarations if more than one
5581 overloaded declaration exists, in which case the pragma applies
5582 to all entities). It specifies that the function @code{Entity} is
5583 to be considered pure for the purposes of code generation. This means
5584 that the compiler can assume that there are no side effects, and
5585 in particular that two calls with identical arguments produce the
5586 same result. It also means that the function can be used in an
5589 Note that, quite deliberately, there are no static checks to try
5590 to ensure that this promise is met, so @code{Pure_Function} can be used
5591 with functions that are conceptually pure, even if they do modify
5592 global variables. For example, a square root function that is
5593 instrumented to count the number of times it is called is still
5594 conceptually pure, and can still be optimized, even though it
5595 modifies a global variable (the count). Memo functions are another
5596 example (where a table of previous calls is kept and consulted to
5597 avoid re-computation).
5599 Note also that the normal rules excluding optimization of subprograms
5600 in pure units (when parameter types are descended from System.Address,
5601 or when the full view of a parameter type is limited), do not apply
5602 for the Pure_Function case. If you explicitly specify Pure_Function,
5603 the compiler may optimize away calls with identical arguments, and
5604 if that results in unexpected behavior, the proper action is not to
5605 use the pragma for subprograms that are not (conceptually) pure.
5608 Note: Most functions in a @code{Pure} package are automatically pure, and
5609 there is no need to use pragma @code{Pure_Function} for such functions. One
5610 exception is any function that has at least one formal of type
5611 @code{System.Address} or a type derived from it. Such functions are not
5612 considered pure by default, since the compiler assumes that the
5613 @code{Address} parameter may be functioning as a pointer and that the
5614 referenced data may change even if the address value does not.
5615 Similarly, imported functions are not considered to be pure by default,
5616 since there is no way of checking that they are in fact pure. The use
5617 of pragma @code{Pure_Function} for such a function will override these default
5618 assumption, and cause the compiler to treat a designated subprogram as pure
5621 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
5622 applies to the underlying renamed function. This can be used to
5623 disambiguate cases of overloading where some but not all functions
5624 in a set of overloaded functions are to be designated as pure.
5626 If pragma @code{Pure_Function} is applied to a library level function, the
5627 function is also considered pure from an optimization point of view, but the
5628 unit is not a Pure unit in the categorization sense. So for example, a function
5629 thus marked is free to @code{with} non-pure units.
5631 @node Pragma Ravenscar
5632 @unnumberedsec Pragma Ravenscar
5633 @findex Pragma Ravenscar
5637 @smallexample @c ada
5642 This pragma is considered obsolescent, but is retained for
5643 compatibility purposes. It is equivalent to:
5645 @smallexample @c ada
5646 pragma Profile (Ravenscar);
5650 which is the preferred method of setting the @code{Ravenscar} profile.
5652 @node Pragma Relative_Deadline
5653 @unnumberedsec Pragma Relative_Deadline
5654 @findex Relative_Deadline
5658 @smallexample @c ada
5659 pragma Relative_Deadline (time_span_EXPRESSSION);
5663 This pragma is standard in Ada 2005, but is available in all earlier
5664 versions of Ada as an implementation-defined pragma.
5665 See Ada 2012 Reference Manual for details.
5667 @node Pragma Remote_Access_Type
5668 @unnumberedsec Pragma Remote_Access_Type
5669 @findex Remote_Access_Type
5673 @smallexample @c ada
5674 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
5678 This pragma appears in the formal part of a generic declaration.
5679 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
5680 the use of a remote access to class-wide type as actual for a formal
5683 When this pragma applies to a formal access type @code{Entity}, that
5684 type is treated as a remote access to class-wide type in the generic.
5685 It must be a formal general access type, and its designated type must
5686 be the class-wide type of a formal tagged limited private type from the
5687 same generic declaration.
5689 In the generic unit, the formal type is subject to all restrictions
5690 pertaining to remote access to class-wide types. At instantiation, the
5691 actual type must be a remote access to class-wide type.
5693 @node Pragma Restricted_Run_Time
5694 @unnumberedsec Pragma Restricted_Run_Time
5695 @findex Pragma Restricted_Run_Time
5699 @smallexample @c ada
5700 pragma Restricted_Run_Time;
5704 This pragma is considered obsolescent, but is retained for
5705 compatibility purposes. It is equivalent to:
5707 @smallexample @c ada
5708 pragma Profile (Restricted);
5712 which is the preferred method of setting the restricted run time
5715 @node Pragma Restriction_Warnings
5716 @unnumberedsec Pragma Restriction_Warnings
5717 @findex Restriction_Warnings
5721 @smallexample @c ada
5722 pragma Restriction_Warnings
5723 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
5727 This pragma allows a series of restriction identifiers to be
5728 specified (the list of allowed identifiers is the same as for
5729 pragma @code{Restrictions}). For each of these identifiers
5730 the compiler checks for violations of the restriction, but
5731 generates a warning message rather than an error message
5732 if the restriction is violated.
5734 @node Pragma Share_Generic
5735 @unnumberedsec Pragma Share_Generic
5736 @findex Share_Generic
5740 @smallexample @c ada
5741 pragma Share_Generic (GNAME @{, GNAME@});
5743 GNAME ::= generic_unit_NAME | generic_instance_NAME
5747 This pragma is provided for compatibility with Dec Ada 83. It has
5748 no effect in @code{GNAT} (which does not implement shared generics), other
5749 than to check that the given names are all names of generic units or
5753 @unnumberedsec Pragma Shared
5757 This pragma is provided for compatibility with Ada 83. The syntax and
5758 semantics are identical to pragma Atomic.
5760 @node Pragma Short_Circuit_And_Or
5761 @unnumberedsec Pragma Short_Circuit_And_Or
5762 @findex Short_Circuit_And_Or
5766 @smallexample @c ada
5767 pragma Short_Circuit_And_Or;
5771 This configuration pragma causes any occurrence of the AND operator applied to
5772 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
5773 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
5774 may be useful in the context of certification protocols requiring the use of
5775 short-circuited logical operators. If this configuration pragma occurs locally
5776 within the file being compiled, it applies only to the file being compiled.
5777 There is no requirement that all units in a partition use this option.
5779 @node Pragma Short_Descriptors
5780 @unnumberedsec Pragma Short_Descriptors
5781 @findex Short_Descriptors
5785 @smallexample @c ada
5786 pragma Short_Descriptors
5790 In VMS versions of the compiler, this configuration pragma causes all
5791 occurrences of the mechanism types Descriptor[_xxx] to be treated as
5792 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
5793 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
5796 @node Pragma Simple_Storage_Pool_Type
5797 @unnumberedsec Pragma Simple_Storage_Pool_Type
5798 @findex Simple_Storage_Pool_Type
5799 @cindex Storage pool, simple
5800 @cindex Simple storage pool
5804 @smallexample @c ada
5805 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
5809 A type can be established as a ``simple storage pool type'' by applying
5810 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
5811 A type named in the pragma must be a library-level immutably limited record
5812 type or limited tagged type declared immediately within a package declaration.
5813 The type can also be a limited private type whose full type is allowed as
5814 a simple storage pool type.
5816 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
5817 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
5818 are subtype conformant with the following subprogram declarations:
5820 @smallexample @c ada
5823 Storage_Address : out System.Address;
5824 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5825 Alignment : System.Storage_Elements.Storage_Count);
5827 procedure Deallocate
5829 Storage_Address : System.Address;
5830 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5831 Alignment : System.Storage_Elements.Storage_Count);
5833 function Storage_Size (Pool : SSP)
5834 return System.Storage_Elements.Storage_Count;
5838 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
5839 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
5840 applying an unchecked deallocation has no effect other than to set its actual
5841 parameter to null. If @code{Storage_Size} is not declared, then the
5842 @code{Storage_Size} attribute applied to an access type associated with
5843 a pool object of type SSP returns zero. Additional operations can be declared
5844 for a simple storage pool type (such as for supporting a mark/release
5845 storage-management discipline).
5847 An object of a simple storage pool type can be associated with an access
5848 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
5850 @smallexample @c ada
5852 My_Pool : My_Simple_Storage_Pool_Type;
5854 type Acc is access My_Data_Type;
5856 for Acc'Simple_Storage_Pool use My_Pool;
5861 See attribute @code{Simple_Storage_Pool} for further details.
5863 @node Pragma Source_File_Name
5864 @unnumberedsec Pragma Source_File_Name
5865 @findex Source_File_Name
5869 @smallexample @c ada
5870 pragma Source_File_Name (
5871 [Unit_Name =>] unit_NAME,
5872 Spec_File_Name => STRING_LITERAL,
5873 [Index => INTEGER_LITERAL]);
5875 pragma Source_File_Name (
5876 [Unit_Name =>] unit_NAME,
5877 Body_File_Name => STRING_LITERAL,
5878 [Index => INTEGER_LITERAL]);
5882 Use this to override the normal naming convention. It is a configuration
5883 pragma, and so has the usual applicability of configuration pragmas
5884 (i.e.@: it applies to either an entire partition, or to all units in a
5885 compilation, or to a single unit, depending on how it is used.
5886 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
5887 the second argument is required, and indicates whether this is the file
5888 name for the spec or for the body.
5890 The optional Index argument should be used when a file contains multiple
5891 units, and when you do not want to use @code{gnatchop} to separate then
5892 into multiple files (which is the recommended procedure to limit the
5893 number of recompilations that are needed when some sources change).
5894 For instance, if the source file @file{source.ada} contains
5896 @smallexample @c ada
5908 you could use the following configuration pragmas:
5910 @smallexample @c ada
5911 pragma Source_File_Name
5912 (B, Spec_File_Name => "source.ada", Index => 1);
5913 pragma Source_File_Name
5914 (A, Body_File_Name => "source.ada", Index => 2);
5917 Note that the @code{gnatname} utility can also be used to generate those
5918 configuration pragmas.
5920 Another form of the @code{Source_File_Name} pragma allows
5921 the specification of patterns defining alternative file naming schemes
5922 to apply to all files.
5924 @smallexample @c ada
5925 pragma Source_File_Name
5926 ( [Spec_File_Name =>] STRING_LITERAL
5927 [,[Casing =>] CASING_SPEC]
5928 [,[Dot_Replacement =>] STRING_LITERAL]);
5930 pragma Source_File_Name
5931 ( [Body_File_Name =>] STRING_LITERAL
5932 [,[Casing =>] CASING_SPEC]
5933 [,[Dot_Replacement =>] STRING_LITERAL]);
5935 pragma Source_File_Name
5936 ( [Subunit_File_Name =>] STRING_LITERAL
5937 [,[Casing =>] CASING_SPEC]
5938 [,[Dot_Replacement =>] STRING_LITERAL]);
5940 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
5944 The first argument is a pattern that contains a single asterisk indicating
5945 the point at which the unit name is to be inserted in the pattern string
5946 to form the file name. The second argument is optional. If present it
5947 specifies the casing of the unit name in the resulting file name string.
5948 The default is lower case. Finally the third argument allows for systematic
5949 replacement of any dots in the unit name by the specified string literal.
5951 Note that Source_File_Name pragmas should not be used if you are using
5952 project files. The reason for this rule is that the project manager is not
5953 aware of these pragmas, and so other tools that use the projet file would not
5954 be aware of the intended naming conventions. If you are using project files,
5955 file naming is controlled by Source_File_Name_Project pragmas, which are
5956 usually supplied automatically by the project manager. A pragma
5957 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
5959 For more details on the use of the @code{Source_File_Name} pragma,
5960 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
5961 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
5964 @node Pragma Source_File_Name_Project
5965 @unnumberedsec Pragma Source_File_Name_Project
5966 @findex Source_File_Name_Project
5969 This pragma has the same syntax and semantics as pragma Source_File_Name.
5970 It is only allowed as a stand alone configuration pragma.
5971 It cannot appear after a @ref{Pragma Source_File_Name}, and
5972 most importantly, once pragma Source_File_Name_Project appears,
5973 no further Source_File_Name pragmas are allowed.
5975 The intention is that Source_File_Name_Project pragmas are always
5976 generated by the Project Manager in a manner consistent with the naming
5977 specified in a project file, and when naming is controlled in this manner,
5978 it is not permissible to attempt to modify this naming scheme using
5979 Source_File_Name or Source_File_Name_Project pragmas (which would not be
5980 known to the project manager).
5982 @node Pragma Source_Reference
5983 @unnumberedsec Pragma Source_Reference
5984 @findex Source_Reference
5988 @smallexample @c ada
5989 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
5993 This pragma must appear as the first line of a source file.
5994 @var{integer_literal} is the logical line number of the line following
5995 the pragma line (for use in error messages and debugging
5996 information). @var{string_literal} is a static string constant that
5997 specifies the file name to be used in error messages and debugging
5998 information. This is most notably used for the output of @code{gnatchop}
5999 with the @option{-r} switch, to make sure that the original unchopped
6000 source file is the one referred to.
6002 The second argument must be a string literal, it cannot be a static
6003 string expression other than a string literal. This is because its value
6004 is needed for error messages issued by all phases of the compiler.
6006 @node Pragma SPARK_Mode
6007 @unnumberedsec Pragma SPARK_Mode
6012 @smallexample @c ada
6013 pragma SPARK_Mode [ (On | Off | Auto) ] ;
6017 This pragma is used to designate whether a contract and its implementation must
6018 follow the SPARK 2014 programming language syntactic and semantic rules. The
6019 pragma is intended for use with formal verification tools and has no effect on
6022 When used as a configuration pragma over a whole compilation or in a particular
6023 compilation unit, it sets the mode of the units involved, in particular:
6028 @code{On}: All entities in the units must follow the SPARK 2014 language, and
6029 an error will be generated if not, unless locally overridden by a local
6030 SPARK_Mode pragma or aspect. @code{On} is the default mode when pragma
6031 SPARK_Mode is used without an argument.
6034 @code{Off}: The units are considered to be in Ada by default and therefore not
6035 part of SPARK 2014 unless overridden locally. These units may be called by
6039 @code{Auto}: The formal verification tools will automatically detect whether
6040 each entity is in SPARK 2014 or in Ada.
6044 Pragma SPARK_Mode can be used as a local pragma with the following semantics:
6049 Auto cannot be used as a mode argument.
6052 When the pragma at the start of the visible declarations (preceded only
6053 by other pragmas) of a package declaration, it marks the whole package
6054 (declaration and body) in or out of SPARK 2014.
6057 When the pragma appears at the start of the private declarations of a
6058 package (only other pragmas can appear between the @code{private} keyword
6059 and the @code{SPARK_Mode} pragma), it marks the private part in or
6060 out of SPARK 2014 (overriding the default mode of the visible part).
6063 When the pragma appears immediately at the start of the declarations of a
6064 package body (preceded only by other pragmas),
6065 it marks the whole body in or out of SPARK 2014 (overriding the default
6066 mode set by the declaration).
6069 When the pragma appears at the start of the elaboration statements of
6070 a package body (only other pragmas can appear between the @code{begin}
6071 keyword and the @code{SPARK_Mode} pragma),
6072 it marks the elaboration statements in or out of SPARK 2014 (overriding
6073 the default mode of the package body).
6076 When the pragma appears after a subprogram declaration (with only other
6077 pragmas intervening), it marks the whole
6078 subprogram (spec and body) in or out of SPARK 2014.
6081 When the pragma appears at the start of the declarations of a subprogram
6082 body (preceded only by other pragmas), it marks the whole body in or out
6083 of SPARK 2014 (overriding the default mode set by the declaration).
6086 Any other use of the pragma is illegal.
6090 @node Pragma Static_Elaboration_Desired
6091 @unnumberedsec Pragma Static_Elaboration_Desired
6092 @findex Static_Elaboration_Desired
6096 @smallexample @c ada
6097 pragma Static_Elaboration_Desired;
6101 This pragma is used to indicate that the compiler should attempt to initialize
6102 statically the objects declared in the library unit to which the pragma applies,
6103 when these objects are initialized (explicitly or implicitly) by an aggregate.
6104 In the absence of this pragma, aggregates in object declarations are expanded
6105 into assignments and loops, even when the aggregate components are static
6106 constants. When the aggregate is present the compiler builds a static expression
6107 that requires no run-time code, so that the initialized object can be placed in
6108 read-only data space. If the components are not static, or the aggregate has
6109 more that 100 components, the compiler emits a warning that the pragma cannot
6110 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
6111 construction of larger aggregates with static components that include an others
6114 @node Pragma Stream_Convert
6115 @unnumberedsec Pragma Stream_Convert
6116 @findex Stream_Convert
6120 @smallexample @c ada
6121 pragma Stream_Convert (
6122 [Entity =>] type_LOCAL_NAME,
6123 [Read =>] function_NAME,
6124 [Write =>] function_NAME);
6128 This pragma provides an efficient way of providing stream functions for
6129 types defined in packages. Not only is it simpler to use than declaring
6130 the necessary functions with attribute representation clauses, but more
6131 significantly, it allows the declaration to made in such a way that the
6132 stream packages are not loaded unless they are needed. The use of
6133 the Stream_Convert pragma adds no overhead at all, unless the stream
6134 attributes are actually used on the designated type.
6136 The first argument specifies the type for which stream functions are
6137 provided. The second parameter provides a function used to read values
6138 of this type. It must name a function whose argument type may be any
6139 subtype, and whose returned type must be the type given as the first
6140 argument to the pragma.
6142 The meaning of the @var{Read} parameter is that if a stream attribute directly
6143 or indirectly specifies reading of the type given as the first parameter,
6144 then a value of the type given as the argument to the Read function is
6145 read from the stream, and then the Read function is used to convert this
6146 to the required target type.
6148 Similarly the @var{Write} parameter specifies how to treat write attributes
6149 that directly or indirectly apply to the type given as the first parameter.
6150 It must have an input parameter of the type specified by the first parameter,
6151 and the return type must be the same as the input type of the Read function.
6152 The effect is to first call the Write function to convert to the given stream
6153 type, and then write the result type to the stream.
6155 The Read and Write functions must not be overloaded subprograms. If necessary
6156 renamings can be supplied to meet this requirement.
6157 The usage of this attribute is best illustrated by a simple example, taken
6158 from the GNAT implementation of package Ada.Strings.Unbounded:
6160 @smallexample @c ada
6161 function To_Unbounded (S : String)
6162 return Unbounded_String
6163 renames To_Unbounded_String;
6165 pragma Stream_Convert
6166 (Unbounded_String, To_Unbounded, To_String);
6170 The specifications of the referenced functions, as given in the Ada
6171 Reference Manual are:
6173 @smallexample @c ada
6174 function To_Unbounded_String (Source : String)
6175 return Unbounded_String;
6177 function To_String (Source : Unbounded_String)
6182 The effect is that if the value of an unbounded string is written to a stream,
6183 then the representation of the item in the stream is in the same format that
6184 would be used for @code{Standard.String'Output}, and this same representation
6185 is expected when a value of this type is read from the stream. Note that the
6186 value written always includes the bounds, even for Unbounded_String'Write,
6187 since Unbounded_String is not an array type.
6189 @node Pragma Style_Checks
6190 @unnumberedsec Pragma Style_Checks
6191 @findex Style_Checks
6195 @smallexample @c ada
6196 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
6197 On | Off [, LOCAL_NAME]);
6201 This pragma is used in conjunction with compiler switches to control the
6202 built in style checking provided by GNAT@. The compiler switches, if set,
6203 provide an initial setting for the switches, and this pragma may be used
6204 to modify these settings, or the settings may be provided entirely by
6205 the use of the pragma. This pragma can be used anywhere that a pragma
6206 is legal, including use as a configuration pragma (including use in
6207 the @file{gnat.adc} file).
6209 The form with a string literal specifies which style options are to be
6210 activated. These are additive, so they apply in addition to any previously
6211 set style check options. The codes for the options are the same as those
6212 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
6213 For example the following two methods can be used to enable
6218 @smallexample @c ada
6219 pragma Style_Checks ("l");
6224 gcc -c -gnatyl @dots{}
6229 The form ALL_CHECKS activates all standard checks (its use is equivalent
6230 to the use of the @code{gnaty} switch with no options. @xref{Top,
6231 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
6232 @value{EDITION} User's Guide}, for details.)
6234 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
6235 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
6236 options (i.e. equivalent to -gnatyg).
6238 The forms with @code{Off} and @code{On}
6239 can be used to temporarily disable style checks
6240 as shown in the following example:
6242 @smallexample @c ada
6246 pragma Style_Checks ("k"); -- requires keywords in lower case
6247 pragma Style_Checks (Off); -- turn off style checks
6248 NULL; -- this will not generate an error message
6249 pragma Style_Checks (On); -- turn style checks back on
6250 NULL; -- this will generate an error message
6254 Finally the two argument form is allowed only if the first argument is
6255 @code{On} or @code{Off}. The effect is to turn of semantic style checks
6256 for the specified entity, as shown in the following example:
6258 @smallexample @c ada
6262 pragma Style_Checks ("r"); -- require consistency of identifier casing
6264 Rf1 : Integer := ARG; -- incorrect, wrong case
6265 pragma Style_Checks (Off, Arg);
6266 Rf2 : Integer := ARG; -- OK, no error
6269 @node Pragma Subtitle
6270 @unnumberedsec Pragma Subtitle
6275 @smallexample @c ada
6276 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
6280 This pragma is recognized for compatibility with other Ada compilers
6281 but is ignored by GNAT@.
6283 @node Pragma Suppress
6284 @unnumberedsec Pragma Suppress
6289 @smallexample @c ada
6290 pragma Suppress (Identifier [, [On =>] Name]);
6294 This is a standard pragma, and supports all the check names required in
6295 the RM. It is included here because GNAT recognizes some additional check
6296 names that are implementation defined (as permitted by the RM):
6301 @code{Alignment_Check} can be used to suppress alignment checks
6302 on addresses used in address clauses. Such checks can also be suppressed
6303 by suppressing range checks, but the specific use of @code{Alignment_Check}
6304 allows suppression of alignment checks without suppressing other range checks.
6307 @code{Predicate_Check} can be used to control whether predicate checks are
6308 active. It is applicable only to predicates for which the policy is
6309 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
6310 predicate is ignored or checked for the whole program, the use of
6311 @code{Suppress} and @code{Unsuppress} with this check name allows a given
6312 predicate to be turned on and off at specific points in the program.
6315 @code{Validity_Check} can be used specifically to control validity checks.
6316 If @code{Suppress} is used to suppress validity checks, then no validity
6317 checks are performed, including those specified by the appropriate compiler
6318 switch or the @code{Validity_Checks} pragma.
6321 Additional check names previously introduced by use of the @code{Check_Name}
6322 pragma are also allowed.
6327 Note that pragma Suppress gives the compiler permission to omit
6328 checks, but does not require the compiler to omit checks. The compiler
6329 will generate checks if they are essentially free, even when they are
6330 suppressed. In particular, if the compiler can prove that a certain
6331 check will necessarily fail, it will generate code to do an
6332 unconditional ``raise'', even if checks are suppressed. The compiler
6335 Of course, run-time checks are omitted whenever the compiler can prove
6336 that they will not fail, whether or not checks are suppressed.
6338 @node Pragma Suppress_All
6339 @unnumberedsec Pragma Suppress_All
6340 @findex Suppress_All
6344 @smallexample @c ada
6345 pragma Suppress_All;
6349 This pragma can appear anywhere within a unit.
6350 The effect is to apply @code{Suppress (All_Checks)} to the unit
6351 in which it appears. This pragma is implemented for compatibility with DEC
6352 Ada 83 usage where it appears at the end of a unit, and for compatibility
6353 with Rational Ada, where it appears as a program unit pragma.
6354 The use of the standard Ada pragma @code{Suppress (All_Checks)}
6355 as a normal configuration pragma is the preferred usage in GNAT@.
6357 @node Pragma Suppress_Debug_Info
6358 @unnumberedsec Pragma Suppress_Debug_Info
6359 @findex Suppress_Debug_Info
6363 @smallexample @c ada
6364 Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
6368 This pragma can be used to suppress generation of debug information
6369 for the specified entity. It is intended primarily for use in debugging
6370 the debugger, and navigating around debugger problems.
6372 @node Pragma Suppress_Exception_Locations
6373 @unnumberedsec Pragma Suppress_Exception_Locations
6374 @findex Suppress_Exception_Locations
6378 @smallexample @c ada
6379 pragma Suppress_Exception_Locations;
6383 In normal mode, a raise statement for an exception by default generates
6384 an exception message giving the file name and line number for the location
6385 of the raise. This is useful for debugging and logging purposes, but this
6386 entails extra space for the strings for the messages. The configuration
6387 pragma @code{Suppress_Exception_Locations} can be used to suppress the
6388 generation of these strings, with the result that space is saved, but the
6389 exception message for such raises is null. This configuration pragma may
6390 appear in a global configuration pragma file, or in a specific unit as
6391 usual. It is not required that this pragma be used consistently within
6392 a partition, so it is fine to have some units within a partition compiled
6393 with this pragma and others compiled in normal mode without it.
6395 @node Pragma Suppress_Initialization
6396 @unnumberedsec Pragma Suppress_Initialization
6397 @findex Suppress_Initialization
6398 @cindex Suppressing initialization
6399 @cindex Initialization, suppression of
6403 @smallexample @c ada
6404 pragma Suppress_Initialization ([Entity =>] subtype_Name);
6408 Here subtype_Name is the name introduced by a type declaration
6409 or subtype declaration.
6410 This pragma suppresses any implicit or explicit initialization
6411 for all variables of the given type or subtype,
6412 including initialization resulting from the use of pragmas
6413 Normalize_Scalars or Initialize_Scalars.
6415 This is considered a representation item, so it cannot be given after
6416 the type is frozen. It applies to all subsequent object declarations,
6417 and also any allocator that creates objects of the type.
6419 If the pragma is given for the first subtype, then it is considered
6420 to apply to the base type and all its subtypes. If the pragma is given
6421 for other than a first subtype, then it applies only to the given subtype.
6422 The pragma may not be given after the type is frozen.
6424 @node Pragma Task_Info
6425 @unnumberedsec Pragma Task_Info
6430 @smallexample @c ada
6431 pragma Task_Info (EXPRESSION);
6435 This pragma appears within a task definition (like pragma
6436 @code{Priority}) and applies to the task in which it appears. The
6437 argument must be of type @code{System.Task_Info.Task_Info_Type}.
6438 The @code{Task_Info} pragma provides system dependent control over
6439 aspects of tasking implementation, for example, the ability to map
6440 tasks to specific processors. For details on the facilities available
6441 for the version of GNAT that you are using, see the documentation
6442 in the spec of package System.Task_Info in the runtime
6445 @node Pragma Task_Name
6446 @unnumberedsec Pragma Task_Name
6451 @smallexample @c ada
6452 pragma Task_Name (string_EXPRESSION);
6456 This pragma appears within a task definition (like pragma
6457 @code{Priority}) and applies to the task in which it appears. The
6458 argument must be of type String, and provides a name to be used for
6459 the task instance when the task is created. Note that this expression
6460 is not required to be static, and in particular, it can contain
6461 references to task discriminants. This facility can be used to
6462 provide different names for different tasks as they are created,
6463 as illustrated in the example below.
6465 The task name is recorded internally in the run-time structures
6466 and is accessible to tools like the debugger. In addition the
6467 routine @code{Ada.Task_Identification.Image} will return this
6468 string, with a unique task address appended.
6470 @smallexample @c ada
6471 -- Example of the use of pragma Task_Name
6473 with Ada.Task_Identification;
6474 use Ada.Task_Identification;
6475 with Text_IO; use Text_IO;
6478 type Astring is access String;
6480 task type Task_Typ (Name : access String) is
6481 pragma Task_Name (Name.all);
6484 task body Task_Typ is
6485 Nam : constant String := Image (Current_Task);
6487 Put_Line ("-->" & Nam (1 .. 14) & "<--");
6490 type Ptr_Task is access Task_Typ;
6491 Task_Var : Ptr_Task;
6495 new Task_Typ (new String'("This is task 1"));
6497 new Task_Typ (new String'("This is task 2"));
6501 @node Pragma Task_Storage
6502 @unnumberedsec Pragma Task_Storage
6503 @findex Task_Storage
6506 @smallexample @c ada
6507 pragma Task_Storage (
6508 [Task_Type =>] LOCAL_NAME,
6509 [Top_Guard =>] static_integer_EXPRESSION);
6513 This pragma specifies the length of the guard area for tasks. The guard
6514 area is an additional storage area allocated to a task. A value of zero
6515 means that either no guard area is created or a minimal guard area is
6516 created, depending on the target. This pragma can appear anywhere a
6517 @code{Storage_Size} attribute definition clause is allowed for a task
6520 @node Pragma Test_Case
6521 @unnumberedsec Pragma Test_Case
6527 @smallexample @c ada
6529 [Name =>] static_string_Expression
6530 ,[Mode =>] (Nominal | Robustness)
6531 [, Requires => Boolean_Expression]
6532 [, Ensures => Boolean_Expression]);
6536 The @code{Test_Case} pragma allows defining fine-grain specifications
6537 for use by testing tools.
6538 The compiler checks the validity of the @code{Test_Case} pragma, but its
6539 presence does not lead to any modification of the code generated by the
6542 @code{Test_Case} pragmas may only appear immediately following the
6543 (separate) declaration of a subprogram in a package declaration, inside
6544 a package spec unit. Only other pragmas may intervene (that is appear
6545 between the subprogram declaration and a test case).
6547 The compiler checks that boolean expressions given in @code{Requires} and
6548 @code{Ensures} are valid, where the rules for @code{Requires} are the
6549 same as the rule for an expression in @code{Precondition} and the rules
6550 for @code{Ensures} are the same as the rule for an expression in
6551 @code{Postcondition}. In particular, attributes @code{'Old} and
6552 @code{'Result} can only be used within the @code{Ensures}
6553 expression. The following is an example of use within a package spec:
6555 @smallexample @c ada
6556 package Math_Functions is
6558 function Sqrt (Arg : Float) return Float;
6559 pragma Test_Case (Name => "Test 1",
6561 Requires => Arg < 10000,
6562 Ensures => Sqrt'Result < 10);
6568 The meaning of a test case is that there is at least one context where
6569 @code{Requires} holds such that, if the associated subprogram is executed in
6570 that context, then @code{Ensures} holds when the subprogram returns.
6571 Mode @code{Nominal} indicates that the input context should also satisfy the
6572 precondition of the subprogram, and the output context should also satisfy its
6573 postcondition. More @code{Robustness} indicates that the precondition and
6574 postcondition of the subprogram should be ignored for this test case.
6576 @node Pragma Thread_Local_Storage
6577 @unnumberedsec Pragma Thread_Local_Storage
6578 @findex Thread_Local_Storage
6579 @cindex Task specific storage
6580 @cindex TLS (Thread Local Storage)
6581 @cindex Task_Attributes
6584 @smallexample @c ada
6585 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
6589 This pragma specifies that the specified entity, which must be
6590 a variable declared in a library level package, is to be marked as
6591 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
6592 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
6593 (and hence each Ada task) to see a distinct copy of the variable.
6595 The variable may not have default initialization, and if there is
6596 an explicit initialization, it must be either @code{null} for an
6597 access variable, or a static expression for a scalar variable.
6598 This provides a low level mechanism similar to that provided by
6599 the @code{Ada.Task_Attributes} package, but much more efficient
6600 and is also useful in writing interface code that will interact
6601 with foreign threads.
6603 If this pragma is used on a system where @code{TLS} is not supported,
6604 then an error message will be generated and the program will be rejected.
6606 @node Pragma Time_Slice
6607 @unnumberedsec Pragma Time_Slice
6612 @smallexample @c ada
6613 pragma Time_Slice (static_duration_EXPRESSION);
6617 For implementations of GNAT on operating systems where it is possible
6618 to supply a time slice value, this pragma may be used for this purpose.
6619 It is ignored if it is used in a system that does not allow this control,
6620 or if it appears in other than the main program unit.
6622 Note that the effect of this pragma is identical to the effect of the
6623 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
6626 @unnumberedsec Pragma Title
6631 @smallexample @c ada
6632 pragma Title (TITLING_OPTION [, TITLING OPTION]);
6635 [Title =>] STRING_LITERAL,
6636 | [Subtitle =>] STRING_LITERAL
6640 Syntax checked but otherwise ignored by GNAT@. This is a listing control
6641 pragma used in DEC Ada 83 implementations to provide a title and/or
6642 subtitle for the program listing. The program listing generated by GNAT
6643 does not have titles or subtitles.
6645 Unlike other pragmas, the full flexibility of named notation is allowed
6646 for this pragma, i.e.@: the parameters may be given in any order if named
6647 notation is used, and named and positional notation can be mixed
6648 following the normal rules for procedure calls in Ada.
6650 @node Pragma Unchecked_Union
6651 @unnumberedsec Pragma Unchecked_Union
6653 @findex Unchecked_Union
6657 @smallexample @c ada
6658 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
6662 This pragma is used to specify a representation of a record type that is
6663 equivalent to a C union. It was introduced as a GNAT implementation defined
6664 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
6665 pragma, making it language defined, and GNAT fully implements this extended
6666 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
6667 details, consult the Ada 2012 Reference Manual, section B.3.3.
6669 @node Pragma Unimplemented_Unit
6670 @unnumberedsec Pragma Unimplemented_Unit
6671 @findex Unimplemented_Unit
6675 @smallexample @c ada
6676 pragma Unimplemented_Unit;
6680 If this pragma occurs in a unit that is processed by the compiler, GNAT
6681 aborts with the message @samp{@var{xxx} not implemented}, where
6682 @var{xxx} is the name of the current compilation unit. This pragma is
6683 intended to allow the compiler to handle unimplemented library units in
6686 The abort only happens if code is being generated. Thus you can use
6687 specs of unimplemented packages in syntax or semantic checking mode.
6689 @node Pragma Universal_Aliasing
6690 @unnumberedsec Pragma Universal_Aliasing
6691 @findex Universal_Aliasing
6695 @smallexample @c ada
6696 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
6700 @var{type_LOCAL_NAME} must refer to a type declaration in the current
6701 declarative part. The effect is to inhibit strict type-based aliasing
6702 optimization for the given type. In other words, the effect is as though
6703 access types designating this type were subject to pragma No_Strict_Aliasing.
6704 For a detailed description of the strict aliasing optimization, and the
6705 situations in which it must be suppressed, @xref{Optimization and Strict
6706 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
6708 @node Pragma Universal_Data
6709 @unnumberedsec Pragma Universal_Data
6710 @findex Universal_Data
6714 @smallexample @c ada
6715 pragma Universal_Data [(library_unit_Name)];
6719 This pragma is supported only for the AAMP target and is ignored for
6720 other targets. The pragma specifies that all library-level objects
6721 (Counter 0 data) associated with the library unit are to be accessed
6722 and updated using universal addressing (24-bit addresses for AAMP5)
6723 rather than the default of 16-bit Data Environment (DENV) addressing.
6724 Use of this pragma will generally result in less efficient code for
6725 references to global data associated with the library unit, but
6726 allows such data to be located anywhere in memory. This pragma is
6727 a library unit pragma, but can also be used as a configuration pragma
6728 (including use in the @file{gnat.adc} file). The functionality
6729 of this pragma is also available by applying the -univ switch on the
6730 compilations of units where universal addressing of the data is desired.
6732 @node Pragma Unmodified
6733 @unnumberedsec Pragma Unmodified
6735 @cindex Warnings, unmodified
6739 @smallexample @c ada
6740 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
6744 This pragma signals that the assignable entities (variables,
6745 @code{out} parameters, @code{in out} parameters) whose names are listed are
6746 deliberately not assigned in the current source unit. This
6747 suppresses warnings about the
6748 entities being referenced but not assigned, and in addition a warning will be
6749 generated if one of these entities is in fact assigned in the
6750 same unit as the pragma (or in the corresponding body, or one
6753 This is particularly useful for clearly signaling that a particular
6754 parameter is not modified, even though the spec suggests that it might
6757 @node Pragma Unreferenced
6758 @unnumberedsec Pragma Unreferenced
6759 @findex Unreferenced
6760 @cindex Warnings, unreferenced
6764 @smallexample @c ada
6765 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
6766 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
6770 This pragma signals that the entities whose names are listed are
6771 deliberately not referenced in the current source unit. This
6772 suppresses warnings about the
6773 entities being unreferenced, and in addition a warning will be
6774 generated if one of these entities is in fact subsequently referenced in the
6775 same unit as the pragma (or in the corresponding body, or one
6778 This is particularly useful for clearly signaling that a particular
6779 parameter is not referenced in some particular subprogram implementation
6780 and that this is deliberate. It can also be useful in the case of
6781 objects declared only for their initialization or finalization side
6784 If @code{LOCAL_NAME} identifies more than one matching homonym in the
6785 current scope, then the entity most recently declared is the one to which
6786 the pragma applies. Note that in the case of accept formals, the pragma
6787 Unreferenced may appear immediately after the keyword @code{do} which
6788 allows the indication of whether or not accept formals are referenced
6789 or not to be given individually for each accept statement.
6791 The left hand side of an assignment does not count as a reference for the
6792 purpose of this pragma. Thus it is fine to assign to an entity for which
6793 pragma Unreferenced is given.
6795 Note that if a warning is desired for all calls to a given subprogram,
6796 regardless of whether they occur in the same unit as the subprogram
6797 declaration, then this pragma should not be used (calls from another
6798 unit would not be flagged); pragma Obsolescent can be used instead
6799 for this purpose, see @xref{Pragma Obsolescent}.
6801 The second form of pragma @code{Unreferenced} is used within a context
6802 clause. In this case the arguments must be unit names of units previously
6803 mentioned in @code{with} clauses (similar to the usage of pragma
6804 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
6805 units and unreferenced entities within these units.
6807 @node Pragma Unreferenced_Objects
6808 @unnumberedsec Pragma Unreferenced_Objects
6809 @findex Unreferenced_Objects
6810 @cindex Warnings, unreferenced
6814 @smallexample @c ada
6815 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
6819 This pragma signals that for the types or subtypes whose names are
6820 listed, objects which are declared with one of these types or subtypes may
6821 not be referenced, and if no references appear, no warnings are given.
6823 This is particularly useful for objects which are declared solely for their
6824 initialization and finalization effect. Such variables are sometimes referred
6825 to as RAII variables (Resource Acquisition Is Initialization). Using this
6826 pragma on the relevant type (most typically a limited controlled type), the
6827 compiler will automatically suppress unwanted warnings about these variables
6828 not being referenced.
6830 @node Pragma Unreserve_All_Interrupts
6831 @unnumberedsec Pragma Unreserve_All_Interrupts
6832 @findex Unreserve_All_Interrupts
6836 @smallexample @c ada
6837 pragma Unreserve_All_Interrupts;
6841 Normally certain interrupts are reserved to the implementation. Any attempt
6842 to attach an interrupt causes Program_Error to be raised, as described in
6843 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
6844 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
6845 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
6846 interrupt execution.
6848 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
6849 a program, then all such interrupts are unreserved. This allows the
6850 program to handle these interrupts, but disables their standard
6851 functions. For example, if this pragma is used, then pressing
6852 @kbd{Ctrl-C} will not automatically interrupt execution. However,
6853 a program can then handle the @code{SIGINT} interrupt as it chooses.
6855 For a full list of the interrupts handled in a specific implementation,
6856 see the source code for the spec of @code{Ada.Interrupts.Names} in
6857 file @file{a-intnam.ads}. This is a target dependent file that contains the
6858 list of interrupts recognized for a given target. The documentation in
6859 this file also specifies what interrupts are affected by the use of
6860 the @code{Unreserve_All_Interrupts} pragma.
6862 For a more general facility for controlling what interrupts can be
6863 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
6864 of the @code{Unreserve_All_Interrupts} pragma.
6866 @node Pragma Unsuppress
6867 @unnumberedsec Pragma Unsuppress
6872 @smallexample @c ada
6873 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
6877 This pragma undoes the effect of a previous pragma @code{Suppress}. If
6878 there is no corresponding pragma @code{Suppress} in effect, it has no
6879 effect. The range of the effect is the same as for pragma
6880 @code{Suppress}. The meaning of the arguments is identical to that used
6881 in pragma @code{Suppress}.
6883 One important application is to ensure that checks are on in cases where
6884 code depends on the checks for its correct functioning, so that the code
6885 will compile correctly even if the compiler switches are set to suppress
6888 This pragma is standard in Ada 2005. It is available in all earlier versions
6889 of Ada as an implementation-defined pragma.
6891 Note that in addition to the checks defined in the Ada RM, GNAT recogizes
6892 a number of implementation-defined check names. See description of pragma
6893 @code{Suppress} for full details.
6895 @node Pragma Use_VADS_Size
6896 @unnumberedsec Pragma Use_VADS_Size
6897 @cindex @code{Size}, VADS compatibility
6898 @cindex Rational profile
6899 @findex Use_VADS_Size
6903 @smallexample @c ada
6904 pragma Use_VADS_Size;
6908 This is a configuration pragma. In a unit to which it applies, any use
6909 of the 'Size attribute is automatically interpreted as a use of the
6910 'VADS_Size attribute. Note that this may result in incorrect semantic
6911 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
6912 the handling of existing code which depends on the interpretation of Size
6913 as implemented in the VADS compiler. See description of the VADS_Size
6914 attribute for further details.
6916 @node Pragma Validity_Checks
6917 @unnumberedsec Pragma Validity_Checks
6918 @findex Validity_Checks
6922 @smallexample @c ada
6923 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
6927 This pragma is used in conjunction with compiler switches to control the
6928 built-in validity checking provided by GNAT@. The compiler switches, if set
6929 provide an initial setting for the switches, and this pragma may be used
6930 to modify these settings, or the settings may be provided entirely by
6931 the use of the pragma. This pragma can be used anywhere that a pragma
6932 is legal, including use as a configuration pragma (including use in
6933 the @file{gnat.adc} file).
6935 The form with a string literal specifies which validity options are to be
6936 activated. The validity checks are first set to include only the default
6937 reference manual settings, and then a string of letters in the string
6938 specifies the exact set of options required. The form of this string
6939 is exactly as described for the @option{-gnatVx} compiler switch (see the
6940 @value{EDITION} User's Guide for details). For example the following two
6941 methods can be used to enable validity checking for mode @code{in} and
6942 @code{in out} subprogram parameters:
6946 @smallexample @c ada
6947 pragma Validity_Checks ("im");
6952 gcc -c -gnatVim @dots{}
6957 The form ALL_CHECKS activates all standard checks (its use is equivalent
6958 to the use of the @code{gnatva} switch.
6960 The forms with @code{Off} and @code{On}
6961 can be used to temporarily disable validity checks
6962 as shown in the following example:
6964 @smallexample @c ada
6968 pragma Validity_Checks ("c"); -- validity checks for copies
6969 pragma Validity_Checks (Off); -- turn off validity checks
6970 A := B; -- B will not be validity checked
6971 pragma Validity_Checks (On); -- turn validity checks back on
6972 A := C; -- C will be validity checked
6975 @node Pragma Volatile
6976 @unnumberedsec Pragma Volatile
6981 @smallexample @c ada
6982 pragma Volatile (LOCAL_NAME);
6986 This pragma is defined by the Ada Reference Manual, and the GNAT
6987 implementation is fully conformant with this definition. The reason it
6988 is mentioned in this section is that a pragma of the same name was supplied
6989 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
6990 implementation of pragma Volatile is upwards compatible with the
6991 implementation in DEC Ada 83.
6993 @node Pragma Warnings
6994 @unnumberedsec Pragma Warnings
6999 @smallexample @c ada
7000 pragma Warnings (On | Off [,REASON]);
7001 pragma Warnings (On | Off, LOCAL_NAME [,REASON]);
7002 pragma Warnings (static_string_EXPRESSION [,REASON]);
7003 pragma Warnings (On | Off, static_string_EXPRESSION [,REASON]);
7005 REASON ::= Reason => static_string_EXPRESSION
7009 Normally warnings are enabled, with the output being controlled by
7010 the command line switch. Warnings (@code{Off}) turns off generation of
7011 warnings until a Warnings (@code{On}) is encountered or the end of the
7012 current unit. If generation of warnings is turned off using this
7013 pragma, then some or all of the warning messages are suppressed,
7014 regardless of the setting of the command line switches.
7016 The @code{Reason} parameter may optionally appear as the last argument
7017 in any of the forms of this pragma. It is intended purely for the
7018 purposes of documenting the reason for the @code{Warnings} pragma.
7019 The compiler will check that the argument is a static string but
7020 otherwise ignore this argument. Other tools may provide specialized
7021 processing for this string.
7023 The form with a single argument (or two arguments if Reason present),
7024 where the first argument is @code{ON} or @code{OFF}
7025 may be used as a configuration pragma.
7027 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
7028 the specified entity. This suppression is effective from the point where
7029 it occurs till the end of the extended scope of the variable (similar to
7030 the scope of @code{Suppress}). This form cannot be used as a configuration
7033 The form with a single static_string_EXPRESSION argument (and possible
7034 reason) provides more precise
7035 control over which warnings are active. The string is a list of letters
7036 specifying which warnings are to be activated and which deactivated. The
7037 code for these letters is the same as the string used in the command
7038 line switch controlling warnings. For a brief summary, use the gnatmake
7039 command with no arguments, which will generate usage information containing
7040 the list of warnings switches supported. For
7041 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
7042 User's Guide}. This form can also be used as a configuration pragma.
7045 The warnings controlled by the `-gnatw' switch are generated by the front end
7046 of the compiler. The `GCC' back end can provide additional warnings and they
7047 are controlled by the `-W' switch.
7048 The form with a single static_string_EXPRESSION argument also works for the
7049 latters, but the string must be a single full `-W' switch in this case.
7050 The above reference lists a few examples of these additional warnings.
7053 The specified warnings will be in effect until the end of the program
7054 or another pragma Warnings is encountered. The effect of the pragma is
7055 cumulative. Initially the set of warnings is the standard default set
7056 as possibly modified by compiler switches. Then each pragma Warning
7057 modifies this set of warnings as specified. This form of the pragma may
7058 also be used as a configuration pragma.
7060 The fourth form, with an @code{On|Off} parameter and a string, is used to
7061 control individual messages, based on their text. The string argument
7062 is a pattern that is used to match against the text of individual
7063 warning messages (not including the initial "warning: " tag).
7065 The pattern may contain asterisks, which match zero or more characters in
7066 the message. For example, you can use
7067 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
7068 message @code{warning: 960 bits of "a" unused}. No other regular
7069 expression notations are permitted. All characters other than asterisk in
7070 these three specific cases are treated as literal characters in the match.
7072 The above use of patterns to match the message applies only to warning
7073 messages generated by the front end. This form of the pragma with a
7074 string argument can also be used to control back end warnings controlled
7075 by a "-Wxxx" switch. Such warnings can be identified by the appearance
7076 of a string of the form "[-Wxxx]" in the message which identifies the
7077 "-W" switch that controls the message. By using the text of the
7078 "-W" switch in the pragma, such back end warnings can be turned on and off.
7080 There are two ways to use the pragma in this form. The OFF form can be used as a
7081 configuration pragma. The effect is to suppress all warnings (if any)
7082 that match the pattern string throughout the compilation (or match the
7083 -W switch in the back end case).
7085 The second usage is to suppress a warning locally, and in this case, two
7086 pragmas must appear in sequence:
7088 @smallexample @c ada
7089 pragma Warnings (Off, Pattern);
7090 @dots{} code where given warning is to be suppressed
7091 pragma Warnings (On, Pattern);
7095 In this usage, the pattern string must match in the Off and On pragmas,
7096 and at least one matching warning must be suppressed.
7098 Note: to write a string that will match any warning, use the string
7099 @code{"***"}. It will not work to use a single asterisk or two asterisks
7100 since this looks like an operator name. This form with three asterisks
7101 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
7102 matching @code{pragma Warnings (On, "***")} will be required. This can be
7103 helpful in avoiding forgetting to turn warnings back on.
7105 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
7106 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
7107 be useful in checking whether obsolete pragmas in existing programs are hiding
7110 Note: pragma Warnings does not affect the processing of style messages. See
7111 separate entry for pragma Style_Checks for control of style messages.
7113 @node Pragma Weak_External
7114 @unnumberedsec Pragma Weak_External
7115 @findex Weak_External
7119 @smallexample @c ada
7120 pragma Weak_External ([Entity =>] LOCAL_NAME);
7124 @var{LOCAL_NAME} must refer to an object that is declared at the library
7125 level. This pragma specifies that the given entity should be marked as a
7126 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
7127 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
7128 of a regular symbol, that is to say a symbol that does not have to be
7129 resolved by the linker if used in conjunction with a pragma Import.
7131 When a weak symbol is not resolved by the linker, its address is set to
7132 zero. This is useful in writing interfaces to external modules that may
7133 or may not be linked in the final executable, for example depending on
7134 configuration settings.
7136 If a program references at run time an entity to which this pragma has been
7137 applied, and the corresponding symbol was not resolved at link time, then
7138 the execution of the program is erroneous. It is not erroneous to take the
7139 Address of such an entity, for example to guard potential references,
7140 as shown in the example below.
7142 Some file formats do not support weak symbols so not all target machines
7143 support this pragma.
7145 @smallexample @c ada
7146 -- Example of the use of pragma Weak_External
7148 package External_Module is
7150 pragma Import (C, key);
7151 pragma Weak_External (key);
7152 function Present return boolean;
7153 end External_Module;
7155 with System; use System;
7156 package body External_Module is
7157 function Present return boolean is
7159 return key'Address /= System.Null_Address;
7161 end External_Module;
7164 @node Pragma Wide_Character_Encoding
7165 @unnumberedsec Pragma Wide_Character_Encoding
7166 @findex Wide_Character_Encoding
7170 @smallexample @c ada
7171 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
7175 This pragma specifies the wide character encoding to be used in program
7176 source text appearing subsequently. It is a configuration pragma, but may
7177 also be used at any point that a pragma is allowed, and it is permissible
7178 to have more than one such pragma in a file, allowing multiple encodings
7179 to appear within the same file.
7181 The argument can be an identifier or a character literal. In the identifier
7182 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
7183 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
7184 case it is correspondingly one of the characters @samp{h}, @samp{u},
7185 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
7187 Note that when the pragma is used within a file, it affects only the
7188 encoding within that file, and does not affect withed units, specs,
7191 @node Implementation Defined Aspects
7192 @chapter Implementation Defined Aspects
7193 Ada defines (throughout the Ada 2012 reference manual, summarized
7194 in annex K) a set of aspects that can be specified for certain entities.
7195 These language defined aspects are implemented in GNAT in Ada 2012 mode
7196 and work as described in the Ada 2012 Reference Manual.
7198 In addition, Ada 2012 allows implementations to define additional aspects
7199 whose meaning is defined by the implementation. GNAT provides
7200 a number of these implementation-dependent aspects which can be used
7201 to extend and enhance the functionality of the compiler. This section of
7202 the GNAT reference manual describes these additional attributes.
7204 Note that any program using these aspects may not be portable to
7205 other compilers (although GNAT implements this set of aspects on all
7206 platforms). Therefore if portability to other compilers is an important
7207 consideration, you should minimize the use of these aspects.
7209 Note that for many of these aspects, the effect is essentially similar
7210 to the use of a pragma or attribute specification with the same name
7211 applied to the entity. For example, if we write:
7213 @smallexample @c ada
7214 type R is range 1 .. 100
7215 with Value_Size => 10;
7219 then the effect is the same as:
7221 @smallexample @c ada
7222 type R is range 1 .. 100;
7223 for R'Value_Size use 10;
7229 @smallexample @c ada
7230 type R is new Integer
7231 with Shared => True;
7235 then the effect is the same as:
7237 @smallexample @c ada
7238 type R is new Integer;
7243 In the documentation sections that follow, such cases are simply marked
7244 as being equivalent to the corresponding pragma or attribute definition
7248 * Aspect Abstract_State::
7251 * Aspect Compiler_Unit::
7252 * Aspect Contract_Cases::
7254 * Aspect Dimension::
7255 * Aspect Dimension_System::
7256 * Aspect Favor_Top_Level::
7258 * Aspect Inline_Always::
7259 * Aspect Invariant::
7260 * Aspect Lock_Free::
7261 * Aspect Object_Size::
7262 * Aspect Persistent_BSS::
7263 * Aspect Predicate::
7264 * Aspect Preelaborate_05::
7267 * Aspect Pure_Function::
7268 * Aspect Remote_Access_Type::
7269 * Aspect Scalar_Storage_Order::
7271 * Aspect Simple_Storage_Pool::
7272 * Aspect Simple_Storage_Pool_Type::
7273 * Aspect SPARK_Mode::
7274 * Aspect Suppress_Debug_Info::
7275 * Aspect Test_Case::
7276 * Aspect Universal_Aliasing::
7277 * Aspect Universal_Data::
7278 * Aspect Unmodified::
7279 * Aspect Unreferenced::
7280 * Aspect Unreferenced_Objects::
7281 * Aspect Value_Size::
7285 @node Aspect Abstract_State
7286 @unnumberedsec Aspect Abstract_State
7287 @findex Abstract_State
7289 This aspect is equivalent to pragma @code{Abstract_State}.
7291 @node Aspect Ada_2005
7292 @unnumberedsec Aspect Ada_2005
7295 This aspect is equivalent to the one argument form of pragma @code{Ada_2005}.
7297 @node Aspect Ada_2012
7298 @unnumberedsec Aspect Ada_2012
7301 This aspect is equivalent to the one argument form of pragma @code{Ada_2012}.
7303 @node Aspect Compiler_Unit
7304 @unnumberedsec Aspect Compiler_Unit
7305 @findex Compiler_Unit
7307 This aspect is equivalent to pragma @code{Compiler_Unit}.
7309 @node Aspect Contract_Cases
7310 @unnumberedsec Aspect Contract_Cases
7311 @findex Contract_Cases
7313 This aspect is equivalent to pragma @code{Contract_Cases}, the sequence
7314 of clauses being enclosed in parentheses so that syntactically it is an
7317 @node Aspect Depends
7318 @unnumberedsec Aspect Depends
7321 This aspect is equivalent to pragma @code{Depends}.
7325 @node Aspect Dimension
7326 @unnumberedsec Aspect Dimension
7329 The @code{Dimension} aspect is used to specify the dimensions of a given
7330 subtype of a dimensioned numeric type. The aspect also specifies a symbol
7331 used when doing formatted output of dimensioned quantities. The syntax is:
7333 @smallexample @c ada
7335 ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
7337 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
7341 | others => RATIONAL
7342 | DISCRETE_CHOICE_LIST => RATIONAL
7344 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
7348 This aspect can only be applied to a subtype whose parent type has
7349 a @code{Dimension_Systen} aspect. The aspect must specify values for
7350 all dimensions of the system. The rational values are the powers of the
7351 corresponding dimensions that are used by the compiler to verify that
7352 physical (numeric) computations are dimensionally consistent. For example,
7353 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
7354 For further examples of the usage
7355 of this aspect, see package @code{System.Dim.Mks}.
7356 Note that when the dimensioned type is an integer type, then any
7357 dimension value must be an integer literal.
7359 @node Aspect Dimension_System
7360 @unnumberedsec Aspect Dimension_System
7361 @findex Dimension_System
7363 The @code{Dimension_System} aspect is used to define a system of
7364 dimensions that will be used in subsequent subtype declarations with
7365 @code{Dimension} aspects that reference this system. The syntax is:
7367 @smallexample @c ada
7368 with Dimension_System => (DIMENSION @{, DIMENSION@});
7370 DIMENSION ::= ([Unit_Name =>] IDENTIFIER,
7371 [Unit_Symbol =>] SYMBOL,
7372 [Dim_Symbol =>] SYMBOL)
7374 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
7378 This aspect is applied to a type, which must be a numeric derived type
7379 (typically a floating-point type), that
7380 will represent values within the dimension system. Each @code{DIMENSION}
7381 corresponds to one particular dimension. A maximum of 7 dimensions may
7382 be specified. @code{Unit_Name} is the name of the dimension (for example
7383 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
7384 of this dimension (for example 'm' for Meter). @code{Dim_Symbol} gives
7385 the identification within the dimension system (typically this is a
7386 single letter, e.g. 'L' standing for length for unit name Meter). The
7387 Unit_Smbol is used in formatted output of dimensioned quantities. The
7388 Dim_Symbol is used in error messages when numeric operations have
7389 inconsistent dimensions.
7391 GNAT provides the standard definition of the International MKS system in
7392 the run-time package @code{System.Dim.Mks}. You can easily define
7393 similar packages for cgs units or British units, and define conversion factors
7394 between values in different systems. The MKS system is characterized by the
7397 @smallexample @c ada
7398 type Mks_Type is new Long_Long_Float
7400 Dimension_System => (
7401 (Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'),
7402 (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'),
7403 (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'),
7404 (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'),
7405 (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => "Theta"),
7406 (Unit_Name => Mole, Unit_Symbol => "mol", Dim_Symbol => 'N'),
7407 (Unit_Name => Candela, Unit_Symbol => "cd", Dim_Symbol => 'J'));
7411 See section "Performing Dimensionality Analysis in GNAT" in the GNAT Users
7412 Guide for detailed examples of use of the dimension system.
7414 @node Aspect Favor_Top_Level
7415 @unnumberedsec Aspect Favor_Top_Level
7416 @findex Favor_Top_Level
7418 This aspect is equivalent to pragma @code{Favor_Top_Level}.
7421 @unnumberedsec Aspect Global
7424 This aspect is equivalent pragma @code{Global}.
7426 @node Aspect Inline_Always
7427 @unnumberedsec Aspect Inline_Always
7428 @findex Inline_Always
7430 This aspect is equivalent to pragma @code{Inline_Always}.
7432 @node Aspect Invariant
7433 @unnumberedsec Aspect Invariant
7436 This aspect is equivalent to pragma @code{Invariant}. It is a
7437 synonym for the language defined aspect @code{Type_Invariant} except
7438 that it is separately controllable using pragma @code{Assertion_Policy}.
7440 @node Aspect Lock_Free
7441 @unnumberedsec Aspect Lock_Free
7444 This aspect is equivalent to pragma @code{Lock_Free}.
7446 @node Aspect Object_Size
7447 @unnumberedsec Aspect Object_Size
7450 This aspect is equivalent to an @code{Object_Size} attribute definition
7453 @node Aspect Persistent_BSS
7454 @unnumberedsec Aspect Persistent_BSS
7455 @findex Persistent_BSS
7457 This aspect is equivalent to pragma @code{Persistent_BSS}.
7459 @node Aspect Predicate
7460 @unnumberedsec Aspect Predicate
7463 This aspect is equivalent to pragma @code{Predicate}. It is thus
7464 similar to the language defined aspects @code{Dynamic_Predicate}
7465 and @code{Static_Predicate} except that whether the resulting
7466 predicate is static or dynamic is controlled by the form of the
7467 expression. It is also separately controllable using pragma
7468 @code{Assertion_Policy}.
7470 @node Aspect Preelaborate_05
7471 @unnumberedsec Aspect Preelaborate_05
7472 @findex Preelaborate_05
7474 This aspect is equivalent to pragma @code{Preelaborate_05}.
7476 @node Aspect Pure_05
7477 @unnumberedsec Aspect Pure_05
7480 This aspect is equivalent to pragma @code{Pure_05}.
7482 @node Aspect Pure_12
7483 @unnumberedsec Aspect Pure_12
7486 This aspect is equivalent to pragma @code{Pure_12}.
7488 @node Aspect Pure_Function
7489 @unnumberedsec Aspect Pure_Function
7490 @findex Pure_Function
7492 This aspect is equivalent to pragma @code{Pure_Function}.
7494 @node Aspect Remote_Access_Type
7495 @unnumberedsec Aspect Remote_Access_Type
7496 @findex Remote_Access_Type
7498 This aspect is equivalent to pragma @code{Remote_Access_Type}.
7500 @node Aspect Scalar_Storage_Order
7501 @unnumberedsec Aspect Scalar_Storage_Order
7502 @findex Scalar_Storage_Order
7504 This aspect is equivalent to a @code{Scalar_Storage_Order}
7505 attribute definition clause.
7508 @unnumberedsec Aspect Shared
7511 This aspect is equivalent to pragma @code{Shared}, and is thus a synonym
7512 for aspect @code{Atomic}.
7514 @node Aspect Simple_Storage_Pool
7515 @unnumberedsec Aspect Simple_Storage_Pool
7516 @findex Simple_Storage_Pool
7518 This aspect is equivalent to a @code{Simple_Storage_Pool}
7519 attribute definition clause.
7521 @node Aspect Simple_Storage_Pool_Type
7522 @unnumberedsec Aspect Simple_Storage_Pool_Type
7523 @findex Simple_Storage_Pool_Type
7525 This aspect is equivalent to pragma @code{Simple_Storage_Pool_Type}.
7527 @node Aspect SPARK_Mode
7528 @unnumberedsec Aspect SPARK_Mode
7531 This aspect is equivalent to pragma @code{SPARK_Mode}.
7533 @node Aspect Suppress_Debug_Info
7534 @unnumberedsec Aspect Suppress_Debug_Info
7535 @findex Suppress_Debug_Info
7537 This aspect is equivalent to pragma @code{Suppress_Debug_Info}.
7539 @node Aspect Test_Case
7540 @unnumberedsec Aspect Test_Case
7543 This aspect is equivalent to pragma @code{Test_Case}.
7545 @node Aspect Universal_Aliasing
7546 @unnumberedsec Aspect Universal_Aliasing
7547 @findex Universal_Aliasing
7549 This aspect is equivalent to pragma @code{Universal_Aliasing}.
7551 @node Aspect Universal_Data
7552 @unnumberedsec Aspect Universal_Data
7553 @findex Universal_Data
7555 This aspect is equivalent to pragma @code{Universal_Data}.
7557 @node Aspect Unmodified
7558 @unnumberedsec Aspect Unmodified
7561 This aspect is equivalent to pragma @code{Unmodified}.
7563 @node Aspect Unreferenced
7564 @unnumberedsec Aspect Unreferenced
7565 @findex Unreferenced
7567 This aspect is equivalent to pragma @code{Unreferenced}.
7569 @node Aspect Unreferenced_Objects
7570 @unnumberedsec Aspect Unreferenced_Objects
7571 @findex Unreferenced_Objects
7573 This aspect is equivalent to pragma @code{Unreferenced_Objects}.
7575 @node Aspect Value_Size
7576 @unnumberedsec Aspect Value_Size
7579 This aspect is equivalent to a @code{Value_Size}
7580 attribute definition clause.
7582 @node Aspect Warnings
7583 @unnumberedsec Aspect Warnings
7586 This aspect is equivalent to the two argument form of pragma @code{Warnings},
7587 where the first argument is @code{ON} or @code{OFF} and the second argument
7590 @node Implementation Defined Attributes
7591 @chapter Implementation Defined Attributes
7592 Ada defines (throughout the Ada reference manual,
7593 summarized in Annex K),
7594 a set of attributes that provide useful additional functionality in all
7595 areas of the language. These language defined attributes are implemented
7596 in GNAT and work as described in the Ada Reference Manual.
7598 In addition, Ada allows implementations to define additional
7599 attributes whose meaning is defined by the implementation. GNAT provides
7600 a number of these implementation-dependent attributes which can be used
7601 to extend and enhance the functionality of the compiler. This section of
7602 the GNAT reference manual describes these additional attributes.
7604 Note that any program using these attributes may not be portable to
7605 other compilers (although GNAT implements this set of attributes on all
7606 platforms). Therefore if portability to other compilers is an important
7607 consideration, you should minimize the use of these attributes.
7610 * Attribute Abort_Signal::
7611 * Attribute Address_Size::
7612 * Attribute Asm_Input::
7613 * Attribute Asm_Output::
7614 * Attribute AST_Entry::
7616 * Attribute Bit_Position::
7617 * Attribute Compiler_Version::
7618 * Attribute Code_Address::
7619 * Attribute Default_Bit_Order::
7620 * Attribute Descriptor_Size::
7621 * Attribute Elaborated::
7622 * Attribute Elab_Body::
7623 * Attribute Elab_Spec::
7624 * Attribute Elab_Subp_Body::
7626 * Attribute Enabled::
7627 * Attribute Enum_Rep::
7628 * Attribute Enum_Val::
7629 * Attribute Epsilon::
7630 * Attribute Fixed_Value::
7631 * Attribute Has_Access_Values::
7632 * Attribute Has_Discriminants::
7634 * Attribute Integer_Value::
7635 * Attribute Invalid_Value::
7637 * Attribute Loop_Entry::
7638 * Attribute Machine_Size::
7639 * Attribute Mantissa::
7640 * Attribute Max_Interrupt_Priority::
7641 * Attribute Max_Priority::
7642 * Attribute Maximum_Alignment::
7643 * Attribute Mechanism_Code::
7644 * Attribute Null_Parameter::
7645 * Attribute Object_Size::
7646 * Attribute Passed_By_Reference::
7647 * Attribute Pool_Address::
7648 * Attribute Range_Length::
7650 * Attribute Restriction_Set::
7651 * Attribute Result::
7652 * Attribute Safe_Emax::
7653 * Attribute Safe_Large::
7654 * Attribute Scalar_Storage_Order::
7655 * Attribute Simple_Storage_Pool::
7657 * Attribute Storage_Unit::
7658 * Attribute Stub_Type::
7659 * Attribute System_Allocator_Alignment::
7660 * Attribute Target_Name::
7662 * Attribute To_Address::
7663 * Attribute Type_Class::
7664 * Attribute UET_Address::
7665 * Attribute Unconstrained_Array::
7666 * Attribute Universal_Literal_String::
7667 * Attribute Unrestricted_Access::
7668 * Attribute Update::
7669 * Attribute Valid_Scalars::
7670 * Attribute VADS_Size::
7671 * Attribute Value_Size::
7672 * Attribute Wchar_T_Size::
7673 * Attribute Word_Size::
7676 @node Attribute Abort_Signal
7677 @unnumberedsec Attribute Abort_Signal
7678 @findex Abort_Signal
7680 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
7681 prefix) provides the entity for the special exception used to signal
7682 task abort or asynchronous transfer of control. Normally this attribute
7683 should only be used in the tasking runtime (it is highly peculiar, and
7684 completely outside the normal semantics of Ada, for a user program to
7685 intercept the abort exception).
7687 @node Attribute Address_Size
7688 @unnumberedsec Attribute Address_Size
7689 @cindex Size of @code{Address}
7690 @findex Address_Size
7692 @code{Standard'Address_Size} (@code{Standard} is the only allowed
7693 prefix) is a static constant giving the number of bits in an
7694 @code{Address}. It is the same value as System.Address'Size,
7695 but has the advantage of being static, while a direct
7696 reference to System.Address'Size is non-static because Address
7699 @node Attribute Asm_Input
7700 @unnumberedsec Attribute Asm_Input
7703 The @code{Asm_Input} attribute denotes a function that takes two
7704 parameters. The first is a string, the second is an expression of the
7705 type designated by the prefix. The first (string) argument is required
7706 to be a static expression, and is the constraint for the parameter,
7707 (e.g.@: what kind of register is required). The second argument is the
7708 value to be used as the input argument. The possible values for the
7709 constant are the same as those used in the RTL, and are dependent on
7710 the configuration file used to built the GCC back end.
7711 @ref{Machine Code Insertions}
7713 @node Attribute Asm_Output
7714 @unnumberedsec Attribute Asm_Output
7717 The @code{Asm_Output} attribute denotes a function that takes two
7718 parameters. The first is a string, the second is the name of a variable
7719 of the type designated by the attribute prefix. The first (string)
7720 argument is required to be a static expression and designates the
7721 constraint for the parameter (e.g.@: what kind of register is
7722 required). The second argument is the variable to be updated with the
7723 result. The possible values for constraint are the same as those used in
7724 the RTL, and are dependent on the configuration file used to build the
7725 GCC back end. If there are no output operands, then this argument may
7726 either be omitted, or explicitly given as @code{No_Output_Operands}.
7727 @ref{Machine Code Insertions}
7729 @node Attribute AST_Entry
7730 @unnumberedsec Attribute AST_Entry
7734 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
7735 the name of an entry, it yields a value of the predefined type AST_Handler
7736 (declared in the predefined package System, as extended by the use of
7737 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
7738 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
7739 Language Reference Manual}, section 9.12a.
7742 @unnumberedsec Attribute Bit
7744 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
7745 offset within the storage unit (byte) that contains the first bit of
7746 storage allocated for the object. The value of this attribute is of the
7747 type @code{Universal_Integer}, and is always a non-negative number not
7748 exceeding the value of @code{System.Storage_Unit}.
7750 For an object that is a variable or a constant allocated in a register,
7751 the value is zero. (The use of this attribute does not force the
7752 allocation of a variable to memory).
7754 For an object that is a formal parameter, this attribute applies
7755 to either the matching actual parameter or to a copy of the
7756 matching actual parameter.
7758 For an access object the value is zero. Note that
7759 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
7760 designated object. Similarly for a record component
7761 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
7762 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
7763 are subject to index checks.
7765 This attribute is designed to be compatible with the DEC Ada 83 definition
7766 and implementation of the @code{Bit} attribute.
7768 @node Attribute Bit_Position
7769 @unnumberedsec Attribute Bit_Position
7770 @findex Bit_Position
7772 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
7773 of the fields of the record type, yields the bit
7774 offset within the record contains the first bit of
7775 storage allocated for the object. The value of this attribute is of the
7776 type @code{Universal_Integer}. The value depends only on the field
7777 @var{C} and is independent of the alignment of
7778 the containing record @var{R}.
7780 @node Attribute Compiler_Version
7781 @unnumberedsec Attribute Compiler_Version
7782 @findex Compiler_Version
7784 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
7785 prefix) yields a static string identifying the version of the compiler
7786 being used to compile the unit containing the attribute reference. A
7787 typical result would be something like "@value{EDITION} @i{version} (20090221)".
7789 @node Attribute Code_Address
7790 @unnumberedsec Attribute Code_Address
7791 @findex Code_Address
7792 @cindex Subprogram address
7793 @cindex Address of subprogram code
7796 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
7797 intended effect seems to be to provide
7798 an address value which can be used to call the subprogram by means of
7799 an address clause as in the following example:
7801 @smallexample @c ada
7802 procedure K is @dots{}
7805 for L'Address use K'Address;
7806 pragma Import (Ada, L);
7810 A call to @code{L} is then expected to result in a call to @code{K}@.
7811 In Ada 83, where there were no access-to-subprogram values, this was
7812 a common work-around for getting the effect of an indirect call.
7813 GNAT implements the above use of @code{Address} and the technique
7814 illustrated by the example code works correctly.
7816 However, for some purposes, it is useful to have the address of the start
7817 of the generated code for the subprogram. On some architectures, this is
7818 not necessarily the same as the @code{Address} value described above.
7819 For example, the @code{Address} value may reference a subprogram
7820 descriptor rather than the subprogram itself.
7822 The @code{'Code_Address} attribute, which can only be applied to
7823 subprogram entities, always returns the address of the start of the
7824 generated code of the specified subprogram, which may or may not be
7825 the same value as is returned by the corresponding @code{'Address}
7828 @node Attribute Default_Bit_Order
7829 @unnumberedsec Attribute Default_Bit_Order
7831 @cindex Little endian
7832 @findex Default_Bit_Order
7834 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
7835 permissible prefix), provides the value @code{System.Default_Bit_Order}
7836 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
7837 @code{Low_Order_First}). This is used to construct the definition of
7838 @code{Default_Bit_Order} in package @code{System}.
7840 @node Attribute Descriptor_Size
7841 @unnumberedsec Attribute Descriptor_Size
7844 @findex Descriptor_Size
7846 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
7847 descriptor allocated for a type. The result is non-zero only for unconstrained
7848 array types and the returned value is of type universal integer. In GNAT, an
7849 array descriptor contains bounds information and is located immediately before
7850 the first element of the array.
7852 @smallexample @c ada
7853 type Unconstr_Array is array (Positive range <>) of Boolean;
7854 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
7858 The attribute takes into account any additional padding due to type alignment.
7859 In the example above, the descriptor contains two values of type
7860 @code{Positive} representing the low and high bound. Since @code{Positive} has
7861 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
7862 Positive'Size + 2} or 64 bits.
7864 @node Attribute Elaborated
7865 @unnumberedsec Attribute Elaborated
7868 The prefix of the @code{'Elaborated} attribute must be a unit name. The
7869 value is a Boolean which indicates whether or not the given unit has been
7870 elaborated. This attribute is primarily intended for internal use by the
7871 generated code for dynamic elaboration checking, but it can also be used
7872 in user programs. The value will always be True once elaboration of all
7873 units has been completed. An exception is for units which need no
7874 elaboration, the value is always False for such units.
7876 @node Attribute Elab_Body
7877 @unnumberedsec Attribute Elab_Body
7880 This attribute can only be applied to a program unit name. It returns
7881 the entity for the corresponding elaboration procedure for elaborating
7882 the body of the referenced unit. This is used in the main generated
7883 elaboration procedure by the binder and is not normally used in any
7884 other context. However, there may be specialized situations in which it
7885 is useful to be able to call this elaboration procedure from Ada code,
7886 e.g.@: if it is necessary to do selective re-elaboration to fix some
7889 @node Attribute Elab_Spec
7890 @unnumberedsec Attribute Elab_Spec
7893 This attribute can only be applied to a program unit name. It returns
7894 the entity for the corresponding elaboration procedure for elaborating
7895 the spec of the referenced unit. This is used in the main
7896 generated elaboration procedure by the binder and is not normally used
7897 in any other context. However, there may be specialized situations in
7898 which it is useful to be able to call this elaboration procedure from
7899 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
7902 @node Attribute Elab_Subp_Body
7903 @unnumberedsec Attribute Elab_Subp_Body
7904 @findex Elab_Subp_Body
7906 This attribute can only be applied to a library level subprogram
7907 name and is only allowed in CodePeer mode. It returns the entity
7908 for the corresponding elaboration procedure for elaborating the body
7909 of the referenced subprogram unit. This is used in the main generated
7910 elaboration procedure by the binder in CodePeer mode only and is unrecognized
7913 @node Attribute Emax
7914 @unnumberedsec Attribute Emax
7915 @cindex Ada 83 attributes
7918 The @code{Emax} attribute is provided for compatibility with Ada 83. See
7919 the Ada 83 reference manual for an exact description of the semantics of
7922 @node Attribute Enabled
7923 @unnumberedsec Attribute Enabled
7926 The @code{Enabled} attribute allows an application program to check at compile
7927 time to see if the designated check is currently enabled. The prefix is a
7928 simple identifier, referencing any predefined check name (other than
7929 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
7930 no argument is given for the attribute, the check is for the general state
7931 of the check, if an argument is given, then it is an entity name, and the
7932 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
7933 given naming the entity (if not, then the argument is ignored).
7935 Note that instantiations inherit the check status at the point of the
7936 instantiation, so a useful idiom is to have a library package that
7937 introduces a check name with @code{pragma Check_Name}, and then contains
7938 generic packages or subprograms which use the @code{Enabled} attribute
7939 to see if the check is enabled. A user of this package can then issue
7940 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
7941 the package or subprogram, controlling whether the check will be present.
7943 @node Attribute Enum_Rep
7944 @unnumberedsec Attribute Enum_Rep
7945 @cindex Representation of enums
7948 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
7949 function with the following spec:
7951 @smallexample @c ada
7952 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
7953 return @i{Universal_Integer};
7957 It is also allowable to apply @code{Enum_Rep} directly to an object of an
7958 enumeration type or to a non-overloaded enumeration
7959 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
7960 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
7961 enumeration literal or object.
7963 The function returns the representation value for the given enumeration
7964 value. This will be equal to value of the @code{Pos} attribute in the
7965 absence of an enumeration representation clause. This is a static
7966 attribute (i.e.@: the result is static if the argument is static).
7968 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
7969 in which case it simply returns the integer value. The reason for this
7970 is to allow it to be used for @code{(<>)} discrete formal arguments in
7971 a generic unit that can be instantiated with either enumeration types
7972 or integer types. Note that if @code{Enum_Rep} is used on a modular
7973 type whose upper bound exceeds the upper bound of the largest signed
7974 integer type, and the argument is a variable, so that the universal
7975 integer calculation is done at run time, then the call to @code{Enum_Rep}
7976 may raise @code{Constraint_Error}.
7978 @node Attribute Enum_Val
7979 @unnumberedsec Attribute Enum_Val
7980 @cindex Representation of enums
7983 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
7984 function with the following spec:
7986 @smallexample @c ada
7987 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
7988 return @var{S}'Base};
7992 The function returns the enumeration value whose representation matches the
7993 argument, or raises Constraint_Error if no enumeration literal of the type
7994 has the matching value.
7995 This will be equal to value of the @code{Val} attribute in the
7996 absence of an enumeration representation clause. This is a static
7997 attribute (i.e.@: the result is static if the argument is static).
7999 @node Attribute Epsilon
8000 @unnumberedsec Attribute Epsilon
8001 @cindex Ada 83 attributes
8004 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
8005 the Ada 83 reference manual for an exact description of the semantics of
8008 @node Attribute Fixed_Value
8009 @unnumberedsec Attribute Fixed_Value
8012 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
8013 function with the following specification:
8015 @smallexample @c ada
8016 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
8021 The value returned is the fixed-point value @var{V} such that
8023 @smallexample @c ada
8024 @var{V} = Arg * @var{S}'Small
8028 The effect is thus similar to first converting the argument to the
8029 integer type used to represent @var{S}, and then doing an unchecked
8030 conversion to the fixed-point type. The difference is
8031 that there are full range checks, to ensure that the result is in range.
8032 This attribute is primarily intended for use in implementation of the
8033 input-output functions for fixed-point values.
8035 @node Attribute Has_Access_Values
8036 @unnumberedsec Attribute Has_Access_Values
8037 @cindex Access values, testing for
8038 @findex Has_Access_Values
8040 The prefix of the @code{Has_Access_Values} attribute is a type. The result
8041 is a Boolean value which is True if the is an access type, or is a composite
8042 type with a component (at any nesting depth) that is an access type, and is
8044 The intended use of this attribute is in conjunction with generic
8045 definitions. If the attribute is applied to a generic private type, it
8046 indicates whether or not the corresponding actual type has access values.
8048 @node Attribute Has_Discriminants
8049 @unnumberedsec Attribute Has_Discriminants
8050 @cindex Discriminants, testing for
8051 @findex Has_Discriminants
8053 The prefix of the @code{Has_Discriminants} attribute is a type. The result
8054 is a Boolean value which is True if the type has discriminants, and False
8055 otherwise. The intended use of this attribute is in conjunction with generic
8056 definitions. If the attribute is applied to a generic private type, it
8057 indicates whether or not the corresponding actual type has discriminants.
8060 @unnumberedsec Attribute Img
8063 The @code{Img} attribute differs from @code{Image} in that it is applied
8064 directly to an object, and yields the same result as
8065 @code{Image} for the subtype of the object. This is convenient for
8068 @smallexample @c ada
8069 Put_Line ("X = " & X'Img);
8073 has the same meaning as the more verbose:
8075 @smallexample @c ada
8076 Put_Line ("X = " & @var{T}'Image (X));
8080 where @var{T} is the (sub)type of the object @code{X}.
8082 Note that technically, in analogy to @code{Image},
8083 @code{X'Img} returns a parameterless function
8084 that returns the appropriate string when called. This means that
8085 @code{X'Img} can be renamed as a function-returning-string, or used
8086 in an instantiation as a function parameter.
8088 @node Attribute Integer_Value
8089 @unnumberedsec Attribute Integer_Value
8090 @findex Integer_Value
8092 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
8093 function with the following spec:
8095 @smallexample @c ada
8096 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
8101 The value returned is the integer value @var{V}, such that
8103 @smallexample @c ada
8104 Arg = @var{V} * @var{T}'Small
8108 where @var{T} is the type of @code{Arg}.
8109 The effect is thus similar to first doing an unchecked conversion from
8110 the fixed-point type to its corresponding implementation type, and then
8111 converting the result to the target integer type. The difference is
8112 that there are full range checks, to ensure that the result is in range.
8113 This attribute is primarily intended for use in implementation of the
8114 standard input-output functions for fixed-point values.
8116 @node Attribute Invalid_Value
8117 @unnumberedsec Attribute Invalid_Value
8118 @findex Invalid_Value
8120 For every scalar type S, S'Invalid_Value returns an undefined value of the
8121 type. If possible this value is an invalid representation for the type. The
8122 value returned is identical to the value used to initialize an otherwise
8123 uninitialized value of the type if pragma Initialize_Scalars is used,
8124 including the ability to modify the value with the binder -Sxx flag and
8125 relevant environment variables at run time.
8127 @node Attribute Large
8128 @unnumberedsec Attribute Large
8129 @cindex Ada 83 attributes
8132 The @code{Large} attribute is provided for compatibility with Ada 83. See
8133 the Ada 83 reference manual for an exact description of the semantics of
8136 @node Attribute Loop_Entry
8137 @unnumberedsec Attribute Loop_Entry
8142 @smallexample @c ada
8143 X'Loop_Entry [(loop_name)]
8147 The @code{Loop_Entry} attribute is used to refer to the value that an
8148 expression had upon entry to a given loop in much the same way that the
8149 @code{Old} attribute in a subprogram postcondition can be used to refer
8150 to the value an expression had upon entry to the subprogram. The
8151 relevant loop is either identified by the given loop name, or it is the
8152 innermost enclosing loop when no loop name is given.
8155 A @code{Loop_Entry} attribute can only occur within a
8156 @code{Loop_Variant} or @code{Loop_Invariant} pragma. A common use of
8157 @code{Loop_Entry} is to compare the current value of objects with their
8158 initial value at loop entry, in a @code{Loop_Invariant} pragma.
8161 The effect of using @code{X'Loop_Entry} is the same as declaring
8162 a constant initialized with the initial value of @code{X} at loop
8163 entry. This copy is not performed if the loop is not entered, or if the
8164 corresponding pragmas are ignored or disabled.
8166 @node Attribute Machine_Size
8167 @unnumberedsec Attribute Machine_Size
8168 @findex Machine_Size
8170 This attribute is identical to the @code{Object_Size} attribute. It is
8171 provided for compatibility with the DEC Ada 83 attribute of this name.
8173 @node Attribute Mantissa
8174 @unnumberedsec Attribute Mantissa
8175 @cindex Ada 83 attributes
8178 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
8179 the Ada 83 reference manual for an exact description of the semantics of
8182 @node Attribute Max_Interrupt_Priority
8183 @unnumberedsec Attribute Max_Interrupt_Priority
8184 @cindex Interrupt priority, maximum
8185 @findex Max_Interrupt_Priority
8187 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
8188 permissible prefix), provides the same value as
8189 @code{System.Max_Interrupt_Priority}.
8191 @node Attribute Max_Priority
8192 @unnumberedsec Attribute Max_Priority
8193 @cindex Priority, maximum
8194 @findex Max_Priority
8196 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
8197 prefix) provides the same value as @code{System.Max_Priority}.
8199 @node Attribute Maximum_Alignment
8200 @unnumberedsec Attribute Maximum_Alignment
8201 @cindex Alignment, maximum
8202 @findex Maximum_Alignment
8204 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
8205 permissible prefix) provides the maximum useful alignment value for the
8206 target. This is a static value that can be used to specify the alignment
8207 for an object, guaranteeing that it is properly aligned in all
8210 @node Attribute Mechanism_Code
8211 @unnumberedsec Attribute Mechanism_Code
8212 @cindex Return values, passing mechanism
8213 @cindex Parameters, passing mechanism
8214 @findex Mechanism_Code
8216 @code{@var{function}'Mechanism_Code} yields an integer code for the
8217 mechanism used for the result of function, and
8218 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
8219 used for formal parameter number @var{n} (a static integer value with 1
8220 meaning the first parameter) of @var{subprogram}. The code returned is:
8228 by descriptor (default descriptor class)
8230 by descriptor (UBS: unaligned bit string)
8232 by descriptor (UBSB: aligned bit string with arbitrary bounds)
8234 by descriptor (UBA: unaligned bit array)
8236 by descriptor (S: string, also scalar access type parameter)
8238 by descriptor (SB: string with arbitrary bounds)
8240 by descriptor (A: contiguous array)
8242 by descriptor (NCA: non-contiguous array)
8246 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
8249 @node Attribute Null_Parameter
8250 @unnumberedsec Attribute Null_Parameter
8251 @cindex Zero address, passing
8252 @findex Null_Parameter
8254 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
8255 type or subtype @var{T} allocated at machine address zero. The attribute
8256 is allowed only as the default expression of a formal parameter, or as
8257 an actual expression of a subprogram call. In either case, the
8258 subprogram must be imported.
8260 The identity of the object is represented by the address zero in the
8261 argument list, independent of the passing mechanism (explicit or
8264 This capability is needed to specify that a zero address should be
8265 passed for a record or other composite object passed by reference.
8266 There is no way of indicating this without the @code{Null_Parameter}
8269 @node Attribute Object_Size
8270 @unnumberedsec Attribute Object_Size
8271 @cindex Size, used for objects
8274 The size of an object is not necessarily the same as the size of the type
8275 of an object. This is because by default object sizes are increased to be
8276 a multiple of the alignment of the object. For example,
8277 @code{Natural'Size} is
8278 31, but by default objects of type @code{Natural} will have a size of 32 bits.
8279 Similarly, a record containing an integer and a character:
8281 @smallexample @c ada
8289 will have a size of 40 (that is @code{Rec'Size} will be 40). The
8290 alignment will be 4, because of the
8291 integer field, and so the default size of record objects for this type
8292 will be 64 (8 bytes).
8294 @node Attribute Passed_By_Reference
8295 @unnumberedsec Attribute Passed_By_Reference
8296 @cindex Parameters, when passed by reference
8297 @findex Passed_By_Reference
8299 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
8300 a value of type @code{Boolean} value that is @code{True} if the type is
8301 normally passed by reference and @code{False} if the type is normally
8302 passed by copy in calls. For scalar types, the result is always @code{False}
8303 and is static. For non-scalar types, the result is non-static.
8305 @node Attribute Pool_Address
8306 @unnumberedsec Attribute Pool_Address
8307 @cindex Parameters, when passed by reference
8308 @findex Pool_Address
8310 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
8311 of X within its storage pool. This is the same as
8312 @code{@var{X}'Address}, except that for an unconstrained array whose
8313 bounds are allocated just before the first component,
8314 @code{@var{X}'Pool_Address} returns the address of those bounds,
8315 whereas @code{@var{X}'Address} returns the address of the first
8318 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
8319 the object is allocated'', which could be a user-defined storage pool,
8320 the global heap, on the stack, or in a static memory area. For an
8321 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
8322 what is passed to @code{Allocate} and returned from @code{Deallocate}.
8324 @node Attribute Range_Length
8325 @unnumberedsec Attribute Range_Length
8326 @findex Range_Length
8328 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
8329 the number of values represented by the subtype (zero for a null
8330 range). The result is static for static subtypes. @code{Range_Length}
8331 applied to the index subtype of a one dimensional array always gives the
8332 same result as @code{Length} applied to the array itself.
8335 @unnumberedsec Attribute Ref
8340 @node Attribute Restriction_Set
8341 @unnumberedsec Attribute Restriction_Set
8342 @findex Restriction_Set
8343 @cindex Restrictions
8345 This attribute allows compile time testing of restrictions that
8346 are currently in effect. It is primarily intended for specializing
8347 code in the run-time based on restrictions that are active (e.g.
8348 don't need to save fpt registers if restriction No_Floating_Point
8349 is known to be in effect), but can be used anywhere.
8351 There are two forms:
8353 @smallexample @c ada
8354 System'Restriction_Set (partition_boolean_restriction_NAME)
8355 System'Restriction_Set (No_Dependence => library_unit_NAME);
8359 In the case of the first form, the only restriction names
8360 allowed are parameterless restrictions that are checked
8361 for consistency at bind time. For a complete list see the
8362 subtype @code{System.Rident.Partition_Boolean_Restrictions}.
8364 The result returned is True if the restriction is known to
8365 be in effect, and False if the restriction is known not to
8366 be in effect. An important guarantee is that the value of
8367 a Restriction_Set attribute is known to be consistent throughout
8368 all the code of a partition.
8370 This is trivially achieved if the entire partition is compiled
8371 with a consistent set of restriction pragmas. However, the
8372 compilation model does not require this. It is possible to
8373 compile one set of units with one set of pragmas, and another
8374 set of units with another set of pragmas. It is even possible
8375 to compile a spec with one set of pragmas, and then WITH the
8376 same spec with a different set of pragmas. Inconsistencies
8377 in the actual use of the restriction are checked at bind time.
8379 In order to achieve the guarantee of consistency for the
8380 Restriction_Set pragma, we consider that a use of the pragma
8381 that yields False is equivalent to a violation of the
8384 So for example if you write
8386 @smallexample @c ada
8387 if System'Restriction_Set (No_Floating_Point) then
8395 And the result is False, so that the else branch is executed,
8396 you can assume that this restriction is not set for any unit
8397 in the partition. This is checked by considering this use of
8398 the restriction pragma to be a violation of the restriction
8399 No_Floating_Point. This means that no other unit can attempt
8400 to set this restriction (if some unit does attempt to set it,
8401 the binder will refuse to bind the partition).
8403 Technical note: The restriction name and the unit name are
8404 intepreted entirely syntactically, as in the corresponding
8405 Restrictions pragma, they are not analyzed semantically,
8406 so they do not have a type.
8408 @node Attribute Result
8409 @unnumberedsec Attribute Result
8412 @code{@var{function}'Result} can only be used with in a Postcondition pragma
8413 for a function. The prefix must be the name of the corresponding function. This
8414 is used to refer to the result of the function in the postcondition expression.
8415 For a further discussion of the use of this attribute and examples of its use,
8416 see the description of pragma Postcondition.
8418 @node Attribute Safe_Emax
8419 @unnumberedsec Attribute Safe_Emax
8420 @cindex Ada 83 attributes
8423 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
8424 the Ada 83 reference manual for an exact description of the semantics of
8427 @node Attribute Safe_Large
8428 @unnumberedsec Attribute Safe_Large
8429 @cindex Ada 83 attributes
8432 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
8433 the Ada 83 reference manual for an exact description of the semantics of
8436 @node Attribute Scalar_Storage_Order
8437 @unnumberedsec Attribute Scalar_Storage_Order
8439 @cindex Scalar storage order
8440 @findex Scalar_Storage_Order
8442 For every array or record type @var{S}, the representation attribute
8443 @code{Scalar_Storage_Order} denotes the order in which storage elements
8444 that make up scalar components are ordered within S:
8446 @smallexample @c ada
8447 -- Component type definitions
8449 subtype Yr_Type is Natural range 0 .. 127;
8450 subtype Mo_Type is Natural range 1 .. 12;
8451 subtype Da_Type is Natural range 1 .. 31;
8453 -- Record declaration
8456 Years_Since_1980 : Yr_Type;
8458 Day_Of_Month : Da_Type;
8461 -- Record representation clause
8464 Years_Since_1980 at 0 range 0 .. 6;
8465 Month at 0 range 7 .. 10;
8466 Day_Of_Month at 0 range 11 .. 15;
8469 -- Attribute definition clauses
8471 for Date'Bit_Order use System.High_Order_First;
8472 for Date'Scalar_Storage_Order use System.High_Order_First;
8473 -- If Scalar_Storage_Order is specified, it must be consistent with
8474 -- Bit_Order, so it's best to always define the latter explicitly if
8475 -- the former is used.
8478 Other properties are
8479 as for standard representation attribute @code{Bit_Order}, as defined by
8480 Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
8482 For a record type @var{S}, if @code{@var{S}'Scalar_Storage_Order} is
8483 specified explicitly, it shall be equal to @code{@var{S}'Bit_Order}. Note:
8484 this means that if a @code{Scalar_Storage_Order} attribute definition
8485 clause is not confirming, then the type's @code{Bit_Order} shall be
8486 specified explicitly and set to the same value.
8488 For a record extension, the derived type shall have the same scalar storage
8489 order as the parent type.
8491 If a component of @var{S} has itself a record or array type, then it shall also
8492 have a @code{Scalar_Storage_Order} attribute definition clause. In addition,
8493 if the component does not start on a byte boundary, then the scalar storage
8494 order specified for S and for the nested component type shall be identical.
8496 No component of a type that has a @code{Scalar_Storage_Order} attribute
8497 definition may be aliased.
8499 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
8500 with a value equal to @code{System.Default_Bit_Order}) has no effect.
8502 If the opposite storage order is specified, then whenever the value of
8503 a scalar component of an object of type @var{S} is read, the storage
8504 elements of the enclosing machine scalar are first reversed (before
8505 retrieving the component value, possibly applying some shift and mask
8506 operatings on the enclosing machine scalar), and the opposite operation
8509 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
8510 are relaxed. Instead, the following rules apply:
8513 @item the underlying storage elements are those at positions
8514 @code{(position + first_bit / storage_element_size) ..
8515 (position + (last_bit + storage_element_size - 1) /
8516 storage_element_size)}
8517 @item the sequence of underlying storage elements shall have
8518 a size no greater than the largest machine scalar
8519 @item the enclosing machine scalar is defined as the smallest machine
8520 scalar starting at a position no greater than
8521 @code{position + first_bit / storage_element_size} and covering
8522 storage elements at least up to @code{position + (last_bit +
8523 storage_element_size - 1) / storage_element_size}
8524 @item the position of the component is interpreted relative to that machine
8529 @node Attribute Simple_Storage_Pool
8530 @unnumberedsec Attribute Simple_Storage_Pool
8531 @cindex Storage pool, simple
8532 @cindex Simple storage pool
8533 @findex Simple_Storage_Pool
8535 For every nonformal, nonderived access-to-object type @var{Acc}, the
8536 representation attribute @code{Simple_Storage_Pool} may be specified
8537 via an attribute_definition_clause (or by specifying the equivalent aspect):
8539 @smallexample @c ada
8541 My_Pool : My_Simple_Storage_Pool_Type;
8543 type Acc is access My_Data_Type;
8545 for Acc'Simple_Storage_Pool use My_Pool;
8550 The name given in an attribute_definition_clause for the
8551 @code{Simple_Storage_Pool} attribute shall denote a variable of
8552 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
8554 The use of this attribute is only allowed for a prefix denoting a type
8555 for which it has been specified. The type of the attribute is the type
8556 of the variable specified as the simple storage pool of the access type,
8557 and the attribute denotes that variable.
8559 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
8560 for the same access type.
8562 If the @code{Simple_Storage_Pool} attribute has been specified for an access
8563 type, then applying the @code{Storage_Pool} attribute to the type is flagged
8564 with a warning and its evaluation raises the exception @code{Program_Error}.
8566 If the Simple_Storage_Pool attribute has been specified for an access
8567 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
8568 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
8569 which is intended to indicate the number of storage elements reserved for
8570 the simple storage pool. If the Storage_Size function has not been defined
8571 for the simple storage pool type, then this attribute returns zero.
8573 If an access type @var{S} has a specified simple storage pool of type
8574 @var{SSP}, then the evaluation of an allocator for that access type calls
8575 the primitive @code{Allocate} procedure for type @var{SSP}, passing
8576 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
8577 semantics of such allocators is the same as those defined for allocators
8578 in section 13.11 of the Ada Reference Manual, with the term
8579 ``simple storage pool'' substituted for ``storage pool''.
8581 If an access type @var{S} has a specified simple storage pool of type
8582 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
8583 for that access type invokes the primitive @code{Deallocate} procedure
8584 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
8585 parameter. The detailed semantics of such unchecked deallocations is the same
8586 as defined in section 13.11.2 of the Ada Reference Manual, except that the
8587 term ``simple storage pool'' is substituted for ``storage pool''.
8589 @node Attribute Small
8590 @unnumberedsec Attribute Small
8591 @cindex Ada 83 attributes
8594 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
8596 GNAT also allows this attribute to be applied to floating-point types
8597 for compatibility with Ada 83. See
8598 the Ada 83 reference manual for an exact description of the semantics of
8599 this attribute when applied to floating-point types.
8601 @node Attribute Storage_Unit
8602 @unnumberedsec Attribute Storage_Unit
8603 @findex Storage_Unit
8605 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
8606 prefix) provides the same value as @code{System.Storage_Unit}.
8608 @node Attribute Stub_Type
8609 @unnumberedsec Attribute Stub_Type
8612 The GNAT implementation of remote access-to-classwide types is
8613 organized as described in AARM section E.4 (20.t): a value of an RACW type
8614 (designating a remote object) is represented as a normal access
8615 value, pointing to a "stub" object which in turn contains the
8616 necessary information to contact the designated remote object. A
8617 call on any dispatching operation of such a stub object does the
8618 remote call, if necessary, using the information in the stub object
8619 to locate the target partition, etc.
8621 For a prefix @code{T} that denotes a remote access-to-classwide type,
8622 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
8624 By construction, the layout of @code{T'Stub_Type} is identical to that of
8625 type @code{RACW_Stub_Type} declared in the internal implementation-defined
8626 unit @code{System.Partition_Interface}. Use of this attribute will create
8627 an implicit dependency on this unit.
8629 @node Attribute System_Allocator_Alignment
8630 @unnumberedsec Attribute System_Allocator_Alignment
8631 @cindex Alignment, allocator
8632 @findex System_Allocator_Alignment
8634 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
8635 permissible prefix) provides the observable guaranted to be honored by
8636 the system allocator (malloc). This is a static value that can be used
8637 in user storage pools based on malloc either to reject allocation
8638 with alignment too large or to enable a realignment circuitry if the
8639 alignment request is larger than this value.
8641 @node Attribute Target_Name
8642 @unnumberedsec Attribute Target_Name
8645 @code{Standard'Target_Name} (@code{Standard} is the only permissible
8646 prefix) provides a static string value that identifies the target
8647 for the current compilation. For GCC implementations, this is the
8648 standard gcc target name without the terminating slash (for
8649 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
8651 @node Attribute Tick
8652 @unnumberedsec Attribute Tick
8655 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
8656 provides the same value as @code{System.Tick},
8658 @node Attribute To_Address
8659 @unnumberedsec Attribute To_Address
8662 The @code{System'To_Address}
8663 (@code{System} is the only permissible prefix)
8664 denotes a function identical to
8665 @code{System.Storage_Elements.To_Address} except that
8666 it is a static attribute. This means that if its argument is
8667 a static expression, then the result of the attribute is a
8668 static expression. The result is that such an expression can be
8669 used in contexts (e.g.@: preelaborable packages) which require a
8670 static expression and where the function call could not be used
8671 (since the function call is always non-static, even if its
8672 argument is static).
8674 @node Attribute Type_Class
8675 @unnumberedsec Attribute Type_Class
8678 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
8679 the value of the type class for the full type of @var{type}. If
8680 @var{type} is a generic formal type, the value is the value for the
8681 corresponding actual subtype. The value of this attribute is of type
8682 @code{System.Aux_DEC.Type_Class}, which has the following definition:
8684 @smallexample @c ada
8686 (Type_Class_Enumeration,
8688 Type_Class_Fixed_Point,
8689 Type_Class_Floating_Point,
8694 Type_Class_Address);
8698 Protected types yield the value @code{Type_Class_Task}, which thus
8699 applies to all concurrent types. This attribute is designed to
8700 be compatible with the DEC Ada 83 attribute of the same name.
8702 @node Attribute UET_Address
8703 @unnumberedsec Attribute UET_Address
8706 The @code{UET_Address} attribute can only be used for a prefix which
8707 denotes a library package. It yields the address of the unit exception
8708 table when zero cost exception handling is used. This attribute is
8709 intended only for use within the GNAT implementation. See the unit
8710 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
8711 for details on how this attribute is used in the implementation.
8713 @node Attribute Unconstrained_Array
8714 @unnumberedsec Attribute Unconstrained_Array
8715 @findex Unconstrained_Array
8717 The @code{Unconstrained_Array} attribute can be used with a prefix that
8718 denotes any type or subtype. It is a static attribute that yields
8719 @code{True} if the prefix designates an unconstrained array,
8720 and @code{False} otherwise. In a generic instance, the result is
8721 still static, and yields the result of applying this test to the
8724 @node Attribute Universal_Literal_String
8725 @unnumberedsec Attribute Universal_Literal_String
8726 @cindex Named numbers, representation of
8727 @findex Universal_Literal_String
8729 The prefix of @code{Universal_Literal_String} must be a named
8730 number. The static result is the string consisting of the characters of
8731 the number as defined in the original source. This allows the user
8732 program to access the actual text of named numbers without intermediate
8733 conversions and without the need to enclose the strings in quotes (which
8734 would preclude their use as numbers).
8736 For example, the following program prints the first 50 digits of pi:
8738 @smallexample @c ada
8739 with Text_IO; use Text_IO;
8743 Put (Ada.Numerics.Pi'Universal_Literal_String);
8747 @node Attribute Unrestricted_Access
8748 @unnumberedsec Attribute Unrestricted_Access
8749 @cindex @code{Access}, unrestricted
8750 @findex Unrestricted_Access
8752 The @code{Unrestricted_Access} attribute is similar to @code{Access}
8753 except that all accessibility and aliased view checks are omitted. This
8754 is a user-beware attribute. It is similar to
8755 @code{Address}, for which it is a desirable replacement where the value
8756 desired is an access type. In other words, its effect is identical to
8757 first applying the @code{Address} attribute and then doing an unchecked
8758 conversion to a desired access type. In GNAT, but not necessarily in
8759 other implementations, the use of static chains for inner level
8760 subprograms means that @code{Unrestricted_Access} applied to a
8761 subprogram yields a value that can be called as long as the subprogram
8762 is in scope (normal Ada accessibility rules restrict this usage).
8764 It is possible to use @code{Unrestricted_Access} for any type, but care
8765 must be exercised if it is used to create pointers to unconstrained
8766 objects. In this case, the resulting pointer has the same scope as the
8767 context of the attribute, and may not be returned to some enclosing
8768 scope. For instance, a function cannot use @code{Unrestricted_Access}
8769 to create a unconstrained pointer and then return that value to the
8772 @node Attribute Update
8773 @unnumberedsec Attribute Update
8776 The @code{Update} attribute creates a copy of an array or record value
8777 with one or more modified components. The syntax is:
8779 @smallexample @c ada
8780 PREFIX'Update (AGGREGATE);
8784 where @code{PREFIX} is the name of an array or record object, and
8785 @code{AGGREGATE} is a named aggregate that does not contain an @code{others}
8786 choice. The effect is to yield a copy of the array or record value which
8787 is unchanged apart from the components mentioned in the aggregate, which
8788 are changed to the indicated value. The original value of the array or
8789 record value is not affected. For example:
8791 @smallexample @c ada
8792 type Arr is Array (1 .. 5) of Integer;
8794 Avar1 : Arr := (1,2,3,4,5);
8795 Avar2 : Arr := Avar1'Update ((2 => 10, 3 .. 4 => 20));
8799 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
8800 begin unmodified. Similarly:
8802 @smallexample @c ada
8803 type Rec is A, B, C : Integer;
8805 Rvar1 : Rec := (A => 1, B => 2, C => 3);
8806 Rvar2 : Rec := Rvar1'Update ((B => 20));
8810 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
8811 with @code{Rvar1} being unmodifed.
8812 Note that the value of the attribute reference is computed
8813 completely before it is used. This means that if you write:
8815 @smallexample @c ada
8816 Avar1 := Avar1'Update ((1 => 10, 2 => Function_Call));
8820 then the value of @code{Avar1} is not modified if @code{Function_Call}
8821 raises an exception, unlike the effect of a series of direct assignments
8822 to elements of @code{Avar1}. In general this requires that
8823 two extra complete copies of the object are required, which should be
8824 kept in mind when considering efficiency.
8826 The @code{Update} attribute cannot be applied to prefixes of a limited
8827 type, and cannot reference discriminants in the case of a record type.
8829 In the record case, no component can be mentioned more than once. In
8830 the array case, two overlapping ranges can appear in the aggregate,
8831 in which case the modifications are processed left to right.
8833 Multi-dimensional arrays can be modified, as shown by this example:
8835 @smallexample @c ada
8836 A : array (1 .. 10, 1 .. 10) of Integer;
8838 A := A'Update (1 => (2 => 20), 3 => (4 => 30));
8842 which changes element (1,2) to 20 and (3,4) to 30.
8844 @node Attribute Valid_Scalars
8845 @unnumberedsec Attribute Valid_Scalars
8846 @findex Valid_Scalars
8848 The @code{'Valid_Scalars} attribute is intended to make it easier to
8849 check the validity of scalar subcomponents of composite objects. It
8850 is defined for any prefix @code{X} that denotes an object.
8851 The value of this attribute is of the predefined type Boolean.
8852 @code{X'Valid_Scalars} yields True if and only if evaluation of
8853 @code{P'Valid} yields True for every scalar part P of X or if X has
8854 no scalar parts. It is not specified in what order the scalar parts
8855 are checked, nor whether any more are checked after any one of them
8856 is determined to be invalid. If the prefix @code{X} is of a class-wide
8857 type @code{T'Class} (where @code{T} is the associated specific type),
8858 or if the prefix @code{X} is of a specific tagged type @code{T}, then
8859 only the scalar parts of components of @code{T} are traversed; in other
8860 words, components of extensions of @code{T} are not traversed even if
8861 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
8862 be determined at compile time that the prefix of the attribute has no
8863 scalar parts (e.g., if the prefix is of an access type, an interface type,
8864 an undiscriminated task type, or an undiscriminated protected type).
8866 @node Attribute VADS_Size
8867 @unnumberedsec Attribute VADS_Size
8868 @cindex @code{Size}, VADS compatibility
8871 The @code{'VADS_Size} attribute is intended to make it easier to port
8872 legacy code which relies on the semantics of @code{'Size} as implemented
8873 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
8874 same semantic interpretation. In particular, @code{'VADS_Size} applied
8875 to a predefined or other primitive type with no Size clause yields the
8876 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
8877 typical machines). In addition @code{'VADS_Size} applied to an object
8878 gives the result that would be obtained by applying the attribute to
8879 the corresponding type.
8881 @node Attribute Value_Size
8882 @unnumberedsec Attribute Value_Size
8883 @cindex @code{Size}, setting for not-first subtype
8885 @code{@var{type}'Value_Size} is the number of bits required to represent
8886 a value of the given subtype. It is the same as @code{@var{type}'Size},
8887 but, unlike @code{Size}, may be set for non-first subtypes.
8889 @node Attribute Wchar_T_Size
8890 @unnumberedsec Attribute Wchar_T_Size
8891 @findex Wchar_T_Size
8892 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
8893 prefix) provides the size in bits of the C @code{wchar_t} type
8894 primarily for constructing the definition of this type in
8895 package @code{Interfaces.C}.
8897 @node Attribute Word_Size
8898 @unnumberedsec Attribute Word_Size
8900 @code{Standard'Word_Size} (@code{Standard} is the only permissible
8901 prefix) provides the value @code{System.Word_Size}.
8903 @node Standard and Implementation Defined Restrictions
8904 @chapter Standard and Implementation Defined Restrictions
8907 All RM defined Restriction identifiers are implemented:
8910 @item language-defined restrictions (see 13.12.1)
8911 @item tasking restrictions (see D.7)
8912 @item high integrity restrictions (see H.4)
8916 GNAT implements additional restriction identifiers. All restrictions, whether
8917 language defined or GNAT-specific, are listed in the following.
8920 * Partition-Wide Restrictions::
8921 * Program Unit Level Restrictions::
8924 @node Partition-Wide Restrictions
8925 @section Partition-Wide Restrictions
8927 There are two separate lists of restriction identifiers. The first
8928 set requires consistency throughout a partition (in other words, if the
8929 restriction identifier is used for any compilation unit in the partition,
8930 then all compilation units in the partition must obey the restriction).
8933 * Immediate_Reclamation::
8934 * Max_Asynchronous_Select_Nesting::
8935 * Max_Entry_Queue_Length::
8936 * Max_Protected_Entries::
8937 * Max_Select_Alternatives::
8938 * Max_Storage_At_Blocking::
8939 * Max_Task_Entries::
8941 * No_Abort_Statements::
8942 * No_Access_Parameter_Allocators::
8943 * No_Access_Subprograms::
8945 * No_Anonymous_Allocators::
8948 * No_Default_Initialization::
8951 * No_Direct_Boolean_Operators::
8953 * No_Dispatching_Calls::
8954 * No_Dynamic_Attachment::
8955 * No_Dynamic_Priorities::
8956 * No_Entry_Calls_In_Elaboration_Code::
8957 * No_Enumeration_Maps::
8958 * No_Exception_Handlers::
8959 * No_Exception_Propagation::
8960 * No_Exception_Registration::
8964 * No_Floating_Point::
8965 * No_Implicit_Conditionals::
8966 * No_Implicit_Dynamic_Code::
8967 * No_Implicit_Heap_Allocations::
8968 * No_Implicit_Loops::
8969 * No_Initialize_Scalars::
8971 * No_Local_Allocators::
8972 * No_Local_Protected_Objects::
8973 * No_Local_Timing_Events::
8974 * No_Nested_Finalization::
8975 * No_Protected_Type_Allocators::
8976 * No_Protected_Types::
8979 * No_Relative_Delay::
8980 * No_Requeue_Statements::
8981 * No_Secondary_Stack::
8982 * No_Select_Statements::
8983 * No_Specific_Termination_Handlers::
8984 * No_Specification_of_Aspect::
8985 * No_Standard_Allocators_After_Elaboration::
8986 * No_Standard_Storage_Pools::
8987 * No_Stream_Optimizations::
8989 * No_Task_Allocators::
8990 * No_Task_Attributes_Package::
8991 * No_Task_Hierarchy::
8992 * No_Task_Termination::
8994 * No_Terminate_Alternatives::
8995 * No_Unchecked_Access::
8997 * Static_Priorities::
8998 * Static_Storage_Size::
9001 @node Immediate_Reclamation
9002 @unnumberedsubsec Immediate_Reclamation
9003 @findex Immediate_Reclamation
9004 [RM H.4] This restriction ensures that, except for storage occupied by
9005 objects created by allocators and not deallocated via unchecked
9006 deallocation, any storage reserved at run time for an object is
9007 immediately reclaimed when the object no longer exists.
9009 @node Max_Asynchronous_Select_Nesting
9010 @unnumberedsubsec Max_Asynchronous_Select_Nesting
9011 @findex Max_Asynchronous_Select_Nesting
9012 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
9013 selects. Violations of this restriction with a value of zero are
9014 detected at compile time. Violations of this restriction with values
9015 other than zero cause Storage_Error to be raised.
9017 @node Max_Entry_Queue_Length
9018 @unnumberedsubsec Max_Entry_Queue_Length
9019 @findex Max_Entry_Queue_Length
9020 [RM D.7] This restriction is a declaration that any protected entry compiled in
9021 the scope of the restriction has at most the specified number of
9022 tasks waiting on the entry at any one time, and so no queue is required.
9023 Note that this restriction is checked at run time. Violation of this
9024 restriction results in the raising of Program_Error exception at the point of
9027 @findex Max_Entry_Queue_Depth
9028 The restriction @code{Max_Entry_Queue_Depth} is recognized as a
9029 synonym for @code{Max_Entry_Queue_Length}. This is retained for historical
9030 compatibility purposes (and a warning will be generated for its use if
9031 warnings on obsolescent features are activated).
9033 @node Max_Protected_Entries
9034 @unnumberedsubsec Max_Protected_Entries
9035 @findex Max_Protected_Entries
9036 [RM D.7] Specifies the maximum number of entries per protected type. The
9037 bounds of every entry family of a protected unit shall be static, or shall be
9038 defined by a discriminant of a subtype whose corresponding bound is static.
9040 @node Max_Select_Alternatives
9041 @unnumberedsubsec Max_Select_Alternatives
9042 @findex Max_Select_Alternatives
9043 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
9045 @node Max_Storage_At_Blocking
9046 @unnumberedsubsec Max_Storage_At_Blocking
9047 @findex Max_Storage_At_Blocking
9048 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
9049 Storage_Size that can be retained by a blocked task. A violation of this
9050 restriction causes Storage_Error to be raised.
9052 @node Max_Task_Entries
9053 @unnumberedsubsec Max_Task_Entries
9054 @findex Max_Task_Entries
9055 [RM D.7] Specifies the maximum number of entries
9056 per task. The bounds of every entry family
9057 of a task unit shall be static, or shall be
9058 defined by a discriminant of a subtype whose
9059 corresponding bound is static.
9062 @unnumberedsubsec Max_Tasks
9064 [RM D.7] Specifies the maximum number of task that may be created, not
9065 counting the creation of the environment task. Violations of this
9066 restriction with a value of zero are detected at compile
9067 time. Violations of this restriction with values other than zero cause
9068 Storage_Error to be raised.
9070 @node No_Abort_Statements
9071 @unnumberedsubsec No_Abort_Statements
9072 @findex No_Abort_Statements
9073 [RM D.7] There are no abort_statements, and there are
9074 no calls to Task_Identification.Abort_Task.
9076 @node No_Access_Parameter_Allocators
9077 @unnumberedsubsec No_Access_Parameter_Allocators
9078 @findex No_Access_Parameter_Allocators
9079 [RM H.4] This restriction ensures at compile time that there are no
9080 occurrences of an allocator as the actual parameter to an access
9083 @node No_Access_Subprograms
9084 @unnumberedsubsec No_Access_Subprograms
9085 @findex No_Access_Subprograms
9086 [RM H.4] This restriction ensures at compile time that there are no
9087 declarations of access-to-subprogram types.
9090 @unnumberedsubsec No_Allocators
9091 @findex No_Allocators
9092 [RM H.4] This restriction ensures at compile time that there are no
9093 occurrences of an allocator.
9095 @node No_Anonymous_Allocators
9096 @unnumberedsubsec No_Anonymous_Allocators
9097 @findex No_Anonymous_Allocators
9098 [RM H.4] This restriction ensures at compile time that there are no
9099 occurrences of an allocator of anonymous access type.
9102 @unnumberedsubsec No_Calendar
9104 [GNAT] This restriction ensures at compile time that there is no implicit or
9105 explicit dependence on the package @code{Ada.Calendar}.
9107 @node No_Coextensions
9108 @unnumberedsubsec No_Coextensions
9109 @findex No_Coextensions
9110 [RM H.4] This restriction ensures at compile time that there are no
9111 coextensions. See 3.10.2.
9113 @node No_Default_Initialization
9114 @unnumberedsubsec No_Default_Initialization
9115 @findex No_Default_Initialization
9117 [GNAT] This restriction prohibits any instance of default initialization
9118 of variables. The binder implements a consistency rule which prevents
9119 any unit compiled without the restriction from with'ing a unit with the
9120 restriction (this allows the generation of initialization procedures to
9121 be skipped, since you can be sure that no call is ever generated to an
9122 initialization procedure in a unit with the restriction active). If used
9123 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
9124 is to prohibit all cases of variables declared without a specific
9125 initializer (including the case of OUT scalar parameters).
9128 @unnumberedsubsec No_Delay
9130 [RM H.4] This restriction ensures at compile time that there are no
9131 delay statements and no dependences on package Calendar.
9134 @unnumberedsubsec No_Dependence
9135 @findex No_Dependence
9136 [RM 13.12.1] This restriction checks at compile time that there are no
9137 dependence on a library unit.
9139 @node No_Direct_Boolean_Operators
9140 @unnumberedsubsec No_Direct_Boolean_Operators
9141 @findex No_Direct_Boolean_Operators
9142 [GNAT] This restriction ensures that no logical operators (and/or/xor)
9143 are used on operands of type Boolean (or any type derived from Boolean).
9144 This is intended for use in safety critical programs where the certification
9145 protocol requires the use of short-circuit (and then, or else) forms for all
9146 composite boolean operations.
9149 @unnumberedsubsec No_Dispatch
9151 [RM H.4] This restriction ensures at compile time that there are no
9152 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
9154 @node No_Dispatching_Calls
9155 @unnumberedsubsec No_Dispatching_Calls
9156 @findex No_Dispatching_Calls
9157 [GNAT] This restriction ensures at compile time that the code generated by the
9158 compiler involves no dispatching calls. The use of this restriction allows the
9159 safe use of record extensions, classwide membership tests and other classwide
9160 features not involving implicit dispatching. This restriction ensures that
9161 the code contains no indirect calls through a dispatching mechanism. Note that
9162 this includes internally-generated calls created by the compiler, for example
9163 in the implementation of class-wide objects assignments. The
9164 membership test is allowed in the presence of this restriction, because its
9165 implementation requires no dispatching.
9166 This restriction is comparable to the official Ada restriction
9167 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
9168 all classwide constructs that do not imply dispatching.
9169 The following example indicates constructs that violate this restriction.
9173 type T is tagged record
9176 procedure P (X : T);
9178 type DT is new T with record
9179 More_Data : Natural;
9181 procedure Q (X : DT);
9185 procedure Example is
9186 procedure Test (O : T'Class) is
9187 N : Natural := O'Size;-- Error: Dispatching call
9188 C : T'Class := O; -- Error: implicit Dispatching Call
9190 if O in DT'Class then -- OK : Membership test
9191 Q (DT (O)); -- OK : Type conversion plus direct call
9193 P (O); -- Error: Dispatching call
9199 P (Obj); -- OK : Direct call
9200 P (T (Obj)); -- OK : Type conversion plus direct call
9201 P (T'Class (Obj)); -- Error: Dispatching call
9203 Test (Obj); -- OK : Type conversion
9205 if Obj in T'Class then -- OK : Membership test
9211 @node No_Dynamic_Attachment
9212 @unnumberedsubsec No_Dynamic_Attachment
9213 @findex No_Dynamic_Attachment
9214 [RM D.7] This restriction ensures that there is no call to any of the
9215 operations defined in package Ada.Interrupts
9216 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
9217 Detach_Handler, and Reference).
9219 @findex No_Dynamic_Interrupts
9220 The restriction @code{No_Dynamic_Interrupts} is recognized as a
9221 synonym for @code{No_Dynamic_Attachment}. This is retained for historical
9222 compatibility purposes (and a warning will be generated for its use if
9223 warnings on obsolescent features are activated).
9225 @node No_Dynamic_Priorities
9226 @unnumberedsubsec No_Dynamic_Priorities
9227 @findex No_Dynamic_Priorities
9228 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
9230 @node No_Entry_Calls_In_Elaboration_Code
9231 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
9232 @findex No_Entry_Calls_In_Elaboration_Code
9233 [GNAT] This restriction ensures at compile time that no task or protected entry
9234 calls are made during elaboration code. As a result of the use of this
9235 restriction, the compiler can assume that no code past an accept statement
9236 in a task can be executed at elaboration time.
9238 @node No_Enumeration_Maps
9239 @unnumberedsubsec No_Enumeration_Maps
9240 @findex No_Enumeration_Maps
9241 [GNAT] This restriction ensures at compile time that no operations requiring
9242 enumeration maps are used (that is Image and Value attributes applied
9243 to enumeration types).
9245 @node No_Exception_Handlers
9246 @unnumberedsubsec No_Exception_Handlers
9247 @findex No_Exception_Handlers
9248 [GNAT] This restriction ensures at compile time that there are no explicit
9249 exception handlers. It also indicates that no exception propagation will
9250 be provided. In this mode, exceptions may be raised but will result in
9251 an immediate call to the last chance handler, a routine that the user
9252 must define with the following profile:
9254 @smallexample @c ada
9255 procedure Last_Chance_Handler
9256 (Source_Location : System.Address; Line : Integer);
9257 pragma Export (C, Last_Chance_Handler,
9258 "__gnat_last_chance_handler");
9261 The parameter is a C null-terminated string representing a message to be
9262 associated with the exception (typically the source location of the raise
9263 statement generated by the compiler). The Line parameter when nonzero
9264 represents the line number in the source program where the raise occurs.
9266 @node No_Exception_Propagation
9267 @unnumberedsubsec No_Exception_Propagation
9268 @findex No_Exception_Propagation
9269 [GNAT] This restriction guarantees that exceptions are never propagated
9270 to an outer subprogram scope. The only case in which an exception may
9271 be raised is when the handler is statically in the same subprogram, so
9272 that the effect of a raise is essentially like a goto statement. Any
9273 other raise statement (implicit or explicit) will be considered
9274 unhandled. Exception handlers are allowed, but may not contain an
9275 exception occurrence identifier (exception choice). In addition, use of
9276 the package GNAT.Current_Exception is not permitted, and reraise
9277 statements (raise with no operand) are not permitted.
9279 @node No_Exception_Registration
9280 @unnumberedsubsec No_Exception_Registration
9281 @findex No_Exception_Registration
9282 [GNAT] This restriction ensures at compile time that no stream operations for
9283 types Exception_Id or Exception_Occurrence are used. This also makes it
9284 impossible to pass exceptions to or from a partition with this restriction
9285 in a distributed environment. If this exception is active, then the generated
9286 code is simplified by omitting the otherwise-required global registration
9287 of exceptions when they are declared.
9290 @unnumberedsubsec No_Exceptions
9291 @findex No_Exceptions
9292 [RM H.4] This restriction ensures at compile time that there are no
9293 raise statements and no exception handlers.
9295 @node No_Finalization
9296 @unnumberedsubsec No_Finalization
9297 @findex No_Finalization
9298 [GNAT] This restriction disables the language features described in
9299 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
9300 performed by the compiler to support these features. The following types
9301 are no longer considered controlled when this restriction is in effect:
9304 @code{Ada.Finalization.Controlled}
9306 @code{Ada.Finalization.Limited_Controlled}
9308 Derivations from @code{Controlled} or @code{Limited_Controlled}
9316 Array and record types with controlled components
9318 The compiler no longer generates code to initialize, finalize or adjust an
9319 object or a nested component, either declared on the stack or on the heap. The
9320 deallocation of a controlled object no longer finalizes its contents.
9322 @node No_Fixed_Point
9323 @unnumberedsubsec No_Fixed_Point
9324 @findex No_Fixed_Point
9325 [RM H.4] This restriction ensures at compile time that there are no
9326 occurrences of fixed point types and operations.
9328 @node No_Floating_Point
9329 @unnumberedsubsec No_Floating_Point
9330 @findex No_Floating_Point
9331 [RM H.4] This restriction ensures at compile time that there are no
9332 occurrences of floating point types and operations.
9334 @node No_Implicit_Conditionals
9335 @unnumberedsubsec No_Implicit_Conditionals
9336 @findex No_Implicit_Conditionals
9337 [GNAT] This restriction ensures that the generated code does not contain any
9338 implicit conditionals, either by modifying the generated code where possible,
9339 or by rejecting any construct that would otherwise generate an implicit
9340 conditional. Note that this check does not include run time constraint
9341 checks, which on some targets may generate implicit conditionals as
9342 well. To control the latter, constraint checks can be suppressed in the
9343 normal manner. Constructs generating implicit conditionals include comparisons
9344 of composite objects and the Max/Min attributes.
9346 @node No_Implicit_Dynamic_Code
9347 @unnumberedsubsec No_Implicit_Dynamic_Code
9348 @findex No_Implicit_Dynamic_Code
9350 [GNAT] This restriction prevents the compiler from building ``trampolines''.
9351 This is a structure that is built on the stack and contains dynamic
9352 code to be executed at run time. On some targets, a trampoline is
9353 built for the following features: @code{Access},
9354 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
9355 nested task bodies; primitive operations of nested tagged types.
9356 Trampolines do not work on machines that prevent execution of stack
9357 data. For example, on windows systems, enabling DEP (data execution
9358 protection) will cause trampolines to raise an exception.
9359 Trampolines are also quite slow at run time.
9361 On many targets, trampolines have been largely eliminated. Look at the
9362 version of system.ads for your target --- if it has
9363 Always_Compatible_Rep equal to False, then trampolines are largely
9364 eliminated. In particular, a trampoline is built for the following
9365 features: @code{Address} of a nested subprogram;
9366 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
9367 but only if pragma Favor_Top_Level applies, or the access type has a
9368 foreign-language convention; primitive operations of nested tagged
9371 @node No_Implicit_Heap_Allocations
9372 @unnumberedsubsec No_Implicit_Heap_Allocations
9373 @findex No_Implicit_Heap_Allocations
9374 [RM D.7] No constructs are allowed to cause implicit heap allocation.
9376 @node No_Implicit_Loops
9377 @unnumberedsubsec No_Implicit_Loops
9378 @findex No_Implicit_Loops
9379 [GNAT] This restriction ensures that the generated code does not contain any
9380 implicit @code{for} loops, either by modifying
9381 the generated code where possible,
9382 or by rejecting any construct that would otherwise generate an implicit
9383 @code{for} loop. If this restriction is active, it is possible to build
9384 large array aggregates with all static components without generating an
9385 intermediate temporary, and without generating a loop to initialize individual
9386 components. Otherwise, a loop is created for arrays larger than about 5000
9389 @node No_Initialize_Scalars
9390 @unnumberedsubsec No_Initialize_Scalars
9391 @findex No_Initialize_Scalars
9392 [GNAT] This restriction ensures that no unit in the partition is compiled with
9393 pragma Initialize_Scalars. This allows the generation of more efficient
9394 code, and in particular eliminates dummy null initialization routines that
9395 are otherwise generated for some record and array types.
9398 @unnumberedsubsec No_IO
9400 [RM H.4] This restriction ensures at compile time that there are no
9401 dependences on any of the library units Sequential_IO, Direct_IO,
9402 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
9404 @node No_Local_Allocators
9405 @unnumberedsubsec No_Local_Allocators
9406 @findex No_Local_Allocators
9407 [RM H.4] This restriction ensures at compile time that there are no
9408 occurrences of an allocator in subprograms, generic subprograms, tasks,
9411 @node No_Local_Protected_Objects
9412 @unnumberedsubsec No_Local_Protected_Objects
9413 @findex No_Local_Protected_Objects
9414 [RM D.7] This restriction ensures at compile time that protected objects are
9415 only declared at the library level.
9417 @node No_Local_Timing_Events
9418 @unnumberedsubsec No_Local_Timing_Events
9419 @findex No_Local_Timing_Events
9420 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
9421 declared at the library level.
9423 @node No_Nested_Finalization
9424 @unnumberedsubsec No_Nested_Finalization
9425 @findex No_Nested_Finalization
9426 [RM D.7] All objects requiring finalization are declared at the library level.
9428 @node No_Protected_Type_Allocators
9429 @unnumberedsubsec No_Protected_Type_Allocators
9430 @findex No_Protected_Type_Allocators
9431 [RM D.7] This restriction ensures at compile time that there are no allocator
9432 expressions that attempt to allocate protected objects.
9434 @node No_Protected_Types
9435 @unnumberedsubsec No_Protected_Types
9436 @findex No_Protected_Types
9437 [RM H.4] This restriction ensures at compile time that there are no
9438 declarations of protected types or protected objects.
9441 @unnumberedsubsec No_Recursion
9442 @findex No_Recursion
9443 [RM H.4] A program execution is erroneous if a subprogram is invoked as
9444 part of its execution.
9447 @unnumberedsubsec No_Reentrancy
9448 @findex No_Reentrancy
9449 [RM H.4] A program execution is erroneous if a subprogram is executed by
9450 two tasks at the same time.
9452 @node No_Relative_Delay
9453 @unnumberedsubsec No_Relative_Delay
9454 @findex No_Relative_Delay
9455 [RM D.7] This restriction ensures at compile time that there are no delay
9456 relative statements and prevents expressions such as @code{delay 1.23;} from
9457 appearing in source code.
9459 @node No_Requeue_Statements
9460 @unnumberedsubsec No_Requeue_Statements
9461 @findex No_Requeue_Statements
9462 [RM D.7] This restriction ensures at compile time that no requeue statements
9463 are permitted and prevents keyword @code{requeue} from being used in source
9467 The restriction @code{No_Requeue} is recognized as a
9468 synonym for @code{No_Requeue_Statements}. This is retained for historical
9469 compatibility purposes (and a warning will be generated for its use if
9470 warnings on oNobsolescent features are activated).
9472 @node No_Secondary_Stack
9473 @unnumberedsubsec No_Secondary_Stack
9474 @findex No_Secondary_Stack
9475 [GNAT] This restriction ensures at compile time that the generated code
9476 does not contain any reference to the secondary stack. The secondary
9477 stack is used to implement functions returning unconstrained objects
9478 (arrays or records) on some targets.
9480 @node No_Select_Statements
9481 @unnumberedsubsec No_Select_Statements
9482 @findex No_Select_Statements
9483 [RM D.7] This restriction ensures at compile time no select statements of any
9484 kind are permitted, that is the keyword @code{select} may not appear.
9486 @node No_Specific_Termination_Handlers
9487 @unnumberedsubsec No_Specific_Termination_Handlers
9488 @findex No_Specific_Termination_Handlers
9489 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
9490 or to Ada.Task_Termination.Specific_Handler.
9492 @node No_Specification_of_Aspect
9493 @unnumberedsubsec No_Specification_of_Aspect
9494 @findex No_Specification_of_Aspect
9495 [RM 13.12.1] This restriction checks at compile time that no aspect
9496 specification, attribute definition clause, or pragma is given for a
9499 @node No_Standard_Allocators_After_Elaboration
9500 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
9501 @findex No_Standard_Allocators_After_Elaboration
9502 [RM D.7] Specifies that an allocator using a standard storage pool
9503 should never be evaluated at run time after the elaboration of the
9504 library items of the partition has completed. Otherwise, Storage_Error
9507 @node No_Standard_Storage_Pools
9508 @unnumberedsubsec No_Standard_Storage_Pools
9509 @findex No_Standard_Storage_Pools
9510 [GNAT] This restriction ensures at compile time that no access types
9511 use the standard default storage pool. Any access type declared must
9512 have an explicit Storage_Pool attribute defined specifying a
9513 user-defined storage pool.
9515 @node No_Stream_Optimizations
9516 @unnumberedsubsec No_Stream_Optimizations
9517 @findex No_Stream_Optimizations
9518 [GNAT] This restriction affects the performance of stream operations on types
9519 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
9520 compiler uses block reads and writes when manipulating @code{String} objects
9521 due to their supperior performance. When this restriction is in effect, the
9522 compiler performs all IO operations on a per-character basis.
9525 @unnumberedsubsec No_Streams
9527 [GNAT] This restriction ensures at compile/bind time that there are no
9528 stream objects created and no use of stream attributes.
9529 This restriction does not forbid dependences on the package
9530 @code{Ada.Streams}. So it is permissible to with
9531 @code{Ada.Streams} (or another package that does so itself)
9532 as long as no actual stream objects are created and no
9533 stream attributes are used.
9535 Note that the use of restriction allows optimization of tagged types,
9536 since they do not need to worry about dispatching stream operations.
9537 To take maximum advantage of this space-saving optimization, any
9538 unit declaring a tagged type should be compiled with the restriction,
9539 though this is not required.
9541 @node No_Task_Allocators
9542 @unnumberedsubsec No_Task_Allocators
9543 @findex No_Task_Allocators
9544 [RM D.7] There are no allocators for task types
9545 or types containing task subcomponents.
9547 @node No_Task_Attributes_Package
9548 @unnumberedsubsec No_Task_Attributes_Package
9549 @findex No_Task_Attributes_Package
9550 [GNAT] This restriction ensures at compile time that there are no implicit or
9551 explicit dependencies on the package @code{Ada.Task_Attributes}.
9553 @findex No_Task_Attributes
9554 The restriction @code{No_Task_Attributes} is recognized as a synonym
9555 for @code{No_Task_Attributes_Package}. This is retained for historical
9556 compatibility purposes (and a warning will be generated for its use if
9557 warnings on obsolescent features are activated).
9559 @node No_Task_Hierarchy
9560 @unnumberedsubsec No_Task_Hierarchy
9561 @findex No_Task_Hierarchy
9562 [RM D.7] All (non-environment) tasks depend
9563 directly on the environment task of the partition.
9565 @node No_Task_Termination
9566 @unnumberedsubsec No_Task_Termination
9567 @findex No_Task_Termination
9568 [RM D.7] Tasks which terminate are erroneous.
9571 @unnumberedsubsec No_Tasking
9573 [GNAT] This restriction prevents the declaration of tasks or task types
9574 throughout the partition. It is similar in effect to the use of
9575 @code{Max_Tasks => 0} except that violations are caught at compile time
9576 and cause an error message to be output either by the compiler or
9579 @node No_Terminate_Alternatives
9580 @unnumberedsubsec No_Terminate_Alternatives
9581 @findex No_Terminate_Alternatives
9582 [RM D.7] There are no selective accepts with terminate alternatives.
9584 @node No_Unchecked_Access
9585 @unnumberedsubsec No_Unchecked_Access
9586 @findex No_Unchecked_Access
9587 [RM H.4] This restriction ensures at compile time that there are no
9588 occurrences of the Unchecked_Access attribute.
9590 @node Simple_Barriers
9591 @unnumberedsubsec Simple_Barriers
9592 @findex Simple_Barriers
9593 [RM D.7] This restriction ensures at compile time that barriers in entry
9594 declarations for protected types are restricted to either static boolean
9595 expressions or references to simple boolean variables defined in the private
9596 part of the protected type. No other form of entry barriers is permitted.
9598 @findex Boolean_Entry_Barriers
9599 The restriction @code{Boolean_Entry_Barriers} is recognized as a
9600 synonym for @code{Simple_Barriers}. This is retained for historical
9601 compatibility purposes (and a warning will be generated for its use if
9602 warnings on obsolescent features are activated).
9604 @node Static_Priorities
9605 @unnumberedsubsec Static_Priorities
9606 @findex Static_Priorities
9607 [GNAT] This restriction ensures at compile time that all priority expressions
9608 are static, and that there are no dependences on the package
9609 @code{Ada.Dynamic_Priorities}.
9611 @node Static_Storage_Size
9612 @unnumberedsubsec Static_Storage_Size
9613 @findex Static_Storage_Size
9614 [GNAT] This restriction ensures at compile time that any expression appearing
9615 in a Storage_Size pragma or attribute definition clause is static.
9617 @node Program Unit Level Restrictions
9618 @section Program Unit Level Restrictions
9621 The second set of restriction identifiers
9622 does not require partition-wide consistency.
9623 The restriction may be enforced for a single
9624 compilation unit without any effect on any of the
9625 other compilation units in the partition.
9628 * No_Elaboration_Code::
9630 * No_Implementation_Aspect_Specifications::
9631 * No_Implementation_Attributes::
9632 * No_Implementation_Identifiers::
9633 * No_Implementation_Pragmas::
9634 * No_Implementation_Restrictions::
9635 * No_Implementation_Units::
9636 * No_Implicit_Aliasing::
9637 * No_Obsolescent_Features::
9638 * No_Wide_Characters::
9642 @node No_Elaboration_Code
9643 @unnumberedsubsec No_Elaboration_Code
9644 @findex No_Elaboration_Code
9645 [GNAT] This restriction ensures at compile time that no elaboration code is
9646 generated. Note that this is not the same condition as is enforced
9647 by pragma @code{Preelaborate}. There are cases in which pragma
9648 @code{Preelaborate} still permits code to be generated (e.g.@: code
9649 to initialize a large array to all zeroes), and there are cases of units
9650 which do not meet the requirements for pragma @code{Preelaborate},
9651 but for which no elaboration code is generated. Generally, it is
9652 the case that preelaborable units will meet the restrictions, with
9653 the exception of large aggregates initialized with an others_clause,
9654 and exception declarations (which generate calls to a run-time
9655 registry procedure). This restriction is enforced on
9656 a unit by unit basis, it need not be obeyed consistently
9657 throughout a partition.
9659 In the case of aggregates with others, if the aggregate has a dynamic
9660 size, there is no way to eliminate the elaboration code (such dynamic
9661 bounds would be incompatible with @code{Preelaborate} in any case). If
9662 the bounds are static, then use of this restriction actually modifies
9663 the code choice of the compiler to avoid generating a loop, and instead
9664 generate the aggregate statically if possible, no matter how many times
9665 the data for the others clause must be repeatedly generated.
9667 It is not possible to precisely document
9668 the constructs which are compatible with this restriction, since,
9669 unlike most other restrictions, this is not a restriction on the
9670 source code, but a restriction on the generated object code. For
9671 example, if the source contains a declaration:
9674 Val : constant Integer := X;
9678 where X is not a static constant, it may be possible, depending
9679 on complex optimization circuitry, for the compiler to figure
9680 out the value of X at compile time, in which case this initialization
9681 can be done by the loader, and requires no initialization code. It
9682 is not possible to document the precise conditions under which the
9683 optimizer can figure this out.
9685 Note that this the implementation of this restriction requires full
9686 code generation. If it is used in conjunction with "semantics only"
9687 checking, then some cases of violations may be missed.
9689 @node No_Entry_Queue
9690 @unnumberedsubsec No_Entry_Queue
9691 @findex No_Entry_Queue
9692 [GNAT] This restriction is a declaration that any protected entry compiled in
9693 the scope of the restriction has at most one task waiting on the entry
9694 at any one time, and so no queue is required. This restriction is not
9695 checked at compile time. A program execution is erroneous if an attempt
9696 is made to queue a second task on such an entry.
9698 @node No_Implementation_Aspect_Specifications
9699 @unnumberedsubsec No_Implementation_Aspect_Specifications
9700 @findex No_Implementation_Aspect_Specifications
9701 [RM 13.12.1] This restriction checks at compile time that no
9702 GNAT-defined aspects are present. With this restriction, the only
9703 aspects that can be used are those defined in the Ada Reference Manual.
9705 @node No_Implementation_Attributes
9706 @unnumberedsubsec No_Implementation_Attributes
9707 @findex No_Implementation_Attributes
9708 [RM 13.12.1] This restriction checks at compile time that no
9709 GNAT-defined attributes are present. With this restriction, the only
9710 attributes that can be used are those defined in the Ada Reference
9713 @node No_Implementation_Identifiers
9714 @unnumberedsubsec No_Implementation_Identifiers
9715 @findex No_Implementation_Identifiers
9716 [RM 13.12.1] This restriction checks at compile time that no
9717 implementation-defined identifiers (marked with pragma Implementation_Defined)
9718 occur within language-defined packages.
9720 @node No_Implementation_Pragmas
9721 @unnumberedsubsec No_Implementation_Pragmas
9722 @findex No_Implementation_Pragmas
9723 [RM 13.12.1] This restriction checks at compile time that no
9724 GNAT-defined pragmas are present. With this restriction, the only
9725 pragmas that can be used are those defined in the Ada Reference Manual.
9727 @node No_Implementation_Restrictions
9728 @unnumberedsubsec No_Implementation_Restrictions
9729 @findex No_Implementation_Restrictions
9730 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
9731 identifiers (other than @code{No_Implementation_Restrictions} itself)
9732 are present. With this restriction, the only other restriction identifiers
9733 that can be used are those defined in the Ada Reference Manual.
9735 @node No_Implementation_Units
9736 @unnumberedsubsec No_Implementation_Units
9737 @findex No_Implementation_Units
9738 [RM 13.12.1] This restriction checks at compile time that there is no
9739 mention in the context clause of any implementation-defined descendants
9740 of packages Ada, Interfaces, or System.
9742 @node No_Implicit_Aliasing
9743 @unnumberedsubsec No_Implicit_Aliasing
9744 @findex No_Implicit_Aliasing
9745 [GNAT] This restriction, which is not required to be partition-wide consistent,
9746 requires an explicit aliased keyword for an object to which 'Access,
9747 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
9748 the 'Unrestricted_Access attribute for objects. Note: the reason that
9749 Unrestricted_Access is forbidden is that it would require the prefix
9750 to be aliased, and in such cases, it can always be replaced by
9751 the standard attribute Unchecked_Access which is preferable.
9753 @node No_Obsolescent_Features
9754 @unnumberedsubsec No_Obsolescent_Features
9755 @findex No_Obsolescent_Features
9756 [RM 13.12.1] This restriction checks at compile time that no obsolescent
9757 features are used, as defined in Annex J of the Ada Reference Manual.
9759 @node No_Wide_Characters
9760 @unnumberedsubsec No_Wide_Characters
9761 @findex No_Wide_Characters
9762 [GNAT] This restriction ensures at compile time that no uses of the types
9763 @code{Wide_Character} or @code{Wide_String} or corresponding wide
9765 appear, and that no wide or wide wide string or character literals
9766 appear in the program (that is literals representing characters not in
9767 type @code{Character}).
9770 @unnumberedsubsec SPARK_05
9772 [GNAT] This restriction checks at compile time that some constructs
9773 forbidden in SPARK 2005 are not present. Error messages related to
9774 SPARK restriction have the form:
9777 The restriction @code{SPARK} is recognized as a
9778 synonym for @code{SPARK_05}. This is retained for historical
9779 compatibility purposes (and an unconditional warning will be generated
9780 for its use, advising replacement by @code{SPARK}.
9783 violation of restriction "SPARK" at <file>
9787 This is not a replacement for the semantic checks performed by the
9788 SPARK Examiner tool, as the compiler only deals currently with code,
9789 not at all with SPARK 2005 annotations and does not guarantee catching all
9790 cases of constructs forbidden by SPARK 2005.
9792 Thus it may well be the case that code which passes the compiler with
9793 the SPARK restriction is rejected by the SPARK Examiner, e.g. due to
9794 the different visibility rules of the Examiner based on SPARK 2005
9795 @code{inherit} annotations.
9797 This restriction can be useful in providing an initial filter for code
9798 developed using SPARK 2005, or in examining legacy code to see how far
9799 it is from meeting SPARK restrictions.
9801 Note that if a unit is compiled in Ada 95 mode with SPARK restriction,
9802 violations will be reported for constructs forbidden in SPARK 95,
9803 instead of SPARK 2005.
9805 @c ------------------------
9806 @node Implementation Advice
9807 @chapter Implementation Advice
9809 The main text of the Ada Reference Manual describes the required
9810 behavior of all Ada compilers, and the GNAT compiler conforms to
9813 In addition, there are sections throughout the Ada Reference Manual headed
9814 by the phrase ``Implementation advice''. These sections are not normative,
9815 i.e., they do not specify requirements that all compilers must
9816 follow. Rather they provide advice on generally desirable behavior. You
9817 may wonder why they are not requirements. The most typical answer is
9818 that they describe behavior that seems generally desirable, but cannot
9819 be provided on all systems, or which may be undesirable on some systems.
9821 As far as practical, GNAT follows the implementation advice sections in
9822 the Ada Reference Manual. This chapter contains a table giving the
9823 reference manual section number, paragraph number and several keywords
9824 for each advice. Each entry consists of the text of the advice followed
9825 by the GNAT interpretation of this advice. Most often, this simply says
9826 ``followed'', which means that GNAT follows the advice. However, in a
9827 number of cases, GNAT deliberately deviates from this advice, in which
9828 case the text describes what GNAT does and why.
9830 @cindex Error detection
9831 @unnumberedsec 1.1.3(20): Error Detection
9834 If an implementation detects the use of an unsupported Specialized Needs
9835 Annex feature at run time, it should raise @code{Program_Error} if
9838 Not relevant. All specialized needs annex features are either supported,
9839 or diagnosed at compile time.
9842 @unnumberedsec 1.1.3(31): Child Units
9845 If an implementation wishes to provide implementation-defined
9846 extensions to the functionality of a language-defined library unit, it
9847 should normally do so by adding children to the library unit.
9851 @cindex Bounded errors
9852 @unnumberedsec 1.1.5(12): Bounded Errors
9855 If an implementation detects a bounded error or erroneous
9856 execution, it should raise @code{Program_Error}.
9858 Followed in all cases in which the implementation detects a bounded
9859 error or erroneous execution. Not all such situations are detected at
9863 @unnumberedsec 2.8(16): Pragmas
9866 Normally, implementation-defined pragmas should have no semantic effect
9867 for error-free programs; that is, if the implementation-defined pragmas
9868 are removed from a working program, the program should still be legal,
9869 and should still have the same semantics.
9871 The following implementation defined pragmas are exceptions to this
9883 @item CPP_Constructor
9887 @item Interface_Name
9889 @item Machine_Attribute
9891 @item Unimplemented_Unit
9893 @item Unchecked_Union
9898 In each of the above cases, it is essential to the purpose of the pragma
9899 that this advice not be followed. For details see the separate section
9900 on implementation defined pragmas.
9902 @unnumberedsec 2.8(17-19): Pragmas
9905 Normally, an implementation should not define pragmas that can
9906 make an illegal program legal, except as follows:
9910 A pragma used to complete a declaration, such as a pragma @code{Import};
9914 A pragma used to configure the environment by adding, removing, or
9915 replacing @code{library_items}.
9917 See response to paragraph 16 of this same section.
9919 @cindex Character Sets
9920 @cindex Alternative Character Sets
9921 @unnumberedsec 3.5.2(5): Alternative Character Sets
9924 If an implementation supports a mode with alternative interpretations
9925 for @code{Character} and @code{Wide_Character}, the set of graphic
9926 characters of @code{Character} should nevertheless remain a proper
9927 subset of the set of graphic characters of @code{Wide_Character}. Any
9928 character set ``localizations'' should be reflected in the results of
9929 the subprograms defined in the language-defined package
9930 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
9931 an alternative interpretation of @code{Character}, the implementation should
9932 also support a corresponding change in what is a legal
9933 @code{identifier_letter}.
9935 Not all wide character modes follow this advice, in particular the JIS
9936 and IEC modes reflect standard usage in Japan, and in these encoding,
9937 the upper half of the Latin-1 set is not part of the wide-character
9938 subset, since the most significant bit is used for wide character
9939 encoding. However, this only applies to the external forms. Internally
9940 there is no such restriction.
9942 @cindex Integer types
9943 @unnumberedsec 3.5.4(28): Integer Types
9947 An implementation should support @code{Long_Integer} in addition to
9948 @code{Integer} if the target machine supports 32-bit (or longer)
9949 arithmetic. No other named integer subtypes are recommended for package
9950 @code{Standard}. Instead, appropriate named integer subtypes should be
9951 provided in the library package @code{Interfaces} (see B.2).
9953 @code{Long_Integer} is supported. Other standard integer types are supported
9954 so this advice is not fully followed. These types
9955 are supported for convenient interface to C, and so that all hardware
9956 types of the machine are easily available.
9957 @unnumberedsec 3.5.4(29): Integer Types
9961 An implementation for a two's complement machine should support
9962 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
9963 implementation should support a non-binary modules up to @code{Integer'Last}.
9967 @cindex Enumeration values
9968 @unnumberedsec 3.5.5(8): Enumeration Values
9971 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
9972 subtype, if the value of the operand does not correspond to the internal
9973 code for any enumeration literal of its type (perhaps due to an
9974 un-initialized variable), then the implementation should raise
9975 @code{Program_Error}. This is particularly important for enumeration
9976 types with noncontiguous internal codes specified by an
9977 enumeration_representation_clause.
9982 @unnumberedsec 3.5.7(17): Float Types
9985 An implementation should support @code{Long_Float} in addition to
9986 @code{Float} if the target machine supports 11 or more digits of
9987 precision. No other named floating point subtypes are recommended for
9988 package @code{Standard}. Instead, appropriate named floating point subtypes
9989 should be provided in the library package @code{Interfaces} (see B.2).
9991 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
9992 former provides improved compatibility with other implementations
9993 supporting this type. The latter corresponds to the highest precision
9994 floating-point type supported by the hardware. On most machines, this
9995 will be the same as @code{Long_Float}, but on some machines, it will
9996 correspond to the IEEE extended form. The notable case is all ia32
9997 (x86) implementations, where @code{Long_Long_Float} corresponds to
9998 the 80-bit extended precision format supported in hardware on this
9999 processor. Note that the 128-bit format on SPARC is not supported,
10000 since this is a software rather than a hardware format.
10002 @cindex Multidimensional arrays
10003 @cindex Arrays, multidimensional
10004 @unnumberedsec 3.6.2(11): Multidimensional Arrays
10007 An implementation should normally represent multidimensional arrays in
10008 row-major order, consistent with the notation used for multidimensional
10009 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
10010 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
10011 column-major order should be used instead (see B.5, ``Interfacing with
10016 @findex Duration'Small
10017 @unnumberedsec 9.6(30-31): Duration'Small
10020 Whenever possible in an implementation, the value of @code{Duration'Small}
10021 should be no greater than 100 microseconds.
10023 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
10027 The time base for @code{delay_relative_statements} should be monotonic;
10028 it need not be the same time base as used for @code{Calendar.Clock}.
10032 @unnumberedsec 10.2.1(12): Consistent Representation
10035 In an implementation, a type declared in a pre-elaborated package should
10036 have the same representation in every elaboration of a given version of
10037 the package, whether the elaborations occur in distinct executions of
10038 the same program, or in executions of distinct programs or partitions
10039 that include the given version.
10041 Followed, except in the case of tagged types. Tagged types involve
10042 implicit pointers to a local copy of a dispatch table, and these pointers
10043 have representations which thus depend on a particular elaboration of the
10044 package. It is not easy to see how it would be possible to follow this
10045 advice without severely impacting efficiency of execution.
10047 @cindex Exception information
10048 @unnumberedsec 11.4.1(19): Exception Information
10051 @code{Exception_Message} by default and @code{Exception_Information}
10052 should produce information useful for
10053 debugging. @code{Exception_Message} should be short, about one
10054 line. @code{Exception_Information} can be long. @code{Exception_Message}
10055 should not include the
10056 @code{Exception_Name}. @code{Exception_Information} should include both
10057 the @code{Exception_Name} and the @code{Exception_Message}.
10059 Followed. For each exception that doesn't have a specified
10060 @code{Exception_Message}, the compiler generates one containing the location
10061 of the raise statement. This location has the form ``file:line'', where
10062 file is the short file name (without path information) and line is the line
10063 number in the file. Note that in the case of the Zero Cost Exception
10064 mechanism, these messages become redundant with the Exception_Information that
10065 contains a full backtrace of the calling sequence, so they are disabled.
10066 To disable explicitly the generation of the source location message, use the
10067 Pragma @code{Discard_Names}.
10069 @cindex Suppression of checks
10070 @cindex Checks, suppression of
10071 @unnumberedsec 11.5(28): Suppression of Checks
10074 The implementation should minimize the code executed for checks that
10075 have been suppressed.
10079 @cindex Representation clauses
10080 @unnumberedsec 13.1 (21-24): Representation Clauses
10083 The recommended level of support for all representation items is
10084 qualified as follows:
10088 An implementation need not support representation items containing
10089 non-static expressions, except that an implementation should support a
10090 representation item for a given entity if each non-static expression in
10091 the representation item is a name that statically denotes a constant
10092 declared before the entity.
10094 Followed. In fact, GNAT goes beyond the recommended level of support
10095 by allowing nonstatic expressions in some representation clauses even
10096 without the need to declare constants initialized with the values of
10100 @smallexample @c ada
10103 for Y'Address use X'Address;>>
10108 An implementation need not support a specification for the @code{Size}
10109 for a given composite subtype, nor the size or storage place for an
10110 object (including a component) of a given composite subtype, unless the
10111 constraints on the subtype and its composite subcomponents (if any) are
10112 all static constraints.
10114 Followed. Size Clauses are not permitted on non-static components, as
10119 An aliased component, or a component whose type is by-reference, should
10120 always be allocated at an addressable location.
10124 @cindex Packed types
10125 @unnumberedsec 13.2(6-8): Packed Types
10128 If a type is packed, then the implementation should try to minimize
10129 storage allocated to objects of the type, possibly at the expense of
10130 speed of accessing components, subject to reasonable complexity in
10131 addressing calculations.
10135 The recommended level of support pragma @code{Pack} is:
10137 For a packed record type, the components should be packed as tightly as
10138 possible subject to the Sizes of the component subtypes, and subject to
10139 any @code{record_representation_clause} that applies to the type; the
10140 implementation may, but need not, reorder components or cross aligned
10141 word boundaries to improve the packing. A component whose @code{Size} is
10142 greater than the word size may be allocated an integral number of words.
10144 Followed. Tight packing of arrays is supported for all component sizes
10145 up to 64-bits. If the array component size is 1 (that is to say, if
10146 the component is a boolean type or an enumeration type with two values)
10147 then values of the type are implicitly initialized to zero. This
10148 happens both for objects of the packed type, and for objects that have a
10149 subcomponent of the packed type.
10153 An implementation should support Address clauses for imported
10157 @cindex @code{Address} clauses
10158 @unnumberedsec 13.3(14-19): Address Clauses
10162 For an array @var{X}, @code{@var{X}'Address} should point at the first
10163 component of the array, and not at the array bounds.
10169 The recommended level of support for the @code{Address} attribute is:
10171 @code{@var{X}'Address} should produce a useful result if @var{X} is an
10172 object that is aliased or of a by-reference type, or is an entity whose
10173 @code{Address} has been specified.
10175 Followed. A valid address will be produced even if none of those
10176 conditions have been met. If necessary, the object is forced into
10177 memory to ensure the address is valid.
10181 An implementation should support @code{Address} clauses for imported
10188 Objects (including subcomponents) that are aliased or of a by-reference
10189 type should be allocated on storage element boundaries.
10195 If the @code{Address} of an object is specified, or it is imported or exported,
10196 then the implementation should not perform optimizations based on
10197 assumptions of no aliases.
10201 @cindex @code{Alignment} clauses
10202 @unnumberedsec 13.3(29-35): Alignment Clauses
10205 The recommended level of support for the @code{Alignment} attribute for
10208 An implementation should support specified Alignments that are factors
10209 and multiples of the number of storage elements per word, subject to the
10216 An implementation need not support specified @code{Alignment}s for
10217 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
10218 loaded and stored by available machine instructions.
10224 An implementation need not support specified @code{Alignment}s that are
10225 greater than the maximum @code{Alignment} the implementation ever returns by
10232 The recommended level of support for the @code{Alignment} attribute for
10235 Same as above, for subtypes, but in addition:
10241 For stand-alone library-level objects of statically constrained
10242 subtypes, the implementation should support all @code{Alignment}s
10243 supported by the target linker. For example, page alignment is likely to
10244 be supported for such objects, but not for subtypes.
10248 @cindex @code{Size} clauses
10249 @unnumberedsec 13.3(42-43): Size Clauses
10252 The recommended level of support for the @code{Size} attribute of
10255 A @code{Size} clause should be supported for an object if the specified
10256 @code{Size} is at least as large as its subtype's @code{Size}, and
10257 corresponds to a size in storage elements that is a multiple of the
10258 object's @code{Alignment} (if the @code{Alignment} is nonzero).
10262 @unnumberedsec 13.3(50-56): Size Clauses
10265 If the @code{Size} of a subtype is specified, and allows for efficient
10266 independent addressability (see 9.10) on the target architecture, then
10267 the @code{Size} of the following objects of the subtype should equal the
10268 @code{Size} of the subtype:
10270 Aliased objects (including components).
10276 @code{Size} clause on a composite subtype should not affect the
10277 internal layout of components.
10279 Followed. But note that this can be overridden by use of the implementation
10280 pragma Implicit_Packing in the case of packed arrays.
10284 The recommended level of support for the @code{Size} attribute of subtypes is:
10288 The @code{Size} (if not specified) of a static discrete or fixed point
10289 subtype should be the number of bits needed to represent each value
10290 belonging to the subtype using an unbiased representation, leaving space
10291 for a sign bit only if the subtype contains negative values. If such a
10292 subtype is a first subtype, then an implementation should support a
10293 specified @code{Size} for it that reflects this representation.
10299 For a subtype implemented with levels of indirection, the @code{Size}
10300 should include the size of the pointers, but not the size of what they
10305 @cindex @code{Component_Size} clauses
10306 @unnumberedsec 13.3(71-73): Component Size Clauses
10309 The recommended level of support for the @code{Component_Size}
10314 An implementation need not support specified @code{Component_Sizes} that are
10315 less than the @code{Size} of the component subtype.
10321 An implementation should support specified @code{Component_Size}s that
10322 are factors and multiples of the word size. For such
10323 @code{Component_Size}s, the array should contain no gaps between
10324 components. For other @code{Component_Size}s (if supported), the array
10325 should contain no gaps between components when packing is also
10326 specified; the implementation should forbid this combination in cases
10327 where it cannot support a no-gaps representation.
10331 @cindex Enumeration representation clauses
10332 @cindex Representation clauses, enumeration
10333 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
10336 The recommended level of support for enumeration representation clauses
10339 An implementation need not support enumeration representation clauses
10340 for boolean types, but should at minimum support the internal codes in
10341 the range @code{System.Min_Int.System.Max_Int}.
10345 @cindex Record representation clauses
10346 @cindex Representation clauses, records
10347 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
10350 The recommended level of support for
10351 @*@code{record_representation_clauses} is:
10353 An implementation should support storage places that can be extracted
10354 with a load, mask, shift sequence of machine code, and set with a load,
10355 shift, mask, store sequence, given the available machine instructions
10356 and run-time model.
10362 A storage place should be supported if its size is equal to the
10363 @code{Size} of the component subtype, and it starts and ends on a
10364 boundary that obeys the @code{Alignment} of the component subtype.
10370 If the default bit ordering applies to the declaration of a given type,
10371 then for a component whose subtype's @code{Size} is less than the word
10372 size, any storage place that does not cross an aligned word boundary
10373 should be supported.
10379 An implementation may reserve a storage place for the tag field of a
10380 tagged type, and disallow other components from overlapping that place.
10382 Followed. The storage place for the tag field is the beginning of the tagged
10383 record, and its size is Address'Size. GNAT will reject an explicit component
10384 clause for the tag field.
10388 An implementation need not support a @code{component_clause} for a
10389 component of an extension part if the storage place is not after the
10390 storage places of all components of the parent type, whether or not
10391 those storage places had been specified.
10393 Followed. The above advice on record representation clauses is followed,
10394 and all mentioned features are implemented.
10396 @cindex Storage place attributes
10397 @unnumberedsec 13.5.2(5): Storage Place Attributes
10400 If a component is represented using some form of pointer (such as an
10401 offset) to the actual data of the component, and this data is contiguous
10402 with the rest of the object, then the storage place attributes should
10403 reflect the place of the actual data, not the pointer. If a component is
10404 allocated discontinuously from the rest of the object, then a warning
10405 should be generated upon reference to one of its storage place
10408 Followed. There are no such components in GNAT@.
10410 @cindex Bit ordering
10411 @unnumberedsec 13.5.3(7-8): Bit Ordering
10414 The recommended level of support for the non-default bit ordering is:
10418 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
10419 should support the non-default bit ordering in addition to the default
10422 Followed. Word size does not equal storage size in this implementation.
10423 Thus non-default bit ordering is not supported.
10425 @cindex @code{Address}, as private type
10426 @unnumberedsec 13.7(37): Address as Private
10429 @code{Address} should be of a private type.
10433 @cindex Operations, on @code{Address}
10434 @cindex @code{Address}, operations of
10435 @unnumberedsec 13.7.1(16): Address Operations
10438 Operations in @code{System} and its children should reflect the target
10439 environment semantics as closely as is reasonable. For example, on most
10440 machines, it makes sense for address arithmetic to ``wrap around''.
10441 Operations that do not make sense should raise @code{Program_Error}.
10443 Followed. Address arithmetic is modular arithmetic that wraps around. No
10444 operation raises @code{Program_Error}, since all operations make sense.
10446 @cindex Unchecked conversion
10447 @unnumberedsec 13.9(14-17): Unchecked Conversion
10450 The @code{Size} of an array object should not include its bounds; hence,
10451 the bounds should not be part of the converted data.
10457 The implementation should not generate unnecessary run-time checks to
10458 ensure that the representation of @var{S} is a representation of the
10459 target type. It should take advantage of the permission to return by
10460 reference when possible. Restrictions on unchecked conversions should be
10461 avoided unless required by the target environment.
10463 Followed. There are no restrictions on unchecked conversion. A warning is
10464 generated if the source and target types do not have the same size since
10465 the semantics in this case may be target dependent.
10469 The recommended level of support for unchecked conversions is:
10473 Unchecked conversions should be supported and should be reversible in
10474 the cases where this clause defines the result. To enable meaningful use
10475 of unchecked conversion, a contiguous representation should be used for
10476 elementary subtypes, for statically constrained array subtypes whose
10477 component subtype is one of the subtypes described in this paragraph,
10478 and for record subtypes without discriminants whose component subtypes
10479 are described in this paragraph.
10483 @cindex Heap usage, implicit
10484 @unnumberedsec 13.11(23-25): Implicit Heap Usage
10487 An implementation should document any cases in which it dynamically
10488 allocates heap storage for a purpose other than the evaluation of an
10491 Followed, the only other points at which heap storage is dynamically
10492 allocated are as follows:
10496 At initial elaboration time, to allocate dynamically sized global
10500 To allocate space for a task when a task is created.
10503 To extend the secondary stack dynamically when needed. The secondary
10504 stack is used for returning variable length results.
10509 A default (implementation-provided) storage pool for an
10510 access-to-constant type should not have overhead to support deallocation of
10511 individual objects.
10517 A storage pool for an anonymous access type should be created at the
10518 point of an allocator for the type, and be reclaimed when the designated
10519 object becomes inaccessible.
10523 @cindex Unchecked deallocation
10524 @unnumberedsec 13.11.2(17): Unchecked De-allocation
10527 For a standard storage pool, @code{Free} should actually reclaim the
10532 @cindex Stream oriented attributes
10533 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
10536 If a stream element is the same size as a storage element, then the
10537 normal in-memory representation should be used by @code{Read} and
10538 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
10539 should use the smallest number of stream elements needed to represent
10540 all values in the base range of the scalar type.
10543 Followed. By default, GNAT uses the interpretation suggested by AI-195,
10544 which specifies using the size of the first subtype.
10545 However, such an implementation is based on direct binary
10546 representations and is therefore target- and endianness-dependent.
10547 To address this issue, GNAT also supplies an alternate implementation
10548 of the stream attributes @code{Read} and @code{Write},
10549 which uses the target-independent XDR standard representation
10551 @cindex XDR representation
10552 @cindex @code{Read} attribute
10553 @cindex @code{Write} attribute
10554 @cindex Stream oriented attributes
10555 The XDR implementation is provided as an alternative body of the
10556 @code{System.Stream_Attributes} package, in the file
10557 @file{s-stratt-xdr.adb} in the GNAT library.
10558 There is no @file{s-stratt-xdr.ads} file.
10559 In order to install the XDR implementation, do the following:
10561 @item Replace the default implementation of the
10562 @code{System.Stream_Attributes} package with the XDR implementation.
10563 For example on a Unix platform issue the commands:
10565 $ mv s-stratt.adb s-stratt-default.adb
10566 $ mv s-stratt-xdr.adb s-stratt.adb
10570 Rebuild the GNAT run-time library as documented in
10571 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
10574 @unnumberedsec A.1(52): Names of Predefined Numeric Types
10577 If an implementation provides additional named predefined integer types,
10578 then the names should end with @samp{Integer} as in
10579 @samp{Long_Integer}. If an implementation provides additional named
10580 predefined floating point types, then the names should end with
10581 @samp{Float} as in @samp{Long_Float}.
10585 @findex Ada.Characters.Handling
10586 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
10589 If an implementation provides a localized definition of @code{Character}
10590 or @code{Wide_Character}, then the effects of the subprograms in
10591 @code{Characters.Handling} should reflect the localizations. See also
10594 Followed. GNAT provides no such localized definitions.
10596 @cindex Bounded-length strings
10597 @unnumberedsec A.4.4(106): Bounded-Length String Handling
10600 Bounded string objects should not be implemented by implicit pointers
10601 and dynamic allocation.
10603 Followed. No implicit pointers or dynamic allocation are used.
10605 @cindex Random number generation
10606 @unnumberedsec A.5.2(46-47): Random Number Generation
10609 Any storage associated with an object of type @code{Generator} should be
10610 reclaimed on exit from the scope of the object.
10616 If the generator period is sufficiently long in relation to the number
10617 of distinct initiator values, then each possible value of
10618 @code{Initiator} passed to @code{Reset} should initiate a sequence of
10619 random numbers that does not, in a practical sense, overlap the sequence
10620 initiated by any other value. If this is not possible, then the mapping
10621 between initiator values and generator states should be a rapidly
10622 varying function of the initiator value.
10624 Followed. The generator period is sufficiently long for the first
10625 condition here to hold true.
10627 @findex Get_Immediate
10628 @unnumberedsec A.10.7(23): @code{Get_Immediate}
10631 The @code{Get_Immediate} procedures should be implemented with
10632 unbuffered input. For a device such as a keyboard, input should be
10633 @dfn{available} if a key has already been typed, whereas for a disk
10634 file, input should always be available except at end of file. For a file
10635 associated with a keyboard-like device, any line-editing features of the
10636 underlying operating system should be disabled during the execution of
10637 @code{Get_Immediate}.
10639 Followed on all targets except VxWorks. For VxWorks, there is no way to
10640 provide this functionality that does not result in the input buffer being
10641 flushed before the @code{Get_Immediate} call. A special unit
10642 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
10643 this functionality.
10646 @unnumberedsec B.1(39-41): Pragma @code{Export}
10649 If an implementation supports pragma @code{Export} to a given language,
10650 then it should also allow the main subprogram to be written in that
10651 language. It should support some mechanism for invoking the elaboration
10652 of the Ada library units included in the system, and for invoking the
10653 finalization of the environment task. On typical systems, the
10654 recommended mechanism is to provide two subprograms whose link names are
10655 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
10656 elaboration code for library units. @code{adafinal} should contain the
10657 finalization code. These subprograms should have no effect the second
10658 and subsequent time they are called.
10664 Automatic elaboration of pre-elaborated packages should be
10665 provided when pragma @code{Export} is supported.
10667 Followed when the main program is in Ada. If the main program is in a
10668 foreign language, then
10669 @code{adainit} must be called to elaborate pre-elaborated
10674 For each supported convention @var{L} other than @code{Intrinsic}, an
10675 implementation should support @code{Import} and @code{Export} pragmas
10676 for objects of @var{L}-compatible types and for subprograms, and pragma
10677 @code{Convention} for @var{L}-eligible types and for subprograms,
10678 presuming the other language has corresponding features. Pragma
10679 @code{Convention} need not be supported for scalar types.
10683 @cindex Package @code{Interfaces}
10685 @unnumberedsec B.2(12-13): Package @code{Interfaces}
10688 For each implementation-defined convention identifier, there should be a
10689 child package of package Interfaces with the corresponding name. This
10690 package should contain any declarations that would be useful for
10691 interfacing to the language (implementation) represented by the
10692 convention. Any declarations useful for interfacing to any language on
10693 the given hardware architecture should be provided directly in
10696 Followed. An additional package not defined
10697 in the Ada Reference Manual is @code{Interfaces.CPP}, used
10698 for interfacing to C++.
10702 An implementation supporting an interface to C, COBOL, or Fortran should
10703 provide the corresponding package or packages described in the following
10706 Followed. GNAT provides all the packages described in this section.
10708 @cindex C, interfacing with
10709 @unnumberedsec B.3(63-71): Interfacing with C
10712 An implementation should support the following interface correspondences
10713 between Ada and C@.
10719 An Ada procedure corresponds to a void-returning C function.
10725 An Ada function corresponds to a non-void C function.
10731 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
10738 An Ada @code{in} parameter of an access-to-object type with designated
10739 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
10740 where @var{t} is the C type corresponding to the Ada type @var{T}.
10746 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
10747 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
10748 argument to a C function, where @var{t} is the C type corresponding to
10749 the Ada type @var{T}. In the case of an elementary @code{out} or
10750 @code{in out} parameter, a pointer to a temporary copy is used to
10751 preserve by-copy semantics.
10757 An Ada parameter of a record type @var{T}, of any mode, is passed as a
10758 @code{@var{t}*} argument to a C function, where @var{t} is the C
10759 structure corresponding to the Ada type @var{T}.
10761 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
10762 pragma, or Convention, or by explicitly specifying the mechanism for a given
10763 call using an extended import or export pragma.
10767 An Ada parameter of an array type with component type @var{T}, of any
10768 mode, is passed as a @code{@var{t}*} argument to a C function, where
10769 @var{t} is the C type corresponding to the Ada type @var{T}.
10775 An Ada parameter of an access-to-subprogram type is passed as a pointer
10776 to a C function whose prototype corresponds to the designated
10777 subprogram's specification.
10781 @cindex COBOL, interfacing with
10782 @unnumberedsec B.4(95-98): Interfacing with COBOL
10785 An Ada implementation should support the following interface
10786 correspondences between Ada and COBOL@.
10792 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
10793 the COBOL type corresponding to @var{T}.
10799 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
10800 the corresponding COBOL type.
10806 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
10807 COBOL type corresponding to the Ada parameter type; for scalars, a local
10808 copy is used if necessary to ensure by-copy semantics.
10812 @cindex Fortran, interfacing with
10813 @unnumberedsec B.5(22-26): Interfacing with Fortran
10816 An Ada implementation should support the following interface
10817 correspondences between Ada and Fortran:
10823 An Ada procedure corresponds to a Fortran subroutine.
10829 An Ada function corresponds to a Fortran function.
10835 An Ada parameter of an elementary, array, or record type @var{T} is
10836 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
10837 the Fortran type corresponding to the Ada type @var{T}, and where the
10838 INTENT attribute of the corresponding dummy argument matches the Ada
10839 formal parameter mode; the Fortran implementation's parameter passing
10840 conventions are used. For elementary types, a local copy is used if
10841 necessary to ensure by-copy semantics.
10847 An Ada parameter of an access-to-subprogram type is passed as a
10848 reference to a Fortran procedure whose interface corresponds to the
10849 designated subprogram's specification.
10853 @cindex Machine operations
10854 @unnumberedsec C.1(3-5): Access to Machine Operations
10857 The machine code or intrinsic support should allow access to all
10858 operations normally available to assembly language programmers for the
10859 target environment, including privileged instructions, if any.
10865 The interfacing pragmas (see Annex B) should support interface to
10866 assembler; the default assembler should be associated with the
10867 convention identifier @code{Assembler}.
10873 If an entity is exported to assembly language, then the implementation
10874 should allocate it at an addressable location, and should ensure that it
10875 is retained by the linking process, even if not otherwise referenced
10876 from the Ada code. The implementation should assume that any call to a
10877 machine code or assembler subprogram is allowed to read or update every
10878 object that is specified as exported.
10882 @unnumberedsec C.1(10-16): Access to Machine Operations
10885 The implementation should ensure that little or no overhead is
10886 associated with calling intrinsic and machine-code subprograms.
10888 Followed for both intrinsics and machine-code subprograms.
10892 It is recommended that intrinsic subprograms be provided for convenient
10893 access to any machine operations that provide special capabilities or
10894 efficiency and that are not otherwise available through the language
10897 Followed. A full set of machine operation intrinsic subprograms is provided.
10901 Atomic read-modify-write operations---e.g.@:, test and set, compare and
10902 swap, decrement and test, enqueue/dequeue.
10904 Followed on any target supporting such operations.
10908 Standard numeric functions---e.g.@:, sin, log.
10910 Followed on any target supporting such operations.
10914 String manipulation operations---e.g.@:, translate and test.
10916 Followed on any target supporting such operations.
10920 Vector operations---e.g.@:, compare vector against thresholds.
10922 Followed on any target supporting such operations.
10926 Direct operations on I/O ports.
10928 Followed on any target supporting such operations.
10930 @cindex Interrupt support
10931 @unnumberedsec C.3(28): Interrupt Support
10934 If the @code{Ceiling_Locking} policy is not in effect, the
10935 implementation should provide means for the application to specify which
10936 interrupts are to be blocked during protected actions, if the underlying
10937 system allows for a finer-grain control of interrupt blocking.
10939 Followed. The underlying system does not allow for finer-grain control
10940 of interrupt blocking.
10942 @cindex Protected procedure handlers
10943 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
10946 Whenever possible, the implementation should allow interrupt handlers to
10947 be called directly by the hardware.
10949 Followed on any target where the underlying operating system permits
10954 Whenever practical, violations of any
10955 implementation-defined restrictions should be detected before run time.
10957 Followed. Compile time warnings are given when possible.
10959 @cindex Package @code{Interrupts}
10961 @unnumberedsec C.3.2(25): Package @code{Interrupts}
10965 If implementation-defined forms of interrupt handler procedures are
10966 supported, such as protected procedures with parameters, then for each
10967 such form of a handler, a type analogous to @code{Parameterless_Handler}
10968 should be specified in a child package of @code{Interrupts}, with the
10969 same operations as in the predefined package Interrupts.
10973 @cindex Pre-elaboration requirements
10974 @unnumberedsec C.4(14): Pre-elaboration Requirements
10977 It is recommended that pre-elaborated packages be implemented in such a
10978 way that there should be little or no code executed at run time for the
10979 elaboration of entities not already covered by the Implementation
10982 Followed. Executable code is generated in some cases, e.g.@: loops
10983 to initialize large arrays.
10985 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
10988 If the pragma applies to an entity, then the implementation should
10989 reduce the amount of storage used for storing names associated with that
10994 @cindex Package @code{Task_Attributes}
10995 @findex Task_Attributes
10996 @unnumberedsec C.7.2(30): The Package Task_Attributes
10999 Some implementations are targeted to domains in which memory use at run
11000 time must be completely deterministic. For such implementations, it is
11001 recommended that the storage for task attributes will be pre-allocated
11002 statically and not from the heap. This can be accomplished by either
11003 placing restrictions on the number and the size of the task's
11004 attributes, or by using the pre-allocated storage for the first @var{N}
11005 attribute objects, and the heap for the others. In the latter case,
11006 @var{N} should be documented.
11008 Not followed. This implementation is not targeted to such a domain.
11010 @cindex Locking Policies
11011 @unnumberedsec D.3(17): Locking Policies
11015 The implementation should use names that end with @samp{_Locking} for
11016 locking policies defined by the implementation.
11018 Followed. Two implementation-defined locking policies are defined,
11019 whose names (@code{Inheritance_Locking} and
11020 @code{Concurrent_Readers_Locking}) follow this suggestion.
11022 @cindex Entry queuing policies
11023 @unnumberedsec D.4(16): Entry Queuing Policies
11026 Names that end with @samp{_Queuing} should be used
11027 for all implementation-defined queuing policies.
11029 Followed. No such implementation-defined queuing policies exist.
11031 @cindex Preemptive abort
11032 @unnumberedsec D.6(9-10): Preemptive Abort
11035 Even though the @code{abort_statement} is included in the list of
11036 potentially blocking operations (see 9.5.1), it is recommended that this
11037 statement be implemented in a way that never requires the task executing
11038 the @code{abort_statement} to block.
11044 On a multi-processor, the delay associated with aborting a task on
11045 another processor should be bounded; the implementation should use
11046 periodic polling, if necessary, to achieve this.
11050 @cindex Tasking restrictions
11051 @unnumberedsec D.7(21): Tasking Restrictions
11054 When feasible, the implementation should take advantage of the specified
11055 restrictions to produce a more efficient implementation.
11057 GNAT currently takes advantage of these restrictions by providing an optimized
11058 run time when the Ravenscar profile and the GNAT restricted run time set
11059 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
11060 pragma @code{Profile (Restricted)} for more details.
11062 @cindex Time, monotonic
11063 @unnumberedsec D.8(47-49): Monotonic Time
11066 When appropriate, implementations should provide configuration
11067 mechanisms to change the value of @code{Tick}.
11069 Such configuration mechanisms are not appropriate to this implementation
11070 and are thus not supported.
11074 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
11075 be implemented as transformations of the same time base.
11081 It is recommended that the @dfn{best} time base which exists in
11082 the underlying system be available to the application through
11083 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
11087 @cindex Partition communication subsystem
11089 @unnumberedsec E.5(28-29): Partition Communication Subsystem
11092 Whenever possible, the PCS on the called partition should allow for
11093 multiple tasks to call the RPC-receiver with different messages and
11094 should allow them to block until the corresponding subprogram body
11097 Followed by GLADE, a separately supplied PCS that can be used with
11102 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
11103 should raise @code{Storage_Error} if it runs out of space trying to
11104 write the @code{Item} into the stream.
11106 Followed by GLADE, a separately supplied PCS that can be used with
11109 @cindex COBOL support
11110 @unnumberedsec F(7): COBOL Support
11113 If COBOL (respectively, C) is widely supported in the target
11114 environment, implementations supporting the Information Systems Annex
11115 should provide the child package @code{Interfaces.COBOL} (respectively,
11116 @code{Interfaces.C}) specified in Annex B and should support a
11117 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
11118 pragmas (see Annex B), thus allowing Ada programs to interface with
11119 programs written in that language.
11123 @cindex Decimal radix support
11124 @unnumberedsec F.1(2): Decimal Radix Support
11127 Packed decimal should be used as the internal representation for objects
11128 of subtype @var{S} when @var{S}'Machine_Radix = 10.
11130 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
11134 @unnumberedsec G: Numerics
11137 If Fortran (respectively, C) is widely supported in the target
11138 environment, implementations supporting the Numerics Annex
11139 should provide the child package @code{Interfaces.Fortran} (respectively,
11140 @code{Interfaces.C}) specified in Annex B and should support a
11141 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
11142 pragmas (see Annex B), thus allowing Ada programs to interface with
11143 programs written in that language.
11147 @cindex Complex types
11148 @unnumberedsec G.1.1(56-58): Complex Types
11151 Because the usual mathematical meaning of multiplication of a complex
11152 operand and a real operand is that of the scaling of both components of
11153 the former by the latter, an implementation should not perform this
11154 operation by first promoting the real operand to complex type and then
11155 performing a full complex multiplication. In systems that, in the
11156 future, support an Ada binding to IEC 559:1989, the latter technique
11157 will not generate the required result when one of the components of the
11158 complex operand is infinite. (Explicit multiplication of the infinite
11159 component by the zero component obtained during promotion yields a NaN
11160 that propagates into the final result.) Analogous advice applies in the
11161 case of multiplication of a complex operand and a pure-imaginary
11162 operand, and in the case of division of a complex operand by a real or
11163 pure-imaginary operand.
11169 Similarly, because the usual mathematical meaning of addition of a
11170 complex operand and a real operand is that the imaginary operand remains
11171 unchanged, an implementation should not perform this operation by first
11172 promoting the real operand to complex type and then performing a full
11173 complex addition. In implementations in which the @code{Signed_Zeros}
11174 attribute of the component type is @code{True} (and which therefore
11175 conform to IEC 559:1989 in regard to the handling of the sign of zero in
11176 predefined arithmetic operations), the latter technique will not
11177 generate the required result when the imaginary component of the complex
11178 operand is a negatively signed zero. (Explicit addition of the negative
11179 zero to the zero obtained during promotion yields a positive zero.)
11180 Analogous advice applies in the case of addition of a complex operand
11181 and a pure-imaginary operand, and in the case of subtraction of a
11182 complex operand and a real or pure-imaginary operand.
11188 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
11189 attempt to provide a rational treatment of the signs of zero results and
11190 result components. As one example, the result of the @code{Argument}
11191 function should have the sign of the imaginary component of the
11192 parameter @code{X} when the point represented by that parameter lies on
11193 the positive real axis; as another, the sign of the imaginary component
11194 of the @code{Compose_From_Polar} function should be the same as
11195 (respectively, the opposite of) that of the @code{Argument} parameter when that
11196 parameter has a value of zero and the @code{Modulus} parameter has a
11197 nonnegative (respectively, negative) value.
11201 @cindex Complex elementary functions
11202 @unnumberedsec G.1.2(49): Complex Elementary Functions
11205 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
11206 @code{True} should attempt to provide a rational treatment of the signs
11207 of zero results and result components. For example, many of the complex
11208 elementary functions have components that are odd functions of one of
11209 the parameter components; in these cases, the result component should
11210 have the sign of the parameter component at the origin. Other complex
11211 elementary functions have zero components whose sign is opposite that of
11212 a parameter component at the origin, or is always positive or always
11217 @cindex Accuracy requirements
11218 @unnumberedsec G.2.4(19): Accuracy Requirements
11221 The versions of the forward trigonometric functions without a
11222 @code{Cycle} parameter should not be implemented by calling the
11223 corresponding version with a @code{Cycle} parameter of
11224 @code{2.0*Numerics.Pi}, since this will not provide the required
11225 accuracy in some portions of the domain. For the same reason, the
11226 version of @code{Log} without a @code{Base} parameter should not be
11227 implemented by calling the corresponding version with a @code{Base}
11228 parameter of @code{Numerics.e}.
11232 @cindex Complex arithmetic accuracy
11233 @cindex Accuracy, complex arithmetic
11234 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
11238 The version of the @code{Compose_From_Polar} function without a
11239 @code{Cycle} parameter should not be implemented by calling the
11240 corresponding version with a @code{Cycle} parameter of
11241 @code{2.0*Numerics.Pi}, since this will not provide the required
11242 accuracy in some portions of the domain.
11246 @cindex Sequential elaboration policy
11247 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
11251 If the partition elaboration policy is @code{Sequential} and the
11252 Environment task becomes permanently blocked during elaboration then the
11253 partition is deadlocked and it is recommended that the partition be
11254 immediately terminated.
11258 @c -----------------------------------------
11259 @node Implementation Defined Characteristics
11260 @chapter Implementation Defined Characteristics
11263 In addition to the implementation dependent pragmas and attributes, and the
11264 implementation advice, there are a number of other Ada features that are
11265 potentially implementation dependent and are designated as
11266 implementation-defined. These are mentioned throughout the Ada Reference
11267 Manual, and are summarized in Annex M@.
11269 A requirement for conforming Ada compilers is that they provide
11270 documentation describing how the implementation deals with each of these
11271 issues. In this chapter, you will find each point in Annex M listed
11272 followed by a description in italic font of how GNAT
11273 handles the implementation dependence.
11275 You can use this chapter as a guide to minimizing implementation
11276 dependent features in your programs if portability to other compilers
11277 and other operating systems is an important consideration. The numbers
11278 in each section below correspond to the paragraph number in the Ada
11284 @strong{2}. Whether or not each recommendation given in Implementation
11285 Advice is followed. See 1.1.2(37).
11288 @xref{Implementation Advice}.
11293 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
11296 The complexity of programs that can be processed is limited only by the
11297 total amount of available virtual memory, and disk space for the
11298 generated object files.
11303 @strong{4}. Variations from the standard that are impractical to avoid
11304 given the implementation's execution environment. See 1.1.3(6).
11307 There are no variations from the standard.
11312 @strong{5}. Which @code{code_statement}s cause external
11313 interactions. See 1.1.3(10).
11316 Any @code{code_statement} can potentially cause external interactions.
11321 @strong{6}. The coded representation for the text of an Ada
11322 program. See 2.1(4).
11325 See separate section on source representation.
11330 @strong{7}. The control functions allowed in comments. See 2.1(14).
11333 See separate section on source representation.
11338 @strong{8}. The representation for an end of line. See 2.2(2).
11341 See separate section on source representation.
11346 @strong{9}. Maximum supported line length and lexical element
11347 length. See 2.2(15).
11350 The maximum line length is 255 characters and the maximum length of
11351 a lexical element is also 255 characters. This is the default setting
11352 if not overridden by the use of compiler switch @option{-gnaty} (which
11353 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
11354 line length to be specified to be any value up to 32767. The maximum
11355 length of a lexical element is the same as the maximum line length.
11360 @strong{10}. Implementation defined pragmas. See 2.8(14).
11364 @xref{Implementation Defined Pragmas}.
11369 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
11372 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
11373 parameter, checks that the optimization flag is set, and aborts if it is
11379 @strong{12}. The sequence of characters of the value returned by
11380 @code{@var{S}'Image} when some of the graphic characters of
11381 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
11385 The sequence of characters is as defined by the wide character encoding
11386 method used for the source. See section on source representation for
11392 @strong{13}. The predefined integer types declared in
11393 @code{Standard}. See 3.5.4(25).
11397 @item Short_Short_Integer
11399 @item Short_Integer
11400 (Short) 16 bit signed
11404 64 bit signed (on most 64 bit targets, depending on the C definition of long).
11405 32 bit signed (all other targets)
11406 @item Long_Long_Integer
11413 @strong{14}. Any nonstandard integer types and the operators defined
11414 for them. See 3.5.4(26).
11417 There are no nonstandard integer types.
11422 @strong{15}. Any nonstandard real types and the operators defined for
11423 them. See 3.5.6(8).
11426 There are no nonstandard real types.
11431 @strong{16}. What combinations of requested decimal precision and range
11432 are supported for floating point types. See 3.5.7(7).
11435 The precision and range is as defined by the IEEE standard.
11440 @strong{17}. The predefined floating point types declared in
11441 @code{Standard}. See 3.5.7(16).
11448 (Short) 32 bit IEEE short
11451 @item Long_Long_Float
11452 64 bit IEEE long (80 bit IEEE long on x86 processors)
11458 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
11461 @code{Fine_Delta} is 2**(@minus{}63)
11466 @strong{19}. What combinations of small, range, and digits are
11467 supported for fixed point types. See 3.5.9(10).
11470 Any combinations are permitted that do not result in a small less than
11471 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
11472 If the mantissa is larger than 53 bits on machines where Long_Long_Float
11473 is 64 bits (true of all architectures except ia32), then the output from
11474 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
11475 is because floating-point conversions are used to convert fixed point.
11480 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
11481 within an unnamed @code{block_statement}. See 3.9(10).
11484 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
11485 decimal integer are allocated.
11490 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
11493 @xref{Implementation Defined Attributes}.
11498 @strong{22}. Any implementation-defined time types. See 9.6(6).
11501 There are no implementation-defined time types.
11506 @strong{23}. The time base associated with relative delays.
11509 See 9.6(20). The time base used is that provided by the C library
11510 function @code{gettimeofday}.
11515 @strong{24}. The time base of the type @code{Calendar.Time}. See
11519 The time base used is that provided by the C library function
11520 @code{gettimeofday}.
11525 @strong{25}. The time zone used for package @code{Calendar}
11526 operations. See 9.6(24).
11529 The time zone used by package @code{Calendar} is the current system time zone
11530 setting for local time, as accessed by the C library function
11536 @strong{26}. Any limit on @code{delay_until_statements} of
11537 @code{select_statements}. See 9.6(29).
11540 There are no such limits.
11545 @strong{27}. Whether or not two non-overlapping parts of a composite
11546 object are independently addressable, in the case where packing, record
11547 layout, or @code{Component_Size} is specified for the object. See
11551 Separate components are independently addressable if they do not share
11552 overlapping storage units.
11557 @strong{28}. The representation for a compilation. See 10.1(2).
11560 A compilation is represented by a sequence of files presented to the
11561 compiler in a single invocation of the @command{gcc} command.
11566 @strong{29}. Any restrictions on compilations that contain multiple
11567 compilation_units. See 10.1(4).
11570 No single file can contain more than one compilation unit, but any
11571 sequence of files can be presented to the compiler as a single
11577 @strong{30}. The mechanisms for creating an environment and for adding
11578 and replacing compilation units. See 10.1.4(3).
11581 See separate section on compilation model.
11586 @strong{31}. The manner of explicitly assigning library units to a
11587 partition. See 10.2(2).
11590 If a unit contains an Ada main program, then the Ada units for the partition
11591 are determined by recursive application of the rules in the Ada Reference
11592 Manual section 10.2(2-6). In other words, the Ada units will be those that
11593 are needed by the main program, and then this definition of need is applied
11594 recursively to those units, and the partition contains the transitive
11595 closure determined by this relationship. In short, all the necessary units
11596 are included, with no need to explicitly specify the list. If additional
11597 units are required, e.g.@: by foreign language units, then all units must be
11598 mentioned in the context clause of one of the needed Ada units.
11600 If the partition contains no main program, or if the main program is in
11601 a language other than Ada, then GNAT
11602 provides the binder options @option{-z} and @option{-n} respectively, and in
11603 this case a list of units can be explicitly supplied to the binder for
11604 inclusion in the partition (all units needed by these units will also
11605 be included automatically). For full details on the use of these
11606 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
11607 @value{EDITION} User's Guide}.
11612 @strong{32}. The implementation-defined means, if any, of specifying
11613 which compilation units are needed by a given compilation unit. See
11617 The units needed by a given compilation unit are as defined in
11618 the Ada Reference Manual section 10.2(2-6). There are no
11619 implementation-defined pragmas or other implementation-defined
11620 means for specifying needed units.
11625 @strong{33}. The manner of designating the main subprogram of a
11626 partition. See 10.2(7).
11629 The main program is designated by providing the name of the
11630 corresponding @file{ALI} file as the input parameter to the binder.
11635 @strong{34}. The order of elaboration of @code{library_items}. See
11639 The first constraint on ordering is that it meets the requirements of
11640 Chapter 10 of the Ada Reference Manual. This still leaves some
11641 implementation dependent choices, which are resolved by first
11642 elaborating bodies as early as possible (i.e., in preference to specs
11643 where there is a choice), and second by evaluating the immediate with
11644 clauses of a unit to determine the probably best choice, and
11645 third by elaborating in alphabetical order of unit names
11646 where a choice still remains.
11651 @strong{35}. Parameter passing and function return for the main
11652 subprogram. See 10.2(21).
11655 The main program has no parameters. It may be a procedure, or a function
11656 returning an integer type. In the latter case, the returned integer
11657 value is the return code of the program (overriding any value that
11658 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
11663 @strong{36}. The mechanisms for building and running partitions. See
11667 GNAT itself supports programs with only a single partition. The GNATDIST
11668 tool provided with the GLADE package (which also includes an implementation
11669 of the PCS) provides a completely flexible method for building and running
11670 programs consisting of multiple partitions. See the separate GLADE manual
11676 @strong{37}. The details of program execution, including program
11677 termination. See 10.2(25).
11680 See separate section on compilation model.
11685 @strong{38}. The semantics of any non-active partitions supported by the
11686 implementation. See 10.2(28).
11689 Passive partitions are supported on targets where shared memory is
11690 provided by the operating system. See the GLADE reference manual for
11696 @strong{39}. The information returned by @code{Exception_Message}. See
11700 Exception message returns the null string unless a specific message has
11701 been passed by the program.
11706 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
11707 declared within an unnamed @code{block_statement}. See 11.4.1(12).
11710 Blocks have implementation defined names of the form @code{B@var{nnn}}
11711 where @var{nnn} is an integer.
11716 @strong{41}. The information returned by
11717 @code{Exception_Information}. See 11.4.1(13).
11720 @code{Exception_Information} returns a string in the following format:
11723 @emph{Exception_Name:} nnnnn
11724 @emph{Message:} mmmmm
11726 @emph{Call stack traceback locations:}
11727 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
11735 @code{nnnn} is the fully qualified name of the exception in all upper
11736 case letters. This line is always present.
11739 @code{mmmm} is the message (this line present only if message is non-null)
11742 @code{ppp} is the Process Id value as a decimal integer (this line is
11743 present only if the Process Id is nonzero). Currently we are
11744 not making use of this field.
11747 The Call stack traceback locations line and the following values
11748 are present only if at least one traceback location was recorded.
11749 The values are given in C style format, with lower case letters
11750 for a-f, and only as many digits present as are necessary.
11754 The line terminator sequence at the end of each line, including
11755 the last line is a single @code{LF} character (@code{16#0A#}).
11760 @strong{42}. Implementation-defined check names. See 11.5(27).
11763 The implementation defined check name Alignment_Check controls checking of
11764 address clause values for proper alignment (that is, the address supplied
11765 must be consistent with the alignment of the type).
11767 The implementation defined check name Predicate_Check controls whether
11768 predicate checks are generated.
11770 The implementation defined check name Validity_Check controls whether
11771 validity checks are generated.
11773 In addition, a user program can add implementation-defined check names
11774 by means of the pragma Check_Name.
11779 @strong{43}. The interpretation of each aspect of representation. See
11783 See separate section on data representations.
11788 @strong{44}. Any restrictions placed upon representation items. See
11792 See separate section on data representations.
11797 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
11801 Size for an indefinite subtype is the maximum possible size, except that
11802 for the case of a subprogram parameter, the size of the parameter object
11803 is the actual size.
11808 @strong{46}. The default external representation for a type tag. See
11812 The default external representation for a type tag is the fully expanded
11813 name of the type in upper case letters.
11818 @strong{47}. What determines whether a compilation unit is the same in
11819 two different partitions. See 13.3(76).
11822 A compilation unit is the same in two different partitions if and only
11823 if it derives from the same source file.
11828 @strong{48}. Implementation-defined components. See 13.5.1(15).
11831 The only implementation defined component is the tag for a tagged type,
11832 which contains a pointer to the dispatching table.
11837 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
11838 ordering. See 13.5.3(5).
11841 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
11842 implementation, so no non-default bit ordering is supported. The default
11843 bit ordering corresponds to the natural endianness of the target architecture.
11848 @strong{50}. The contents of the visible part of package @code{System}
11849 and its language-defined children. See 13.7(2).
11852 See the definition of these packages in files @file{system.ads} and
11853 @file{s-stoele.ads}.
11858 @strong{51}. The contents of the visible part of package
11859 @code{System.Machine_Code}, and the meaning of
11860 @code{code_statements}. See 13.8(7).
11863 See the definition and documentation in file @file{s-maccod.ads}.
11868 @strong{52}. The effect of unchecked conversion. See 13.9(11).
11871 Unchecked conversion between types of the same size
11872 results in an uninterpreted transmission of the bits from one type
11873 to the other. If the types are of unequal sizes, then in the case of
11874 discrete types, a shorter source is first zero or sign extended as
11875 necessary, and a shorter target is simply truncated on the left.
11876 For all non-discrete types, the source is first copied if necessary
11877 to ensure that the alignment requirements of the target are met, then
11878 a pointer is constructed to the source value, and the result is obtained
11879 by dereferencing this pointer after converting it to be a pointer to the
11880 target type. Unchecked conversions where the target subtype is an
11881 unconstrained array are not permitted. If the target alignment is
11882 greater than the source alignment, then a copy of the result is
11883 made with appropriate alignment
11888 @strong{53}. The semantics of operations on invalid representations.
11892 For assignments and other operations where the use of invalid values cannot
11893 result in erroneous behavior, the compiler ignores the possibility of invalid
11894 values. An exception is raised at the point where an invalid value would
11895 result in erroneous behavior. For example executing:
11897 @smallexample @c ada
11898 procedure invalidvals is
11900 Y : Natural range 1 .. 10;
11901 for Y'Address use X'Address;
11902 Z : Natural range 1 .. 10;
11903 A : array (Natural range 1 .. 10) of Integer;
11905 Z := Y; -- no exception
11906 A (Z) := 3; -- exception raised;
11911 As indicated, an exception is raised on the array assignment, but not
11912 on the simple assignment of the invalid negative value from Y to Z.
11917 @strong{53}. The manner of choosing a storage pool for an access type
11918 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
11921 There are 3 different standard pools used by the compiler when
11922 @code{Storage_Pool} is not specified depending whether the type is local
11923 to a subprogram or defined at the library level and whether
11924 @code{Storage_Size}is specified or not. See documentation in the runtime
11925 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
11926 @code{System.Pool_Local} in files @file{s-poosiz.ads},
11927 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
11928 default pools used.
11933 @strong{54}. Whether or not the implementation provides user-accessible
11934 names for the standard pool type(s). See 13.11(17).
11938 See documentation in the sources of the run time mentioned in paragraph
11939 @strong{53} . All these pools are accessible by means of @code{with}'ing
11945 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
11948 @code{Storage_Size} is measured in storage units, and refers to the
11949 total space available for an access type collection, or to the primary
11950 stack space for a task.
11955 @strong{56}. Implementation-defined aspects of storage pools. See
11959 See documentation in the sources of the run time mentioned in paragraph
11960 @strong{53} for details on GNAT-defined aspects of storage pools.
11965 @strong{57}. The set of restrictions allowed in a pragma
11966 @code{Restrictions}. See 13.12(7).
11969 @xref{Standard and Implementation Defined Restrictions}.
11974 @strong{58}. The consequences of violating limitations on
11975 @code{Restrictions} pragmas. See 13.12(9).
11978 Restrictions that can be checked at compile time result in illegalities
11979 if violated. Currently there are no other consequences of violating
11985 @strong{59}. The representation used by the @code{Read} and
11986 @code{Write} attributes of elementary types in terms of stream
11987 elements. See 13.13.2(9).
11990 The representation is the in-memory representation of the base type of
11991 the type, using the number of bits corresponding to the
11992 @code{@var{type}'Size} value, and the natural ordering of the machine.
11997 @strong{60}. The names and characteristics of the numeric subtypes
11998 declared in the visible part of package @code{Standard}. See A.1(3).
12001 See items describing the integer and floating-point types supported.
12006 @strong{61}. The accuracy actually achieved by the elementary
12007 functions. See A.5.1(1).
12010 The elementary functions correspond to the functions available in the C
12011 library. Only fast math mode is implemented.
12016 @strong{62}. The sign of a zero result from some of the operators or
12017 functions in @code{Numerics.Generic_Elementary_Functions}, when
12018 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
12021 The sign of zeroes follows the requirements of the IEEE 754 standard on
12027 @strong{63}. The value of
12028 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
12031 Maximum image width is 6864, see library file @file{s-rannum.ads}.
12036 @strong{64}. The value of
12037 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
12040 Maximum image width is 6864, see library file @file{s-rannum.ads}.
12045 @strong{65}. The algorithms for random number generation. See
12049 The algorithm is the Mersenne Twister, as documented in the source file
12050 @file{s-rannum.adb}. This version of the algorithm has a period of
12056 @strong{66}. The string representation of a random number generator's
12057 state. See A.5.2(38).
12060 The value returned by the Image function is the concatenation of
12061 the fixed-width decimal representations of the 624 32-bit integers
12062 of the state vector.
12067 @strong{67}. The minimum time interval between calls to the
12068 time-dependent Reset procedure that are guaranteed to initiate different
12069 random number sequences. See A.5.2(45).
12072 The minimum period between reset calls to guarantee distinct series of
12073 random numbers is one microsecond.
12078 @strong{68}. The values of the @code{Model_Mantissa},
12079 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
12080 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
12081 Annex is not supported. See A.5.3(72).
12084 Run the compiler with @option{-gnatS} to produce a listing of package
12085 @code{Standard}, has the values of all numeric attributes.
12090 @strong{69}. Any implementation-defined characteristics of the
12091 input-output packages. See A.7(14).
12094 There are no special implementation defined characteristics for these
12100 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
12104 All type representations are contiguous, and the @code{Buffer_Size} is
12105 the value of @code{@var{type}'Size} rounded up to the next storage unit
12111 @strong{71}. External files for standard input, standard output, and
12112 standard error See A.10(5).
12115 These files are mapped onto the files provided by the C streams
12116 libraries. See source file @file{i-cstrea.ads} for further details.
12121 @strong{72}. The accuracy of the value produced by @code{Put}. See
12125 If more digits are requested in the output than are represented by the
12126 precision of the value, zeroes are output in the corresponding least
12127 significant digit positions.
12132 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
12133 @code{Command_Name}. See A.15(1).
12136 These are mapped onto the @code{argv} and @code{argc} parameters of the
12137 main program in the natural manner.
12142 @strong{74}. The interpretation of the @code{Form} parameter in procedure
12143 @code{Create_Directory}. See A.16(56).
12146 The @code{Form} parameter is not used.
12151 @strong{75}. The interpretation of the @code{Form} parameter in procedure
12152 @code{Create_Path}. See A.16(60).
12155 The @code{Form} parameter is not used.
12160 @strong{76}. The interpretation of the @code{Form} parameter in procedure
12161 @code{Copy_File}. See A.16(68).
12164 The @code{Form} parameter is case-insensitive.
12166 Two fields are recognized in the @code{Form} parameter:
12170 @item preserve=<value>
12177 <value> starts immediately after the character '=' and ends with the
12178 character immediately preceding the next comma (',') or with the last
12179 character of the parameter.
12181 The only possible values for preserve= are:
12185 @item no_attributes
12186 Do not try to preserve any file attributes. This is the default if no
12187 preserve= is found in Form.
12189 @item all_attributes
12190 Try to preserve all file attributes (timestamps, access rights).
12193 Preserve the timestamp of the copied file, but not the other file attributes.
12198 The only possible values for mode= are:
12203 Only do the copy if the destination file does not already exist. If it already
12204 exists, Copy_File fails.
12207 Copy the file in all cases. Overwrite an already existing destination file.
12210 Append the original file to the destination file. If the destination file does
12211 not exist, the destination file is a copy of the source file. When mode=append,
12212 the field preserve=, if it exists, is not taken into account.
12217 If the Form parameter includes one or both of the fields and the value or
12218 values are incorrect, Copy_file fails with Use_Error.
12220 Examples of correct Forms:
12223 Form => "preserve=no_attributes,mode=overwrite" (the default)
12224 Form => "mode=append"
12225 Form => "mode=copy, preserve=all_attributes"
12229 Examples of incorrect Forms
12232 Form => "preserve=junk"
12233 Form => "mode=internal, preserve=timestamps"
12239 @strong{77}. Implementation-defined convention names. See B.1(11).
12242 The following convention names are supported
12247 @item Ada_Pass_By_Copy
12248 Allowed for any types except by-reference types such as limited
12249 records. Compatible with convention Ada, but causes any parameters
12250 with this convention to be passed by copy.
12251 @item Ada_Pass_By_Reference
12252 Allowed for any types except by-copy types such as scalars.
12253 Compatible with convention Ada, but causes any parameters
12254 with this convention to be passed by reference.
12258 Synonym for Assembler
12260 Synonym for Assembler
12263 @item C_Pass_By_Copy
12264 Allowed only for record types, like C, but also notes that record
12265 is to be passed by copy rather than reference.
12268 @item C_Plus_Plus (or CPP)
12271 Treated the same as C
12273 Treated the same as C
12277 For support of pragma @code{Import} with convention Intrinsic, see
12278 separate section on Intrinsic Subprograms.
12280 Stdcall (used for Windows implementations only). This convention correspond
12281 to the WINAPI (previously called Pascal convention) C/C++ convention under
12282 Windows. A routine with this convention cleans the stack before
12283 exit. This pragma cannot be applied to a dispatching call.
12285 Synonym for Stdcall
12287 Synonym for Stdcall
12289 Stubbed is a special convention used to indicate that the body of the
12290 subprogram will be entirely ignored. Any call to the subprogram
12291 is converted into a raise of the @code{Program_Error} exception. If a
12292 pragma @code{Import} specifies convention @code{stubbed} then no body need
12293 be present at all. This convention is useful during development for the
12294 inclusion of subprograms whose body has not yet been written.
12298 In addition, all otherwise unrecognized convention names are also
12299 treated as being synonymous with convention C@. In all implementations
12300 except for VMS, use of such other names results in a warning. In VMS
12301 implementations, these names are accepted silently.
12306 @strong{78}. The meaning of link names. See B.1(36).
12309 Link names are the actual names used by the linker.
12314 @strong{79}. The manner of choosing link names when neither the link
12315 name nor the address of an imported or exported entity is specified. See
12319 The default linker name is that which would be assigned by the relevant
12320 external language, interpreting the Ada name as being in all lower case
12326 @strong{80}. The effect of pragma @code{Linker_Options}. See B.1(37).
12329 The string passed to @code{Linker_Options} is presented uninterpreted as
12330 an argument to the link command, unless it contains ASCII.NUL characters.
12331 NUL characters if they appear act as argument separators, so for example
12333 @smallexample @c ada
12334 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
12338 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
12339 linker. The order of linker options is preserved for a given unit. The final
12340 list of options passed to the linker is in reverse order of the elaboration
12341 order. For example, linker options for a body always appear before the options
12342 from the corresponding package spec.
12347 @strong{81}. The contents of the visible part of package
12348 @code{Interfaces} and its language-defined descendants. See B.2(1).
12351 See files with prefix @file{i-} in the distributed library.
12356 @strong{82}. Implementation-defined children of package
12357 @code{Interfaces}. The contents of the visible part of package
12358 @code{Interfaces}. See B.2(11).
12361 See files with prefix @file{i-} in the distributed library.
12366 @strong{83}. The types @code{Floating}, @code{Long_Floating},
12367 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
12368 @code{COBOL_Character}; and the initialization of the variables
12369 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
12370 @code{Interfaces.COBOL}. See B.4(50).
12376 @item Long_Floating
12377 (Floating) Long_Float
12382 @item Decimal_Element
12384 @item COBOL_Character
12389 For initialization, see the file @file{i-cobol.ads} in the distributed library.
12394 @strong{84}. Support for access to machine instructions. See C.1(1).
12397 See documentation in file @file{s-maccod.ads} in the distributed library.
12402 @strong{85}. Implementation-defined aspects of access to machine
12403 operations. See C.1(9).
12406 See documentation in file @file{s-maccod.ads} in the distributed library.
12411 @strong{86}. Implementation-defined aspects of interrupts. See C.3(2).
12414 Interrupts are mapped to signals or conditions as appropriate. See
12416 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
12417 on the interrupts supported on a particular target.
12422 @strong{87}. Implementation-defined aspects of pre-elaboration. See
12426 GNAT does not permit a partition to be restarted without reloading,
12427 except under control of the debugger.
12432 @strong{88}. The semantics of pragma @code{Discard_Names}. See C.5(7).
12435 Pragma @code{Discard_Names} causes names of enumeration literals to
12436 be suppressed. In the presence of this pragma, the Image attribute
12437 provides the image of the Pos of the literal, and Value accepts
12443 @strong{89}. The result of the @code{Task_Identification.Image}
12444 attribute. See C.7.1(7).
12447 The result of this attribute is a string that identifies
12448 the object or component that denotes a given task. If a variable @code{Var}
12449 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
12451 is the hexadecimal representation of the virtual address of the corresponding
12452 task control block. If the variable is an array of tasks, the image of each
12453 task will have the form of an indexed component indicating the position of a
12454 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
12455 component of a record, the image of the task will have the form of a selected
12456 component. These rules are fully recursive, so that the image of a task that
12457 is a subcomponent of a composite object corresponds to the expression that
12458 designates this task.
12460 If a task is created by an allocator, its image depends on the context. If the
12461 allocator is part of an object declaration, the rules described above are used
12462 to construct its image, and this image is not affected by subsequent
12463 assignments. If the allocator appears within an expression, the image
12464 includes only the name of the task type.
12466 If the configuration pragma Discard_Names is present, or if the restriction
12467 No_Implicit_Heap_Allocation is in effect, the image reduces to
12468 the numeric suffix, that is to say the hexadecimal representation of the
12469 virtual address of the control block of the task.
12473 @strong{90}. The value of @code{Current_Task} when in a protected entry
12474 or interrupt handler. See C.7.1(17).
12477 Protected entries or interrupt handlers can be executed by any
12478 convenient thread, so the value of @code{Current_Task} is undefined.
12483 @strong{91}. The effect of calling @code{Current_Task} from an entry
12484 body or interrupt handler. See C.7.1(19).
12487 The effect of calling @code{Current_Task} from an entry body or
12488 interrupt handler is to return the identification of the task currently
12489 executing the code.
12494 @strong{92}. Implementation-defined aspects of
12495 @code{Task_Attributes}. See C.7.2(19).
12498 There are no implementation-defined aspects of @code{Task_Attributes}.
12503 @strong{93}. Values of all @code{Metrics}. See D(2).
12506 The metrics information for GNAT depends on the performance of the
12507 underlying operating system. The sources of the run-time for tasking
12508 implementation, together with the output from @option{-gnatG} can be
12509 used to determine the exact sequence of operating systems calls made
12510 to implement various tasking constructs. Together with appropriate
12511 information on the performance of the underlying operating system,
12512 on the exact target in use, this information can be used to determine
12513 the required metrics.
12518 @strong{94}. The declarations of @code{Any_Priority} and
12519 @code{Priority}. See D.1(11).
12522 See declarations in file @file{system.ads}.
12527 @strong{95}. Implementation-defined execution resources. See D.1(15).
12530 There are no implementation-defined execution resources.
12535 @strong{96}. Whether, on a multiprocessor, a task that is waiting for
12536 access to a protected object keeps its processor busy. See D.2.1(3).
12539 On a multi-processor, a task that is waiting for access to a protected
12540 object does not keep its processor busy.
12545 @strong{97}. The affect of implementation defined execution resources
12546 on task dispatching. See D.2.1(9).
12549 Tasks map to threads in the threads package used by GNAT@. Where possible
12550 and appropriate, these threads correspond to native threads of the
12551 underlying operating system.
12556 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
12557 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
12560 There are no implementation-defined policy-identifiers allowed in this
12566 @strong{99}. Implementation-defined aspects of priority inversion. See
12570 Execution of a task cannot be preempted by the implementation processing
12571 of delay expirations for lower priority tasks.
12576 @strong{100}. Implementation-defined task dispatching. See D.2.2(18).
12579 The policy is the same as that of the underlying threads implementation.
12584 @strong{101}. Implementation-defined @code{policy_identifiers} allowed
12585 in a pragma @code{Locking_Policy}. See D.3(4).
12588 The two implementation defined policies permitted in GNAT are
12589 @code{Inheritance_Locking} and @code{Conccurent_Readers_Locking}. On
12590 targets that support the @code{Inheritance_Locking} policy, locking is
12591 implemented by inheritance, i.e.@: the task owning the lock operates
12592 at a priority equal to the highest priority of any task currently
12593 requesting the lock. On targets that support the
12594 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
12595 read/write lock allowing multiple propected object functions to enter
12601 @strong{102}. Default ceiling priorities. See D.3(10).
12604 The ceiling priority of protected objects of the type
12605 @code{System.Interrupt_Priority'Last} as described in the Ada
12606 Reference Manual D.3(10),
12611 @strong{103}. The ceiling of any protected object used internally by
12612 the implementation. See D.3(16).
12615 The ceiling priority of internal protected objects is
12616 @code{System.Priority'Last}.
12621 @strong{104}. Implementation-defined queuing policies. See D.4(1).
12624 There are no implementation-defined queuing policies.
12629 @strong{105}. On a multiprocessor, any conditions that cause the
12630 completion of an aborted construct to be delayed later than what is
12631 specified for a single processor. See D.6(3).
12634 The semantics for abort on a multi-processor is the same as on a single
12635 processor, there are no further delays.
12640 @strong{106}. Any operations that implicitly require heap storage
12641 allocation. See D.7(8).
12644 The only operation that implicitly requires heap storage allocation is
12650 @strong{107}. Implementation-defined aspects of pragma
12651 @code{Restrictions}. See D.7(20).
12654 There are no such implementation-defined aspects.
12659 @strong{108}. Implementation-defined aspects of package
12660 @code{Real_Time}. See D.8(17).
12663 There are no implementation defined aspects of package @code{Real_Time}.
12668 @strong{109}. Implementation-defined aspects of
12669 @code{delay_statements}. See D.9(8).
12672 Any difference greater than one microsecond will cause the task to be
12673 delayed (see D.9(7)).
12678 @strong{110}. The upper bound on the duration of interrupt blocking
12679 caused by the implementation. See D.12(5).
12682 The upper bound is determined by the underlying operating system. In
12683 no cases is it more than 10 milliseconds.
12688 @strong{111}. The means for creating and executing distributed
12689 programs. See E(5).
12692 The GLADE package provides a utility GNATDIST for creating and executing
12693 distributed programs. See the GLADE reference manual for further details.
12698 @strong{112}. Any events that can result in a partition becoming
12699 inaccessible. See E.1(7).
12702 See the GLADE reference manual for full details on such events.
12707 @strong{113}. The scheduling policies, treatment of priorities, and
12708 management of shared resources between partitions in certain cases. See
12712 See the GLADE reference manual for full details on these aspects of
12713 multi-partition execution.
12718 @strong{114}. Events that cause the version of a compilation unit to
12719 change. See E.3(5).
12722 Editing the source file of a compilation unit, or the source files of
12723 any units on which it is dependent in a significant way cause the version
12724 to change. No other actions cause the version number to change. All changes
12725 are significant except those which affect only layout, capitalization or
12731 @strong{115}. Whether the execution of the remote subprogram is
12732 immediately aborted as a result of cancellation. See E.4(13).
12735 See the GLADE reference manual for details on the effect of abort in
12736 a distributed application.
12741 @strong{116}. Implementation-defined aspects of the PCS@. See E.5(25).
12744 See the GLADE reference manual for a full description of all implementation
12745 defined aspects of the PCS@.
12750 @strong{117}. Implementation-defined interfaces in the PCS@. See
12754 See the GLADE reference manual for a full description of all
12755 implementation defined interfaces.
12760 @strong{118}. The values of named numbers in the package
12761 @code{Decimal}. See F.2(7).
12773 @item Max_Decimal_Digits
12780 @strong{119}. The value of @code{Max_Picture_Length} in the package
12781 @code{Text_IO.Editing}. See F.3.3(16).
12789 @strong{120}. The value of @code{Max_Picture_Length} in the package
12790 @code{Wide_Text_IO.Editing}. See F.3.4(5).
12798 @strong{121}. The accuracy actually achieved by the complex elementary
12799 functions and by other complex arithmetic operations. See G.1(1).
12802 Standard library functions are used for the complex arithmetic
12803 operations. Only fast math mode is currently supported.
12808 @strong{122}. The sign of a zero result (or a component thereof) from
12809 any operator or function in @code{Numerics.Generic_Complex_Types}, when
12810 @code{Real'Signed_Zeros} is True. See G.1.1(53).
12813 The signs of zero values are as recommended by the relevant
12814 implementation advice.
12819 @strong{123}. The sign of a zero result (or a component thereof) from
12820 any operator or function in
12821 @code{Numerics.Generic_Complex_Elementary_Functions}, when
12822 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
12825 The signs of zero values are as recommended by the relevant
12826 implementation advice.
12831 @strong{124}. Whether the strict mode or the relaxed mode is the
12832 default. See G.2(2).
12835 The strict mode is the default. There is no separate relaxed mode. GNAT
12836 provides a highly efficient implementation of strict mode.
12841 @strong{125}. The result interval in certain cases of fixed-to-float
12842 conversion. See G.2.1(10).
12845 For cases where the result interval is implementation dependent, the
12846 accuracy is that provided by performing all operations in 64-bit IEEE
12847 floating-point format.
12852 @strong{126}. The result of a floating point arithmetic operation in
12853 overflow situations, when the @code{Machine_Overflows} attribute of the
12854 result type is @code{False}. See G.2.1(13).
12857 Infinite and NaN values are produced as dictated by the IEEE
12858 floating-point standard.
12860 Note that on machines that are not fully compliant with the IEEE
12861 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
12862 must be used for achieving IEEE conforming behavior (although at the cost
12863 of a significant performance penalty), so infinite and NaN values are
12864 properly generated.
12869 @strong{127}. The result interval for division (or exponentiation by a
12870 negative exponent), when the floating point hardware implements division
12871 as multiplication by a reciprocal. See G.2.1(16).
12874 Not relevant, division is IEEE exact.
12879 @strong{128}. The definition of close result set, which determines the
12880 accuracy of certain fixed point multiplications and divisions. See
12884 Operations in the close result set are performed using IEEE long format
12885 floating-point arithmetic. The input operands are converted to
12886 floating-point, the operation is done in floating-point, and the result
12887 is converted to the target type.
12892 @strong{129}. Conditions on a @code{universal_real} operand of a fixed
12893 point multiplication or division for which the result shall be in the
12894 perfect result set. See G.2.3(22).
12897 The result is only defined to be in the perfect result set if the result
12898 can be computed by a single scaling operation involving a scale factor
12899 representable in 64-bits.
12904 @strong{130}. The result of a fixed point arithmetic operation in
12905 overflow situations, when the @code{Machine_Overflows} attribute of the
12906 result type is @code{False}. See G.2.3(27).
12909 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
12915 @strong{131}. The result of an elementary function reference in
12916 overflow situations, when the @code{Machine_Overflows} attribute of the
12917 result type is @code{False}. See G.2.4(4).
12920 IEEE infinite and Nan values are produced as appropriate.
12925 @strong{132}. The value of the angle threshold, within which certain
12926 elementary functions, complex arithmetic operations, and complex
12927 elementary functions yield results conforming to a maximum relative
12928 error bound. See G.2.4(10).
12931 Information on this subject is not yet available.
12936 @strong{133}. The accuracy of certain elementary functions for
12937 parameters beyond the angle threshold. See G.2.4(10).
12940 Information on this subject is not yet available.
12945 @strong{134}. The result of a complex arithmetic operation or complex
12946 elementary function reference in overflow situations, when the
12947 @code{Machine_Overflows} attribute of the corresponding real type is
12948 @code{False}. See G.2.6(5).
12951 IEEE infinite and Nan values are produced as appropriate.
12956 @strong{135}. The accuracy of certain complex arithmetic operations and
12957 certain complex elementary functions for parameters (or components
12958 thereof) beyond the angle threshold. See G.2.6(8).
12961 Information on those subjects is not yet available.
12966 @strong{136}. Information regarding bounded errors and erroneous
12967 execution. See H.2(1).
12970 Information on this subject is not yet available.
12975 @strong{137}. Implementation-defined aspects of pragma
12976 @code{Inspection_Point}. See H.3.2(8).
12979 Pragma @code{Inspection_Point} ensures that the variable is live and can
12980 be examined by the debugger at the inspection point.
12985 @strong{138}. Implementation-defined aspects of pragma
12986 @code{Restrictions}. See H.4(25).
12989 There are no implementation-defined aspects of pragma @code{Restrictions}. The
12990 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
12991 generated code. Checks must suppressed by use of pragma @code{Suppress}.
12996 @strong{139}. Any restrictions on pragma @code{Restrictions}. See
13000 There are no restrictions on pragma @code{Restrictions}.
13002 @node Intrinsic Subprograms
13003 @chapter Intrinsic Subprograms
13004 @cindex Intrinsic Subprograms
13007 * Intrinsic Operators::
13008 * Enclosing_Entity::
13009 * Exception_Information::
13010 * Exception_Message::
13014 * Shifts and Rotates::
13015 * Source_Location::
13019 GNAT allows a user application program to write the declaration:
13021 @smallexample @c ada
13022 pragma Import (Intrinsic, name);
13026 providing that the name corresponds to one of the implemented intrinsic
13027 subprograms in GNAT, and that the parameter profile of the referenced
13028 subprogram meets the requirements. This chapter describes the set of
13029 implemented intrinsic subprograms, and the requirements on parameter profiles.
13030 Note that no body is supplied; as with other uses of pragma Import, the
13031 body is supplied elsewhere (in this case by the compiler itself). Note
13032 that any use of this feature is potentially non-portable, since the
13033 Ada standard does not require Ada compilers to implement this feature.
13035 @node Intrinsic Operators
13036 @section Intrinsic Operators
13037 @cindex Intrinsic operator
13040 All the predefined numeric operators in package Standard
13041 in @code{pragma Import (Intrinsic,..)}
13042 declarations. In the binary operator case, the operands must have the same
13043 size. The operand or operands must also be appropriate for
13044 the operator. For example, for addition, the operands must
13045 both be floating-point or both be fixed-point, and the
13046 right operand for @code{"**"} must have a root type of
13047 @code{Standard.Integer'Base}.
13048 You can use an intrinsic operator declaration as in the following example:
13050 @smallexample @c ada
13051 type Int1 is new Integer;
13052 type Int2 is new Integer;
13054 function "+" (X1 : Int1; X2 : Int2) return Int1;
13055 function "+" (X1 : Int1; X2 : Int2) return Int2;
13056 pragma Import (Intrinsic, "+");
13060 This declaration would permit ``mixed mode'' arithmetic on items
13061 of the differing types @code{Int1} and @code{Int2}.
13062 It is also possible to specify such operators for private types, if the
13063 full views are appropriate arithmetic types.
13065 @node Enclosing_Entity
13066 @section Enclosing_Entity
13067 @cindex Enclosing_Entity
13069 This intrinsic subprogram is used in the implementation of the
13070 library routine @code{GNAT.Source_Info}. The only useful use of the
13071 intrinsic import in this case is the one in this unit, so an
13072 application program should simply call the function
13073 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
13074 the current subprogram, package, task, entry, or protected subprogram.
13076 @node Exception_Information
13077 @section Exception_Information
13078 @cindex Exception_Information'
13080 This intrinsic subprogram is used in the implementation of the
13081 library routine @code{GNAT.Current_Exception}. The only useful
13082 use of the intrinsic import in this case is the one in this unit,
13083 so an application program should simply call the function
13084 @code{GNAT.Current_Exception.Exception_Information} to obtain
13085 the exception information associated with the current exception.
13087 @node Exception_Message
13088 @section Exception_Message
13089 @cindex Exception_Message
13091 This intrinsic subprogram is used in the implementation of the
13092 library routine @code{GNAT.Current_Exception}. The only useful
13093 use of the intrinsic import in this case is the one in this unit,
13094 so an application program should simply call the function
13095 @code{GNAT.Current_Exception.Exception_Message} to obtain
13096 the message associated with the current exception.
13098 @node Exception_Name
13099 @section Exception_Name
13100 @cindex Exception_Name
13102 This intrinsic subprogram is used in the implementation of the
13103 library routine @code{GNAT.Current_Exception}. The only useful
13104 use of the intrinsic import in this case is the one in this unit,
13105 so an application program should simply call the function
13106 @code{GNAT.Current_Exception.Exception_Name} to obtain
13107 the name of the current exception.
13113 This intrinsic subprogram is used in the implementation of the
13114 library routine @code{GNAT.Source_Info}. The only useful use of the
13115 intrinsic import in this case is the one in this unit, so an
13116 application program should simply call the function
13117 @code{GNAT.Source_Info.File} to obtain the name of the current
13124 This intrinsic subprogram is used in the implementation of the
13125 library routine @code{GNAT.Source_Info}. The only useful use of the
13126 intrinsic import in this case is the one in this unit, so an
13127 application program should simply call the function
13128 @code{GNAT.Source_Info.Line} to obtain the number of the current
13131 @node Shifts and Rotates
13132 @section Shifts and Rotates
13134 @cindex Shift_Right
13135 @cindex Shift_Right_Arithmetic
13136 @cindex Rotate_Left
13137 @cindex Rotate_Right
13139 In standard Ada, the shift and rotate functions are available only
13140 for the predefined modular types in package @code{Interfaces}. However, in
13141 GNAT it is possible to define these functions for any integer
13142 type (signed or modular), as in this example:
13144 @smallexample @c ada
13145 function Shift_Left
13152 The function name must be one of
13153 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
13154 Rotate_Right. T must be an integer type. T'Size must be
13155 8, 16, 32 or 64 bits; if T is modular, the modulus
13156 must be 2**8, 2**16, 2**32 or 2**64.
13157 The result type must be the same as the type of @code{Value}.
13158 The shift amount must be Natural.
13159 The formal parameter names can be anything.
13161 @node Source_Location
13162 @section Source_Location
13163 @cindex Source_Location
13165 This intrinsic subprogram is used in the implementation of the
13166 library routine @code{GNAT.Source_Info}. The only useful use of the
13167 intrinsic import in this case is the one in this unit, so an
13168 application program should simply call the function
13169 @code{GNAT.Source_Info.Source_Location} to obtain the current
13170 source file location.
13172 @node Representation Clauses and Pragmas
13173 @chapter Representation Clauses and Pragmas
13174 @cindex Representation Clauses
13177 * Alignment Clauses::
13179 * Storage_Size Clauses::
13180 * Size of Variant Record Objects::
13181 * Biased Representation ::
13182 * Value_Size and Object_Size Clauses::
13183 * Component_Size Clauses::
13184 * Bit_Order Clauses::
13185 * Effect of Bit_Order on Byte Ordering::
13186 * Pragma Pack for Arrays::
13187 * Pragma Pack for Records::
13188 * Record Representation Clauses::
13189 * Enumeration Clauses::
13190 * Address Clauses::
13191 * Effect of Convention on Representation::
13192 * Determining the Representations chosen by GNAT::
13196 @cindex Representation Clause
13197 @cindex Representation Pragma
13198 @cindex Pragma, representation
13199 This section describes the representation clauses accepted by GNAT, and
13200 their effect on the representation of corresponding data objects.
13202 GNAT fully implements Annex C (Systems Programming). This means that all
13203 the implementation advice sections in chapter 13 are fully implemented.
13204 However, these sections only require a minimal level of support for
13205 representation clauses. GNAT provides much more extensive capabilities,
13206 and this section describes the additional capabilities provided.
13208 @node Alignment Clauses
13209 @section Alignment Clauses
13210 @cindex Alignment Clause
13213 GNAT requires that all alignment clauses specify a power of 2, and all
13214 default alignments are always a power of 2. The default alignment
13215 values are as follows:
13218 @item @emph{Primitive Types}.
13219 For primitive types, the alignment is the minimum of the actual size of
13220 objects of the type divided by @code{Storage_Unit},
13221 and the maximum alignment supported by the target.
13222 (This maximum alignment is given by the GNAT-specific attribute
13223 @code{Standard'Maximum_Alignment}; see @ref{Attribute Maximum_Alignment}.)
13224 @cindex @code{Maximum_Alignment} attribute
13225 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
13226 default alignment will be 8 on any target that supports alignments
13227 this large, but on some targets, the maximum alignment may be smaller
13228 than 8, in which case objects of type @code{Long_Float} will be maximally
13231 @item @emph{Arrays}.
13232 For arrays, the alignment is equal to the alignment of the component type
13233 for the normal case where no packing or component size is given. If the
13234 array is packed, and the packing is effective (see separate section on
13235 packed arrays), then the alignment will be one for long packed arrays,
13236 or arrays whose length is not known at compile time. For short packed
13237 arrays, which are handled internally as modular types, the alignment
13238 will be as described for primitive types, e.g.@: a packed array of length
13239 31 bits will have an object size of four bytes, and an alignment of 4.
13241 @item @emph{Records}.
13242 For the normal non-packed case, the alignment of a record is equal to
13243 the maximum alignment of any of its components. For tagged records, this
13244 includes the implicit access type used for the tag. If a pragma @code{Pack}
13245 is used and all components are packable (see separate section on pragma
13246 @code{Pack}), then the resulting alignment is 1, unless the layout of the
13247 record makes it profitable to increase it.
13249 A special case is when:
13252 the size of the record is given explicitly, or a
13253 full record representation clause is given, and
13255 the size of the record is 2, 4, or 8 bytes.
13258 In this case, an alignment is chosen to match the
13259 size of the record. For example, if we have:
13261 @smallexample @c ada
13262 type Small is record
13265 for Small'Size use 16;
13269 then the default alignment of the record type @code{Small} is 2, not 1. This
13270 leads to more efficient code when the record is treated as a unit, and also
13271 allows the type to specified as @code{Atomic} on architectures requiring
13277 An alignment clause may specify a larger alignment than the default value
13278 up to some maximum value dependent on the target (obtainable by using the
13279 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
13280 a smaller alignment than the default value for enumeration, integer and
13281 fixed point types, as well as for record types, for example
13283 @smallexample @c ada
13288 for V'alignment use 1;
13292 @cindex Alignment, default
13293 The default alignment for the type @code{V} is 4, as a result of the
13294 Integer field in the record, but it is permissible, as shown, to
13295 override the default alignment of the record with a smaller value.
13297 @cindex Alignment, subtypes
13298 Note that according to the Ada standard, an alignment clause applies only
13299 to the first named subtype. If additional subtypes are declared, then the
13300 compiler is allowed to choose any alignment it likes, and there is no way
13301 to control this choice. Consider:
13303 @smallexample @c ada
13304 type R is range 1 .. 10_000;
13305 for R'Alignment use 1;
13306 subtype RS is R range 1 .. 1000;
13310 The alignment clause specifies an alignment of 1 for the first named subtype
13311 @code{R} but this does not necessarily apply to @code{RS}. When writing
13312 portable Ada code, you should avoid writing code that explicitly or
13313 implicitly relies on the alignment of such subtypes.
13315 For the GNAT compiler, if an explicit alignment clause is given, this
13316 value is also used for any subsequent subtypes. So for GNAT, in the
13317 above example, you can count on the alignment of @code{RS} being 1. But this
13318 assumption is non-portable, and other compilers may choose different
13319 alignments for the subtype @code{RS}.
13322 @section Size Clauses
13323 @cindex Size Clause
13326 The default size for a type @code{T} is obtainable through the
13327 language-defined attribute @code{T'Size} and also through the
13328 equivalent GNAT-defined attribute @code{T'Value_Size}.
13329 For objects of type @code{T}, GNAT will generally increase the type size
13330 so that the object size (obtainable through the GNAT-defined attribute
13331 @code{T'Object_Size})
13332 is a multiple of @code{T'Alignment * Storage_Unit}.
13335 @smallexample @c ada
13336 type Smallint is range 1 .. 6;
13345 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
13346 as specified by the RM rules,
13347 but objects of this type will have a size of 8
13348 (@code{Smallint'Object_Size} = 8),
13349 since objects by default occupy an integral number
13350 of storage units. On some targets, notably older
13351 versions of the Digital Alpha, the size of stand
13352 alone objects of this type may be 32, reflecting
13353 the inability of the hardware to do byte load/stores.
13355 Similarly, the size of type @code{Rec} is 40 bits
13356 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
13357 the alignment is 4, so objects of this type will have
13358 their size increased to 64 bits so that it is a multiple
13359 of the alignment (in bits). This decision is
13360 in accordance with the specific Implementation Advice in RM 13.3(43):
13363 A @code{Size} clause should be supported for an object if the specified
13364 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
13365 to a size in storage elements that is a multiple of the object's
13366 @code{Alignment} (if the @code{Alignment} is nonzero).
13370 An explicit size clause may be used to override the default size by
13371 increasing it. For example, if we have:
13373 @smallexample @c ada
13374 type My_Boolean is new Boolean;
13375 for My_Boolean'Size use 32;
13379 then values of this type will always be 32 bits long. In the case of
13380 discrete types, the size can be increased up to 64 bits, with the effect
13381 that the entire specified field is used to hold the value, sign- or
13382 zero-extended as appropriate. If more than 64 bits is specified, then
13383 padding space is allocated after the value, and a warning is issued that
13384 there are unused bits.
13386 Similarly the size of records and arrays may be increased, and the effect
13387 is to add padding bits after the value. This also causes a warning message
13390 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
13391 Size in bits, this corresponds to an object of size 256 megabytes (minus
13392 one). This limitation is true on all targets. The reason for this
13393 limitation is that it improves the quality of the code in many cases
13394 if it is known that a Size value can be accommodated in an object of
13397 @node Storage_Size Clauses
13398 @section Storage_Size Clauses
13399 @cindex Storage_Size Clause
13402 For tasks, the @code{Storage_Size} clause specifies the amount of space
13403 to be allocated for the task stack. This cannot be extended, and if the
13404 stack is exhausted, then @code{Storage_Error} will be raised (if stack
13405 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
13406 or a @code{Storage_Size} pragma in the task definition to set the
13407 appropriate required size. A useful technique is to include in every
13408 task definition a pragma of the form:
13410 @smallexample @c ada
13411 pragma Storage_Size (Default_Stack_Size);
13415 Then @code{Default_Stack_Size} can be defined in a global package, and
13416 modified as required. Any tasks requiring stack sizes different from the
13417 default can have an appropriate alternative reference in the pragma.
13419 You can also use the @option{-d} binder switch to modify the default stack
13422 For access types, the @code{Storage_Size} clause specifies the maximum
13423 space available for allocation of objects of the type. If this space is
13424 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
13425 In the case where the access type is declared local to a subprogram, the
13426 use of a @code{Storage_Size} clause triggers automatic use of a special
13427 predefined storage pool (@code{System.Pool_Size}) that ensures that all
13428 space for the pool is automatically reclaimed on exit from the scope in
13429 which the type is declared.
13431 A special case recognized by the compiler is the specification of a
13432 @code{Storage_Size} of zero for an access type. This means that no
13433 items can be allocated from the pool, and this is recognized at compile
13434 time, and all the overhead normally associated with maintaining a fixed
13435 size storage pool is eliminated. Consider the following example:
13437 @smallexample @c ada
13439 type R is array (Natural) of Character;
13440 type P is access all R;
13441 for P'Storage_Size use 0;
13442 -- Above access type intended only for interfacing purposes
13446 procedure g (m : P);
13447 pragma Import (C, g);
13458 As indicated in this example, these dummy storage pools are often useful in
13459 connection with interfacing where no object will ever be allocated. If you
13460 compile the above example, you get the warning:
13463 p.adb:16:09: warning: allocation from empty storage pool
13464 p.adb:16:09: warning: Storage_Error will be raised at run time
13468 Of course in practice, there will not be any explicit allocators in the
13469 case of such an access declaration.
13471 @node Size of Variant Record Objects
13472 @section Size of Variant Record Objects
13473 @cindex Size, variant record objects
13474 @cindex Variant record objects, size
13477 In the case of variant record objects, there is a question whether Size gives
13478 information about a particular variant, or the maximum size required
13479 for any variant. Consider the following program
13481 @smallexample @c ada
13482 with Text_IO; use Text_IO;
13484 type R1 (A : Boolean := False) is record
13486 when True => X : Character;
13487 when False => null;
13495 Put_Line (Integer'Image (V1'Size));
13496 Put_Line (Integer'Image (V2'Size));
13501 Here we are dealing with a variant record, where the True variant
13502 requires 16 bits, and the False variant requires 8 bits.
13503 In the above example, both V1 and V2 contain the False variant,
13504 which is only 8 bits long. However, the result of running the
13513 The reason for the difference here is that the discriminant value of
13514 V1 is fixed, and will always be False. It is not possible to assign
13515 a True variant value to V1, therefore 8 bits is sufficient. On the
13516 other hand, in the case of V2, the initial discriminant value is
13517 False (from the default), but it is possible to assign a True
13518 variant value to V2, therefore 16 bits must be allocated for V2
13519 in the general case, even fewer bits may be needed at any particular
13520 point during the program execution.
13522 As can be seen from the output of this program, the @code{'Size}
13523 attribute applied to such an object in GNAT gives the actual allocated
13524 size of the variable, which is the largest size of any of the variants.
13525 The Ada Reference Manual is not completely clear on what choice should
13526 be made here, but the GNAT behavior seems most consistent with the
13527 language in the RM@.
13529 In some cases, it may be desirable to obtain the size of the current
13530 variant, rather than the size of the largest variant. This can be
13531 achieved in GNAT by making use of the fact that in the case of a
13532 subprogram parameter, GNAT does indeed return the size of the current
13533 variant (because a subprogram has no way of knowing how much space
13534 is actually allocated for the actual).
13536 Consider the following modified version of the above program:
13538 @smallexample @c ada
13539 with Text_IO; use Text_IO;
13541 type R1 (A : Boolean := False) is record
13543 when True => X : Character;
13544 when False => null;
13550 function Size (V : R1) return Integer is
13556 Put_Line (Integer'Image (V2'Size));
13557 Put_Line (Integer'IMage (Size (V2)));
13559 Put_Line (Integer'Image (V2'Size));
13560 Put_Line (Integer'IMage (Size (V2)));
13565 The output from this program is
13575 Here we see that while the @code{'Size} attribute always returns
13576 the maximum size, regardless of the current variant value, the
13577 @code{Size} function does indeed return the size of the current
13580 @node Biased Representation
13581 @section Biased Representation
13582 @cindex Size for biased representation
13583 @cindex Biased representation
13586 In the case of scalars with a range starting at other than zero, it is
13587 possible in some cases to specify a size smaller than the default minimum
13588 value, and in such cases, GNAT uses an unsigned biased representation,
13589 in which zero is used to represent the lower bound, and successive values
13590 represent successive values of the type.
13592 For example, suppose we have the declaration:
13594 @smallexample @c ada
13595 type Small is range -7 .. -4;
13596 for Small'Size use 2;
13600 Although the default size of type @code{Small} is 4, the @code{Size}
13601 clause is accepted by GNAT and results in the following representation
13605 -7 is represented as 2#00#
13606 -6 is represented as 2#01#
13607 -5 is represented as 2#10#
13608 -4 is represented as 2#11#
13612 Biased representation is only used if the specified @code{Size} clause
13613 cannot be accepted in any other manner. These reduced sizes that force
13614 biased representation can be used for all discrete types except for
13615 enumeration types for which a representation clause is given.
13617 @node Value_Size and Object_Size Clauses
13618 @section Value_Size and Object_Size Clauses
13620 @findex Object_Size
13621 @cindex Size, of objects
13624 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
13625 number of bits required to hold values of type @code{T}.
13626 Although this interpretation was allowed in Ada 83, it was not required,
13627 and this requirement in practice can cause some significant difficulties.
13628 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
13629 However, in Ada 95 and Ada 2005,
13630 @code{Natural'Size} is
13631 typically 31. This means that code may change in behavior when moving
13632 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
13634 @smallexample @c ada
13635 type Rec is record;
13641 at 0 range 0 .. Natural'Size - 1;
13642 at 0 range Natural'Size .. 2 * Natural'Size - 1;
13647 In the above code, since the typical size of @code{Natural} objects
13648 is 32 bits and @code{Natural'Size} is 31, the above code can cause
13649 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
13650 there are cases where the fact that the object size can exceed the
13651 size of the type causes surprises.
13653 To help get around this problem GNAT provides two implementation
13654 defined attributes, @code{Value_Size} and @code{Object_Size}. When
13655 applied to a type, these attributes yield the size of the type
13656 (corresponding to the RM defined size attribute), and the size of
13657 objects of the type respectively.
13659 The @code{Object_Size} is used for determining the default size of
13660 objects and components. This size value can be referred to using the
13661 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
13662 the basis of the determination of the size. The backend is free to
13663 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
13664 character might be stored in 32 bits on a machine with no efficient
13665 byte access instructions such as the Alpha.
13667 The default rules for the value of @code{Object_Size} for
13668 discrete types are as follows:
13672 The @code{Object_Size} for base subtypes reflect the natural hardware
13673 size in bits (run the compiler with @option{-gnatS} to find those values
13674 for numeric types). Enumeration types and fixed-point base subtypes have
13675 8, 16, 32 or 64 bits for this size, depending on the range of values
13679 The @code{Object_Size} of a subtype is the same as the
13680 @code{Object_Size} of
13681 the type from which it is obtained.
13684 The @code{Object_Size} of a derived base type is copied from the parent
13685 base type, and the @code{Object_Size} of a derived first subtype is copied
13686 from the parent first subtype.
13690 The @code{Value_Size} attribute
13691 is the (minimum) number of bits required to store a value
13693 This value is used to determine how tightly to pack
13694 records or arrays with components of this type, and also affects
13695 the semantics of unchecked conversion (unchecked conversions where
13696 the @code{Value_Size} values differ generate a warning, and are potentially
13699 The default rules for the value of @code{Value_Size} are as follows:
13703 The @code{Value_Size} for a base subtype is the minimum number of bits
13704 required to store all values of the type (including the sign bit
13705 only if negative values are possible).
13708 If a subtype statically matches the first subtype of a given type, then it has
13709 by default the same @code{Value_Size} as the first subtype. This is a
13710 consequence of RM 13.1(14) (``if two subtypes statically match,
13711 then their subtype-specific aspects are the same''.)
13714 All other subtypes have a @code{Value_Size} corresponding to the minimum
13715 number of bits required to store all values of the subtype. For
13716 dynamic bounds, it is assumed that the value can range down or up
13717 to the corresponding bound of the ancestor
13721 The RM defined attribute @code{Size} corresponds to the
13722 @code{Value_Size} attribute.
13724 The @code{Size} attribute may be defined for a first-named subtype. This sets
13725 the @code{Value_Size} of
13726 the first-named subtype to the given value, and the
13727 @code{Object_Size} of this first-named subtype to the given value padded up
13728 to an appropriate boundary. It is a consequence of the default rules
13729 above that this @code{Object_Size} will apply to all further subtypes. On the
13730 other hand, @code{Value_Size} is affected only for the first subtype, any
13731 dynamic subtypes obtained from it directly, and any statically matching
13732 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
13734 @code{Value_Size} and
13735 @code{Object_Size} may be explicitly set for any subtype using
13736 an attribute definition clause. Note that the use of these attributes
13737 can cause the RM 13.1(14) rule to be violated. If two access types
13738 reference aliased objects whose subtypes have differing @code{Object_Size}
13739 values as a result of explicit attribute definition clauses, then it
13740 is erroneous to convert from one access subtype to the other.
13742 At the implementation level, Esize stores the Object_Size and the
13743 RM_Size field stores the @code{Value_Size} (and hence the value of the
13744 @code{Size} attribute,
13745 which, as noted above, is equivalent to @code{Value_Size}).
13747 To get a feel for the difference, consider the following examples (note
13748 that in each case the base is @code{Short_Short_Integer} with a size of 8):
13751 Object_Size Value_Size
13753 type x1 is range 0 .. 5; 8 3
13755 type x2 is range 0 .. 5;
13756 for x2'size use 12; 16 12
13758 subtype x3 is x2 range 0 .. 3; 16 2
13760 subtype x4 is x2'base range 0 .. 10; 8 4
13762 subtype x5 is x2 range 0 .. dynamic; 16 3*
13764 subtype x6 is x2'base range 0 .. dynamic; 8 3*
13769 Note: the entries marked ``3*'' are not actually specified by the Ada
13770 Reference Manual, but it seems in the spirit of the RM rules to allocate
13771 the minimum number of bits (here 3, given the range for @code{x2})
13772 known to be large enough to hold the given range of values.
13774 So far, so good, but GNAT has to obey the RM rules, so the question is
13775 under what conditions must the RM @code{Size} be used.
13776 The following is a list
13777 of the occasions on which the RM @code{Size} must be used:
13781 Component size for packed arrays or records
13784 Value of the attribute @code{Size} for a type
13787 Warning about sizes not matching for unchecked conversion
13791 For record types, the @code{Object_Size} is always a multiple of the
13792 alignment of the type (this is true for all types). In some cases the
13793 @code{Value_Size} can be smaller. Consider:
13803 On a typical 32-bit architecture, the X component will be four bytes, and
13804 require four-byte alignment, and the Y component will be one byte. In this
13805 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
13806 required to store a value of this type, and for example, it is permissible
13807 to have a component of type R in an outer array whose component size is
13808 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
13809 since it must be rounded up so that this value is a multiple of the
13810 alignment (4 bytes = 32 bits).
13813 For all other types, the @code{Object_Size}
13814 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
13815 Only @code{Size} may be specified for such types.
13817 @node Component_Size Clauses
13818 @section Component_Size Clauses
13819 @cindex Component_Size Clause
13822 Normally, the value specified in a component size clause must be consistent
13823 with the subtype of the array component with regard to size and alignment.
13824 In other words, the value specified must be at least equal to the size
13825 of this subtype, and must be a multiple of the alignment value.
13827 In addition, component size clauses are allowed which cause the array
13828 to be packed, by specifying a smaller value. A first case is for
13829 component size values in the range 1 through 63. The value specified
13830 must not be smaller than the Size of the subtype. GNAT will accurately
13831 honor all packing requests in this range. For example, if we have:
13833 @smallexample @c ada
13834 type r is array (1 .. 8) of Natural;
13835 for r'Component_Size use 31;
13839 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
13840 Of course access to the components of such an array is considerably
13841 less efficient than if the natural component size of 32 is used.
13842 A second case is when the subtype of the component is a record type
13843 padded because of its default alignment. For example, if we have:
13845 @smallexample @c ada
13852 type a is array (1 .. 8) of r;
13853 for a'Component_Size use 72;
13857 then the resulting array has a length of 72 bytes, instead of 96 bytes
13858 if the alignment of the record (4) was obeyed.
13860 Note that there is no point in giving both a component size clause
13861 and a pragma Pack for the same array type. if such duplicate
13862 clauses are given, the pragma Pack will be ignored.
13864 @node Bit_Order Clauses
13865 @section Bit_Order Clauses
13866 @cindex Bit_Order Clause
13867 @cindex bit ordering
13868 @cindex ordering, of bits
13871 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
13872 attribute. The specification may either correspond to the default bit
13873 order for the target, in which case the specification has no effect and
13874 places no additional restrictions, or it may be for the non-standard
13875 setting (that is the opposite of the default).
13877 In the case where the non-standard value is specified, the effect is
13878 to renumber bits within each byte, but the ordering of bytes is not
13879 affected. There are certain
13880 restrictions placed on component clauses as follows:
13884 @item Components fitting within a single storage unit.
13886 These are unrestricted, and the effect is merely to renumber bits. For
13887 example if we are on a little-endian machine with @code{Low_Order_First}
13888 being the default, then the following two declarations have exactly
13891 @smallexample @c ada
13894 B : Integer range 1 .. 120;
13898 A at 0 range 0 .. 0;
13899 B at 0 range 1 .. 7;
13904 B : Integer range 1 .. 120;
13907 for R2'Bit_Order use High_Order_First;
13910 A at 0 range 7 .. 7;
13911 B at 0 range 0 .. 6;
13916 The useful application here is to write the second declaration with the
13917 @code{Bit_Order} attribute definition clause, and know that it will be treated
13918 the same, regardless of whether the target is little-endian or big-endian.
13920 @item Components occupying an integral number of bytes.
13922 These are components that exactly fit in two or more bytes. Such component
13923 declarations are allowed, but have no effect, since it is important to realize
13924 that the @code{Bit_Order} specification does not affect the ordering of bytes.
13925 In particular, the following attempt at getting an endian-independent integer
13928 @smallexample @c ada
13933 for R2'Bit_Order use High_Order_First;
13936 A at 0 range 0 .. 31;
13941 This declaration will result in a little-endian integer on a
13942 little-endian machine, and a big-endian integer on a big-endian machine.
13943 If byte flipping is required for interoperability between big- and
13944 little-endian machines, this must be explicitly programmed. This capability
13945 is not provided by @code{Bit_Order}.
13947 @item Components that are positioned across byte boundaries
13949 but do not occupy an integral number of bytes. Given that bytes are not
13950 reordered, such fields would occupy a non-contiguous sequence of bits
13951 in memory, requiring non-trivial code to reassemble. They are for this
13952 reason not permitted, and any component clause specifying such a layout
13953 will be flagged as illegal by GNAT@.
13958 Since the misconception that Bit_Order automatically deals with all
13959 endian-related incompatibilities is a common one, the specification of
13960 a component field that is an integral number of bytes will always
13961 generate a warning. This warning may be suppressed using @code{pragma
13962 Warnings (Off)} if desired. The following section contains additional
13963 details regarding the issue of byte ordering.
13965 @node Effect of Bit_Order on Byte Ordering
13966 @section Effect of Bit_Order on Byte Ordering
13967 @cindex byte ordering
13968 @cindex ordering, of bytes
13971 In this section we will review the effect of the @code{Bit_Order} attribute
13972 definition clause on byte ordering. Briefly, it has no effect at all, but
13973 a detailed example will be helpful. Before giving this
13974 example, let us review the precise
13975 definition of the effect of defining @code{Bit_Order}. The effect of a
13976 non-standard bit order is described in section 15.5.3 of the Ada
13980 2 A bit ordering is a method of interpreting the meaning of
13981 the storage place attributes.
13985 To understand the precise definition of storage place attributes in
13986 this context, we visit section 13.5.1 of the manual:
13989 13 A record_representation_clause (without the mod_clause)
13990 specifies the layout. The storage place attributes (see 13.5.2)
13991 are taken from the values of the position, first_bit, and last_bit
13992 expressions after normalizing those values so that first_bit is
13993 less than Storage_Unit.
13997 The critical point here is that storage places are taken from
13998 the values after normalization, not before. So the @code{Bit_Order}
13999 interpretation applies to normalized values. The interpretation
14000 is described in the later part of the 15.5.3 paragraph:
14003 2 A bit ordering is a method of interpreting the meaning of
14004 the storage place attributes. High_Order_First (known in the
14005 vernacular as ``big endian'') means that the first bit of a
14006 storage element (bit 0) is the most significant bit (interpreting
14007 the sequence of bits that represent a component as an unsigned
14008 integer value). Low_Order_First (known in the vernacular as
14009 ``little endian'') means the opposite: the first bit is the
14014 Note that the numbering is with respect to the bits of a storage
14015 unit. In other words, the specification affects only the numbering
14016 of bits within a single storage unit.
14018 We can make the effect clearer by giving an example.
14020 Suppose that we have an external device which presents two bytes, the first
14021 byte presented, which is the first (low addressed byte) of the two byte
14022 record is called Master, and the second byte is called Slave.
14024 The left most (most significant bit is called Control for each byte, and
14025 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
14026 (least significant) bit.
14028 On a big-endian machine, we can write the following representation clause
14030 @smallexample @c ada
14031 type Data is record
14032 Master_Control : Bit;
14040 Slave_Control : Bit;
14050 for Data use record
14051 Master_Control at 0 range 0 .. 0;
14052 Master_V1 at 0 range 1 .. 1;
14053 Master_V2 at 0 range 2 .. 2;
14054 Master_V3 at 0 range 3 .. 3;
14055 Master_V4 at 0 range 4 .. 4;
14056 Master_V5 at 0 range 5 .. 5;
14057 Master_V6 at 0 range 6 .. 6;
14058 Master_V7 at 0 range 7 .. 7;
14059 Slave_Control at 1 range 0 .. 0;
14060 Slave_V1 at 1 range 1 .. 1;
14061 Slave_V2 at 1 range 2 .. 2;
14062 Slave_V3 at 1 range 3 .. 3;
14063 Slave_V4 at 1 range 4 .. 4;
14064 Slave_V5 at 1 range 5 .. 5;
14065 Slave_V6 at 1 range 6 .. 6;
14066 Slave_V7 at 1 range 7 .. 7;
14071 Now if we move this to a little endian machine, then the bit ordering within
14072 the byte is backwards, so we have to rewrite the record rep clause as:
14074 @smallexample @c ada
14075 for Data use record
14076 Master_Control at 0 range 7 .. 7;
14077 Master_V1 at 0 range 6 .. 6;
14078 Master_V2 at 0 range 5 .. 5;
14079 Master_V3 at 0 range 4 .. 4;
14080 Master_V4 at 0 range 3 .. 3;
14081 Master_V5 at 0 range 2 .. 2;
14082 Master_V6 at 0 range 1 .. 1;
14083 Master_V7 at 0 range 0 .. 0;
14084 Slave_Control at 1 range 7 .. 7;
14085 Slave_V1 at 1 range 6 .. 6;
14086 Slave_V2 at 1 range 5 .. 5;
14087 Slave_V3 at 1 range 4 .. 4;
14088 Slave_V4 at 1 range 3 .. 3;
14089 Slave_V5 at 1 range 2 .. 2;
14090 Slave_V6 at 1 range 1 .. 1;
14091 Slave_V7 at 1 range 0 .. 0;
14096 It is a nuisance to have to rewrite the clause, especially if
14097 the code has to be maintained on both machines. However,
14098 this is a case that we can handle with the
14099 @code{Bit_Order} attribute if it is implemented.
14100 Note that the implementation is not required on byte addressed
14101 machines, but it is indeed implemented in GNAT.
14102 This means that we can simply use the
14103 first record clause, together with the declaration
14105 @smallexample @c ada
14106 for Data'Bit_Order use High_Order_First;
14110 and the effect is what is desired, namely the layout is exactly the same,
14111 independent of whether the code is compiled on a big-endian or little-endian
14114 The important point to understand is that byte ordering is not affected.
14115 A @code{Bit_Order} attribute definition never affects which byte a field
14116 ends up in, only where it ends up in that byte.
14117 To make this clear, let us rewrite the record rep clause of the previous
14120 @smallexample @c ada
14121 for Data'Bit_Order use High_Order_First;
14122 for Data use record
14123 Master_Control at 0 range 0 .. 0;
14124 Master_V1 at 0 range 1 .. 1;
14125 Master_V2 at 0 range 2 .. 2;
14126 Master_V3 at 0 range 3 .. 3;
14127 Master_V4 at 0 range 4 .. 4;
14128 Master_V5 at 0 range 5 .. 5;
14129 Master_V6 at 0 range 6 .. 6;
14130 Master_V7 at 0 range 7 .. 7;
14131 Slave_Control at 0 range 8 .. 8;
14132 Slave_V1 at 0 range 9 .. 9;
14133 Slave_V2 at 0 range 10 .. 10;
14134 Slave_V3 at 0 range 11 .. 11;
14135 Slave_V4 at 0 range 12 .. 12;
14136 Slave_V5 at 0 range 13 .. 13;
14137 Slave_V6 at 0 range 14 .. 14;
14138 Slave_V7 at 0 range 15 .. 15;
14143 This is exactly equivalent to saying (a repeat of the first example):
14145 @smallexample @c ada
14146 for Data'Bit_Order use High_Order_First;
14147 for Data use record
14148 Master_Control at 0 range 0 .. 0;
14149 Master_V1 at 0 range 1 .. 1;
14150 Master_V2 at 0 range 2 .. 2;
14151 Master_V3 at 0 range 3 .. 3;
14152 Master_V4 at 0 range 4 .. 4;
14153 Master_V5 at 0 range 5 .. 5;
14154 Master_V6 at 0 range 6 .. 6;
14155 Master_V7 at 0 range 7 .. 7;
14156 Slave_Control at 1 range 0 .. 0;
14157 Slave_V1 at 1 range 1 .. 1;
14158 Slave_V2 at 1 range 2 .. 2;
14159 Slave_V3 at 1 range 3 .. 3;
14160 Slave_V4 at 1 range 4 .. 4;
14161 Slave_V5 at 1 range 5 .. 5;
14162 Slave_V6 at 1 range 6 .. 6;
14163 Slave_V7 at 1 range 7 .. 7;
14168 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
14169 field. The storage place attributes are obtained by normalizing the
14170 values given so that the @code{First_Bit} value is less than 8. After
14171 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
14172 we specified in the other case.
14174 Now one might expect that the @code{Bit_Order} attribute might affect
14175 bit numbering within the entire record component (two bytes in this
14176 case, thus affecting which byte fields end up in), but that is not
14177 the way this feature is defined, it only affects numbering of bits,
14178 not which byte they end up in.
14180 Consequently it never makes sense to specify a starting bit number
14181 greater than 7 (for a byte addressable field) if an attribute
14182 definition for @code{Bit_Order} has been given, and indeed it
14183 may be actively confusing to specify such a value, so the compiler
14184 generates a warning for such usage.
14186 If you do need to control byte ordering then appropriate conditional
14187 values must be used. If in our example, the slave byte came first on
14188 some machines we might write:
14190 @smallexample @c ada
14191 Master_Byte_First constant Boolean := @dots{};
14193 Master_Byte : constant Natural :=
14194 1 - Boolean'Pos (Master_Byte_First);
14195 Slave_Byte : constant Natural :=
14196 Boolean'Pos (Master_Byte_First);
14198 for Data'Bit_Order use High_Order_First;
14199 for Data use record
14200 Master_Control at Master_Byte range 0 .. 0;
14201 Master_V1 at Master_Byte range 1 .. 1;
14202 Master_V2 at Master_Byte range 2 .. 2;
14203 Master_V3 at Master_Byte range 3 .. 3;
14204 Master_V4 at Master_Byte range 4 .. 4;
14205 Master_V5 at Master_Byte range 5 .. 5;
14206 Master_V6 at Master_Byte range 6 .. 6;
14207 Master_V7 at Master_Byte range 7 .. 7;
14208 Slave_Control at Slave_Byte range 0 .. 0;
14209 Slave_V1 at Slave_Byte range 1 .. 1;
14210 Slave_V2 at Slave_Byte range 2 .. 2;
14211 Slave_V3 at Slave_Byte range 3 .. 3;
14212 Slave_V4 at Slave_Byte range 4 .. 4;
14213 Slave_V5 at Slave_Byte range 5 .. 5;
14214 Slave_V6 at Slave_Byte range 6 .. 6;
14215 Slave_V7 at Slave_Byte range 7 .. 7;
14220 Now to switch between machines, all that is necessary is
14221 to set the boolean constant @code{Master_Byte_First} in
14222 an appropriate manner.
14224 @node Pragma Pack for Arrays
14225 @section Pragma Pack for Arrays
14226 @cindex Pragma Pack (for arrays)
14229 Pragma @code{Pack} applied to an array has no effect unless the component type
14230 is packable. For a component type to be packable, it must be one of the
14237 Any type whose size is specified with a size clause
14239 Any packed array type with a static size
14241 Any record type padded because of its default alignment
14245 For all these cases, if the component subtype size is in the range
14246 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
14247 component size were specified giving the component subtype size.
14248 For example if we have:
14250 @smallexample @c ada
14251 type r is range 0 .. 17;
14253 type ar is array (1 .. 8) of r;
14258 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
14259 and the size of the array @code{ar} will be exactly 40 bits.
14261 Note that in some cases this rather fierce approach to packing can produce
14262 unexpected effects. For example, in Ada 95 and Ada 2005,
14263 subtype @code{Natural} typically has a size of 31, meaning that if you
14264 pack an array of @code{Natural}, you get 31-bit
14265 close packing, which saves a few bits, but results in far less efficient
14266 access. Since many other Ada compilers will ignore such a packing request,
14267 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
14268 might not be what is intended. You can easily remove this warning by
14269 using an explicit @code{Component_Size} setting instead, which never generates
14270 a warning, since the intention of the programmer is clear in this case.
14272 GNAT treats packed arrays in one of two ways. If the size of the array is
14273 known at compile time and is less than 64 bits, then internally the array
14274 is represented as a single modular type, of exactly the appropriate number
14275 of bits. If the length is greater than 63 bits, or is not known at compile
14276 time, then the packed array is represented as an array of bytes, and the
14277 length is always a multiple of 8 bits.
14279 Note that to represent a packed array as a modular type, the alignment must
14280 be suitable for the modular type involved. For example, on typical machines
14281 a 32-bit packed array will be represented by a 32-bit modular integer with
14282 an alignment of four bytes. If you explicitly override the default alignment
14283 with an alignment clause that is too small, the modular representation
14284 cannot be used. For example, consider the following set of declarations:
14286 @smallexample @c ada
14287 type R is range 1 .. 3;
14288 type S is array (1 .. 31) of R;
14289 for S'Component_Size use 2;
14291 for S'Alignment use 1;
14295 If the alignment clause were not present, then a 62-bit modular
14296 representation would be chosen (typically with an alignment of 4 or 8
14297 bytes depending on the target). But the default alignment is overridden
14298 with the explicit alignment clause. This means that the modular
14299 representation cannot be used, and instead the array of bytes
14300 representation must be used, meaning that the length must be a multiple
14301 of 8. Thus the above set of declarations will result in a diagnostic
14302 rejecting the size clause and noting that the minimum size allowed is 64.
14304 @cindex Pragma Pack (for type Natural)
14305 @cindex Pragma Pack warning
14307 One special case that is worth noting occurs when the base type of the
14308 component size is 8/16/32 and the subtype is one bit less. Notably this
14309 occurs with subtype @code{Natural}. Consider:
14311 @smallexample @c ada
14312 type Arr is array (1 .. 32) of Natural;
14317 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
14318 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
14319 Ada 83 compilers did not attempt 31 bit packing.
14321 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
14322 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
14323 substantial unintended performance penalty when porting legacy Ada 83 code.
14324 To help prevent this, GNAT generates a warning in such cases. If you really
14325 want 31 bit packing in a case like this, you can set the component size
14328 @smallexample @c ada
14329 type Arr is array (1 .. 32) of Natural;
14330 for Arr'Component_Size use 31;
14334 Here 31-bit packing is achieved as required, and no warning is generated,
14335 since in this case the programmer intention is clear.
14337 @node Pragma Pack for Records
14338 @section Pragma Pack for Records
14339 @cindex Pragma Pack (for records)
14342 Pragma @code{Pack} applied to a record will pack the components to reduce
14343 wasted space from alignment gaps and by reducing the amount of space
14344 taken by components. We distinguish between @emph{packable} components and
14345 @emph{non-packable} components.
14346 Components of the following types are considered packable:
14349 All primitive types are packable.
14352 Small packed arrays, whose size does not exceed 64 bits, and where the
14353 size is statically known at compile time, are represented internally
14354 as modular integers, and so they are also packable.
14359 All packable components occupy the exact number of bits corresponding to
14360 their @code{Size} value, and are packed with no padding bits, i.e.@: they
14361 can start on an arbitrary bit boundary.
14363 All other types are non-packable, they occupy an integral number of
14365 are placed at a boundary corresponding to their alignment requirements.
14367 For example, consider the record
14369 @smallexample @c ada
14370 type Rb1 is array (1 .. 13) of Boolean;
14373 type Rb2 is array (1 .. 65) of Boolean;
14388 The representation for the record x2 is as follows:
14390 @smallexample @c ada
14391 for x2'Size use 224;
14393 l1 at 0 range 0 .. 0;
14394 l2 at 0 range 1 .. 64;
14395 l3 at 12 range 0 .. 31;
14396 l4 at 16 range 0 .. 0;
14397 l5 at 16 range 1 .. 13;
14398 l6 at 18 range 0 .. 71;
14403 Studying this example, we see that the packable fields @code{l1}
14405 of length equal to their sizes, and placed at specific bit boundaries (and
14406 not byte boundaries) to
14407 eliminate padding. But @code{l3} is of a non-packable float type, so
14408 it is on the next appropriate alignment boundary.
14410 The next two fields are fully packable, so @code{l4} and @code{l5} are
14411 minimally packed with no gaps. However, type @code{Rb2} is a packed
14412 array that is longer than 64 bits, so it is itself non-packable. Thus
14413 the @code{l6} field is aligned to the next byte boundary, and takes an
14414 integral number of bytes, i.e.@: 72 bits.
14416 @node Record Representation Clauses
14417 @section Record Representation Clauses
14418 @cindex Record Representation Clause
14421 Record representation clauses may be given for all record types, including
14422 types obtained by record extension. Component clauses are allowed for any
14423 static component. The restrictions on component clauses depend on the type
14426 @cindex Component Clause
14427 For all components of an elementary type, the only restriction on component
14428 clauses is that the size must be at least the 'Size value of the type
14429 (actually the Value_Size). There are no restrictions due to alignment,
14430 and such components may freely cross storage boundaries.
14432 Packed arrays with a size up to and including 64 bits are represented
14433 internally using a modular type with the appropriate number of bits, and
14434 thus the same lack of restriction applies. For example, if you declare:
14436 @smallexample @c ada
14437 type R is array (1 .. 49) of Boolean;
14443 then a component clause for a component of type R may start on any
14444 specified bit boundary, and may specify a value of 49 bits or greater.
14446 For packed bit arrays that are longer than 64 bits, there are two
14447 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
14448 including the important case of single bits or boolean values, then
14449 there are no limitations on placement of such components, and they
14450 may start and end at arbitrary bit boundaries.
14452 If the component size is not a power of 2 (e.g.@: 3 or 5), then
14453 an array of this type longer than 64 bits must always be placed on
14454 on a storage unit (byte) boundary and occupy an integral number
14455 of storage units (bytes). Any component clause that does not
14456 meet this requirement will be rejected.
14458 Any aliased component, or component of an aliased type, must
14459 have its normal alignment and size. A component clause that
14460 does not meet this requirement will be rejected.
14462 The tag field of a tagged type always occupies an address sized field at
14463 the start of the record. No component clause may attempt to overlay this
14464 tag. When a tagged type appears as a component, the tag field must have
14467 In the case of a record extension T1, of a type T, no component clause applied
14468 to the type T1 can specify a storage location that would overlap the first
14469 T'Size bytes of the record.
14471 For all other component types, including non-bit-packed arrays,
14472 the component can be placed at an arbitrary bit boundary,
14473 so for example, the following is permitted:
14475 @smallexample @c ada
14476 type R is array (1 .. 10) of Boolean;
14485 G at 0 range 0 .. 0;
14486 H at 0 range 1 .. 1;
14487 L at 0 range 2 .. 81;
14488 R at 0 range 82 .. 161;
14493 Note: the above rules apply to recent releases of GNAT 5.
14494 In GNAT 3, there are more severe restrictions on larger components.
14495 For non-primitive types, including packed arrays with a size greater than
14496 64 bits, component clauses must respect the alignment requirement of the
14497 type, in particular, always starting on a byte boundary, and the length
14498 must be a multiple of the storage unit.
14500 @node Enumeration Clauses
14501 @section Enumeration Clauses
14503 The only restriction on enumeration clauses is that the range of values
14504 must be representable. For the signed case, if one or more of the
14505 representation values are negative, all values must be in the range:
14507 @smallexample @c ada
14508 System.Min_Int .. System.Max_Int
14512 For the unsigned case, where all values are nonnegative, the values must
14515 @smallexample @c ada
14516 0 .. System.Max_Binary_Modulus;
14520 A @emph{confirming} representation clause is one in which the values range
14521 from 0 in sequence, i.e.@: a clause that confirms the default representation
14522 for an enumeration type.
14523 Such a confirming representation
14524 is permitted by these rules, and is specially recognized by the compiler so
14525 that no extra overhead results from the use of such a clause.
14527 If an array has an index type which is an enumeration type to which an
14528 enumeration clause has been applied, then the array is stored in a compact
14529 manner. Consider the declarations:
14531 @smallexample @c ada
14532 type r is (A, B, C);
14533 for r use (A => 1, B => 5, C => 10);
14534 type t is array (r) of Character;
14538 The array type t corresponds to a vector with exactly three elements and
14539 has a default size equal to @code{3*Character'Size}. This ensures efficient
14540 use of space, but means that accesses to elements of the array will incur
14541 the overhead of converting representation values to the corresponding
14542 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
14544 @node Address Clauses
14545 @section Address Clauses
14546 @cindex Address Clause
14548 The reference manual allows a general restriction on representation clauses,
14549 as found in RM 13.1(22):
14552 An implementation need not support representation
14553 items containing nonstatic expressions, except that
14554 an implementation should support a representation item
14555 for a given entity if each nonstatic expression in the
14556 representation item is a name that statically denotes
14557 a constant declared before the entity.
14561 In practice this is applicable only to address clauses, since this is the
14562 only case in which a non-static expression is permitted by the syntax. As
14563 the AARM notes in sections 13.1 (22.a-22.h):
14566 22.a Reason: This is to avoid the following sort of thing:
14568 22.b X : Integer := F(@dots{});
14569 Y : Address := G(@dots{});
14570 for X'Address use Y;
14572 22.c In the above, we have to evaluate the
14573 initialization expression for X before we
14574 know where to put the result. This seems
14575 like an unreasonable implementation burden.
14577 22.d The above code should instead be written
14580 22.e Y : constant Address := G(@dots{});
14581 X : Integer := F(@dots{});
14582 for X'Address use Y;
14584 22.f This allows the expression ``Y'' to be safely
14585 evaluated before X is created.
14587 22.g The constant could be a formal parameter of mode in.
14589 22.h An implementation can support other nonstatic
14590 expressions if it wants to. Expressions of type
14591 Address are hardly ever static, but their value
14592 might be known at compile time anyway in many
14597 GNAT does indeed permit many additional cases of non-static expressions. In
14598 particular, if the type involved is elementary there are no restrictions
14599 (since in this case, holding a temporary copy of the initialization value,
14600 if one is present, is inexpensive). In addition, if there is no implicit or
14601 explicit initialization, then there are no restrictions. GNAT will reject
14602 only the case where all three of these conditions hold:
14607 The type of the item is non-elementary (e.g.@: a record or array).
14610 There is explicit or implicit initialization required for the object.
14611 Note that access values are always implicitly initialized.
14614 The address value is non-static. Here GNAT is more permissive than the
14615 RM, and allows the address value to be the address of a previously declared
14616 stand-alone variable, as long as it does not itself have an address clause.
14618 @smallexample @c ada
14619 Anchor : Some_Initialized_Type;
14620 Overlay : Some_Initialized_Type;
14621 for Overlay'Address use Anchor'Address;
14625 However, the prefix of the address clause cannot be an array component, or
14626 a component of a discriminated record.
14631 As noted above in section 22.h, address values are typically non-static. In
14632 particular the To_Address function, even if applied to a literal value, is
14633 a non-static function call. To avoid this minor annoyance, GNAT provides
14634 the implementation defined attribute 'To_Address. The following two
14635 expressions have identical values:
14639 @smallexample @c ada
14640 To_Address (16#1234_0000#)
14641 System'To_Address (16#1234_0000#);
14645 except that the second form is considered to be a static expression, and
14646 thus when used as an address clause value is always permitted.
14649 Additionally, GNAT treats as static an address clause that is an
14650 unchecked_conversion of a static integer value. This simplifies the porting
14651 of legacy code, and provides a portable equivalent to the GNAT attribute
14654 Another issue with address clauses is the interaction with alignment
14655 requirements. When an address clause is given for an object, the address
14656 value must be consistent with the alignment of the object (which is usually
14657 the same as the alignment of the type of the object). If an address clause
14658 is given that specifies an inappropriately aligned address value, then the
14659 program execution is erroneous.
14661 Since this source of erroneous behavior can have unfortunate effects, GNAT
14662 checks (at compile time if possible, generating a warning, or at execution
14663 time with a run-time check) that the alignment is appropriate. If the
14664 run-time check fails, then @code{Program_Error} is raised. This run-time
14665 check is suppressed if range checks are suppressed, or if the special GNAT
14666 check Alignment_Check is suppressed, or if
14667 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
14669 Finally, GNAT does not permit overlaying of objects of controlled types or
14670 composite types containing a controlled component. In most cases, the compiler
14671 can detect an attempt at such overlays and will generate a warning at compile
14672 time and a Program_Error exception at run time.
14675 An address clause cannot be given for an exported object. More
14676 understandably the real restriction is that objects with an address
14677 clause cannot be exported. This is because such variables are not
14678 defined by the Ada program, so there is no external object to export.
14681 It is permissible to give an address clause and a pragma Import for the
14682 same object. In this case, the variable is not really defined by the
14683 Ada program, so there is no external symbol to be linked. The link name
14684 and the external name are ignored in this case. The reason that we allow this
14685 combination is that it provides a useful idiom to avoid unwanted
14686 initializations on objects with address clauses.
14688 When an address clause is given for an object that has implicit or
14689 explicit initialization, then by default initialization takes place. This
14690 means that the effect of the object declaration is to overwrite the
14691 memory at the specified address. This is almost always not what the
14692 programmer wants, so GNAT will output a warning:
14702 for Ext'Address use System'To_Address (16#1234_1234#);
14704 >>> warning: implicit initialization of "Ext" may
14705 modify overlaid storage
14706 >>> warning: use pragma Import for "Ext" to suppress
14707 initialization (RM B(24))
14713 As indicated by the warning message, the solution is to use a (dummy) pragma
14714 Import to suppress this initialization. The pragma tell the compiler that the
14715 object is declared and initialized elsewhere. The following package compiles
14716 without warnings (and the initialization is suppressed):
14718 @smallexample @c ada
14726 for Ext'Address use System'To_Address (16#1234_1234#);
14727 pragma Import (Ada, Ext);
14732 A final issue with address clauses involves their use for overlaying
14733 variables, as in the following example:
14734 @cindex Overlaying of objects
14736 @smallexample @c ada
14739 for B'Address use A'Address;
14743 or alternatively, using the form recommended by the RM:
14745 @smallexample @c ada
14747 Addr : constant Address := A'Address;
14749 for B'Address use Addr;
14753 In both of these cases, @code{A}
14754 and @code{B} become aliased to one another via the
14755 address clause. This use of address clauses to overlay
14756 variables, achieving an effect similar to unchecked
14757 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
14758 the effect is implementation defined. Furthermore, the
14759 Ada RM specifically recommends that in a situation
14760 like this, @code{B} should be subject to the following
14761 implementation advice (RM 13.3(19)):
14764 19 If the Address of an object is specified, or it is imported
14765 or exported, then the implementation should not perform
14766 optimizations based on assumptions of no aliases.
14770 GNAT follows this recommendation, and goes further by also applying
14771 this recommendation to the overlaid variable (@code{A}
14772 in the above example) in this case. This means that the overlay
14773 works "as expected", in that a modification to one of the variables
14774 will affect the value of the other.
14776 @node Effect of Convention on Representation
14777 @section Effect of Convention on Representation
14778 @cindex Convention, effect on representation
14781 Normally the specification of a foreign language convention for a type or
14782 an object has no effect on the chosen representation. In particular, the
14783 representation chosen for data in GNAT generally meets the standard system
14784 conventions, and for example records are laid out in a manner that is
14785 consistent with C@. This means that specifying convention C (for example)
14788 There are four exceptions to this general rule:
14792 @item Convention Fortran and array subtypes
14793 If pragma Convention Fortran is specified for an array subtype, then in
14794 accordance with the implementation advice in section 3.6.2(11) of the
14795 Ada Reference Manual, the array will be stored in a Fortran-compatible
14796 column-major manner, instead of the normal default row-major order.
14798 @item Convention C and enumeration types
14799 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
14800 to accommodate all values of the type. For example, for the enumeration
14803 @smallexample @c ada
14804 type Color is (Red, Green, Blue);
14808 8 bits is sufficient to store all values of the type, so by default, objects
14809 of type @code{Color} will be represented using 8 bits. However, normal C
14810 convention is to use 32 bits for all enum values in C, since enum values
14811 are essentially of type int. If pragma @code{Convention C} is specified for an
14812 Ada enumeration type, then the size is modified as necessary (usually to
14813 32 bits) to be consistent with the C convention for enum values.
14815 Note that this treatment applies only to types. If Convention C is given for
14816 an enumeration object, where the enumeration type is not Convention C, then
14817 Object_Size bits are allocated. For example, for a normal enumeration type,
14818 with less than 256 elements, only 8 bits will be allocated for the object.
14819 Since this may be a surprise in terms of what C expects, GNAT will issue a
14820 warning in this situation. The warning can be suppressed by giving an explicit
14821 size clause specifying the desired size.
14823 @item Convention C/Fortran and Boolean types
14824 In C, the usual convention for boolean values, that is values used for
14825 conditions, is that zero represents false, and nonzero values represent
14826 true. In Ada, the normal convention is that two specific values, typically
14827 0/1, are used to represent false/true respectively.
14829 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
14830 value represents true).
14832 To accommodate the Fortran and C conventions, if a pragma Convention specifies
14833 C or Fortran convention for a derived Boolean, as in the following example:
14835 @smallexample @c ada
14836 type C_Switch is new Boolean;
14837 pragma Convention (C, C_Switch);
14841 then the GNAT generated code will treat any nonzero value as true. For truth
14842 values generated by GNAT, the conventional value 1 will be used for True, but
14843 when one of these values is read, any nonzero value is treated as True.
14845 @item Access types on OpenVMS
14846 For 64-bit OpenVMS systems, access types (other than those for unconstrained
14847 arrays) are 64-bits long. An exception to this rule is for the case of
14848 C-convention access types where there is no explicit size clause present (or
14849 inherited for derived types). In this case, GNAT chooses to make these
14850 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
14851 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
14855 @node Determining the Representations chosen by GNAT
14856 @section Determining the Representations chosen by GNAT
14857 @cindex Representation, determination of
14858 @cindex @option{-gnatR} switch
14861 Although the descriptions in this section are intended to be complete, it is
14862 often easier to simply experiment to see what GNAT accepts and what the
14863 effect is on the layout of types and objects.
14865 As required by the Ada RM, if a representation clause is not accepted, then
14866 it must be rejected as illegal by the compiler. However, when a
14867 representation clause or pragma is accepted, there can still be questions
14868 of what the compiler actually does. For example, if a partial record
14869 representation clause specifies the location of some components and not
14870 others, then where are the non-specified components placed? Or if pragma
14871 @code{Pack} is used on a record, then exactly where are the resulting
14872 fields placed? The section on pragma @code{Pack} in this chapter can be
14873 used to answer the second question, but it is often easier to just see
14874 what the compiler does.
14876 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
14877 with this option, then the compiler will output information on the actual
14878 representations chosen, in a format similar to source representation
14879 clauses. For example, if we compile the package:
14881 @smallexample @c ada
14883 type r (x : boolean) is tagged record
14885 when True => S : String (1 .. 100);
14886 when False => null;
14890 type r2 is new r (false) with record
14895 y2 at 16 range 0 .. 31;
14902 type x1 is array (1 .. 10) of x;
14903 for x1'component_size use 11;
14905 type ia is access integer;
14907 type Rb1 is array (1 .. 13) of Boolean;
14910 type Rb2 is array (1 .. 65) of Boolean;
14926 using the switch @option{-gnatR} we obtain the following output:
14929 Representation information for unit q
14930 -------------------------------------
14933 for r'Alignment use 4;
14935 x at 4 range 0 .. 7;
14936 _tag at 0 range 0 .. 31;
14937 s at 5 range 0 .. 799;
14940 for r2'Size use 160;
14941 for r2'Alignment use 4;
14943 x at 4 range 0 .. 7;
14944 _tag at 0 range 0 .. 31;
14945 _parent at 0 range 0 .. 63;
14946 y2 at 16 range 0 .. 31;
14950 for x'Alignment use 1;
14952 y at 0 range 0 .. 7;
14955 for x1'Size use 112;
14956 for x1'Alignment use 1;
14957 for x1'Component_Size use 11;
14959 for rb1'Size use 13;
14960 for rb1'Alignment use 2;
14961 for rb1'Component_Size use 1;
14963 for rb2'Size use 72;
14964 for rb2'Alignment use 1;
14965 for rb2'Component_Size use 1;
14967 for x2'Size use 224;
14968 for x2'Alignment use 4;
14970 l1 at 0 range 0 .. 0;
14971 l2 at 0 range 1 .. 64;
14972 l3 at 12 range 0 .. 31;
14973 l4 at 16 range 0 .. 0;
14974 l5 at 16 range 1 .. 13;
14975 l6 at 18 range 0 .. 71;
14980 The Size values are actually the Object_Size, i.e.@: the default size that
14981 will be allocated for objects of the type.
14982 The ?? size for type r indicates that we have a variant record, and the
14983 actual size of objects will depend on the discriminant value.
14985 The Alignment values show the actual alignment chosen by the compiler
14986 for each record or array type.
14988 The record representation clause for type r shows where all fields
14989 are placed, including the compiler generated tag field (whose location
14990 cannot be controlled by the programmer).
14992 The record representation clause for the type extension r2 shows all the
14993 fields present, including the parent field, which is a copy of the fields
14994 of the parent type of r2, i.e.@: r1.
14996 The component size and size clauses for types rb1 and rb2 show
14997 the exact effect of pragma @code{Pack} on these arrays, and the record
14998 representation clause for type x2 shows how pragma @code{Pack} affects
15001 In some cases, it may be useful to cut and paste the representation clauses
15002 generated by the compiler into the original source to fix and guarantee
15003 the actual representation to be used.
15005 @node Standard Library Routines
15006 @chapter Standard Library Routines
15009 The Ada Reference Manual contains in Annex A a full description of an
15010 extensive set of standard library routines that can be used in any Ada
15011 program, and which must be provided by all Ada compilers. They are
15012 analogous to the standard C library used by C programs.
15014 GNAT implements all of the facilities described in annex A, and for most
15015 purposes the description in the Ada Reference Manual, or appropriate Ada
15016 text book, will be sufficient for making use of these facilities.
15018 In the case of the input-output facilities,
15019 @xref{The Implementation of Standard I/O},
15020 gives details on exactly how GNAT interfaces to the
15021 file system. For the remaining packages, the Ada Reference Manual
15022 should be sufficient. The following is a list of the packages included,
15023 together with a brief description of the functionality that is provided.
15025 For completeness, references are included to other predefined library
15026 routines defined in other sections of the Ada Reference Manual (these are
15027 cross-indexed from Annex A).
15031 This is a parent package for all the standard library packages. It is
15032 usually included implicitly in your program, and itself contains no
15033 useful data or routines.
15035 @item Ada.Calendar (9.6)
15036 @code{Calendar} provides time of day access, and routines for
15037 manipulating times and durations.
15039 @item Ada.Characters (A.3.1)
15040 This is a dummy parent package that contains no useful entities
15042 @item Ada.Characters.Handling (A.3.2)
15043 This package provides some basic character handling capabilities,
15044 including classification functions for classes of characters (e.g.@: test
15045 for letters, or digits).
15047 @item Ada.Characters.Latin_1 (A.3.3)
15048 This package includes a complete set of definitions of the characters
15049 that appear in type CHARACTER@. It is useful for writing programs that
15050 will run in international environments. For example, if you want an
15051 upper case E with an acute accent in a string, it is often better to use
15052 the definition of @code{UC_E_Acute} in this package. Then your program
15053 will print in an understandable manner even if your environment does not
15054 support these extended characters.
15056 @item Ada.Command_Line (A.15)
15057 This package provides access to the command line parameters and the name
15058 of the current program (analogous to the use of @code{argc} and @code{argv}
15059 in C), and also allows the exit status for the program to be set in a
15060 system-independent manner.
15062 @item Ada.Decimal (F.2)
15063 This package provides constants describing the range of decimal numbers
15064 implemented, and also a decimal divide routine (analogous to the COBOL
15065 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
15067 @item Ada.Direct_IO (A.8.4)
15068 This package provides input-output using a model of a set of records of
15069 fixed-length, containing an arbitrary definite Ada type, indexed by an
15070 integer record number.
15072 @item Ada.Dynamic_Priorities (D.5)
15073 This package allows the priorities of a task to be adjusted dynamically
15074 as the task is running.
15076 @item Ada.Exceptions (11.4.1)
15077 This package provides additional information on exceptions, and also
15078 contains facilities for treating exceptions as data objects, and raising
15079 exceptions with associated messages.
15081 @item Ada.Finalization (7.6)
15082 This package contains the declarations and subprograms to support the
15083 use of controlled types, providing for automatic initialization and
15084 finalization (analogous to the constructors and destructors of C++)
15086 @item Ada.Interrupts (C.3.2)
15087 This package provides facilities for interfacing to interrupts, which
15088 includes the set of signals or conditions that can be raised and
15089 recognized as interrupts.
15091 @item Ada.Interrupts.Names (C.3.2)
15092 This package provides the set of interrupt names (actually signal
15093 or condition names) that can be handled by GNAT@.
15095 @item Ada.IO_Exceptions (A.13)
15096 This package defines the set of exceptions that can be raised by use of
15097 the standard IO packages.
15100 This package contains some standard constants and exceptions used
15101 throughout the numerics packages. Note that the constants pi and e are
15102 defined here, and it is better to use these definitions than rolling
15105 @item Ada.Numerics.Complex_Elementary_Functions
15106 Provides the implementation of standard elementary functions (such as
15107 log and trigonometric functions) operating on complex numbers using the
15108 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
15109 created by the package @code{Numerics.Complex_Types}.
15111 @item Ada.Numerics.Complex_Types
15112 This is a predefined instantiation of
15113 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
15114 build the type @code{Complex} and @code{Imaginary}.
15116 @item Ada.Numerics.Discrete_Random
15117 This generic package provides a random number generator suitable for generating
15118 uniformly distributed values of a specified discrete subtype.
15120 @item Ada.Numerics.Float_Random
15121 This package provides a random number generator suitable for generating
15122 uniformly distributed floating point values in the unit interval.
15124 @item Ada.Numerics.Generic_Complex_Elementary_Functions
15125 This is a generic version of the package that provides the
15126 implementation of standard elementary functions (such as log and
15127 trigonometric functions) for an arbitrary complex type.
15129 The following predefined instantiations of this package are provided:
15133 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
15135 @code{Ada.Numerics.Complex_Elementary_Functions}
15137 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
15140 @item Ada.Numerics.Generic_Complex_Types
15141 This is a generic package that allows the creation of complex types,
15142 with associated complex arithmetic operations.
15144 The following predefined instantiations of this package exist
15147 @code{Ada.Numerics.Short_Complex_Complex_Types}
15149 @code{Ada.Numerics.Complex_Complex_Types}
15151 @code{Ada.Numerics.Long_Complex_Complex_Types}
15154 @item Ada.Numerics.Generic_Elementary_Functions
15155 This is a generic package that provides the implementation of standard
15156 elementary functions (such as log an trigonometric functions) for an
15157 arbitrary float type.
15159 The following predefined instantiations of this package exist
15163 @code{Ada.Numerics.Short_Elementary_Functions}
15165 @code{Ada.Numerics.Elementary_Functions}
15167 @code{Ada.Numerics.Long_Elementary_Functions}
15170 @item Ada.Real_Time (D.8)
15171 This package provides facilities similar to those of @code{Calendar}, but
15172 operating with a finer clock suitable for real time control. Note that
15173 annex D requires that there be no backward clock jumps, and GNAT generally
15174 guarantees this behavior, but of course if the external clock on which
15175 the GNAT runtime depends is deliberately reset by some external event,
15176 then such a backward jump may occur.
15178 @item Ada.Sequential_IO (A.8.1)
15179 This package provides input-output facilities for sequential files,
15180 which can contain a sequence of values of a single type, which can be
15181 any Ada type, including indefinite (unconstrained) types.
15183 @item Ada.Storage_IO (A.9)
15184 This package provides a facility for mapping arbitrary Ada types to and
15185 from a storage buffer. It is primarily intended for the creation of new
15188 @item Ada.Streams (13.13.1)
15189 This is a generic package that provides the basic support for the
15190 concept of streams as used by the stream attributes (@code{Input},
15191 @code{Output}, @code{Read} and @code{Write}).
15193 @item Ada.Streams.Stream_IO (A.12.1)
15194 This package is a specialization of the type @code{Streams} defined in
15195 package @code{Streams} together with a set of operations providing
15196 Stream_IO capability. The Stream_IO model permits both random and
15197 sequential access to a file which can contain an arbitrary set of values
15198 of one or more Ada types.
15200 @item Ada.Strings (A.4.1)
15201 This package provides some basic constants used by the string handling
15204 @item Ada.Strings.Bounded (A.4.4)
15205 This package provides facilities for handling variable length
15206 strings. The bounded model requires a maximum length. It is thus
15207 somewhat more limited than the unbounded model, but avoids the use of
15208 dynamic allocation or finalization.
15210 @item Ada.Strings.Fixed (A.4.3)
15211 This package provides facilities for handling fixed length strings.
15213 @item Ada.Strings.Maps (A.4.2)
15214 This package provides facilities for handling character mappings and
15215 arbitrarily defined subsets of characters. For instance it is useful in
15216 defining specialized translation tables.
15218 @item Ada.Strings.Maps.Constants (A.4.6)
15219 This package provides a standard set of predefined mappings and
15220 predefined character sets. For example, the standard upper to lower case
15221 conversion table is found in this package. Note that upper to lower case
15222 conversion is non-trivial if you want to take the entire set of
15223 characters, including extended characters like E with an acute accent,
15224 into account. You should use the mappings in this package (rather than
15225 adding 32 yourself) to do case mappings.
15227 @item Ada.Strings.Unbounded (A.4.5)
15228 This package provides facilities for handling variable length
15229 strings. The unbounded model allows arbitrary length strings, but
15230 requires the use of dynamic allocation and finalization.
15232 @item Ada.Strings.Wide_Bounded (A.4.7)
15233 @itemx Ada.Strings.Wide_Fixed (A.4.7)
15234 @itemx Ada.Strings.Wide_Maps (A.4.7)
15235 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
15236 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
15237 These packages provide analogous capabilities to the corresponding
15238 packages without @samp{Wide_} in the name, but operate with the types
15239 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
15240 and @code{Character}.
15242 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
15243 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
15244 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
15245 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
15246 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
15247 These packages provide analogous capabilities to the corresponding
15248 packages without @samp{Wide_} in the name, but operate with the types
15249 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
15250 of @code{String} and @code{Character}.
15252 @item Ada.Synchronous_Task_Control (D.10)
15253 This package provides some standard facilities for controlling task
15254 communication in a synchronous manner.
15257 This package contains definitions for manipulation of the tags of tagged
15260 @item Ada.Task_Attributes
15261 This package provides the capability of associating arbitrary
15262 task-specific data with separate tasks.
15265 This package provides basic text input-output capabilities for
15266 character, string and numeric data. The subpackages of this
15267 package are listed next.
15269 @item Ada.Text_IO.Decimal_IO
15270 Provides input-output facilities for decimal fixed-point types
15272 @item Ada.Text_IO.Enumeration_IO
15273 Provides input-output facilities for enumeration types.
15275 @item Ada.Text_IO.Fixed_IO
15276 Provides input-output facilities for ordinary fixed-point types.
15278 @item Ada.Text_IO.Float_IO
15279 Provides input-output facilities for float types. The following
15280 predefined instantiations of this generic package are available:
15284 @code{Short_Float_Text_IO}
15286 @code{Float_Text_IO}
15288 @code{Long_Float_Text_IO}
15291 @item Ada.Text_IO.Integer_IO
15292 Provides input-output facilities for integer types. The following
15293 predefined instantiations of this generic package are available:
15296 @item Short_Short_Integer
15297 @code{Ada.Short_Short_Integer_Text_IO}
15298 @item Short_Integer
15299 @code{Ada.Short_Integer_Text_IO}
15301 @code{Ada.Integer_Text_IO}
15303 @code{Ada.Long_Integer_Text_IO}
15304 @item Long_Long_Integer
15305 @code{Ada.Long_Long_Integer_Text_IO}
15308 @item Ada.Text_IO.Modular_IO
15309 Provides input-output facilities for modular (unsigned) types
15311 @item Ada.Text_IO.Complex_IO (G.1.3)
15312 This package provides basic text input-output capabilities for complex
15315 @item Ada.Text_IO.Editing (F.3.3)
15316 This package contains routines for edited output, analogous to the use
15317 of pictures in COBOL@. The picture formats used by this package are a
15318 close copy of the facility in COBOL@.
15320 @item Ada.Text_IO.Text_Streams (A.12.2)
15321 This package provides a facility that allows Text_IO files to be treated
15322 as streams, so that the stream attributes can be used for writing
15323 arbitrary data, including binary data, to Text_IO files.
15325 @item Ada.Unchecked_Conversion (13.9)
15326 This generic package allows arbitrary conversion from one type to
15327 another of the same size, providing for breaking the type safety in
15328 special circumstances.
15330 If the types have the same Size (more accurately the same Value_Size),
15331 then the effect is simply to transfer the bits from the source to the
15332 target type without any modification. This usage is well defined, and
15333 for simple types whose representation is typically the same across
15334 all implementations, gives a portable method of performing such
15337 If the types do not have the same size, then the result is implementation
15338 defined, and thus may be non-portable. The following describes how GNAT
15339 handles such unchecked conversion cases.
15341 If the types are of different sizes, and are both discrete types, then
15342 the effect is of a normal type conversion without any constraint checking.
15343 In particular if the result type has a larger size, the result will be
15344 zero or sign extended. If the result type has a smaller size, the result
15345 will be truncated by ignoring high order bits.
15347 If the types are of different sizes, and are not both discrete types,
15348 then the conversion works as though pointers were created to the source
15349 and target, and the pointer value is converted. The effect is that bits
15350 are copied from successive low order storage units and bits of the source
15351 up to the length of the target type.
15353 A warning is issued if the lengths differ, since the effect in this
15354 case is implementation dependent, and the above behavior may not match
15355 that of some other compiler.
15357 A pointer to one type may be converted to a pointer to another type using
15358 unchecked conversion. The only case in which the effect is undefined is
15359 when one or both pointers are pointers to unconstrained array types. In
15360 this case, the bounds information may get incorrectly transferred, and in
15361 particular, GNAT uses double size pointers for such types, and it is
15362 meaningless to convert between such pointer types. GNAT will issue a
15363 warning if the alignment of the target designated type is more strict
15364 than the alignment of the source designated type (since the result may
15365 be unaligned in this case).
15367 A pointer other than a pointer to an unconstrained array type may be
15368 converted to and from System.Address. Such usage is common in Ada 83
15369 programs, but note that Ada.Address_To_Access_Conversions is the
15370 preferred method of performing such conversions in Ada 95 and Ada 2005.
15372 unchecked conversion nor Ada.Address_To_Access_Conversions should be
15373 used in conjunction with pointers to unconstrained objects, since
15374 the bounds information cannot be handled correctly in this case.
15376 @item Ada.Unchecked_Deallocation (13.11.2)
15377 This generic package allows explicit freeing of storage previously
15378 allocated by use of an allocator.
15380 @item Ada.Wide_Text_IO (A.11)
15381 This package is similar to @code{Ada.Text_IO}, except that the external
15382 file supports wide character representations, and the internal types are
15383 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
15384 and @code{String}. It contains generic subpackages listed next.
15386 @item Ada.Wide_Text_IO.Decimal_IO
15387 Provides input-output facilities for decimal fixed-point types
15389 @item Ada.Wide_Text_IO.Enumeration_IO
15390 Provides input-output facilities for enumeration types.
15392 @item Ada.Wide_Text_IO.Fixed_IO
15393 Provides input-output facilities for ordinary fixed-point types.
15395 @item Ada.Wide_Text_IO.Float_IO
15396 Provides input-output facilities for float types. The following
15397 predefined instantiations of this generic package are available:
15401 @code{Short_Float_Wide_Text_IO}
15403 @code{Float_Wide_Text_IO}
15405 @code{Long_Float_Wide_Text_IO}
15408 @item Ada.Wide_Text_IO.Integer_IO
15409 Provides input-output facilities for integer types. The following
15410 predefined instantiations of this generic package are available:
15413 @item Short_Short_Integer
15414 @code{Ada.Short_Short_Integer_Wide_Text_IO}
15415 @item Short_Integer
15416 @code{Ada.Short_Integer_Wide_Text_IO}
15418 @code{Ada.Integer_Wide_Text_IO}
15420 @code{Ada.Long_Integer_Wide_Text_IO}
15421 @item Long_Long_Integer
15422 @code{Ada.Long_Long_Integer_Wide_Text_IO}
15425 @item Ada.Wide_Text_IO.Modular_IO
15426 Provides input-output facilities for modular (unsigned) types
15428 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
15429 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
15430 external file supports wide character representations.
15432 @item Ada.Wide_Text_IO.Editing (F.3.4)
15433 This package is similar to @code{Ada.Text_IO.Editing}, except that the
15434 types are @code{Wide_Character} and @code{Wide_String} instead of
15435 @code{Character} and @code{String}.
15437 @item Ada.Wide_Text_IO.Streams (A.12.3)
15438 This package is similar to @code{Ada.Text_IO.Streams}, except that the
15439 types are @code{Wide_Character} and @code{Wide_String} instead of
15440 @code{Character} and @code{String}.
15442 @item Ada.Wide_Wide_Text_IO (A.11)
15443 This package is similar to @code{Ada.Text_IO}, except that the external
15444 file supports wide character representations, and the internal types are
15445 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
15446 and @code{String}. It contains generic subpackages listed next.
15448 @item Ada.Wide_Wide_Text_IO.Decimal_IO
15449 Provides input-output facilities for decimal fixed-point types
15451 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
15452 Provides input-output facilities for enumeration types.
15454 @item Ada.Wide_Wide_Text_IO.Fixed_IO
15455 Provides input-output facilities for ordinary fixed-point types.
15457 @item Ada.Wide_Wide_Text_IO.Float_IO
15458 Provides input-output facilities for float types. The following
15459 predefined instantiations of this generic package are available:
15463 @code{Short_Float_Wide_Wide_Text_IO}
15465 @code{Float_Wide_Wide_Text_IO}
15467 @code{Long_Float_Wide_Wide_Text_IO}
15470 @item Ada.Wide_Wide_Text_IO.Integer_IO
15471 Provides input-output facilities for integer types. The following
15472 predefined instantiations of this generic package are available:
15475 @item Short_Short_Integer
15476 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
15477 @item Short_Integer
15478 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
15480 @code{Ada.Integer_Wide_Wide_Text_IO}
15482 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
15483 @item Long_Long_Integer
15484 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
15487 @item Ada.Wide_Wide_Text_IO.Modular_IO
15488 Provides input-output facilities for modular (unsigned) types
15490 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
15491 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
15492 external file supports wide character representations.
15494 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
15495 This package is similar to @code{Ada.Text_IO.Editing}, except that the
15496 types are @code{Wide_Character} and @code{Wide_String} instead of
15497 @code{Character} and @code{String}.
15499 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
15500 This package is similar to @code{Ada.Text_IO.Streams}, except that the
15501 types are @code{Wide_Character} and @code{Wide_String} instead of
15502 @code{Character} and @code{String}.
15505 @node The Implementation of Standard I/O
15506 @chapter The Implementation of Standard I/O
15509 GNAT implements all the required input-output facilities described in
15510 A.6 through A.14. These sections of the Ada Reference Manual describe the
15511 required behavior of these packages from the Ada point of view, and if
15512 you are writing a portable Ada program that does not need to know the
15513 exact manner in which Ada maps to the outside world when it comes to
15514 reading or writing external files, then you do not need to read this
15515 chapter. As long as your files are all regular files (not pipes or
15516 devices), and as long as you write and read the files only from Ada, the
15517 description in the Ada Reference Manual is sufficient.
15519 However, if you want to do input-output to pipes or other devices, such
15520 as the keyboard or screen, or if the files you are dealing with are
15521 either generated by some other language, or to be read by some other
15522 language, then you need to know more about the details of how the GNAT
15523 implementation of these input-output facilities behaves.
15525 In this chapter we give a detailed description of exactly how GNAT
15526 interfaces to the file system. As always, the sources of the system are
15527 available to you for answering questions at an even more detailed level,
15528 but for most purposes the information in this chapter will suffice.
15530 Another reason that you may need to know more about how input-output is
15531 implemented arises when you have a program written in mixed languages
15532 where, for example, files are shared between the C and Ada sections of
15533 the same program. GNAT provides some additional facilities, in the form
15534 of additional child library packages, that facilitate this sharing, and
15535 these additional facilities are also described in this chapter.
15538 * Standard I/O Packages::
15544 * Wide_Wide_Text_IO::
15546 * Text Translation::
15548 * Filenames encoding::
15550 * Operations on C Streams::
15551 * Interfacing to C Streams::
15554 @node Standard I/O Packages
15555 @section Standard I/O Packages
15558 The Standard I/O packages described in Annex A for
15564 Ada.Text_IO.Complex_IO
15566 Ada.Text_IO.Text_Streams
15570 Ada.Wide_Text_IO.Complex_IO
15572 Ada.Wide_Text_IO.Text_Streams
15574 Ada.Wide_Wide_Text_IO
15576 Ada.Wide_Wide_Text_IO.Complex_IO
15578 Ada.Wide_Wide_Text_IO.Text_Streams
15588 are implemented using the C
15589 library streams facility; where
15593 All files are opened using @code{fopen}.
15595 All input/output operations use @code{fread}/@code{fwrite}.
15599 There is no internal buffering of any kind at the Ada library level. The only
15600 buffering is that provided at the system level in the implementation of the
15601 library routines that support streams. This facilitates shared use of these
15602 streams by mixed language programs. Note though that system level buffering is
15603 explicitly enabled at elaboration of the standard I/O packages and that can
15604 have an impact on mixed language programs, in particular those using I/O before
15605 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
15606 the Ada elaboration routine before performing any I/O or when impractical,
15607 flush the common I/O streams and in particular Standard_Output before
15608 elaborating the Ada code.
15611 @section FORM Strings
15614 The format of a FORM string in GNAT is:
15617 "keyword=value,keyword=value,@dots{},keyword=value"
15621 where letters may be in upper or lower case, and there are no spaces
15622 between values. The order of the entries is not important. Currently
15623 the following keywords defined.
15626 TEXT_TRANSLATION=[YES|NO]
15628 WCEM=[n|h|u|s|e|8|b]
15629 ENCODING=[UTF8|8BITS]
15633 The use of these parameters is described later in this section. If an
15634 unrecognized keyword appears in a form string, it is silently ignored
15635 and not considered invalid.
15638 For OpenVMS additional FORM string keywords are available for use with
15639 RMS services. The syntax is:
15642 VMS_RMS_Keys=(keyword=value,@dots{},keyword=value)
15646 The following RMS keywords and values are currently defined:
15649 Context=Force_Stream_Mode|Force_Record_Mode
15653 VMS RMS keys are silently ignored on non-VMS systems. On OpenVMS
15654 unimplented RMS keywords, values, or invalid syntax will raise Use_Error.
15660 Direct_IO can only be instantiated for definite types. This is a
15661 restriction of the Ada language, which means that the records are fixed
15662 length (the length being determined by @code{@var{type}'Size}, rounded
15663 up to the next storage unit boundary if necessary).
15665 The records of a Direct_IO file are simply written to the file in index
15666 sequence, with the first record starting at offset zero, and subsequent
15667 records following. There is no control information of any kind. For
15668 example, if 32-bit integers are being written, each record takes
15669 4-bytes, so the record at index @var{K} starts at offset
15670 (@var{K}@minus{}1)*4.
15672 There is no limit on the size of Direct_IO files, they are expanded as
15673 necessary to accommodate whatever records are written to the file.
15675 @node Sequential_IO
15676 @section Sequential_IO
15679 Sequential_IO may be instantiated with either a definite (constrained)
15680 or indefinite (unconstrained) type.
15682 For the definite type case, the elements written to the file are simply
15683 the memory images of the data values with no control information of any
15684 kind. The resulting file should be read using the same type, no validity
15685 checking is performed on input.
15687 For the indefinite type case, the elements written consist of two
15688 parts. First is the size of the data item, written as the memory image
15689 of a @code{Interfaces.C.size_t} value, followed by the memory image of
15690 the data value. The resulting file can only be read using the same
15691 (unconstrained) type. Normal assignment checks are performed on these
15692 read operations, and if these checks fail, @code{Data_Error} is
15693 raised. In particular, in the array case, the lengths must match, and in
15694 the variant record case, if the variable for a particular read operation
15695 is constrained, the discriminants must match.
15697 Note that it is not possible to use Sequential_IO to write variable
15698 length array items, and then read the data back into different length
15699 arrays. For example, the following will raise @code{Data_Error}:
15701 @smallexample @c ada
15702 package IO is new Sequential_IO (String);
15707 IO.Write (F, "hello!")
15708 IO.Reset (F, Mode=>In_File);
15715 On some Ada implementations, this will print @code{hell}, but the program is
15716 clearly incorrect, since there is only one element in the file, and that
15717 element is the string @code{hello!}.
15719 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
15720 using Stream_IO, and this is the preferred mechanism. In particular, the
15721 above program fragment rewritten to use Stream_IO will work correctly.
15727 Text_IO files consist of a stream of characters containing the following
15728 special control characters:
15731 LF (line feed, 16#0A#) Line Mark
15732 FF (form feed, 16#0C#) Page Mark
15736 A canonical Text_IO file is defined as one in which the following
15737 conditions are met:
15741 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
15745 The character @code{FF} is used only as a page mark, i.e.@: to mark the
15746 end of a page and consequently can appear only immediately following a
15747 @code{LF} (line mark) character.
15750 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
15751 (line mark, page mark). In the former case, the page mark is implicitly
15752 assumed to be present.
15756 A file written using Text_IO will be in canonical form provided that no
15757 explicit @code{LF} or @code{FF} characters are written using @code{Put}
15758 or @code{Put_Line}. There will be no @code{FF} character at the end of
15759 the file unless an explicit @code{New_Page} operation was performed
15760 before closing the file.
15762 A canonical Text_IO file that is a regular file (i.e., not a device or a
15763 pipe) can be read using any of the routines in Text_IO@. The
15764 semantics in this case will be exactly as defined in the Ada Reference
15765 Manual, and all the routines in Text_IO are fully implemented.
15767 A text file that does not meet the requirements for a canonical Text_IO
15768 file has one of the following:
15772 The file contains @code{FF} characters not immediately following a
15773 @code{LF} character.
15776 The file contains @code{LF} or @code{FF} characters written by
15777 @code{Put} or @code{Put_Line}, which are not logically considered to be
15778 line marks or page marks.
15781 The file ends in a character other than @code{LF} or @code{FF},
15782 i.e.@: there is no explicit line mark or page mark at the end of the file.
15786 Text_IO can be used to read such non-standard text files but subprograms
15787 to do with line or page numbers do not have defined meanings. In
15788 particular, a @code{FF} character that does not follow a @code{LF}
15789 character may or may not be treated as a page mark from the point of
15790 view of page and line numbering. Every @code{LF} character is considered
15791 to end a line, and there is an implied @code{LF} character at the end of
15795 * Text_IO Stream Pointer Positioning::
15796 * Text_IO Reading and Writing Non-Regular Files::
15798 * Treating Text_IO Files as Streams::
15799 * Text_IO Extensions::
15800 * Text_IO Facilities for Unbounded Strings::
15803 @node Text_IO Stream Pointer Positioning
15804 @subsection Stream Pointer Positioning
15807 @code{Ada.Text_IO} has a definition of current position for a file that
15808 is being read. No internal buffering occurs in Text_IO, and usually the
15809 physical position in the stream used to implement the file corresponds
15810 to this logical position defined by Text_IO@. There are two exceptions:
15814 After a call to @code{End_Of_Page} that returns @code{True}, the stream
15815 is positioned past the @code{LF} (line mark) that precedes the page
15816 mark. Text_IO maintains an internal flag so that subsequent read
15817 operations properly handle the logical position which is unchanged by
15818 the @code{End_Of_Page} call.
15821 After a call to @code{End_Of_File} that returns @code{True}, if the
15822 Text_IO file was positioned before the line mark at the end of file
15823 before the call, then the logical position is unchanged, but the stream
15824 is physically positioned right at the end of file (past the line mark,
15825 and past a possible page mark following the line mark. Again Text_IO
15826 maintains internal flags so that subsequent read operations properly
15827 handle the logical position.
15831 These discrepancies have no effect on the observable behavior of
15832 Text_IO, but if a single Ada stream is shared between a C program and
15833 Ada program, or shared (using @samp{shared=yes} in the form string)
15834 between two Ada files, then the difference may be observable in some
15837 @node Text_IO Reading and Writing Non-Regular Files
15838 @subsection Reading and Writing Non-Regular Files
15841 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
15842 can be used for reading and writing. Writing is not affected and the
15843 sequence of characters output is identical to the normal file case, but
15844 for reading, the behavior of Text_IO is modified to avoid undesirable
15845 look-ahead as follows:
15847 An input file that is not a regular file is considered to have no page
15848 marks. Any @code{Ascii.FF} characters (the character normally used for a
15849 page mark) appearing in the file are considered to be data
15850 characters. In particular:
15854 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
15855 following a line mark. If a page mark appears, it will be treated as a
15859 This avoids the need to wait for an extra character to be typed or
15860 entered from the pipe to complete one of these operations.
15863 @code{End_Of_Page} always returns @code{False}
15866 @code{End_Of_File} will return @code{False} if there is a page mark at
15867 the end of the file.
15871 Output to non-regular files is the same as for regular files. Page marks
15872 may be written to non-regular files using @code{New_Page}, but as noted
15873 above they will not be treated as page marks on input if the output is
15874 piped to another Ada program.
15876 Another important discrepancy when reading non-regular files is that the end
15877 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
15878 pressing the @key{EOT} key,
15880 is signaled once (i.e.@: the test @code{End_Of_File}
15881 will yield @code{True}, or a read will
15882 raise @code{End_Error}), but then reading can resume
15883 to read data past that end of
15884 file indication, until another end of file indication is entered.
15886 @node Get_Immediate
15887 @subsection Get_Immediate
15888 @cindex Get_Immediate
15891 Get_Immediate returns the next character (including control characters)
15892 from the input file. In particular, Get_Immediate will return LF or FF
15893 characters used as line marks or page marks. Such operations leave the
15894 file positioned past the control character, and it is thus not treated
15895 as having its normal function. This means that page, line and column
15896 counts after this kind of Get_Immediate call are set as though the mark
15897 did not occur. In the case where a Get_Immediate leaves the file
15898 positioned between the line mark and page mark (which is not normally
15899 possible), it is undefined whether the FF character will be treated as a
15902 @node Treating Text_IO Files as Streams
15903 @subsection Treating Text_IO Files as Streams
15904 @cindex Stream files
15907 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
15908 as a stream. Data written to a Text_IO file in this stream mode is
15909 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
15910 16#0C# (@code{FF}), the resulting file may have non-standard
15911 format. Similarly if read operations are used to read from a Text_IO
15912 file treated as a stream, then @code{LF} and @code{FF} characters may be
15913 skipped and the effect is similar to that described above for
15914 @code{Get_Immediate}.
15916 @node Text_IO Extensions
15917 @subsection Text_IO Extensions
15918 @cindex Text_IO extensions
15921 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
15922 to the standard @code{Text_IO} package:
15925 @item function File_Exists (Name : String) return Boolean;
15926 Determines if a file of the given name exists.
15928 @item function Get_Line return String;
15929 Reads a string from the standard input file. The value returned is exactly
15930 the length of the line that was read.
15932 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
15933 Similar, except that the parameter File specifies the file from which
15934 the string is to be read.
15938 @node Text_IO Facilities for Unbounded Strings
15939 @subsection Text_IO Facilities for Unbounded Strings
15940 @cindex Text_IO for unbounded strings
15941 @cindex Unbounded_String, Text_IO operations
15944 The package @code{Ada.Strings.Unbounded.Text_IO}
15945 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
15946 subprograms useful for Text_IO operations on unbounded strings:
15950 @item function Get_Line (File : File_Type) return Unbounded_String;
15951 Reads a line from the specified file
15952 and returns the result as an unbounded string.
15954 @item procedure Put (File : File_Type; U : Unbounded_String);
15955 Writes the value of the given unbounded string to the specified file
15956 Similar to the effect of
15957 @code{Put (To_String (U))} except that an extra copy is avoided.
15959 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
15960 Writes the value of the given unbounded string to the specified file,
15961 followed by a @code{New_Line}.
15962 Similar to the effect of @code{Put_Line (To_String (U))} except
15963 that an extra copy is avoided.
15967 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
15968 and is optional. If the parameter is omitted, then the standard input or
15969 output file is referenced as appropriate.
15971 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
15972 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
15973 @code{Wide_Text_IO} functionality for unbounded wide strings.
15975 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
15976 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
15977 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
15980 @section Wide_Text_IO
15983 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
15984 both input and output files may contain special sequences that represent
15985 wide character values. The encoding scheme for a given file may be
15986 specified using a FORM parameter:
15993 as part of the FORM string (WCEM = wide character encoding method),
15994 where @var{x} is one of the following characters
16000 Upper half encoding
16012 The encoding methods match those that
16013 can be used in a source
16014 program, but there is no requirement that the encoding method used for
16015 the source program be the same as the encoding method used for files,
16016 and different files may use different encoding methods.
16018 The default encoding method for the standard files, and for opened files
16019 for which no WCEM parameter is given in the FORM string matches the
16020 wide character encoding specified for the main program (the default
16021 being brackets encoding if no coding method was specified with -gnatW).
16025 In this encoding, a wide character is represented by a five character
16033 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
16034 characters (using upper case letters) of the wide character code. For
16035 example, ESC A345 is used to represent the wide character with code
16036 16#A345#. This scheme is compatible with use of the full
16037 @code{Wide_Character} set.
16039 @item Upper Half Coding
16040 The wide character with encoding 16#abcd#, where the upper bit is on
16041 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
16042 16#cd#. The second byte may never be a format control character, but is
16043 not required to be in the upper half. This method can be also used for
16044 shift-JIS or EUC where the internal coding matches the external coding.
16046 @item Shift JIS Coding
16047 A wide character is represented by a two character sequence 16#ab# and
16048 16#cd#, with the restrictions described for upper half encoding as
16049 described above. The internal character code is the corresponding JIS
16050 character according to the standard algorithm for Shift-JIS
16051 conversion. Only characters defined in the JIS code set table can be
16052 used with this encoding method.
16055 A wide character is represented by a two character sequence 16#ab# and
16056 16#cd#, with both characters being in the upper half. The internal
16057 character code is the corresponding JIS character according to the EUC
16058 encoding algorithm. Only characters defined in the JIS code set table
16059 can be used with this encoding method.
16062 A wide character is represented using
16063 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
16064 10646-1/Am.2. Depending on the character value, the representation
16065 is a one, two, or three byte sequence:
16068 16#0000#-16#007f#: 2#0xxxxxxx#
16069 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
16070 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
16074 where the @var{xxx} bits correspond to the left-padded bits of the
16075 16-bit character value. Note that all lower half ASCII characters
16076 are represented as ASCII bytes and all upper half characters and
16077 other wide characters are represented as sequences of upper-half
16078 (The full UTF-8 scheme allows for encoding 31-bit characters as
16079 6-byte sequences, but in this implementation, all UTF-8 sequences
16080 of four or more bytes length will raise a Constraint_Error, as
16081 will all invalid UTF-8 sequences.)
16083 @item Brackets Coding
16084 In this encoding, a wide character is represented by the following eight
16085 character sequence:
16092 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
16093 characters (using uppercase letters) of the wide character code. For
16094 example, @code{["A345"]} is used to represent the wide character with code
16096 This scheme is compatible with use of the full Wide_Character set.
16097 On input, brackets coding can also be used for upper half characters,
16098 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
16099 is only used for wide characters with a code greater than @code{16#FF#}.
16101 Note that brackets coding is not normally used in the context of
16102 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
16103 a portable way of encoding source files. In the context of Wide_Text_IO
16104 or Wide_Wide_Text_IO, it can only be used if the file does not contain
16105 any instance of the left bracket character other than to encode wide
16106 character values using the brackets encoding method. In practice it is
16107 expected that some standard wide character encoding method such
16108 as UTF-8 will be used for text input output.
16110 If brackets notation is used, then any occurrence of a left bracket
16111 in the input file which is not the start of a valid wide character
16112 sequence will cause Constraint_Error to be raised. It is possible to
16113 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
16114 input will interpret this as a left bracket.
16116 However, when a left bracket is output, it will be output as a left bracket
16117 and not as ["5B"]. We make this decision because for normal use of
16118 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
16119 brackets. For example, if we write:
16122 Put_Line ("Start of output [first run]");
16126 we really do not want to have the left bracket in this message clobbered so
16127 that the output reads:
16130 Start of output ["5B"]first run]
16134 In practice brackets encoding is reasonably useful for normal Put_Line use
16135 since we won't get confused between left brackets and wide character
16136 sequences in the output. But for input, or when files are written out
16137 and read back in, it really makes better sense to use one of the standard
16138 encoding methods such as UTF-8.
16143 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
16144 not all wide character
16145 values can be represented. An attempt to output a character that cannot
16146 be represented using the encoding scheme for the file causes
16147 Constraint_Error to be raised. An invalid wide character sequence on
16148 input also causes Constraint_Error to be raised.
16151 * Wide_Text_IO Stream Pointer Positioning::
16152 * Wide_Text_IO Reading and Writing Non-Regular Files::
16155 @node Wide_Text_IO Stream Pointer Positioning
16156 @subsection Stream Pointer Positioning
16159 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
16160 of stream pointer positioning (@pxref{Text_IO}). There is one additional
16163 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
16164 normal lower ASCII set (i.e.@: a character in the range:
16166 @smallexample @c ada
16167 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
16171 then although the logical position of the file pointer is unchanged by
16172 the @code{Look_Ahead} call, the stream is physically positioned past the
16173 wide character sequence. Again this is to avoid the need for buffering
16174 or backup, and all @code{Wide_Text_IO} routines check the internal
16175 indication that this situation has occurred so that this is not visible
16176 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
16177 can be observed if the wide text file shares a stream with another file.
16179 @node Wide_Text_IO Reading and Writing Non-Regular Files
16180 @subsection Reading and Writing Non-Regular Files
16183 As in the case of Text_IO, when a non-regular file is read, it is
16184 assumed that the file contains no page marks (any form characters are
16185 treated as data characters), and @code{End_Of_Page} always returns
16186 @code{False}. Similarly, the end of file indication is not sticky, so
16187 it is possible to read beyond an end of file.
16189 @node Wide_Wide_Text_IO
16190 @section Wide_Wide_Text_IO
16193 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
16194 both input and output files may contain special sequences that represent
16195 wide wide character values. The encoding scheme for a given file may be
16196 specified using a FORM parameter:
16203 as part of the FORM string (WCEM = wide character encoding method),
16204 where @var{x} is one of the following characters
16210 Upper half encoding
16222 The encoding methods match those that
16223 can be used in a source
16224 program, but there is no requirement that the encoding method used for
16225 the source program be the same as the encoding method used for files,
16226 and different files may use different encoding methods.
16228 The default encoding method for the standard files, and for opened files
16229 for which no WCEM parameter is given in the FORM string matches the
16230 wide character encoding specified for the main program (the default
16231 being brackets encoding if no coding method was specified with -gnatW).
16236 A wide character is represented using
16237 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
16238 10646-1/Am.2. Depending on the character value, the representation
16239 is a one, two, three, or four byte sequence:
16242 16#000000#-16#00007f#: 2#0xxxxxxx#
16243 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
16244 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
16245 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
16249 where the @var{xxx} bits correspond to the left-padded bits of the
16250 21-bit character value. Note that all lower half ASCII characters
16251 are represented as ASCII bytes and all upper half characters and
16252 other wide characters are represented as sequences of upper-half
16255 @item Brackets Coding
16256 In this encoding, a wide wide character is represented by the following eight
16257 character sequence if is in wide character range
16263 and by the following ten character sequence if not
16266 [ " a b c d e f " ]
16270 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
16271 are the four or six hexadecimal
16272 characters (using uppercase letters) of the wide wide character code. For
16273 example, @code{["01A345"]} is used to represent the wide wide character
16274 with code @code{16#01A345#}.
16276 This scheme is compatible with use of the full Wide_Wide_Character set.
16277 On input, brackets coding can also be used for upper half characters,
16278 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
16279 is only used for wide characters with a code greater than @code{16#FF#}.
16284 If is also possible to use the other Wide_Character encoding methods,
16285 such as Shift-JIS, but the other schemes cannot support the full range
16286 of wide wide characters.
16287 An attempt to output a character that cannot
16288 be represented using the encoding scheme for the file causes
16289 Constraint_Error to be raised. An invalid wide character sequence on
16290 input also causes Constraint_Error to be raised.
16293 * Wide_Wide_Text_IO Stream Pointer Positioning::
16294 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
16297 @node Wide_Wide_Text_IO Stream Pointer Positioning
16298 @subsection Stream Pointer Positioning
16301 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
16302 of stream pointer positioning (@pxref{Text_IO}). There is one additional
16305 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
16306 normal lower ASCII set (i.e.@: a character in the range:
16308 @smallexample @c ada
16309 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
16313 then although the logical position of the file pointer is unchanged by
16314 the @code{Look_Ahead} call, the stream is physically positioned past the
16315 wide character sequence. Again this is to avoid the need for buffering
16316 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
16317 indication that this situation has occurred so that this is not visible
16318 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
16319 can be observed if the wide text file shares a stream with another file.
16321 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
16322 @subsection Reading and Writing Non-Regular Files
16325 As in the case of Text_IO, when a non-regular file is read, it is
16326 assumed that the file contains no page marks (any form characters are
16327 treated as data characters), and @code{End_Of_Page} always returns
16328 @code{False}. Similarly, the end of file indication is not sticky, so
16329 it is possible to read beyond an end of file.
16335 A stream file is a sequence of bytes, where individual elements are
16336 written to the file as described in the Ada Reference Manual. The type
16337 @code{Stream_Element} is simply a byte. There are two ways to read or
16338 write a stream file.
16342 The operations @code{Read} and @code{Write} directly read or write a
16343 sequence of stream elements with no control information.
16346 The stream attributes applied to a stream file transfer data in the
16347 manner described for stream attributes.
16350 @node Text Translation
16351 @section Text Translation
16354 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
16355 passed to Text_IO.Create and Text_IO.Open:
16356 @samp{Text_Translation=@var{Yes}} is the default, which means to
16357 translate LF to/from CR/LF on Windows systems.
16358 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
16359 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
16360 may be used to create Unix-style files on
16361 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
16365 @section Shared Files
16368 Section A.14 of the Ada Reference Manual allows implementations to
16369 provide a wide variety of behavior if an attempt is made to access the
16370 same external file with two or more internal files.
16372 To provide a full range of functionality, while at the same time
16373 minimizing the problems of portability caused by this implementation
16374 dependence, GNAT handles file sharing as follows:
16378 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
16379 to open two or more files with the same full name is considered an error
16380 and is not supported. The exception @code{Use_Error} will be
16381 raised. Note that a file that is not explicitly closed by the program
16382 remains open until the program terminates.
16385 If the form parameter @samp{shared=no} appears in the form string, the
16386 file can be opened or created with its own separate stream identifier,
16387 regardless of whether other files sharing the same external file are
16388 opened. The exact effect depends on how the C stream routines handle
16389 multiple accesses to the same external files using separate streams.
16392 If the form parameter @samp{shared=yes} appears in the form string for
16393 each of two or more files opened using the same full name, the same
16394 stream is shared between these files, and the semantics are as described
16395 in Ada Reference Manual, Section A.14.
16399 When a program that opens multiple files with the same name is ported
16400 from another Ada compiler to GNAT, the effect will be that
16401 @code{Use_Error} is raised.
16403 The documentation of the original compiler and the documentation of the
16404 program should then be examined to determine if file sharing was
16405 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
16406 and @code{Create} calls as required.
16408 When a program is ported from GNAT to some other Ada compiler, no
16409 special attention is required unless the @samp{shared=@var{xxx}} form
16410 parameter is used in the program. In this case, you must examine the
16411 documentation of the new compiler to see if it supports the required
16412 file sharing semantics, and form strings modified appropriately. Of
16413 course it may be the case that the program cannot be ported if the
16414 target compiler does not support the required functionality. The best
16415 approach in writing portable code is to avoid file sharing (and hence
16416 the use of the @samp{shared=@var{xxx}} parameter in the form string)
16419 One common use of file sharing in Ada 83 is the use of instantiations of
16420 Sequential_IO on the same file with different types, to achieve
16421 heterogeneous input-output. Although this approach will work in GNAT if
16422 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
16423 for this purpose (using the stream attributes)
16425 @node Filenames encoding
16426 @section Filenames encoding
16429 An encoding form parameter can be used to specify the filename
16430 encoding @samp{encoding=@var{xxx}}.
16434 If the form parameter @samp{encoding=utf8} appears in the form string, the
16435 filename must be encoded in UTF-8.
16438 If the form parameter @samp{encoding=8bits} appears in the form
16439 string, the filename must be a standard 8bits string.
16442 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
16443 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
16444 variable. And if not set @samp{utf8} is assumed.
16448 The current system Windows ANSI code page.
16453 This encoding form parameter is only supported on the Windows
16454 platform. On the other Operating Systems the run-time is supporting
16458 @section Open Modes
16461 @code{Open} and @code{Create} calls result in a call to @code{fopen}
16462 using the mode shown in the following table:
16465 @center @code{Open} and @code{Create} Call Modes
16467 @b{OPEN } @b{CREATE}
16468 Append_File "r+" "w+"
16470 Out_File (Direct_IO) "r+" "w"
16471 Out_File (all other cases) "w" "w"
16472 Inout_File "r+" "w+"
16476 If text file translation is required, then either @samp{b} or @samp{t}
16477 is added to the mode, depending on the setting of Text. Text file
16478 translation refers to the mapping of CR/LF sequences in an external file
16479 to LF characters internally. This mapping only occurs in DOS and
16480 DOS-like systems, and is not relevant to other systems.
16482 A special case occurs with Stream_IO@. As shown in the above table, the
16483 file is initially opened in @samp{r} or @samp{w} mode for the
16484 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
16485 subsequently requires switching from reading to writing or vice-versa,
16486 then the file is reopened in @samp{r+} mode to permit the required operation.
16488 @node Operations on C Streams
16489 @section Operations on C Streams
16490 The package @code{Interfaces.C_Streams} provides an Ada program with direct
16491 access to the C library functions for operations on C streams:
16493 @smallexample @c adanocomment
16494 package Interfaces.C_Streams is
16495 -- Note: the reason we do not use the types that are in
16496 -- Interfaces.C is that we want to avoid dragging in the
16497 -- code in this unit if possible.
16498 subtype chars is System.Address;
16499 -- Pointer to null-terminated array of characters
16500 subtype FILEs is System.Address;
16501 -- Corresponds to the C type FILE*
16502 subtype voids is System.Address;
16503 -- Corresponds to the C type void*
16504 subtype int is Integer;
16505 subtype long is Long_Integer;
16506 -- Note: the above types are subtypes deliberately, and it
16507 -- is part of this spec that the above correspondences are
16508 -- guaranteed. This means that it is legitimate to, for
16509 -- example, use Integer instead of int. We provide these
16510 -- synonyms for clarity, but in some cases it may be
16511 -- convenient to use the underlying types (for example to
16512 -- avoid an unnecessary dependency of a spec on the spec
16514 type size_t is mod 2 ** Standard'Address_Size;
16515 NULL_Stream : constant FILEs;
16516 -- Value returned (NULL in C) to indicate an
16517 -- fdopen/fopen/tmpfile error
16518 ----------------------------------
16519 -- Constants Defined in stdio.h --
16520 ----------------------------------
16521 EOF : constant int;
16522 -- Used by a number of routines to indicate error or
16524 IOFBF : constant int;
16525 IOLBF : constant int;
16526 IONBF : constant int;
16527 -- Used to indicate buffering mode for setvbuf call
16528 SEEK_CUR : constant int;
16529 SEEK_END : constant int;
16530 SEEK_SET : constant int;
16531 -- Used to indicate origin for fseek call
16532 function stdin return FILEs;
16533 function stdout return FILEs;
16534 function stderr return FILEs;
16535 -- Streams associated with standard files
16536 --------------------------
16537 -- Standard C functions --
16538 --------------------------
16539 -- The functions selected below are ones that are
16540 -- available in UNIX (but not necessarily in ANSI C).
16541 -- These are very thin interfaces
16542 -- which copy exactly the C headers. For more
16543 -- documentation on these functions, see the Microsoft C
16544 -- "Run-Time Library Reference" (Microsoft Press, 1990,
16545 -- ISBN 1-55615-225-6), which includes useful information
16546 -- on system compatibility.
16547 procedure clearerr (stream : FILEs);
16548 function fclose (stream : FILEs) return int;
16549 function fdopen (handle : int; mode : chars) return FILEs;
16550 function feof (stream : FILEs) return int;
16551 function ferror (stream : FILEs) return int;
16552 function fflush (stream : FILEs) return int;
16553 function fgetc (stream : FILEs) return int;
16554 function fgets (strng : chars; n : int; stream : FILEs)
16556 function fileno (stream : FILEs) return int;
16557 function fopen (filename : chars; Mode : chars)
16559 -- Note: to maintain target independence, use
16560 -- text_translation_required, a boolean variable defined in
16561 -- a-sysdep.c to deal with the target dependent text
16562 -- translation requirement. If this variable is set,
16563 -- then b/t should be appended to the standard mode
16564 -- argument to set the text translation mode off or on
16566 function fputc (C : int; stream : FILEs) return int;
16567 function fputs (Strng : chars; Stream : FILEs) return int;
16584 function ftell (stream : FILEs) return long;
16591 function isatty (handle : int) return int;
16592 procedure mktemp (template : chars);
16593 -- The return value (which is just a pointer to template)
16595 procedure rewind (stream : FILEs);
16596 function rmtmp return int;
16604 function tmpfile return FILEs;
16605 function ungetc (c : int; stream : FILEs) return int;
16606 function unlink (filename : chars) return int;
16607 ---------------------
16608 -- Extra functions --
16609 ---------------------
16610 -- These functions supply slightly thicker bindings than
16611 -- those above. They are derived from functions in the
16612 -- C Run-Time Library, but may do a bit more work than
16613 -- just directly calling one of the Library functions.
16614 function is_regular_file (handle : int) return int;
16615 -- Tests if given handle is for a regular file (result 1)
16616 -- or for a non-regular file (pipe or device, result 0).
16617 ---------------------------------
16618 -- Control of Text/Binary Mode --
16619 ---------------------------------
16620 -- If text_translation_required is true, then the following
16621 -- functions may be used to dynamically switch a file from
16622 -- binary to text mode or vice versa. These functions have
16623 -- no effect if text_translation_required is false (i.e.@: in
16624 -- normal UNIX mode). Use fileno to get a stream handle.
16625 procedure set_binary_mode (handle : int);
16626 procedure set_text_mode (handle : int);
16627 ----------------------------
16628 -- Full Path Name support --
16629 ----------------------------
16630 procedure full_name (nam : chars; buffer : chars);
16631 -- Given a NUL terminated string representing a file
16632 -- name, returns in buffer a NUL terminated string
16633 -- representing the full path name for the file name.
16634 -- On systems where it is relevant the drive is also
16635 -- part of the full path name. It is the responsibility
16636 -- of the caller to pass an actual parameter for buffer
16637 -- that is big enough for any full path name. Use
16638 -- max_path_len given below as the size of buffer.
16639 max_path_len : integer;
16640 -- Maximum length of an allowable full path name on the
16641 -- system, including a terminating NUL character.
16642 end Interfaces.C_Streams;
16645 @node Interfacing to C Streams
16646 @section Interfacing to C Streams
16649 The packages in this section permit interfacing Ada files to C Stream
16652 @smallexample @c ada
16653 with Interfaces.C_Streams;
16654 package Ada.Sequential_IO.C_Streams is
16655 function C_Stream (F : File_Type)
16656 return Interfaces.C_Streams.FILEs;
16658 (File : in out File_Type;
16659 Mode : in File_Mode;
16660 C_Stream : in Interfaces.C_Streams.FILEs;
16661 Form : in String := "");
16662 end Ada.Sequential_IO.C_Streams;
16664 with Interfaces.C_Streams;
16665 package Ada.Direct_IO.C_Streams is
16666 function C_Stream (F : File_Type)
16667 return Interfaces.C_Streams.FILEs;
16669 (File : in out File_Type;
16670 Mode : in File_Mode;
16671 C_Stream : in Interfaces.C_Streams.FILEs;
16672 Form : in String := "");
16673 end Ada.Direct_IO.C_Streams;
16675 with Interfaces.C_Streams;
16676 package Ada.Text_IO.C_Streams is
16677 function C_Stream (F : File_Type)
16678 return Interfaces.C_Streams.FILEs;
16680 (File : in out File_Type;
16681 Mode : in File_Mode;
16682 C_Stream : in Interfaces.C_Streams.FILEs;
16683 Form : in String := "");
16684 end Ada.Text_IO.C_Streams;
16686 with Interfaces.C_Streams;
16687 package Ada.Wide_Text_IO.C_Streams is
16688 function C_Stream (F : File_Type)
16689 return Interfaces.C_Streams.FILEs;
16691 (File : in out File_Type;
16692 Mode : in File_Mode;
16693 C_Stream : in Interfaces.C_Streams.FILEs;
16694 Form : in String := "");
16695 end Ada.Wide_Text_IO.C_Streams;
16697 with Interfaces.C_Streams;
16698 package Ada.Wide_Wide_Text_IO.C_Streams is
16699 function C_Stream (F : File_Type)
16700 return Interfaces.C_Streams.FILEs;
16702 (File : in out File_Type;
16703 Mode : in File_Mode;
16704 C_Stream : in Interfaces.C_Streams.FILEs;
16705 Form : in String := "");
16706 end Ada.Wide_Wide_Text_IO.C_Streams;
16708 with Interfaces.C_Streams;
16709 package Ada.Stream_IO.C_Streams is
16710 function C_Stream (F : File_Type)
16711 return Interfaces.C_Streams.FILEs;
16713 (File : in out File_Type;
16714 Mode : in File_Mode;
16715 C_Stream : in Interfaces.C_Streams.FILEs;
16716 Form : in String := "");
16717 end Ada.Stream_IO.C_Streams;
16721 In each of these six packages, the @code{C_Stream} function obtains the
16722 @code{FILE} pointer from a currently opened Ada file. It is then
16723 possible to use the @code{Interfaces.C_Streams} package to operate on
16724 this stream, or the stream can be passed to a C program which can
16725 operate on it directly. Of course the program is responsible for
16726 ensuring that only appropriate sequences of operations are executed.
16728 One particular use of relevance to an Ada program is that the
16729 @code{setvbuf} function can be used to control the buffering of the
16730 stream used by an Ada file. In the absence of such a call the standard
16731 default buffering is used.
16733 The @code{Open} procedures in these packages open a file giving an
16734 existing C Stream instead of a file name. Typically this stream is
16735 imported from a C program, allowing an Ada file to operate on an
16738 @node The GNAT Library
16739 @chapter The GNAT Library
16742 The GNAT library contains a number of general and special purpose packages.
16743 It represents functionality that the GNAT developers have found useful, and
16744 which is made available to GNAT users. The packages described here are fully
16745 supported, and upwards compatibility will be maintained in future releases,
16746 so you can use these facilities with the confidence that the same functionality
16747 will be available in future releases.
16749 The chapter here simply gives a brief summary of the facilities available.
16750 The full documentation is found in the spec file for the package. The full
16751 sources of these library packages, including both spec and body, are provided
16752 with all GNAT releases. For example, to find out the full specifications of
16753 the SPITBOL pattern matching capability, including a full tutorial and
16754 extensive examples, look in the @file{g-spipat.ads} file in the library.
16756 For each entry here, the package name (as it would appear in a @code{with}
16757 clause) is given, followed by the name of the corresponding spec file in
16758 parentheses. The packages are children in four hierarchies, @code{Ada},
16759 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
16760 GNAT-specific hierarchy.
16762 Note that an application program should only use packages in one of these
16763 four hierarchies if the package is defined in the Ada Reference Manual,
16764 or is listed in this section of the GNAT Programmers Reference Manual.
16765 All other units should be considered internal implementation units and
16766 should not be directly @code{with}'ed by application code. The use of
16767 a @code{with} statement that references one of these internal implementation
16768 units makes an application potentially dependent on changes in versions
16769 of GNAT, and will generate a warning message.
16772 * Ada.Characters.Latin_9 (a-chlat9.ads)::
16773 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
16774 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
16775 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
16776 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
16777 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
16778 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
16779 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
16780 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
16781 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
16782 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
16783 * Ada.Command_Line.Environment (a-colien.ads)::
16784 * Ada.Command_Line.Remove (a-colire.ads)::
16785 * Ada.Command_Line.Response_File (a-clrefi.ads)::
16786 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
16787 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
16788 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
16789 * Ada.Exceptions.Traceback (a-exctra.ads)::
16790 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
16791 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
16792 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
16793 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
16794 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
16795 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
16796 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
16797 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
16798 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
16799 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
16800 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
16801 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
16802 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
16803 * GNAT.Altivec (g-altive.ads)::
16804 * GNAT.Altivec.Conversions (g-altcon.ads)::
16805 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
16806 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
16807 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
16808 * GNAT.Array_Split (g-arrspl.ads)::
16809 * GNAT.AWK (g-awk.ads)::
16810 * GNAT.Bounded_Buffers (g-boubuf.ads)::
16811 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
16812 * GNAT.Bubble_Sort (g-bubsor.ads)::
16813 * GNAT.Bubble_Sort_A (g-busora.ads)::
16814 * GNAT.Bubble_Sort_G (g-busorg.ads)::
16815 * GNAT.Byte_Order_Mark (g-byorma.ads)::
16816 * GNAT.Byte_Swapping (g-bytswa.ads)::
16817 * GNAT.Calendar (g-calend.ads)::
16818 * GNAT.Calendar.Time_IO (g-catiio.ads)::
16819 * GNAT.Case_Util (g-casuti.ads)::
16820 * GNAT.CGI (g-cgi.ads)::
16821 * GNAT.CGI.Cookie (g-cgicoo.ads)::
16822 * GNAT.CGI.Debug (g-cgideb.ads)::
16823 * GNAT.Command_Line (g-comlin.ads)::
16824 * GNAT.Compiler_Version (g-comver.ads)::
16825 * GNAT.Ctrl_C (g-ctrl_c.ads)::
16826 * GNAT.CRC32 (g-crc32.ads)::
16827 * GNAT.Current_Exception (g-curexc.ads)::
16828 * GNAT.Debug_Pools (g-debpoo.ads)::
16829 * GNAT.Debug_Utilities (g-debuti.ads)::
16830 * GNAT.Decode_String (g-decstr.ads)::
16831 * GNAT.Decode_UTF8_String (g-deutst.ads)::
16832 * GNAT.Directory_Operations (g-dirope.ads)::
16833 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
16834 * GNAT.Dynamic_HTables (g-dynhta.ads)::
16835 * GNAT.Dynamic_Tables (g-dyntab.ads)::
16836 * GNAT.Encode_String (g-encstr.ads)::
16837 * GNAT.Encode_UTF8_String (g-enutst.ads)::
16838 * GNAT.Exception_Actions (g-excact.ads)::
16839 * GNAT.Exception_Traces (g-exctra.ads)::
16840 * GNAT.Exceptions (g-except.ads)::
16841 * GNAT.Expect (g-expect.ads)::
16842 * GNAT.Expect.TTY (g-exptty.ads)::
16843 * GNAT.Float_Control (g-flocon.ads)::
16844 * GNAT.Heap_Sort (g-heasor.ads)::
16845 * GNAT.Heap_Sort_A (g-hesora.ads)::
16846 * GNAT.Heap_Sort_G (g-hesorg.ads)::
16847 * GNAT.HTable (g-htable.ads)::
16848 * GNAT.IO (g-io.ads)::
16849 * GNAT.IO_Aux (g-io_aux.ads)::
16850 * GNAT.Lock_Files (g-locfil.ads)::
16851 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
16852 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
16853 * GNAT.MD5 (g-md5.ads)::
16854 * GNAT.Memory_Dump (g-memdum.ads)::
16855 * GNAT.Most_Recent_Exception (g-moreex.ads)::
16856 * GNAT.OS_Lib (g-os_lib.ads)::
16857 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
16858 * GNAT.Random_Numbers (g-rannum.ads)::
16859 * GNAT.Regexp (g-regexp.ads)::
16860 * GNAT.Registry (g-regist.ads)::
16861 * GNAT.Regpat (g-regpat.ads)::
16862 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
16863 * GNAT.Semaphores (g-semaph.ads)::
16864 * GNAT.Serial_Communications (g-sercom.ads)::
16865 * GNAT.SHA1 (g-sha1.ads)::
16866 * GNAT.SHA224 (g-sha224.ads)::
16867 * GNAT.SHA256 (g-sha256.ads)::
16868 * GNAT.SHA384 (g-sha384.ads)::
16869 * GNAT.SHA512 (g-sha512.ads)::
16870 * GNAT.Signals (g-signal.ads)::
16871 * GNAT.Sockets (g-socket.ads)::
16872 * GNAT.Source_Info (g-souinf.ads)::
16873 * GNAT.Spelling_Checker (g-speche.ads)::
16874 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
16875 * GNAT.Spitbol.Patterns (g-spipat.ads)::
16876 * GNAT.Spitbol (g-spitbo.ads)::
16877 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
16878 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
16879 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
16880 * GNAT.SSE (g-sse.ads)::
16881 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
16882 * GNAT.Strings (g-string.ads)::
16883 * GNAT.String_Split (g-strspl.ads)::
16884 * GNAT.Table (g-table.ads)::
16885 * GNAT.Task_Lock (g-tasloc.ads)::
16886 * GNAT.Threads (g-thread.ads)::
16887 * GNAT.Time_Stamp (g-timsta.ads)::
16888 * GNAT.Traceback (g-traceb.ads)::
16889 * GNAT.Traceback.Symbolic (g-trasym.ads)::
16890 * GNAT.UTF_32 (g-utf_32.ads)::
16891 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
16892 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
16893 * GNAT.Wide_String_Split (g-wistsp.ads)::
16894 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
16895 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
16896 * Interfaces.C.Extensions (i-cexten.ads)::
16897 * Interfaces.C.Streams (i-cstrea.ads)::
16898 * Interfaces.CPP (i-cpp.ads)::
16899 * Interfaces.Packed_Decimal (i-pacdec.ads)::
16900 * Interfaces.VxWorks (i-vxwork.ads)::
16901 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
16902 * System.Address_Image (s-addima.ads)::
16903 * System.Assertions (s-assert.ads)::
16904 * System.Memory (s-memory.ads)::
16905 * System.Multiprocessors (s-multip.ads)::
16906 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
16907 * System.Partition_Interface (s-parint.ads)::
16908 * System.Pool_Global (s-pooglo.ads)::
16909 * System.Pool_Local (s-pooloc.ads)::
16910 * System.Restrictions (s-restri.ads)::
16911 * System.Rident (s-rident.ads)::
16912 * System.Strings.Stream_Ops (s-ststop.ads)::
16913 * System.Task_Info (s-tasinf.ads)::
16914 * System.Wch_Cnv (s-wchcnv.ads)::
16915 * System.Wch_Con (s-wchcon.ads)::
16918 @node Ada.Characters.Latin_9 (a-chlat9.ads)
16919 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
16920 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
16921 @cindex Latin_9 constants for Character
16924 This child of @code{Ada.Characters}
16925 provides a set of definitions corresponding to those in the
16926 RM-defined package @code{Ada.Characters.Latin_1} but with the
16927 few modifications required for @code{Latin-9}
16928 The provision of such a package
16929 is specifically authorized by the Ada Reference Manual
16932 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
16933 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
16934 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
16935 @cindex Latin_1 constants for Wide_Character
16938 This child of @code{Ada.Characters}
16939 provides a set of definitions corresponding to those in the
16940 RM-defined package @code{Ada.Characters.Latin_1} but with the
16941 types of the constants being @code{Wide_Character}
16942 instead of @code{Character}. The provision of such a package
16943 is specifically authorized by the Ada Reference Manual
16946 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
16947 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
16948 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
16949 @cindex Latin_9 constants for Wide_Character
16952 This child of @code{Ada.Characters}
16953 provides a set of definitions corresponding to those in the
16954 GNAT defined package @code{Ada.Characters.Latin_9} but with the
16955 types of the constants being @code{Wide_Character}
16956 instead of @code{Character}. The provision of such a package
16957 is specifically authorized by the Ada Reference Manual
16960 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
16961 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
16962 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
16963 @cindex Latin_1 constants for Wide_Wide_Character
16966 This child of @code{Ada.Characters}
16967 provides a set of definitions corresponding to those in the
16968 RM-defined package @code{Ada.Characters.Latin_1} but with the
16969 types of the constants being @code{Wide_Wide_Character}
16970 instead of @code{Character}. The provision of such a package
16971 is specifically authorized by the Ada Reference Manual
16974 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
16975 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
16976 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
16977 @cindex Latin_9 constants for Wide_Wide_Character
16980 This child of @code{Ada.Characters}
16981 provides a set of definitions corresponding to those in the
16982 GNAT defined package @code{Ada.Characters.Latin_9} but with the
16983 types of the constants being @code{Wide_Wide_Character}
16984 instead of @code{Character}. The provision of such a package
16985 is specifically authorized by the Ada Reference Manual
16988 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
16989 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
16990 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
16991 @cindex Formal container for doubly linked lists
16994 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16995 container for doubly linked lists, meant to facilitate formal verification of
16996 code using such containers.
16998 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
16999 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
17000 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
17001 @cindex Formal container for hashed maps
17004 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
17005 container for hashed maps, meant to facilitate formal verification of
17006 code using such containers.
17008 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
17009 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
17010 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
17011 @cindex Formal container for hashed sets
17014 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
17015 container for hashed sets, meant to facilitate formal verification of
17016 code using such containers.
17018 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
17019 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
17020 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
17021 @cindex Formal container for ordered maps
17024 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
17025 container for ordered maps, meant to facilitate formal verification of
17026 code using such containers.
17028 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
17029 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
17030 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
17031 @cindex Formal container for ordered sets
17034 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
17035 container for ordered sets, meant to facilitate formal verification of
17036 code using such containers.
17038 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
17039 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
17040 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
17041 @cindex Formal container for vectors
17044 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
17045 container for vectors, meant to facilitate formal verification of
17046 code using such containers.
17048 @node Ada.Command_Line.Environment (a-colien.ads)
17049 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
17050 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
17051 @cindex Environment entries
17054 This child of @code{Ada.Command_Line}
17055 provides a mechanism for obtaining environment values on systems
17056 where this concept makes sense.
17058 @node Ada.Command_Line.Remove (a-colire.ads)
17059 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
17060 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
17061 @cindex Removing command line arguments
17062 @cindex Command line, argument removal
17065 This child of @code{Ada.Command_Line}
17066 provides a mechanism for logically removing
17067 arguments from the argument list. Once removed, an argument is not visible
17068 to further calls on the subprograms in @code{Ada.Command_Line} will not
17069 see the removed argument.
17071 @node Ada.Command_Line.Response_File (a-clrefi.ads)
17072 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
17073 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
17074 @cindex Response file for command line
17075 @cindex Command line, response file
17076 @cindex Command line, handling long command lines
17079 This child of @code{Ada.Command_Line} provides a mechanism facilities for
17080 getting command line arguments from a text file, called a "response file".
17081 Using a response file allow passing a set of arguments to an executable longer
17082 than the maximum allowed by the system on the command line.
17084 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
17085 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
17086 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
17087 @cindex C Streams, Interfacing with Direct_IO
17090 This package provides subprograms that allow interfacing between
17091 C streams and @code{Direct_IO}. The stream identifier can be
17092 extracted from a file opened on the Ada side, and an Ada file
17093 can be constructed from a stream opened on the C side.
17095 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
17096 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
17097 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
17098 @cindex Null_Occurrence, testing for
17101 This child subprogram provides a way of testing for the null
17102 exception occurrence (@code{Null_Occurrence}) without raising
17105 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
17106 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
17107 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
17108 @cindex Null_Occurrence, testing for
17111 This child subprogram is used for handling otherwise unhandled
17112 exceptions (hence the name last chance), and perform clean ups before
17113 terminating the program. Note that this subprogram never returns.
17115 @node Ada.Exceptions.Traceback (a-exctra.ads)
17116 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
17117 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
17118 @cindex Traceback for Exception Occurrence
17121 This child package provides the subprogram (@code{Tracebacks}) to
17122 give a traceback array of addresses based on an exception
17125 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
17126 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
17127 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
17128 @cindex C Streams, Interfacing with Sequential_IO
17131 This package provides subprograms that allow interfacing between
17132 C streams and @code{Sequential_IO}. The stream identifier can be
17133 extracted from a file opened on the Ada side, and an Ada file
17134 can be constructed from a stream opened on the C side.
17136 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
17137 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
17138 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
17139 @cindex C Streams, Interfacing with Stream_IO
17142 This package provides subprograms that allow interfacing between
17143 C streams and @code{Stream_IO}. The stream identifier can be
17144 extracted from a file opened on the Ada side, and an Ada file
17145 can be constructed from a stream opened on the C side.
17147 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
17148 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
17149 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
17150 @cindex @code{Unbounded_String}, IO support
17151 @cindex @code{Text_IO}, extensions for unbounded strings
17154 This package provides subprograms for Text_IO for unbounded
17155 strings, avoiding the necessity for an intermediate operation
17156 with ordinary strings.
17158 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
17159 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
17160 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
17161 @cindex @code{Unbounded_Wide_String}, IO support
17162 @cindex @code{Text_IO}, extensions for unbounded wide strings
17165 This package provides subprograms for Text_IO for unbounded
17166 wide strings, avoiding the necessity for an intermediate operation
17167 with ordinary wide strings.
17169 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
17170 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
17171 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
17172 @cindex @code{Unbounded_Wide_Wide_String}, IO support
17173 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
17176 This package provides subprograms for Text_IO for unbounded
17177 wide wide strings, avoiding the necessity for an intermediate operation
17178 with ordinary wide wide strings.
17180 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
17181 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
17182 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
17183 @cindex C Streams, Interfacing with @code{Text_IO}
17186 This package provides subprograms that allow interfacing between
17187 C streams and @code{Text_IO}. The stream identifier can be
17188 extracted from a file opened on the Ada side, and an Ada file
17189 can be constructed from a stream opened on the C side.
17191 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
17192 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
17193 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
17194 @cindex @code{Text_IO} resetting standard files
17197 This procedure is used to reset the status of the standard files used
17198 by Ada.Text_IO. This is useful in a situation (such as a restart in an
17199 embedded application) where the status of the files may change during
17200 execution (for example a standard input file may be redefined to be
17203 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
17204 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
17205 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
17206 @cindex Unicode categorization, Wide_Character
17209 This package provides subprograms that allow categorization of
17210 Wide_Character values according to Unicode categories.
17212 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
17213 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
17214 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
17215 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
17218 This package provides subprograms that allow interfacing between
17219 C streams and @code{Wide_Text_IO}. The stream identifier can be
17220 extracted from a file opened on the Ada side, and an Ada file
17221 can be constructed from a stream opened on the C side.
17223 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
17224 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
17225 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
17226 @cindex @code{Wide_Text_IO} resetting standard files
17229 This procedure is used to reset the status of the standard files used
17230 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
17231 embedded application) where the status of the files may change during
17232 execution (for example a standard input file may be redefined to be
17235 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
17236 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
17237 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
17238 @cindex Unicode categorization, Wide_Wide_Character
17241 This package provides subprograms that allow categorization of
17242 Wide_Wide_Character values according to Unicode categories.
17244 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
17245 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
17246 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
17247 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
17250 This package provides subprograms that allow interfacing between
17251 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
17252 extracted from a file opened on the Ada side, and an Ada file
17253 can be constructed from a stream opened on the C side.
17255 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
17256 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
17257 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
17258 @cindex @code{Wide_Wide_Text_IO} resetting standard files
17261 This procedure is used to reset the status of the standard files used
17262 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
17263 restart in an embedded application) where the status of the files may
17264 change during execution (for example a standard input file may be
17265 redefined to be interactive).
17267 @node GNAT.Altivec (g-altive.ads)
17268 @section @code{GNAT.Altivec} (@file{g-altive.ads})
17269 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
17273 This is the root package of the GNAT AltiVec binding. It provides
17274 definitions of constants and types common to all the versions of the
17277 @node GNAT.Altivec.Conversions (g-altcon.ads)
17278 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
17279 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
17283 This package provides the Vector/View conversion routines.
17285 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
17286 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
17287 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
17291 This package exposes the Ada interface to the AltiVec operations on
17292 vector objects. A soft emulation is included by default in the GNAT
17293 library. The hard binding is provided as a separate package. This unit
17294 is common to both bindings.
17296 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
17297 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
17298 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
17302 This package exposes the various vector types part of the Ada binding
17303 to AltiVec facilities.
17305 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
17306 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
17307 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
17311 This package provides public 'View' data types from/to which private
17312 vector representations can be converted via
17313 GNAT.Altivec.Conversions. This allows convenient access to individual
17314 vector elements and provides a simple way to initialize vector
17317 @node GNAT.Array_Split (g-arrspl.ads)
17318 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
17319 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
17320 @cindex Array splitter
17323 Useful array-manipulation routines: given a set of separators, split
17324 an array wherever the separators appear, and provide direct access
17325 to the resulting slices.
17327 @node GNAT.AWK (g-awk.ads)
17328 @section @code{GNAT.AWK} (@file{g-awk.ads})
17329 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
17334 Provides AWK-like parsing functions, with an easy interface for parsing one
17335 or more files containing formatted data. The file is viewed as a database
17336 where each record is a line and a field is a data element in this line.
17338 @node GNAT.Bounded_Buffers (g-boubuf.ads)
17339 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
17340 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
17342 @cindex Bounded Buffers
17345 Provides a concurrent generic bounded buffer abstraction. Instances are
17346 useful directly or as parts of the implementations of other abstractions,
17349 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
17350 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
17351 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
17356 Provides a thread-safe asynchronous intertask mailbox communication facility.
17358 @node GNAT.Bubble_Sort (g-bubsor.ads)
17359 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
17360 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
17362 @cindex Bubble sort
17365 Provides a general implementation of bubble sort usable for sorting arbitrary
17366 data items. Exchange and comparison procedures are provided by passing
17367 access-to-procedure values.
17369 @node GNAT.Bubble_Sort_A (g-busora.ads)
17370 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
17371 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
17373 @cindex Bubble sort
17376 Provides a general implementation of bubble sort usable for sorting arbitrary
17377 data items. Move and comparison procedures are provided by passing
17378 access-to-procedure values. This is an older version, retained for
17379 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
17381 @node GNAT.Bubble_Sort_G (g-busorg.ads)
17382 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
17383 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
17385 @cindex Bubble sort
17388 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
17389 are provided as generic parameters, this improves efficiency, especially
17390 if the procedures can be inlined, at the expense of duplicating code for
17391 multiple instantiations.
17393 @node GNAT.Byte_Order_Mark (g-byorma.ads)
17394 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
17395 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
17396 @cindex UTF-8 representation
17397 @cindex Wide characte representations
17400 Provides a routine which given a string, reads the start of the string to
17401 see whether it is one of the standard byte order marks (BOM's) which signal
17402 the encoding of the string. The routine includes detection of special XML
17403 sequences for various UCS input formats.
17405 @node GNAT.Byte_Swapping (g-bytswa.ads)
17406 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
17407 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
17408 @cindex Byte swapping
17412 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
17413 Machine-specific implementations are available in some cases.
17415 @node GNAT.Calendar (g-calend.ads)
17416 @section @code{GNAT.Calendar} (@file{g-calend.ads})
17417 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
17418 @cindex @code{Calendar}
17421 Extends the facilities provided by @code{Ada.Calendar} to include handling
17422 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
17423 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
17424 C @code{timeval} format.
17426 @node GNAT.Calendar.Time_IO (g-catiio.ads)
17427 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
17428 @cindex @code{Calendar}
17430 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
17432 @node GNAT.CRC32 (g-crc32.ads)
17433 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
17434 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
17436 @cindex Cyclic Redundancy Check
17439 This package implements the CRC-32 algorithm. For a full description
17440 of this algorithm see
17441 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
17442 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
17443 Aug.@: 1988. Sarwate, D.V@.
17445 @node GNAT.Case_Util (g-casuti.ads)
17446 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
17447 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
17448 @cindex Casing utilities
17449 @cindex Character handling (@code{GNAT.Case_Util})
17452 A set of simple routines for handling upper and lower casing of strings
17453 without the overhead of the full casing tables
17454 in @code{Ada.Characters.Handling}.
17456 @node GNAT.CGI (g-cgi.ads)
17457 @section @code{GNAT.CGI} (@file{g-cgi.ads})
17458 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
17459 @cindex CGI (Common Gateway Interface)
17462 This is a package for interfacing a GNAT program with a Web server via the
17463 Common Gateway Interface (CGI)@. Basically this package parses the CGI
17464 parameters, which are a set of key/value pairs sent by the Web server. It
17465 builds a table whose index is the key and provides some services to deal
17468 @node GNAT.CGI.Cookie (g-cgicoo.ads)
17469 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
17470 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
17471 @cindex CGI (Common Gateway Interface) cookie support
17472 @cindex Cookie support in CGI
17475 This is a package to interface a GNAT program with a Web server via the
17476 Common Gateway Interface (CGI). It exports services to deal with Web
17477 cookies (piece of information kept in the Web client software).
17479 @node GNAT.CGI.Debug (g-cgideb.ads)
17480 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
17481 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
17482 @cindex CGI (Common Gateway Interface) debugging
17485 This is a package to help debugging CGI (Common Gateway Interface)
17486 programs written in Ada.
17488 @node GNAT.Command_Line (g-comlin.ads)
17489 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
17490 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
17491 @cindex Command line
17494 Provides a high level interface to @code{Ada.Command_Line} facilities,
17495 including the ability to scan for named switches with optional parameters
17496 and expand file names using wild card notations.
17498 @node GNAT.Compiler_Version (g-comver.ads)
17499 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
17500 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
17501 @cindex Compiler Version
17502 @cindex Version, of compiler
17505 Provides a routine for obtaining the version of the compiler used to
17506 compile the program. More accurately this is the version of the binder
17507 used to bind the program (this will normally be the same as the version
17508 of the compiler if a consistent tool set is used to compile all units
17511 @node GNAT.Ctrl_C (g-ctrl_c.ads)
17512 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
17513 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
17517 Provides a simple interface to handle Ctrl-C keyboard events.
17519 @node GNAT.Current_Exception (g-curexc.ads)
17520 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
17521 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
17522 @cindex Current exception
17523 @cindex Exception retrieval
17526 Provides access to information on the current exception that has been raised
17527 without the need for using the Ada 95 / Ada 2005 exception choice parameter
17528 specification syntax.
17529 This is particularly useful in simulating typical facilities for
17530 obtaining information about exceptions provided by Ada 83 compilers.
17532 @node GNAT.Debug_Pools (g-debpoo.ads)
17533 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
17534 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
17536 @cindex Debug pools
17537 @cindex Memory corruption debugging
17540 Provide a debugging storage pools that helps tracking memory corruption
17541 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
17542 @value{EDITION} User's Guide}.
17544 @node GNAT.Debug_Utilities (g-debuti.ads)
17545 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
17546 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
17550 Provides a few useful utilities for debugging purposes, including conversion
17551 to and from string images of address values. Supports both C and Ada formats
17552 for hexadecimal literals.
17554 @node GNAT.Decode_String (g-decstr.ads)
17555 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
17556 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
17557 @cindex Decoding strings
17558 @cindex String decoding
17559 @cindex Wide character encoding
17564 A generic package providing routines for decoding wide character and wide wide
17565 character strings encoded as sequences of 8-bit characters using a specified
17566 encoding method. Includes validation routines, and also routines for stepping
17567 to next or previous encoded character in an encoded string.
17568 Useful in conjunction with Unicode character coding. Note there is a
17569 preinstantiation for UTF-8. See next entry.
17571 @node GNAT.Decode_UTF8_String (g-deutst.ads)
17572 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
17573 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
17574 @cindex Decoding strings
17575 @cindex Decoding UTF-8 strings
17576 @cindex UTF-8 string decoding
17577 @cindex Wide character decoding
17582 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
17584 @node GNAT.Directory_Operations (g-dirope.ads)
17585 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
17586 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
17587 @cindex Directory operations
17590 Provides a set of routines for manipulating directories, including changing
17591 the current directory, making new directories, and scanning the files in a
17594 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
17595 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
17596 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
17597 @cindex Directory operations iteration
17600 A child unit of GNAT.Directory_Operations providing additional operations
17601 for iterating through directories.
17603 @node GNAT.Dynamic_HTables (g-dynhta.ads)
17604 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
17605 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
17606 @cindex Hash tables
17609 A generic implementation of hash tables that can be used to hash arbitrary
17610 data. Provided in two forms, a simple form with built in hash functions,
17611 and a more complex form in which the hash function is supplied.
17614 This package provides a facility similar to that of @code{GNAT.HTable},
17615 except that this package declares a type that can be used to define
17616 dynamic instances of the hash table, while an instantiation of
17617 @code{GNAT.HTable} creates a single instance of the hash table.
17619 @node GNAT.Dynamic_Tables (g-dyntab.ads)
17620 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
17621 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
17622 @cindex Table implementation
17623 @cindex Arrays, extendable
17626 A generic package providing a single dimension array abstraction where the
17627 length of the array can be dynamically modified.
17630 This package provides a facility similar to that of @code{GNAT.Table},
17631 except that this package declares a type that can be used to define
17632 dynamic instances of the table, while an instantiation of
17633 @code{GNAT.Table} creates a single instance of the table type.
17635 @node GNAT.Encode_String (g-encstr.ads)
17636 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
17637 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
17638 @cindex Encoding strings
17639 @cindex String encoding
17640 @cindex Wide character encoding
17645 A generic package providing routines for encoding wide character and wide
17646 wide character strings as sequences of 8-bit characters using a specified
17647 encoding method. Useful in conjunction with Unicode character coding.
17648 Note there is a preinstantiation for UTF-8. See next entry.
17650 @node GNAT.Encode_UTF8_String (g-enutst.ads)
17651 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
17652 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
17653 @cindex Encoding strings
17654 @cindex Encoding UTF-8 strings
17655 @cindex UTF-8 string encoding
17656 @cindex Wide character encoding
17661 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
17663 @node GNAT.Exception_Actions (g-excact.ads)
17664 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
17665 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
17666 @cindex Exception actions
17669 Provides callbacks when an exception is raised. Callbacks can be registered
17670 for specific exceptions, or when any exception is raised. This
17671 can be used for instance to force a core dump to ease debugging.
17673 @node GNAT.Exception_Traces (g-exctra.ads)
17674 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
17675 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
17676 @cindex Exception traces
17680 Provides an interface allowing to control automatic output upon exception
17683 @node GNAT.Exceptions (g-except.ads)
17684 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
17685 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
17686 @cindex Exceptions, Pure
17687 @cindex Pure packages, exceptions
17690 Normally it is not possible to raise an exception with
17691 a message from a subprogram in a pure package, since the
17692 necessary types and subprograms are in @code{Ada.Exceptions}
17693 which is not a pure unit. @code{GNAT.Exceptions} provides a
17694 facility for getting around this limitation for a few
17695 predefined exceptions, and for example allow raising
17696 @code{Constraint_Error} with a message from a pure subprogram.
17698 @node GNAT.Expect (g-expect.ads)
17699 @section @code{GNAT.Expect} (@file{g-expect.ads})
17700 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
17703 Provides a set of subprograms similar to what is available
17704 with the standard Tcl Expect tool.
17705 It allows you to easily spawn and communicate with an external process.
17706 You can send commands or inputs to the process, and compare the output
17707 with some expected regular expression. Currently @code{GNAT.Expect}
17708 is implemented on all native GNAT ports except for OpenVMS@.
17709 It is not implemented for cross ports, and in particular is not
17710 implemented for VxWorks or LynxOS@.
17712 @node GNAT.Expect.TTY (g-exptty.ads)
17713 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
17714 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
17717 As GNAT.Expect but using pseudo-terminal.
17718 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
17719 ports except for OpenVMS@. It is not implemented for cross ports, and
17720 in particular is not implemented for VxWorks or LynxOS@.
17722 @node GNAT.Float_Control (g-flocon.ads)
17723 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
17724 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
17725 @cindex Floating-Point Processor
17728 Provides an interface for resetting the floating-point processor into the
17729 mode required for correct semantic operation in Ada. Some third party
17730 library calls may cause this mode to be modified, and the Reset procedure
17731 in this package can be used to reestablish the required mode.
17733 @node GNAT.Heap_Sort (g-heasor.ads)
17734 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
17735 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
17739 Provides a general implementation of heap sort usable for sorting arbitrary
17740 data items. Exchange and comparison procedures are provided by passing
17741 access-to-procedure values. The algorithm used is a modified heap sort
17742 that performs approximately N*log(N) comparisons in the worst case.
17744 @node GNAT.Heap_Sort_A (g-hesora.ads)
17745 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
17746 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
17750 Provides a general implementation of heap sort usable for sorting arbitrary
17751 data items. Move and comparison procedures are provided by passing
17752 access-to-procedure values. The algorithm used is a modified heap sort
17753 that performs approximately N*log(N) comparisons in the worst case.
17754 This differs from @code{GNAT.Heap_Sort} in having a less convenient
17755 interface, but may be slightly more efficient.
17757 @node GNAT.Heap_Sort_G (g-hesorg.ads)
17758 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
17759 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
17763 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
17764 are provided as generic parameters, this improves efficiency, especially
17765 if the procedures can be inlined, at the expense of duplicating code for
17766 multiple instantiations.
17768 @node GNAT.HTable (g-htable.ads)
17769 @section @code{GNAT.HTable} (@file{g-htable.ads})
17770 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
17771 @cindex Hash tables
17774 A generic implementation of hash tables that can be used to hash arbitrary
17775 data. Provides two approaches, one a simple static approach, and the other
17776 allowing arbitrary dynamic hash tables.
17778 @node GNAT.IO (g-io.ads)
17779 @section @code{GNAT.IO} (@file{g-io.ads})
17780 @cindex @code{GNAT.IO} (@file{g-io.ads})
17782 @cindex Input/Output facilities
17785 A simple preelaborable input-output package that provides a subset of
17786 simple Text_IO functions for reading characters and strings from
17787 Standard_Input, and writing characters, strings and integers to either
17788 Standard_Output or Standard_Error.
17790 @node GNAT.IO_Aux (g-io_aux.ads)
17791 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
17792 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
17794 @cindex Input/Output facilities
17796 Provides some auxiliary functions for use with Text_IO, including a test
17797 for whether a file exists, and functions for reading a line of text.
17799 @node GNAT.Lock_Files (g-locfil.ads)
17800 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
17801 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
17802 @cindex File locking
17803 @cindex Locking using files
17806 Provides a general interface for using files as locks. Can be used for
17807 providing program level synchronization.
17809 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
17810 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
17811 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
17812 @cindex Random number generation
17815 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
17816 a modified version of the Blum-Blum-Shub generator.
17818 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
17819 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
17820 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
17821 @cindex Random number generation
17824 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
17825 a modified version of the Blum-Blum-Shub generator.
17827 @node GNAT.MD5 (g-md5.ads)
17828 @section @code{GNAT.MD5} (@file{g-md5.ads})
17829 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
17830 @cindex Message Digest MD5
17833 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
17835 @node GNAT.Memory_Dump (g-memdum.ads)
17836 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
17837 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
17838 @cindex Dump Memory
17841 Provides a convenient routine for dumping raw memory to either the
17842 standard output or standard error files. Uses GNAT.IO for actual
17845 @node GNAT.Most_Recent_Exception (g-moreex.ads)
17846 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
17847 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
17848 @cindex Exception, obtaining most recent
17851 Provides access to the most recently raised exception. Can be used for
17852 various logging purposes, including duplicating functionality of some
17853 Ada 83 implementation dependent extensions.
17855 @node GNAT.OS_Lib (g-os_lib.ads)
17856 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
17857 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
17858 @cindex Operating System interface
17859 @cindex Spawn capability
17862 Provides a range of target independent operating system interface functions,
17863 including time/date management, file operations, subprocess management,
17864 including a portable spawn procedure, and access to environment variables
17865 and error return codes.
17867 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
17868 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
17869 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
17870 @cindex Hash functions
17873 Provides a generator of static minimal perfect hash functions. No
17874 collisions occur and each item can be retrieved from the table in one
17875 probe (perfect property). The hash table size corresponds to the exact
17876 size of the key set and no larger (minimal property). The key set has to
17877 be know in advance (static property). The hash functions are also order
17878 preserving. If w2 is inserted after w1 in the generator, their
17879 hashcode are in the same order. These hashing functions are very
17880 convenient for use with realtime applications.
17882 @node GNAT.Random_Numbers (g-rannum.ads)
17883 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
17884 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
17885 @cindex Random number generation
17888 Provides random number capabilities which extend those available in the
17889 standard Ada library and are more convenient to use.
17891 @node GNAT.Regexp (g-regexp.ads)
17892 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
17893 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
17894 @cindex Regular expressions
17895 @cindex Pattern matching
17898 A simple implementation of regular expressions, using a subset of regular
17899 expression syntax copied from familiar Unix style utilities. This is the
17900 simples of the three pattern matching packages provided, and is particularly
17901 suitable for ``file globbing'' applications.
17903 @node GNAT.Registry (g-regist.ads)
17904 @section @code{GNAT.Registry} (@file{g-regist.ads})
17905 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
17906 @cindex Windows Registry
17909 This is a high level binding to the Windows registry. It is possible to
17910 do simple things like reading a key value, creating a new key. For full
17911 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
17912 package provided with the Win32Ada binding
17914 @node GNAT.Regpat (g-regpat.ads)
17915 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
17916 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
17917 @cindex Regular expressions
17918 @cindex Pattern matching
17921 A complete implementation of Unix-style regular expression matching, copied
17922 from the original V7 style regular expression library written in C by
17923 Henry Spencer (and binary compatible with this C library).
17925 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
17926 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
17927 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
17928 @cindex Secondary Stack Info
17931 Provide the capability to query the high water mark of the current task's
17934 @node GNAT.Semaphores (g-semaph.ads)
17935 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
17936 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
17940 Provides classic counting and binary semaphores using protected types.
17942 @node GNAT.Serial_Communications (g-sercom.ads)
17943 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
17944 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
17945 @cindex Serial_Communications
17948 Provides a simple interface to send and receive data over a serial
17949 port. This is only supported on GNU/Linux and Windows.
17951 @node GNAT.SHA1 (g-sha1.ads)
17952 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
17953 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
17954 @cindex Secure Hash Algorithm SHA-1
17957 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
17960 @node GNAT.SHA224 (g-sha224.ads)
17961 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
17962 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
17963 @cindex Secure Hash Algorithm SHA-224
17966 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
17968 @node GNAT.SHA256 (g-sha256.ads)
17969 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
17970 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
17971 @cindex Secure Hash Algorithm SHA-256
17974 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
17976 @node GNAT.SHA384 (g-sha384.ads)
17977 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
17978 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
17979 @cindex Secure Hash Algorithm SHA-384
17982 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
17984 @node GNAT.SHA512 (g-sha512.ads)
17985 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
17986 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
17987 @cindex Secure Hash Algorithm SHA-512
17990 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
17992 @node GNAT.Signals (g-signal.ads)
17993 @section @code{GNAT.Signals} (@file{g-signal.ads})
17994 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
17998 Provides the ability to manipulate the blocked status of signals on supported
18001 @node GNAT.Sockets (g-socket.ads)
18002 @section @code{GNAT.Sockets} (@file{g-socket.ads})
18003 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
18007 A high level and portable interface to develop sockets based applications.
18008 This package is based on the sockets thin binding found in
18009 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
18010 on all native GNAT ports except for OpenVMS@. It is not implemented
18011 for the LynxOS@ cross port.
18013 @node GNAT.Source_Info (g-souinf.ads)
18014 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
18015 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
18016 @cindex Source Information
18019 Provides subprograms that give access to source code information known at
18020 compile time, such as the current file name and line number.
18022 @node GNAT.Spelling_Checker (g-speche.ads)
18023 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
18024 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
18025 @cindex Spell checking
18028 Provides a function for determining whether one string is a plausible
18029 near misspelling of another string.
18031 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
18032 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
18033 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
18034 @cindex Spell checking
18037 Provides a generic function that can be instantiated with a string type for
18038 determining whether one string is a plausible near misspelling of another
18041 @node GNAT.Spitbol.Patterns (g-spipat.ads)
18042 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
18043 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
18044 @cindex SPITBOL pattern matching
18045 @cindex Pattern matching
18048 A complete implementation of SNOBOL4 style pattern matching. This is the
18049 most elaborate of the pattern matching packages provided. It fully duplicates
18050 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
18051 efficient algorithm developed by Robert Dewar for the SPITBOL system.
18053 @node GNAT.Spitbol (g-spitbo.ads)
18054 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
18055 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
18056 @cindex SPITBOL interface
18059 The top level package of the collection of SPITBOL-style functionality, this
18060 package provides basic SNOBOL4 string manipulation functions, such as
18061 Pad, Reverse, Trim, Substr capability, as well as a generic table function
18062 useful for constructing arbitrary mappings from strings in the style of
18063 the SNOBOL4 TABLE function.
18065 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
18066 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
18067 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
18068 @cindex Sets of strings
18069 @cindex SPITBOL Tables
18072 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
18073 for type @code{Standard.Boolean}, giving an implementation of sets of
18076 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
18077 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
18078 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
18079 @cindex Integer maps
18081 @cindex SPITBOL Tables
18084 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
18085 for type @code{Standard.Integer}, giving an implementation of maps
18086 from string to integer values.
18088 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
18089 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
18090 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
18091 @cindex String maps
18093 @cindex SPITBOL Tables
18096 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
18097 a variable length string type, giving an implementation of general
18098 maps from strings to strings.
18100 @node GNAT.SSE (g-sse.ads)
18101 @section @code{GNAT.SSE} (@file{g-sse.ads})
18102 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
18105 Root of a set of units aimed at offering Ada bindings to a subset of
18106 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
18107 targets. It exposes vector component types together with a general
18108 introduction to the binding contents and use.
18110 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
18111 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
18112 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
18115 SSE vector types for use with SSE related intrinsics.
18117 @node GNAT.Strings (g-string.ads)
18118 @section @code{GNAT.Strings} (@file{g-string.ads})
18119 @cindex @code{GNAT.Strings} (@file{g-string.ads})
18122 Common String access types and related subprograms. Basically it
18123 defines a string access and an array of string access types.
18125 @node GNAT.String_Split (g-strspl.ads)
18126 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
18127 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
18128 @cindex String splitter
18131 Useful string manipulation routines: given a set of separators, split
18132 a string wherever the separators appear, and provide direct access
18133 to the resulting slices. This package is instantiated from
18134 @code{GNAT.Array_Split}.
18136 @node GNAT.Table (g-table.ads)
18137 @section @code{GNAT.Table} (@file{g-table.ads})
18138 @cindex @code{GNAT.Table} (@file{g-table.ads})
18139 @cindex Table implementation
18140 @cindex Arrays, extendable
18143 A generic package providing a single dimension array abstraction where the
18144 length of the array can be dynamically modified.
18147 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
18148 except that this package declares a single instance of the table type,
18149 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
18150 used to define dynamic instances of the table.
18152 @node GNAT.Task_Lock (g-tasloc.ads)
18153 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
18154 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
18155 @cindex Task synchronization
18156 @cindex Task locking
18160 A very simple facility for locking and unlocking sections of code using a
18161 single global task lock. Appropriate for use in situations where contention
18162 between tasks is very rarely expected.
18164 @node GNAT.Time_Stamp (g-timsta.ads)
18165 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
18166 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
18168 @cindex Current time
18171 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
18172 represents the current date and time in ISO 8601 format. This is a very simple
18173 routine with minimal code and there are no dependencies on any other unit.
18175 @node GNAT.Threads (g-thread.ads)
18176 @section @code{GNAT.Threads} (@file{g-thread.ads})
18177 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
18178 @cindex Foreign threads
18179 @cindex Threads, foreign
18182 Provides facilities for dealing with foreign threads which need to be known
18183 by the GNAT run-time system. Consult the documentation of this package for
18184 further details if your program has threads that are created by a non-Ada
18185 environment which then accesses Ada code.
18187 @node GNAT.Traceback (g-traceb.ads)
18188 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
18189 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
18190 @cindex Trace back facilities
18193 Provides a facility for obtaining non-symbolic traceback information, useful
18194 in various debugging situations.
18196 @node GNAT.Traceback.Symbolic (g-trasym.ads)
18197 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
18198 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
18199 @cindex Trace back facilities
18201 @node GNAT.UTF_32 (g-utf_32.ads)
18202 @section @code{GNAT.UTF_32} (@file{g-table.ads})
18203 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
18204 @cindex Wide character codes
18207 This is a package intended to be used in conjunction with the
18208 @code{Wide_Character} type in Ada 95 and the
18209 @code{Wide_Wide_Character} type in Ada 2005 (available
18210 in @code{GNAT} in Ada 2005 mode). This package contains
18211 Unicode categorization routines, as well as lexical
18212 categorization routines corresponding to the Ada 2005
18213 lexical rules for identifiers and strings, and also a
18214 lower case to upper case fold routine corresponding to
18215 the Ada 2005 rules for identifier equivalence.
18217 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
18218 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
18219 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
18220 @cindex Spell checking
18223 Provides a function for determining whether one wide wide string is a plausible
18224 near misspelling of another wide wide string, where the strings are represented
18225 using the UTF_32_String type defined in System.Wch_Cnv.
18227 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
18228 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
18229 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
18230 @cindex Spell checking
18233 Provides a function for determining whether one wide string is a plausible
18234 near misspelling of another wide string.
18236 @node GNAT.Wide_String_Split (g-wistsp.ads)
18237 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
18238 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
18239 @cindex Wide_String splitter
18242 Useful wide string manipulation routines: given a set of separators, split
18243 a wide string wherever the separators appear, and provide direct access
18244 to the resulting slices. This package is instantiated from
18245 @code{GNAT.Array_Split}.
18247 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
18248 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
18249 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
18250 @cindex Spell checking
18253 Provides a function for determining whether one wide wide string is a plausible
18254 near misspelling of another wide wide string.
18256 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
18257 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
18258 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
18259 @cindex Wide_Wide_String splitter
18262 Useful wide wide string manipulation routines: given a set of separators, split
18263 a wide wide string wherever the separators appear, and provide direct access
18264 to the resulting slices. This package is instantiated from
18265 @code{GNAT.Array_Split}.
18267 @node Interfaces.C.Extensions (i-cexten.ads)
18268 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
18269 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
18272 This package contains additional C-related definitions, intended
18273 for use with either manually or automatically generated bindings
18276 @node Interfaces.C.Streams (i-cstrea.ads)
18277 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
18278 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
18279 @cindex C streams, interfacing
18282 This package is a binding for the most commonly used operations
18285 @node Interfaces.CPP (i-cpp.ads)
18286 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
18287 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
18288 @cindex C++ interfacing
18289 @cindex Interfacing, to C++
18292 This package provides facilities for use in interfacing to C++. It
18293 is primarily intended to be used in connection with automated tools
18294 for the generation of C++ interfaces.
18296 @node Interfaces.Packed_Decimal (i-pacdec.ads)
18297 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
18298 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
18299 @cindex IBM Packed Format
18300 @cindex Packed Decimal
18303 This package provides a set of routines for conversions to and
18304 from a packed decimal format compatible with that used on IBM
18307 @node Interfaces.VxWorks (i-vxwork.ads)
18308 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
18309 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
18310 @cindex Interfacing to VxWorks
18311 @cindex VxWorks, interfacing
18314 This package provides a limited binding to the VxWorks API.
18315 In particular, it interfaces with the
18316 VxWorks hardware interrupt facilities.
18318 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
18319 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
18320 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
18321 @cindex Interfacing to VxWorks' I/O
18322 @cindex VxWorks, I/O interfacing
18323 @cindex VxWorks, Get_Immediate
18324 @cindex Get_Immediate, VxWorks
18327 This package provides a binding to the ioctl (IO/Control)
18328 function of VxWorks, defining a set of option values and
18329 function codes. A particular use of this package is
18330 to enable the use of Get_Immediate under VxWorks.
18332 @node System.Address_Image (s-addima.ads)
18333 @section @code{System.Address_Image} (@file{s-addima.ads})
18334 @cindex @code{System.Address_Image} (@file{s-addima.ads})
18335 @cindex Address image
18336 @cindex Image, of an address
18339 This function provides a useful debugging
18340 function that gives an (implementation dependent)
18341 string which identifies an address.
18343 @node System.Assertions (s-assert.ads)
18344 @section @code{System.Assertions} (@file{s-assert.ads})
18345 @cindex @code{System.Assertions} (@file{s-assert.ads})
18347 @cindex Assert_Failure, exception
18350 This package provides the declaration of the exception raised
18351 by an run-time assertion failure, as well as the routine that
18352 is used internally to raise this assertion.
18354 @node System.Memory (s-memory.ads)
18355 @section @code{System.Memory} (@file{s-memory.ads})
18356 @cindex @code{System.Memory} (@file{s-memory.ads})
18357 @cindex Memory allocation
18360 This package provides the interface to the low level routines used
18361 by the generated code for allocation and freeing storage for the
18362 default storage pool (analogous to the C routines malloc and free.
18363 It also provides a reallocation interface analogous to the C routine
18364 realloc. The body of this unit may be modified to provide alternative
18365 allocation mechanisms for the default pool, and in addition, direct
18366 calls to this unit may be made for low level allocation uses (for
18367 example see the body of @code{GNAT.Tables}).
18369 @node System.Multiprocessors (s-multip.ads)
18370 @section @code{System.Multiprocessors} (@file{s-multip.ads})
18371 @cindex @code{System.Multiprocessors} (@file{s-multip.ads})
18372 @cindex Multiprocessor interface
18373 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
18374 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
18375 technically an implementation-defined addition).
18377 @node System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
18378 @section @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
18379 @cindex @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
18380 @cindex Multiprocessor interface
18381 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
18382 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
18383 technically an implementation-defined addition).
18385 @node System.Partition_Interface (s-parint.ads)
18386 @section @code{System.Partition_Interface} (@file{s-parint.ads})
18387 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
18388 @cindex Partition interfacing functions
18391 This package provides facilities for partition interfacing. It
18392 is used primarily in a distribution context when using Annex E
18395 @node System.Pool_Global (s-pooglo.ads)
18396 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
18397 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
18398 @cindex Storage pool, global
18399 @cindex Global storage pool
18402 This package provides a storage pool that is equivalent to the default
18403 storage pool used for access types for which no pool is specifically
18404 declared. It uses malloc/free to allocate/free and does not attempt to
18405 do any automatic reclamation.
18407 @node System.Pool_Local (s-pooloc.ads)
18408 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
18409 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
18410 @cindex Storage pool, local
18411 @cindex Local storage pool
18414 This package provides a storage pool that is intended for use with locally
18415 defined access types. It uses malloc/free for allocate/free, and maintains
18416 a list of allocated blocks, so that all storage allocated for the pool can
18417 be freed automatically when the pool is finalized.
18419 @node System.Restrictions (s-restri.ads)
18420 @section @code{System.Restrictions} (@file{s-restri.ads})
18421 @cindex @code{System.Restrictions} (@file{s-restri.ads})
18422 @cindex Run-time restrictions access
18425 This package provides facilities for accessing at run time
18426 the status of restrictions specified at compile time for
18427 the partition. Information is available both with regard
18428 to actual restrictions specified, and with regard to
18429 compiler determined information on which restrictions
18430 are violated by one or more packages in the partition.
18432 @node System.Rident (s-rident.ads)
18433 @section @code{System.Rident} (@file{s-rident.ads})
18434 @cindex @code{System.Rident} (@file{s-rident.ads})
18435 @cindex Restrictions definitions
18438 This package provides definitions of the restrictions
18439 identifiers supported by GNAT, and also the format of
18440 the restrictions provided in package System.Restrictions.
18441 It is not normally necessary to @code{with} this generic package
18442 since the necessary instantiation is included in
18443 package System.Restrictions.
18445 @node System.Strings.Stream_Ops (s-ststop.ads)
18446 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
18447 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
18448 @cindex Stream operations
18449 @cindex String stream operations
18452 This package provides a set of stream subprograms for standard string types.
18453 It is intended primarily to support implicit use of such subprograms when
18454 stream attributes are applied to string types, but the subprograms in this
18455 package can be used directly by application programs.
18457 @node System.Task_Info (s-tasinf.ads)
18458 @section @code{System.Task_Info} (@file{s-tasinf.ads})
18459 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
18460 @cindex Task_Info pragma
18463 This package provides target dependent functionality that is used
18464 to support the @code{Task_Info} pragma
18466 @node System.Wch_Cnv (s-wchcnv.ads)
18467 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
18468 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
18469 @cindex Wide Character, Representation
18470 @cindex Wide String, Conversion
18471 @cindex Representation of wide characters
18474 This package provides routines for converting between
18475 wide and wide wide characters and a representation as a value of type
18476 @code{Standard.String}, using a specified wide character
18477 encoding method. It uses definitions in
18478 package @code{System.Wch_Con}.
18480 @node System.Wch_Con (s-wchcon.ads)
18481 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
18482 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
18485 This package provides definitions and descriptions of
18486 the various methods used for encoding wide characters
18487 in ordinary strings. These definitions are used by
18488 the package @code{System.Wch_Cnv}.
18490 @node Interfacing to Other Languages
18491 @chapter Interfacing to Other Languages
18493 The facilities in annex B of the Ada Reference Manual are fully
18494 implemented in GNAT, and in addition, a full interface to C++ is
18498 * Interfacing to C::
18499 * Interfacing to C++::
18500 * Interfacing to COBOL::
18501 * Interfacing to Fortran::
18502 * Interfacing to non-GNAT Ada code::
18505 @node Interfacing to C
18506 @section Interfacing to C
18509 Interfacing to C with GNAT can use one of two approaches:
18513 The types in the package @code{Interfaces.C} may be used.
18515 Standard Ada types may be used directly. This may be less portable to
18516 other compilers, but will work on all GNAT compilers, which guarantee
18517 correspondence between the C and Ada types.
18521 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
18522 effect, since this is the default. The following table shows the
18523 correspondence between Ada scalar types and the corresponding C types.
18528 @item Short_Integer
18530 @item Short_Short_Integer
18534 @item Long_Long_Integer
18542 @item Long_Long_Float
18543 This is the longest floating-point type supported by the hardware.
18547 Additionally, there are the following general correspondences between Ada
18551 Ada enumeration types map to C enumeration types directly if pragma
18552 @code{Convention C} is specified, which causes them to have int
18553 length. Without pragma @code{Convention C}, Ada enumeration types map to
18554 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
18555 @code{int}, respectively) depending on the number of values passed.
18556 This is the only case in which pragma @code{Convention C} affects the
18557 representation of an Ada type.
18560 Ada access types map to C pointers, except for the case of pointers to
18561 unconstrained types in Ada, which have no direct C equivalent.
18564 Ada arrays map directly to C arrays.
18567 Ada records map directly to C structures.
18570 Packed Ada records map to C structures where all members are bit fields
18571 of the length corresponding to the @code{@var{type}'Size} value in Ada.
18574 @node Interfacing to C++
18575 @section Interfacing to C++
18578 The interface to C++ makes use of the following pragmas, which are
18579 primarily intended to be constructed automatically using a binding generator
18580 tool, although it is possible to construct them by hand.
18582 Using these pragmas it is possible to achieve complete
18583 inter-operability between Ada tagged types and C++ class definitions.
18584 See @ref{Implementation Defined Pragmas}, for more details.
18587 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
18588 The argument denotes an entity in the current declarative region that is
18589 declared as a tagged or untagged record type. It indicates that the type
18590 corresponds to an externally declared C++ class type, and is to be laid
18591 out the same way that C++ would lay out the type.
18593 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
18594 for backward compatibility but its functionality is available
18595 using pragma @code{Import} with @code{Convention} = @code{CPP}.
18597 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
18598 This pragma identifies an imported function (imported in the usual way
18599 with pragma @code{Import}) as corresponding to a C++ constructor.
18602 A few restrictions are placed on the use of the @code{Access} attribute
18603 in conjunction with subprograms subject to convention @code{CPP}: the
18604 attribute may be used neither on primitive operations of a tagged
18605 record type with convention @code{CPP}, imported or not, nor on
18606 subprograms imported with pragma @code{CPP_Constructor}.
18608 In addition, C++ exceptions are propagated and can be handled in an
18609 @code{others} choice of an exception handler. The corresponding Ada
18610 occurrence has no message, and the simple name of the exception identity
18611 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
18612 tasks works properly when such foreign exceptions are propagated.
18614 @node Interfacing to COBOL
18615 @section Interfacing to COBOL
18618 Interfacing to COBOL is achieved as described in section B.4 of
18619 the Ada Reference Manual.
18621 @node Interfacing to Fortran
18622 @section Interfacing to Fortran
18625 Interfacing to Fortran is achieved as described in section B.5 of the
18626 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
18627 multi-dimensional array causes the array to be stored in column-major
18628 order as required for convenient interface to Fortran.
18630 @node Interfacing to non-GNAT Ada code
18631 @section Interfacing to non-GNAT Ada code
18633 It is possible to specify the convention @code{Ada} in a pragma
18634 @code{Import} or pragma @code{Export}. However this refers to
18635 the calling conventions used by GNAT, which may or may not be
18636 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
18637 compiler to allow interoperation.
18639 If arguments types are kept simple, and if the foreign compiler generally
18640 follows system calling conventions, then it may be possible to integrate
18641 files compiled by other Ada compilers, provided that the elaboration
18642 issues are adequately addressed (for example by eliminating the
18643 need for any load time elaboration).
18645 In particular, GNAT running on VMS is designed to
18646 be highly compatible with the DEC Ada 83 compiler, so this is one
18647 case in which it is possible to import foreign units of this type,
18648 provided that the data items passed are restricted to simple scalar
18649 values or simple record types without variants, or simple array
18650 types with fixed bounds.
18652 @node Specialized Needs Annexes
18653 @chapter Specialized Needs Annexes
18656 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
18657 required in all implementations. However, as described in this chapter,
18658 GNAT implements all of these annexes:
18661 @item Systems Programming (Annex C)
18662 The Systems Programming Annex is fully implemented.
18664 @item Real-Time Systems (Annex D)
18665 The Real-Time Systems Annex is fully implemented.
18667 @item Distributed Systems (Annex E)
18668 Stub generation is fully implemented in the GNAT compiler. In addition,
18669 a complete compatible PCS is available as part of the GLADE system,
18670 a separate product. When the two
18671 products are used in conjunction, this annex is fully implemented.
18673 @item Information Systems (Annex F)
18674 The Information Systems annex is fully implemented.
18676 @item Numerics (Annex G)
18677 The Numerics Annex is fully implemented.
18679 @item Safety and Security / High-Integrity Systems (Annex H)
18680 The Safety and Security Annex (termed the High-Integrity Systems Annex
18681 in Ada 2005) is fully implemented.
18684 @node Implementation of Specific Ada Features
18685 @chapter Implementation of Specific Ada Features
18688 This chapter describes the GNAT implementation of several Ada language
18692 * Machine Code Insertions::
18693 * GNAT Implementation of Tasking::
18694 * GNAT Implementation of Shared Passive Packages::
18695 * Code Generation for Array Aggregates::
18696 * The Size of Discriminated Records with Default Discriminants::
18697 * Strict Conformance to the Ada Reference Manual::
18700 @node Machine Code Insertions
18701 @section Machine Code Insertions
18702 @cindex Machine Code insertions
18705 Package @code{Machine_Code} provides machine code support as described
18706 in the Ada Reference Manual in two separate forms:
18709 Machine code statements, consisting of qualified expressions that
18710 fit the requirements of RM section 13.8.
18712 An intrinsic callable procedure, providing an alternative mechanism of
18713 including machine instructions in a subprogram.
18717 The two features are similar, and both are closely related to the mechanism
18718 provided by the asm instruction in the GNU C compiler. Full understanding
18719 and use of the facilities in this package requires understanding the asm
18720 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
18721 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
18723 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
18724 semantic restrictions and effects as described below. Both are provided so
18725 that the procedure call can be used as a statement, and the function call
18726 can be used to form a code_statement.
18728 The first example given in the GCC documentation is the C @code{asm}
18731 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
18735 The equivalent can be written for GNAT as:
18737 @smallexample @c ada
18738 Asm ("fsinx %1 %0",
18739 My_Float'Asm_Output ("=f", result),
18740 My_Float'Asm_Input ("f", angle));
18744 The first argument to @code{Asm} is the assembler template, and is
18745 identical to what is used in GNU C@. This string must be a static
18746 expression. The second argument is the output operand list. It is
18747 either a single @code{Asm_Output} attribute reference, or a list of such
18748 references enclosed in parentheses (technically an array aggregate of
18751 The @code{Asm_Output} attribute denotes a function that takes two
18752 parameters. The first is a string, the second is the name of a variable
18753 of the type designated by the attribute prefix. The first (string)
18754 argument is required to be a static expression and designates the
18755 constraint for the parameter (e.g.@: what kind of register is
18756 required). The second argument is the variable to be updated with the
18757 result. The possible values for constraint are the same as those used in
18758 the RTL, and are dependent on the configuration file used to build the
18759 GCC back end. If there are no output operands, then this argument may
18760 either be omitted, or explicitly given as @code{No_Output_Operands}.
18762 The second argument of @code{@var{my_float}'Asm_Output} functions as
18763 though it were an @code{out} parameter, which is a little curious, but
18764 all names have the form of expressions, so there is no syntactic
18765 irregularity, even though normally functions would not be permitted
18766 @code{out} parameters. The third argument is the list of input
18767 operands. It is either a single @code{Asm_Input} attribute reference, or
18768 a list of such references enclosed in parentheses (technically an array
18769 aggregate of such references).
18771 The @code{Asm_Input} attribute denotes a function that takes two
18772 parameters. The first is a string, the second is an expression of the
18773 type designated by the prefix. The first (string) argument is required
18774 to be a static expression, and is the constraint for the parameter,
18775 (e.g.@: what kind of register is required). The second argument is the
18776 value to be used as the input argument. The possible values for the
18777 constant are the same as those used in the RTL, and are dependent on
18778 the configuration file used to built the GCC back end.
18780 If there are no input operands, this argument may either be omitted, or
18781 explicitly given as @code{No_Input_Operands}. The fourth argument, not
18782 present in the above example, is a list of register names, called the
18783 @dfn{clobber} argument. This argument, if given, must be a static string
18784 expression, and is a space or comma separated list of names of registers
18785 that must be considered destroyed as a result of the @code{Asm} call. If
18786 this argument is the null string (the default value), then the code
18787 generator assumes that no additional registers are destroyed.
18789 The fifth argument, not present in the above example, called the
18790 @dfn{volatile} argument, is by default @code{False}. It can be set to
18791 the literal value @code{True} to indicate to the code generator that all
18792 optimizations with respect to the instruction specified should be
18793 suppressed, and that in particular, for an instruction that has outputs,
18794 the instruction will still be generated, even if none of the outputs are
18795 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
18796 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
18797 Generally it is strongly advisable to use Volatile for any ASM statement
18798 that is missing either input or output operands, or when two or more ASM
18799 statements appear in sequence, to avoid unwanted optimizations. A warning
18800 is generated if this advice is not followed.
18802 The @code{Asm} subprograms may be used in two ways. First the procedure
18803 forms can be used anywhere a procedure call would be valid, and
18804 correspond to what the RM calls ``intrinsic'' routines. Such calls can
18805 be used to intersperse machine instructions with other Ada statements.
18806 Second, the function forms, which return a dummy value of the limited
18807 private type @code{Asm_Insn}, can be used in code statements, and indeed
18808 this is the only context where such calls are allowed. Code statements
18809 appear as aggregates of the form:
18811 @smallexample @c ada
18812 Asm_Insn'(Asm (@dots{}));
18813 Asm_Insn'(Asm_Volatile (@dots{}));
18817 In accordance with RM rules, such code statements are allowed only
18818 within subprograms whose entire body consists of such statements. It is
18819 not permissible to intermix such statements with other Ada statements.
18821 Typically the form using intrinsic procedure calls is more convenient
18822 and more flexible. The code statement form is provided to meet the RM
18823 suggestion that such a facility should be made available. The following
18824 is the exact syntax of the call to @code{Asm}. As usual, if named notation
18825 is used, the arguments may be given in arbitrary order, following the
18826 normal rules for use of positional and named arguments)
18830 [Template =>] static_string_EXPRESSION
18831 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
18832 [,[Inputs =>] INPUT_OPERAND_LIST ]
18833 [,[Clobber =>] static_string_EXPRESSION ]
18834 [,[Volatile =>] static_boolean_EXPRESSION] )
18836 OUTPUT_OPERAND_LIST ::=
18837 [PREFIX.]No_Output_Operands
18838 | OUTPUT_OPERAND_ATTRIBUTE
18839 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
18841 OUTPUT_OPERAND_ATTRIBUTE ::=
18842 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
18844 INPUT_OPERAND_LIST ::=
18845 [PREFIX.]No_Input_Operands
18846 | INPUT_OPERAND_ATTRIBUTE
18847 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
18849 INPUT_OPERAND_ATTRIBUTE ::=
18850 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
18854 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
18855 are declared in the package @code{Machine_Code} and must be referenced
18856 according to normal visibility rules. In particular if there is no
18857 @code{use} clause for this package, then appropriate package name
18858 qualification is required.
18860 @node GNAT Implementation of Tasking
18861 @section GNAT Implementation of Tasking
18864 This chapter outlines the basic GNAT approach to tasking (in particular,
18865 a multi-layered library for portability) and discusses issues related
18866 to compliance with the Real-Time Systems Annex.
18869 * Mapping Ada Tasks onto the Underlying Kernel Threads::
18870 * Ensuring Compliance with the Real-Time Annex::
18873 @node Mapping Ada Tasks onto the Underlying Kernel Threads
18874 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
18877 GNAT's run-time support comprises two layers:
18880 @item GNARL (GNAT Run-time Layer)
18881 @item GNULL (GNAT Low-level Library)
18885 In GNAT, Ada's tasking services rely on a platform and OS independent
18886 layer known as GNARL@. This code is responsible for implementing the
18887 correct semantics of Ada's task creation, rendezvous, protected
18890 GNARL decomposes Ada's tasking semantics into simpler lower level
18891 operations such as create a thread, set the priority of a thread,
18892 yield, create a lock, lock/unlock, etc. The spec for these low-level
18893 operations constitutes GNULLI, the GNULL Interface. This interface is
18894 directly inspired from the POSIX real-time API@.
18896 If the underlying executive or OS implements the POSIX standard
18897 faithfully, the GNULL Interface maps as is to the services offered by
18898 the underlying kernel. Otherwise, some target dependent glue code maps
18899 the services offered by the underlying kernel to the semantics expected
18902 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
18903 key point is that each Ada task is mapped on a thread in the underlying
18904 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
18906 In addition Ada task priorities map onto the underlying thread priorities.
18907 Mapping Ada tasks onto the underlying kernel threads has several advantages:
18911 The underlying scheduler is used to schedule the Ada tasks. This
18912 makes Ada tasks as efficient as kernel threads from a scheduling
18916 Interaction with code written in C containing threads is eased
18917 since at the lowest level Ada tasks and C threads map onto the same
18918 underlying kernel concept.
18921 When an Ada task is blocked during I/O the remaining Ada tasks are
18925 On multiprocessor systems Ada tasks can execute in parallel.
18929 Some threads libraries offer a mechanism to fork a new process, with the
18930 child process duplicating the threads from the parent.
18932 support this functionality when the parent contains more than one task.
18933 @cindex Forking a new process
18935 @node Ensuring Compliance with the Real-Time Annex
18936 @subsection Ensuring Compliance with the Real-Time Annex
18937 @cindex Real-Time Systems Annex compliance
18940 Although mapping Ada tasks onto
18941 the underlying threads has significant advantages, it does create some
18942 complications when it comes to respecting the scheduling semantics
18943 specified in the real-time annex (Annex D).
18945 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
18946 scheduling policy states:
18949 @emph{When the active priority of a ready task that is not running
18950 changes, or the setting of its base priority takes effect, the
18951 task is removed from the ready queue for its old active priority
18952 and is added at the tail of the ready queue for its new active
18953 priority, except in the case where the active priority is lowered
18954 due to the loss of inherited priority, in which case the task is
18955 added at the head of the ready queue for its new active priority.}
18959 While most kernels do put tasks at the end of the priority queue when
18960 a task changes its priority, (which respects the main
18961 FIFO_Within_Priorities requirement), almost none keep a thread at the
18962 beginning of its priority queue when its priority drops from the loss
18963 of inherited priority.
18965 As a result most vendors have provided incomplete Annex D implementations.
18967 The GNAT run-time, has a nice cooperative solution to this problem
18968 which ensures that accurate FIFO_Within_Priorities semantics are
18971 The principle is as follows. When an Ada task T is about to start
18972 running, it checks whether some other Ada task R with the same
18973 priority as T has been suspended due to the loss of priority
18974 inheritance. If this is the case, T yields and is placed at the end of
18975 its priority queue. When R arrives at the front of the queue it
18978 Note that this simple scheme preserves the relative order of the tasks
18979 that were ready to execute in the priority queue where R has been
18982 @node GNAT Implementation of Shared Passive Packages
18983 @section GNAT Implementation of Shared Passive Packages
18984 @cindex Shared passive packages
18987 GNAT fully implements the pragma @code{Shared_Passive} for
18988 @cindex pragma @code{Shared_Passive}
18989 the purpose of designating shared passive packages.
18990 This allows the use of passive partitions in the
18991 context described in the Ada Reference Manual; i.e., for communication
18992 between separate partitions of a distributed application using the
18993 features in Annex E.
18995 @cindex Distribution Systems Annex
18997 However, the implementation approach used by GNAT provides for more
18998 extensive usage as follows:
19001 @item Communication between separate programs
19003 This allows separate programs to access the data in passive
19004 partitions, using protected objects for synchronization where
19005 needed. The only requirement is that the two programs have a
19006 common shared file system. It is even possible for programs
19007 running on different machines with different architectures
19008 (e.g.@: different endianness) to communicate via the data in
19009 a passive partition.
19011 @item Persistence between program runs
19013 The data in a passive package can persist from one run of a
19014 program to another, so that a later program sees the final
19015 values stored by a previous run of the same program.
19020 The implementation approach used is to store the data in files. A
19021 separate stream file is created for each object in the package, and
19022 an access to an object causes the corresponding file to be read or
19025 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
19026 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
19027 set to the directory to be used for these files.
19028 The files in this directory
19029 have names that correspond to their fully qualified names. For
19030 example, if we have the package
19032 @smallexample @c ada
19034 pragma Shared_Passive (X);
19041 and the environment variable is set to @code{/stemp/}, then the files created
19042 will have the names:
19050 These files are created when a value is initially written to the object, and
19051 the files are retained until manually deleted. This provides the persistence
19052 semantics. If no file exists, it means that no partition has assigned a value
19053 to the variable; in this case the initial value declared in the package
19054 will be used. This model ensures that there are no issues in synchronizing
19055 the elaboration process, since elaboration of passive packages elaborates the
19056 initial values, but does not create the files.
19058 The files are written using normal @code{Stream_IO} access.
19059 If you want to be able
19060 to communicate between programs or partitions running on different
19061 architectures, then you should use the XDR versions of the stream attribute
19062 routines, since these are architecture independent.
19064 If active synchronization is required for access to the variables in the
19065 shared passive package, then as described in the Ada Reference Manual, the
19066 package may contain protected objects used for this purpose. In this case
19067 a lock file (whose name is @file{___lock} (three underscores)
19068 is created in the shared memory directory.
19069 @cindex @file{___lock} file (for shared passive packages)
19070 This is used to provide the required locking
19071 semantics for proper protected object synchronization.
19073 As of January 2003, GNAT supports shared passive packages on all platforms
19074 except for OpenVMS.
19076 @node Code Generation for Array Aggregates
19077 @section Code Generation for Array Aggregates
19080 * Static constant aggregates with static bounds::
19081 * Constant aggregates with unconstrained nominal types::
19082 * Aggregates with static bounds::
19083 * Aggregates with non-static bounds::
19084 * Aggregates in assignment statements::
19088 Aggregates have a rich syntax and allow the user to specify the values of
19089 complex data structures by means of a single construct. As a result, the
19090 code generated for aggregates can be quite complex and involve loops, case
19091 statements and multiple assignments. In the simplest cases, however, the
19092 compiler will recognize aggregates whose components and constraints are
19093 fully static, and in those cases the compiler will generate little or no
19094 executable code. The following is an outline of the code that GNAT generates
19095 for various aggregate constructs. For further details, you will find it
19096 useful to examine the output produced by the -gnatG flag to see the expanded
19097 source that is input to the code generator. You may also want to examine
19098 the assembly code generated at various levels of optimization.
19100 The code generated for aggregates depends on the context, the component values,
19101 and the type. In the context of an object declaration the code generated is
19102 generally simpler than in the case of an assignment. As a general rule, static
19103 component values and static subtypes also lead to simpler code.
19105 @node Static constant aggregates with static bounds
19106 @subsection Static constant aggregates with static bounds
19109 For the declarations:
19110 @smallexample @c ada
19111 type One_Dim is array (1..10) of integer;
19112 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
19116 GNAT generates no executable code: the constant ar0 is placed in static memory.
19117 The same is true for constant aggregates with named associations:
19119 @smallexample @c ada
19120 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
19121 Cr3 : constant One_Dim := (others => 7777);
19125 The same is true for multidimensional constant arrays such as:
19127 @smallexample @c ada
19128 type two_dim is array (1..3, 1..3) of integer;
19129 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
19133 The same is true for arrays of one-dimensional arrays: the following are
19136 @smallexample @c ada
19137 type ar1b is array (1..3) of boolean;
19138 type ar_ar is array (1..3) of ar1b;
19139 None : constant ar1b := (others => false); -- fully static
19140 None2 : constant ar_ar := (1..3 => None); -- fully static
19144 However, for multidimensional aggregates with named associations, GNAT will
19145 generate assignments and loops, even if all associations are static. The
19146 following two declarations generate a loop for the first dimension, and
19147 individual component assignments for the second dimension:
19149 @smallexample @c ada
19150 Zero1: constant two_dim := (1..3 => (1..3 => 0));
19151 Zero2: constant two_dim := (others => (others => 0));
19154 @node Constant aggregates with unconstrained nominal types
19155 @subsection Constant aggregates with unconstrained nominal types
19158 In such cases the aggregate itself establishes the subtype, so that
19159 associations with @code{others} cannot be used. GNAT determines the
19160 bounds for the actual subtype of the aggregate, and allocates the
19161 aggregate statically as well. No code is generated for the following:
19163 @smallexample @c ada
19164 type One_Unc is array (natural range <>) of integer;
19165 Cr_Unc : constant One_Unc := (12,24,36);
19168 @node Aggregates with static bounds
19169 @subsection Aggregates with static bounds
19172 In all previous examples the aggregate was the initial (and immutable) value
19173 of a constant. If the aggregate initializes a variable, then code is generated
19174 for it as a combination of individual assignments and loops over the target
19175 object. The declarations
19177 @smallexample @c ada
19178 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
19179 Cr_Var2 : One_Dim := (others > -1);
19183 generate the equivalent of
19185 @smallexample @c ada
19191 for I in Cr_Var2'range loop
19196 @node Aggregates with non-static bounds
19197 @subsection Aggregates with non-static bounds
19200 If the bounds of the aggregate are not statically compatible with the bounds
19201 of the nominal subtype of the target, then constraint checks have to be
19202 generated on the bounds. For a multidimensional array, constraint checks may
19203 have to be applied to sub-arrays individually, if they do not have statically
19204 compatible subtypes.
19206 @node Aggregates in assignment statements
19207 @subsection Aggregates in assignment statements
19210 In general, aggregate assignment requires the construction of a temporary,
19211 and a copy from the temporary to the target of the assignment. This is because
19212 it is not always possible to convert the assignment into a series of individual
19213 component assignments. For example, consider the simple case:
19215 @smallexample @c ada
19220 This cannot be converted into:
19222 @smallexample @c ada
19228 So the aggregate has to be built first in a separate location, and then
19229 copied into the target. GNAT recognizes simple cases where this intermediate
19230 step is not required, and the assignments can be performed in place, directly
19231 into the target. The following sufficient criteria are applied:
19235 The bounds of the aggregate are static, and the associations are static.
19237 The components of the aggregate are static constants, names of
19238 simple variables that are not renamings, or expressions not involving
19239 indexed components whose operands obey these rules.
19243 If any of these conditions are violated, the aggregate will be built in
19244 a temporary (created either by the front-end or the code generator) and then
19245 that temporary will be copied onto the target.
19247 @node The Size of Discriminated Records with Default Discriminants
19248 @section The Size of Discriminated Records with Default Discriminants
19251 If a discriminated type @code{T} has discriminants with default values, it is
19252 possible to declare an object of this type without providing an explicit
19255 @smallexample @c ada
19257 type Size is range 1..100;
19259 type Rec (D : Size := 15) is record
19260 Name : String (1..D);
19268 Such an object is said to be @emph{unconstrained}.
19269 The discriminant of the object
19270 can be modified by a full assignment to the object, as long as it preserves the
19271 relation between the value of the discriminant, and the value of the components
19274 @smallexample @c ada
19276 Word := (3, "yes");
19278 Word := (5, "maybe");
19280 Word := (5, "no"); -- raises Constraint_Error
19285 In order to support this behavior efficiently, an unconstrained object is
19286 given the maximum size that any value of the type requires. In the case
19287 above, @code{Word} has storage for the discriminant and for
19288 a @code{String} of length 100.
19289 It is important to note that unconstrained objects do not require dynamic
19290 allocation. It would be an improper implementation to place on the heap those
19291 components whose size depends on discriminants. (This improper implementation
19292 was used by some Ada83 compilers, where the @code{Name} component above
19294 been stored as a pointer to a dynamic string). Following the principle that
19295 dynamic storage management should never be introduced implicitly,
19296 an Ada compiler should reserve the full size for an unconstrained declared
19297 object, and place it on the stack.
19299 This maximum size approach
19300 has been a source of surprise to some users, who expect the default
19301 values of the discriminants to determine the size reserved for an
19302 unconstrained object: ``If the default is 15, why should the object occupy
19304 The answer, of course, is that the discriminant may be later modified,
19305 and its full range of values must be taken into account. This is why the
19310 type Rec (D : Positive := 15) is record
19311 Name : String (1..D);
19319 is flagged by the compiler with a warning:
19320 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
19321 because the required size includes @code{Positive'Last}
19322 bytes. As the first example indicates, the proper approach is to declare an
19323 index type of ``reasonable'' range so that unconstrained objects are not too
19326 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
19327 created in the heap by means of an allocator, then it is @emph{not}
19329 it is constrained by the default values of the discriminants, and those values
19330 cannot be modified by full assignment. This is because in the presence of
19331 aliasing all views of the object (which may be manipulated by different tasks,
19332 say) must be consistent, so it is imperative that the object, once created,
19335 @node Strict Conformance to the Ada Reference Manual
19336 @section Strict Conformance to the Ada Reference Manual
19339 The dynamic semantics defined by the Ada Reference Manual impose a set of
19340 run-time checks to be generated. By default, the GNAT compiler will insert many
19341 run-time checks into the compiled code, including most of those required by the
19342 Ada Reference Manual. However, there are three checks that are not enabled
19343 in the default mode for efficiency reasons: arithmetic overflow checking for
19344 integer operations (including division by zero), checks for access before
19345 elaboration on subprogram calls, and stack overflow checking (most operating
19346 systems do not perform this check by default).
19348 Strict conformance to the Ada Reference Manual can be achieved by adding
19349 three compiler options for overflow checking for integer operations
19350 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
19351 calls and generic instantiations (@option{-gnatE}), and stack overflow
19352 checking (@option{-fstack-check}).
19354 Note that the result of a floating point arithmetic operation in overflow and
19355 invalid situations, when the @code{Machine_Overflows} attribute of the result
19356 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
19357 case for machines compliant with the IEEE floating-point standard, but on
19358 machines that are not fully compliant with this standard, such as Alpha, the
19359 @option{-mieee} compiler flag must be used for achieving IEEE confirming
19360 behavior (although at the cost of a significant performance penalty), so
19361 infinite and NaN values are properly generated.
19364 @node Implementation of Ada 2012 Features
19365 @chapter Implementation of Ada 2012 Features
19366 @cindex Ada 2012 implementation status
19368 This chapter contains a complete list of Ada 2012 features that have been
19369 implemented as of GNAT version 6.4. Generally, these features are only
19370 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
19371 @cindex @option{-gnat12} option
19372 or if the configuration pragma @code{Ada_2012} is used.
19373 @cindex pragma @code{Ada_2012}
19374 @cindex configuration pragma @code{Ada_2012}
19375 @cindex @code{Ada_2012} configuration pragma
19376 However, new pragmas, attributes, and restrictions are
19377 unconditionally available, since the Ada 95 standard allows the addition of
19378 new pragmas, attributes, and restrictions (there are exceptions, which are
19379 documented in the individual descriptions), and also certain packages
19380 were made available in earlier versions of Ada.
19382 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
19383 This date shows the implementation date of the feature. Any wavefront
19384 subsequent to this date will contain the indicated feature, as will any
19385 subsequent releases. A date of 0000-00-00 means that GNAT has always
19386 implemented the feature, or implemented it as soon as it appeared as a
19387 binding interpretation.
19389 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
19390 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
19391 The features are ordered based on the relevant sections of the Ada
19392 Reference Manual (``RM''). When a given AI relates to multiple points
19393 in the RM, the earliest is used.
19395 A complete description of the AIs may be found in
19396 @url{www.ada-auth.org/ai05-summary.html}.
19401 @emph{AI-0176 Quantified expressions (2010-09-29)}
19402 @cindex AI-0176 (Ada 2012 feature)
19405 Both universally and existentially quantified expressions are implemented.
19406 They use the new syntax for iterators proposed in AI05-139-2, as well as
19407 the standard Ada loop syntax.
19410 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
19413 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
19414 @cindex AI-0079 (Ada 2012 feature)
19417 Wide characters in the unicode category @i{other_format} are now allowed in
19418 source programs between tokens, but not within a token such as an identifier.
19421 RM References: 2.01 (4/2) 2.02 (7)
19424 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
19425 @cindex AI-0091 (Ada 2012 feature)
19428 Wide characters in the unicode category @i{other_format} are not permitted
19429 within an identifier, since this can be a security problem. The error
19430 message for this case has been improved to be more specific, but GNAT has
19431 never allowed such characters to appear in identifiers.
19434 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)
19437 @emph{AI-0100 Placement of pragmas (2010-07-01)}
19438 @cindex AI-0100 (Ada 2012 feature)
19441 This AI is an earlier version of AI-163. It simplifies the rules
19442 for legal placement of pragmas. In the case of lists that allow pragmas, if
19443 the list may have no elements, then the list may consist solely of pragmas.
19446 RM References: 2.08 (7)
19449 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
19450 @cindex AI-0163 (Ada 2012 feature)
19453 A statement sequence may be composed entirely of pragmas. It is no longer
19454 necessary to add a dummy @code{null} statement to make the sequence legal.
19457 RM References: 2.08 (7) 2.08 (16)
19461 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
19462 @cindex AI-0080 (Ada 2012 feature)
19465 This is an editorial change only, described as non-testable in the AI.
19468 RM References: 3.01 (7)
19472 @emph{AI-0183 Aspect specifications (2010-08-16)}
19473 @cindex AI-0183 (Ada 2012 feature)
19476 Aspect specifications have been fully implemented except for pre and post-
19477 conditions, and type invariants, which have their own separate AI's. All
19478 forms of declarations listed in the AI are supported. The following is a
19479 list of the aspects supported (with GNAT implementation aspects marked)
19481 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
19482 @item @code{Ada_2005} @tab -- GNAT
19483 @item @code{Ada_2012} @tab -- GNAT
19484 @item @code{Address} @tab
19485 @item @code{Alignment} @tab
19486 @item @code{Atomic} @tab
19487 @item @code{Atomic_Components} @tab
19488 @item @code{Bit_Order} @tab
19489 @item @code{Component_Size} @tab
19490 @item @code{Contract_Cases} @tab -- GNAT
19491 @item @code{Discard_Names} @tab
19492 @item @code{External_Tag} @tab
19493 @item @code{Favor_Top_Level} @tab -- GNAT
19494 @item @code{Inline} @tab
19495 @item @code{Inline_Always} @tab -- GNAT
19496 @item @code{Invariant} @tab -- GNAT
19497 @item @code{Machine_Radix} @tab
19498 @item @code{No_Return} @tab
19499 @item @code{Object_Size} @tab -- GNAT
19500 @item @code{Pack} @tab
19501 @item @code{Persistent_BSS} @tab -- GNAT
19502 @item @code{Post} @tab
19503 @item @code{Pre} @tab
19504 @item @code{Predicate} @tab
19505 @item @code{Preelaborable_Initialization} @tab
19506 @item @code{Pure_Function} @tab -- GNAT
19507 @item @code{Remote_Access_Type} @tab -- GNAT
19508 @item @code{Shared} @tab -- GNAT
19509 @item @code{Size} @tab
19510 @item @code{Storage_Pool} @tab
19511 @item @code{Storage_Size} @tab
19512 @item @code{Stream_Size} @tab
19513 @item @code{Suppress} @tab
19514 @item @code{Suppress_Debug_Info} @tab -- GNAT
19515 @item @code{Test_Case} @tab -- GNAT
19516 @item @code{Type_Invariant} @tab
19517 @item @code{Unchecked_Union} @tab
19518 @item @code{Universal_Aliasing} @tab -- GNAT
19519 @item @code{Unmodified} @tab -- GNAT
19520 @item @code{Unreferenced} @tab -- GNAT
19521 @item @code{Unreferenced_Objects} @tab -- GNAT
19522 @item @code{Unsuppress} @tab
19523 @item @code{Value_Size} @tab -- GNAT
19524 @item @code{Volatile} @tab
19525 @item @code{Volatile_Components}
19526 @item @code{Warnings} @tab -- GNAT
19530 Note that for aspects with an expression, e.g. @code{Size}, the expression is
19531 treated like a default expression (visibility is analyzed at the point of
19532 occurrence of the aspect, but evaluation of the expression occurs at the
19533 freeze point of the entity involved).
19536 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
19537 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
19538 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
19539 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
19540 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
19545 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
19546 @cindex AI-0128 (Ada 2012 feature)
19549 If an equality operator ("=") is declared for a type, then the implicitly
19550 declared inequality operator ("/=") is a primitive operation of the type.
19551 This is the only reasonable interpretation, and is the one always implemented
19552 by GNAT, but the RM was not entirely clear in making this point.
19555 RM References: 3.02.03 (6) 6.06 (6)
19558 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
19559 @cindex AI-0003 (Ada 2012 feature)
19562 In Ada 2012, a qualified expression is considered to be syntactically a name,
19563 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
19564 useful in disambiguating some cases of overloading.
19567 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
19571 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
19572 @cindex AI-0120 (Ada 2012 feature)
19575 This is an RM editorial change only. The section that lists objects that are
19576 constant failed to include the current instance of a protected object
19577 within a protected function. This has always been treated as a constant
19581 RM References: 3.03 (21)
19584 @emph{AI-0008 General access to constrained objects (0000-00-00)}
19585 @cindex AI-0008 (Ada 2012 feature)
19588 The wording in the RM implied that if you have a general access to a
19589 constrained object, it could be used to modify the discriminants. This was
19590 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
19591 has always done so in this situation.
19594 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
19598 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
19599 @cindex AI-0093 (Ada 2012 feature)
19602 This is an editorial change only, to make more widespread use of the Ada 2012
19603 ``immutably limited''.
19606 RM References: 3.03 (23.4/3)
19611 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
19612 @cindex AI-0096 (Ada 2012 feature)
19615 In general it is illegal for a type derived from a formal limited type to be
19616 nonlimited. This AI makes an exception to this rule: derivation is legal
19617 if it appears in the private part of the generic, and the formal type is not
19618 tagged. If the type is tagged, the legality check must be applied to the
19619 private part of the package.
19622 RM References: 3.04 (5.1/2) 6.02 (7)
19626 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
19627 @cindex AI-0181 (Ada 2012 feature)
19630 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
19631 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
19632 @code{Image} and @code{Value} attributes for the character types. Strictly
19633 speaking this is an inconsistency with Ada 95, but in practice the use of
19634 these attributes is so obscure that it will not cause problems.
19637 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
19641 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
19642 @cindex AI-0182 (Ada 2012 feature)
19645 This AI allows @code{Character'Value} to accept the string @code{'?'} where
19646 @code{?} is any character including non-graphic control characters. GNAT has
19647 always accepted such strings. It also allows strings such as
19648 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
19649 permission and raises @code{Constraint_Error}, as is certainly still
19653 RM References: 3.05 (56/2)
19657 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
19658 @cindex AI-0214 (Ada 2012 feature)
19661 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
19662 to have default expressions by allowing them when the type is limited. It
19663 is often useful to define a default value for a discriminant even though
19664 it can't be changed by assignment.
19667 RM References: 3.07 (9.1/2) 3.07.02 (3)
19671 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
19672 @cindex AI-0102 (Ada 2012 feature)
19675 It is illegal to assign an anonymous access constant to an anonymous access
19676 variable. The RM did not have a clear rule to prevent this, but GNAT has
19677 always generated an error for this usage.
19680 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
19684 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
19685 @cindex AI-0158 (Ada 2012 feature)
19688 This AI extends the syntax of membership tests to simplify complex conditions
19689 that can be expressed as membership in a subset of values of any type. It
19690 introduces syntax for a list of expressions that may be used in loop contexts
19694 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
19698 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
19699 @cindex AI-0173 (Ada 2012 feature)
19702 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
19703 with the tag of an abstract type, and @code{False} otherwise.
19706 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
19711 @emph{AI-0076 function with controlling result (0000-00-00)}
19712 @cindex AI-0076 (Ada 2012 feature)
19715 This is an editorial change only. The RM defines calls with controlling
19716 results, but uses the term ``function with controlling result'' without an
19717 explicit definition.
19720 RM References: 3.09.02 (2/2)
19724 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
19725 @cindex AI-0126 (Ada 2012 feature)
19728 This AI clarifies dispatching rules, and simply confirms that dispatching
19729 executes the operation of the parent type when there is no explicitly or
19730 implicitly declared operation for the descendant type. This has always been
19731 the case in all versions of GNAT.
19734 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
19738 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
19739 @cindex AI-0097 (Ada 2012 feature)
19742 The RM as written implied that in some cases it was possible to create an
19743 object of an abstract type, by having an abstract extension inherit a non-
19744 abstract constructor from its parent type. This mistake has been corrected
19745 in GNAT and in the RM, and this construct is now illegal.
19748 RM References: 3.09.03 (4/2)
19752 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
19753 @cindex AI-0203 (Ada 2012 feature)
19756 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
19757 permitted such usage.
19760 RM References: 3.09.03 (8/3)
19764 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
19765 @cindex AI-0198 (Ada 2012 feature)
19768 This AI resolves a conflict between two rules involving inherited abstract
19769 operations and predefined operators. If a derived numeric type inherits
19770 an abstract operator, it overrides the predefined one. This interpretation
19771 was always the one implemented in GNAT.
19774 RM References: 3.09.03 (4/3)
19777 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
19778 @cindex AI-0073 (Ada 2012 feature)
19781 This AI covers a number of issues regarding returning abstract types. In
19782 particular generic functions cannot have abstract result types or access
19783 result types designated an abstract type. There are some other cases which
19784 are detailed in the AI. Note that this binding interpretation has not been
19785 retrofitted to operate before Ada 2012 mode, since it caused a significant
19786 number of regressions.
19789 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
19793 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
19794 @cindex AI-0070 (Ada 2012 feature)
19797 This is an editorial change only, there are no testable consequences short of
19798 checking for the absence of generated code for an interface declaration.
19801 RM References: 3.09.04 (18/2)
19805 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
19806 @cindex AI-0208 (Ada 2012 feature)
19809 The wording in the Ada 2005 RM concerning characteristics of incomplete views
19810 was incorrect and implied that some programs intended to be legal were now
19811 illegal. GNAT had never considered such programs illegal, so it has always
19812 implemented the intent of this AI.
19815 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
19819 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
19820 @cindex AI-0162 (Ada 2012 feature)
19823 Incomplete types are made more useful by allowing them to be completed by
19824 private types and private extensions.
19827 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
19832 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
19833 @cindex AI-0098 (Ada 2012 feature)
19836 An unintentional omission in the RM implied some inconsistent restrictions on
19837 the use of anonymous access to subprogram values. These restrictions were not
19838 intentional, and have never been enforced by GNAT.
19841 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
19845 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
19846 @cindex AI-0199 (Ada 2012 feature)
19849 A choice list in a record aggregate can include several components of
19850 (distinct) anonymous access types as long as they have matching designated
19854 RM References: 4.03.01 (16)
19858 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
19859 @cindex AI-0220 (Ada 2012 feature)
19862 This AI addresses a wording problem in the RM that appears to permit some
19863 complex cases of aggregates with non-static discriminants. GNAT has always
19864 implemented the intended semantics.
19867 RM References: 4.03.01 (17)
19870 @emph{AI-0147 Conditional expressions (2009-03-29)}
19871 @cindex AI-0147 (Ada 2012 feature)
19874 Conditional expressions are permitted. The form of such an expression is:
19877 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
19880 The parentheses can be omitted in contexts where parentheses are present
19881 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
19882 clause is omitted, @b{else True} is assumed;
19883 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
19884 @emph{(A implies B)} in standard logic.
19887 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
19888 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
19892 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
19893 @cindex AI-0037 (Ada 2012 feature)
19896 This AI confirms that an association of the form @code{Indx => <>} in an
19897 array aggregate must raise @code{Constraint_Error} if @code{Indx}
19898 is out of range. The RM specified a range check on other associations, but
19899 not when the value of the association was defaulted. GNAT has always inserted
19900 a constraint check on the index value.
19903 RM References: 4.03.03 (29)
19907 @emph{AI-0123 Composability of equality (2010-04-13)}
19908 @cindex AI-0123 (Ada 2012 feature)
19911 Equality of untagged record composes, so that the predefined equality for a
19912 composite type that includes a component of some untagged record type
19913 @code{R} uses the equality operation of @code{R} (which may be user-defined
19914 or predefined). This makes the behavior of untagged records identical to that
19915 of tagged types in this respect.
19917 This change is an incompatibility with previous versions of Ada, but it
19918 corrects a non-uniformity that was often a source of confusion. Analysis of
19919 a large number of industrial programs indicates that in those rare cases
19920 where a composite type had an untagged record component with a user-defined
19921 equality, either there was no use of the composite equality, or else the code
19922 expected the same composability as for tagged types, and thus had a bug that
19923 would be fixed by this change.
19926 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
19931 @emph{AI-0088 The value of exponentiation (0000-00-00)}
19932 @cindex AI-0088 (Ada 2012 feature)
19935 This AI clarifies the equivalence rule given for the dynamic semantics of
19936 exponentiation: the value of the operation can be obtained by repeated
19937 multiplication, but the operation can be implemented otherwise (for example
19938 using the familiar divide-by-two-and-square algorithm, even if this is less
19939 accurate), and does not imply repeated reads of a volatile base.
19942 RM References: 4.05.06 (11)
19945 @emph{AI-0188 Case expressions (2010-01-09)}
19946 @cindex AI-0188 (Ada 2012 feature)
19949 Case expressions are permitted. This allows use of constructs such as:
19951 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
19955 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
19958 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
19959 @cindex AI-0104 (Ada 2012 feature)
19962 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
19963 @code{Constraint_Error} because the default value of the allocated object is
19964 @b{null}. This useless construct is illegal in Ada 2012.
19967 RM References: 4.08 (2)
19970 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
19971 @cindex AI-0157 (Ada 2012 feature)
19974 Allocation and Deallocation from an empty storage pool (i.e. allocation or
19975 deallocation of a pointer for which a static storage size clause of zero
19976 has been given) is now illegal and is detected as such. GNAT
19977 previously gave a warning but not an error.
19980 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
19983 @emph{AI-0179 Statement not required after label (2010-04-10)}
19984 @cindex AI-0179 (Ada 2012 feature)
19987 It is not necessary to have a statement following a label, so a label
19988 can appear at the end of a statement sequence without the need for putting a
19989 null statement afterwards, but it is not allowable to have only labels and
19990 no real statements in a statement sequence.
19993 RM References: 5.01 (2)
19997 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
19998 @cindex AI-139-2 (Ada 2012 feature)
20001 The new syntax for iterating over arrays and containers is now implemented.
20002 Iteration over containers is for now limited to read-only iterators. Only
20003 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
20006 RM References: 5.05
20009 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
20010 @cindex AI-0134 (Ada 2012 feature)
20013 For full conformance, the profiles of anonymous-access-to-subprogram
20014 parameters must match. GNAT has always enforced this rule.
20017 RM References: 6.03.01 (18)
20020 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
20021 @cindex AI-0207 (Ada 2012 feature)
20024 This AI confirms that access_to_constant indication must match for mode
20025 conformance. This was implemented in GNAT when the qualifier was originally
20026 introduced in Ada 2005.
20029 RM References: 6.03.01 (16/2)
20033 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
20034 @cindex AI-0046 (Ada 2012 feature)
20037 For full conformance, in the case of access parameters, the null exclusion
20038 must match (either both or neither must have @code{@b{not null}}).
20041 RM References: 6.03.02 (18)
20045 @emph{AI-0118 The association of parameter associations (0000-00-00)}
20046 @cindex AI-0118 (Ada 2012 feature)
20049 This AI clarifies the rules for named associations in subprogram calls and
20050 generic instantiations. The rules have been in place since Ada 83.
20053 RM References: 6.04.01 (2) 12.03 (9)
20057 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
20058 @cindex AI-0196 (Ada 2012 feature)
20061 Null exclusion checks are not made for @code{@b{out}} parameters when
20062 evaluating the actual parameters. GNAT has never generated these checks.
20065 RM References: 6.04.01 (13)
20068 @emph{AI-0015 Constant return objects (0000-00-00)}
20069 @cindex AI-0015 (Ada 2012 feature)
20072 The return object declared in an @i{extended_return_statement} may be
20073 declared constant. This was always intended, and GNAT has always allowed it.
20076 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
20081 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
20082 @cindex AI-0032 (Ada 2012 feature)
20085 If a function returns a class-wide type, the object of an extended return
20086 statement can be declared with a specific type that is covered by the class-
20087 wide type. This has been implemented in GNAT since the introduction of
20088 extended returns. Note AI-0103 complements this AI by imposing matching
20089 rules for constrained return types.
20092 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
20096 @emph{AI-0103 Static matching for extended return (2010-07-23)}
20097 @cindex AI-0103 (Ada 2012 feature)
20100 If the return subtype of a function is an elementary type or a constrained
20101 type, the subtype indication in an extended return statement must match
20102 statically this return subtype.
20105 RM References: 6.05 (5.2/2)
20109 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
20110 @cindex AI-0058 (Ada 2012 feature)
20113 The RM had some incorrect wording implying wrong treatment of abnormal
20114 completion in an extended return. GNAT has always implemented the intended
20115 correct semantics as described by this AI.
20118 RM References: 6.05 (22/2)
20122 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
20123 @cindex AI-0050 (Ada 2012 feature)
20126 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
20127 not take advantage of these incorrect permissions in any case.
20130 RM References: 6.05 (24/2)
20134 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
20135 @cindex AI-0125 (Ada 2012 feature)
20138 In Ada 2012, the declaration of a primitive operation of a type extension
20139 or private extension can also override an inherited primitive that is not
20140 visible at the point of this declaration.
20143 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
20146 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
20147 @cindex AI-0062 (Ada 2012 feature)
20150 A full constant may have a null exclusion even if its associated deferred
20151 constant does not. GNAT has always allowed this.
20154 RM References: 7.04 (6/2) 7.04 (7.1/2)
20158 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
20159 @cindex AI-0178 (Ada 2012 feature)
20162 This AI clarifies the role of incomplete views and plugs an omission in the
20163 RM. GNAT always correctly restricted the use of incomplete views and types.
20166 RM References: 7.05 (3/2) 7.05 (6/2)
20169 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
20170 @cindex AI-0087 (Ada 2012 feature)
20173 The actual for a formal nonlimited derived type cannot be limited. In
20174 particular, a formal derived type that extends a limited interface but which
20175 is not explicitly limited cannot be instantiated with a limited type.
20178 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
20181 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
20182 @cindex AI-0099 (Ada 2012 feature)
20185 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
20186 and therefore depends on the run-time characteristics of an object (i.e. its
20187 tag) and not on its nominal type. As the AI indicates: ``we do not expect
20188 this to affect any implementation''.
20191 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
20196 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
20197 @cindex AI-0064 (Ada 2012 feature)
20200 This is an editorial change only. The intended behavior is already checked
20201 by an existing ACATS test, which GNAT has always executed correctly.
20204 RM References: 7.06.01 (17.1/1)
20207 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
20208 @cindex AI-0026 (Ada 2012 feature)
20211 Record representation clauses concerning Unchecked_Union types cannot mention
20212 the discriminant of the type. The type of a component declared in the variant
20213 part of an Unchecked_Union cannot be controlled, have controlled components,
20214 nor have protected or task parts. If an Unchecked_Union type is declared
20215 within the body of a generic unit or its descendants, then the type of a
20216 component declared in the variant part cannot be a formal private type or a
20217 formal private extension declared within the same generic unit.
20220 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
20224 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
20225 @cindex AI-0205 (Ada 2012 feature)
20228 This AI corrects a simple omission in the RM. Return objects have always
20229 been visible within an extended return statement.
20232 RM References: 8.03 (17)
20236 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
20237 @cindex AI-0042 (Ada 2012 feature)
20240 This AI fixes a wording gap in the RM. An operation of a synchronized
20241 interface can be implemented by a protected or task entry, but the abstract
20242 operation is not being overridden in the usual sense, and it must be stated
20243 separately that this implementation is legal. This has always been the case
20247 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
20250 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
20251 @cindex AI-0030 (Ada 2012 feature)
20254 Requeue is permitted to a protected, synchronized or task interface primitive
20255 providing it is known that the overriding operation is an entry. Otherwise
20256 the requeue statement has the same effect as a procedure call. Use of pragma
20257 @code{Implemented} provides a way to impose a static requirement on the
20258 overriding operation by adhering to one of the implementation kinds: entry,
20259 protected procedure or any of the above.
20262 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
20263 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
20267 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
20268 @cindex AI-0201 (Ada 2012 feature)
20271 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
20272 attribute, then individual components may not be addressable by independent
20273 tasks. However, if the representation clause has no effect (is confirming),
20274 then independence is not compromised. Furthermore, in GNAT, specification of
20275 other appropriately addressable component sizes (e.g. 16 for 8-bit
20276 characters) also preserves independence. GNAT now gives very clear warnings
20277 both for the declaration of such a type, and for any assignment to its components.
20280 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
20283 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
20284 @cindex AI-0009 (Ada 2012 feature)
20287 This AI introduces the new pragmas @code{Independent} and
20288 @code{Independent_Components},
20289 which control guaranteeing independence of access to objects and components.
20290 The AI also requires independence not unaffected by confirming rep clauses.
20293 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
20294 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
20298 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
20299 @cindex AI-0072 (Ada 2012 feature)
20302 This AI clarifies that task signalling for reading @code{'Terminated} only
20303 occurs if the result is True. GNAT semantics has always been consistent with
20304 this notion of task signalling.
20307 RM References: 9.10 (6.1/1)
20310 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
20311 @cindex AI-0108 (Ada 2012 feature)
20314 This AI confirms that an incomplete type from a limited view does not have
20315 discriminants. This has always been the case in GNAT.
20318 RM References: 10.01.01 (12.3/2)
20321 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
20322 @cindex AI-0129 (Ada 2012 feature)
20325 This AI clarifies the description of limited views: a limited view of a
20326 package includes only one view of a type that has an incomplete declaration
20327 and a full declaration (there is no possible ambiguity in a client package).
20328 This AI also fixes an omission: a nested package in the private part has no
20329 limited view. GNAT always implemented this correctly.
20332 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
20337 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
20338 @cindex AI-0077 (Ada 2012 feature)
20341 This AI clarifies that a declaration does not include a context clause,
20342 and confirms that it is illegal to have a context in which both a limited
20343 and a nonlimited view of a package are accessible. Such double visibility
20344 was always rejected by GNAT.
20347 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
20350 @emph{AI-0122 Private with and children of generics (0000-00-00)}
20351 @cindex AI-0122 (Ada 2012 feature)
20354 This AI clarifies the visibility of private children of generic units within
20355 instantiations of a parent. GNAT has always handled this correctly.
20358 RM References: 10.01.02 (12/2)
20363 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
20364 @cindex AI-0040 (Ada 2012 feature)
20367 This AI confirms that a limited with clause in a child unit cannot name
20368 an ancestor of the unit. This has always been checked in GNAT.
20371 RM References: 10.01.02 (20/2)
20374 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
20375 @cindex AI-0132 (Ada 2012 feature)
20378 This AI fills a gap in the description of library unit pragmas. The pragma
20379 clearly must apply to a library unit, even if it does not carry the name
20380 of the enclosing unit. GNAT has always enforced the required check.
20383 RM References: 10.01.05 (7)
20387 @emph{AI-0034 Categorization of limited views (0000-00-00)}
20388 @cindex AI-0034 (Ada 2012 feature)
20391 The RM makes certain limited with clauses illegal because of categorization
20392 considerations, when the corresponding normal with would be legal. This is
20393 not intended, and GNAT has always implemented the recommended behavior.
20396 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
20400 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
20401 @cindex AI-0035 (Ada 2012 feature)
20404 This AI remedies some inconsistencies in the legality rules for Pure units.
20405 Derived access types are legal in a pure unit (on the assumption that the
20406 rule for a zero storage pool size has been enforced on the ancestor type).
20407 The rules are enforced in generic instances and in subunits. GNAT has always
20408 implemented the recommended behavior.
20411 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)
20415 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
20416 @cindex AI-0219 (Ada 2012 feature)
20419 This AI refines the rules for the cases with limited parameters which do not
20420 allow the implementations to omit ``redundant''. GNAT now properly conforms
20421 to the requirements of this binding interpretation.
20424 RM References: 10.02.01 (18/2)
20427 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
20428 @cindex AI-0043 (Ada 2012 feature)
20431 This AI covers various omissions in the RM regarding the raising of
20432 exceptions. GNAT has always implemented the intended semantics.
20435 RM References: 11.04.01 (10.1/2) 11 (2)
20439 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
20440 @cindex AI-0200 (Ada 2012 feature)
20443 This AI plugs a gap in the RM which appeared to allow some obviously intended
20444 illegal instantiations. GNAT has never allowed these instantiations.
20447 RM References: 12.07 (16)
20451 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
20452 @cindex AI-0112 (Ada 2012 feature)
20455 This AI concerns giving names to various representation aspects, but the
20456 practical effect is simply to make the use of duplicate
20457 @code{Atomic}[@code{_Components}],
20458 @code{Volatile}[@code{_Components}] and
20459 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
20460 now performs this required check.
20463 RM References: 13.01 (8)
20466 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
20467 @cindex AI-0106 (Ada 2012 feature)
20470 The RM appeared to allow representation pragmas on generic formal parameters,
20471 but this was not intended, and GNAT has never permitted this usage.
20474 RM References: 13.01 (9.1/1)
20478 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
20479 @cindex AI-0012 (Ada 2012 feature)
20482 It is now illegal to give an inappropriate component size or a pragma
20483 @code{Pack} that attempts to change the component size in the case of atomic
20484 or aliased components. Previously GNAT ignored such an attempt with a
20488 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
20492 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
20493 @cindex AI-0039 (Ada 2012 feature)
20496 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
20497 for stream attributes, but these were never useful and are now illegal. GNAT
20498 has always regarded such expressions as illegal.
20501 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
20505 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
20506 @cindex AI-0095 (Ada 2012 feature)
20509 The prefix of @code{'Address} cannot statically denote a subprogram with
20510 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
20511 @code{Program_Error} if the prefix denotes a subprogram with convention
20515 RM References: 13.03 (11/1)
20519 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
20520 @cindex AI-0116 (Ada 2012 feature)
20523 This AI requires that the alignment of a class-wide object be no greater
20524 than the alignment of any type in the class. GNAT has always followed this
20528 RM References: 13.03 (29) 13.11 (16)
20532 @emph{AI-0146 Type invariants (2009-09-21)}
20533 @cindex AI-0146 (Ada 2012 feature)
20536 Type invariants may be specified for private types using the aspect notation.
20537 Aspect @code{Type_Invariant} may be specified for any private type,
20538 @code{Type_Invariant'Class} can
20539 only be specified for tagged types, and is inherited by any descendent of the
20540 tagged types. The invariant is a boolean expression that is tested for being
20541 true in the following situations: conversions to the private type, object
20542 declarations for the private type that are default initialized, and
20544 parameters and returned result on return from any primitive operation for
20545 the type that is visible to a client.
20546 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
20547 @code{Invariant'Class} for @code{Type_Invariant'Class}.
20550 RM References: 13.03.03 (00)
20553 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
20554 @cindex AI-0078 (Ada 2012 feature)
20557 In Ada 2012, compilers are required to support unchecked conversion where the
20558 target alignment is a multiple of the source alignment. GNAT always supported
20559 this case (and indeed all cases of differing alignments, doing copies where
20560 required if the alignment was reduced).
20563 RM References: 13.09 (7)
20567 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
20568 @cindex AI-0195 (Ada 2012 feature)
20571 The handling of invalid values is now designated to be implementation
20572 defined. This is a documentation change only, requiring Annex M in the GNAT
20573 Reference Manual to document this handling.
20574 In GNAT, checks for invalid values are made
20575 only when necessary to avoid erroneous behavior. Operations like assignments
20576 which cannot cause erroneous behavior ignore the possibility of invalid
20577 values and do not do a check. The date given above applies only to the
20578 documentation change, this behavior has always been implemented by GNAT.
20581 RM References: 13.09.01 (10)
20584 @emph{AI-0193 Alignment of allocators (2010-09-16)}
20585 @cindex AI-0193 (Ada 2012 feature)
20588 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
20589 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
20593 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
20594 13.11.01 (2) 13.11.01 (3)
20598 @emph{AI-0177 Parameterized expressions (2010-07-10)}
20599 @cindex AI-0177 (Ada 2012 feature)
20602 The new Ada 2012 notion of parameterized expressions is implemented. The form
20605 @i{function specification} @b{is} (@i{expression})
20609 This is exactly equivalent to the
20610 corresponding function body that returns the expression, but it can appear
20611 in a package spec. Note that the expression must be parenthesized.
20614 RM References: 13.11.01 (3/2)
20617 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
20618 @cindex AI-0033 (Ada 2012 feature)
20621 Neither of these two pragmas may appear within a generic template, because
20622 the generic might be instantiated at other than the library level.
20625 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
20629 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
20630 @cindex AI-0161 (Ada 2012 feature)
20633 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
20634 of the default stream attributes for elementary types. If this restriction is
20635 in force, then it is necessary to provide explicit subprograms for any
20636 stream attributes used.
20639 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
20642 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
20643 @cindex AI-0194 (Ada 2012 feature)
20646 The @code{Stream_Size} attribute returns the default number of bits in the
20647 stream representation of the given type.
20648 This value is not affected by the presence
20649 of stream subprogram attributes for the type. GNAT has always implemented
20650 this interpretation.
20653 RM References: 13.13.02 (1.2/2)
20656 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
20657 @cindex AI-0109 (Ada 2012 feature)
20660 This AI is an editorial change only. It removes the need for a tag check
20661 that can never fail.
20664 RM References: 13.13.02 (34/2)
20667 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
20668 @cindex AI-0007 (Ada 2012 feature)
20671 The RM as written appeared to limit the possibilities of declaring read
20672 attribute procedures for private scalar types. This limitation was not
20673 intended, and has never been enforced by GNAT.
20676 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
20680 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
20681 @cindex AI-0065 (Ada 2012 feature)
20684 This AI clarifies the fact that all remote access types support external
20685 streaming. This fixes an obvious oversight in the definition of the
20686 language, and GNAT always implemented the intended correct rules.
20689 RM References: 13.13.02 (52/2)
20692 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
20693 @cindex AI-0019 (Ada 2012 feature)
20696 The RM suggests that primitive subprograms of a specific tagged type are
20697 frozen when the tagged type is frozen. This would be an incompatible change
20698 and is not intended. GNAT has never attempted this kind of freezing and its
20699 behavior is consistent with the recommendation of this AI.
20702 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)
20705 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
20706 @cindex AI-0017 (Ada 2012 feature)
20709 So-called ``Taft-amendment types'' (i.e., types that are completed in package
20710 bodies) are not frozen by the occurrence of bodies in the
20711 enclosing declarative part. GNAT always implemented this properly.
20714 RM References: 13.14 (3/1)
20718 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
20719 @cindex AI-0060 (Ada 2012 feature)
20722 This AI extends the definition of remote access types to include access
20723 to limited, synchronized, protected or task class-wide interface types.
20724 GNAT already implemented this extension.
20727 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
20730 @emph{AI-0114 Classification of letters (0000-00-00)}
20731 @cindex AI-0114 (Ada 2012 feature)
20734 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
20735 181 (@code{MICRO SIGN}), and
20736 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
20737 lower case letters by Unicode.
20738 However, they are not allowed in identifiers, and they
20739 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
20740 This behavior is consistent with that defined in Ada 95.
20743 RM References: A.03.02 (59) A.04.06 (7)
20747 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
20748 @cindex AI-0185 (Ada 2012 feature)
20751 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
20752 classification functions for @code{Wide_Character} and
20753 @code{Wide_Wide_Character}, as well as providing
20754 case folding routines for @code{Wide_[Wide_]Character} and
20755 @code{Wide_[Wide_]String}.
20758 RM References: A.03.05 (0) A.03.06 (0)
20762 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
20763 @cindex AI-0031 (Ada 2012 feature)
20766 A new version of @code{Find_Token} is added to all relevant string packages,
20767 with an extra parameter @code{From}. Instead of starting at the first
20768 character of the string, the search for a matching Token starts at the
20769 character indexed by the value of @code{From}.
20770 These procedures are available in all versions of Ada
20771 but if used in versions earlier than Ada 2012 they will generate a warning
20772 that an Ada 2012 subprogram is being used.
20775 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
20780 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
20781 @cindex AI-0056 (Ada 2012 feature)
20784 The wording in the Ada 2005 RM implied an incompatible handling of the
20785 @code{Index} functions, resulting in raising an exception instead of
20786 returning zero in some situations.
20787 This was not intended and has been corrected.
20788 GNAT always returned zero, and is thus consistent with this AI.
20791 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
20795 @emph{AI-0137 String encoding package (2010-03-25)}
20796 @cindex AI-0137 (Ada 2012 feature)
20799 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
20800 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
20801 and @code{Wide_Wide_Strings} have been
20802 implemented. These packages (whose documentation can be found in the spec
20803 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
20804 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
20805 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
20806 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
20807 UTF-16), as well as conversions between the different UTF encodings. With
20808 the exception of @code{Wide_Wide_Strings}, these packages are available in
20809 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
20810 The @code{Wide_Wide_Strings package}
20811 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
20812 mode since it uses @code{Wide_Wide_Character}).
20815 RM References: A.04.11
20818 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
20819 @cindex AI-0038 (Ada 2012 feature)
20822 These are minor errors in the description on three points. The intent on
20823 all these points has always been clear, and GNAT has always implemented the
20824 correct intended semantics.
20827 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)
20830 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
20831 @cindex AI-0044 (Ada 2012 feature)
20834 This AI places restrictions on allowed instantiations of generic containers.
20835 These restrictions are not checked by the compiler, so there is nothing to
20836 change in the implementation. This affects only the RM documentation.
20839 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)
20842 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
20843 @cindex AI-0127 (Ada 2012 feature)
20846 This package provides an interface for identifying the current locale.
20849 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
20850 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
20855 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
20856 @cindex AI-0002 (Ada 2012 feature)
20859 The compiler is not required to support exporting an Ada subprogram with
20860 convention C if there are parameters or a return type of an unconstrained
20861 array type (such as @code{String}). GNAT allows such declarations but
20862 generates warnings. It is possible, but complicated, to write the
20863 corresponding C code and certainly such code would be specific to GNAT and
20867 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
20871 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
20872 @cindex AI05-0216 (Ada 2012 feature)
20875 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
20876 forbid tasks declared locally within subprograms, or functions returning task
20877 objects, and that is the implementation that GNAT has always provided.
20878 However the language in the RM was not sufficiently clear on this point.
20879 Thus this is a documentation change in the RM only.
20882 RM References: D.07 (3/3)
20885 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
20886 @cindex AI-0211 (Ada 2012 feature)
20889 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
20890 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
20893 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
20896 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
20897 @cindex AI-0190 (Ada 2012 feature)
20900 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
20901 used to control storage pools globally.
20902 In particular, you can force every access
20903 type that is used for allocation (@b{new}) to have an explicit storage pool,
20904 or you can declare a pool globally to be used for all access types that lack
20908 RM References: D.07 (8)
20911 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
20912 @cindex AI-0189 (Ada 2012 feature)
20915 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
20916 which says that no dynamic allocation will occur once elaboration is
20918 In general this requires a run-time check, which is not required, and which
20919 GNAT does not attempt. But the static cases of allocators in a task body or
20920 in the body of the main program are detected and flagged at compile or bind
20924 RM References: D.07 (19.1/2) H.04 (23.3/2)
20927 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
20928 @cindex AI-0171 (Ada 2012 feature)
20931 A new package @code{System.Multiprocessors} is added, together with the
20932 definition of pragma @code{CPU} for controlling task affinity. A new no
20933 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
20934 is added to the Ravenscar profile.
20937 RM References: D.13.01 (4/2) D.16
20941 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
20942 @cindex AI-0210 (Ada 2012 feature)
20945 This is a documentation only issue regarding wording of metric requirements,
20946 that does not affect the implementation of the compiler.
20949 RM References: D.15 (24/2)
20953 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
20954 @cindex AI-0206 (Ada 2012 feature)
20957 Remote types packages are now allowed to depend on preelaborated packages.
20958 This was formerly considered illegal.
20961 RM References: E.02.02 (6)
20966 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
20967 @cindex AI-0152 (Ada 2012 feature)
20970 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
20971 where the type of the returned value is an anonymous access type.
20974 RM References: H.04 (8/1)
20978 @node Obsolescent Features
20979 @chapter Obsolescent Features
20982 This chapter describes features that are provided by GNAT, but are
20983 considered obsolescent since there are preferred ways of achieving
20984 the same effect. These features are provided solely for historical
20985 compatibility purposes.
20988 * pragma No_Run_Time::
20989 * pragma Ravenscar::
20990 * pragma Restricted_Run_Time::
20993 @node pragma No_Run_Time
20994 @section pragma No_Run_Time
20996 The pragma @code{No_Run_Time} is used to achieve an affect similar
20997 to the use of the "Zero Foot Print" configurable run time, but without
20998 requiring a specially configured run time. The result of using this
20999 pragma, which must be used for all units in a partition, is to restrict
21000 the use of any language features requiring run-time support code. The
21001 preferred usage is to use an appropriately configured run-time that
21002 includes just those features that are to be made accessible.
21004 @node pragma Ravenscar
21005 @section pragma Ravenscar
21007 The pragma @code{Ravenscar} has exactly the same effect as pragma
21008 @code{Profile (Ravenscar)}. The latter usage is preferred since it
21009 is part of the new Ada 2005 standard.
21011 @node pragma Restricted_Run_Time
21012 @section pragma Restricted_Run_Time
21014 The pragma @code{Restricted_Run_Time} has exactly the same effect as
21015 pragma @code{Profile (Restricted)}. The latter usage is
21016 preferred since the Ada 2005 pragma @code{Profile} is intended for
21017 this kind of implementation dependent addition.
21020 @c GNU Free Documentation License
21022 @node Index,,GNU Free Documentation License, Top
21030 tablishes the following set of restrictions: