home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / gnat-2.06-src.tgz / tar.out / fsf / gnat / ada-other / gnatinfo.txt < prev    next >
Text File  |  1996-09-28  |  66KB  |  1,499 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                              GNAT DOCUMENTS                              --
  4. --                                I N T R O                                 --
  5. --                                                                          --
  6. --                                                                          --
  7. --                                                                          -- 
  8. --                                                                          --
  9. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  10. --                                                                          --
  11. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  12. -- terms  of the GNU  General  Public  License  as  published  by the  Free --
  13. -- Software  Foundation;  either version 2,  or (at your option)  any later --
  14. -- version.  GNAT is distributed  in the hope  that it will be useful,  but --
  15. -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT- --
  16. -- ABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public --
  17. -- License  for  more details.  You should have received  a copy of the GNU --
  18. -- General Public License along with GNAT;  see file COPYING. If not, write --
  19. -- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. --
  20. --                                                                          --
  21. ------------------------------------------------------------------------------
  22.  
  23. Contents.
  24. ---------
  25.    Running GNAT.
  26.    A small example.
  27.    Gnatbl.
  28.    Using the binder.
  29.    Using gcc to compile.
  30.    Using gcc for syntax checking.
  31.    Using gcc for semantics checking.
  32.    Search Paths and the Run Time Library (RTL).
  33.    Options.  
  34.    Gnatmake.
  35.    Smart gnatmake.
  36.    Constraint Checking and Pragma Suppress.
  37.    Software Overflow Checking.
  38.    Order of Compilation Issues.
  39.    File Name Rules.
  40.    Gnatk8.
  41.    Compiling Files With Several Compilation Units.
  42.    Cross Reference Tool.
  43.    Implementation of Intrinsic Functions.
  44.    Getting Internal Debugging Information.
  45.    When GNAT crashes.
  46.    Using gdb.
  47.    GNAT specific pragmas.
  48.    New WARNING messages related to accessibility checks and private packages
  49.    Features supported/unsupported.
  50.    Files.
  51.    Ada Mode for Emacs.
  52.    Copyright considerations.
  53.    How to get in touch with us.
  54.    Schedule.
  55.    A short gnat paper.
  56.    Ada information resources on the Internet.
  57.    The GNAT development team.
  58. ------------------------------------------------------------------------------ 
  59.  
  60. Running GNAT.
  61. -------------
  62. Three steps are needed to create an executable file from an Ada source file:
  63. it must first be compiled, it then must go through the gnat binder, and then
  64. all appropriate object files it needs are then linked together to produce an
  65. executable.  A tool has been provided to combine the last 2 steps into one
  66. command.
  67.  
  68. A small example.
  69. ----------------
  70.  
  71. The file hello.adb contains the source of our modest version of the
  72. "Hello World" program.  Other components of this program are contained
  73. in the GNAT Runtime Library (RTL).  You needn't mention the files
  74. containing these other components but you can find the sources (g-io.ads,
  75. g-io.adb, and a-cio.c) in the RTL source directory (described below).
  76.  
  77. The file hello.adb can be found in the current distribution in the examples
  78. directory.  Here are the commands for building and running it (Since this
  79. documentation is for systems running Unix and also for those running DOS,
  80. IBM OS/2 2.x and Windows NT, in places where the instructions differ a prefix
  81. "Unix:" or "OS/2:" or "DOS:" indicates what is relevant for each system):
  82.  
  83.             gcc -c hello.adb
  84.       Unix: gnatbl -o hello hello.ali
  85.       OS/2: gnatbl -o hello.exe hello.ali
  86.       DOS : gnatbl -o hello.exe hello.ali
  87.  
  88. create the executable called "hello" or "hello.exe" in your current directory.
  89.  
  90. In the example above, gnatbl calls the binder and creates a file b_hello.c
  91. which contains among things the calls to the necessary elaboration procedures.
  92. b_hello is then compiled and linked with all the other object files. After the
  93. link is completed, both b_hello.c and b_hello.o (b_hello.obj) are removed by
  94. default. If -g was specified on the call to gnatbl, the two files are not
  95. removed since it is assumed they might be required for debugging.
  96.  
  97. (Note that the operation of the DOS version of gnatbl changed with GNAT 2.00.
  98. Previously the file hello (no extension) was created.  The extra step of 
  99. running coff2exe has now been incorporated into gnatbl.  In order to lessen 
  100. the proliferation of normally unused files, the extensionless coff version 
  101. is automatically deleted.  If you need it, for example for debugging, it can 
  102. be recreated by running exe2coff.)
  103.  
  104. Typing
  105.  
  106.       hello
  107.  
  108. will allow you to verify that the system is alive and willing to enter into 
  109. a primitive dialogue.
  110.  
  111. The gcc switch -c indicates that we only want to compile, not link. The gnatbl
  112. step produces the executable by means of calling the GNAT binder, compiling
  113. its output, and calling gcc with the needed object files and libraries to
  114. link the executable.  The -o switch is passed to the linker to name the
  115. resulting executable file.
  116.  
  117. As the example suggests, the gcc command recognizes the extension .adb as
  118. an indication of an Ada source file and calls the appropriate programs
  119. to generate an object file (hello.o or hello.obj) and an Ada Library
  120. Information (ALI) file (hello.ali) containing dependency information used
  121. by the binder to verify consistency and determine order of elaboration.
  122. The "ali" extension is recognized by gnatbl as the ALI file of the main
  123. procedure or function, and gnatbl uses it to create a file called the
  124. bind file, and to gather all the needed object files for linking.
  125.  
  126.  
  127. Gnatbl
  128. -----
  129.   gnatbl
  130.        [-o exec_name]
  131.        [-v]                  -- verbose mode
  132.        [-g]                  -- include debugging information
  133.        [-linkonly]           -- doesn't call the binder
  134.        [-gnatbind name]      -- full name for gnatbind
  135.        [-gnatlink name]      -- full name for the linker (gcc)
  136.        [list of objects]     -- non Ada binaries
  137.        [linker options]      -- other options for the linker
  138.  
  139. The program gnatbl provides for binding and linking using the GNAT RTL.
  140. Gnatbl calls gnatbind which creates a C file (b_hello.c in our
  141. simple example) containing calls to all of the elaboration routines.
  142. Gnatbind is described more fully below.  The typical use of GNAT (currently
  143. -- in the presence of gnatbl) to construct a program consisting of a mix
  144. of Ada and C sources is to compile all of the sources using "gcc -c" to
  145. generate object (.o or .obj) files.  In the case of Ada sources, ALI files
  146. with the extension .ali are also produced.  Then gnatbl is used to construct
  147. the executable.  All arguments to gnatbl are simply passed through to gcc
  148. to link the objects together, with the exception of a file name with the
  149. .ali extension.  Such an argument is presumed to be the ALI file of the
  150. main procedure of the program.  When gnatbl sees a .ali file it calls gnatbind
  151. to create the bind file, compiles the bind file, extracts a list of needed
  152. object files from the bind file, and replaces the .ali argument with the
  153. a list of object files (the result of compiling the bind file and the list
  154. extracted from the bind file) in the gcc command it makes.  As a quick
  155. illustration consider a program comprising main.adb, foo.adb and bar.c.
  156. After compiling these sources into object files, the command (under Unix)
  157.  
  158. gnatbl -o main main.ali bar.o
  159.  
  160. would cause gnatbl to:
  161.   call "gnatbind main.ali", generating b_main.c
  162.   call "gcc -c b_main.c"
  163.   call "gcc -o main b_main.o main.o foo.o bar.o (+ gnat library args)"
  164.  
  165. In the last step, the "main.ali" argument has been replaced by all of the
  166. object files needed by main (the binder file, main itself, and foo -- upon
  167. which main depends). All other gnatbl arguments are passed through unchanged
  168. to gcc.  Finally a -l and a -L argument are added to the end of the gcc call
  169. to point it to the gnatlib library.  (Under OS/2, the command line and
  170. behavior of gnatbl is similar.)  (Under DOS, the additional step of calling
  171. "coff2exe main" is done.)
  172.  
  173. A current limitation of gnatbl is that the main program must be Ada and that
  174. it depends on all of the necessary library units.  In other words, there can
  175. be only one .ali file listed and it must be the main program. This
  176. particularly restricts gnatbl's use when a routine written in another language
  177. calls an Ada subprogram which is not also called from Ada.
  178.  
  179. [-o exec_name]
  180.   Under unix if the -o option is omitted the executable is called the name of
  181.   the main unit. So "gnatbl try.ali" will create an executable called try.
  182.   Under DOS and OS/2 it would create an exectuable called try.exe.
  183.  
  184. [-v]
  185.   The verbose option is most useful when the user wants to see what set of
  186.   object files that are being used in the link step.
  187.  
  188. [-g]
  189.   The option to include debugging information causes the C bind file, i.e.
  190.   b_foo.c, to be compiled with -g. In addition the b_foo.c and b_foo.o file
  191.   will not be removed (without -g the default action is to remove the binder
  192.   generated files). Additionally on DOS, it causes the COFF output file to
  193.   be preserved and on Windows NT causes extra debugging information to be
  194.   linked into the executable.
  195.  
  196. [-linkonly]           -- doesn't call the binder
  197.   Do not call gnatbind but rather use the bind file that has already been
  198.   generated. This option is useful if the user wants to pass options to
  199.   gnatbind which is not directly possible with gnatbl. The sequence would be:
  200.   
  201.   gnatbind binder_options file.ali
  202.   gnatbl -linkonly file.ali
  203.  
  204. [-gnatbind name]      -- full name for gnatbind
  205.   Allows the user to specify the full path of the gnatbind executable that
  206.   gnatbl should use rather than the default one on the path.
  207.  
  208. [-gnatlink name]      -- full name for the linker (gcc)
  209.  
  210. Using the Binder.
  211. -----------------
  212.  
  213. In the "Hello World" example, if gnatbl were not used, the second step
  214. would have been to call the binder directly with the command:
  215.  
  216.        gnatbind hello.ali
  217.  
  218. This command generates a file named b_hello.c which needs to be compiled and
  219. linked together with hello.o (or hello.obj).  The file b_hello.c contains
  220. a program which contains calls to all of the elaboration routines of all
  221. of the units required by the subprogram whose ALI file is given on the command
  222. line.  Then it calls the Ada subprogram itself.  By default, this C function
  223. is called "main".  (For other options, see the section on options below.)
  224. The program gnatbind works by recursively processing the ALI files of all
  225. of the units that are needed.  These ALI files are found using the search
  226. path mechanism described below.  Since object and ALI files are always
  227. kept together, the object files needed for linking are found at the same
  228. time and are listed in a comment at the end of the bind file.  This is where
  229. gnatbl finds the list of object files required.
  230.  
  231. The options of gnatbind are summarized below. Normally gnatbind is called
  232. by default from gnatbl. If you want to invoke gnatbind explicitly with some
  233. of the options mentioned below, your invoke gnatbind with the options on the
  234. ali file and then invoke gnatbl with the -linkonly option so that the binder
  235. will not be called again.
  236.  
  237. Usage: gnatbind switches lfile
  238.  
  239.   -b      Generate brief messages to stderr even if verbose mode set
  240.   -c      Check only, no generation of binder output file
  241.   -e      Output complete list of elaboration order dependencies
  242.   -Idir   Specify library and source files search path
  243.   -l      Output chosen elaboration order
  244.   -mnnn   Limit number of detected errors to nnn (1-999)
  245.   -n      No main program
  246.   -o file give the Output name (default is b_xxx.c) 
  247.   -s      Require all source files to be present
  248.   -t      Ignore time stamp errors
  249.   -v      Verbose mode. Error messages,header, summary output to stdout
  250.   -wx     Warning mode. (x=s/e for suppress/treat as error)
  251.   -x      Exclude source files (check object consistency only
  252.   lfile   Library file names
  253.  
  254. Using gcc to compile.
  255. ---------------------
  256.  
  257. In the usual procedures for using GNAT, Ada source programs are compiled into
  258. object files using the driver program 'gcc' with the option '-c' (compile
  259. only). Gcc recognizes the ada filename extensions .ads and .adb (discussed
  260. more thoroughly below) and calls the actual compiler, 'gnat1' to compile
  261. the source file.  Gcc has many switches which you will need your gcc
  262. documentation to learn about.  In addition, gcc passes gnat1 switches
  263. through to gnat1.  These (with a couple of exceptional abbreviations) are
  264. spelled on the gcc command line by "-gnatXXX".  Thus
  265.  
  266.         gcc -c -gnata foo.adb
  267.  
  268. causes gcc to call the Ada compiler gnat1 with gnat1's '-a' switch; the '-c'
  269. is understood by gcc to mean that it is done after producing the object file
  270. (it won't try to link).  The output of this command is the object and ALI
  271. files for foo.
  272.  
  273. In the future, the gcc and the GNAT-specific switches will be more fully
  274. integrated.  At this time, there is the "-gnatXXX" mechanism for passing
  275. switches through to gnat1.  Some of these switches are described in
  276. specific sections of this document; a more complete discussion is in the
  277. options section below.  Note that gcc passes these switches to gnat1
  278. with the "gnat" prefix, where it is stripped off.  This means that
  279. when gnat1 is executed the "gnat" prefix is required; but in all of the
  280. documentation the switches are described without the prefix.
  281.  
  282. Three gcc options are translated to gnat1 arguments when seen on the gcc
  283. command line.  These are "k8" (file name limit), "83" (Ada83 syntax) and
  284. "w" (warning mode). Thus, the following commands are identical:
  285.  
  286.      gcc -ws -k8 file.adb
  287.      gcc -gnatws -gnatk8 file.adb
  288.  
  289. i.e., both of them suppress warning messages from GNAT, and expect file names
  290. to be 8 characters long at most (see below for usage).
  291.  
  292. In addition, the following gcc switches are passed through and recognized by 
  293. gnat1 with the same effects as in cc1 (as for C files): "-g*" (other than
  294. "-gnat*"); "-O*"; "-p"; "-pg"; "-f*"; "-d*"; "-S".  For example, 
  295.  
  296.       gcc -c -g math.adb
  297.  
  298. will generate debugging information that can be used with the debugger gdb
  299. (see below).
  300.  
  301. The other flags that control gcc itself (notably -B and -c) and the 
  302. assembler, behave as usual. Please consult your GCC documentation for details.
  303.  
  304.  
  305. Using gcc for syntax checking
  306. ------------------------------
  307.  
  308. The current release of GNAT implements the full Ada 95 grammar as described in 
  309. annotated Ada Reference Manual for Ada 95 (AARM, version 5.95). We think the
  310. parser gives excellent error messages (try it and see!) and is pleasantly 
  311. fast (again, try and see!).
  312.  
  313. To run GNAT in syntax checking only mode, use the switch "s",
  314. that is to say, enter the command:
  315.  
  316.     gcc -c -gnats file
  317.  
  318. where file is the name of the file to be checked. (Under Unix, wild cards can
  319. be used to check a set of files, as in *.adb.)  Note that the 'compile only'
  320. flag has to be given for gcc, as well as the 'syntax only' flag, which is
  321. GNAT-specific.  We will remove this redundancy in subsequent releases. 
  322.  
  323. The syntax checker is complete, and quite robust. If you manage
  324. to blow it up, or if it fails to diagnose an error, or lets a syntactically
  325. invalid program through, definitely let us know (see separate section below). 
  326. If you find an error message you think could be improved, let us know as well. 
  327. Of course, no compiler can ever have perfect error messages (that would involve
  328. mind reading), but we are committed to doing as well as possible, so we are
  329. happy to get suggestions in this department.
  330.  
  331. Using gcc for semantics checking
  332. --------------------------------
  333.  
  334. The command to perform semantic checking is:
  335.  
  336.     gcc -c -gnatc file
  337.  
  338. To operate in this mode, since WITH'ed files must be accessed, the GNAT
  339. semantic restrictions on file structuring must be followed:
  340.  
  341.      o    The needed source files must be accessible.  See the section
  342.         below on search paths.
  343.  
  344.      o    Each file must contain only one compilation unit.
  345.     See the section below on file name rules.
  346.  
  347.      o    The file name and unit name must match as described below, under
  348.         File name rules.
  349.  
  350. Note that the use of search paths and the flexibility of the File name
  351. rules will increase in the future as described in the sections on these
  352. facilities.
  353.  
  354. The coverage of semantic checks is still incomplete, and the system
  355. is not very robust in the presence of semantically illegal programs.
  356. Nevertheless, this release supports many more features of Ada 95 than the
  357. previous one, and semantic checking is correspondingly more extensive. 
  358.  
  359. Here, use of the 'report errors immediately' switch ("-e", i.e., "-gnate" on
  360. the gcc command line) will help pinpoint the source of the trouble if the
  361. system misbehaves. 
  362.  
  363. Search paths and the Run Time Library (RTL)
  364. -------------------------------------------
  365.  
  366. With GNAT's source based library system, the compiler must be able to
  367. find source files for units that are needed by the unit being
  368. compiled.  Also, during binding, ALI files are needed to do the
  369. required checking of compilation order and to determine elaboration
  370. requirements.  Botyh the compiler and binder use search paths to
  371. locate the files that they need. The rules are straightforward.
  372.  
  373. The compiler compiles one source file whose name must be givien explicitly
  374. on the command line (i.e. there is no searching done for this file).  All
  375. other source files that are needed (the most common being the specs of
  376. WITH'ed units) are found by looking in the following directories: 
  377.  
  378.    o The first directory searched is the directory containing the source
  379.      file of the main unit being compiled (the file name on the command
  380.      line). This directory is the current working directory only if the
  381.      input file contains no relative or absolute path
  382.      information. Otherwise if the input file is specified as dir/file
  383.      then the first directory searched is dir.
  384.  
  385.    o Next, the compiler looks in each directory named by a "-I" option
  386.      given to gcc (in the order given on the command line).
  387.  
  388.    o Then the compiler looks in each of the directories listed in the value
  389.      of the ADA_INCLUDE_PATH environment variable.  This value is constructed
  390.      exactly as the PATH environment variable -- a list of directory names
  391.      separated by ':' or ';' (Unix or OS/2, respectively) characters. Under
  392.      OS/2, this mechanism is used to locate the RTL source files in place of
  393.      the default location described next for Unix.
  394.  
  395.    o (Unix only) Finally the compiler looks in the default location for
  396.      the GNAT Run Time Library (RTL) source files that is determined at the
  397.      time that GNAT is built and installed on your system.
  398.  
  399. The compiler outputs its object files and ALI files in the current working
  400. directory (NOTE: the object file can be redirected with the -o option;
  401. however, gcc and gnat1 have not been coordinated on this so the ALI file
  402. will not go to the right place -- DON'T DO THIS).
  403.  
  404. The binder takes the name of an ALI file as its argument and needs to locate
  405. other ALI files in its recursive processing.  These are found in the
  406. following directories:
  407.  
  408.    o First, the current working directory is searched.
  409.  
  410.    o Next, the binder looks in directories named in "-I" options on the 
  411.      gnatbind command line (in the order given).
  412.  
  413.    o Next, the binder looks in each of the directories listed in the value
  414.      of the ADA_OBJECTS_PATH environment variable.  This value is constructed
  415.      exactly as the PATH environment variable -- a list of directory names
  416.      separated by ':' or ';' (Unix or OS/2, respectively) characters. Under
  417.      OS/2, this mechanism is used to locate the RTL object files in place of
  418.      the default location described next for Unix.
  419.  
  420.    o (Unix only) Finally the binder looks in the default location for
  421.      the GNAT Run Time Library (RTL) object files that is determined at the
  422.      time that GNAT is built and installed on your system.
  423.  
  424. If the binder is requested to locate source files (for time stamp
  425. verification) the source files are located using the mechanism for
  426. source files described above, that is the curent working directory is
  427. searched first, then the directories specified with -I, then those in
  428. ADA_INCLUDE_PATH, etc. The only difference being that because no
  429. source file is specified to the binder, the first directory which is
  430. searched for sources is the current working directory.
  431.  
  432. The binder generates the bind file (a C language source file) in the
  433. current working directory.
  434.  
  435. The packages Ada, System, and Interfaces and their children make up the GNAT
  436. Run Time Library, together with the simple System.IO package used in the "Hello
  437. World" example.  The sources for these units are needed by the compiler
  438. and are kept together in one directory (not all of the bodies are needed,
  439. but all of the sources are kept together anyway).  The ALI files and object
  440. files generated by compiling the RTL are needed by the binder and the linker,
  441. and are kept together in one directory (typically different from the
  442. directory containing the sources).  In a normal installation, the user will
  443. not need to specify these directory names when compiling or binding (or
  444. binding and linking with gnatbl -- though the call to the linker contains
  445. explicit pathnames of the object files).  Either the environment variables
  446. (OS/2) or the builtin defaults will cause these files to be found.
  447.  
  448. Besides the assistance in using the RTL, a major use of search paths is
  449. in compiling sources from multiple directories.  This can make development
  450. environments much more flexible.
  451.  
  452. The user might use the search paths to experiment with alternative RTLs, or
  453. to create new libraries (not the technical Ada meaning here).
  454.  
  455.  
  456. Options.
  457. --------
  458.  
  459. Error reporting, as well as other aspects of the behavior of the system,
  460. are controlled by the following flags. All of these must be entered with
  461. the prefix '-gnat'. For example, '-gnatv83' specifies verbose mode for
  462. output, and Ada83 syntax checking. 
  463.  
  464.   a      Assertions enabled. Pragma Assert and Debug to be activated.
  465.   b      Generate brief messages to stderr even if verbose mode set.
  466.   c      Check syntax and semantics only (no code generation attempted)
  467.   e      Error messages generated immediately, not saved up till end
  468.   f      Full errors. Normally only the first error on each line is reported.
  469.   g      GNAT style checks enabled - col alignment, spacing, capitalization.
  470.       See any source file for examples.
  471.   i?      Identifier char set (?=1/2/3/4/p/f/n/w) default = i1 (Latin-1)
  472.         1-4 = Latin 1-4, p = IBM PC, f/n = full/no, upper w=wide_character
  473.   j?     Wide character encoding method (?=n/h/u/s/e)
  474.   knnn      Limit file names to k characters (k = krunch)
  475.   l      Output full source listing with embedded error messages
  476.   mnnn      Limit number of detected errors to nnn (1-999)
  477.   n      No inlining of subprograms (ignore pragma Inline)
  478.   o       Enable integer overflow checking using range checks
  479.   p      Automatic suppression of all run-time checks mentioned in LRM 11.7
  480.   q       Don't quit, try semantics, even if parse errors
  481.   r      Reference manual column layout required
  482.   s      Syntax check only
  483.   t       Tree output file to be generated
  484.   u      List units for this compilation
  485.   v      Verbose mode. Full error output with source lines to stdout.
  486.   w?      Warning mode. s = suppress, e = treat as error
  487.   x?      Cross-reference level and switches (?=1/2/3/4/5/9/b/s)
  488.   z?      Distribution stub generation (r/s for receiver/sender stubs)
  489.   83      Enforce Ada 83 restrictions
  490.   sfile      Source file names (wild cards allowed for multiple files)
  491.  
  492. Some of these options are explained in more detail elsewhere in this document.
  493. For full information, refer to file usage.adb in this distribution.
  494.  
  495. For first-time users, and for first-compilation attempts, the following mode
  496. of operation is recommended:
  497.  
  498.       gcc -c -gnatc lets_try_this.adb
  499.  
  500.  
  501. gnatmake
  502. --------
  503.  
  504. In the following command line description we use BNF notation. Hence
  505. [X] means zero or one occurrence of X, while {Y} means zero, one or
  506. arbitrarily many occurrences of Y.
  507.  
  508.   gnatmake [-a] [-c] [-f] [-g] [-n] [-q] [-s] [-v] {[-Idirname] [-Ldirname]}
  509.            unit_or_file_name
  510.            {[-cargs options] [-bargs options] [-largs options]}
  511.  
  512. The purpose of gnatmake is to automatically determine and (re)compile
  513. the set of ada sources needed by some ada compilation unit, Unit.
  514. An ada source needed by Unit is recompiled if its corresponding
  515. object file is obsolete with respect to the current sources.
  516. By default the bind and link steps are also performed.
  517. There are two ways to specify the actual compilation unit:
  518.  
  519.   * By giving the lower case name of the compilation unit (`gnatmake unit')
  520.  
  521.   * By giving the name of the source containing it
  522.     (`gnatmake  file.adb' or `gnatmake  file.ads')
  523.  
  524. All gnatmake output is to stderr. 
  525.  
  526. [-a]
  527.    Consider all files. Considers all files in the make process, even
  528.    the GNAT internal system files (for instance the predefined Ada
  529.    library files). By default gnatmake does not check these internal
  530.    files (don't worry this is safe, if there is an installation
  531.    problem this will be caught when gnatmake binds your program).
  532.    You may have to set this switch if you are working on gnat itself.
  533.    For the vast majority of gnatmake users you never need to set this flag.
  534.  
  535. [-c]
  536.    Compile only. Do not perform the bind and link steps.
  537.  
  538. [-f]
  539.    Force recompilations. Recompile all sources even though some object
  540.    files may be up to date but don't recompile predifined units if up
  541.    to date. If a predified unit is not up to date, then recompile it.
  542.  
  543. [-g]
  544.    Compile with debugging information. Same effect as -cargs -g -largs -g.
  545.    See below for meaning of -cargs & -largs.
  546.  
  547. [-n]
  548.    Don't compile, bind or link. Issue a (maybe innacurate) list of
  549.    commands without actually executing them by guessing from the old
  550.    ali (ada library information). Note that this information is
  551.    imprecise, because no recompilations are actually carried out.
  552.    However, if `gnatmake -n' reports no recompilations needed then the
  553.    user is guaranteed that the objects are up to date.
  554.    If, during the process, any ali is missing gnatmake is halted and
  555.    an error message emitted.
  556.         
  557. [-q]
  558.    Quiet. Without this flag set the commands carried out by gnatmake
  559.    are displayed. If -q is set, they are not.
  560.  
  561. [-s]
  562.    Smart. Performs smart recompilations.
  563.    See section on smart gnatmake below.
  564.  
  565. [-v] 
  566.    Verbose. Motivates all (re)compilations (ie gives *one* reason for
  567.    (re)compiling a source file).
  568.  
  569. [-Idirname]
  570. [-Ldirname]
  571.    Recognized but not yet implemented.
  572.  
  573. [-cargs options] 
  574.    Compiler arguments. Without -cargs, gnatmake simply uses "gcc -c"
  575.    to perform compilations. Otherwise gnatmake uses "gcc -c c_opts".
  576.    `c_opts' is a list of parameters. This list includes all the
  577.    options encoutered in the set of `-cargs options' present on the
  578.    gnatmake command line. A given sublist of `-cargs options' is
  579.    terminated upon encounter of another -cargs, -bargs or -largs.
  580.    Note that by default `gnatmake -a' (see flag -a above) compiles all
  581.    GNAT internal files with "gcc -c -gnatg" rather than just "gcc -c".
  582.    
  583. [-bargs options]
  584.    Binder arguments. Without -bargs, gnatmake simply uses
  585.    "gnatbind unit.ali" to bind. Otherwise gnatmake uses
  586.    "gnatbind b_opts unit.ali". `b_opts' is akin to `c_opts' above but
  587.    is obtained from `-bargs options'.
  588.  
  589. [-largs options]
  590.    Linker arguments.  Without -largs, gnatmake simply uses
  591.    "gnatbl -linkonly unit.ali" to link. Otherwise gnatmake uses
  592.    "gnatbl -linkonly l_opts unit.ali". `l_opts' is akin to `c_opts'
  593.    and `b_opts' above but is obtained from `-largs options'.
  594.  
  595. NOTES: 
  596.  
  597. 1. If the user types "gnatmake file.adb" where file.adb is a
  598. subunit or body of a generic unit, then gnatmake will recompile
  599. file.adb systematically because it finds no ali and then will stop
  600. issuing a warning.
  601.  
  602. 2. gnatmake does not examine .o files, only .ali files, so deleting .o
  603. files will not force a recompilation. You can force everything to be
  604. recompiled either by deleting the .ali files or by using the -f option.
  605.  
  606. Smart gnatmake
  607. --------------
  608.  
  609. Not implemented yet. Coming to your local ftp site soon.
  610.  
  611.  
  612. Constraint Checking and Pragma Suppress
  613. ---------------------------------------
  614. In the current version there are some checks performed that are mentioned in
  615. the LRM in section 11.7. These are:
  616.  
  617. range checks on signed integer and enumeration types
  618.   (assignment, in parameters and initial values in object declarations)
  619. index checks
  620. access checks
  621.  
  622. Since this is relatively new, there might still be some cases where exceptions
  623. are raised where they shouldn't. To disable constraint checks, compile the
  624. program with the "-gnatp" option. This is equivalent to having Pragma suppress
  625. applied to everything. Gdb can be used to find where the exception was raised.
  626. See the section on  "Using gdb" for further information.
  627.  
  628. Arithmetic Overflow Checking
  629. ----------------------------
  630.  
  631. Compiling with the default options results in code that performs range
  632. checking against constraints (see -gnatp for suppressing such checks).
  633. However, the default mode does not enable checking for arithmetic overflow
  634. and division by zero.
  635.  
  636. If this checking is required, then the -gnato switch should be set. This
  637. causes appropriate additional code to be generated to check for both
  638. overflow and division by zero (resulting in raising Constraint_Error as
  639. required by the Ada semantics).
  640.  
  641. Note that the -gnato switch does not affect the code generated for any
  642. floating-point operations; it applies only to integer operations. For
  643. floating-point, GNAT has Machine_Overflows set to False, and the normal
  644. mode of operation is to generate IEEE NaN and infinite values on overflow
  645. or invalid operations (such as dividing 0.0 by 0.0)
  646.  
  647. The checks generated by -gnato are quite expensive, which is why they
  648. are not the generated by default. This is because GCC does not yet use
  649. specialized hardware features (flags, sticky flags, traps etc.) for the
  650. detection of integer overflow. Eventually we plan to implement more
  651. efficient integer overflow checking in the future.
  652.  
  653. Order of Compilation Issues.
  654. ----------------------------
  655.  
  656. If, in our example, there were a spec for the hello procedure, it would
  657. be contained in the file "hello.ads"; yet this file would not need to be
  658. explicitly compiled.  This is the result of the model we chose to implement
  659. library management. Details of the model can be found in file gnote1. Some of
  660. the unexpected consequences of the model (unexpected from the point of view
  661. of existing Ada compiler systems) are the following: 
  662.  
  663.      o    There is no point in compiling generics or specifications (except for
  664.     package specifications with no bodies), since these are compiled as
  665.     needed by clients. If you do attempt a useless compilation, you will
  666.     get a warning message. It is also useless to compile subunits in this
  667.     mode, since they are compiled as needed by the parent.
  668.  
  669.      o    There are no order of compilation requirements, and performing a
  670.     compilation never obsoletes anything. The only way you can obsolete
  671.     something and require recompilations is if one of the relevant source
  672.     files is modified.
  673.  
  674.      o    There is no library as such, apart from the .ali files, whose format 
  675.     is also described in libfmt.ads. For now, we find it convenient to
  676.     create separate .ali files, but eventually the information therein may
  677.     be incorporated into the object file directly.
  678.  
  679.      o    When you compile a unit, the source files for the specs of all 
  680.     units that it WITH's, all its subunits, and the bodies of any
  681.     generics it instantiates must be around (findable by the search
  682.         paths mechanism described above), or you will get a fatal error
  683.     message.
  684.  
  685. The above may seem surprising. Just to provide one immediate assurance,
  686. all of this does not mean that we are violating Ada's strict consistency 
  687. rules; they are enforced instead by the binder. 
  688.  
  689. File Name Rules
  690. ---------------
  691.  
  692. The current version of GNAT requires that file names match compilation unit
  693. names. The matching rules are as follows:
  694.  
  695.      o    The file name is obtained by replacing dots in the unit name with
  696.     minus signs, and adding a suffix distinguishing bodies and specs.
  697.     The suffix for specs is ".ads" and for bodies is ".adb".
  698.  
  699.     For example, files containing the unit very_long_unit_name would be
  700.         called:
  701.  
  702.         very_long_unit_name.ads
  703.         very_long_unit_name.adb
  704.  
  705.     on systems supporting long file names.
  706.  
  707.      o    When running under systems which permit only short file names,
  708.         (like DOS and OS/2 under FAT) the file name itself needs to be
  709.         crunched to 8 characters. You can always find out the name it expects
  710.     by running gnatk8 or compiling it (since it warns you if it's wrong).
  711.  
  712.         So in DOS or OS/2 under FAT the filenames above would be crunched to:
  713.             velounna.ads
  714.             velounna.adb
  715.  
  716.         (The full details of the crunching algorithm are in source code of
  717.          krunch.ads and krunch.adb)
  718.  
  719.      Under DOS -gnatk8 is the default, so crunching always takes place.
  720.      On all systems the RTL files are all crunched to 8 characters.
  721.  
  722. Gnatk8.
  723. -------
  724.  
  725. As mentioned in the previous section, gnatk8 can be used to find out what
  726. the krunched name of a file should be when using the -k8 (-gnatk8) option.
  727.  
  728. The first argument can now be an Ada name with dots or it can be the Gnat
  729. name of the unit where the dots representing child units or subunit are
  730. replaced by hypens. The only confusion arises if a name ends .ads or
  731. .adb, and we take this to be an extension if there are no other dots in the
  732. name and the whole name is in lower case.
  733.  
  734. The second argument represents the length of the krunched name. The default
  735. without any argument given is 8 characters. A length of zero stands for
  736. unlimited, i.e. no chop except for system files which are always 8.
  737.  
  738. Examples:
  739.    gnatk8 very_long_unit_name.ads       ---->  velounna.ads
  740.    gnatk8 very_long_unit_name.ads 6     ---->  vlunna.ads
  741.    gnatk8 very_long_unit_name.ads 0     ---->  very_long_unit_name.ads
  742.    gnatk8 grandparent-parent-child.ads  ---->  grparchi.ads
  743.    gnatk8 grandparent.parent.child      ---->  grparchi
  744.  
  745. Note:
  746.    gnatk8 grandparent.parent.child.adb  -----> grpachad
  747. Here the .adb at the end is taken as part of the unit name as explained in
  748. one of the preceeding paragraphs above.
  749.  
  750. Compiling Files With Several Compilation Units.
  751. -----------------------------------------------
  752.  
  753. GNAT can only deal with files that contain a single Ada compilation unit.
  754. However, since it is an established style for certain types of programs
  755. to contain more than one compilation in a file, such as in test suites,
  756. a simple utility program, "gnatchop", is provided to preprocess the file
  757. and split it several other files, one for each compilation unit.
  758. gnatchop takes a filename with any extension. This name can basically
  759. be anything.
  760.  
  761. Usage : gnatchop [-k] [-r] [-s] [-w] filename [directory]
  762.  
  763.   k         limit filenames to 8 characters
  764.   r         generate source reference pragmas
  765.   s         generate a compilation script
  766.   w         overwrite existing filenames
  767.   filename  source file
  768.   directory directory to place split files (default is the current directory)
  769.  
  770. For example, assume archive contains package spec part1, package body
  771. part1, package spec part2, package body part2.adb and subprogram part3 in
  772. any sequence.
  773.  
  774. "gnatchop archive" will create five files in the current directory called
  775. part1.ads, part1.adb, part2.ads, part2.adb, part3.adb. The optional directory
  776. argument places all the split files in that directory rather than the current
  777. directory. The directory must already exist otherwise gnatchop will reject it.
  778.  
  779. If at least one of the files to be split already exists, gnatchop will issue a
  780. message and exit unless the -w flag is used to overwrite existing files.
  781.  
  782. The -r flag causes source reference pragmas to be generated at the start of
  783. each file written. These pragmas will cause error message references and
  784. debugging source information to refer back to the original unchopped files.
  785. This is appropriate if you intend to maintain the program in unchopped form.
  786.  
  787. The -s flag generates a script which can be used to compile all the units
  788. contained in the original source file.
  789.  
  790.   Suppose that you wanted to compile all the units contained in a given file
  791.   called "archive" with some specific options like -gnatv, -O2 and -g. The
  792.   gnatchop with -s option will generate a script with the appropriate
  793.   extension depending on the the operating system. Then the script is
  794.   invoked with the options following at the end as given below.
  795.  
  796.   gnatchop -s archive
  797.   In Unix:  sh archive.sh -gnatv -O2 -g 
  798.   In Dos :  archive.bat -gnatv -O2 -g
  799.   In OS/2:  archive.cmd -gnatv -O2 -g
  800.  
  801. The -k flag krunches the names of the units to be 8 characters followed by the
  802. ads or adb extension.
  803.  
  804. Currently, if you want to specify more than one flag, you need to specify
  805. them separately.  For example, if you want to split archive.adb and specify
  806. both the -s and the -w flags, type "gnatchop -s -w archive" instead of
  807. "gnatchop -sw archive". This limitation will be lifted in the near future.
  808.  
  809. Note: gnatchop works fine for the case of a single compilation unit in a
  810. file, and this is useful in dealing with files that do not have names
  811. satisfying the GNAT naming requirements.
  812.  
  813. Cross Reference Tool.
  814. ---------------------
  815.  
  816. The GNAT system provides a standalone tool, gnatf, which allows for
  817. syntax and semantics checking without any code generation. This is
  818. somewhat faster than using "gcc -gnatc". 
  819.  
  820. Note: the standard gnat options that do not concern code generation are
  821.       still available in gnatf. However, they should not be preceeded by
  822.       -gnat, so to do syntax only checking with gnatf, use `gnatf -s file.adb'
  823.       not `gnatf -gnats file.adb'.
  824.  
  825. The real point of gnatf is that it contains a cross reference (xref)
  826. tool.  The goal of the xref tool is:
  827.  
  828.  1. Give precise information about all declared entities
  829.     (where they are defined and where they are used).
  830.     This is particularly useful in the ada emacs mode
  831.     that you will find with the distribution (see Ada Emacs
  832.     Mode below).
  833.  
  834.  2. Emit warnings if an entity is defined but never used or
  835.     a with clause is unnecessary, misplaced or redundant
  836.     (more on this later).
  837.  
  838.  3. In the future this tool will be the backbone of a smart
  839.     recompilation system which should reduce the number of
  840.     recompilations in the event of minor source code
  841.     modifications.
  842.  
  843. Usage : gnatf [-x[1-6]] files
  844.  
  845.   files The list of Ada source files to cross reference.
  846.  
  847. -x[1-6] The -x[1-6] flags control the amount of information given
  848.         by the xref tool. Flags -x1 and -x2 control the level of
  849.         warnings generated. These warnings are output on standard
  850.         error (usually the screen). Flags -x1 and -x2 do not cause
  851.         any cross reference information to be generated.
  852.         Flags -x[345] distribute cross reference information across
  853.         several files. Specifically for each file "f.adb" (resp. "f.ads")
  854.         in the `files' list we create a file "f.xrb" (resp. "f.xrs")
  855.         containing all cross reference information (more on this below).
  856.     Flag -x6 centralizes and stores this information in the single
  857.         file "X.ref".
  858.  
  859. Flags usage:
  860.  
  861.   -x1       Issues warnings for unnecessary, misplaced or redundant
  862.             ``with'' clauses. Specifically, a warning message is
  863.             generated in the following cases:
  864.  
  865.               - A compilation unit which is withed but never used
  866.                 (this works with child library units as well).
  867.  
  868.               - A compilation unit which is withed in a body (resp.
  869.                 subunit) if the same with clause already appears in
  870.                 the spec (resp. spec or body for subunits).
  871.  
  872.               - A compilation unit which is withed within a spec
  873.                 but is used only by the body or a subunit.
  874.  
  875.   -x2       Issues warnings on unused entities, that is entities that
  876.             are declared but never used. Note that we give *no*
  877.             warnings for unreferenced entities like:
  878.  
  879.               - Record fields, since they could be referenced indirectly
  880.                 by an aggregate.
  881.  
  882.               - Enumeration entities, since they could be referenced
  883.                 indirectly by enumeration ranges:
  884.                      for i in Color'First .. Color'Last
  885.  
  886.               - Loop parameters
  887.                     for I in 1 .. 80 loop
  888.                        Put ('x');
  889.                     end loop;
  890.  
  891.   -x[345]   Generate cross-reference information. Flag -x3 gives the most
  892.             succint xref information, -x5 the most comprehensive. Flag -x4
  893.             gives more information than -x3 but not as much as -x5. The
  894.             information given by flags -x3 and -x4 will be used in the smart
  895.             recompilation system currently under development and will
  896.             be described hereafter. Flag -x5 lists all entities defined or
  897.             used in the analyzed compilation units. It gives the source
  898.             location of their definition and all their uses in the analyzed
  899.             units.
  900.  
  901.   -x6       The cross reference output is the same as with -x5 except that
  902.             with -x6 all cross reference information is stored in the single
  903.             file "X.ref" and the entity kind of each cross referenced entity
  904.             is also given.
  905.  
  906. Cross reference information and smart recompilation
  907.  
  908.   The cross reference information gathered by flags -x3 and -x4 is a
  909.   subset of the information specified by flag -x5. The -x[34]
  910.   information is specifically tailored to the smart recompilation system
  911.   currently under development.  When flags -x3 or -x4 are selected, then
  912.   for each compilation unit "Unit" analyzed by the xref tool we gather
  913.   the following information:
  914.  
  915.     * The full graph of the source files directly or indirectly loaded as
  916.       a result of compiling "Unit" along with their time stamp. This graph
  917.       includes the with-ed unit graph rooted at "Unit" but contains also
  918.       other units automatically loaded by gnat during code generation
  919.       (generic bodies, subunits, bodies of inlined subprograms). This graph
  920.       is created only for flags -x[345].
  921.  
  922.     * The list of entities that can be exported from "Unit" to other Ada
  923.       sources along with their line and column of definition and use in
  924.       "Unit".
  925.  
  926.       If "Unit" is a subprogram or package spec, the notion of exported
  927.       entity matches the set of entities listed therein. If "Unit" is a
  928.       package body with no generics or inlined subprograms then no entities
  929.       are exported. In general, however, the set of entities exported from
  930.       "Unit" is the set of entities that are needed across compilation units
  931.       by gnat when generating code. Specifically inlined subprogram bodies
  932.       or generic bodies are always exported since these are inlined at the
  933.       point of use or instantiation. The same happens for subunits, which are
  934.       inlined in the parent unit.
  935.  
  936.       The difference between flags -x3 and -x4 is that -x3 omits all
  937.       generic bodies or inlined subprograms from the exported entities,
  938.       while flag -x4 includes them. Both -x3 and -x4 consider subunits as
  939.       exported entities.
  940.  
  941.       In addition we only consider outermost visible entities to be
  942.       exported. That is a record or enumeration type may be exported but its
  943.       inner fields or enumeration literals are never considered exported
  944.       entities. Likewise for subprogram parameters and discriminants.
  945.  
  946.     * The list of entities *directly* imported by "Unit" from other Ada
  947.       sources, along with their lines and columns where they are used in
  948.       "Unit".
  949.  
  950.       The notion of imported entities falls off the notion of exported
  951.       entities (what is exported by one unit may be imported by another).
  952.  
  953. Cross reference file structure:
  954.  
  955.   The xref file is divided into various sections. There is one section
  956.   for each compilation unit explicitly requested in `files'. We
  957.   call these units, the RUs, short for requested units.  There is also
  958.   one section for each AU, short for auxiliary unit, that is, those
  959.   compilation units that get implicitly loaded by the compiler, but
  960.   whose compilation has not been explicitly requested by the user.
  961.   Specs of withed packages are typical auxiliary units.
  962.  
  963.   All entities exported by RUs (flags -x3 and -x4) or all entities
  964.   belonging to RUs (flags -x5 and -x6) appear in the xref file(s).
  965.  
  966.   However, only the entities defined in AUs that are imported in RUs
  967.   appear in the xref file. Their order is the order of declaration in
  968.   the source files.
  969.  
  970.   The sections in the xref referring to RUs and AUs are respectively denoted:
  971.  
  972.             %% unit.ad[sb]     for a RU.
  973.  
  974.             -- unit.ad[sb]     for an AU.
  975.  
  976.   Note: An entitiy defined inside a generic and used through a generic
  977.   instantiation, is listed under the xref section of the generic unit.
  978.  
  979.   Example: Follows a list of files and the corresponding cross reference.
  980.   ^^^^^^^
  981.                         test.adb
  982.                         ^^^^^^^^
  983.             01  with Part1;  --  unused
  984.             02  with Part2; use Part2;
  985.             03  procedure Test is
  986.             04
  987.             05     Thing : Number;
  988.             06     type Client is record
  989.             07        Number : Integer;
  990.             08        State  : Boolean;
  991.             09     end record;
  992.             10     type Color is (Red, Green);  -- unused
  993.             11     My_Client : Client;
  994.             12
  995.             13  begin
  996.             14     My_Client.Number := 1;
  997.             15     My_Client.State  := True;
  998.             16     Thing := 20;
  999.             17     Thing := Thing + Thing;
  1000.             18  end;
  1001.                       part1.ads
  1002.                ^^^^^^^^^
  1003.             01  package Part1 is
  1004.             02     type Useless is new Integer;
  1005.             03  end;
  1006.                       part2.ads
  1007.                   ^^^^^^
  1008.             01  package Part2 is
  1009.             02     type Number is new Integer range 1 .. 1000;
  1010.             03     The_Number : constant := 42;
  1011.             04  end;
  1012.  
  1013.   The result of invoking `gnatf -x5 test.adb' is the following
  1014.   (just skim the "test.xrb", explanations follow):
  1015.  
  1016.                     Warnings on stderr (the screen)
  1017.                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  1018.              test.adb:1:06: warning: "Part1" withed but unused.
  1019.              test.adb:3:11: warning: "Test" unused
  1020.              test.adb:10:09: warning: "Color" unused
  1021.  
  1022.                            test.xrb
  1023.                            ^^^^^^^^
  1024.              01 V "SGNAT v1.0      "
  1025.              02 test.adb                941012154746 2 3 
  1026.              03 part1.ads               941012154531 
  1027.              04 part2.ads               941012154620 
  1028.              05 
  1029.              06 %% test.adb
  1030.              07 test 3:11 
  1031.              08 thing 5:4 
  1032.              09  {16:4 17:4 17:13 17:21}
  1033.              10 client 6:9 
  1034.              11  {11:16}
  1035.              12 client.number 7:7 
  1036.              13  {14:14}
  1037.              14 client.state 8:7 
  1038.              15  {15:14}
  1039.              16 color 10:9 
  1040.              17 red 10:19 
  1041.              18 green 10:24 
  1042.              19 my_client 11:4 
  1043.              20  {14:4 15:4}
  1044.              21 
  1045.              22 -- part1.ads
  1046.              23 part1 1:9 
  1047.              24  {1:6}
  1048.              25 
  1049.              26 -- part2.ads
  1050.              27 part2 1:9 
  1051.              28  {2:6 2:17}
  1052.              29 number 2:9 
  1053.              30  {5:14}
  1054.  
  1055.   Explanations:
  1056.   ^^^^^^^^^^^^
  1057.   File "Test" is the only RU (requested unit). AUs (auxiliary
  1058.   units are packages "Part1" and "Part2". First the graph of
  1059.   the loaded units with their time stamps is given
  1060.  
  1061.              02 test.adb                941012154746 2 3 
  1062.              03 part1.ads               941012154531 
  1063.              04 part2.ads               941012154620 
  1064.  
  1065.   Unit "Test" requires the loading of units "Part1" and "Part2"
  1066.   (the second and third units listed in the inclusion graph).
  1067.   Entry:
  1068.              06 %% test.adb
  1069.              07 [...]
  1070.              08 thing 5:4 
  1071.              09  {16:4 17:4 17:13 17:21}
  1072.  
  1073.   means that "Thing" is an entity (a variable) defined in line 5
  1074.   column 4 and used in line 16 column 4, line 17 columns 4, 13 and 21
  1075.   in file "test.adb". 
  1076.  
  1077.   Note that entity "Useless" may be used in units other than "Test"
  1078.   but that information is not contained in the "test.xrb" since "Test"
  1079.   does not use "Useless".
  1080.  
  1081. Implementation of Intrinsic Functions.
  1082. --------------------------------------
  1083. GNAT version 1.79 begins to implement intrinsic functions. In particular,
  1084. the shift functions predefined in Interfaces are now implemented.
  1085.  
  1086. The implementation is quite general. You can define shift operations (i.e.
  1087. one of the five operations, Shift_Left, Shift_Right, Shift_Right_Arithmetic,
  1088. Rotate_Left, Rotate_Right) on any integer type, signed or unsigned, whose
  1089. Size is 8, 16, 32 or 64 bits, and then provide an appropriate pragma Import
  1090. Intrinsic, and everything will work.
  1091.  
  1092. In other words, the package Interfaces is not using any special magic, and
  1093. you can do exactly what it does to make shift operations available for any
  1094. integer types that meet the size criteria (shift operations for wierd-sized
  1095. integers seem too marginal to worry about!)
  1096.  
  1097. Example:
  1098.  
  1099.    type My_Type is new Integer;
  1100.  
  1101.    function Shift_Left (Val : My_Type; Count : Natural) return My_Type;
  1102.    pragma Import (Intrinsic, Shift_Left);
  1103.  
  1104. The exact requirements on the pragma Import are as follows:
  1105.  
  1106.   The function must have one of the five standard names
  1107.  
  1108.   There must be two arguments
  1109.  
  1110.   The first argument can be of any integer type with a size of 8, 16, 32, 64
  1111.   either signed or unsigned.
  1112.  
  1113.   The return type must be the same as the first argument type
  1114.  
  1115.   The second argument (the shift count), can be of any integer type
  1116.  
  1117. Getting Internal Debugging Information.
  1118. ---------------------------------------
  1119.  
  1120. Most compilers have secret internal debugging switches and modes. GNAT is
  1121. no exception, except that nothing about GNAT is secret. A summary and full
  1122. description of all the compiler/binder debug flags can be found in the file
  1123. debug.adb. You will have to get the sources of the compiler to see the full
  1124. detailed effects of these, but feel free to experiment with them.
  1125.  
  1126. The switches that print the source of the program (reconstructed from the
  1127. internal tree) are of general interest, as are the options to print the full
  1128. internal tree, and the entity table (that is to say, the symbol table
  1129. information). 
  1130.  
  1131. When GNAT crashes. 
  1132. ------------------
  1133.  
  1134. There are several things you can do when GNAT does the unexpected while
  1135. compiling your Ada program, such as aborting with a segmentation fault
  1136. or illegal memory access, raising an internal exception, or otherwise
  1137. terminating abnormally. The following lines of action are of course
  1138. palliatives that will become unecessary as the system becomes more complete
  1139. and robust. The following strategies are presented in increasing order of
  1140. difficulty, corresponding to the sophistication of the user, and her
  1141. curiosity about the functioning of the compiler.
  1142.  
  1143.   1. run gcc with the -gnatf and -gnate switches.
  1144.      The 'f' switch causes all errors on a given line to be reported. In
  1145.      its absence, only the first error on a line is displayed. 
  1146.  
  1147.      The 'e' switch causes errors to be displayed as soon as they are 
  1148.      encountered, rather than after compilation is terminated.
  1149.  
  1150. Often this will be enough to identify the construct that produced the crash.
  1151.  
  1152.   2. run gcc with -v (verbose) switch. In this mode, gcc produces ongoing 
  1153.      information about progress of the compilation and in particular the name 
  1154.      of each procedure as it begins to generate code for it. This switch
  1155.      allows you to find which Ada procedure it was compiling when it ran into 
  1156.      a code generation problem. 
  1157.  
  1158.   3. run gcc with the -gnatdc switch. This is a GNAT-specific switch that
  1159.      does for the front-end what -v does for the back-end. The system prints
  1160.      the name of each unit, either compilation unit or nested unit, as it
  1161.      is being analyzed. 
  1162.  
  1163.   4. On systems that have gdb available (like most Unix systems), you can run
  1164.      gdb directly on the gnat1 executable. Gnat1 is the front-end of
  1165.      GNAT, and can be run independently (normally it is just called from gcc).
  1166.      You can use gdb on gnat1 as you would on a C program (but see below for
  1167.      caveats). The "where" command is the first line of attack; the variable
  1168.      "lineno"  (seen by "print lineno") used by the second phase of gnat1
  1169.      and by the gcc back-end, indicates the source line at which the execution
  1170.      stopped, and "input_filename" the name of the source file.
  1171.  
  1172. Using gdb
  1173. ---------
  1174.  
  1175. Gdb awaits modifications to handle Ada properly, and for now can only be
  1176. used as it would be for a c program. (Someone is working on the proper
  1177. extensions, and these will appear in subsequent releases.) In the meantime,
  1178. the following naming conventions will allow you to find the Ada entities
  1179. defined in your program:
  1180.  
  1181. a)  The names of all entities (variables, subprograms, etc.) are converted to
  1182.     lower case. 
  1183.  
  1184. b)  Entities that appear in library package declarations have the name
  1185.     package_name__subprogram_name (Note the two underscores separating 
  1186.     package name from subprogram name). 
  1187.  
  1188. Exceptions can be caught by breaking in the "__gnat_raise" routine and then
  1189. doing a "bt" or "where" command.
  1190.  
  1191. GNAT specific pragmas
  1192. ---------------------
  1193. Full documentation of the GNAT specific pragmas can be found in the GNAT
  1194. source file sem_prag.adb. You need to retrieve the latest source distribution
  1195. to view this file.
  1196.  
  1197. New WARNING messages related to accessibility checks and private packages
  1198. -------------------------------------------------------------------------
  1199. GNAT version 2.05 implements two new checks that we anticipate will cause
  1200. some problems to existing programs.
  1201.  
  1202. First, static accessibility checks are implemented. These catch two common
  1203. errors:
  1204.  
  1205.    Improper use of 'Access attribute. These can usually be "corrected" by
  1206.    the use of 'Unchecked_Access in the variable case, but good Ada style
  1207.    says that the use of 'Unchecked_Access should be restricted, just like
  1208.    the use of Unchecked_Conversion. Unchecked_Access can lead to dangling
  1209.    pointers, and at the least careful analysis is needed.
  1210.  
  1211.    The invalid use of 'Access for subprograms is harder to fix in a
  1212.    "legitimate" manner. GNAT provides the 'Unrestricted_Access attribute
  1213.    that can be applied to subprograms in defiance of the accessibility
  1214.    rules (e.g. to create downward closures), but this attribute is not
  1215.    portable, and, as described by Bob Duff "naughty". So think twice at
  1216.    least before casually "fixing" your problem this way. Dangling
  1217.    subprogram pointers are particularly unpleasant. Another alternative
  1218.    is to use a generic, and pass the subprogram as a generic formal
  1219.    subprogram.
  1220.  
  1221.    The other common error is the derivation of a tagged type at a deeper
  1222.    nesting level than the parent type. This is also illegal (because it
  1223.    could cause dangling hidden subprogram pointers in dispatch tables).
  1224.    GNAT is not about to provide a way around this error, you must
  1225.    restructure your program. The simplest approach is to define all
  1226.    tagged types at the library level.
  1227.  
  1228.    Note in particular that all controlled types are derived from library
  1229.    level types, and so can only be declared at the library level. This is
  1230.    such a common case, that we have special-cased the error message.
  1231.  
  1232. The second new check is for the (mis)use of private packages. This caused
  1233. some unwelcome surprises in the GNAT code itself. Again, the only proper
  1234. remedy is to restructure (or possibly reconsider the use of private
  1235. packages). The critical rule is that specs cannot with a private package
  1236. unless they are themselves private.
  1237.  
  1238. We are thinking of introducing a pragma that would provide some protection
  1239. for withing packages that are not intended to be public, but are needed in
  1240. specs, stay tuned!
  1241.  
  1242. Meanwhile, in version 2.05, these error messages are warnings, but take care,
  1243. they are really illegalities, and in 2.06 they will be changed to be error
  1244. messages instead of warnings, so you have one version to clean up your act
  1245. with respect to accessibility and private packages!
  1246.  
  1247. Features supported/unsupported
  1248. ------------------------------
  1249. A full listing of features supported/unsupported is available separately in
  1250. the file "features" included in the distribution. Note that this usually
  1251. changes with each distribution, so read often.
  1252.  
  1253. Files.
  1254. ------
  1255.  
  1256. If you want to examine the workings of the GNAT system, the following
  1257. haiku-like description of its organization might be of minimal use:
  1258.  
  1259. File with prefix "sc" contain the lexical scanner.
  1260.  
  1261. All files prefixed with "par" are components of the parser. The numbers 
  1262. correspond to chapters of the Ada 83 LRM (or the corresponding sections of 
  1263. the Ada 95 LRM).  For example, parsing of select statements can be found 
  1264. in par-ch9.
  1265.  
  1266. All files prefixed with "sem" perform semantic analysis. Same numbering scheme.
  1267. For example, all issues involving context clauses can be found in sem_ch10.
  1268.  
  1269. All files prefixed with "exp" perform AST normalization and expansion. 
  1270. For example, the construction of record initialization procedures is 
  1271. done in exp_ch3.
  1272.  
  1273. The files prefixed with "bind" implement the binder, which verifies the
  1274. consistency of the compilation, determines an order of elaboration, and
  1275. generates the bind file.
  1276.  
  1277. The file atree details the low-level data structures used by the front-end.
  1278. The file sinfo details the structure of the AST as produced by the parser.
  1279. The file einfo details the attributes of all entities, computed during
  1280. semantic analysis.
  1281.  
  1282. Library management issues are dealt with in files with prefix "lib".
  1283.  
  1284. Files with prefix a- are GNAT-specific C files. They are the components of
  1285. Gigi (gnat-to-gnu), the program that translates the Ada AST into gcc tree 
  1286. fragments. Gigi makes use of C versions of atree, einfo and sinfo, called 
  1287. a-atree.[ch], a-einfo.[ch] and a-sinfo.h respectively.
  1288.  
  1289. All the other .c files are modifications of common GCC files. 
  1290.  
  1291. Happy browsing!
  1292.  
  1293. Ada Mode for Emacs
  1294. ------------------
  1295.  
  1296. In the subdirectory `emacs-ada-mode' you will find a bunch of files
  1297. implementing an Ada mode under Gnu emacs. The mode is still under
  1298. development, but a number of features are complete. For instance, the
  1299. Ada mode has the same indenting friendliness that C programmers get
  1300. with the c-mode, you can toggle between spec and body with a few
  1301. keystrokes, etc. This mode also uses gnatf to be able to point to an
  1302. entity with the mouse, click it and open a window with its definition.
  1303. This mode is copywrited by Markus Heritsch and Rolf Ebert.
  1304.  
  1305. Copyright Considerations
  1306. ------------------------
  1307.  
  1308. For now, everything is copyrighted by NYU, using the GNU public license. This
  1309. means that you can copy everything freely, but you can't incorporate the code
  1310. directly into a commercial program. For more information on the GNU license,
  1311. see the file header. One important note is that it will be possible
  1312. to use GNAT to generate software that is not itself covered by the GNU license.
  1313. Eventually the copyright will be transferred to the Free Software Foundation,
  1314. so that GNAT can be distributed directly by FSF under the same restrictions (or
  1315. what we like to think of as lack of restrictions!).
  1316.  
  1317. How to Get in Touch with Us
  1318. ---------------------------
  1319.  
  1320. To get on our external INTERNET mailing list, send a message to:
  1321.  
  1322.     gnat-request@cs.nyu.edu
  1323.  
  1324. Submitting Bug Reports
  1325. ======================
  1326.  
  1327. We welcome bug reports, they are of course a vital part of the process of
  1328. getting GNAT into solid shape. You will help us (and make it more likely
  1329. that you receive a timely response) if you follow these guidelines.
  1330.  
  1331. We only receive bug reports by internet, addressed to gnat-report@cs.nyu.edu.
  1332. At the moment we cannot process bug reports from any other source.
  1333.  
  1334. Note: if you believe you have found a GCC (C language or configuration
  1335. file) bug rather than an GNAT (Ada language) bug please report it to
  1336. bug-gcc@prep.ai.mit.edu.  If you have found a bug when using GCC to
  1337. compile C++, please report it to bug-g++@prep.ai.mit.edu.
  1338.  
  1339. Please put one bug in a message, and add a short but specific subject (a
  1340. general subject like "GNAT bug" is not so useful, a title like "bug in
  1341. visibility with generics" is more useful).
  1342.  
  1343. Please include full sources. We can't duplicate errors without the full
  1344. sources. Include all sources in the single email message with appropriate
  1345. indications in the multiple file cases, see below.
  1346.  
  1347. Please send all sources in plain ASCII form, we can't process compressed,
  1348. uuencoded etc. messages in our current form (they have to go through extra
  1349. steps, and easily get lost, separated from the author etc during this process).
  1350.  
  1351. Please include COMPLETE identification of the version of the system you are
  1352. running.
  1353.  
  1354. To be maximally helpful, for a report that contains multiple separate
  1355. compilation units, and hence multiple files, submit them in the form of
  1356. a single file that is acceptable input to gnatchop (used to be called gnatsplit
  1357. on versions of GNAT prior to 1.80), i.e. contains no non-Ada text. If you use
  1358. banners to separate the files, make sure they are composed entirely of blank
  1359. lines or Ada comments.
  1360.  
  1361. If you want to be maximally helpful, try to reduce your example to a simple one
  1362. but DON'T spend too much time doing this. Especially when you are reporting
  1363. a blow up during compilation, rather than bad code generated, we can in 
  1364. practice work with big sources if you have trouble narrowing things down.
  1365.  
  1366. If a bug involves incorrect operation of the generated code, then the first
  1367. thing the program should do is to output a line indicating the expected
  1368. output or behavior. If at all possible, do a test later on that prints
  1369. out "passed" or "failed" depending on the behavior. Of course it may not
  1370. always be possible to structure a test this way, but that's the most 
  1371. convenient form (for obvious reasons!)
  1372.  
  1373. When we receive a bug report, we take a preliminary look to categorize it
  1374. into one of the following:
  1375.  
  1376.    1.  Pilot error, documentation problems, installation problems etc.
  1377.  
  1378.    2.  Interesting comment, suggestion etc, but not a bug
  1379.  
  1380.    3.  Bug that we already know about
  1381.  
  1382.    4.  Bug that is already fixed in our development version
  1383.  
  1384.    5.  Obvious bug that we correct immediately in our development version
  1385.  
  1386.    6.  Real genuine new unfixed bug.
  1387.  
  1388. In the first 5 cases, you will get a message telling you the status. In the
  1389. 6th case only, we assign a bug tracking number of the form mmdd-nnn, where
  1390. mmdd is the date of receipt, and nnn is a serial number (highest value so
  1391. far 005, but you never know!) In this case, the release notes will tell you
  1392. what the status of the bug is, and also we will send you a message when it
  1393. is fixed.
  1394.  
  1395. To send reports to us on the system, or ask questions, send messages to
  1396.  
  1397.     gnat-report@cs.nyu.edu
  1398.  
  1399. To contact team members, send messages to:
  1400.  
  1401.     dewar@cs.nyu.edu
  1402.     schonberg@cs.nyu.edu
  1403.  
  1404. To obtain electronically the latest version of the system, FTP from:
  1405.  
  1406.     cs.nyu.edu (directory pub/gnat)
  1407.  
  1408. This FTP directory also includes full sources for the system, full
  1409. documentation and technical notes, as well as executables of the system
  1410. for several targets. We are sorry that our limited resources do not allow
  1411. us to distribute the system through other media.
  1412.  
  1413. We trust that this information will be mirrored at other FTP sites around 
  1414. the world (we encourage such mirroring to occur), which will make it easier
  1415. for users in other continents to obtain the GNAT system without heavy
  1416. communication uncertainties.
  1417.  
  1418. Schedule.
  1419. ---------
  1420. We will make available new releases of GNAT at around 5 or 6 week intervals
  1421. for the time being. Please recall that releases of the system are still only
  1422. snapshots of work in progress. We hope that it will be of some use in the
  1423. work of others, even in its current embryonic form. 
  1424.  
  1425. A short gnat paper
  1426. ------------------
  1427. A TeX file of a short paper describing something about the GNAT project is
  1428. included under the name gnatdoc1.tex.
  1429.  
  1430. Ada Information Resources On the Internet
  1431. ---------------------------------------
  1432. There is a wealth of Ada-related information available on the Internet.
  1433. The simplest way to access it is via a World Wide Web (WWW) browser
  1434. such as Mosaic or Netscape. Start up your browser and "open"
  1435. the following URLs that interest you:
  1436.  
  1437. http://lglwww.epfl.ch/Ada/
  1438.   The Ada WWW server in Lausanne, Switzerland; this server has
  1439.   a wealth of Ada-related information.
  1440.  
  1441. http://lglwww.epfl.ch/Ada/FAQ/comp-lang-ada.html
  1442.   Ada frequently-asked questions (FAQs).
  1443.  
  1444. http://lglwww.epfl.ch/Ada/Tutorials/Lovelace/lovelace.html
  1445.   Lovelace, a free interactive Ada 95 tutorial.
  1446.  
  1447. http://lglwww.epfl.ch/Ada/Resources/Books/Textbooks.html
  1448.   An annotated list of Ada-oriented textbooks.
  1449.  
  1450. http://wuarchive.wustl.edu/languages/ada/
  1451.   The Public Ada Library (PAL); this contains lots of software.
  1452.  
  1453. http://sw-eng.falls-church.va.us/
  1454.   The Ada Information Clearinghouse.
  1455.  
  1456. http://www.acm.org/sigada/
  1457.   The Association for Computing Machinery (ACM)'s SIGAda home page.
  1458.   
  1459. There is also a newsgroup, comp.lang.ada , specifically
  1460. dedicated to Ada.
  1461.  
  1462. The GNAT development team.
  1463. ---------------------------
  1464.  
  1465.     New York University
  1466.  
  1467.          Bernard Banner (*)
  1468.          Cyrille Comar (*)
  1469.          Robert Dewar (*)
  1470.          Sam Figueroa (*)
  1471.          Richard Kenner (*)
  1472.          Bruno LeClerc (*)
  1473.          Brett Porter (*)
  1474.          Gail Schenker (*)
  1475.          Edmond Schonberg (*)
  1476.  
  1477.     Florida State University (Tasking runtime work)
  1478.  
  1479.          Ted Baker
  1480.          Ted Giering (*)
  1481.          Frank Muller
  1482.  
  1483.     Ecole Nationale Superieure de Telecommunications
  1484.  
  1485.              Patrick Bazire
  1486.          Franco Gasperoni (*)
  1487.          Yvon Kermarrec
  1488.          Laurent Pautet
  1489.  
  1490.     Elsewhere
  1491.  
  1492.          Paul Hilfinger (*) (University of California, Berkeley)
  1493.          Jean Pierre Rosen (*) (Paris)
  1494.          Richard Stallman (Free Software Foundation)
  1495.  
  1496. (*) partially supported by the NYU GNAT project
  1497.     (ARPA, USAF, AJPO, Ada 9X project office)
  1498.  
  1499.