File: gnat_ug.html

package info (click to toggle)
gnat-doc 3.12p-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 6,464 kB
  • ctags: 1,036
  • sloc: perl: 1,295
file content (11570 lines) | stat: -rw-r--r-- 374,829 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.51
     from gnat_ug.texi on 2 July 1999 -->

<TITLE>GNAT User's Guide</TITLE>
</HEAD>
<BODY>
<H1>GNAT User's Guide</H1>
<H2>GNAT, The GNU Ada 95 Compiler</H2>
<H2>Document revision level Document revision level 1.242 $</H2>
<H2>GNAT Version 3.12p </H2>
<H2>Date: $Date: 1999/06/28 18:09:34 $</H2>
<ADDRESS>Ada Core Technologies, Inc.</ADDRESS>
<P>
<P><HR><P>

<P>
(C) Copyright 1995-1999, Ada Core Technologies, Inc.

</P>
<P>
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.

</P>

<P>
Silicon Graphics and IRIS are registered trademarks
and IRIX is a trademark of Silicon Graphics, Inc.

</P>
<P>
IBM PC is a trademark of International
Business Machines Corporation.

</P>
<P>
UNIX is a registered trademark of AT&#38;T
Bell Laboratories.

</P>
<P>
The following are trademarks of Compaq Computers:
DEC, DEC Ada, DECthreads, DIGITAL, DECset, OpenVMS, and VAX.

</P>
<P>
The following are trademarks of Microsoft Corporation:
Windows NT, Windows 95, Windows 98.

</P>
<P>
The following are trademarks of Wind River Systems:
VxWorks, Tornado.

</P>



<H1><A NAME="SEC1" HREF="gnat_ug_toc.html#TOC1">About This Guide</A></H1>

<P>
This guide describes the use of GNAT, a compiler and software development
toolset for the full Ada 95 programming language.
It describes the features of the compiler and tools, and details
how to use them to build Ada 95 applications.

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC2">What This Guide Contains</A>
<LI><A HREF="gnat_ug.html#SEC3">What You Should Know Before Reading This Guide</A>
<LI><A HREF="gnat_ug.html#SEC4">Related Information</A>
<LI><A HREF="gnat_ug.html#SEC5">Conventions</A>
</UL>



<H2><A NAME="SEC2" HREF="gnat_ug_toc.html#TOC2">What This Guide Contains</A></H2>

<P>
This guide contains the following chapters:

<UL>
<LI>

section <A HREF="gnat_ug.html#SEC6">Getting Started With GNAT</A>, describes how to get started compiling
and running Ada programs with the GNAT Ada programming environment.
<LI>

section <A HREF="gnat_ug.html#SEC11">The GNAT Compilation Model</A>, describes the compilation model used
by GNAT.
<LI>

section <A HREF="gnat_ug.html#SEC33">Compiling Using <CODE>gcc</CODE></A>, describes how to compile
Ada programs with <CODE>gcc</CODE>, the Ada compiler.
<LI>

section <A HREF="gnat_ug.html#SEC52">Binding Using <CODE>gnatbind</CODE></A>, describes how to
perform binding of Ada programs with <CODE>gnatbind</CODE>, the GNAT binding
utility.
<LI>

section <A HREF="gnat_ug.html#SEC64">Linking Using <CODE>gnatlink</CODE></A>,
describes <CODE>gnatlink</CODE>, a
program that provides for linking using the GNAT run-time library to
construct a program. <CODE>gnatlink</CODE> can also incorporate foreign language
object units into the executable.
<LI>

section <A HREF="gnat_ug.html#SEC67">The GNAT Make Program <CODE>gnatmake</CODE></A>, describes <CODE>gnatmake</CODE>, a
utility that automatically determines the set of sources
needed by an Ada compilation unit, and executes the necessary compilations
binding and link.
<LI>

section <A HREF="gnat_ug.html#SEC75">Renaming Files Using <CODE>gnatchop</CODE></A>, describes
<CODE>gnatchop</CODE>, a utility that allows you to preprocess a file that
contains Ada source code, and split it into one or more new files, one
for each compilation unit.
<LI>

section <A HREF="gnat_ug.html#SEC94">The cross-referencing tools <CODE>gnatxref</CODE> and <CODE>gnatfind</CODE></A>, discusses
<CODE>gnatxref</CODE> and <CODE>gnatfind</CODE>, two tools that provide an easy
way to navigate through sources.
<LI>

section <A HREF="gnat_ug.html#SEC103">File Name Krunching Using <CODE>gnatkr</CODE></A>, describes the <CODE>gnatkr</CODE>
file name krunching utility, used to handle shortened
file names on operating systems with a limit on the length of names.
<LI>

section <A HREF="gnat_ug.html#SEC108">Preprocessing Using <CODE>gnatprep</CODE></A>, describes <CODE>gnatprep</CODE>, a
preprocessor utility that allows a single source file to be used to
generate multiple or parameterized source files, by means of macro
substitution.
<LI>

section <A HREF="gnat_ug.html#SEC113">The GNAT library browser <CODE>gnatls</CODE></A>, describes <CODE>gnatls</CODE>, a
utility that displays information about compiled units, including dependences
on the corresponding sources files, and consistency of compilations.
<LI>

section <A HREF="gnat_ug.html#SEC117">Rebuilding the GNAT Library</A>, describe the process of rebuilding
the GNAT library.

<LI>

section <A HREF="gnat_ug.html#SEC118">Finding memory problems with <CODE>gnatmem</CODE></A>, describes <CODE>gnatmem</CODE>, a
utility that monitors dynamic allocation and deallocation activity in a
program, and displays information about incorrect deallocations and sources
of possible memory leaks.
<LI>

section <A HREF="gnat_ug.html#SEC123">ASIS-Based Tools</A>, gives the general idea about the tools built
on top of the ASIS implementation for GNAT.
<LI>

section <A HREF="gnat_ug.html#SEC126">Creating Sample Bodies Using <CODE>gnatstub</CODE></A>, discusses <CODE>gnatstub</CODE>,
a utility that generates empty, but compilable bodies for library units.
<LI>

section <A HREF="gnat_ug.html#SEC129">Minimizing Executables for Ada Programs Using <CODE>gnatelim</CODE></A>, discusses
<CODE>gnatelim</CODE>, a tool which detects unused subprograms and produces
information that helps the compiler to create a smaller executable for a
program.
<LI>

section <A HREF="gnat_ug.html#SEC137">Other Utility Programs</A>, discusses several other GNAT utilities,
including <CODE>gnatpsta</CODE> and <CODE>gnatpsys</CODE>.
<LI>

section <A HREF="gnat_ug.html#SEC148">Running and Debugging Ada Programs</A>, describes how to run and debug
Ada programs.

<LI>

section <A HREF="gnat_ug.html#SEC27">Building mixed Ada &#38; C++ programs</A>, gives hints on how to interface
with c++.

<LI>

section <A HREF="gnat_ug.html#SEC160">Performance Considerations</A>, reviews the trade offs between using
defaults or options in program development.
</UL>



<H2><A NAME="SEC3" HREF="gnat_ug_toc.html#TOC3">What You Should Know Before Reading This Guide</A></H2>

<P>
<A NAME="IDX1"></A>
This user's guide assumes that you are familiar with Ada 95 language, as
described in the International Standard ANSI/ISO/IEC-8652:1995, Jan
1995.

</P>


<H2><A NAME="SEC4" HREF="gnat_ug_toc.html#TOC4">Related Information</A></H2>

<P>
For further information about related tools, refer to the following
documents:

</P>

<UL>
<LI>

<CITE>GNAT Reference Manual</CITE>, which contains all reference
material for the GNAT implementation of Ada 95.

<LI>

<CITE>Ada 95 Language Reference Manual</CITE>, which contains all reference
material for the Ada 95 programming language.

<LI>

<CITE>Debugging with GDB</CITE>
contains all details on the use of the GNU source-level debugger.

<LI>

<CITE>GNU Emacs Manual</CITE>
contains full information on the extensible editor and programming
environment Emacs.

</UL>



<H2><A NAME="SEC5" HREF="gnat_ug_toc.html#TOC5">Conventions</A></H2>
<P>
<A NAME="IDX2"></A>
<A NAME="IDX3"></A>

</P>
<P>
Following are examples of the typographical and graphic conventions used
in this guide:

</P>

<UL>
<LI>

<CODE>Functions</CODE>, <CODE>utility program names</CODE>, <CODE>standard names</CODE>,
and <CODE>classes</CODE>.

<LI>

<SAMP>`Option flags'</SAMP>

<LI>

<TT>`File Names'</TT>, <TT>`button names'</TT>, and <TT>`field names'</TT>.

<LI>

<VAR>Variables</VAR>.

<LI>

<EM>Emphasis</EM>.

<LI>

[optional information or parameters]

<LI>

Examples are described by text

<PRE>
and then shown this way.
</PRE>

</UL>

<P>
Commands that are entered by the user are preceded in this manual by the
characters "<CODE>$ </CODE>" (dollar sign followed by space). If your system
uses this sequence as a prompt, then the commands will appear exactly as
you see them in the manual. If your system uses some other prompt, then
the command will appear with the <CODE>$</CODE> replaced by whatever prompt
character you are using.

</P>



<H1><A NAME="SEC6" HREF="gnat_ug_toc.html#TOC6">Getting Started With GNAT</A></H1>

<P>
This chapter describes the simplest ways of using GNAT to compile Ada
programs.

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC7">Running GNAT</A>
<LI><A HREF="gnat_ug.html#SEC8">Running a Simple Ada Program</A>
<LI><A HREF="gnat_ug.html#SEC9">Running a Program With Multiple Units</A>
<LI><A HREF="gnat_ug.html#SEC10">Using the gnatmake Utility</A>
</UL>



<H2><A NAME="SEC7" HREF="gnat_ug_toc.html#TOC7">Running GNAT</A></H2>

<P>
Three steps are needed to create an executable file from an Ada source
file:

</P>

<OL>
<LI>

The source file(s) must be compiled.
<LI>

The file(s) must be bound using the GNAT binder.
<LI>

All appropriate object files must be linked to produce an executable.
</OL>

<P>
All three steps are most commonly handled by using the <CODE>gnatmake</CODE>
utility program that, given the name of the main program, automatically
performs the necessary compilation, binding and linking steps.

</P>


<H2><A NAME="SEC8" HREF="gnat_ug_toc.html#TOC8">Running a Simple Ada Program</A></H2>

<P>
Any editor may be used to prepare an Ada program. If <CODE>emacs</CODE> is
used, the optional Ada mode may be helpful in laying out the program. The
program text is a normal text file. We will suppose in our initial
example that you have used your editor to prepare the following
standard format text file:

</P>

<PRE>
   <B>with</B> Text_IO; <B>use</B> Text_IO;
   <B>procedure</B> Hello <B>is</B>
   <B>begin</B>
      Put_Line ("Hello WORLD!");
   <B>end</B> Hello;
</PRE>

<P>
This file should be named <TT>`hello.adb'</TT>.
Using the normal default file naming conventions, By default, GNAT requires
that each file
contain a single compilation unit whose file name corresponds to the
unit name
with periods replaced by hyphens, and whose
extension is <TT>`.ads'</TT> for a
spec and <TT>`.adb'</TT> for a body.
This default file naming convention can be overridden by use of the
special pragma <CODE>Source_File_Name</CODE> see section <A HREF="gnat_ug.html#SEC18">Using Other File Names</A>.
Alternatively, if you want to rename your files according to this default
convention, which is probably more convenient if you will be using GNAT
for all your compilation requirements, then the <CODE>gnatchop</CODE> utility
can be used to perform this renaming operation
(see section <A HREF="gnat_ug.html#SEC75">Renaming Files Using <CODE>gnatchop</CODE></A>).

</P>
<P>
You can compile the program using the following command:

</P>

<PRE>
   $ gcc -c hello.adb
</PRE>

<P>
<CODE>gcc</CODE> is the command used to run the compiler. This compiler is
capable of compiling programs in several languages including Ada 95 and
C.  It determines you have given it an Ada program by the extension
(<TT>`.ads'</TT> or <TT>`.adb'</TT>), and will call the GNAT compiler to compile
the specified file.

</P>
<P>
The <CODE>-c</CODE> switch is required.  It tells <CODE>gcc</CODE> to only do a
compilation. (For C programs, <CODE>gcc</CODE> can also do linking, but this
capability is not used directly for Ada programs, so the <CODE>-c</CODE>
switch must always be present.)

</P>
<P>
This compile command generates a file
<TT>`hello.o'</TT> which is the object
file corresponding to your Ada program. It also generates a file
<TT>`hello.ali'</TT>
which contains additional information used to check
that an Ada program is consistent. To get an executable file,
we then use <CODE>gnatbind</CODE> to bind the program
and <CODE>gnatlink</CODE> to link it to produce the executable. The
argument to both gnatbind and gnatlink is the name of the
<TT>`ali'</TT> file, but the default extension of <TT>`.ali'</TT> can
be omitted. This means that in the most common case, the argument
is simply the name of the main program:

</P>

<PRE>
   $ gnatbind hello
   $ gnatlink hello
</PRE>

<P>
A simpler method of carrying out these steps is to use
<CODE>gnatmake</CODE>, which
is a master program which invokes all of the required
compilation, binding and linking tools in the correct order. In particular,
<CODE>gnatmake</CODE> automatically recompiles any sources that have been modified
since they were last compiled, or sources that depend
on such modified sources, so that a consistent compilation is ensured.

</P>

<PRE>
   $ gnatmake hello.adb
</PRE>

<P>
The result is an executable program called <TT>`hello'</TT>, which can be
run by entering:

</P>

<PRE>
   $ ./hello
</PRE>

<P>
and, if all has gone well, you will see

</P>

<PRE>
   Hello WORLD!
</PRE>

<P>
appear in response to this command.

</P>


<H2><A NAME="SEC9" HREF="gnat_ug_toc.html#TOC9">Running a Program With Multiple Units</A></H2>

<P>
Consider a slightly more complicated example that has three files: a
main program, and the spec and body of a package:

</P>

<PRE>
   <B>package</B> Greetings <B>is</B>
      <B>procedure</B> Hello;
      <B>procedure</B> Goodbye;
   <B>end</B> Greetings;

   <B>with</B> Text_IO; <B>use</B> Text_IO;
   <B>package</B> <B>body</B> Greetings <B>is</B>
      <B>procedure</B> Hello <B>is</B>
      <B>begin</B>
         Put_Line ("Hello WORLD!");
      <B>end</B> Hello;
      <B>procedure</B> Goodbye <B>is</B>
      <B>begin</B>
         Put_Line ("Goodbye WORLD!");
      <B>end</B> Goodbye;
   <B>end</B> Greetings;

   <B>with</B> Greetings;
   <B>procedure</B> Gmain <B>is</B>
   <B>begin</B>
      Greetings.Hello;
      Greetings.Goodbye;
   <B>end</B> Gmain;
</PRE>

<P>
Following the one-unit-per-file rule, place this program in the
following three separate files:

</P>
<DL COMPACT>

<DT><TT>`greetings.ads'</TT>
<DD>
spec of package <CODE>Greetings</CODE>

<DT><TT>`greetings.adb'</TT>
<DD>
body of package <CODE>Greetings</CODE>

<DT><TT>`gmain.adb'</TT>
<DD>
body of main program
</DL>

<P>
To build an executable version of
this program, we could use four separate steps to compile, bind, and link
the program, as follows:

</P>

<PRE>
   $ gcc -c gmain.adb
   $ gcc -c greetings.adb
   $ gnatbind gmain
   $ gnatlink gmain
</PRE>

<P>
Note that there is no required order of compilation when using GNAT.
In particular it is perfectly fine to compile the main program first.
Also, it is not necessary to compile package specs in the case where
there is a separate body, only the body need be compiled. If you want
to submit these programs to the compiler for semantic checking purposes,
then you use the
<CODE>-gnatc</CODE> switch:

</P>

<PRE>
   $ gcc -c greetings.ads -gnatc
</PRE>

<P>
Although the compilation can be done in separate steps as in the
above example, in practice it is almost always more convenient
to use the <CODE>gnatmake</CODE> capability. All you need to know in this case
is the name of the main program source file. The effect of the above four
commands can be achieved with a single one:

</P>

<PRE>
   $ gnatmake gmain.adb
</PRE>

<P>

</P>
<P>
In the next section we discuss the advantages of using <CODE>gnatmake</CODE> in
more detail.

</P>


<H2><A NAME="SEC10" HREF="gnat_ug_toc.html#TOC10">Using the <CODE>gnatmake</CODE> Utility</A></H2>

<P>
If you work on a program by compiling single components at a time using
<CODE>gcc</CODE>, you typically keep track of the units you modify. In order to
build a consistent system, you compile not only these units, but also any
units that depend on the units you have modified.
For example, in the preceding case,
if you edit <TT>`gmain.adb'</TT>, you only need to recompile that file. But if
you edit <TT>`greetings.ads'</TT>, you must recompile both
<TT>`greetings.adb'</TT> and <TT>`gmain.adb'</TT>, because both files contain
units that depend on <TT>`greetings.ads'</TT>.

</P>
<P>
<CODE>gnatbind</CODE> will warn you if you forget one of these compilation
steps, so that it is impossible to generate an inconsistent program as a
result of forgetting to do a compilation. Nevertheless it is tedious and
error-prone to keep track of dependencies among units.
One approach to handle the dependency-bookkeeping is to use a
makefile. However, makefiles present maintenance problems of their own:
if the dependencies change as you change the program, you must make
sure that the makefile is kept up-to-date manually, which is also an
error-prone process.

</P>
<P>
The <CODE>gnatmake</CODE> utility takes care of these details automatically.
Invoke it using either one of the following forms:

</P>

<PRE>
   $ gnatmake gmain.adb
   $ gnatmake gmain
</PRE>

<P>
The argument is the name of the file containing the main program from
which you may omit the extension. <CODE>gnatmake</CODE>
examines the environment, automatically recompiles any files that need
recompiling, and binds and links the resulting set of object files,
generating the executable file, <TT>`gmain'</TT>.
In a large program, it
can be extremely helpful to use <CODE>gnatmake</CODE>, because working out by hand
what needs to be recompiled can be difficult.

</P>
<P>
Note that <CODE>gnatmake</CODE>
takes into account all the intricate Ada 95 rules that
establish dependencies among units. These include dependencies that result
from inlining subprogram bodies, and from
generic instantiation. Unlike some other
Ada make tools, <CODE>gnatmake</CODE> does not rely on the dependencies that were
found by the compiler on a previous compilation, which may possibly
be wrong when sources change. <CODE>gnatmake</CODE> determines the exact set of
dependencies from scratch each time it is run.

</P>



<H1><A NAME="SEC11" HREF="gnat_ug_toc.html#TOC11">The GNAT Compilation Model</A></H1>
<P>
<A NAME="IDX4"></A>
<A NAME="IDX5"></A>

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC12">Source Representation</A>
<LI><A HREF="gnat_ug.html#SEC13">Foreign Language Representation</A>
<LI><A HREF="gnat_ug.html#SEC17">File Naming Rules</A>
<LI><A HREF="gnat_ug.html#SEC18">Using Other File Names</A>
<LI><A HREF="gnat_ug.html#SEC19">Generating Object Files</A>
<LI><A HREF="gnat_ug.html#SEC20">Source Dependencies</A>
<LI><A HREF="gnat_ug.html#SEC21">The Ada Library Information Files</A>
<LI><A HREF="gnat_ug.html#SEC22">Representation of Time Stamps</A>
<LI><A HREF="gnat_ug.html#SEC23">Binding an Ada Program</A>
<LI><A HREF="gnat_ug.html#SEC24">Mixed Language Programming</A>
<LI><A HREF="gnat_ug.html#SEC27">Building mixed Ada &#38; C++ programs</A>
<LI><A HREF="gnat_ug.html#SEC31">Comparison between GNAT and C/C++ Compilation Models</A>
<LI><A HREF="gnat_ug.html#SEC32">Comparison between GNAT and Conventional Ada Library Models</A>
</UL>

<P>
This chapter describes the compilation model used by GNAT. Although
similar to that used by other languages, such as C and C++, this model
is substantially different from the traditional Ada compilation models,
which are based on a library.  The model is initially described without
reference to the library-based model. If you have not previously used an
Ada compiler, you need only read the first part of this chapter.  The
last section describes and discusses the differences between the GNAT
model and the traditional Ada compiler models. If you have used other
Ada compilers, this section will help you to understand those
differences, and the advantages of the GNAT model.

</P>


<H2><A NAME="SEC12" HREF="gnat_ug_toc.html#TOC12">Source Representation</A></H2>
<P>
<A NAME="IDX6"></A>

</P>
<P>
Ada source programs are represented in standard text files, using
Latin-1 coding. Latin-1 is an 8-bit code that includes the familiar
7-bit ASCII set, plus additional characters used for
representing foreign languages (see section <A HREF="gnat_ug.html#SEC13">Foreign Language Representation</A>
for support of non-USA character sets). The format effector characters
are represented using their standard ASCII encodings, as follows:

</P>
<DL COMPACT>

<DT><CODE>VT</CODE>
<DD>
<A NAME="IDX7"></A>
Vertical tab, <CODE>16#0B#</CODE>

<DT><CODE>HT</CODE>
<DD>
<A NAME="IDX8"></A>
Horizontal tab, <CODE>16#09#</CODE>

<DT><CODE>CR</CODE>
<DD>
<A NAME="IDX9"></A>
Carriage return, <CODE>16#0D#</CODE>

<DT><CODE>LF</CODE>
<DD>
<A NAME="IDX10"></A>
Line feed, <CODE>16#0A#</CODE>

<DT><CODE>FF</CODE>
<DD>
<A NAME="IDX11"></A>
Form feed, <CODE>16#0C#</CODE>
</DL>

<P>
Source files are in standard text file format. In addition, GNAT will
recognize a wide variety of stream formats, in which the end of physical
physical lines is marked by any of the following sequences:
<CODE>LF</CODE>, <CODE>CR</CODE>, <CODE>CR-LF</CODE>, or <CODE>LF-CR</CODE>. This is useful
in accommodating files that are imported from other operating systems.

</P>
<P>
<A NAME="IDX12"></A>
<A NAME="IDX13"></A>
<A NAME="IDX14"></A>
The end of a source file is normally represented by the physical end of
file. However, the control character <CODE>16#1A#</CODE> (<CODE>SUB</CODE>) is also
recognized as signalling the end of the source file. Again, this is
provided for compatibility with other operating systems where this
code is used to represent the end of file.

</P>
<P>
Each file contains a single Ada compilation unit, including any pragmas
associated with the unit. For example, this means you must place a
package declaration (a package <STRONG>spec</STRONG>) and the corresponding body in
separate files. An Ada <STRONG>compilation</STRONG> (which is a sequence of
compilation units) is represented using a sequence of files. Similarly,
you will place each subunit or child unit in a separate file.

</P>


<H2><A NAME="SEC13" HREF="gnat_ug_toc.html#TOC13">Foreign Language Representation</A></H2>

<P>
GNAT supports the standard character sets defined in Ada 95 as well as
several other non-standard character sets for use in localized versions
of the compiler (see section <A HREF="gnat_ug.html#SEC44">Character Set Control</A>).

<UL>
<LI><A HREF="gnat_ug.html#SEC14">Latin-1</A>
<LI><A HREF="gnat_ug.html#SEC15">Other 8-Bit Codes</A>
<LI><A HREF="gnat_ug.html#SEC16">Wide Character Encodings</A>
</UL>



<H3><A NAME="SEC14" HREF="gnat_ug_toc.html#TOC14">Latin-1</A></H3>
<P>
<A NAME="IDX15"></A>

</P>
<P>
The basic character set is Latin-1. This character set is defined by ISO
standard 8859, part 1. The lower half (character codes <CODE>16#00#</CODE>
... <CODE>16#7F#)</CODE> is identical to standard ASCII coding, but the upper half is
used to represent additional characters. These include extended letters
used by European languages, such as French accents, the vowels with umlauts
used in German, and the extra letter A-ring used in Swedish.

</P>
<P>
<A NAME="IDX16"></A>
For a complete list of Latin-1 codes and their encodings, see the source
file of library unit <CODE>Ada.Characters.Latin_1</CODE> in file
<TT>`a-chlat1.ads'</TT>.
You may use any of these extended characters freely in character or
string literals. In addition, the extended characters that represent
letters can be used in identifiers.

</P>


<H3><A NAME="SEC15" HREF="gnat_ug_toc.html#TOC15">Other 8-Bit Codes</A></H3>

<P>
GNAT also supports several other 8-bit coding schemes:

</P>
<DL COMPACT>

<DT>Latin-2
<DD>
<A NAME="IDX17"></A>
 
Latin-2 letters allowed in identifiers, with uppercase and lowercase
equivalence.

<DT>Latin-3
<DD>
<A NAME="IDX18"></A>
Latin-3 letters allowed in identifiers, with uppercase and lowercase
equivalence.

<DT>Latin-4
<DD>
<A NAME="IDX19"></A>
Latin-4 letters allowed in identifiers, with uppercase and lowercase
equivalence.

<DT>IBM PC (code page 437)
<DD>
<A NAME="IDX20"></A>
This code page is the normal default for PCs in the U.S. It corresponds
to the original IBM PC character set. This set has some, but not all, of
the extended Latin-1 letters, but these letters do not have the same
encoding as Latin-1. In this mode, these letters are allowed in
identifiers with uppercase and lowercase equivalence.

<DT>IBM PC (code page 850)
<DD>
<A NAME="IDX21"></A>
This code page is a modification of 437 extended to include all the
Latin-1 letters, but still not with the usual Latin-1 encoding. In this
mode, all these letters are allowed in identifiers with uppercase and
lowercase equivalence.

<DT>Full Upper 8-bit
<DD>
Any character in the range 80-FF allowed in identifiers, and all are
considered distinct.  In other words, there are no uppercase and lowercase
equivalences in this range. This is useful in conjunction with
certain encoding schemes used for some foreign character sets (e.g.
the typical method of representing Chinese characters on the PC).

<DT>No Upper-Half
<DD>
No upper-half characters in the range 80-FF are allowed in identifiers.
This gives Ada 83 compatibility for identifier names.
</DL>

<P>
For precise data on the encodings permitted, and the uppercase and lowercase
equivalences that are recognized, see the file <TT>`csets.adb'</TT> in
the GNAT compiler sources. You will need to obtain a full source release
of GNAT to obtain this file.

</P>


<H3><A NAME="SEC16" HREF="gnat_ug_toc.html#TOC16">Wide Character Encodings</A></H3>

<P>
GNAT allows wide character codes to appear in character and string
literals, and also optionally in identifiers, by means of the following
possible encoding schemes:

</P>
<DL COMPACT>

<DT>Hex Coding
<DD>
In this encoding, a wide character is represented by the following five
character sequence:


<PRE>
   ESC a b c d
</PRE>

Where <CODE>a</CODE>, <CODE>b</CODE>, <CODE>c</CODE>, <CODE>d</CODE> are the four hexadecimal
characters (using uppercase letters) of the wide character code. For
example, ESC A345 is used to represent the wide character with code
<CODE>16#A345#</CODE>.
This scheme is compatible with use of the full Wide_Character set.

<DT>Upper-Half Coding
<DD>
<A NAME="IDX22"></A>
The wide character with encoding <CODE>16#abcd#</CODE> where the upper bit is on (in
other words, "a" is in the range 8-F) is represented as two bytes,
<CODE>16#ab#</CODE> and <CODE>16#cd#</CODE>. The second byte cannot be a format control
character, but is not required to be in the upper half. This method can
be also used for shift-JIS or EUC, where the internal coding matches the
external coding.

<DT>Shift JIS Coding
<DD>
<A NAME="IDX23"></A>
A wide character is represented by a two-character sequence,
<CODE>16#ab#</CODE> and
<CODE>16#cd#</CODE>, with the restrictions described for upper-half encoding as
described above. The internal character code is the corresponding JIS
character according to the standard algorithm for Shift-JIS
conversion. Only characters defined in the JIS code set table can be
used with this encoding method.

<DT>EUC Coding
<DD>
<A NAME="IDX24"></A>
A wide character is represented by a two-character sequence
<CODE>16#ab#</CODE> and
<CODE>16#cd#</CODE>, with both characters being in the upper half. The internal
character code is the corresponding JIS character according to the EUC
encoding algorithm. Only characters defined in the JIS code set table
can be used with this encoding method.

<DT>UTF-8 Coding
<DD>
A wide character is represented using
UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
10646-1/Am.2.  Depending on the character value, the representation
is a one, two, or three byte sequence:


<PRE>
   16#0000#-16#007f#: 2#0xxxxxxx#
   16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
   16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
</PRE>

where the xxx bits correspond to the left-padded bits of the
16-bit character value. Note that all lower half ASCII characters
are represented as ASCII bytes and all upper half characters and
other wide characters are represented as sequences of upper-half
(The full UTF-8 scheme allows for encoding 31-bit characters as
6-byte sequences, but in this implementation, all UTF-8 sequences
of four or more bytes length will be treated as illegal).
<DT>Brackets Coding
<DD>
In this encoding, a wide character is represented by the following eight
character sequence:


<PRE>
   [ " a b c d " ]
</PRE>

Where <CODE>a</CODE>, <CODE>b</CODE>, <CODE>c</CODE>, <CODE>d</CODE> are the four hexadecimal
characters (using uppercase letters) of the wide character code. For
example, ["A345"] is used to represent the wide character with code
<CODE>16#A345#</CODE>. It is also possible (though not required) to use the
Brackets coding for upper half characters. For example, the code
<CODE>16#A3#</CODE> can be represented as <CODE>["A3"]</CODE>.

This scheme is compatible with use of the full Wide_Character set,
and is also the method used for wide character encoding in the standard
ACVC (Ada Compiler Validation Capability) test suite distributions.

</DL>

<P>
Note: Some of these coding schemes do not permit the full use of the
Ada 95 character set. For example, neither Shift JIS, nor EUC allow the
use of the upper half of the Latin-1 set.

</P>


<H2><A NAME="SEC17" HREF="gnat_ug_toc.html#TOC17">File Naming Rules</A></H2>

<P>
The default file name is determined by the name of the unit that the
file contains.  The name is formed by taking the full expanded name of
the unit and replacing the separating dots with hyphens and using
lowercase for all letters.

</P>
<P>
An exception arises if the file name generated by the above rules starts
with one of the characters
a,g,i, or s,
and the second character is a
minus.  In this case, the character tilde is used in place
of the minus.  The reason for this special rule is to avoid clashes with
the standard names for child units of the packages System, Ada,
Interfaces, and GNAT, which use the prefixes
s- a- i- and g-
respectively.

</P>
<P>
The file extension is <TT>`.ads'</TT> for a spec and
<TT>`.adb'</TT> for a body. The following list shows some
examples of these rules.

</P>
<DL COMPACT>

<DT><TT>`main.ads'</TT>
<DD>
Main (spec)
<DT><TT>`main.adb'</TT>
<DD>
Main (body)
<DT><TT>`arith_functions.ads'</TT>
<DD>
Arith_Functions (package spec)
<DT><TT>`arith_functions.adb'</TT>
<DD>
Arith_Functions (package body)
<DT><TT>`func-spec.ads'</TT>
<DD>
Func.Spec (child package spec)
<DT><TT>`func-spec.adb'</TT>
<DD>
Func.Spec (child package body)
<DT><TT>`main-sub.adb'</TT>
<DD>
Sub (subunit of Main)
<DT><TT>`a~bad.adb'</TT>
<DD>
A.Bad (child package body)
</DL>

<P>
Following these rules can result in excessively long
file names if corresponding
unit names are long (for example, if child units or subunits are
heavily nested). An option is available to shorten such long file names
(called file name "krunching"). This may be particularly useful when
programs being developed with GNAT are to be used on operating systems
with limited file name lengths.  See section <A HREF="gnat_ug.html#SEC105">Using <CODE>gnatkr</CODE></A>.

</P>
<P>
Of course, no file shortening algorithm can guarantee uniqueness over
all possible unit names; if file name krunching is used, it is your
responsibility to ensure no name clashes occur. Alternatively you
can specify the exact file names that you want used, as described
in the next section. Finally, if your Ada programs are migrating from a
compiler with a different naming convention, you can use the gnatchop
utility to produce source files that follow the GNAT naming conventions.
(For details see section <A HREF="gnat_ug.html#SEC75">Renaming Files Using <CODE>gnatchop</CODE></A>.)

</P>


<H2><A NAME="SEC18" HREF="gnat_ug_toc.html#TOC18">Using Other File Names</A></H2>
<P>
<A NAME="IDX25"></A>

</P>
<P>
In the previous section, we have described the default rules used by
GNAT to determine the file name in which a given unit resides. It is
often convenient to follow these default rules, and if you follow them,
the compiler knows without being explicitly told where to find all
the files it needs.

</P>
<P>
However, in some cases, particularly when a program is imported from
another Ada compiler environment, it may be more convenient for the
programmer to specify which file names contain which units. GNAT allows
arbitrary file names to be used by means of the Source_File_Name pragma.
The form of this pragma is as shown in the following examples:
<A NAME="IDX26"></A>

</P>

<PRE>
   <B>pragma</B> Source_File_Name (My_Utilities.Stacks,
     Spec_File_Name =&#62; "myutilst_a.ada");
   <B>pragma</B> Source_File_name (My_Utilities.Stacks,
     Body_File_Name =&#62; "myutilst.ada");
</PRE>

<P>
As shown in this example, the first argument for the pragma is the unit
name (in this example a child unit). The second argument has the form
of a named association.  The identifier
indicates whether the file name is for a spec or a body;
the file name itself is given by a string literal.

</P>
<P>
The source file name pragma is a configuration pragma, which means that
normally it will be placed in the <TT>`gnat.adc'</TT>
file used to hold configuration
pragmas that apply to a complete compilation environment.
For more details on how the <TT>`gnat.adc'</TT> file is created and used
see section <A HREF="gnat_ug.html#SEC82">Handling of Configuration Pragmas</A>
<A NAME="IDX27"></A>

</P>
<P>
GNAT allows completely arbitrary file names to be specified using the
source file name pragma. However, if the file name specified has an
extension other than <TT>`.ads'</TT> or <TT>`.adb'</TT> it is necessary to use a special
syntax when compiling the file. The name in this case must be preceded
by the special sequence <CODE>-x</CODE> followed by a space and the name of the
language, here <CODE>ada</CODE>, as in:

</P>

<PRE>
   $ gcc -c -x ada peculiar_file_name.sim
</PRE>

<P>
<CODE>gnatmake</CODE> handles non-standard file names in the usual manner (the
non-standard file name for the main program is simply used as the
argument to gnatmake). Note that if the extension is also non-standard,
then it must be included in the gnatmake command, it may not be omitted.

</P>


<H2><A NAME="SEC19" HREF="gnat_ug_toc.html#TOC19">Generating Object Files</A></H2>

<P>
An Ada program consists of a set of source files, and the first step in
compiling the program is to generate the corresponding object files.
These are generated by compiling a subset of these source files.
The files you need to compile are the following:

</P>

<UL>
<LI>

If a package spec has no body, compile the package spec to produce the
object file for the package.

<LI>

If a package has both a spec and a body, compile the body to produce the
object file for the package. The source file for the package spec need
not be compiled in this case because there is only one object file, which
contains the code for both the spec and body of the package.

<LI>

For a subprogram, compile the subprogram body to produce the object file
for the subprogram. The spec, if one is present, is as usual in a
separate file, and need not be compiled.

<LI>

<A NAME="IDX28"></A>
In the case of subunits, only compile the parent unit.  A single object
file is generated for the entire subunit tree, which includes all the
subunits.

<LI>

Compile child units independently of their parent units
(though, of course, the spec of all the ancestor unit must be present in order
to compile a child unit).

<LI>

<A NAME="IDX29"></A>
Compile generic units in the same manner as any other units. The object
files in this case are small dummy files that contain at most the
flag used for elaboration checking. This is because GNAT always handles generic
instantiation by means of macro expansion. However, it is still necessary to
compile generic units, for dependency checking and elaboration purposes.
</UL>

<P>
The preceding rules describe the set of files that must be compiled to
generate the object files for a program. Each object file has the same
name as the corresponding source file, except that the extension is
<TT>`.o'</TT> as usual.

</P>
<P>
You may wish to compile other files for the purpose of checking their
syntactic and semantic correctness. For example, in the case where a
package has a separate spec and body, you would not normally compile the
spec.  However, it is convenient in practice to compile the spec to make
sure it is error-free before compiling clients of this spec, because such
compilations will fail if there is an error in the spec.

</P>
<P>
GNAT provides an option for compiling such files purely for the
purposes of checking correctness; such compilations are not required as
part of the process of building a program. To compile a file in this
checking mode, use the <CODE>-gnatc</CODE> switch.

</P>


<H2><A NAME="SEC20" HREF="gnat_ug_toc.html#TOC20">Source Dependencies</A></H2>

<P>
A given object file clearly depends on the source file which is compiled
to produce it. Here we are using <STRONG>depends</STRONG> in the sense of a typical
<CODE>make</CODE> utility; in other words, an object file depends on a source
file if changes to the source file require the object file to be
recompiled.
In addition to this basic dependency, a given object may depend on
additional source files as follows:

</P>

<UL>
<LI>

If a file being compiled <CODE>with</CODE>'s a unit <VAR>X</VAR>, the object file
depends on the file containing the spec of unit <VAR>X</VAR>. This includes
files that are <CODE>with</CODE>'ed implicitly either because they are parents
of <CODE>with</CODE>'ed child units or they are run-time units required by the
language constructs used in a particular unit.

<LI>

If a file being compiled instantiates a library level generic unit, the
object file depends on both the spec and body files for this generic
unit.

<LI>

If a file being compiled instantiates a generic unit defined within a
package, the object file depends on the body file for the package as
well as the spec file.

<LI>

<A NAME="IDX30"></A>
<A NAME="IDX31"></A>
If a file being compiled contains a call to a subprogram for which
pragma <CODE>Inline</CODE> applies and inlining is activated with the
<CODE>-gnatn</CODE> switch, the object file depends on the file containing the
body of this subprogram as well as on the file containing the spec.
Similarly if the <CODE>-gnatN</CODE> switch is used, then the unit is
dependent on all body files.

<LI>

The object file for a parent unit depends on all its subunit body files.
</UL>

<P>
These rules are applied transitively: if unit <CODE>A</CODE> <CODE>with</CODE>'s
unit <CODE>B</CODE>, whose elaboration calls an inlined procedure in package
<CODE>C</CODE>, the object file for unit <CODE>A</CODE> will depend on the body of
<CODE>C</CODE>, in file <TT>`c.adb'</TT>.

</P>
<P>
The set of dependent files described by these rules includes all the
files on which the unit is semantically dependent, as described in the
Ada 95 Language Reference Manual. However, it is a superset of what the
ARM describes, because it includes generic, inline, and subunit dependencies.

</P>
<P>
An object file must be recreated by recompiling the corresponding source
file if any of the source files on which it depends are modified. For
example, if the <CODE>make</CODE> utility is used to control compilation,
the rule for an Ada object file must mention all the source files on
which the object file depends, according to the above definition.
The determination of the necessary
recompilations is done automatically when one uses <CODE>gnatmake</CODE>.

</P>


<H2><A NAME="SEC21" HREF="gnat_ug_toc.html#TOC21">The Ada Library Information Files</A></H2>

<P>
Each compilation actually generates two output files. The first of these
is the normal object file that has a <TT>`.o'</TT> extension. The second is a
text file containing full dependency information. It has the same
name as the source file, but an <TT>`.ali'</TT> extension.
This file is known as the Ada Library Information (ALI) file.

</P>
<P>
Normally you need not be concerned with the contents of this file.
This section is included in case you want to understand how these files
are being used by the binder and other GNAT utilities.
Each ALI file consists of a series of lines of the form:

</P>

<PRE>
   <VAR>Key_Character</VAR> <VAR>parameter</VAR> <VAR>parameter</VAR> ...
</PRE>

<P>
<A NAME="IDX32"></A>
The first two lines in the file identify the library output version and
<CODE>Standard</CODE> version. These are required to be consistent across the
entire set of compilation units in your program.

</P>

<PRE>
   V "<VAR>xxxxxxxxxxxxxxxx</VAR>"
</PRE>

<P>
This line indicates the library output version, as defined in
<TT>`gnatvsn.ads'</TT>.  It ensures that separate object modules of a
program are consistent. The library output version
must be changed if anything in the compiler changes that
would affect successful binding of modules compiled separately.
Examples of such changes are modifications in the format of the library
information described in this package, modifications to calling
sequences, or to the way data is represented.

</P>

<PRE>
   S "<VAR>xxxxxxxxxxxxxxxx</VAR>"
</PRE>

<P>
<A NAME="IDX33"></A>
<A NAME="IDX34"></A>
This line contains information regarding types declared in packages
<CODE>Standard</CODE> as stored in <CODE>Gnatvsn.Standard_Version</CODE>.
The purpose of this information is to ensure that all units in a
program are compiled with a consistent set of options.
This is critical on systems where, for example, the size of <CODE>Integer</CODE>
can be set by command line switches.

</P>

<PRE>
   M <VAR>type</VAR> [<VAR>priority</VAR>]
</PRE>

<P>
<A NAME="IDX35"></A>
This line is present only for a unit that can be a main program.
<VAR>type</VAR> is either <CODE>P</CODE> for a parameterless procedure or <CODE>F</CODE>
for a function returning a value of integral type.  The latter is for
writing a main program that returns an exit status. <VAR>priority</VAR> is
present only if there was a valid pragma <CODE>Priority</CODE> in the
corresponding unit to set the main task priority. It is an unsigned
decimal integer.

</P>

<PRE>
   F x
</PRE>

<P>
This line is present if a pragma Float_Representation or Long_Float is
used to specify other than the default floating-point format.
This option
applies only to implementations of GNAT for the Digital Alpha Systems.
The character
x is 'I' for IEEE_Float, 'G' for VAX_Float with Long_Float using G_Float,
and 'D' for VAX_Float for Long_Float with D_Float.

</P>

<PRE>
   P L=x Q=x T=x
</PRE>

<P>
This line is present if the unit uses tasking directly or indirectly, and
has one or more valid xxx_Policy pragmas that apply to the unit. The
arguments are as follows

</P>

<PRE>
   L=x (locking policy)
</PRE>

<P>
This is present if a valid Locking_Policy pragma applies to the unit. The
single character indicates the policy in effect
(e.g. <SAMP>`C'</SAMP> for Ceiling_Locking).

</P>

<PRE>
   Q=x (queuing policy)
</PRE>

<P>
This is present if a valid Queuing_Policy pragma applies to the unit. The
single character indicates the policy in effect (e.g. <SAMP>`P'</SAMP> for
Priority_Queuing).

</P>

<PRE>
   T=x (task_dispatching policy)
</PRE>

<P>
This is present if a valid
Task_Dispatching_Policy pragma applies to the unit. The
single character indicates the policy
in effect (e.g. <SAMP>`F'</SAMP> for
FIFO_Within_Priorities).

</P>
<P>
Following these header lines is a set of information lines, one per
compilation unit. Each line lists a unit in the object file corresponding
to this ALI file.
In particular, when a package body or subprogram body is compiled there
will be two such lines, one for the spec and one for the body,
with the entry for the body appearing first. This is the only case in
which a single ALI file contains more than one unit. Note that
subunits do not count as compilation units for this purpose, and
generate no library information, because they are inlined.
The lines for each compilation unit have the following form:

</P>

<PRE>
   U <VAR>unit-name</VAR> <VAR>source-name</VAR> <VAR>version</VAR> [<VAR>attributes</VAR>]
</PRE>

<P>
<A NAME="IDX36"></A>
This line identifies the unit to which this section of the library
information file applies. <VAR>unit-name</VAR> is the unit name in internal
format, as described in package <CODE>Uname</CODE>, and <VAR>source-name</VAR> is
the name of the source file containing the unit.

</P>
<P>
<VAR>version</VAR> is the version, given by eight hexadecimal characters with
lowercase letters. This value is a hash code that includes
contributions from the time stamps of this unit and all the units on which
it semantically depends.

</P>
<P>
The optional <VAR>attributes</VAR> are a series of two-letter codes
indicating information about the unit. They indicate the nature of
the unit and they summarize information provided by
categorization pragmas.

</P>
<DL COMPACT>

<DT><CODE>EB</CODE>
<DD>
<A NAME="IDX37"></A>
Unit has pragma Elaborate_Body.

<DT><CODE>NE</CODE>
<DD>
Unit has no elaboration routine. All subprogram specs are in this
category, as are subprogram bodies if access-before-elaboration checks
are being generated. Package bodies and specs may or may not have
<CODE>NE</CODE> set, depending on whether or not elaboration code is required.

<DT><CODE>PK</CODE>
<DD>
Unit is a package.

<DT><CODE>PU</CODE>
<DD>
<A NAME="IDX38"></A>
Unit has pragma <CODE>Pure</CODE>.

<DT><CODE>PR</CODE>
<DD>
<A NAME="IDX39"></A>
Unit has pragma <CODE>Preelaborate</CODE>.

<DT><CODE>RC</CODE>
<DD>
<A NAME="IDX40"></A>
Unit has pragma <CODE>Remote_Call_Interface</CODE>.

<DT><CODE>RT</CODE>
<DD>
<A NAME="IDX41"></A>
Unit has pragma <CODE>Remote_Types</CODE>.

<DT><CODE>SP</CODE>
<DD>
<A NAME="IDX42"></A>
Unit has pragma <CODE>Shared_Passive</CODE>.

<DT><CODE>SU</CODE>
<DD>
Unit is a subprogram.
</DL>

<P>
The attributes may appear in any order, separated by spaces.  The next
set of lines in the ALI file have the following form:

</P>

<PRE>
   W <VAR>unit-name</VAR> [<VAR>source-name</VAR> <VAR>lib-name</VAR> [E] [EA] [ED]]
</PRE>

<P>
<A NAME="IDX43"></A>
<A NAME="IDX44"></A>
One of these lines is present for each unit mentioned in an explicit
<CODE>with</CODE> clause in the current unit. <VAR>unit-name</VAR> is the unit name
in internal format. <VAR>source-name</VAR> is the file name of the file that
must be compiled to compile that unit (usually the file for the body,
except for packages that have no body).  <VAR>lib-name</VAR> is the file name
of the library information file that contains the results of compiling
the unit. The <CODE>E</CODE> and <CODE>EA</CODE> parameters are present if
pragma <CODE>Elaborate</CODE> or pragma <CODE>Elaborate_All</CODE>, respectively,
apply to this unit. <CODE>ED</CODE> is used to indicate that the compiler
has determined that a pragma <CODE>Elaborate_All</CODE> for this unit would be
desirable. For details on the use of the ED parameter see
See section <A HREF="gnat_ug.html#SEC84">Elaboration Order Handling in GNAT</A>.

</P>
<P>
Following the unit information is an optional series of lines that
indicate the usage of pragma <CODE>Linker_Options</CODE>. For each appearance of
pragma <CODE>Linker_Options</CODE> in any of the units for which unit lines are
present, a line of the form

</P>

<PRE>
   L <VAR>string</VAR>
</PRE>

<P>
appears. <VAR>string</VAR> is the string from the pragma enclosed in
quotes. Within the quotes, the following can occur:

<UL>

<LI>

7-bit graphic characters other than " or {
<LI>

"" (indicating a single " character)

<LI>

{hh} indicating a character whose code is hex hh
</UL>

<P>
<A NAME="IDX45"></A>
<A NAME="IDX46"></A>
For further details, see <CODE>Stringt.Write_String_Table_Entry</CODE> in the
file <TT>`stringt.ads'</TT>. Note that wide characters of the form {hhhh}
cannot be produced, because <CODE>pragma Linker_Option</CODE> accepts only
<CODE>String</CODE>, not <CODE>Wide_String</CODE>.

</P>
<P>
Finally, the rest of the ALI file contains a series of lines that
indicate the source files on which the compiled units depend. This is
used by the binder for consistency checking and looks like:

<PRE>
   D <VAR>source-name</VAR> <VAR>time-stamp</VAR> [<VAR>comments</VAR>]
</PRE>

<P>
where
<VAR>comments</VAR>, if present, must be separated from the time stamp by at
least one blank. Currently this field is unused.

</P>
<P>
Blank lines are ignored when the library information is read, and
separate sections of the file are separated by blank lines to help
readability. Extra blanks between fields are also ignored.

</P>


<H2><A NAME="SEC22" HREF="gnat_ug_toc.html#TOC22">Representation of Time Stamps</A></H2>

<P>
All compiled units are marked with a time stamp, which is derived from
the source file. The binder uses these time stamps to ensure consistency
of the set of units that constitutes a single program. Time stamps are
fourteen-character strings of the form <VAR>YYYYMMDDHHMMSS</VAR>.  The
fields have the following meaning:

</P>
<DL COMPACT>

<DT><CODE>YYYY</CODE>
<DD>
year (4 digits)
<DT><CODE>MM</CODE>
<DD>
month (2 digits 01-12)
<DT><CODE>DD</CODE>
<DD>
day (2 digits 01-31)
<DT><CODE>HH</CODE>
<DD>
hour (2 digits 00-23)
<DT><CODE>MM</CODE>
<DD>
minutes (2 digits 00-59)
<DT><CODE>SS</CODE>
<DD>
seconds (2 digits 00-59)
</DL>

<P>
Time stamps may be compared lexicographically (in other words, the order
of Ada comparison operations on strings) to determine which is later or
earlier. However, in normal mode, only equality comparisons have any
effect on the semantics of the library. Later/earlier comparisons are
used only for determining the most informative error messages to be
issued by the binder.

</P>
<P>
The time stamp is the actual stamp stored with the file without any
adjustment resulting from time zone comparisons. This avoids problems in
using libraries across networks with clients spread across multiple time
zones, but it means that the time stamp might differ from that displayed in a
directory listing. For example, in UNIX systems,
file time stamps are stored in Greenwich Mean Time (GMT), but the
<CODE>ls</CODE> command displays local times.

</P>


<H2><A NAME="SEC23" HREF="gnat_ug_toc.html#TOC23">Binding an Ada Program</A></H2>

<P>
When using languages such as C and C++, once the source files have been
compiled the only remaining step in building an executable program
is linking the object modules together.  This means that it is possible to
link an inconsistent version of a program, in which two units have
included different versions of the same header.

</P>
<P>
The rules of Ada do not permit such an inconsistent program to be built.
For example, if two clients have different versions of the same package,
it is illegal to build a program containing these two clients.
These rules are enforced by the GNAT binder, which also determines an
elaboration order consistent with the Ada rules.

</P>
<P>
The GNAT binder is run after all the object files for a program have
been created. It is given the name of the main program unit, and from
this it determines the set of units required by the program, by reading the
corresponding ALI files. It generates error messages if the program is
inconsistent or if no valid order of elaboration exists.

</P>
<P>
If no errors are detected, the binder produces a main program, in Ada by
default, that contains calls to the elaboration procedures of those
compilation unit that require them, followed by
a call to the main program. This Ada program is compiled to generate the
object file for the main program. The name of
the Ada file is <CODE>b~<VAR>xxx</VAR>.adb</CODE> (with the corresponding spec
<CODE>b~<VAR>xxx</VAR>.ads</CODE>) where <VAR>xxx</VAR> is the name of the
main program unit.

</P>
<P>
Finally, the linker is used to build the resulting executable program,
using the object from the main program from the bind step as well as the
object files for the Ada units of the program.

</P>


<H2><A NAME="SEC24" HREF="gnat_ug_toc.html#TOC24">Mixed Language Programming</A></H2>
<P>
<A NAME="IDX47"></A>

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC25">Interfacing to C</A>
<LI><A HREF="gnat_ug.html#SEC26">Calling Conventions</A>
</UL>



<H3><A NAME="SEC25" HREF="gnat_ug_toc.html#TOC25">Interfacing to C</A></H3>
<P>
There are two ways to
build a program that contains some Ada files and some other language
files depending on whether the main program is in Ada or not.
If the main program is in Ada, you should proceed as follows:

</P>

<OL>
<LI>

Compile the other language files to generate object files. For instance:

<PRE>
gcc -c file1.c
gcc -c file2.c
</PRE>

<LI>

Compile the Ada units to produce a set of object files and ALI
files. For instance:

<PRE>
gnatmake -c my_main.adb
</PRE>

<LI>

Run the Ada binder on the Ada main program. For instance:

<PRE>
gnatbind my_main
</PRE>

<LI>

Link the Ada main program, the Ada objects and the other language
objects. For instance:

<PRE>
gnatlink my_main.ali file1.o file2.o
</PRE>

</OL>

<P>
The three last steps can be grouped in a single command:

<PRE>
gnatmake my_main.adb -largs file1.o file2.o
</PRE>

<P>
<A NAME="IDX48"></A>
If the main program is in some language other than Ada, Then you may
have more than one entry point in the Ada subsystem. You must use a
special option of the binder to generate callable routines to initialize
and finalize the Ada units (see section <A HREF="gnat_ug.html#SEC58">Binding with Non-Ada Main Programs</A>).
Calls to the initialization and finalization routines must be inserted in
the main program, or some other appropriate point in the code.  The call to
initialize the Ada units must occur before the first Ada subprogram is
called, and the call to finalize the Ada units must occur after the last
Ada subprogram returns. You use the same procedure for building the
program as described previously.  In this case, however, the binder
only places the initialization and finalization subprograms into file
<TT>`b~<VAR>xxx</VAR>.adb'</TT> instead of the main program.
So, if the main program is not in Ada, you should proceed as follows:

</P>

<OL>
<LI>

Compile the other language files to generate object files. For instance:

<PRE>
gcc -c file1.c
gcc -c file2.c
</PRE>

<LI>

Compile the Ada units to produce a set of object files and ALI
files. For instance:

<PRE>
gnatmake -c entry_point1.adb
gnatmake -c entry_point2.adb
</PRE>

<LI>

Run the Ada binder on the Ada main program. For instance:

<PRE>
gnatbind -n entry_point1 entry_point2
</PRE>

<LI>

Link the Ada main program, the Ada objects and the other language
objects. You only need to give the last entry point here. For instance:

<PRE>
gnatlink entry_point2.ali file1.o file2.o
</PRE>

</OL>



<H3><A NAME="SEC26" HREF="gnat_ug_toc.html#TOC26">Calling Conventions</A></H3>
<P>
<A NAME="IDX49"></A>
<A NAME="IDX50"></A>
GNAT follows standard calling sequence conventions and will thus interface
to any other language that also follows these conventions. The following
Convention identifiers are recognized by GNAT:

</P>

<UL>
<LI>

<A NAME="IDX51"></A>
 <A NAME="IDX52"></A>
 <A NAME="IDX53"></A>
 
Ada. This indicates that the standard Ada calling sequence will be
used and all Ada data items may be passed without any limitations in the
case where GNAT is used to generate both the caller and callee. It is also
possible to mix GNAT generated code and code generated by another Ada
compiler. In this case, the data types should be restricted to simple
cases, including primitive types. Whether complex data types can be passed
depends on the situation. Probably it is safe to pass simple arrays, such
as arrays of integers or floats. Records may or may not work, depending
on whether both compilers lay them out identically. Complex structures
involving variant records, access parameters, tasks, or protected types,
are unlikely to be able to be passed.

Note that in the case of GNAT running
on a platform that supports DEC Ada 83, a higher degree of compatibility
can be guaranteed, and in particular records are layed out in an identical
manner in the two compilers. Note also that if output from two different
compilers is mixed, the program is responsible for dealing with elaboration
issues. Probably the safest approach is to write the main program in the
version of Ada other than GNAT, so that it takes care of its own elaboration
requirements, and then call the GNAT-generated adainit procedure to ensure
elaboration of the GNAT components. Consult the documentation of the other
Ada compiler for further details on elaboration.

However, it is not possible to mix the tasking runtime of GNAT and
DEC Ada 83, All the tasking operations must either be entirely within
GNAT compiled sections of the program, or entirely within DEC Ada 83
compiled sections of the program.

<A NAME="IDX54"></A>
<A NAME="IDX55"></A>
<LI>

Asm. Equivalent to Ada.

<A NAME="IDX56"></A>
<LI>

Assembler. Equivalent to Ada.

<A NAME="IDX57"></A>
<A NAME="IDX58"></A>
<A NAME="IDX59"></A>
<LI>

COBOL. Data will be passed according to the conventions described
in section B.4 of the Ada 95 Reference Manual.

<A NAME="IDX60"></A>
<A NAME="IDX61"></A>
<A NAME="IDX62"></A>
<LI>

C. Data will be passed according to the conventions described
in section B.3 of the Ada 95 Reference Manual.

<A NAME="IDX63"></A>
<A NAME="IDX64"></A>
<A NAME="IDX65"></A>
<LI>

CPP. This stands for C++. For most purposes this is identical to C.
See the separate description of the specialized GNAT pragmas relating to
C++ interfacing for further details.

<A NAME="IDX66"></A>
<A NAME="IDX67"></A>
<A NAME="IDX68"></A>
<LI>

Fortran. Data will be passed according to the conventions described
in section B.5 of the Ada 95 Reference Manual.

<LI>

Intrinsic. This defines an intrinsic operation, as defined in the Ada 95
Reference Manual. Normally this is not used in application programs. The
one exception is that GNAT permits the use of Intrinsic for defining shift
operations on user defined (signed and unsigned) integer types.

<A NAME="IDX69"></A>
<A NAME="IDX70"></A>
<LI>

Stdcall. This is relevant only to NT/Win95 implementations of GNAT,
and specifies that the Stdcall calling sequence will be used, as defined
by the NT API.

<A NAME="IDX71"></A>
<A NAME="IDX72"></A>
<LI>

Stubbed. This is a special convention that indicates that the compiler
should provide a stub body that raises Program_Error.
</UL>



<H2><A NAME="SEC27" HREF="gnat_ug_toc.html#TOC27">Building mixed Ada &#38; C++ programs</A></H2>

<P>
Building a mixed application containing both Ada and C++ code may be a
challenge for the unaware programmer. As a matter of fact, this
interfacing has not been standardized in the Ada 95 reference manual due
to the immaturity and lack of standard of C++ at the time. This
section gives a few hints that should make this task easier. In
particular the first section addresses the differences with
interfacing with C. The second section looks into the delicate problem
of linking the complete application from its Ada and C++ parts. The last
section give some hints on how the GNAT runtime can be adapted in order
to allow inter-language dispatching with a new C++ compiler.

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC28">Interfacing to C++</A>
<LI><A HREF="gnat_ug.html#SEC29">Linking a mixed C++ &#38; Ada program</A>
<LI><A HREF="gnat_ug.html#SEC30">Adapting the runtime to a new C++ compiler</A>
</UL>



<H3><A NAME="SEC28" HREF="gnat_ug_toc.html#TOC28">Interfacing to C++</A></H3>

<P>
GNAT supports interfacing with C++ compilers generating code that is
compatible with the standard Application Binary Interface of the given
platform.

</P>
<P>
Interfacing can be done at 3 levels: simple data, subprograms and
classes. In the first 2 cases, GNAT offer a specific <VAR>Convention
CPP</VAR> that behaves exactly like <VAR>Convention C</VAR>. Usually C++ mangle
names of subprograms and currently GNAT does not provide any help to
solve the demangling problem. This problem can be addressed in 2 ways:

<UL>
<LI>

by modifying the C++ code in order to force a C convention using
the <VAR>extern "C"</VAR> syntax.

<LI>

by figuring out the mangled name and use it as the Link_Name argument of
the pragma import.
</UL>

<P>
Interfacing at the class level can be achieved by using the GNAT specific
pragmas such as <CODE>CPP_Class</CODE> and <CODE> CPP_Virtual</CODE>. See the GNAT
Reference Manual for additional information.

</P>


<H3><A NAME="SEC29" HREF="gnat_ug_toc.html#TOC29">Linking a mixed C++ &#38; Ada program</A></H3>

<P>
Usually the linker of the C++ development system must be used to link
mixed applications because most C++ systems will resolve elaboration
issues (such as calling constructors on global class instances)
transparently during the link phase. GNAT has been adapted to ease the
use of a foreign linker for the last phase. Three cases can be
considered:

<OL>

<LI>

Using GNAT and G++ (GNU C++ compiler) from the same GCC
installation. The c++ linker can simply be called by using the c++
specific driver called <CODE>c++</CODE>. Note that this setup is not
very common because it may request recompiling the whole GCC
tree from sources and it does not allow to upgrade easily to a new
version of one compiler for one of the two languages without taking the
risk of destabilizing the other.


<PRE>
$ c++ -c file1.C
$ c++ -c file2.C
$ gnatmake ada_unit -largs file1.o file2.o --LINK=c++
</PRE>

<LI>

Using GNAT and G++ from 2 different GCC installations.  If both
compilers are on the PATH, the same method can be used. It is important
to be aware that environment variables such as C_INCLUDE_PATH or
GCC_EXEC_PREFIX will affect both compilers at the same time and thus may
make one of the 2 compilers operate improperly if they are set for the
other. In particular it is important that the link command has access to
the proper gcc library 'libgcc.a', that is to say the one that is part
of the C++ compiler installation. The implicit link command as suggested
in the gnatmake command from the former example can be replaced by an
explicit link command with full verbosity in order to verify which
library is used:

<PRE>
$ gnatbind ada_unit
$ gnatlink -v -v ada_unit file1.o file2.o --LINK=c++
</PRE>

If there is a problem due to interfering environment variables, it can be
workaround by using an intermediate script:


<PRE>
$ gnatlink -v -v ada_unit file1.o file2.o --LINK=./my_script
$ cat ./my_script
#!/bin/sh
unset C_INCLUDE_PATH
unset GCC_EXEC_PREFIX
c++ $*
</PRE>

<LI>

Using a non GNU C++ compiler.  The same set of command as previously
described can be used to insure that the c++ linker is
used. Nonetheless, the Ada code may implicitly depend on the gcc
library. The latter can be located thanks to gnatls: it is to be found
on the last directory of the object path. It must then be explicitly
mentioned in the link command :

<PRE>
$ gnatls -v
$ Gdir=&#60;the last directory on the object path&#62;
$ gnatlink ada_unit file1.o file2.o -L$Gdir -lgcc --LINK=&#60;cpp_linker&#62;
</PRE>

</OL>



<H3><A NAME="SEC30" HREF="gnat_ug_toc.html#TOC30">Adapting the runtime to a new C++ compiler</A></H3>
<P>
GNAT offers the capability to derive Ada 95 tagged types directly from
preexisting C++ classes and . See "Interfacing with C++" in the GNAT
reference manual. The mechanism used by GNAT for achieving such a goal
has been made user configurable through a GNAT library unit
<CODE>Interfaces.CPP</CODE>. The default version of this file is adapted to
the GNU c++ compiler. Internal knowledge of the virtual
table layout used by the new C++ compiler is needed to configure
properly this unit. The Interface of this unit is known by the compiler
and cannot be changed except for the value of the constants defining the
characteristics of the virtual table: CPP_DT_Prologue_Size, CPP_DT_Entry_Size,
CPP_TSD_Prologue_Size, CPP_TSD_Entry_Size. Read comments in the source
of this unit for more details.

</P>



<H2><A NAME="SEC31" HREF="gnat_ug_toc.html#TOC31">Comparison between GNAT and C/C++ Compilation Models</A></H2>

<P>
The GNAT model of compilation is close to the C and C++ models. You can
think of Ada specs as corresponding to header files in C. As in C, you
don't need to compile specs; they are compiled when they are used. The
Ada <CODE>with</CODE> is similar in effect to the <CODE>#include</CODE> of a C
header.

</P>
<P>
One notable difference is that, in Ada, you may compile specs separately
to check them for semantic and syntactic accuracy. This is not always
possible with C headers because they are fragments of programs that have
less specific syntactic or semantic rules.

</P>
<P>
The other major difference is the requirement for running the binder,
which performs two important functions. First, it checks for
consistency. In C or C++, the only defense against assembling
inconsistent programs lies outside the compiler, in a makefile, for
example. The binder satisfies the Ada requirement that it be impossible
to construct an inconsistent program when the compiler is used in normal
mode.

</P>
<P>
<A NAME="IDX73"></A>
The other important function of the binder is to deal with elaboration
issues. There are also elaboration issues in C++ that are handled
automatically.  This automatic handling has the advantage of being
simpler to use, but the C++ programmer has no control over elaboration.
Where <CODE>gnatbind</CODE> might complain there was no valid order of
elaboration, a C++ compiler would simply construct a program that
malfunctioned at run time.

</P>


<H2><A NAME="SEC32" HREF="gnat_ug_toc.html#TOC32">Comparison between GNAT and Conventional Ada Library Models</A></H2>

<P>
This section is intended to be useful to Ada programmers who have
previously used an Ada compiler implementing the traditional Ada library
model, as described in the Ada 95 Language Reference Manual. If you
have not used such a system, please go on to the next section.

</P>
<P>
<A NAME="IDX74"></A>
In GNAT, there is no <STRONG>library</STRONG> in the normal sense. Instead, the set of
source files themselves acts as the library. Compiling Ada programs does
not generate any centralized information, but rather an object file and
a ALI file, which are of interest only to the binder and linker.
In a traditional system, the compiler reads information not only from
the source file being compiled, but also from the centralized library.
This means that the effect of a compilation depends on what has been
previously compiled. In particular:

</P>

<UL>
<LI>

When a unit is <CODE>with</CODE>'ed, the unit seen by the compiler corresponds
to the version of the unit most recently compiled into the library.

<LI>

Inlining is effective only if the necessary body has already been
compiled into the library.

<LI>

Compiling a unit may obsolete other units in the library.
</UL>

<P>
In GNAT, compiling one unit never affects the compilation of any other
units because the compiler reads only source files. Only changes to source
files can affect the results of a compilation. In particular:

</P>

<UL>
<LI>

When a unit is <CODE>with</CODE>'ed, the unit seen by the compiler corresponds
to the source version of the unit that is currently accessible to the
compiler.

<LI>

<A NAME="IDX75"></A>
Inlining requires the appropriate source files for the package or
subprogram bodies to be available to the compiler. Inlining is always
effective, independent of the order in which units are complied.

<LI>

Compiling a unit never affects any other compilations. The editing of
sources may cause previous compilations to be out of date if they
depended on the source file being modified.
</UL>

<P>
The most important result of these differences is that order of compilation
is never significant in GNAT. There is no situation in which one is
required to do one compilation before another. What shows up as order of
compilation requirements in the traditional Ada library becomes, in
GNAT, simple source dependencies; in other words, there is only a set
of rules saying what source files must be present when a file is
compiled.

</P>


<H1><A NAME="SEC33" HREF="gnat_ug_toc.html#TOC33">Compiling Using <CODE>gcc</CODE></A></H1>

<P>
This chapter discusses how to compile Ada programs using the <CODE>gcc</CODE>
command. It also describes the set of switches
that can be used to control the behavior of the compiler.

<UL>
<LI><A HREF="gnat_ug.html#SEC34">Compiling Programs</A>
<LI><A HREF="gnat_ug.html#SEC35">Switches for gcc</A>
<LI><A HREF="gnat_ug.html#SEC49">Search Paths and the Run-Time Library (RTL)</A>
<LI><A HREF="gnat_ug.html#SEC50">Order of Compilation Issues</A>
<LI><A HREF="gnat_ug.html#SEC51">Examples</A>
</UL>



<H2><A NAME="SEC34" HREF="gnat_ug_toc.html#TOC34">Compiling Programs</A></H2>

<P>
The first step in creating an executable program is to compile the units
of the program using the <CODE>gcc</CODE> command. You must compile the
following files:

</P>

<UL>
<LI>

the body file (<TT>`.adb'</TT>) for a library level subprogram or generic
subprogram

<LI>

the spec file (<TT>`.ads'</TT>) for a library level package or generic
package that has no body

<LI>

the body file (<TT>`.adb'</TT>) for a library level package
or generic package that has a body

</UL>

<P>
You need <EM>not</EM> compile the following files

</P>

<UL>

<LI>

the spec of a library unit which has a body

<LI>

subunits
</UL>

<P>
because they are compiled as part of compiling related units. GNAT
package specs
when the corresponding body is compiled, and subunits when the parent is
compiled.
<A NAME="IDX76"></A>
If you attempt to compile any of these files, you will get one of the
following error messages (where fff is the name of the file you compiled):

</P>

<PRE>
   No code generated for file <VAR>fff</VAR> (<VAR>package spec</VAR>)
   No code generated for file <VAR>fff</VAR> (<VAR>subunit</VAR>)
</PRE>

<P>
The basic command for compiling a file containing an Ada unit is

</P>

<PRE>
   $ gcc -c [<VAR>switches</VAR>] <TT>`file name'</TT>
</PRE>

<P>
where <VAR>file name</VAR> is the name of the Ada file (usually
having an extension
<TT>`.ads'</TT> for a spec or <TT>`.adb'</TT> for a body).
You specify the
<CODE>-c</CODE> switch to tell <CODE>gcc</CODE> to compile, but not link, the file.
The result of a successful compilation is an object file, which has the
same name as the source file but an extension of <TT>`.o'</TT> and an Ada
Library Information (ALI) file, which also has the same name as the
source file, but with <TT>`.ali'</TT> as the extension. GNAT creates these
two output files in the current directory, but you may specify a source
file in any directory using an absolute or relative path specification
containing the directory information.

</P>
<P>
<A NAME="IDX77"></A>
<CODE>gcc</CODE> is actually a driver program that looks at the extensions of
the file arguments and loads the appropriate compiler. For example, the
GNU C compiler is <TT>`cc1'</TT>, and the Ada compiler is <TT>`gnat1'</TT>.
These programs are in directories known to the driver program (in some
configurations via environment variables you set), but need not be in
your path.  The <CODE>gcc</CODE> driver also calls the assembler and any other
utilities needed to complete the generation of the required object
files.

</P>
<P>
It is possible to supply several file names on the same <CODE>gcc</CODE>
command. This causes <CODE>gcc</CODE> to call the appropriate compiler for
each file. For example, the following command lists three separate
files to be compiled:

</P>

<PRE>
   $ gcc -c x.adb y.adb z.c
</PRE>

<P>
calls <CODE>gnat1</CODE> (the Ada compiler) twice to compile <TT>`x.adb'</TT> and
<TT>`y.adb'</TT>, and <CODE>cc1</CODE> (the C compiler) once to compile <TT>`z.c'</TT>.
The compiler generates three object files <TT>`x.o'</TT>, <TT>`y.o'</TT> and
<TT>`z.o'</TT> and the two ALI files <TT>`x.ali'</TT> and <TT>`y.ali'</TT> from the
Ada compilations. Any switches apply to all the files listed,
except for
<CODE>-gnat<VAR>x</VAR></CODE> switches, which apply only to Ada compilations.

</P>


<H2><A NAME="SEC35" HREF="gnat_ug_toc.html#TOC35">Switches for <CODE>gcc</CODE></A></H2>

<P>
The <CODE>gcc</CODE> command accepts numerous switches to control the
compilation process. These switches are fully described in this section.

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC36">Output and Error Message Control</A>
<LI><A HREF="gnat_ug.html#SEC37">Debugging and Assertion Control</A>
<LI><A HREF="gnat_ug.html#SEC39">Run-time Checks</A>
<LI><A HREF="gnat_ug.html#SEC38">Style Checking</A>
<LI><A HREF="gnat_ug.html#SEC40">Using gcc for Syntax Checking</A>
<LI><A HREF="gnat_ug.html#SEC41">Using gcc for Semantic Checking</A>
<LI><A HREF="gnat_ug.html#SEC42">Compiling Ada 83 Programs</A>
<LI><A HREF="gnat_ug.html#SEC43">Reference Manual Style Checking</A>
<LI><A HREF="gnat_ug.html#SEC44">Character Set Control</A>
<LI><A HREF="gnat_ug.html#SEC45">File Naming Control</A>
<LI><A HREF="gnat_ug.html#SEC46">Subprogram Inlining Control</A>
<LI><A HREF="gnat_ug.html#SEC47">Auxiliary Output Control</A>
<LI><A HREF="gnat_ug.html#SEC48">Debugging Control</A>
</UL>

<DL COMPACT>

<DT><CODE>-b <VAR>target</VAR></CODE>
<DD>
<A NAME="IDX78"></A>
 
Compile your program to run on <VAR>target</VAR>, which is the name of a
system configuration.  You must have a GNAT cross-compiler built if
<VAR>target</VAR> is not the same as your host system.

<DT><CODE>-B<VAR>dir</VAR></CODE>
<DD>
<A NAME="IDX79"></A>
Load compiler executables (for example, <CODE>gnat1</CODE>, the Ada compiler)
from <VAR>dir</VAR> instead of the default location. Only use this switch
when multiple versions of the GNAT compiler are available. See the
<CODE>gcc</CODE> manual page for further details.  You would normally use the
<CODE>-b</CODE> or <CODE>-V</CODE> switch instead.

<DT><CODE>-c</CODE>
<DD>
<A NAME="IDX80"></A>
Compile. Always use this switch when compiling Ada programs.

Note that you may not use <CODE>gcc</CODE> without a <CODE>-c</CODE> switch to
compile and link in one step. This is because the binder must be run,
and currently <CODE>gcc</CODE> cannot be used to run the GNAT binder.

<DT><CODE>-g</CODE>
<DD>
<A NAME="IDX81"></A>
Generate debugging information. This information is stored in the object
file and copied from there to the final executable file by the linker,
where it can be read by the debugger. You must use the <CODE>-g</CODE> switch
if you plan on using the debugger.

<DT><CODE>-I<VAR>dir</VAR></CODE>
<DD>
<A NAME="IDX82"></A>
<A NAME="IDX83"></A>
Direct GNAT to search the <VAR>dir</VAR> directory for source files needed by
the current compilation (see section <A HREF="gnat_ug.html#SEC49">Search Paths and the Run-Time Library (RTL)</A>).

<DT><CODE>-I-</CODE>
<DD>
<A NAME="IDX84"></A>
<A NAME="IDX85"></A>
Do not look for source files in the directory containing the source
file named in the command line
(see section <A HREF="gnat_ug.html#SEC49">Search Paths and the Run-Time Library (RTL)</A>).

<DT><CODE>-o <VAR>file</VAR></CODE>
<DD>
<A NAME="IDX86"></A>
This switch is used in <CODE>gcc</CODE> to redirect the generated object file
and its associated ALI file. Beware of this switch with GNAT, because it may
cause the object file and ALI file to have different names which in turn
may confuse the binder and the linker.

<DT><CODE>-O[<VAR>n</VAR>]</CODE>
<DD>
<A NAME="IDX87"></A>
<VAR>n</VAR> controls the optimization level.

<DL COMPACT>

<DT>n = 0
<DD>
No optimization, the default setting if no <CODE>-O</CODE> appears

<DT>n = 1
<DD>
Normal optimization, the default if you specify <CODE>-O</CODE> without
an operand.

<DT>n = 2
<DD>
Extensive optimization

<DT>n = 3
<DD>
Extensive optimization with automatic inlining. This applies only to
inlining within a unit. For details on control of inter-unit inlining
see See section <A HREF="gnat_ug.html#SEC46">Subprogram Inlining Control</A>.
</DL>

<DT><CODE>-S</CODE>
<DD>
<A NAME="IDX88"></A>
Used in place of <CODE>-c</CODE> to
cause the assembler source file to be
generated, using <TT>`.s'</TT> as the extension,
instead of the object file.
This may be useful if you need to examine the generated assembly code.

<DT><CODE>-v</CODE>
<DD>
<A NAME="IDX89"></A>
Show commands generated by the <CODE>gcc</CODE> driver. Normally used only for
debugging purposes or if you need to be sure what version of the
compiler you are executing.

<DT><CODE>-V <VAR>ver</VAR></CODE>
<DD>
<A NAME="IDX90"></A>
Execute <VAR>ver</VAR> version of the compiler.  This is the <CODE>gcc</CODE>
version, not the GNAT version.

<DT><CODE>-Wuninitialized</CODE>
<DD>
<A NAME="IDX91"></A>
Generate warnings for uninitialized variables. You must also specify the
<CODE>-O</CODE> switch (in other words, This switch works only if
optimization is turned on).

<DT><CODE>-gnata</CODE>
<DD>
Assertions enabled. <CODE>Pragma Assert</CODE> and <CODE>pragma Debug</CODE> to be
activated.

<DT><CODE>-gnatb</CODE>
<DD>
Generate brief messages to <CODE>stderr</CODE> even if verbose mode set.

<DT><CODE>-gnatc</CODE>
<DD>
Check syntax and semantics only (no code generation attempted).

<DT><CODE>-gnatD</CODE>
<DD>
Output expanded source files for source level debugging.

<DT><CODE>-gnate</CODE>
<DD>
Force error message generation (for use when compiler crashes).

<DT><CODE>-gnatE</CODE>
<DD>
Full dynamic elaboration checks.

<DT><CODE>-gnatf</CODE>
<DD>
Full errors. Multiple errors per line, all undefined references.

<DT><CODE>-gnatg</CODE>
<DD>
GNAT style checks enabled.

<DT><CODE>-gnatG</CODE>
<DD>
List generated expanded code in source form.

<DT><CODE>-gnati<VAR>c</VAR></CODE>
<DD>
Identifier character set
(<VAR>c</VAR>=1/2/3/4/8/p/f/n/w).

<DT><CODE>-gnath</CODE>
<DD>
Output usage information. The output is written to <CODE>stdout</CODE>.

<DT><CODE>-gnatk<VAR>n</VAR></CODE>
<DD>
Limit file names to <VAR>n</VAR> (1-999) characters (<CODE>k</CODE> = krunch).

<DT><CODE>-gnatl</CODE>
<DD>
Output full source listing with embedded error messages.

<DT><CODE>-gnatm<VAR>n</VAR></CODE>
<DD>
Limit number of detected errors to <VAR>n</VAR> (1-999).

<DT><CODE>-gnatn</CODE>
<DD>
Activate inlining across unit boundaries for subprograms for which
pragma <CODE>inline</CODE> is specified.

<DT><CODE>-gnatN</CODE>
<DD>
Activate inlining across unit boundaries for all subprograms (not just
those for which pragma <CODE>inline</CODE> is specified. This is equivalent
to using <CODE>-gnatn</CODE> and adding a pragma <CODE>inline</CODE> for every
subprogram in the program.

<DT><CODE>-fno-inline</CODE>
<DD>
Suppresses all inlining, even if other optimization or inlining switches
are set.

<DT><CODE>-gnato</CODE>
<DD>
Enable other checks, not normally enabled by default, including numeric
overflow checking, and access before elaboration checks.

<DT><CODE>-gnatp</CODE>
<DD>
Suppress all checks.

<DT><CODE>-gnatq</CODE>
<DD>
Don't quit; try semantics, even if parse errors.

<DT><CODE>-gnatP</CODE>
<DD>
Enable polling. This is required on some systems (notably Windows NT) to
obtain asynchronous abort and asynchronous transfer of control capability.
See the description of pragma Polling in the GNAT Reference Manual for
full details.

<DT><CODE>-gnatR</CODE>
<DD>
Output representation information for declared array and record types.

<DT><CODE>-gnats</CODE>
<DD>
Syntax check only.

<DT><CODE>-gnatt</CODE>
<DD>
Tree output file to be generated.

<DT><CODE>-gnatu</CODE>
<DD>
List units for this compilation.

<DT><CODE>-gnatU</CODE>
<DD>
Tag all error messages with the unique string "error:"

<DT><CODE>-gnatv</CODE>
<DD>
Verbose mode. Full error output with source lines to <CODE>stdout</CODE>.

<DT><CODE>-gnatw<VAR>m</VAR></CODE>
<DD>
Warning mode
(<VAR>m</VAR>=<CODE>s,e,l</CODE> for suppress, treat as error, elaboration
warnings).

<DT><CODE>-gnatW<VAR>e</VAR></CODE>
<DD>
Wide character encoding method
(<VAR>e</VAR>=n/h/u/s/e/8).

<DT><CODE>-gnatx</CODE>
<DD>
Suppress generation of cross-reference information.

<DT><CODE>-gnatw<VAR>m</VAR></CODE>
<DD>
Warning mode
<DT><CODE>-gnaty</CODE>
<DD>
Enable built-in style checks. See separate section describing this feature.

<DT><CODE>-gnatz<VAR>m</VAR></CODE>
<DD>
Distribution stub generation and compilation
(<VAR>m</VAR>=r/c for receiver/caller stubs).

<DT><CODE>-gnat83</CODE>
<DD>
Enforce Ada 83 restrictions.

<DT><CODE>-gnat95</CODE>
<DD>
Standard Ada 95 mode
</DL>

<P>
You may combine a sequence of GNAT switches into a single switch. For
example, the combined switch

</P>
<P>
<A NAME="IDX92"></A>

<PRE>
   -gnatcfi3
</PRE>

<P>
is equivalent to specifying the following sequence of switches:

</P>

<PRE>
   -gnatc -gnatf -gnati3
</PRE>



<H3><A NAME="SEC36" HREF="gnat_ug_toc.html#TOC36">Output and Error Message Control</A></H3>
<P>
<A NAME="IDX93"></A>

</P>
<P>
The standard default format for error messages is called "brief format."
Brief format messages are written to <CODE>stdout</CODE> (the standard output
file) and have the following form:

</P>

<PRE>
   e.adb:3:04: Incorrect spelling of keyword "function"
   e.adb:4:20: ";" should be "is"
</PRE>

<P>
The first integer after the file name is the line number in the file,
and the second integer is the column number within the line.
<CODE>emacs</CODE> can parse the error messages
and point to the referenced character.
The following switches provide control over the error message
format:

</P>
<DL COMPACT>

<DT><CODE>-gnatv</CODE>
<DD>
<A NAME="IDX94"></A>
<A NAME="IDX95"></A>
The v stands for verbose.
The effect of this setting is to write long-format error
messages to <CODE>stdout</CODE>. The same program compiled with the
<CODE>-gnatv</CODE> switch would generate:


<PRE>
   3. funcion X (Q : Integer)
      |
   &#62;&#62;&#62; Incorrect spelling of keyword "function"
   4. return Integer;
                    |
   &#62;&#62;&#62; ";" should be "is"
</PRE>

The vertical bar indicates the location of the error, and the <SAMP>`&#62;&#62;&#62;'</SAMP>
prefix can be used to search for error messages. When this switch is
used the only source lines output are those with errors.

<DT><CODE>-gnatl</CODE>
<DD>
<A NAME="IDX96"></A>
The <CODE>l</CODE> stands for list.
This switch causes a full listing of
the file to be generated. The output might look as follows:


<PRE>
    1. procedure E is
    2.    V : Integer;
    3.    funcion X (Q : Integer)
          |
       &#62;&#62;&#62; Incorrect spelling of keyword "function"
    4.     return Integer;
                         |
       &#62;&#62;&#62; ";" should be "is"
    5.    begin
    6.       return Q + Q;
    7.    end;
    8. begin
    9.    V := X + X;
   10.end E;
</PRE>

When you specify the <CODE>-gnatv</CODE> or <CODE>-gnatl</CODE> switches and
standard output is redirected, a brief summary is written to
<CODE>stderr</CODE> (standard error) giving the number of error messages and
warning messages generated.

<DT><CODE>-gnatU</CODE>
<DD>
<A NAME="IDX97"></A>
This switch forces all error messages to be preceded by the unique
string "error:". This means that error messages take a few more
characters in space, but allows easy searching for and identification
of error messages.

<DT><CODE>-gnatb</CODE>
<DD>
<A NAME="IDX98"></A>
The <CODE>b</CODE> stands for brief.
This switch causes GNAT to generate the
brief format error messages to <CODE>stdout</CODE> as well as the verbose
format message or full listing.

<DT><CODE>-gnatm<VAR>n</VAR></CODE>
<DD>
<A NAME="IDX99"></A>
The <CODE>m</CODE> stands for maximum.
<VAR>n</VAR> is a decimal integer in the
range of 1 to 999 and limits the number of error messages to be
generated. For example, using <CODE>-gnatm2</CODE> might yield


<PRE>
   e.adb:3:04: Incorrect spelling of keyword "function"
   e.adb:5:35: missing ".."
   fatal error: maximum errors reached
   compilation abandoned
</PRE>

<DT><CODE>-gnatf</CODE>
<DD>
<A NAME="IDX100"></A>
<A NAME="IDX101"></A>
The <CODE>f</CODE> stands for full.
Normally, the compiler suppresses error messages that are likely to be
redundant. This switch causes all error
messages to be generated. In particular, in the case of
references to undefined variables. If a given variable is referenced
several times, the normal format of messages is


<PRE>
   e.adb:7:07: "V" is undefined (more references follow)
</PRE>

where the parenthetical comment warns that there are additional
references to the variable <CODE>V</CODE>. Compiling the same program with the
<CODE>-gnatf</CODE> switch yields


<PRE>
   e.adb:7:07: "V" is undefined
   e.adb:8:07: "V" is undefined
   e.adb:8:12: "V" is undefined
   e.adb:8:16: "V" is undefined
   e.adb:9:07: "V" is undefined
   e.adb:9:12: "V" is undefined
</PRE>

<DT><CODE>-gnatq</CODE>
<DD>
<A NAME="IDX102"></A>
The <CODE>q</CODE> stands for quit (really "don't quit").
In normal operation mode, the compiler first parses the program and
determines if there are any syntax errors. If there are, appropriate
error messages are generated and compilation is immediately terminated.
This switch tells
GNAT to continue with semantic analysis even if syntax errors have been
found.  This may enable the detection of more errors in a single run. On
the other hand, the semantic analyzer is more likely to encounter some
internal fatal error when given a syntactically invalid tree.

<DT><CODE>-gnate</CODE>
<DD>
<A NAME="IDX103"></A>
Normally, the compiler saves up error messages and generates them at the
end of compilation in proper sequence.  This switch
 (the <SAMP>`e'</SAMP> stands for error)
causes error messages to be generated as soon as they are
detected. The use of <CODE>-gnate</CODE> may cause error messages to be
generated out of sequence and also disconnects a number of useful
error message processing circuits. This switch should be used only
in error situations where the compiler terminates with no output
at all, or goes into an infinite loop. In such cases, the
<CODE>-gnate</CODE> switch may be used to see if any error situations
were detected before the compiler crash (see section <A HREF="gnat_ug.html#SEC157">GNAT Abnormal Termination</A>).
</DL>

<P>
In addition to error messages, which correspond to illegalities as defined
in the Ada 95 Reference Manual, the compiler detects two kinds of warning
situations.

</P>
<P>
<A NAME="IDX104"></A>
First, the compiler considers some constructs suspicious and generates a
warning message to alert you to a possible error. Second, if the
compiler detects a situation that is sure to raise an exception at
run time, it generates a warning message. The following shows an example
of warning messages:

</P>

<PRE>
   e.adb:4:24: warning: creation of object may raise Storage_Error
   e.adb:10:17: warning: static value out of range
   e.adb:10:17: warning: "Constraint_Error" will be raised at run time
</PRE>

<P>
GNAT considers a large number of situations as appropriate
for the generation of warning messages. As always, warnings are not
definite indications of errors. For example, if you do an out-of-range
assignment with the deliberate intention of raising a
<CODE>Constraint_Error</CODE> exception, then the warning that may be
issued does not indicate an error. Some of the situations for which GNAT
issues warnings (at least some of the time) are:

</P>

<UL>
<LI>

Possible infinitely recursive calls

<LI>

Out-of-range values being assigned

<LI>

Possible order of elaboration problems

<LI>

Unreachable code

<LI>

Variables that are never assigned a value

<LI>

Variables that are referenced before being initialized

<LI>

Task entries with no corresponding Accept statement

<LI>

Duplicate Accepts for the same task entry in a select

<LI>

Objects that take too much storage

<LI>

Unchecked conversion between types of differing sizes

<LI>

Missing return statements along some execution paths in a function

<LI>

Incorrect pragmas

<LI>

Incorrect external names

<LI>

Allocation from empty storage pool

<LI>

Potentially blocking operations in protected types

<LI>

Suspicious parenthesization of expressions

<LI>

Mismatching bounds in an aggregate

<LI>

Attempt to return local value by reference

<LI>

Unrecognized pragmas

<LI>

Premature instantiation of a generic body

<LI>

Attempt to pack aliased components

<LI>

Out of bounds array subscripts

<LI>

Wrong length on string assignment
</UL>

<P>
Four switches are available to control the handling of warning messages:

</P>
<DL COMPACT>

<DT><CODE>-gnatwe (treat warnings as errors)</CODE>
<DD>
<A NAME="IDX105"></A>
This switch causes warning messages to be treated as errors.
The warning string still appears, but the warning messages are counted
as errors, and prevent the generation of an object file.

<DT><CODE>-gnatws (suppress warnings)</CODE>
<DD>
<A NAME="IDX106"></A>
This switch completely suppresses the
output of all warning messages.

<DT><CODE>-gnatwl (warn on elaboration order errors)</CODE>
<DD>
<A NAME="IDX107"></A>
This switch causes the generation
of additional warning messages relating to elaboration issues. See the
separate chapter on elaboration order handling for full details of the
use of this switch.

<DT><CODE>-gnatwu (warn on unused entities)</CODE>
<DD>
<A NAME="IDX108"></A>
This switch causes warning messages to be generated for entities that
are defined but not referenced, and for units that are <CODE>with</CODE>'ed
and not
referenced. In the case of packages, a warning is also generated if
no entities in the package are referenced. This means that if the package
is referenced but the only references are in <CODE>use</CODE>
clauses or <CODE>renames</CODE>
declarations, a warning is still generated. A warning is also generated
for a generic package that is <CODE>with</CODE>'ed but never instantiated.

<DT><CODE>-gnatR</CODE>
<DD>
<A NAME="IDX109"></A>
Use of the switch <CODE>-gnatR</CODE> causes the compiler to output a listing
showing representation information for declared array and record types,
including record representation clauses.

<DT><CODE>-gnatx</CODE>
<DD>
<A NAME="IDX110"></A>
Normally the compiler generates full cross-referencing information in
the <TT>`ALI'</TT> file. This information is used by a number of tools,
including <CODE>gnatfind</CODE> and <CODE>gnatxref</CODE>. The -gnatx switch
suppresses this information. This saves some space and may slightly
speed up compilation, but means that these tools cannot be used.
</DL>



<H3><A NAME="SEC37" HREF="gnat_ug_toc.html#TOC37">Debugging and Assertion Control</A></H3>

<DL COMPACT>

<DT><CODE>-gnata</CODE>
<DD>
<A NAME="IDX111"></A>
<A NAME="IDX112"></A>
<A NAME="IDX113"></A>
<A NAME="IDX114"></A>

The pragmas <CODE>Assert</CODE> and <CODE>Debug</CODE> normally have no effect and
are ignored. This switch, where <SAMP>`a'</SAMP> stands for assert, causes
<CODE>Assert</CODE> and <CODE>Debug</CODE> pragmas to be activated.

The pragmas have the form:


<PRE>
   <B>pragma</B> Assert (<VAR>Boolean-expression</VAR> [, <VAR>static-string-expression</VAR>])
   <B>pragma</B> Debug (<VAR>procedure call</VAR>)
</PRE>

The <CODE>Assert</CODE> pragma causes <VAR>Boolean-expression</VAR> to be tested.
If the result is <CODE>True</CODE>, the pragma has no effect (other than
possible side effects from evaluating the expression). If the result is
<CODE>False</CODE>, the exception <CODE>Assert_Error</CODE> declared in the package
<CODE>System.Assertions</CODE> is
raised (passing <VAR>static-string-expression</VAR>, if present, as the
message associated with the exception). If no string expression is
given the default is a string giving the file name and line number
of the pragma.

The <CODE>Debug</CODE> pragma causes <VAR>procedure</VAR> to be called. Note that
<CODE>pragma Debug</CODE> may appear within a declaration sequence, allowing
debugging procedures to be called between declarations.

</DL>



<H3><A NAME="SEC38" HREF="gnat_ug_toc.html#TOC38">Style Checking</A></H3>
<P>
<A NAME="IDX115"></A>

</P>
<P>
The -gnaty<VAR>x</VAR> switch causes the compiler to
enforce specified style rules. A limited set of style rules has been used
in writing the GNAT sources themselves. This switch allows user programs
to activate all or some of these checks. If the source program fails a
specified style check, an appropriate error message is given, preceded by
the character sequence "(style)", and the program is considered illegal.
The string <VAR>x</VAR> is a sequence of letters or digits
indicating the particular style
checks to be performed. The following checks are defined:

</P>
<DL COMPACT>

<DT><CODE>1-9 (specify indentation level)</CODE>
<DD>
If a digit from 1-9 appears in the string after <CODE>-gnaty</CODE> then proper
indentation is checked, with the digit indicating the indentation level
required. The general style of required indentation is as specified by
the examples in the Ada Reference Manual. Full line comments must be
aligned with the <CODE>--</CODE> starting on a column that is a multiple of
the alignment level.

<DT><CODE>a (check attribute casing)</CODE>
<DD>
If the letter a appears in the string after <CODE>-gnaty</CODE> then
attribute names, including the case of keywords such as <CODE>digits</CODE>
used as attributes names, must be written in mixed case, that is, the
initial letter and any letter following an underscore must be uppercase.
All other letters must be lowercase.

<DT><CODE>b (blanks not allowed at statement end)</CODE>
<DD>
If the letter b appears in the string after <CODE>-gnaty</CODE> then
trailing blanks are not allowed at the end of statements. The purpose of this
rule, together with h (no horizontal tabs), is to enforce a canonical format
for the use of blanks to separate source tokens.

<DT><CODE>c (check comments)</CODE>
<DD>
If the letter c appears in the string after <CODE>-gnaty</CODE> then
comments must meet the following set of rules:


<UL>

<LI>

The "--" that starts the column must either start in column one, or else
at least one blank must precede this sequence.

<LI>

Comments that follow other tokens on a line must have at least one blank
following the "--" at the start of the comment.

<LI>

Full line comments must have two blanks following the "--" that starts
the comment, with the following exceptions.

<LI>

A line consisting only of the "--" characters, possibly preceded by blanks
is permitted.

<LI>

A comment starting with "--!" is permitted. This allows proper processing
of the output generated by the <CODE>gnatprep</CODE> tool.

<LI>

A line consisting entirely of minus signs, possibly preceded by blanks, is
permitted. This allows the construction of box comments where lines of minus
signs are used to form the top and bottom of the box.

<LI>

If a comment starts and ends with "--" is permitted as long as at least
one blank follows the initial "--". Together with the preceding rule,
this allows the construction of box comments, as shown in the following
example:

<PRE>
   ---------------------------
   -- This is a box comment --
   -- with two text lines.  --
   ---------------------------
</PRE>

</UL>

<DT><CODE>e (check end labels)</CODE>
<DD>
If the letter e appears in the string after <CODE>-gnaty</CODE> then
optional labels on <CODE>end</CODE> statements ending subprograms are required to be
present.

<DT><CODE>f (no form feeds or vertical tabs)</CODE>
<DD>
If the letter f appears in the string after <CODE>-gnaty</CODE> then
neither form feeds nor vertical tab characters are not permitted
in the source text.

<DT><CODE>h (no horizontal tabs)</CODE>
<DD>
If the letter h appears in the string after <CODE>-gnaty</CODE> then
horizontal tab characters are not permitted in the source text.
Together with the b (no blanks at end of line) check, this
enforces a canonical form for the use of blanks to separate
source tokens.

<DT><CODE>i (check if-then layout)</CODE>
<DD>
If the letter i appears in the string after <CODE>-gnaty</CODE>,
then the keyword <CODE>then</CODE> must appear either on the same
line as corresponding <CODE>if</CODE>, or on a line on its own, lined
up under the <CODE>if</CODE> with at least one non-blank line in between
containing all or part of the condition to be tested.

<DT><CODE>k (check keyword casing)</CODE>
<DD>
If the letter k appears in the string after <CODE>-gnaty</CODE> then
all keywords must be in lower case (with the exception of keywords
such as <CODE>digits</CODE> used as attribute names to which this check
does not apply).

<DT><CODE>l (check layout)</CODE>
<DD>
If the letter l appears in the string after <CODE>-gnaty</CODE> then
layout of statement and declaration constructs must follow the
recommendations in the Ada Reference Manual, as indicated by the
form of the syntax rules. For example an <CODE>else</CODE> keyword must
be lined up with the corresponding <CODE>if</CODE> keyword.

There are two respects in which the style rule enforced by this check
option are more liberal than those in the Ada Reference Manual. First
in the case of record declarations, it is permissible to put the
<CODE>record</CODE> keyword on the same line as the <CODE>type</CODE> keyword, and
then the <CODE>end</CODE> in <CODE>end record</CODE> must line up under <CODE>type</CODE>.
For example, either of the following two layouts is acceptable:


<PRE>
   <B>type</B> q <B>is record</B>
      a : integer;
      b : integer;
   <B>end record</B>;

   <B>type</B> q <B>is</B>
      <B>record</B>
         a : integer;
         b : integer;
      <B>end record</B>;
</PRE>

Second, in the case of a block statement, a permitted alternative
is to put the block label on the same line as the <CODE>declare</CODE> or
<CODE>begin</CODE> keyword, and then line the <CODE>end</CODE> keyword up under
the block label. For example both the following are permitted:


<PRE>
   Block : <B>declare</B>
      A : Integer := 3;
   <B>begin</B>
      Proc (A, A);
   <B>end</B> Block;

   Block :
      <B>declare</B>
         A : Integer := 3;
      <B>begin</B>
         Proc (A, A);
      <B>end</B> Block;
</PRE>

The same alternative format is allowed for loops. For example, both of
the following are permitted:


<PRE>
   Clear : <B>while</B> J &#60; 10 <B>loop</B>
      A (J) := 0;
   <B>end loop</B> Clear;

   Clear :
      <B>while</B> J &#60; 10 <B>loop</B>
         A (J) := 0;
      <B>end loop</B> Clear;
</PRE>

<DT><CODE>m (check maximum line length)</CODE>
<DD>
If the letter m appears in the string after <CODE>-gnaty</CODE>
then the length of source lines must not exceed 79 characters, including
any trailing blanks. The value of 79 allows convenient display on an
80 character wide device or window, allowing for possible special
treatment of 80 character lines.

<DT><CODE>Mnnn (set maximum line length)</CODE>
<DD>
If the sequence Mnnn, where nnn is a decimal number, appears in
the string after <CODE>-gnaty</CODE> then the length of lines must not exceed the
given value.

<DT><CODE>p (check pragma casing)</CODE>
<DD>
If the letter p appears in the string after <CODE>-gnaty</CODE> then
pragma names must be written in mixed case, that is, the
initial letter and any letter following an underscore must be uppercase.
All other letters must be lowercase.

<DT><CODE>r (check references)</CODE>
<DD>
If the letter r appears in the string after <CODE>-gnaty</CODE>
then all identifier references must be cased in the same way as the
corresponding declaration. No specific casing style is imposed on
identifiers. The only requirement is for consistency of references
with declarations.

<DT><CODE>s (check separate specs)</CODE>
<DD>
If the letter s appears in the string after <CODE>-gnaty</CODE> then
separate declarations ("specs") are required for subprograms (a
body is not allowed to serve as its own declaration). The only
exception is that parameterless library level procedures are
not required to have a separate declaration. This exception covers
the most frequent form of main program procedures.

<DT><CODE>t (check token spacing)</CODE>
<DD>
If the letter t appears in the string after <CODE>-gnaty</CODE> then
the following token spacing rules are enforced:


<UL>

<LI>

The keywords <CODE>abs</CODE> and <CODE>not</CODE> must be followed by a space.

<LI>

The token <CODE>=&#62;</CODE> must be surrounded by spaces.

<LI>

The token <CODE>&#60;&#62;</CODE> must be preceded by a space or a left parenthesis.

<LI>

Binary operators other than <CODE>**</CODE> must be surrounded by spaces.
There is no restriction on the layout of the <CODE>**</CODE> binary operator.

<LI>

Colon must be surrounded by spaces.

<LI>

Colon-equal (assignment) must be surrounded by spaces.

<LI>

Comma must be the first non-blank character on the line, or be
immediately preceded by a non-blank character, and must be followed
by a space.

<LI>

Left parenthesis must be preceded by a space, and must not be followed
by a space (it can be at the end of a line).

<LI>

A right parenthesis must either be the first non-blank character on
a line, or it must be preceded by a non-blank character.

<LI>

A semicolon must not be preceded by a space, and must not be followed by
a non-blank character.

<LI>

A unary plus or minus may not be followed by a space.

<LI>

A vertical bar must be surrounded by spaces.
</UL>

In the above rules, appearing in column one is always permitted, that is,
counts as meeting either a requirement for a required preceding space,
or as meeting a requirement for no preceding space.

Appearing at the end of a line is also always permitted, that is, counts
as meeting either a requirement for a following space, or as meeting
a requirement for no following space.

</DL>

<P>
The switch
<CODE>-gnaty</CODE> on its own (that is not followed by any letters or digits),
is equivalent to <CODE>gnaty3abcefhiklmprst</CODE>, that is all checking
options are enabled, with an indentation level of 3. This is the standard
checking option that is used for the GNAT sources.

</P>


<H3><A NAME="SEC39" HREF="gnat_ug_toc.html#TOC39">Run-time Checks</A></H3>
<P>
<A NAME="IDX116"></A>
<A NAME="IDX117"></A>
<A NAME="IDX118"></A>
<A NAME="IDX119"></A>

</P>
<P>
If you compile with the default options, GNAT will insert many run-time
checks into the compiled code, including code that performs range
checking against constraints, but not arithmetic overflow checking for
integer operations (including division by zero) or checks for access
before elaboration on subprogram calls.  All other run-time checks, as
required by the Ada 95 Reference Manual, are generated by default.
The following <CODE>gcc</CODE> switches refine this default behavior:

</P>
<DL COMPACT>

<DT><CODE>-gnatp</CODE>
<DD>
<A NAME="IDX120"></A>
<A NAME="IDX121"></A>
<A NAME="IDX122"></A>
<A NAME="IDX123"></A>
Suppress all run-time checks as though <CODE>pragma Suppress (all_checks</CODE>)
had been present in the source. Use this switch to improve the performance
of the code at the expense of safety in the presence of invalid data or
program bugs.

<DT><CODE>-gnato</CODE>
<DD>
<A NAME="IDX124"></A>
<A NAME="IDX125"></A>
<A NAME="IDX126"></A>
Enables overflow checking for integer operations.
This causes GNAT to generate slower and larger executable
programs by adding code to check for both overflow and division by zero
(resulting in raising <CODE>Constraint_Error</CODE> as required by Ada
semantics).
<A NAME="IDX127"></A>
Note that the <CODE>-gnato</CODE> switch does not affect the code generated
for any floating-point operations; it applies only to integer
operations. For floating-point, GNAT has the <CODE>Machine_Overflows</CODE>
attribute set to <CODE>False</CODE> and the normal mode of operation is to
generate IEEE NaN and infinite values on overflow or invalid operations
(such as dividing 0.0 by 0.0).

<DT><CODE>-gnatE</CODE>
<DD>
<A NAME="IDX128"></A>
<A NAME="IDX129"></A>
<A NAME="IDX130"></A>
Enables dynamic checks for access-before-elaboration
on subprogram calls and generic instantiations.
For full details of the effect and use of this switch,
See section <A HREF="gnat_ug.html#SEC33">Compiling Using <CODE>gcc</CODE></A>.
</DL>

<P>
<A NAME="IDX131"></A>
The setting of these switches only controls the default setting of the
checks.  You may modify them using either <CODE>Suppress</CODE> (to remove
checks) or <CODE>Unsuppress</CODE> (to add back suppressed checks) pragmas in
the program source.

</P>


<H3><A NAME="SEC40" HREF="gnat_ug_toc.html#TOC40">Using <CODE>gcc</CODE> for Syntax Checking</A></H3>
<DL COMPACT>

<DT><CODE>-gnats</CODE>
<DD>
<A NAME="IDX132"></A>

The <CODE>s</CODE> stands for syntax.

Run GNAT in syntax checking only mode. For
example, the command


<PRE>
   $ gcc -c -gnats x.adb
</PRE>

compiles file <TT>`x.adb'</TT> in syntax-check-only mode. You can check a
series of files in a single command
, and can use wild cards to specify such a group of files.
Note that you must specify the <CODE>-c</CODE> (compile
only) flag in addition to the <CODE>-gnats</CODE> flag.
.

You may use other switches in conjunction with <CODE>-gnats</CODE>. In
particular, <CODE>-gnatl</CODE> and <CODE>-gnatv</CODE> are useful to control the
format of any generated error messages.

The output is simply the error messages, if any. No object file or ALI
file is generated by a syntax-only compilation. Also, no units other
than the one specified are accessed. For example, if a unit <CODE>X</CODE>
<CODE>with</CODE>'s a unit <CODE>Y</CODE>, compiling unit <CODE>X</CODE> in syntax
check only mode does not access the source file containing unit
<CODE>Y</CODE>.

<A NAME="IDX133"></A>
Normally, GNAT allows only a single unit in a source file. However, this
restriction does not apply in syntax-check-only mode, and it is possible
to check a file containing multiple compilation units concatenated
together. This is primarily used by the <CODE>gnatchop</CODE> utility
(see section <A HREF="gnat_ug.html#SEC75">Renaming Files Using <CODE>gnatchop</CODE></A>).
</DL>



<H3><A NAME="SEC41" HREF="gnat_ug_toc.html#TOC41">Using <CODE>gcc</CODE> for Semantic Checking</A></H3>
<DL COMPACT>

<DT><CODE>-gnatc</CODE>
<DD>
<A NAME="IDX134"></A>

The <CODE>c</CODE> stands for check.
Causes the compiler to operate in semantic check mode,
with full checking for all illegalities specified in the
Ada 95 Reference Manual, but without generation of any source code (no object
or ALI file generated).

Because dependent files must be accessed, you must follow the GNAT
semantic restrictions on file structuring to operate in this mode:


<UL>
<LI>

The needed source files must be accessible (see section <A HREF="gnat_ug.html#SEC49">Search Paths and the Run-Time Library (RTL)</A>).

<LI>

Each file must contain only one compilation unit.

<LI>

The file name and unit name must match (see section <A HREF="gnat_ug.html#SEC17">File Naming Rules</A>).
</UL>

The output consists of error messages as appropriate. No object file or
ALI file is generated. The checking corresponds exactly to the notion of
legality in the Ada 95 Reference Manual.

Any unit can be compiled in semantics-checking-only mode, including
units that would not normally be compiled (subunits,
and specifications where a separate body is present).
</DL>



<H3><A NAME="SEC42" HREF="gnat_ug_toc.html#TOC42">Compiling Ada 83 Programs</A></H3>
<DL COMPACT>

<DT><CODE>-gnat83</CODE>
<DD>
<A NAME="IDX135"></A>
 
<A NAME="IDX136"></A>
<A NAME="IDX137"></A>

Although GNAT is primarily an Ada 95 compiler, it accepts this switch to
specify that an Ada 83 program is to be compiled in Ada83 mode. If you specify
this switch, GNAT rejects most Ada 95 extensions and applies Ada 83 semantics
where this can be done easily.
It is not possible to guarantee this switch does a perfect
job; for example, some subtle tests, such as are
found in earlier ACVC tests (that have been removed from the ACVC suite for Ada
95), may not compile correctly. However, for most purposes, using
this switch should help to ensure that programs that compile correctly
under the <CODE>-gnat83</CODE> switch can be ported easily to an Ada 83
compiler. This is the main use of the switch.

With few exceptions (most notably the need to use <CODE>&#60;&#62;</CODE> on
<A NAME="IDX138"></A>
unconstrained generic formal parameters, the use of the new Ada 95
keywords, and the use of packages
with optional bodies), it is not necessary to use the
<CODE>-gnat83</CODE> switch when compiling Ada 83 programs, because, with rare
exceptions, Ada 95 is upwardly compatible with Ada 83. This
means that a correct Ada 83 program is usually also a correct Ada 95
program.

<DT><CODE>-gnat95</CODE>
<DD>
<A NAME="IDX139"></A>
This switch specifies normal Ada 95 mode, and cancels the effect of
any previously given -gnat83 switch.

</DL>


<H3><A NAME="SEC43" HREF="gnat_ug_toc.html#TOC43">Reference Manual Style Checking</A></H3>
<DL COMPACT>

<DT><CODE>-gnatr</CODE>
<DD>
<A NAME="IDX140"></A>

Normally, GNAT permits any source layout consistent with the Ada 95
reference manual requirements. This switch
(<SAMP>`r'</SAMP> is for "reference manual")
enforces the layout conventions suggested by the examples and syntax
rules of the Ada 95 Language Reference Manual. For example, an <CODE>else</CODE>
must line up with an <CODE>if</CODE> and code in the <CODE>then</CODE> and
<CODE>else</CODE> parts must be indented. The compiler treats violations of
the layout rules as syntax errors if you specify this switch.

<DT><CODE>-gnatg</CODE>
<DD>
<A NAME="IDX141"></A>
Enforces a set of style conventions that correspond to the style used in
the GNAT source code.  All compiler units are always compiled with the
<CODE>-gnatg</CODE> switch specified.

<A NAME="IDX142"></A>
You can find the full documentation for the style conventions imposed by
<CODE>-gnatg</CODE> in the body of the package <CODE>Style</CODE> in the
compiler sources (in the file <TT>`style.adb'</TT>).

<A NAME="IDX143"></A>
You should not normally use the <CODE>-gnatg</CODE> switch. However, you
<EM>must</EM> use <CODE>-gnatg</CODE> for compiling any language-defined unit,
or for adding children to any language-defined unit other than
<CODE>Standard</CODE>.
</DL>


<H3><A NAME="SEC44" HREF="gnat_ug_toc.html#TOC44">Character Set Control</A></H3>
<DL COMPACT>

<DT><CODE>-gnati<VAR>c</VAR></CODE>
<DD>
<A NAME="IDX144"></A>

Normally GNAT recognizes the Latin-1 character set in source program
identifiers, as described in the Ada 95 Reference Manual.
This switch causes
GNAT to recognize alternate character sets in identifiers.  <VAR>c</VAR> is a
single character  indicating the character set, as follows:

<DL COMPACT>

<DT><CODE>1</CODE>
<DD>
Latin-1 identifiers

<DT><CODE>2</CODE>
<DD>
Latin-2 letters allowed in identifiers

<DT><CODE>3</CODE>
<DD>
Latin-3 letters allowed in identifiers

<DT><CODE>4</CODE>
<DD>
Latin-4 letters allowed in identifiers

<DT><CODE>p</CODE>
<DD>
IBM PC letters (code page 437) allowed in identifiers

<DT><CODE>8</CODE>
<DD>
IBM PC letters (code page 850) allowed in identifiers

<DT><CODE>f</CODE>
<DD>
Full upper-half codes allowed in identifiers

<DT><CODE>n</CODE>
<DD>
No upper-half codes allowed in identifiers

<DT><CODE>w</CODE>
<DD>
Wide-character codes allowed in identifiers
</DL>

See section <A HREF="gnat_ug.html#SEC13">Foreign Language Representation</A>, for full details on the
implementation of these character sets.

<DT><CODE>-gnatW<VAR>e</VAR></CODE>
<DD>
<A NAME="IDX145"></A>
Specify the method of encoding for wide characters.
<VAR>e</VAR> is one of the following:

<DL COMPACT>

<DT><CODE>h</CODE>
<DD>
Hex encoding (brackets coding also recognized)

<DT><CODE>u</CODE>
<DD>
Upper half encoding (brackets encoding also recognized)

<DT><CODE>s</CODE>
<DD>
Shift/JIS encoding (brackets encoding also recognized)

<DT><CODE>e</CODE>
<DD>
EUC encoding (brackets encoding also recognized)

<DT><CODE>8</CODE>
<DD>
UTF-8 encoding (brackets encoding also recognized)

<DT><CODE>b</CODE>
<DD>
Brackets encoding only (default value)
</DL>
For full details on the these encoding
methods see See section <A HREF="gnat_ug.html#SEC16">Wide Character Encodings</A>.
Note that brackets coding is always accepted, even if one of the other
options is specified, so for example <CODE>-gnatW8</CODE> specifies that both
brackets and <CODE>UTF-8</CODE> encodings will be recognized. The units that are
with'ed directly or indirectly will be scanned using the specified
representation scheme, and so if one of the non-brackets scheme is
used, it must be used consistently throughout the program. However,
since brackets encoding is always recognized, it may be conveniently
used in standard libraries, allowing these libraries to be used with
any of the available coding schemes.
scheme. If no <CODE>-gnatW?</CODE> parameter is present, then the default
representation is Brackets encoding only.

Note that the wide character representation that is specified (explicitly
or by default) for the main program also acts as the default encoding used
for Wide_Text_IO files if not specifically overridden by a WCEM form
parameter.

</DL>


<H3><A NAME="SEC45" HREF="gnat_ug_toc.html#TOC45">File Naming Control</A></H3>

<DL COMPACT>

<DT><CODE>-gnatk<VAR>n</VAR></CODE>
<DD>
<A NAME="IDX146"></A>
Activates file name "krunching". <VAR>n</VAR>, a decimal integer in the range
1-999, indicates the maximum allowable length of a file name (not
including the <TT>`.ads'</TT> or <TT>`.adb'</TT> extension). The default is not
to enable file name krunching.

For the source file naming rules, See section <A HREF="gnat_ug.html#SEC17">File Naming Rules</A>.
</DL>



<H3><A NAME="SEC46" HREF="gnat_ug_toc.html#TOC46">Subprogram Inlining Control</A></H3>

<DL COMPACT>

<DT><CODE>-gnatn</CODE>
<DD>
<A NAME="IDX147"></A>
The <CODE>n</CODE> here is intended to suggest the first syllable of the
word "inline".
GNAT recognizes and processes <CODE>Inline</CODE> pragmas. However, for the
inlining to actually occur, optimization must be enabled.  To enable
inlining across unit boundaries, this is, inlining a call in one unit of
a subprogram declared in a <CODE>with</CODE>'ed unit, you must also specify
this switch.
In the absence of this switch, GNAT does not attempt
inlining across units and does not need to access the bodies of
subprograms for which <CODE>pragma Inline</CODE> is specified if they are not
in the current unit.

If you specify this switch the compiler will access these bodies,
creating an extra source dependency for the resulting object file, and
where possible, the call will be inlined. For further details on when inlining is possible
see See section <A HREF="gnat_ug.html#SEC163">Inlining of Subprograms</A>.

<DT><CODE>-gnatN</CODE>
<DD>
This switch enforces a more extreme form of inlining across unit
boundaries. It causes the compiler to proceed as though the normal
(pragma) inlining switch was set, and to assume that there is a
pragma <CODE>Inline</CODE> for every subprogram referenced by the compiled
unit.

</DL>



<H3><A NAME="SEC47" HREF="gnat_ug_toc.html#TOC47">Auxiliary Output Control</A></H3>

<DL COMPACT>

<DT><CODE>-gnatt</CODE>
<DD>
<A NAME="IDX148"></A>
<A NAME="IDX149"></A>
<A NAME="IDX150"></A>
Cause GNAT to write the internal tree for a unit to a file (with the
extension <TT>`.atb'</TT> for a body or <TT>`.ats'</TT> for a spec).  This is
not normally required, but is used by separate analysis tools. Typically
these tools do the necessary compilations automatically, so you should
never have to specify this switch in normal operation.

<DT><CODE>-gnatu</CODE>
<DD>
<A NAME="IDX151"></A>
Print a list of units required by this compilation on <CODE>stdout</CODE>.
The listing includes all units on which the unit being compiled depends
either directly or indirectly.
</DL>



<H3><A NAME="SEC48" HREF="gnat_ug_toc.html#TOC48">Debugging Control</A></H3>

<DL COMPACT>

<DT><CODE>-gnatd<VAR>x</VAR></CODE>
<DD>
<A NAME="IDX152"></A>
 
Activate internal debugging switches.  <VAR>x</VAR> is a letter or digit, or
string of letters or digits, which specifies the type of debugging
outputs desired.  Normally these are used only for internal development
or system debugging purposes. You can find full documentation for these
switches in the body of the <CODE>Debug</CODE> unit in the compiler source
file <TT>`debug.adb'</TT>.

<DT><CODE>-gnatG</CODE>
<DD>
<A NAME="IDX153"></A>
This switch causes the compiler to generate auxiliary output containing
a pseudo-source listing of the generated expanded code. Like most Ada
compilers, GNAT works by first transforming the high level Ada code into
lower level constructs. For example, tasking operations are transformed
into calls to the tasking run-time routines. A unique capability of GNAT
is to list this expanded code in a form very close to normal Ada source.
This is very useful in understanding the implications of various Ada
usage on the efficiency of the generated code. There are many cases in
Ada (e.g. the use of controlled types), where simple Ada statements can
generate a lot of run-time code. By using <CODE>-gnatG</CODE> you can identify
these cases, and consider whether it may be desirable to modify the coding
approach to improve efficiency.

The format of the output is very similar to standard Ada source, and is
easily understood by an Ada programmer. The following special syntactic
additions correspond to low level features used in the generated code that
do not have any exact analogies in pure Ada source form:

<DT><CODE>-gnatD</CODE>
<DD>
<A NAME="IDX154"></A>
This switch is used in conjunction with <CODE>-gnatG</CODE> to cause the expanded
source, as described above to be written to files with names
<TT>`xxx.dg'</TT>, where <TT>`xxx'</TT> is the normal file name,
for example, if the source file name is <TT>`hello.adb'</TT>,
then a file <TT>`hello.adb.dg'</TT> will be written.
The debugging information generated
by the <CODE>gcc</CODE> <CODE>-g</CODE> switch will refer to the generated
<TT>`xxx.dg'</TT> file. This allows you to do source level debugging using
the generated code which is sometimes useful for complex code, for example
to find out exactly which part of a complex construction raised an
exception.

</DL>

<DL COMPACT>

<DT><CODE>new <VAR>xxx</VAR> [storage_pool = <VAR>yyy</VAR>]</CODE>
<DD>
Shows the storage pool being used for an allocator.

<DT><CODE>at end <VAR>procedure-name</VAR>;</CODE>
<DD>
Shows the finalization (cleanup) procedure for a scope.

<DT><CODE>(if <VAR>expr</VAR> then <VAR>expr</VAR> else <VAR>expr</VAR>)</CODE>
<DD>
Conditional expression equivalent to the <CODE>x?y:z</CODE> construction in C.

<DT><CODE><VAR>target</VAR>^(<VAR>source</VAR>)</CODE>
<DD>
A conversion with floating-point truncation instead of rounding.

<DT><CODE><VAR>target</VAR>?(<VAR>source</VAR>)</CODE>
<DD>
A conversion that bypasses normal Ada semantic checking. In particular
enumeration types and fixed-point types are treated simply as integers.

<DT><CODE><VAR>target</VAR>?^(<VAR>source</VAR>)</CODE>
<DD>
Combines the above two cases.

<DT><CODE><VAR>x</VAR> #/ <VAR>y</VAR></CODE>
<DD>
<DT><CODE><VAR>x</VAR> #mod <VAR>y</VAR></CODE>
<DD>
<DT><CODE><VAR>x</VAR> #* <VAR>y</VAR></CODE>
<DD>
<DT><CODE><VAR>x</VAR> #rem <VAR>y</VAR></CODE>
<DD>
A division or multiplication of fixed-point values which are treated as
integers without any kind of scaling.

<DT><CODE>free <VAR>expr</VAR> [storage_pool = <VAR>xxx</VAR>]</CODE>
<DD>
Shows the storage pool associated with a <CODE>free</CODE> statement.

<DT><CODE>freeze <VAR>typename</VAR> [<VAR>actions</VAR>]</CODE>
<DD>
Shows the point at which <VAR>typename</VAR> is frozen, with possible
associated actions to be performed at the freeze point.

<DT><CODE>reference <VAR>itype</VAR></CODE>
<DD>
Reference (and hence definition) to internal type <VAR>itype</VAR>.

<DT><CODE><VAR>function-name</VAR>! (<VAR>arg</VAR>, <VAR>arg</VAR>, <VAR>arg</VAR>)</CODE>
<DD>
Intrinsic function call.

<DT><CODE><VAR>labelname</VAR> : label</CODE>
<DD>
Declaration of label <VAR>labelname</VAR>.

<DT><CODE><VAR>expr</VAR> &#38;&#38; <VAR>expr</VAR> &#38;&#38; <VAR>expr</VAR> ... &#38;&#38; <VAR>expr</VAR></CODE>
<DD>
A multiple concatenation (same effect as <VAR>expr</VAR> &#38; <VAR>expr</VAR> &#38;
<VAR>expr</VAR>, but handled more efficiently).

<DT><CODE>[constraint_error]</CODE>
<DD>
Raise the <CODE>Constraint_Error</CODE> exception.

<DT><CODE><VAR>expression</VAR>'reference</CODE>
<DD>
A pointer to the result of evaluating <VAR>expression</VAR>.

<DT><CODE><VAR>target-type</VAR>!(<VAR>source-expression</VAR>)</CODE>
<DD>
An unchecked conversion of <VAR>source-expression</VAR> to <VAR>target-type</VAR>.

<DT><CODE>[<VAR>numerator</VAR>/<VAR>denominator</VAR>]</CODE>
<DD>
Used to represent internal real literals (that) have no exact
representation in base 2-16 (for example, the result of compile time
evaluation of the expression 1.0/27.0).

</DL>


<H2><A NAME="SEC49" HREF="gnat_ug_toc.html#TOC49">Search Paths and the Run-Time Library (RTL)</A></H2>

<P>
With the GNAT source-based library system, the compiler must be able to
find source files for units that are needed by the unit being compiled.
Search paths are used to guide this process.

</P>
<P>
The compiler compiles one source file whose name must be given
explicitly on the command line.  In other words, no searching is done
for this file. To find all other source files that are needed (the most
common being the specs of units), the compiler examines the following
directories, in the following order:

</P>

<OL>
<LI>

The directory containing the source file of the main unit being compiled
(the file name on the command line).

<LI>

Each directory named by an <CODE>-I</CODE> switch given on the <CODE>gcc</CODE>
command line, in the order given.

<LI>

<A NAME="IDX155"></A>
Each of the directories listed in the value of the
<CODE>ADA_INCLUDE_PATH</CODE> environment variable.
Construct this value
exactly as the <CODE>PATH</CODE> environment variable: a list of directory
names separated by colons.

<LI>

The default location for the GNAT Run Time Library (RTL) source files.
This is determined at the time GNAT is built and installed on your
system.
</OL>

<P>
Specifying the switch <CODE>-I-</CODE>
inhibits the use of the directory
containing the source file named in the command line.  You can still
have this directory on your search path, but in this case it must be
explicitly requested with a <CODE>-I</CODE> switch.

</P>
<P>
Specifying the switch <CODE>-nostdinc</CODE>
inhibits the search of the default location for the GNAT Run Time
Library (RTL) source files.

</P>
<P>
The compiler outputs its object files and ALI files in the current
working directory.
Caution: The object file can be redirected with the <CODE>-o</CODE> switch;
however, <CODE>gcc</CODE> and <CODE>gnat1</CODE> have not been coordinated on this
so the ALI file will not go to the right place.  Therefore, you should
avoid using the <CODE>-o</CODE> switch.

</P>
<P>
<A NAME="IDX156"></A>
The packages <CODE>Ada</CODE>, <CODE>System</CODE>, and <CODE>Interfaces</CODE> and their
children make up the GNAT RTL, together with the simple <CODE>System.IO</CODE>
package used in the "Hello World" example. The sources for these units
are needed by the compiler and are kept together in one directory. Not
all of the bodies are needed, but all of the sources are kept together
anyway.  In a normal installation, you need not specify these directory
names when compiling or binding.  Either the environment variables or
the built-in defaults cause these files to be found.

</P>
<P>
In addition to the language-defined hierarchies (System, Ada and
Interfaces), the GNAT distribution provides a fourth hierarchy,
consisting of child units of GNAT. This is a collection of generally
useful routines. See the GNAT Reference Manual for further details.

</P>
<P>
Besides simplifying access to the RTL, a major use of search paths is
in compiling sources from multiple directories. This can make
development environments much more flexible.

</P>


<H2><A NAME="SEC50" HREF="gnat_ug_toc.html#TOC50">Order of Compilation Issues</A></H2>

<P>
If, in our earlier example, there was a spec for the <CODE>hello</CODE>
procedure, it would be contained in the file <TT>`hello.ads'</TT>; yet this
file would not have to be explicitly compiled. This is the result of the
model we chose to implement library management. Some of the consequences
of this model are as follows:

</P>

<UL>
<LI>

There is no point in compiling specs (except for package
specs with no bodies) because these are compiled as needed by clients. If
you attempt a useless compilation, you will receive an error message.
It is also useless to compile subunits because they are compiled as needed
by the parent.

<LI>

There are no order of compilation requirements: performing a
compilation never obsoletes anything. The only way you can obsolete
something and require recompilations is to modify one of the
source files on which it depends.

<LI>

There is no library as such, apart from the ALI files (see section <A HREF="gnat_ug.html#SEC21">The Ada Library Information Files</A>, for information on the format of these
files). For now we find it convenient to create separate ALI files, but
eventually the information therein may be incorporated into the object
file directly.

<LI>

When you compile a unit, the source files for the specs of all units
that it <CODE>with</CODE>'s, all its subunits, and the bodies of any generics it
instantiates must be available (reachable by the search-paths mechanism
described above), or you will receive a fatal error message.
</UL>



<H2><A NAME="SEC51" HREF="gnat_ug_toc.html#TOC51">Examples</A></H2>

<P>
The following are some typical Ada compilation command line examples:

</P>
<DL COMPACT>

<DT><CODE>$ gcc -c xyz.adb</CODE>
<DD>
Compile body in file <TT>`xyz.adb'</TT> with all default options.

<DT><CODE>$ gcc -c -O2 -gnata xyz-def.adb</CODE>
<DD>
Compile the child unit package in file <TT>`xyz-def.adb'</TT> with extensive
optimizations, and pragma <CODE>Assert</CODE>/<CODE>Debug</CODE> statements
enabled.

<DT><CODE>$ gcc -c -gnatc abc-def.adb</CODE>
<DD>
Compile the subunit in file <TT>`abc-def.adb'</TT> in semantic-checking-only
mode.
</DL>



<H1><A NAME="SEC52" HREF="gnat_ug_toc.html#TOC52">Binding Using <CODE>gnatbind</CODE></A></H1>
<P>
<A NAME="IDX157"></A>

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC53">Running gnatbind</A>
<LI><A HREF="gnat_ug.html#SEC54">Consistency-Checking Modes</A>
<LI><A HREF="gnat_ug.html#SEC55">Binder Error Message Control</A>
<LI><A HREF="gnat_ug.html#SEC56">Elaboration Control</A>
<LI><A HREF="gnat_ug.html#SEC57">Output Control</A>
<LI><A HREF="gnat_ug.html#SEC58">Binding with Non-Ada Main Programs</A>
<LI><A HREF="gnat_ug.html#SEC59">Binding Programs with no Main Subprogram</A>
<LI><A HREF="gnat_ug.html#SEC60">Summary of Binder Switches</A>
<LI><A HREF="gnat_ug.html#SEC61">Command-Line Access</A>
<LI><A HREF="gnat_ug.html#SEC62">Search Paths for gnatbind</A>
<LI><A HREF="gnat_ug.html#SEC63">Examples of gnatbind Usage</A>
</UL>

<P>
This chapter describes the GNAT binder, <CODE>gnatbind</CODE>, which is used
to bind compiled GNAT objects.  The <CODE>gnatbind</CODE> program performs
four separate functions:

</P>

<OL>
<LI>

Checks that a program is consistent, in accordance with the rules in
Chapter 10 of the Ada 95 Reference Manual. In particular, error
messages are generated if a program uses inconsistent versions of a
given unit.

<LI>

Checks that an acceptable order of elaboration exists for the program
and issues an error message if it cannot find an order of elaboration
that satisfies the rules in Chapter 10 of the Ada 95 Language Manual.

<LI>

Generates a main program incorporating the given elaboration order.
This program is a small C source file that must be subsequently compiled
using the C compiler. The two most important functions of this program
are to call the elaboration routines of units in an appropriate order
and to call the main program.

<LI>

Determines the set of object files required by the given main program.
This information is output in the forms of comments in the generated C program,
to be read by the <CODE>gnatlink</CODE> utility used to link the Ada application.
</OL>



<H2><A NAME="SEC53" HREF="gnat_ug_toc.html#TOC53">Running <CODE>gnatbind</CODE></A></H2>

<P>
The form of the <CODE>gnatbind</CODE> command is

</P>

<PRE>
   $ gnatbind [<VAR>switches</VAR>] <VAR>mainprog</VAR>[.ali] [<VAR>switches</VAR>]
</PRE>

<P>
where <VAR>mainprog</VAR>.adb is the Ada file containing the main program
unit body. If no switches are specified, <CODE>gnatbind</CODE> constructs an Ada
package in two files whose names are
<TT>`b~<VAR>ada_main</VAR>.ads'</TT>, and
<TT>`b~<VAR>ada_main</VAR>.adb'</TT>.
For example, if given the
parameter <SAMP>`hello.ali'</SAMP>, for a main program contained in file
<TT>`hello.adb'</TT>, the binder output files would be <TT>`b~hello.ads'</TT>
and <TT>`b~hello.adb'</TT>.

</P>
<P>
When doing consistency checking, the binder takes any source files it
can locate into consideration. For example, if the binder determines
that the given main program requires the package <CODE>Pack</CODE>, whose ALI
file is <TT>`pack.ali'</TT> and whose corresponding source spec file is
<TT>`pack.ads'</TT>, it attempts to locate the source file <TT>`pack.ads'</TT>
(using the same search path conventions as previously described for the
<CODE>gcc</CODE> command). If it can locate this source file, it checks that
the time stamps
or source checksums of the source and its references to in <TT>`ali'</TT> files
match. In other words, any <TT>`ali'</TT> files that mentions this spec must have
resulted from compiling this version of the source file (or in the case
where the source checksums match, a version close enough that the
difference does not matter).

</P>
<P>
<A NAME="IDX158"></A>
The effect of this consistency checking, which includes source files, is
that the binder ensures that the program is consistent with the latest
version of the source files that can be located at bind time. Editing a
source file without compiling files that depend on the source file cause
error messages to be generated by the binder.

</P>
<P>
For example, suppose you have a main program <TT>`hello.adb'</TT> and a
package <CODE>P</CODE>, from file <TT>`p.ads'</TT> and you perform the following
steps:

</P>

<OL>
<LI>

Enter <CODE>gcc -c hello.adb</CODE> to compile the main program.

<LI>

Enter <CODE>gcc -c p.ads</CODE> to compile package <CODE>P</CODE>.

<LI>

Edit file <TT>`p.ads'</TT>.

<LI>

Enter <CODE>gnatbind hello</CODE>.
</OL>

<P>
At this point, the file <TT>`p.ali'</TT> contains an out-of-date time stamp
because the file <TT>`p.ads'</TT> has been edited. The attempt at binding
fails, and the binder generates the following error messages:

</P>

<PRE>
   error: "hello.adb" must be recompiled ("p.ads" has been modified)
   error: "p.ads" has been modified and must be recompiled
</PRE>

<P>
Now both files must be recompiled as indicated, and then the bind can
succeed, generating a main program.  You need not normally be concerned
with the contents of this file, but it is similar to the following (when
using -C):

</P>

<PRE>

extern int gnat_argc;
extern char **gnat_argv;
extern char **gnat_envp;
extern int gnat_exit_status;
void adafinal ();
void adainit ()
{
   __gnat_set_globals (
      -1,    /* Main_Priority              */
      -1,    /* Time_Slice_Value           */
      ' ',   /* Locking_Policy             */
      ' ',   /* Queuing_Policy             */
      ' ',   /* Tasking_Dispatching_Policy */
      adafinal);
   system___elabs ();
/* system__standard_library___elabs (); */
/* system__task_specific_data___elabs (); */
/* system__tasking_soft_links___elabs (); */
   system__tasking_soft_links___elabb ();
/* system__task_specific_data___elabb (); */
/* system__standard_library___elabb (); */
/* m___elabb (); */
}
void adafinal () {
}
int main (argc, argv, envp)
    int argc;
    char **argv;
    char **envp;
{
   gnat_argc = argc;
   gnat_argv = argv;
   gnat_envp = envp;

   __gnat_initialize();
   adainit();

   _ada_m ();

   adafinal();
   __gnat_finalize();
   exit (gnat_exit_status);
}
unsigned mB = 0x2B0EB17F;
unsigned system__standard_libraryB = 0x0122ED49;
unsigned system__standard_libraryS = 0x79B018CE;
unsigned systemS = 0x08FBDA7E;
unsigned system__task_specific_dataB = 0x6CC7367B;
unsigned system__task_specific_dataS = 0x47178527;
unsigned system__tasking_soft_linksB = 0x5A75A73C;
unsigned system__tasking_soft_linksS = 0x3012AFCB;
/* BEGIN Object file/option list
./system.o
./s-tasoli.o
./s-taspda.o
./s-stalib.o
./m.o
   END Object file/option list */
</PRE>

<P>
The call to <CODE>__gnat_set_globals</CODE> establishes program parameters,
including the priority of the main task, and parameters for tasking
control. It also passes the address of the finalization routine so
that it can be called at the end of program execution.

</P>
<P>
<A NAME="IDX159"></A>
<A NAME="IDX160"></A>
<A NAME="IDX161"></A>
<A NAME="IDX162"></A>
<A NAME="IDX163"></A>

</P>
<P>
Next there is code to save the <CODE>argc</CODE> and <CODE>argv</CODE> values for
later access by the <CODE>Ada.Command_Line</CODE> package. The variable
<CODE>gnat_exit_status</CODE> saves the exit status set by calls to
<CODE>Ada.Command_Line.Set_Exit_Status</CODE> and is used to return an exit
status to the system.

</P>
<P>
<A NAME="IDX164"></A>
<A NAME="IDX165"></A>
The call to <CODE>__gnat_initialize</CODE> and the corresponding call at the
end of execution to <CODE>__gnat_finalize</CODE> allow any specialized
initialization and finalization code to be hooked in.  The default
versions of these routines do nothing.

</P>
<P>
<A NAME="IDX166"></A>
The calls to <CODE>xxx___elabb</CODE> and
<CODE>xxx___elabs</CODE> perform necessary elaboration of the bodies and
specs respectively of units in the program. These calls are commented
out if the unit in question has no elaboration code.

</P>
<P>
The call to
<CODE>m</CODE>
is the call to the main program.

</P>
<P>
<A NAME="IDX167"></A>
<A NAME="IDX168"></A>
The list of unsigned constants gives the version number information.
Version numbers are computed by combining time stamps of a unit and all
units on which it depends. These values are used for implementation of
the <CODE>Version</CODE> and <CODE>Body_Version</CODE> attributes.

</P>
<P>
Finally, a set of comments gives the full names of all the object files
that must be linked to provide the Ada component of the program. As seen in
the previous example, this list includes the files explicitly supplied
and referenced by the user as well as implicitly referenced run-time unit
files. The latter are omitted if the corresponding units reside in
shared libraries. The directory names for the run-time units depend on
the system configuration. See section <A HREF="gnat_ug.html#SEC57">Output Control</A>.

</P>


<H2><A NAME="SEC54" HREF="gnat_ug_toc.html#TOC54">Consistency-Checking Modes</A></H2>

<P>
As described in the previous section, by default <CODE>gnatbind</CODE> checks
that object files are consistent with one another and are consistent
with any source files it can locate. The following switches control binder
access to sources.

</P>
<DL COMPACT>

<DT><CODE>-s</CODE>
<DD>
<A NAME="IDX169"></A>
Require source files to be present. In this mode, the binder must be
able to locate all source files that are referenced, in order to check
their consistency. In normal mode, if a source file cannot be located it
is simply ignored. If you specify this switch, a missing source
file is an error.

<DT><CODE>-x</CODE>
<DD>
<A NAME="IDX170"></A>
Exclude source files. In this mode, the binder only checks that ALI
files are consistent with one another. Source files are not accessed.
The binder runs faster in this mode, and there is still a guarantee that
the resulting program is self-consistent.
If a source file has been edited since it was last compiled, and you
specify this switch, the binder will not detect that the object
file is out of date with respect to the source file. Note that this is the
mode that is automatically used by <CODE>gnatmake</CODE> because in this
case the checking against sources has already been performed by
<CODE>gnatmake</CODE> in the course of compilation (i.e. before binding).

</DL>



<H2><A NAME="SEC55" HREF="gnat_ug_toc.html#TOC55">Binder Error Message Control</A></H2>

<P>
The following switches provide control over the generation of error
messages from the binder:

</P>
<DL COMPACT>

<DT><CODE>-v</CODE>
<DD>
<A NAME="IDX171"></A>
Verbose mode. In the normal mode, brief error messages are generated to
<CODE>stderr</CODE>. If this switch is present, a header is written
to <CODE>stdout</CODE> and any error messages are directed to <CODE>stdout</CODE>.
All that is written to <CODE>stderr</CODE> is a brief summary message.

<DT><CODE>-b</CODE>
<DD>
<A NAME="IDX172"></A>
Generate brief error messages to <CODE>stderr</CODE> even if verbose mode is
specified. This is relevant only when used with the
<CODE>-v</CODE> switch.

<DT><CODE>-m<VAR>n</VAR></CODE>
<DD>
<A NAME="IDX173"></A>
Limits the number of error messages to <VAR>n</VAR>, a decimal integer in the
range 1-999. The binder terminates immediately if this limit is reached.

<DT><CODE>-M<VAR>xxx</VAR></CODE>
<DD>
<A NAME="IDX174"></A>
Renames the generated main program from <CODE>main</CODE> to <CODE>xxx</CODE>.
This is useful in the case of some cross-building environments, where
the actual main program is separate from the one generated
by <CODE>gnatbind</CODE>.

<DT><CODE>-ws</CODE>
<DD>
<A NAME="IDX175"></A>
<A NAME="IDX176"></A>
Suppress all warning messages.

<DT><CODE>-we</CODE>
<DD>
<A NAME="IDX177"></A>
Treat any warning messages as fatal errors.

<DT><CODE>-t</CODE>
<DD>
<A NAME="IDX178"></A>
<A NAME="IDX179"></A>
Ignore time stamp errors. Any time stamp error messages are treated as
warning messages. This switch essentially disconnects the normal
consistency checking, and the resulting program may have undefined
semantics if inconsistent units are present. <EM>This means that
<CODE>-t</CODE> should be used only in unusual situations,
with extreme care.</EM>
</DL>



<H2><A NAME="SEC56" HREF="gnat_ug_toc.html#TOC56">Elaboration Control</A></H2>

<P>
The following switches provide additional control over the elaboration
order. For full details see See section <A HREF="gnat_ug.html#SEC84">Elaboration Order Handling in GNAT</A>.

</P>
<DL COMPACT>

<DT><CODE>-f</CODE>
<DD>
<A NAME="IDX180"></A>
Instructs the binder to ignore directives from the compiler about
implied <CODE>Elaborate_All</CODE> pragmas, and to use full Ada 95 Reference
Manual semantics in an attempt to find a legal elaboration order,
even if it seems likely that this order will cause an elaboration
exception.

<DT><CODE>-p</CODE>
<DD>
<A NAME="IDX181"></A>
Normally the binder attempts to choose an elaboration order that is
likely to minimize the likelihood of an elaboration order error resulting
in raising a <CODE>Program_Error</CODE> exception. This switch reverses the
action of the binder, and requests that it deliberately choose an order
that is likely to maximize the likelihood of an elaboration error.
This is useful in ensuring portability and avoiding dependence on
accidental fortuitous elaboration ordering.
</DL>



<H2><A NAME="SEC57" HREF="gnat_ug_toc.html#TOC57">Output Control</A></H2>

<P>
The following switches allow additional control over the output
generated by the binder.

</P>
<DL COMPACT>

<DT><CODE>-A</CODE>
<DD>
<A NAME="IDX182"></A>
Generate binder program in Ada (default). The binder program is named
<TT>`b~<VAR>mainprog</VAR>.adb'</TT> by default. This can be changed with
<CODE>-o</CODE> <CODE>gnatbind</CODE> option.

<DT><CODE>-C</CODE>
<DD>
<A NAME="IDX183"></A>
Generate binder program in C. The binder program is named
<TT>`b_<VAR>mainprog</VAR>.c'</TT>. This can be changed with <CODE>-o</CODE> <CODE>gnatbind</CODE>
option.

<DT><CODE>-e</CODE>
<DD>
<A NAME="IDX184"></A>
Output complete list of elaboration-order dependencies, showing the
reason for each dependency. This output can be rather extensive but may
be useful in diagnosing problems with elaboration order. The output is
written to <CODE>stdout</CODE>.

<DT><CODE>-h</CODE>
<DD>
<A NAME="IDX185"></A>
Output usage information. The output is written to <CODE>stdout</CODE>.

<DT><CODE>-l</CODE>
<DD>
<A NAME="IDX186"></A>
Output chosen elaboration order. The output is written to <CODE>stdout</CODE>.

<DT><CODE>-O</CODE>
<DD>
<A NAME="IDX187"></A>
Output full names of all the object files that must be linked to provide
the Ada component of the program. The output is written to <CODE>stdout</CODE>.
This list includes the files explicitly supplied and referenced by the user
as well as implicitly referenced run-time unit files. The latter are
omitted if the corresponding units reside in shared libraries. The
directory names for the run-time units depend on the system configuration.

<DT><CODE>-o <VAR>file</VAR></CODE>
<DD>
<A NAME="IDX188"></A>
Set name of output file to <VAR>file</VAR> instead of the normal
<TT>`b~<VAR>mainprog</VAR>.adb'</TT> default.  Note that <VAR>file</VAR> denote the Ada
binder generated body filename. In C mode you would normally give
<VAR>file</VAR> an extension of <TT>`.c'</TT> because it will be a C source program.
Note that if this option is used, then linking must be done manually.
It is not possible to use gnatlink in this case, since it cannot locate
the binder file.

<DT><CODE>-c</CODE>
<DD>
<A NAME="IDX189"></A>
Check only. Do not generate the binder output file. In this mode the
binder performs all error checks but does not generate an output file.
</DL>



<H2><A NAME="SEC58" HREF="gnat_ug_toc.html#TOC58">Binding with Non-Ada Main Programs</A></H2>

<P>
In our description so far we have assumed that the main
program is in Ada, and that the task of the binder is to generate a
corresponding function <CODE>main</CODE> that invokes this Ada main
program.  GNAT also supports the building of executable programs where
the main program is not in Ada, but some of the called routines are
written in Ada and compiled using GNAT (see section <A HREF="gnat_ug.html#SEC24">Mixed Language Programming</A>).
The following switch is used in this situation:

</P>
<DL COMPACT>

<DT><CODE>-n</CODE>
<DD>
<A NAME="IDX190"></A>
No main program. The main program is not in Ada.
</DL>

<P>
In this case, most of the functions of the binder are still required,
but instead of generating a main program, the binder generates a file
containing the following callable routines:

</P>
<DL COMPACT>

<DT><CODE>adainit</CODE>
<DD>
<A NAME="IDX191"></A>
You must call this routine to initialize the Ada part of the program by
calling the necessary elaboration routines. A call to <CODE>adainit</CODE> is
required before the first call to an Ada subprogram.

<DT><CODE>adafinal</CODE>
<DD>
<A NAME="IDX192"></A>
You must call this routine to perform any library-level finalization
required by the Ada subprograms. A call to <CODE>adafinal</CODE> is required
after the last call to an Ada subprogram, and before the program
terminates.
</DL>

<P>
If the <CODE>-n</CODE> switch
<A NAME="IDX193"></A>
is given, more than one ALI file may appear on
the command line for <CODE>gnatbind</CODE>. The normal <STRONG>closure</STRONG>
calculation is performed for each of the specified units. Calculating
the closure means finding out the set of units involved by tracing
<CODE>with</CODE> references.  The reason it is necessary to be able to
specify more than one ALI file is that a given program may invoke two or
more quite separate groups of Ada units.

</P>
<P>
The binder takes the name of its output file from the last specified ALI
file, unless overridden by the use of the <CODE>\-o
file\/OUTPUT=file\</CODE>. The output is an Ada unit in source form that can
be compiled with GNAT unless the -C switch is used in which case the
output is a C source file, which must be compiled using the C compiler.
This compilation occurs automatically as part of the <CODE>gnatlink</CODE>
processing.

</P>


<H2><A NAME="SEC59" HREF="gnat_ug_toc.html#TOC59">Binding Programs with no Main Subprogram</A></H2>

<P>
It is possible to have an Ada program which does not have a main
subprogram. This program will call the elaboration routines of all the
packages, then the finalization routines.

</P>
<P>
The following switch is used to bind programs organized in this manner:

</P>
<DL COMPACT>

<DT><CODE>-z</CODE>
<DD>
<A NAME="IDX194"></A>
Normally the binder checks that the unit name given on the command line
corresponds to a suitable main subprogram. When this switch is used,
a list of ALI files can be given, and the execution of the program
consists of elaboration of these units in an appropriate order.
</DL>



<H2><A NAME="SEC60" HREF="gnat_ug_toc.html#TOC60">Summary of Binder Switches</A></H2>

<P>
The following are the switches available with <CODE>gnatbind</CODE>:

</P>
<DL COMPACT>

<DT><CODE>-aO</CODE>
<DD>
Specify directory to be searched for ALI files.

<DT><CODE>-aI</CODE>
<DD>
Specify directory to be searched for source file.

<DT><CODE>-A</CODE>
<DD>
Generate binder program in Ada (default)

<DT><CODE>-b</CODE>
<DD>
Generate brief messages to <CODE>stderr</CODE> even if verbose mode set.

<DT><CODE>-c</CODE>
<DD>
Check only, no generation of binder output file.

<DT><CODE>-C</CODE>
<DD>
Generate binder program in C

<DT><CODE>-e</CODE>
<DD>
Output complete list of elaboration-order dependencies.

<DT><CODE>-E</CODE>
<DD>
Store tracebacks in exception occurrences when the target supports it.
This is the default with the zero cost exception mechanism.
This option is currently only supported on Solaris and Linux where you
explicitly need to use the <CODE>gcc</CODE> flag <CODE>-funwind-tables</CODE> when
compiling every file in your application. See also the packages
<CODE>GNAT.Traceback</CODE> and <CODE>GNAT.Traceback.Symbolic</CODE>

<DT><CODE>-f</CODE>
<DD>
Full elaboration semantics. Follow Ada rules. No attempt to be kind

<DT><CODE>-h</CODE>
<DD>
Output usage (help) information

<DT><CODE>-I</CODE>
<DD>
Specify directory to be searched for source and ALI files.

<DT><CODE>-I-</CODE>
<DD>
Do not look for sources in the current directory where <CODE>gnatbind</CODE> was
invoked, and do not look for ALI files in the directory containing the
ALI file named in the <CODE>gnatbind</CODE> command line.

<DT><CODE>-l</CODE>
<DD>
Output chosen elaboration order.

<DT><CODE>-Mxyz</CODE>
<DD>
Rename generated main program from main to xyz

<DT><CODE>-m<VAR>n</VAR></CODE>
<DD>
Limit number of detected errors to <VAR>n</VAR> (1-999).

<DT><CODE>-n</CODE>
<DD>
No main program.

<DT><CODE>-nostdinc</CODE>
<DD>
Do not look for sources in the system default directory.

<DT><CODE>-nostdlib</CODE>
<DD>
Do not look for library files in the system default directory.

<DT><CODE>-o <VAR>file</VAR></CODE>
<DD>
Name the output file <VAR>file</VAR> (default is <TT>`b~<VAR>xxx</VAR>.adb'</TT>).
Note that if this option is used, then linking must be done manually,
gnatlink cannot be used.

<DT><CODE>-O</CODE>
<DD>
Output object list.

<DT><CODE>-p</CODE>
<DD>
Pessimistic (worst-case) elaboration order

<DT><CODE>-s</CODE>
<DD>
Require all source files to be present.

<DT><CODE>-static</CODE>
<DD>
Link against a static GNAT run time.

<DT><CODE>-shared</CODE>
<DD>
Link against a shared GNAT run time when available.

<DT><CODE>-t</CODE>
<DD>
Tolerate time stamp and other consistency errors

<DT><CODE>-T<VAR>n</VAR></CODE>
<DD>
Set the time slice value to n milliseconds. A value of zero means no time
slicing and also indicates to the tasking run time to match as close as
possible to the annex D requirements of the RM.

<DT><CODE>-v</CODE>
<DD>
Verbose mode. Write error messages, header, summary output to
<CODE>stdout</CODE>.

<DT><CODE>-w<VAR>x</VAR></CODE>
<DD>
Warning mode (<VAR>x</VAR>=s/e for suppress/treat as error)

<DT><CODE>-x</CODE>
<DD>
Exclude source files (check object consistency only).

<DT><CODE>-z</CODE>
<DD>
No main subprogram.

</DL>

<P>
You may obtain this listing by running the program <CODE>gnatbind</CODE> with
no arguments.

</P>


<H2><A NAME="SEC61" HREF="gnat_ug_toc.html#TOC61">Command-Line Access</A></H2>

<P>
The package <CODE>Ada.Command_Line</CODE> provides access to the command-line
arguments and program name. In order for this interface to operate
correctly, the two variables

</P>

<PRE>
   int gnat_argc;
   char **gnat_argv;
</PRE>

<P>
<A NAME="IDX195"></A>
<A NAME="IDX196"></A>
are declared in one of the GNAT library routines. These variables must
be set from the actual <CODE>argc</CODE> and <CODE>argv</CODE> values passed to the
main program.  With no <CODE>n</CODE> present, <CODE>gnatbind</CODE>
generates the C main program to automatically set these variables.
If the <CODE>n</CODE> switch is used, there is no automatic way to
set these variables.  If they are not set, the procedures in
<CODE>Ada.Command_Line</CODE> will not be available, and any attempt to use
them will raise <CODE>Constraint_Error</CODE>. If command line access is
required, your main program must set <CODE>gnat_argc</CODE> and
<CODE>gnat_argv</CODE> from the <CODE>argc</CODE> and <CODE>argv</CODE> values passed to
it.

</P>


<H2><A NAME="SEC62" HREF="gnat_ug_toc.html#TOC62">Search Paths for <CODE>gnatbind</CODE></A></H2>

<P>
The binder takes the name of an ALI file as its argument and needs to
locate source files as well as other ALI files to verify object consistency.

</P>
<P>
For source files, it follows exactly the same search rules as <CODE>gcc</CODE>
(see section <A HREF="gnat_ug.html#SEC49">Search Paths and the Run-Time Library (RTL)</A>). For ALI files the
directories searched are:

</P>

<OL>
<LI>

The directory containing the ALI file named in the command line, unless
the switch <CODE>-I-</CODE> is specified.

<LI>

All directories specified by <CODE>-I</CODE>
switches on the <CODE>gnatbind</CODE>
command line, in the order given.

<LI>

<A NAME="IDX197"></A>
Each of the directories listed in the value of the
<CODE>ADA_OBJECTS_PATH</CODE> environment variable.
Construct this value
exactly as the <CODE>PATH</CODE> environment variable: a list of directory
names separated by colons.

<LI>

The default location for the GNAT Run-Time Library (RTL) files,
determined when GNAT was built and installed on your system, unless
the switch <CODE>-nostdlib</CODE> is specified.
</OL>

<P>
In the binder the switch <CODE>-I</CODE>
is used to specify both source and
library file paths. Use <CODE>-aI</CODE>
instead if you want to specify
source paths only, and <CODE>-aO</CODE>
if you want to specify library paths
only. This means that for the binder
<CODE>-I</CODE><VAR>dir</VAR> is equivalent to
<CODE>-aI</CODE><VAR>dir</VAR>
<CODE>-aO</CODE><VAR>dir</VAR>.
The binder generates the bind file (a C language source file) in the
current working directory.

</P>
<P>
<A NAME="IDX198"></A>
<A NAME="IDX199"></A>
<A NAME="IDX200"></A>
<A NAME="IDX201"></A>
The packages <CODE>Ada</CODE>, <CODE>System</CODE>, and <CODE>Interfaces</CODE> and their
children make up the GNAT Run-Time Library, together with the package
GNAT and its children, which contain a set of useful additional
library functions provided by GNAT. The sources for these units are
needed by the compiler and are kept together in one directory. The ALI
files and object files generated by compiling the RTL are needed by the
binder and the linker and are kept together in one directory, typically
different from the directory containing the sources. In a normal
installation, you need not specify these directory names when compiling
or binding.  Either the environment variables or the built-in defaults
cause these files to be found.

</P>
<P>
Besides simplifying access to the RTL, a major use of search paths is
in compiling sources from multiple directories. This can make
development environments much more flexible.

</P>


<H2><A NAME="SEC63" HREF="gnat_ug_toc.html#TOC63">Examples of <CODE>gnatbind</CODE> Usage</A></H2>

<P>
This section contains a number of examples of using the GNAT binding
utility <CODE>gnatbind</CODE>.

</P>
<DL COMPACT>

<DT><CODE>gnatbind hello</CODE>
<DD>
The main program <CODE>Hello</CODE> (source program in <TT>`hello.adb'</TT>) is
bound using the standard switch settings. The generated main program is
<TT>`b~hello.adb'</TT>. This is the normal, default use of the binder.

<DT><CODE>gnatbind hello -o mainprog.adb</CODE>
<DD>
The main program <CODE>Hello</CODE> (source program in <TT>`hello.adb'</TT>) is
bound using the standard switch settings. The generated main program is
<TT>`mainprog.adb'</TT> with the associated spec in
<TT>`mainprog.ads'</TT>. Note that you must specify the body here not the
spec, in the case where the output is in Ada. Note that if this option
is used, then linking must be done manually, since gnatlink will not
be able to find the generated file.

<DT><CODE>gnatbind main -C -o mainprog.c -x</CODE>
<DD>
The main program <CODE>Main</CODE> (source program in
<TT>`main.adb'</TT>) is bound, excluding source files from the
consistency checking, generating
the file <TT>`mainprog.c'</TT>.

<DT><CODE>gnatbind -x main_program -C -o mainprog.c</CODE>
<DD>
This command is exactly the same as the previous example. Switches may
appear anywhere in the command line, and single letter switches may be
combined into a single switch.

<DT><CODE>gnatbind -n math dbase -C -o ada-control.c</CODE>
<DD>
The main program is in a language other than Ada, but calls to
subprograms in packages <CODE>Math</CODE> and <CODE>Dbase</CODE> appear. This call
to <CODE>gnatbind</CODE> generates the file <TT>`ada-control.c'</TT> containing
the <CODE>adainit</CODE> and <CODE>adafinal</CODE> routines to be called before and
after accessing the Ada units.
</DL>



<H1><A NAME="SEC64" HREF="gnat_ug_toc.html#TOC64">Linking Using <CODE>gnatlink</CODE></A></H1>
<P>
<A NAME="IDX202"></A>

</P>
<P>
This chapter discusses <CODE>gnatlink</CODE>, a utility program used to link
Ada programs and build an executable file. This is a simple program
that invokes the UNIX linker (via the <CODE>gcc</CODE>
command) with a correct list of object files and library references.
<CODE>gnatlink</CODE> automatically determines the list of files and
references for the Ada part of a program. It uses the binder file
generated by the binder to determine this list.

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC65">Running gnatlink</A>
<LI><A HREF="gnat_ug.html#SEC66">Switches for gnatlink</A>
</UL>



<H2><A NAME="SEC65" HREF="gnat_ug_toc.html#TOC65">Running <CODE>gnatlink</CODE></A></H2>

<P>
The form of the <CODE>gnatlink</CODE> command is

</P>

<PRE>
   $ gnatlink [<VAR>switches</VAR>] <VAR>mainprog</VAR>[.ali] [<VAR>non-Ada objects</VAR>] [<VAR>linker options</VAR>]
</PRE>

<P>
<TT>`<VAR>mainprog</VAR>.ali'</TT> references the ALI file of the main program.
The <TT>`.ali'</TT> extension of this file can be omitted. From this
reference, <CODE>gnatlink</CODE> locates the corresponding binder file
<TT>`b~<VAR>mainprog</VAR>.adb'</TT> and, using the information in this file along
with the list of non-Ada objects and linker options, constructs a UNIX
linker command file to create the executable.

</P>
<P>
The arguments following <TT>`<VAR>mainprog</VAR>.ali'</TT> are passed to the
linker uninterpreted. They typically include the names of object files
for units written in other languages than Ada and any library references
required to resolve references in any of these foreign language units,
or in <CODE>pragma Import</CODE> statements in any Ada units.  This list may
also include linker switches.

</P>
<P>
<CODE>gnatlink</CODE> determines the list of objects required by the Ada
program and prepends them to the list of objects passed to the linker.
<CODE>gnatlink</CODE> also gathers any arguments set by the use of
<CODE>pragma Linker_Options</CODE> and adds them to the list of arguments
presented to the linker.

</P>



<H2><A NAME="SEC66" HREF="gnat_ug_toc.html#TOC66">Switches for <CODE>gnatlink</CODE></A></H2>

<P>
The following switches are available with the <CODE>gnatlink</CODE> utility:

</P>
<DL COMPACT>

<DT><CODE>-A</CODE>
<DD>
<A NAME="IDX203"></A>
The binder has generated code in Ada. This is the default.

<DT><CODE>-C</CODE>
<DD>
<A NAME="IDX204"></A>
If instead of generating a file in Ada, the binder has generated one in
C, then the linker needs to know about it. Use this switch to signal
to <CODE>gnatlink</CODE> that the binder has generated C code rather than
Ada code.

<DT><CODE>-g</CODE>
<DD>
<A NAME="IDX205"></A>
<A NAME="IDX206"></A>
The option to include debugging information causes the Ada bind file (in
other words, <TT>`b~<VAR>mainprog</VAR>.adb'</TT>) to be compiled with
<CODE>-g</CODE>.
In addition, the binder does not delete the <TT>`b~<VAR>mainprog</VAR>.adb'</TT>,
<TT>`b~<VAR>mainprog</VAR>.o'</TT> and <TT>`b~<VAR>mainprog</VAR>.ali'</TT> files.
Without <CODE>-g</CODE>, the binder removes these files by
default. The same procedure apply if a C bind file was generated using
<CODE>-C</CODE> <CODE>gnatbind</CODE> option, in this case the filenames are
<TT>`b_<VAR>mainprog</VAR>.c'</TT> and <TT>`b_<VAR>mainprog</VAR>.o'</TT>.

<DT><CODE>-n</CODE>
<DD>
<A NAME="IDX207"></A>
Do not compile the file generated by the binder. This may be used when
a link is rerun with different options, but there is no need to recompile
the binder file.

<DT><CODE>-v</CODE>
<DD>
<A NAME="IDX208"></A>
Causes additional information to be output, including a full list of the
included object files. This switch option is most useful when you want
to see what set of object files are being used in the link step.

<DT><CODE>-v -v</CODE>
<DD>
<A NAME="IDX209"></A>
Very verbose mode. Requests that the compiler operate in verbose mode when
it compiles the binder file, and that the system linker run in verbose mode.

<DT><CODE>-o <VAR>exec-name</VAR></CODE>
<DD>
<A NAME="IDX210"></A>
<VAR>exec-name</VAR> specifies an alternate name for the generated
executable program. If this switch is omitted, the executable has the same
name as the main unit. For example, <CODE>gnatlink try.ali</CODE> creates
an executable called <TT>`try'</TT>.

<DT><CODE>-b <VAR>target</VAR></CODE>
<DD>
<A NAME="IDX211"></A>
Compile your program to run on <VAR>target</VAR>, which is the name of a
system configuration.  You must have a GNAT cross-compiler built if
<VAR>target</VAR> is not the same as your host system.

<DT><CODE>-B<VAR>dir</VAR></CODE>
<DD>
<A NAME="IDX212"></A>
Load compiler executables (for example, <CODE>gnat1</CODE>, the Ada compiler)
from <VAR>dir</VAR> instead of the default location. Only use this switch
when multiple versions of the GNAT compiler are available. See the
<CODE>gcc</CODE> manual page for further details.  You would normally use the
<CODE>-b</CODE> or <CODE>-V</CODE> switch instead.

<DT><CODE>--GCC=<VAR>compiler_name</VAR></CODE>
<DD>
<A NAME="IDX213"></A>
Program used for compiling the binder file. The default is
<CODE>gcc</CODE>'. You need to use quotes around <VAR>compiler_name</VAR> if
<CODE>compiler_name</CODE> contains spaces or other separator characters. As
an example <CODE>--GCC="foo -x -y"</CODE> will instruct <CODE>gnatlink</CODE> to use
<CODE>foo -x -y</CODE> as your compiler.  Note that switch <CODE>-c</CODE> is always
inserted after your command name. Thus in the above example the compiler
command that will be used by <CODE>gnatlink</CODE> will be <CODE>foo -c -x -y</CODE>.

<DT><CODE>--LINK=<VAR>name</VAR></CODE>
<DD>
<A NAME="IDX214"></A>
<VAR>name</VAR> is the name of the linker to be invoked. This is especially
useful in mixed language programs since languages such as c++ require
their own linker to be used. When this switch is
omitted, the default name for the linker is (<TT>`gcc'</TT>).

</DL>



<H1><A NAME="SEC67" HREF="gnat_ug_toc.html#TOC67">The GNAT Make Program <CODE>gnatmake</CODE></A></H1>
<P>
<A NAME="IDX215"></A>

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC68">Running gnatmake</A>
<LI><A HREF="gnat_ug.html#SEC69">Switches for gnatmake</A>
<LI><A HREF="gnat_ug.html#SEC70">Mode switches for gnatmake</A>
<LI><A HREF="gnat_ug.html#SEC71">Notes on the Command Line</A>
<LI><A HREF="gnat_ug.html#SEC72">How gnatmake Works</A>
<LI><A HREF="gnat_ug.html#SEC73">Examples of gnatmake Usage</A>
<LI><A HREF="gnat_ug.html#SEC74">Gnatmake in makefiles</A>
</UL>
<P>
A typical development cycle when working on an Ada program consists of
the following steps:

</P>

<OL>
<LI>

Edit some sources to fix bugs.

<LI>

Add enhancements.

<LI>

Compile all sources affected.

<LI>

Rebind and relink.

<LI>

Test.
</OL>

<P>
The third step can be tricky, because not only do the modified files
<A NAME="IDX216"></A>
have to be compiled, but any files depending on these files must also be
recompiled. The dependency rules in Ada can be quite complex, especially
in the presence of overloading, <CODE>use</CODE> clauses, generics and inlined
subprograms.

</P>
<P>
<CODE>gnatmake</CODE> automatically takes care of the third and fourth steps
of this process. It determines which sources need to be compiled,
compiles them, and binds and links the resulting object files.

</P>
<P>
Unlike some other Ada make programs, the dependencies are always
accurately recomputed from the new sources. The source based approach of
the GNAT compilation model makes this possible. This means that if
changes to the source program cause corresponding changes in
dependencies, they will always be tracked exactly correctly by
<CODE>gnatmake</CODE>.

</P>


<H2><A NAME="SEC68" HREF="gnat_ug_toc.html#TOC68">Running <CODE>gnatmake</CODE></A></H2>

<P>
The form of the <CODE>gnatmake</CODE> command is

</P>

<PRE>
   $ gnatmake [<VAR>switches</VAR>] <VAR>file_name</VAR> [<VAR>mode_switches</VAR>]
</PRE>

<P>
The only required argument is <VAR>file_name</VAR>, which specifies
the compilation unit that is the main program.  If <CODE>switches</CODE> are
present, they can be placed before of after <VAR>file_name</VAR>.
If <VAR>mode_switches</VAR> are present, they must always be placed after
<VAR>file_name</VAR> and all <CODE>switches</CODE>.

</P>
<P>
If you are using standard file extensions (.adb and .ads), then the
extension may be omitted from the <VAR>file_name</VAR> argument. However, if
you are using non-standard extensions, then it is required that the
extension be given. A relative or absolute directory path can be
specified in <VAR>file_name</VAR>, in which case, the input source file will
be searched for in the specified directory only. Otherwise, the input
source file will first be searched in the directory where
<CODE>gnatmake</CODE> was invoked and if it is not found, it will be search on
the source path of the compiler as described in section <A HREF="gnat_ug.html#SEC49">Search Paths and the Run-Time Library (RTL)</A>.

</P>
<P>
All <CODE>gnatmake</CODE> output (except when you specify
<CODE>-M</CODE>) is to
<CODE>stderr</CODE>. The output produced by the
<CODE>-M</CODE> switch is send to
<CODE>stdout</CODE>.

</P>


<H2><A NAME="SEC69" HREF="gnat_ug_toc.html#TOC69">Switches for <CODE>gnatmake</CODE></A></H2>

<P>
You may specify any of the following switches to <CODE>gnatmake</CODE>:

</P>
<DL COMPACT>

<DT><CODE>--GCC=<VAR>compiler_name</VAR></CODE>
<DD>
<A NAME="IDX217"></A>
Program used for compiling. The default is <CODE>gcc</CODE>'. You need to use
quotes around <VAR>compiler_name</VAR> if <CODE>compiler_name</CODE> contains
spaces or other separator characters. As an example <CODE>--GCC="foo -x
-y"</CODE> will instruct <CODE>gnatmake</CODE> to use <CODE>foo -x -y</CODE> as your
compiler.  Note that switch <CODE>-c</CODE> is always inserted after your
command name. Thus in the above example the compiler command that will
be used by <CODE>gnatmake</CODE> will be <CODE>foo -c -x -y</CODE>.

<DT><CODE>--GNATBIND=<VAR>binder_name</VAR></CODE>
<DD>
<A NAME="IDX218"></A>
Program used for binding. The default is <CODE>gnatbind</CODE>'. You need to
use quotes around <VAR>binder_name</VAR> if <VAR>binder_name</VAR> contains spaces
or other separator characters.  As an example <CODE>--GNATBIND="bar -x
-y"</CODE> will instruct <CODE>gnatmake</CODE> to use <CODE>bar -x -y</CODE> as your
binder. Binder switches that are normally appended by <CODE>gnatmake</CODE> to
<CODE>gnatbind</CODE>' are now appended to the end of <CODE>bar -x -y</CODE>.

<DT><CODE>--GNATLINK=<VAR>linker_name</VAR></CODE>
<DD>
<A NAME="IDX219"></A>
Program used for linking. The default is <CODE>gnatlink</CODE>'. You need to
use quotes around <VAR>linker_name</VAR> if <VAR>linker_name</VAR> contains spaces
or other separator characters.  As an example <CODE>--GNATLINK="lan -x
-y"</CODE> will instruct <CODE>gnatmake</CODE> to use <CODE>lan -x -y</CODE> as your
linker. Linker switches that are normally appended by <CODE>gnatmake</CODE> to
<CODE>gnatlink</CODE>' are now appended to the end of <CODE>lan -x -y</CODE>.

<DT><CODE>-a</CODE>
<DD>
<A NAME="IDX220"></A>
Consider all files in the make process, even the GNAT internal system
files (for example, the predefined Ada library files), as well as any
locked files. Locked files are files whose ALI file is write-protected.
By default,
<CODE>gnatmake</CODE> does not check these files,
because the assumption is that the GNAT internal files are properly up
to date, and also that any write protected ALI files have been properly
installed. Note that if there is an installation problem, such that one
of these files is not up to date, it will be properly caught by the
binder.
You may have to specify this switch if you are working on GNAT
itself. <CODE>-f</CODE> is also useful in conjunction with
<CODE>-f</CODE>
if you need to recompile an entire application,
including run-time files, using special configuration pragma settings,
such as a non-standard <CODE>Float_Representation</CODE> pragma.
By default
<CODE>gnatmake -a</CODE> compiles all GNAT
internal files with
<CODE>gcc -c -gnatg</CODE> rather than <CODE>gcc -c</CODE>.

<DT><CODE>-c</CODE>
<DD>
<A NAME="IDX221"></A>
Compile only. Do not perform binding and linking. If the root unit
specified by <VAR>file_name</VAR> is not a main unit, this is the
default.  Otherwise <CODE>gnatmake</CODE> will attempt binding and linking
unless all objects are up to date and the executable is more recent than
the objects.

<DT><CODE>-f</CODE>
<DD>
<A NAME="IDX222"></A>
Force recompilations. Recompile all sources, even though some object
files may be up to date, but don't recompile predefined or GNAT internal
files or locked files (files with a write-protected ALI file),
unless the <CODE>-a</CODE> switch is also specified.

<DT><CODE></CODE>
<DD>
<DT><CODE>-i</CODE>
<DD>
<A NAME="IDX223"></A>
In normal mode, <CODE>gnatmake</CODE> compiles all object files and ALI files
into the current directory. If the <CODE>-i</CODE> switch is used,
then instead object files and ALI files that already exist are overwritten
in place. This means that once a large project is organized into separate
directories in the desired manner, then <CODE>gnatmake</CODE> will automatically
maintain and update this organization. If no ALI files are found on the
Ada object path (section <A HREF="gnat_ug.html#SEC49">Search Paths and the Run-Time Library (RTL)</A>),
the new object and ALI files are created in the
directory containing the source being compiled. If another organization
is desired, where objects and sources are kept in different directories,
a useful technique is to create dummy ALI files in the desired directories.
When detecting such a dummy file, <CODE>gnatmake</CODE> will be forced to recompile
the corresponding source file, and it will be put the resulting object
and ALI files in the directory where it found the dummy file.

<DT><CODE>-j<VAR>n</VAR></CODE>
<DD>
<A NAME="IDX224"></A>
<A NAME="IDX225"></A>
Use <VAR>n</VAR> processes to carry out the (re)compilations. On a
multiprocessor machine compilations will occur in parallel.  In the
event of compilation errors, messages from various compilations might
get interspersed (but <CODE>gnatmake</CODE> will give you the full ordered
list of failing compiles at the end). If this is problematic, rerun
the make process with n set to 1 to get a clean list of messages.

<DT><CODE>-k</CODE>
<DD>
<A NAME="IDX226"></A>
Keep going. Continue as much as possible after a compilation error.  To
ease the programmer's task in case of compilation errors, the list of
sources for which the compile fails is given when <CODE>gnatmake</CODE>
terminates.

<DT><CODE>-m</CODE>
<DD>
<A NAME="IDX227"></A>
Specifies that the minimum necessary amount of recompilations
be performed. In this mode <CODE>gnatmake</CODE> ignores time
stamp differences when the only
modifications to a source file consist in adding/removing comments,
empty lines, spaces or tabs. This means that if you have changed the
comments in a source file or have simply reformatted it, using this
switch will tell gnatmake not to recompile files that depend on it
(provided other sources on which these files depend have undergone no
semantic modifications).

<DT><CODE>-M</CODE>
<DD>
<A NAME="IDX228"></A>
<A NAME="IDX229"></A>
Check if all objects are up to date. If they are, output the object
dependences to <CODE>stdout</CODE> in a form that can be directly exploited in
a <TT>`Makefile'</TT>. By default, each source file is prefixed with its
(relative or absolute) directory name. This name is whatever you
specified in the various <CODE>-aI</CODE>
and <CODE>-I</CODE> switches.  If you use
<CODE>gnatmake -M</CODE>
<CODE>-q</CODE>
(see below), only the source file names,
without relative paths, are output. If you just specify the
<CODE>-M</CODE>
switch, dependencies of the GNAT internal system files are omitted. This
is typically what you want. If you also specify
the <CODE>-a</CODE> switch,
dependencies of the GNAT internal files are also listed. Note that
dependencies of the objects in external Ada libraries (see switch
<CODE>-aL</CODE><VAR>dir</VAR> in the following list) are never reported.

<DT><CODE>-n</CODE>
<DD>
<A NAME="IDX230"></A>
Don't compile, bind, or link.  Checks if all objects are up to date.
If they are not, the full name of the first file that needs to be
recompiled is printed.
Repeated use of this option, followed by compiling the indicated source
file, will eventually result in recompiling all required units.

<DT><CODE>-o <VAR>exec_name</VAR></CODE>
<DD>
<A NAME="IDX231"></A>
Output executable name. The name of the final executable program will be
<VAR>exec_name</VAR>. If the <CODE>-o</CODE> switch is omitted the default
name for the executable will be the name of the input file in appropriate form
for an executable file on the host system.

<DT><CODE>-q</CODE>
<DD>
<A NAME="IDX232"></A>
Quiet. When this flag is not set, the commands carried out by
<CODE>gnatmake</CODE> are displayed.

<DT><CODE>-v</CODE>
<DD>
<A NAME="IDX233"></A>
Verbose. Displays the reason for all recompilations <CODE>gnatmake</CODE>
decides are necessary.

<DT><CODE>-z</CODE>
<DD>
<A NAME="IDX234"></A>
No main subprogram. Bind and link the program even if the unit name
given on the command line is a package name. The resulting executable
will execute the elaboration routines of the package and its closure,
then the finalization routines.

<DT><CODE><CODE>gcc</CODE> switches</CODE>
<DD>
The switch <CODE>-g</CODE> or any uppercase switch (other than <CODE>-A</CODE>, or
<CODE>-L</CODE>) or any switch that is more than one character is passed to
<CODE>gcc</CODE> (e.g. <CODE>-O</CODE>, <CODE>-gnato,</CODE> etc.)
</DL>

<P>
Source and library search path switches:

</P>
<DL COMPACT>

<DT><CODE>-aI<VAR>dir</VAR></CODE>
<DD>
<A NAME="IDX235"></A>
When looking for source files also look in directory <VAR>dir</VAR>.
The order in which source files search is undertaken is
described in section <A HREF="gnat_ug.html#SEC49">Search Paths and the Run-Time Library (RTL)</A>.

<DT><CODE>-aL<VAR>dir</VAR></CODE>
<DD>
<A NAME="IDX236"></A>
Consider <VAR>dir</VAR> as being an externally provided Ada library.
Instructs <CODE>gnatmake</CODE> to skip compilation units whose <TT>`.ali'</TT>
files have been located in directory <VAR>dir</VAR>. This allows you to have
missing bodies for the units in <VAR>dir</VAR>.  You still need to specify
the location of the specs for these units by using the switches
<CODE>-aI<VAR>dir</VAR></CODE>
or <CODE>-I<VAR>dir</VAR></CODE>.
Note: this switch is provided for compatibility with previous versions
of <CODE>gnatmake</CODE>. The easier method of causing standard libraries
to be excluded from consideration is to write-protect the corresponding
ALI files.

<DT><CODE>-aO<VAR>dir</VAR></CODE>
<DD>
<A NAME="IDX237"></A>
When searching for library and object files, look in directory
<VAR>dir</VAR>. The order in which library files are searched is described in
section <A HREF="gnat_ug.html#SEC62">Search Paths for <CODE>gnatbind</CODE></A>.

<DT><CODE>-A<VAR>dir</VAR></CODE>
<DD>
<A NAME="IDX238"></A>
<A NAME="IDX239"></A>
Equivalent to <CODE>-aL<VAR>dir</VAR>
-aI<VAR>dir</VAR></CODE>.

<DT><CODE>-I<VAR>dir</VAR></CODE>
<DD>
<A NAME="IDX240"></A>
Equivalent to <CODE>-aO<VAR>dir</VAR>
-aI<VAR>dir</VAR></CODE>.

<DT><CODE>-I-</CODE>
<DD>
<A NAME="IDX241"></A>
<A NAME="IDX242"></A>
Do not look for source files in the directory containing the source
file named in the command line.
Do not look for ALI or object files in the directory
where <CODE>gnatmake</CODE> was invoked.

<DT><CODE>-L<VAR>dir</VAR></CODE>
<DD>
<A NAME="IDX243"></A>
<A NAME="IDX244"></A>
Add directory <VAR>dir</VAR> to the list of directories in which the linker
will search for libraries. This is equivalent to
<CODE>-largs -L</CODE><VAR>dir</VAR>.

<DT><CODE>-nostdinc</CODE>
<DD>
<A NAME="IDX245"></A>
Do not look for source files in the system default directory.

<DT><CODE>-nostdlib</CODE>
<DD>
<A NAME="IDX246"></A>
Do not look for library files in the system default directory.
</DL>



<H2><A NAME="SEC70" HREF="gnat_ug_toc.html#TOC70">Mode switches for <CODE>gnatmake</CODE></A></H2>

<P>
The mode switches (referred to as <CODE>mode_switches</CODE>) allow the
inclusion of switches that are to be passed to the compiler itself, the
binder or the linker. The effect of a mode switch is to cause all
subsequent switches up to the end of the switch list, or up to the next
mode switch, to be interpreted as switches to be passed on to the
designated component of GNAT.

</P>
<DL COMPACT>

<DT><CODE>-cargs <VAR>switches</VAR></CODE>
<DD>
<A NAME="IDX247"></A>
Compiler switches. Here <VAR>switches</VAR> is a list of switches
that are valid switches for <CODE>gcc</CODE>. They will be passed on to
all compile steps performed by <CODE>gnatmake</CODE>.

<DT><CODE>-bargs <VAR>switches</VAR></CODE>
<DD>
<A NAME="IDX248"></A>
Binder switches. Here <VAR>switches</VAR> is a list of switches
that are valid switches for <CODE>gcc</CODE>. They will be passed on to
all bind steps performed by <CODE>gnatmake</CODE>.

<DT><CODE>-largs <VAR>switches</VAR></CODE>
<DD>
<A NAME="IDX249"></A>
Linker switches. Here <VAR>switches</VAR> is a list of switches
that are valid switches for <CODE>gcc</CODE>. They will be passed on to
all link steps performed by <CODE>gnatmake</CODE>.
</DL>



<H2><A NAME="SEC71" HREF="gnat_ug_toc.html#TOC71">Notes on the Command Line</A></H2>

<P>
This section contains some additional useful notes on the operation
of the <CODE>gnatmake</CODE> command.

</P>

<UL>
<LI>

<A NAME="IDX250"></A>
If <CODE>gnatmake</CODE> finds no ALI files, it recompiles the main program
and all other units required by the main program.
This means that <CODE>gnatmake</CODE>
can be used for the initial compile, as well as during subsequent steps of
the development cycle.

<LI>

If you enter <CODE>gnatmake <VAR>file</VAR>.adb</CODE>, where <TT>`<VAR>file</VAR>.adb'</TT>
is a subunit or body of a generic unit, <CODE>gnatmake</CODE> recompiles
<TT>`<VAR>file</VAR>.adb'</TT> (because it finds no ALI) and stops, issuing a
warning.

<LI>

In <CODE>gnatmake</CODE> the switch <CODE>-I</CODE>
is used to specify both source and
library file paths. Use <CODE>-aI</CODE>
instead if you just want to specify
source paths only and <CODE>-aO</CODE>
if you want to specify library paths
only.

<LI>

<CODE>gnatmake</CODE> examines both an ALI file and its corresponding object file
for consistency. If an ALI is more recent than its corresponding object,
or if the object file is missing, the corresponding source will be recompiled.
Note that <CODE>gnatmake</CODE> expects an ALI and the corresponding object file
to be in the same directory.

<LI>

<CODE>gnatmake</CODE> will ignore any files whose ALI file is write-protected.
This may conveniently be used to exclude standard libraries from
consideration and in particular it means that the use of the
<CODE>-f</CODE> switch will not recompile these files
unless <CODE>-a</CODE> is also specified.

<LI>

<CODE>gnatmake</CODE> has been designed to make the use of Ada libraries
particularly convenient. Assume you have an Ada library organized
as follows: <VAR>obj-dir</VAR> contains the objects and ALI files for
of your Ada compilation units,
whereas <VAR>include-dir</VAR> contains the
specs of these units, but no bodies. Then to compile a unit
stored in <CODE>main.adb</CODE>, which uses this Ada library you would just type


<PRE>
   $ gnatmake -aI<VAR>include-dir</VAR>  -aL<VAR>obj-dir</VAR>  main
</PRE>

<LI>

Using <CODE>gnatmake</CODE> along with the
<CODE>-m (minimal recompilation)</CODE>
switch provides an
extremely powerful tool: you can freely update the comments/format of your
source files without having to recompile everything. Note, however, that
adding or deleting lines in a source files may render its debugging
info obsolete. If the file in question is a spec, the impact is rather
limited, as that debugging info will only be useful during the
elaboration phase of your program. For bodies the impact can be more
significant. In all events, your debugger will warn you if a source file
is more recent than the corresponding object, and therefore obsolescence of
debugging information will go unnoticed.
</UL>



<H2><A NAME="SEC72" HREF="gnat_ug_toc.html#TOC72">How <CODE>gnatmake</CODE> Works</A></H2>

<P>
Generally <CODE>gnatmake</CODE> automatically performs all necessary
recompilations and you don't need to worry about how it works. However,
it may be useful to have some basic understanding of the <CODE>gnatmake</CODE>
approach and in particular to understand how it uses the results of
previous compilations without incorrectly depending on them.

</P>
<P>
First a definition: an object file is considered <STRONG>up to date</STRONG> if the
corresponding ALI file exists and its time stamp predates that of the
object file and if all the source files listed in the
dependency section of this ALI file have time stamps matching those in
the ALI file. This means that neither the source file itself nor any
files that it depends on have been modified, and hence there is no need
to recompile this file.

</P>
<P>
<CODE>gnatmake</CODE> works by first checking if the specified main unit is up
to date. If so, no compilations are required for the main unit.  If not,
<CODE>gnatmake</CODE> compiles the main program to build a new ALI file that
reflects the latest sources. Then the ALI file of the main unit is
examined to find all the source files on which the main program depends,
and <CODE>gnatmake</CODE> recursively applies the above procedure on all these files.

</P>
<P>
This process ensures that <CODE>gnatmake</CODE> only trusts the dependencies
in an existing ALI file if they are known to be correct.  Otherwise it
always recompiles to determine a new, guaranteed accurate set of
dependencies. As a result the program is compiled "upside down" from what may
be more familiar as the required order of compilation in some other Ada
systems. In particular, clients are compiled before the units on which
they depend. The ability of GNAT to compile in any order is critical in
allowing an order of compilation to be chosen that guarantees that
<CODE>gnatmake</CODE> will recompute a correct set of new dependencies if
necessary.

</P>


<H2><A NAME="SEC73" HREF="gnat_ug_toc.html#TOC73">Examples of <CODE>gnatmake</CODE> Usage</A></H2>

<DL COMPACT>

<DT><CODE>gnatmake hello.adb</CODE>
<DD>
Compile all files necessary to bind and link the main program
<TT>`hello.adb'</TT> (containing unit <CODE>Hello</CODE>) and bind and link the
resulting object files to generate an executable file <TT>`hello'</TT>.

<DT><CODE>gnatmake -q Main_Unit -cargs -O2 -bargs -l</CODE>
<DD>
Compile all files necessary to bind and link the main program unit
<CODE>Main_Unit</CODE> (from file <TT>`main_unit.adb'</TT>). All compilations will
be done with optimization level 2 and the order of elaboration will be
listed by the binder. <CODE>gnatmake</CODE> will operate in quiet mode, not
displaying commands it is executing.
</DL>



<H2><A NAME="SEC74" HREF="gnat_ug_toc.html#TOC74">Gnatmake in makefiles</A></H2>
<P>
<A NAME="IDX251"></A>
<A NAME="IDX252"></A>

</P>
<P>
Complex project organizations can be handled in a very powerful way by
using GNU make combined with gnatmake. Here is for instance a Makefile
which allows to build each subsystem of a big project into a separate
shared library. Such a makefile allows to significantly reduce the link
time of very bug applications while maintaining a complete coherence at
each step of the build process.

</P>

<PRE>
## This Makefile is intended to be used with the following directory
## configuration:
##  - The sources are split into a series of csc (computer software components)
##    Each of these csc is put in its own directory.
##    Their name are referenced by the directory names.
##    They will be compiled into shared library (although this would also work
##    with static libraries
##  - The main program (and possibly other packages that do not belong to any
##    csc is put in the top level directory (where the Makefile is).
##       toplevel_dir __ first_csc  (sources) __ lib (will contain the library)
##                    \_ second_csc (sources) __ lib (will contain the library)
##                    \_ ...
## Although this Makefile is build for shared library, it is easy to modify
## to build partial link objects instead (modify the lines with -shared and
## gnatlink below)
##
## With this makefile, you can change any file in the system or add any new
## file, and everything will be recompiled correctly (only the relevant shared
## objects will be recompiled, and the main program will be re-linked).

# The list of computer software component for your project
CSC_LIST=aa bb cc

# Name of the main program (no extension)
MAIN=main

# If we need to build objects with -fPIC, uncomment the following line
#NEED_FPIC=-fPIC

# The following variable should give the directory containing libgnat.so
# You can get this directory through 'gnatls -v'. This is usually the last
# directory in the Object_Path.
GLIB=...

# The directories for the libraries
# (This macro expands the list of CSC to the list of shared libraries, you
# could simply use the expanded form :
# LIB_DIR=aa/lib/libaa.so bb/lib/libbb.so cc/lib/libcc.so
LIB_DIR=${foreach dir,${CSC_LIST},${dir}/lib/lib${dir}.so}

${MAIN}: objects ${LIB_DIR}
	gnatbind ${MAIN} ${CSC_LIST:%=-aO%/lib} -shared
	gnatlink ${MAIN} ${CSC_LIST:%=-l%}

objects::
	# recompile the sources
	gnatmake -c -i ${MAIN}.adb ${NEED_FPIC} ${CSC_LIST:%=-I%}

# Note about the rules below: if your csc are not split into multiple
# directories, but simply by their name, you need to replace *.o and
# *.ali with the appropriate list of files
# Note: In a future version of GNAT, the following commands will be simplified
# by a new tool, gnatmlib
${LIB_DIR}:
	mkdir -p ${dir $ }
	cd ${dir $ }; gcc -shared -o ${notdir $ } ../*.o -L${GLIB} -lgnat
	cd ${dir $ }; cp -f ../*.ali .

# The dependencies for the modules
aa/lib/libaa.so: aa/*.o
bb/lib/libbb.so: bb/*.o
bb/lib/libcc.so: cc/*.o

run::
	LD_LIBRARY_PATH=pwd/aa/lib:pwd/bb/lib:pwd/cc/lib ./${MAIN}

clean::
	${RM} -rf ${CSC_LIST:%=%/lib}
	${RM} ${CSC_LIST:%=%/*.ali}
	${RM} ${CSC_LIST:%=%/*.o}
	${RM} *.o *.ali ${MAIN}

</PRE>



<H1><A NAME="SEC75" HREF="gnat_ug_toc.html#TOC75">Renaming Files Using <CODE>gnatchop</CODE></A></H1>
<P>
<A NAME="IDX253"></A>

</P>
<P>
This chapter discusses how to handle files with multiple units by using
the <CODE>gnatchop</CODE> utility. This utility is also useful in renaming
files to meet the standard GNAT default file naming conventions.

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC76">Handling Files with Multiple Units</A>
<LI><A HREF="gnat_ug.html#SEC77">Operating gnatchop in Compilation Mode</A>
<LI><A HREF="gnat_ug.html#SEC78">Command Line for gnatchop</A>
<LI><A HREF="gnat_ug.html#SEC79">Switches for gnatchop</A>
<LI><A HREF="gnat_ug.html#SEC80">Examples of gnatchop Usage</A>
</UL>



<H2><A NAME="SEC76" HREF="gnat_ug_toc.html#TOC76">Handling Files with Multiple Units</A></H2>

<P>
The basic compilation model of GNAT requires that a file submitted to the
compiler have only one unit and there be a strict correspondence
between the file name and the unit name.

</P>
<P>
The <CODE>gnatchop</CODE> utility allows both of these rules to be relaxed,
allowing GNAT to process files which contain multiple compilation units
and files with arbitrary file names. <CODE>gnatchop</CODE>
reads the specified file and generates one or more output files,
containing one unit per file. The unit and the file name correspond,
as required by GNAT.

</P>
<P>
If you want to permanently restructure a set of "foreign" files so that
they match the GNAT rules, and do the remaining development using the
GNAT structure, you can simply use <CODE>gnatchop</CODE> once, generate the
new set of files and work with them from that point on.

</P>
<P>
Alternatively, if you want to keep your files in the "foreign" format,
perhaps to maintain compatibility with some other Ada compilation
system, you can set up a procedure where you use <CODE>gnatchop</CODE> each
time you compile, regarding the source files that it writes as temporary
files that you throw away.

</P>


<H2><A NAME="SEC77" HREF="gnat_ug_toc.html#TOC77">Operating gnatchop in Compilation Mode</A></H2>

<P>
The basic function of <CODE>gnatchop</CODE> is to take a file with multiple units
and split it into separate files. The boundary between files is reasonably
clear, except for the issue of comments and pragmas. In default mode, the
rule is that any pragmas between units belong to the previous unit, except
that configuration pragmas always belong to the following unit. Any comments
belong to the following unit. These rules
almost always result in the right choice of
the split point without needing to mark it explicitly and most users will
find this default to be what they want. In this default mode it is incorrect to
submit a file containing only configuration pragmas, or one that ends in
configuration pragmas, to <CODE>gnatchop</CODE>.

</P>
<P>
However, using a special option to activate "compilation mode",
<CODE>gnatchop</CODE>
can perform another function, which is to provide exactly the semantics
required by the RM for handling of configuration pragmas in a compilation.
In the absence of configuration pragmas (at the main file level), this
option has no effect, but it causes such configuration pragmas to be handled
in a quite different manner.

</P>
<P>
First, in compilation mode, if <CODE>gnatchop</CODE> is given a file that consists of
only configuration pragmas, then this file is appended to the
<TT>`gnat.adc'</TT> file in the current directory. This behavior provides
the required behavior described in the RM for the actions to be taken
on submitting such a file to the compiler, namely that these pragmas
should apply to all subsequent compilations in the same compilation
environment. Using GNAT, the current directory, possibly containing a
<TT>`gnat.adc'</TT> file is the representation
of a compilation environment. For more information on the
<TT>`gnat.adc'</TT> file, see the section on handling of configuration
pragmas see section <A HREF="gnat_ug.html#SEC82">Handling of Configuration Pragmas</A>.

</P>
<P>
Second, in compilation mode, if <CODE>gnatchop</CODE>
is given a file that starts with
configuration pragmas, and contains one or more units, then these
configuration pragmas are prepended to each of the chopped files. This
behavior provides the required behavior described in the RM for the
actions to be taken on compiling such a file, namely that the pragmas
apply to all units in the compilation, but not to subsequently compiled
units.

</P>
<P>
Finally, if configuration pragmas appear between units, they are appended
to the previous unit. This results in the previous unit being illegal,
since the compiler does not accept configuration pragmas that follow
a unit. This provides the required RM behavior that forbids configuration
pragmas other than those preceding the first compilation unit of a
compilation.

</P>
<P>
For most purposes, <CODE>gnatchop</CODE> will be used in default mode. The
compilation mode described above is used only if you need exactly
accurate behavior with respect to compilations, and you have files
that contain multiple units and configuration pragmas. In this
circumstance the use of <CODE>gnatchop</CODE> with the compilation mode
switch provides the required behavior, and is for example the mode
in which GNAT processes the ACVC tests.

</P>


<H2><A NAME="SEC78" HREF="gnat_ug_toc.html#TOC78">Command Line for <CODE>gnatchop</CODE></A></H2>

<P>
The <CODE>gnatchop</CODE> command has the form:

</P>

<PRE>
   $ gnatchop switches <VAR>file name</VAR> [<VAR>file name</VAR> <VAR>file name</VAR> ...] [<VAR>directory</VAR>]
</PRE>

<P>
The only required argument is the file name of the file to be chopped.
There are no restrictions on the form of this file name. The file itself
contains one or more Ada units, in normal GNAT format, concatenated
together. As shown, more than one file may be presented to be chopped.

</P>
<P>
When run in default mode, <CODE>gnatchop</CODE> generates one output file in
the current directory for each unit in each of the files.

</P>
<P>
<VAR>directory</VAR>, if specified, gives the name of the directory to which
the output files will be written. If it is not specified, all files are
written to the current directory.

</P>
<P>
For example, given a
file called <TT>`hellofiles'</TT> containing

</P>

<PRE>
   <B>procedure</B> hello;

   <B>with</B> Text_IO; <B>use</B> Text_IO;
   <B>procedure</B> hello <B>is</B>
   <B>begin</B>
      Put_Line ("Hello");
   <B>end</B> hello;
</PRE>

<P>
the command

</P>

<PRE>
   $ gnatchop hellofiles
</PRE>

<P>
generates two files in the current directory, one called
<TT>`hello.ads'</TT> containing the single line that is the procedure spec,
and the other called <TT>`hello.adb'</TT> containing the remaining text. The
original file is not affected. The generated files can be compiled in
the normal manner.

</P>


<H2><A NAME="SEC79" HREF="gnat_ug_toc.html#TOC79">Switches for <CODE>gnatchop</CODE></A></H2>

<P>
<CODE>gnatchop</CODE> recognizes the following switches:

</P>
<DL COMPACT>

<DT><CODE>-c</CODE>
<DD>
<A NAME="IDX254"></A>
Causes <CODE>gnatchop</CODE> to operate in compilation mode, in which
configuration pragmas are handled according to strict RM rules. See
previous section for a full description of this mode.

<DT><CODE>-gnatxxx</CODE>
<DD>
This passes the given <CODE>-gnatxxx</CODE> switch to <CODE>gnat</CODE> which is
used to parse the given file. Not all <CODE>xxx</CODE> options make sense,
but for example, the use of <CODE>-gnati2</CODE> allows <CODE>gnatchop</CODE> to
process a source file that uses Latin-2 coding for identifiers.

<DT><CODE>-h</CODE>
<DD>
Causes <CODE>gnatchop</CODE> to generate a brief help summary to the standard
output file showing usage information.

<DT><CODE>-k<VAR>mm</VAR></CODE>
<DD>
<A NAME="IDX255"></A>
Limit generated file names to the specified number <CODE>mm</CODE>
of characters.
This is useful if the
resulting set of files is required to be interoperable with systems
which limit the length of file names.
No space is allowed between the <CODE>-k</CODE> and the numeric value. The numeric
value may be omitted in which case a default of <CODE>-k8</CODE>,
suitable for use
with DOS-like file systems, is used. If no <CODE>-k</CODE> switch
is present then
there is no limit on the length of file names.

<DT><CODE>-q</CODE>
<DD>
<A NAME="IDX256"></A>
Causes output of informational messages indicating the set of generated
files to be suppressed. Warnings and error messages are unaffected.

<DT><CODE>-r</CODE>
<DD>
<A NAME="IDX257"></A>
<A NAME="IDX258"></A>
Generate <CODE>Source_Reference</CODE> pragmas. Use this switch if the output
files are regarded as temporary and development is to be done in terms
of the original unchopped file. This switch causes
<CODE>Source_Reference</CODE> pragmas to be inserted into each of the
generated files to refers back to the original file name and line number.
The result is that all error messages refer back to the original
unchopped file.
In addition, the debugging information placed into the object file (when
the <CODE>-g</CODE> switch of <CODE>gcc</CODE> or <CODE>gnatmake</CODE> is specified) also
refers back to this original file so that tools like profilers and
debuggers will give information in terms of the original unchopped file.

If the original file to be chopped itself contains
a <CODE>Source_Reference</CODE>
pragma referencing a third file, then gnatchop respects
this pragma, and the generated <CODE>Source_Reference</CODE> pragmas
in the chopped file refer to the original file, with appropriate
line numbers. This is particularly useful when <CODE>gnatchop</CODE>
is used in conjunction with <CODE>gnatprep</CODE> to compile files that
contain preprocessing statements and multiple units.

<DT><CODE>-v</CODE>
<DD>
<A NAME="IDX259"></A>
Causes <CODE>gnatchop</CODE> to operate in verbose mode. The version
number and copyright notice are output, as well as exact copies of
the gnat1 commands spawned to obtain the chop control information.

<DT><CODE>-w</CODE>
<DD>
<A NAME="IDX260"></A>
Overwrite existing file names. Normally <CODE>gnatchop</CODE> regards it as a
fatal error if there is already a file with the same name as a
file it would otherwise output, in other words if the files to be
chopped contain duplicated units. This switch bypasses this
check, and causes all but the last instance of such duplicated
units to be skipped.
</DL>



<H2><A NAME="SEC80" HREF="gnat_ug_toc.html#TOC80">Examples of <CODE>gnatchop</CODE> Usage</A></H2>

<DL COMPACT>

<DT><CODE>gnatchop -w hello_s.ada ichbiah/files</CODE>
<DD>
Chops the source file <TT>`hello_s.ada'</TT>. The output files will be
placed in the directory <TT>`ichbiah/files'</TT>,
overwriting any
files with matching names in that directory (no files in the current
directory are modified).

<DT><CODE>gnatchop archive</CODE>
<DD>
Chops the source file <TT>`archive'</TT>
into the current directory.  One
useful application of <CODE>gnatchop</CODE> is in sending sets of sources
around, for example in email messages. The required sources are simply
concatenated (for example, using a UNIX <CODE>cat</CODE>
command), and then
<CODE>gnatchop</CODE> is used at the other end to reconstitute the original
file names.

<DT><CODE>gnatchop file1 file2 file3 direc</CODE>
<DD>
Chops all units in files <TT>`file1'</TT>, <TT>`file2'</TT>, <TT>`file3'</TT>, placing
the resulting files in the directory <TT>`direc'</TT>. Note that if any units
occur more than once anywhere within this set of files, an error message
is generated, and no files are written. To override this check, use the
<CODE>-w</CODE> switch,
in which case the last occurrence in the last file will
be the one that is output, and earlier duplicate occurrences for a given
unit will be skipped.
</DL>



<H1><A NAME="SEC81" HREF="gnat_ug_toc.html#TOC81">Configuration Pragmas</A></H1>
<P>
<A NAME="IDX261"></A>
<A NAME="IDX262"></A>

</P>
<P>
In Ada 95, configuration pragmas include those pragmas described as
such in the Ada 95 Reference Manual, as well as
implementation-dependent pragmas that are configuration pragmas. See the
individual descriptions of pragmas in the GNAT Reference Manual for
details on these additional GNAT-specific configuration pragmas. Most
notably, the pragma <CODE>Source_File_Name</CODE>, which allows
specifying non-default names for source files, is a configuration
pragma.

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC82">Handling of Configuration Pragmas</A>
<LI><A HREF="gnat_ug.html#SEC83">The Configuration Pragmas file</A>
</UL>



<H2><A NAME="SEC82" HREF="gnat_ug_toc.html#TOC82">Handling of Configuration Pragmas</A></H2>

<P>
Configuration pragmas may either appear at the start of a compilation
unit, in which case they apply only to that unit, or they may apply to
all compilations performed in a given compilation environment.

</P>
<P>
GNAT also provides the <CODE>gnatchop</CODE> utility to provide an automatic
way to handle configuration pragmas following the semantics for
compilations (that is, files with multiple units), described in the RM.
See section see section <A HREF="gnat_ug.html#SEC77">Operating gnatchop in Compilation Mode</A> for details.
However, for most purposes, it will be more convenient to edit the
<TT>`gnat.adc'</TT> file that contains configuration pragmas directly,
as described in the following section.

</P>


<H2><A NAME="SEC83" HREF="gnat_ug_toc.html#TOC83">The Configuration Pragmas file</A></H2>
<P>
<A NAME="IDX263"></A>

</P>
<P>
In GNAT a compilation environment is defined by the current
directory at the time that a compile command is given. This current
directory is searched for a file whose name is <TT>`gnat.adc'</TT>. If
this file is present, it is expected to contain one or more
configuration pragmas that will be applied to the current compilation.

</P>
<P>
Configuration pragmas may be entered into the <TT>`gnat.adc'</TT> file
either by running <CODE>gnatchop</CODE> on a source file that consists only of
configuration pragmas, or more conveniently  by
direct editing of the <TT>`gnat.adc'</TT> file, which is a standard format
source file.

</P>



<H1><A NAME="SEC84" HREF="gnat_ug_toc.html#TOC84">Elaboration Order Handling in GNAT</A></H1>
<P>
<A NAME="IDX264"></A>
<A NAME="IDX265"></A>

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC85">Elaboration Code in Ada 95</A>
<LI><A HREF="gnat_ug.html#SEC86">Checking the Elaboration Order in Ada 95</A>
<LI><A HREF="gnat_ug.html#SEC87">Controlling the Elaboration Order in Ada 95</A>
<LI><A HREF="gnat_ug.html#SEC88">Controlling Elaboration in GNAT - Internal Calls</A>
<LI><A HREF="gnat_ug.html#SEC89">Controlling Elaboration in GNAT - External Calls</A>
<LI><A HREF="gnat_ug.html#SEC90">Default Behavior in GNAT - Ensuring Safety</A>
<LI><A HREF="gnat_ug.html#SEC91">What to do if the Default Elaboration Behavior Fails</A>
<LI><A HREF="gnat_ug.html#SEC92">Elaboration for Access-to-Subprogram Values</A>
<LI><A HREF="gnat_ug.html#SEC93">Summary of Procedures for Elaboration Control</A>
</UL>

<P>
This chapter describes the handling of elaboration code in Ada 95 and
in GNAT, and discusses how the order of elaboration of program units can
be controlled in GNAT, either automatically or with explicit programming
features.

</P>


<H2><A NAME="SEC85" HREF="gnat_ug_toc.html#TOC85">Elaboration Code in Ada 95</A></H2>

<P>
Ada 95 provides rather general mechanisms for executing code at elaboration
time, that is to say before the main program starts executing. Such code arises
in three contexts:

</P>
<DL COMPACT>

<DT>Initializers for variables.
<DD>
Variables declared at the library level, in package specs or bodies, can
require initialization that is performed at elaboration time, as in:

<PRE>
   Sqrt_Half : Float := Sqrt (0.5);
</PRE>

<DT>Package initialization code
<DD>
Code in a <CODE>BEGIN-END</CODE> section at the outer level of a package body is
executed as part of the package body elaboration code.

<DT>Library level task allocators
<DD>
Tasks that are declared using task allocators at the library level
start executing immediately and hence can execute at elaboration time.
</DL>

<P>
Subprogram calls are possible in any of these contexts, which means that
any arbitrary part of the program may be executed as part of the elaboration
code. It is even possible to write a program which does all its work at
elaboration time, with a null main program, although stylistically this
would usually be considered an inappropriate way to structure
a program.

</P>
<P>
An important concern arises in the context of elaboration code:
we have to be sure that it is executed in an appropriate order. What we
have is numerous sections of elaboration code, potentially one section
for each unit in the program. It is important that these execute
in the correct order. Correctness here means that, taking the above
example of the declaration of <CODE>Sqrt_Half</CODE>,
that if some other piece of
elaboration code references <CODE>Sqrt_Half</CODE>,
then it must run after the
section of elaboration code that contains the declaration of
<CODE>Sqrt_Half</CODE>.

</P>
<P>
There would never be any order of elaboration problem if we made a rule
that whenever you <CODE>with</CODE> a unit, you must elaborate both the spec and body
of that unit before elaborating the unit doing the <CODE>with</CODE>'ing:

</P>

<PRE>
   <B>with</B> Unit_1;
   <B>package</B> Unit_2 <B>is</B> ...
</PRE>

<P>
would require that both the body and spec of <CODE>Unit_1</CODE> be elaborated
before the spec of <CODE>Unit_2</CODE>. However, a rule like that would be far too
restrictive. In particular, it would make it impossible to have routines
in separate packages that were mutually recursive.

</P>
<P>
You might think that a clever enough compiler could look at the actual
elaboration code and determine an appropriate correct order of elaboration,
but in the general case, this is not possible. Consider the following
example.

</P>
<P>
In the body of <CODE>Unit_1</CODE>, we have a procedure <CODE>Func_1</CODE>
that references
the variable <CODE>Sqrt_1</CODE>, which is declared in the elaboration code
of the body of <CODE>Unit_1</CODE>:

</P>

<PRE>
   Sqrt_1 : Float := Sqrt (0.1);
</PRE>

<P>
The elaboration code of the body of <CODE>Unit_1</CODE> also contains:

</P>

<PRE>
   <B>if</B> expression_1 = 1 <B>then</B>
      Q := Unit_2.Func_2;
   <B>end if</B>;
</PRE>

<P>
<CODE>Unit_2</CODE> is exactly parallel,
it has a procedure <CODE>Func_2</CODE> that references
the variable <CODE>Sqrt_2</CODE>, which is declared in the elaboration code of
the body <CODE>Unit_2</CODE>:

</P>

<PRE>
   Sqrt_2 : Float := Sqrt (0.1);
</PRE>

<P>
The elaboration code of the body of <CODE>Unit_2</CODE> also contains:

</P>

<PRE>
   <B>if</B> expression_2 = 2 <B>then</B>
      Q := Unit_1.Func_1;
   <B>end if</B>;
</PRE>

<P>
Now the question is, which of the following orders of elaboration is
acceptable:

</P>

<PRE>
   Spec of Unit_1
   Spec of Unit_2
   Body of Unit_1
   Body of Unit_2
</PRE>

<P>
or

</P>

<PRE>
   Spec of Unit_2
   Spec of Unit_1
   Body of Unit_2
   Body of Unit_1
</PRE>

<P>
If you carefully analyze the flow here, you will see that you cannot tell
at compile time the answer to this question.
If <CODE>expression_1</CODE> is not equal to 1,
and <CODE>expression_2</CODE> is not equal to 2,
then either order is acceptable, because neither of the function calls is
executed. If both tests evaluate to true, then neither order is acceptable
and in fact there is no correct order.

</P>
<P>
If one of the two expressions is true, and the other is false, then one
of the above orders is correct, and the other is incorrect. For example,
if <CODE>expression_1</CODE> = 1 and <CODE>expression_2</CODE> /= 2,
then the call to <CODE>Func_2</CODE>
will occur, but not the call to <CODE>Func_1.</CODE>
This means that it is essential
to elaborate the body of <CODE>Unit_1</CODE> before
the body of <CODE>Unit_2</CODE>, so the first
order of elaboration is correct and the second is wrong.

</P>
<P>
By making <CODE>expression_1</CODE> and <CODE>expression_2</CODE>
depend on input data, or perhaps
the time of day, we can make it impossible for the compiler or binder
to figure out which of these expressions will be true, and hence it
is impossible to guarantee a safe order of elaboration at run time.

</P>


<H2><A NAME="SEC86" HREF="gnat_ug_toc.html#TOC86">Checking the Elaboration Order in Ada 95</A></H2>

<P>
In some languages that involve the same kind of elaboration problems,
e.g. Java and C++, the programmer is expected to worry about these
ordering problems himself, and it is common to
write a program in which an incorrect elaboration order  gives
surprising results, because it references variables before they
are initialized.
Ada 95 is designed to be a safe language, and a programmer-beware approach is
clearly not sufficient. Consequently, the language provides three lines
of defense:

</P>
<DL COMPACT>

<DT>Standard rules
<DD>
Some standard rules restrict the possible choice of elaboration
order. In particular, if you <CODE>with</CODE> a unit, then its spec is always
elaborated before the unit doing the <CODE>with</CODE>. Similarly, a parent
spec is always elaborated before the child spec, and finally
a spec is always elaborated before its corresponding body.

<DT>Dynamic elaboration checks
<DD>
<A NAME="IDX266"></A>
Dynamic checks are made at run time, so that if some entity is accessed
before it is elaborated (typically  by means of a subprogram call)
then the exception (<CODE>Program_Error</CODE>) is raised.

<DT>Elaboration control
<DD>
Facilities are provided for the programmer to specify the desired order
of elaboration.
</DL>

<P>
Let's look at these facilities in more detail. First, the rules for
dynamic checking. One possible rule would be simply to say that the
exception is raised if you access a variable which has not yet been
elaborated. The trouble with this approach is that it could require
expensive checks on every variable reference. Instead Ada 95 has two
rules which are a little more restrictive, but easier to check, and
easier to state:

</P>
<DL COMPACT>

<DT>Restrictions on calls
<DD>
A subprogram can only be called at elaboration time if its body
has been elaborated. The rules for elaboration given above guarantee
that the spec of the subprogram has been elaborated before the
call, but not the body. If this rule is violated, then the
exception <CODE>Program_Error</CODE> is raised.

<DT>Restrictions on instantiations
<DD>
A generic unit can only be instantiated if the body of the generic
unit has been elaborated. Again, the rules for elaboration given above
guarantee that the spec of the generic unit has been elaborated
before the instantiation, but not the body. if this rule is
violated, then the exception <CODE>Program_Error</CODE> is raised.
</DL>

<P>
The idea is that if the body has been elaborated, then any variables
it references must have been elaborated; by checking for the body being
elaborated we guarantee that none of its references causes any
trouble. As we noted above, this is a little too restrictive, because a
subprogram that has no non-local references in its body may in fact be safe
to call. However, it really would be unsafe to rely on this, because
it would mean that the caller was aware of details of the implementation
in the body. This goes against the basic tenets of Ada.

</P>
<P>
A plausible implementation can be described as follows.
A Boolean variable is associated with each subprogram
and each generic unit. This variable is initialized to False, and is set to
True at the point body is elaborated. Every call or instantiation checks the
variable, and raises <CODE>Program_Error</CODE> if the variable is False.

</P>


<H2><A NAME="SEC87" HREF="gnat_ug_toc.html#TOC87">Controlling the Elaboration Order in Ada 95</A></H2>

<P>
In the previous section we discussed the rules in Ada 95 which ensure
that <CODE>Program_Error</CODE> is raised if an incorrect elaboration order is
chosen. This prevents erroneous executions, but we need mechanisms to
specify a correct execution and avoid the exception altogether.
To achieve this, Ada 95 provides a number of features for controlling
the order of elaboration. We discuss these features in this section.

</P>
<P>
First, there are several ways of indicating to the compiler that a given
unit has no elaboration problems:

</P>
<DL COMPACT>

<DT>packages that do not require a body
<DD>
In Ada 95, a library package that does not require a body does not permit
a body. This means that if we have a such a package, as in:


<PRE>
   <B>package</B> Definitions <B>is</B>
      <B>generic</B>
         <B>type</B> m <B>is new</B> integer;
      <B>package</B> Subp <B>is</B>
         <B>type</B> a <B>is array</B> (1 .. 10) <B>of</B> m;
         <B>type</B> b <B>is array</B> (1 .. 20) <B>of</B> m;
      <B>end</B> Subp;
   <B>end</B> Definitions;
</PRE>

A package that <CODE>with</CODE>'s <CODE>Definitions</CODE> may safely instantiate
<CODE>Definitions.Subp</CODE> because the compiler can determine that there
definitely is no package body to worry about in this case

<DT>pragma Pure
<DD>
<A NAME="IDX267"></A>
<A NAME="IDX268"></A>
Places sufficient restrictions on a unit to guarantee that
no call to any subprogram in the unit can result in an
elaboration problem. This means that the compiler does not need
to worry about the point of elaboration of such units, and in
particular, does not need to check any calls to any subprograms
in this unit.

<DT>pragma Preelaborate
<DD>
<A NAME="IDX269"></A>
<A NAME="IDX270"></A>
This pragma places slightly less stringent restrictions on a unit than
does pragma Pure,
but these restrictions are still sufficient to ensure that there
are no elaboration problems with any calls to the unit.

<DT>pragma Elaborate_Body
<DD>
<A NAME="IDX271"></A>
<A NAME="IDX272"></A>
This pragma requires that the body of a unit be elaborated immediately
after its spec. Suppose a unit <CODE>A</CODE> has such a pragma,
and unit <CODE>B</CODE> does
a <CODE>with</CODE> of unit <CODE>A</CODE>. Recall that the standard rules require
the spec of unit <CODE>A</CODE>
to be elaborated before the <CODE>with</CODE>'ing unit; given the pragma in
<CODE>A</CODE>, we also know that the body of <CODE>A</CODE>
will be elaborated before <CODE>B</CODE>, so
that calls to <CODE>A</CODE> are safe and do not need a check.
</DL>

<P>
Note that,
unlike pragma <CODE>Pure</CODE> and pragma <CODE>Preelaborate</CODE>,
the use of
<CODE>Elaborate_Body</CODE> does not guarantee that the program is
free of elaboration problems, because it may not be possible
to satisfy the requested elaboration order.
Let's go back to the example with <CODE>Unit_1</CODE> and <CODE>Unit_2</CODE>.
If a programmer
marks <CODE>Unit_1</CODE> as <CODE>Elaborate_Body</CODE>,
and not <CODE>Unit_2,</CODE> then the order of
elaboration will be:

</P>

<PRE>
   Spec of Unit_2
   Spec of Unit_1
   Body of Unit_1
   Body of Unit_2
</PRE>

<P>
Now that means that the call to <CODE>Func_1</CODE> in <CODE>Unit_2</CODE>
need not be checked,
it must be safe. But the call to <CODE>Func_2</CODE> in
<CODE>Unit_1</CODE> may still fail if
<CODE>Expression_1</CODE> is equal to 1,
and the programmer must still take
responsibility for this not being the case.

</P>
<P>
If all units carry a pragma <CODE>Elaborate_Body</CODE>, then all problems are
eliminated, except for calls entirely within a body, which are
in any case fully under programmer control. However, using the pragma
everywhere is not always possible.
In particular, for our <CODE>Unit_1</CODE>/<CODE>Unit_2</CODE> example, if
we marked both of them as having pragma <CODE>Elaborate_Body</CODE>, then
clearly there would be no possible elaboration order.

</P>
<P>
The above pragmas allow a server to guarantee safe use by clients, and
clearly this is the preferable approach. Consequently a good rule in
Ada 95 is to mark units as <CODE>Pure</CODE> or <CODE>Preelaborate</CODE> if possible,
and if this is not possible,
mark them as <CODE>Elaborate_Body</CODE> if possible.
As we have seen, there are situation where neither of these
three pragmas can be used.
So we also provide methods for clients to control the
order of elaboration of the servers on which they depend:

</P>
<DL COMPACT>

<DT>pragma Elaborate (unit)
<DD>
<A NAME="IDX273"></A>
<A NAME="IDX274"></A>
This pragma is placed in the context clause, after a <CODE>with</CODE> statement,
and it requires that the body of the named unit be elaborated before
the unit in which the pragma occurs. The idea is to use this pragma
if the current unit calls at elaboration time, directly or indirectly,
some subprogram in the named unit.

<DT>pragma Elaborate_All (unit)
<DD>
<A NAME="IDX275"></A>
<A NAME="IDX276"></A>
This is a stronger version of the Elaborate pragma. Consider the
following example:


<PRE>
   Unit A <CODE>with</CODE>'s unit B and calls B.Func in elaboration code
   Unit B <CODE>with</CODE>'s unit C, and B.Func calls C.Func
</PRE>

Now if we put a pragma <CODE>Elaborate (B)</CODE>
in unit <CODE>A</CODE>, this ensures that the
body of <CODE>B</CODE> is elaborated before the call, but not the
body of <CODE>C</CODE>, so
the call to <CODE>C.Func</CODE> could still cause <CODE>Program_Error</CODE> to
be raised.

The effect of a pragma <CODE>Elaborate_All</CODE> is stronger, it requires
not only that the body of the named unit be elaborated before the
unit doing the <CODE>with</CODE>, but also the bodies of all units that the
named unit uses, following <CODE>with</CODE> links transitively. For example,
if we put a pragma <CODE>Elaborate_All (B)</CODE> in unit <CODE>A</CODE>,
then it requires
not only that the body of <CODE>B</CODE> be elaborated before <CODE>A</CODE>,
but also the
body of <CODE>C</CODE>, because <CODE>B</CODE> <CODE>with</CODE>'s <CODE>C</CODE>.
</DL>

<P>
We are now in a position to give a usage rule in Ada 95 for avoiding
elaboration problems, at least if dynamic dispatching and access to
subprogram values are not used. We will handle these cases separately
later.

</P>
<P>
The rule is simple. If a unit has elaboration code that can directly or
indirectly make a call to a subprogram in a <CODE>with</CODE>'ed unit, or instantiate
a generic unit in a <CODE>with</CODE>'ed unit,
then if the <CODE>with</CODE>'ed unit does not have
pragma Pure, Preelaborate, or Elaborate_Body, then the client should have
an Elaborate_All for the <CODE>with</CODE>'ed unit. By following this rule a client is
assured that calls can be made without risk of an exception.
If this rule is not followed, then a program may be in one of four
states:

</P>
<DL COMPACT>

<DT>No order exists
<DD>
No order of elaboration exists which follows the rules, taking into
account any Elaborate, Elaborate_All, or Elaborate_Body pragmas. In
this case, an Ada 95 compiler must diagnose the situation at bind
time, and refuse to build an executable program.

<DT>One or more orders exist, all incorrect
<DD>
One or more acceptable elaboration orders exists, and all of them
generate an elaboration order problem. In this case, the binder
can build an executable program, but Program_Error will be raised
when the program is run.

<DT>Several orders exist, some right, some incorrect
<DD>
One or more acceptable elaboration orders exists, and some of them
work, and some do not. The programmer has not controlled
the order of elaboration, so the binder may or may not pick one of
the correct orders, and the program may or may not raise an
exception when it is run. This is the worst case, because it means
that the program may fail when moved to another compiler, or even
another version of the same compiler.

<DT>One or more orders exists, all correct
<DD>
One ore more acceptable elaboration orders exist, and all of them
work. In this case the program runs successfully. This state of
affairs can be guaranteed by following the rule we gave above, but
may be true even if the rule is not followed.
</DL>

<P>
Note that one additional advantage of following our Elaborate_All rule
is that the program continues to stay in the ideal (all orders OK) state
even if maintenance
changes some bodies of some subprograms. Conversely, if a program that does
not follow this rule happens to be safe at some point, this state of affairs
may deteriorate silently as a result of maintenance changes.

</P>


<H2><A NAME="SEC88" HREF="gnat_ug_toc.html#TOC88">Controlling Elaboration in GNAT - Internal Calls</A></H2>

<P>
In the case of internal calls, i.e. calls within a single package, the
programmer has full control over the order of elaboration, and it is up
to the programmer to elaborate declarations in an appropriate order. For
example writing:

</P>

<PRE>
   <B>function</B> One <B>return</B> Float;

   Q : Float := One;

   <B>function</B> One <B>return</B> Float <B>is</B>
   <B>begin</B>
        return 1.0;
   <B>end</B> One;
</PRE>

<P>
will obviously raise Program_Error at run time, because function One will be
called before its body is elaborated.  In this case GNAT will generate
a warning that the call will raise Program_Error:

</P>

<PRE>
    1. procedure y is
    2.    function One return Float;
    3.
    4.    Q : Float := One;
                       |
       &#62;&#62;&#62; warning: cannot call "One" before body is elaborated
       &#62;&#62;&#62; warning: Program_Error will be raised at run time

    5.
    6.    function One return Float is
    7.    begin
    8.         return 1.0;
    9.    end One;
   10.
   11. begin
   12.    null;
   13. end;
</PRE>

<P>
Note that in this particular case, it is likely that the call is safe, because
the function <CODE>One</CODE> does not access any global variables.
Nevertheless in Ada 95, we do not want the validity of the check to depend on
the contents of the body (think about the separate compilation case), so this
is still wrong, as we discussed in the previous sections.

</P>
<P>
The error is easily corrected by rearranging the declarations so that the
body of One appears before the declaration containing the call
(note that in Ada 95,
declarations can appear in any order, so there is no restriction that
would prevent this reordering, and if we write:

</P>

<PRE>
   <B>function</B> One <B>return</B> Float;

   <B>function</B> One <B>return</B> Float <B>is</B>
   <B>begin</B>
        return 1.0;
   <B>end</B> One;

   Q : Float := One;
</PRE>

<P>
then all is well, no warning is generated, and no
<CODE>Program_Error</CODE> exception
will be raised.
Things are more complicated when a chain of subprograms is executed:

</P>

<PRE>
   <B>function</B> A <B>return</B> Integer;
   <B>function</B> B <B>return</B> Integer;
   <B>function</B> C <B>return</B> Integer;

   <B>function</B> B <B>return</B> Integer <B>is begin return</B> A; <B>end</B>;
   <B>function</B> C <B>return</B> Integer <B>is begin return</B> B; <B>end</B>;

   X : Integer := C;

   <B>function</B> A <B>return</B> Integer <B>is begin return</B> 1; <B>end</B>;
</PRE>

<P>
Now the call to <CODE>C</CODE>
at elaboration time in the declaration of <CODE>X</CODE> is correct, because
the body of <CODE>C</CODE> is already elaborated,
and the call to <CODE>B</CODE> within the body of
<CODE>C</CODE> is correct, but the call
to <CODE>A</CODE> within the body of <CODE>B</CODE> is incorrect, because the body
of <CODE>A</CODE> has not been elaborated, so <CODE>Program_Error</CODE>
will be raised on the call to <CODE>A</CODE>.
In this case GNAT will generate a
warning that <CODE>Program_Error</CODE> may be
raised at the point of the call. Let's look at the warning:

</P>

<PRE>
    1. procedure x is
    2.    function A return Integer;
    3.    function B return Integer;
    4.    function C return Integer;
    5.
    6.    function B return Integer is begin return A; end;
                                                    |
       &#62;&#62;&#62; warning: call to "A" before body is elaborated may
                    raise Program_Error
       &#62;&#62;&#62; warning: "B" called at line 7
       &#62;&#62;&#62; warning: "C" called at line 9

    7.    function C return Integer is begin return B; end;
    8.
    9.    X : Integer := C;
   10.
   11.    function A return Integer is begin return 1; end;
   12.
   13. begin
   14.    null;
   15. end;
</PRE>

<P>
Note that the message here says "may raise", instead of the direct case,
where the message says "will be raised". That's because whether
<CODE>A</CODE> is
actually called depends in general on run-time flow of control.
For example, if the body of <CODE>B</CODE> said

</P>

<PRE>
   <B>function</B> B <B>return</B> Integer <B>is</B>
   <B>begin</B>
      <B>if</B> some-condition-depending-on-input-data <B>then</B>
         <B>return</B> A;
      <B>else</B>
         <B>return</B> 1;
      <B>end if</B>;
   <B>end</B> B;
</PRE>

<P>
then we could not know until run time whether the incorrect call to A would
actually occur, so <CODE>Program_Error</CODE> might
or might not be raised. It is possible for a compiler to
do a better job of analyzing bodies, to
determine whether or not <CODE>Program_Error</CODE>
might be raised, but it certainly
couldn't do a perfect job (that would require solving the halting problem
and is provably impossible), and because this is a warning anyway, it does
not seem worth the effort to do the analysis. Cases in which it
would be relevant are rare.

</P>
<P>
In practice, warnings of either of the forms given
above will usually correspond to
real errors, and should be examined carefully and eliminated.
In the rare case where a warning is bogus, it can be suppressed by any of
the following methods:

</P>

<UL>
<LI>

Compile with the <CODE>-gnatws</CODE> switch set

<LI>

Suppress <CODE>Elaboration_Checks</CODE> for the called subprogram

<LI>

Use pragma <CODE>Warnings_Off</CODE> to turn warnings off for the call
</UL>

<P>
For the internal elaboration check case,
GNAT by default generates the
necessary run-time checks to ensure
that <CODE>Program_Error</CODE> is raised if any
call fails an elaboration check. Of course this can only happen if a
warning has been issued as described above. The use of pragma
<CODE>Suppress (Elaboration_Checks)</CODE> may (but is not guaranteed) to suppress
some of these checks, meaning that it may be possible (but is not
guaranteed) for a program to be able to call a subprogram whose body
is not yet elaborated, without raising a <CODE>Program_Error</CODE> exception.

</P>


<H2><A NAME="SEC89" HREF="gnat_ug_toc.html#TOC89">Controlling Elaboration in GNAT - External Calls</A></H2>

<P>
The previous section discussed the case in which the execution of a
particular thread of elaboration code occurred entirely within a
single unit. This is the easy case to handle, because a programmer
has direct and total control over the order of elaboration, and
furthermore, checks need only be generated in cases which are rare
and which the compiler can easily detect.
The situation is more complex when separate compilation is taken into account.
Consider the following:

</P>

<PRE>
   <B>package</B> Math <B>is</B>
      <B>function</B> Sqrt (Arg : Float) <B>return</B> Float;
   <B>end</B> Math;

   <B>package body</B> Math <B>is</B>
      <B>function</B> Sqrt (Arg : Float) <B>return</B> Float <B>is</B>
      <B>begin</B>
         ...
      <B>end</B> Sqrt;
   <B>end</B> Math;
   <B>with</B> Math;
   <B>package</B> Stuff <B>is</B>
      X : Float := Math.Sqrt (0.5);
   <B>end</B> Stuff;

   <B>with</B> Stuff;
   <B>procedure</B> Main <B>is</B>
   <B>begin</B>
      ...
   <B>end</B> Main;
</PRE>

<P>
where <CODE>Main</CODE> is the main program. When this program is executed, the
elaboration code must first be executed, and one of the jobs of the
binder is to determine the order in which the units of a program are
to be elaborated. In this case we have four units: the spec and body
of <CODE>Math</CODE>,
the spec of <CODE>Stuff</CODE> and the body of <CODE>Main</CODE>).
In what order should the four separate sections of elaboration code
be executed?

</P>
<P>
There are some restrictions in the order of elaboration that the binder
can choose. In particular, if unit U has a <CODE>with</CODE>
for a package <CODE>X</CODE>, then you
are assured that the spec of <CODE>X</CODE>
is elaborated before U , but you are
not assured that the body of <CODE>X</CODE>
is elaborated before U.
This means that in the above case, the binder is allowed to choose the
order:

</P>

<PRE>
   spec of Math
   spec of Stuff
   body of Math
   body of Main
</PRE>

<P>
but that's not good, because now the call to <CODE>Math.Sqrt</CODE>
that happens during
the elaboration of the <CODE>Stuff</CODE>
spec happens before the body of <CODE>Math.Sqrt</CODE> is
elaborated, and hence causes <CODE>Program_Error</CODE> exception to be raised.
At first glance, one might say that the binder is misbehaving, because
obviously you want to elaborate the body of something you <CODE>with</CODE>
first, but
that is not a general rule that can be followed in all cases. Consider

</P>

<PRE>
   <B>package</B> X <B>is</B> ...

   <B>package</B> Y <B>is</B> ...

   <B>with</B> X;
   <B>package body</B> Y <B>is</B> ...

   <B>with</B> Y;
   <B>package body</B> X <B>is</B> ...
</PRE>

<P>
This is a common arrangement, and, apart from the order of elaboration
problems that might arise in connection with elaboration code, this works fine.
A rule that says that you must first elaborate the body of anything you
<CODE>with</CODE> cannot work in this case
(the body of <CODE>X</CODE> <CODE>with</CODE>'s <CODE>Y</CODE>,
which means you would have to
elaborate the body of <CODE>Y</CODE> first, but that <CODE>with</CODE>'s <CODE>X</CODE>,
which means
you have to elaborate the body of <CODE>X</CODE> first, but ... and we have a
loop that cannot be broken.

</P>
<P>
It is true that the binder can in many cases guess an order of elaboration
that is unlikely to cause a <CODE>Program_Error</CODE>
exception to be raised, and it tries to do so (in the
above example of <CODE>Math/Stuff/Spec</CODE>, the GNAT binder will
in fact always
elaborate the body of <CODE>Math</CODE> right after its spec, so all will be well).

</P>
<P>
However, a program that blindly relies on the binder to be helpful can
get into trouble, as we discussed in the previous sections, so
GNAT
provides a number of facilities for assisting the programmer in
developing programs that are robust with respect to elaboration order.

</P>


<H2><A NAME="SEC90" HREF="gnat_ug_toc.html#TOC90">Default Behavior in GNAT - Ensuring Safety</A></H2>

<P>
The default behavior in GNAT ensures elaboration safety. In its
default mode GNAT implements the
rule we previously described as the right approach. Let's restate it:

</P>
<P>
If a unit has elaboration code that can directly or indirectly make a
call to a subprogram in a <CODE>with</CODE>'ed unit, or instantiate a generic unit
in a <CODE>with</CODE>'ed unit, then if the <CODE>with</CODE>'ed unit
does not have pragma <CODE>Pure</CODE>,
<CODE>Preelaborate</CODE>, or <CODE>Elaborate_Body</CODE>,
then the client should have an
<CODE>Elaborate_All</CODE> for the <CODE>with</CODE>'ed unit. By following this rule a client
is assured that calls and instantiations can be made without risk of an exception.

</P>
<P>
In this mode GNAT traces all calls that are potentially made from
elaboration code, and put in any missing implicit <CODE>Elaborate_All</CODE>
pragmas.
The advantage of this approach is that no elaboration problems
are possible if the binder can find an elaboration order that is
consistent with these implicit <CODE>Elaborate_All</CODE> pragmas. The
disadvantage of this approach is that no such order may exist.

</P>
<P>
If the binder does not generate any diagnostics, then it means that it
has found an elaboration order that is guaranteed to be safe. However,
the binder may still be relying on implicitly generated
<CODE>Elaborate_All</CODE> pragmas so portability to other compilers than
GNAT is not guaranteed.

</P>
<P>
If it is important to guarantee portability, then the compilations should
use the
<CODE>-gnatwl</CODE>
(warn on elaboration problems) switch. This will cause warning messages
to be generated indicating the missing <CODE>Elaborate_All</CODE> pragmas.
Consider the following source program:

</P>

<PRE>
   <B>with</B> k;
   <B>package</B> j <B>is</B>
     m : integer := k.r;
   <B>end</B>;
</PRE>

<P>
where it is clear that there
should be a pragma <CODE>Elaborate_All</CODE>
for unit <CODE>k</CODE>. An implicit pragma will be generated, and it is
likely that the binder will be able to honor it. However,
it is safer to include the pragma explicitly in the source. If this
unit is compiled with the
<CODE>-gnatwl</CODE>
switch, then the compiler outputs a warning:

</P>

<PRE>
   1. with k;
   2. package j is
   3.   m : integer := k.r;
                        |
      &#62;&#62;&#62; warning: call to "r" may raise Program_Error
      &#62;&#62;&#62; warning: missing pragma Elaborate_All for "k"

   4. end;
</PRE>

<P>
and these warnings can be used as a guide for supplying manually
the missing pragmas.

</P>


<H2><A NAME="SEC91" HREF="gnat_ug_toc.html#TOC91">What to do if the Default Elaboration Behavior Fails</A></H2>

<P>
If the binder cannot find an acceptable order, it outputs detailed
diagnostics. For example:

</P>

<PRE>
   error: elaboration circularity detected
   info:   "proc (body)" must be elaborated before "pack (body)"
   info:     reason: Elaborate_All probably needed in unit "pack (body)"
   info:     recompile "pack (body)" with -gnatwl
   info:                             for full details
   info:       "proc (body)"
   info:         is needed by its spec:
   info:       "proc (spec)"
   info:         which is withed by:
   info:       "pack (body)"
   info:  "pack (body)" must be elaborated before "proc (body)"
   info:     reason: pragma Elaborate in unit "proc (body)"
</PRE>

<P>
In this case we have a cycle that the binder cannot break. On the one
hand, there is an explicit pragma Elaborate in <CODE>proc</CODE> for
<CODE>pack</CODE>. This means that the body of <CODE>pack</CODE> must be elaborated
before the body of <CODE>proc</CODE>. On the other hand, there is elaboration
code in <CODE>pack</CODE> that calls a subprogram in <CODE>proc</CODE>. This means
that for maximum safety, there should really be a pragma
Elaborate_All in <CODE>pack</CODE> for <CODE>proc</CODE> which would require that
the body of <CODE>proc</CODE> be elaborated before the body of
<CODE>pack</CODE>. Clearly both requirements cannot be satisfied.
Faced with a circularity of this kind, you have three different options.

</P>
<DL COMPACT>

<DT>Fix the program
<DD>
The most desirable option from the point of view of long-term maintenance
is to rearrange the program so that the elaboration problems are avoided.
One useful technique is to place the elaboration code into separate
child packages. Another is to move some of the initialization code to
explicitly called subprograms, where the program controls the order
of initialization explicitly. Although this is the most desirable option,
it may be impractical and involve too much modification, especially in
the case of complex legacy code.

<DT>Perform dynamic checks
<DD>
If the compilations are done using the
<CODE>-gnatE</CODE>
(dynamic elaboration check) switch, then GNAT behaves in
a quite different manner. Dynamic checks are generated for all calls
that could possibly result in raising an exception. With this switch,
the compiler does not generate implicit <CODE>Elaborate_All</CODE> pragmas.
The behavior then is exactly as specified in the Ada 95 Reference Manual.
The binder will generate an executable program that may or may not
raise Program_Error, and then it is the programmer's job to ensure
that it does not raise an exception. Note that it is important to
compile all units with the switch, it cannot be used selectively.

<DT>Suppress checks
<DD>
The drawback of dynamic checks is that they generate a
significant overhead at run time, both in space and time. If you
are absolutely sure that your program cannot raise any elaboration
exceptions, then you can use the
<CODE>-f</CODE>
switch for the
<CODE>gnatbind</CODE>
step, or
<CODE>-bargs -f</CODE>
if you are using
<CODE>gnatmake</CODE>.
This switch tells the binder to ignore any implicit <CODE>Elaborate_All</CODE>
pragmas that were generated by the compiler, and suppresses any
circularity messages that they cause. The resulting executable will work
properly if there are no elaboration problems, but if there are some order of
elaboration problems they will not be detected, and unexpected
results may occur.
</DL>

<P>
It is hard to generalize on which of these three approaches should be
taken. Obviously if it is possible to fix the program so that the default
treatment works, this is preferable, but this may not always be practical.
It is certainly simple enough to use
<CODE>-gnatE</CODE>
or
<CODE>-f</CODE>
but the danger in either case is that, even if the GNAT binder
finds a correct elaboration order, it may not always do so,
and certainly a binder from another Ada compiler might not. A
combination of testing and analysis (for which the warnings generated
with the
<CODE>-gnatwl</CODE>
switch can be useful) must be used to ensure that the program is free
of errors. One switch that is useful in this testing is the
<CODE>-h (horrible elaboration order)</CODE>
switch for
<CODE>gnatbind</CODE>.
Normally the binder tries to find an order that has the best chance of
of avoiding elaboration problems. With this switch, the binder
plays a devil's advocate role, and tries to choose the order that
has the best chance of failing. If your program works even with this
switch, then it has a better chance of being error free, but this is still
not a guarantee.

</P>
<P>
For an example of this approach in action, consider the C-tests (executable
tests) from the ACVC suite. If these are compiled and run with the default
treatment, then all but one of them succeed without generating any error
diagnostics from the binder. However, there is one test that fails, and
this is not surprising, because the whole point of this test is to ensure
that the compiler can handle cases where it is impossible to determine
a correct order statically, and it checks that an exception is indeed
raised at run time.

</P>
<P>
This one test must be compiled and run using the
<CODE>-gnatE</CODE>
switch, and then it passes. Alternatively, the entire suite can
be run using this switch. It is never wrong to run with the dynamic
elaboration switch if your code is correct, and we assume that the
C-tests are indeed correct (it is less efficient, but efficiency is
not a factor in running the ACVC tests.)

</P>


<H2><A NAME="SEC92" HREF="gnat_ug_toc.html#TOC92">Elaboration for Access-to-Subprogram Values</A></H2>
<P>
<A NAME="IDX277"></A>

</P>
<P>
The introduction of access-to-subprogram types in Ada 95 complicates
the handling of elaboration. The trouble is that it becomes
impossible to tell at compile time which procedure
is being called. This means that it is not possible for the binder
to analyze the elaboration requirements in this case.

</P>
<P>
If at the point at which  the access value is created, the body of the subprogram is
known to have been elaborated, then the access value is safe, and its use
does not require a check. This may be achieved by appropriate arrangement
of the order of declarations if the subprogram is in the current unit,
or, if the subprogram is in another unit, by using pragma
<CODE>Pure</CODE>, <CODE>Preelaborate</CODE>, or <CODE>Elaborate_Body</CODE>
on the referenced unit.

</P>
<P>
If the referenced body is not known to have been elaborated at the point
the access value is created, then any use of the access value must do a
dynamic check, and this dynamic check will fail and raise a
<CODE>Program_Error</CODE> exception if the body has not been elaborated yet.
GNAT will generate the necessary checks, and in addition, if the
<CODE>-gnatwl</CODE>
switch is set, will generate warnings that such checks are required.

</P>
<P>
The use of dynamic dispatching for tagged types similarly generates
a requirement for dynamic checks, and premature calls to any primitive
operation of a tagged type before the body of the operation has been elaborated,
will result in the raising of <CODE>Program_Error</CODE>.

</P>


<H2><A NAME="SEC93" HREF="gnat_ug_toc.html#TOC93">Summary of Procedures for Elaboration Control</A></H2>
<P>
<A NAME="IDX278"></A>

</P>
<P>
First, compile your program with the default options, using none of
the special elaboration control switches. If the binder successfully
binds your program, then you can be confident that, apart from issues
raised by the use of access-to-subprogram types and dynamic dispatching,
the program is free of elaboration errors. If it is important that the
program be portable, then use the
<CODE>-gnatwl</CODE>
switch to generate warnings about missing <CODE>Elaborate_All</CODE>
pragmas, and supply the missing pragmas.

</P>
<P>
If the program fails to bind using the default static elaboration
handling, then you can fix the program to eliminate the binder
message, or recompile the entire program with the
<CODE>-gnatE</CODE> switch to generate dynamic elaboration checks,
or, if you are sure there really are no elaboration problems,
use the
<CODE>-f</CODE>
switch for the binder to cause it to ignore implicit <CODE>Elaborate_All</CODE>
pragmas generated by the compiler.

</P>



<H1><A NAME="SEC94" HREF="gnat_ug_toc.html#TOC94">The cross-referencing tools <CODE>gnatxref</CODE> and <CODE>gnatfind</CODE></A></H1>
<P>
<A NAME="IDX279"></A>
<A NAME="IDX280"></A>

</P>
<P>
The compiler generates cross-referencing information (unless
you set the <SAMP>`-gnatx'</SAMP> switch), which are saved in the <TT>`.ali'</TT> files.
This information indicates where in the source each entity is declared and
referenced.

</P>
<P>
Before using any of these two tools, you need to compile successfully your
application, so that GNAT gets a chance to generate the cross-referencing
information.

</P>
<P>
The two tools <CODE>gnatxref</CODE> and <CODE>gnatfind</CODE> take advantage of this
information to provide the user with the capability to easily locate the
declaration and references to an entity. These tools are quite similar,
the difference being that <CODE>gnatfind</CODE> is intended for locating
definitions and/or references to a specified entity or entities, whereas
<CODE>gnatxref</CODE> is oriented to generating a full report of all
cross-references.

</P>
<P>
To use these tools, you must not compile your application using the
<SAMP>`-gnatx'</SAMP> switch on the <TT>`gnatmake'</TT> command line (See Info file `gnat_ug', node `The GNAT Make Program gnatmake'). Otherwise, cross-referencing
information will not be generated.

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC95">Gnatxref switches</A>
<LI><A HREF="gnat_ug.html#SEC96">Gnatfind switches</A>
<LI><A HREF="gnat_ug.html#SEC97">Project files</A>
<LI><A HREF="gnat_ug.html#SEC98">Regular expressions in gnatfind and gnatxref</A>
<LI><A HREF="gnat_ug.html#SEC99">Examples of gnatxref usage</A>
<LI><A HREF="gnat_ug.html#SEC102">Examples of gnatfind usage</A>
</UL>



<H2><A NAME="SEC95" HREF="gnat_ug_toc.html#TOC95">Gnatxref switches</A></H2>

<P>
The command lines for <CODE>gnatxref</CODE> is:

<PRE>
   $ gnatxref [switches] sourcefile1 [sourcefile2 ...]
</PRE>

<P>
where

</P>
<DL COMPACT>

<DT><CODE>sourcefile1, sourcefile2</CODE>
<DD>
identifies the source files for which a report is to be generated. The
'with'ed units will be processed too. You must provide at least one file.

These file names are considered to be regular expressions, so for instance
specifying 'source*.adb' is the same as giving every file in the current
directory whose name starts with 'source' and whose extension is 'adb'.

</DL>

<P>
The switches can be :
<DL COMPACT>

<DT><CODE>-a</CODE>
<DD>
If this switch is present, <CODE>gnatfind</CODE> and <CODE>gnatxref</CODE> will parse
the read-only files found in the library search path. Otherwise, these files
will be ignored. This option can be used to protect Gnat sources or your own
libraries from being parsed, thus making <CODE>gnatfind</CODE> and <CODE>gnatxref</CODE>
much faster, and their output much smaller.

<DT><CODE>-aIDIR</CODE>
<DD>
When looking for source files also look in directory DIR. The order in which
source file search is undertaken is the same as for <TT>`gnatmake'</TT>.

<DT><CODE>-aODIR</CODE>
<DD>
When searching for library and object files, look in directory
DIR. The order in which library files are searched is the same as for
<TT>`gnatmake'</TT>.

<DT><CODE>-f</CODE>
<DD>
If this switch is set, the output file names will be preceded by their
directory (if the file was found in the search path). If this switch is
not set, the directory will not be printed.

<DT><CODE>-g</CODE>
<DD>
If this switch is set, information is output only for library-level
entities, ignoring local entities. The use of this switch may accelerate
<CODE>gnatfind</CODE> and <CODE>gnatxref</CODE>.

<DT><CODE>-IDIR</CODE>
<DD>
Equivalent to <SAMP>`-aODIR -aIDIR'</SAMP>.

<DT><CODE>-pFILE</CODE>
<DD>
Specify a project file to use See section <A HREF="gnat_ug.html#SEC97">Project files</A>.
By default, <CODE>gnatxref</CODE> and <CODE>gnatfind</CODE> will try to locate a
project file in the current directory.

If a project file is either specified or found by the tools, then the content
of the source directory and object directory lines are added as if they
had been specified respectively by <SAMP>`-aI'</SAMP>
and <SAMP>`-aO'</SAMP>.
<DT><CODE>-u</CODE>
<DD>
Output only unused symbols. This may be really useful if you give your
main compilation unit on the command line, as <CODE>gnatxref</CODE> will then
display every unused entity and 'with'ed package.

<DT><CODE>-v</CODE>
<DD>
Instead of producing the default output, <CODE>gnatxref</CODE> will generate a
<TT>`tags'</TT> file that can be used by vi. For examples how to use this
feature, see See section <A HREF="gnat_ug.html#SEC99">Examples of <CODE>gnatxref</CODE> usage</A>. The tags file is output
to the standard output, thus you will have to redirect it to a file.

</DL>

<P>
All these switches may be in any order on the command line, and may even
appear after the file names. They need not be separated by spaces, thus
you can say <SAMP>`gnatxref -ag'</SAMP> instead of
<SAMP>`gnatxref -a -g'</SAMP>.

</P>



<H2><A NAME="SEC96" HREF="gnat_ug_toc.html#TOC96">Gnatfind switches</A></H2>

<P>
The command line for <CODE>gnatfind</CODE> is:

</P>

<PRE>
   $ gnatfind [switches] pattern[:sourcefile[:line[:column]]] [file1 file2 ...]
</PRE>

<P>
where

</P>
<DL COMPACT>

<DT><CODE>pattern</CODE>
<DD>
An entity will be output only if it matches the regular expression found
in <SAMP>`pattern'</SAMP>, see See section <A HREF="gnat_ug.html#SEC98">Regular expressions in gnatfind and gnatxref</A>.

Omitting the pattern is equivalent to specifying <SAMP>`*'</SAMP>, which
will match any entity. Note that if you do not provide a pattern, you
have to provide both a sourcefile and a line.

Entity names are given in Latin-1, with upper-lower case equivalence
for matching purposes. At the current time there is no support for
8-bit codes other than Latin-1, or for wide characters in identifiers.

<DT><CODE>sourcefile</CODE>
<DD>
<CODE>gnatfind</CODE> will look for references, bodies or declarations
of symbols referenced in <TT>`sourcefile'</TT>, at line <SAMP>`line'</SAMP>
and column <SAMP>`column'</SAMP>. See see section <A HREF="gnat_ug.html#SEC102">Examples of <CODE>gnatfind</CODE> usage</A>
for syntax examples.

<DT><CODE>line</CODE>
<DD>
is a decimal integer identifying the line number containing
the reference to the entity (or entities) to be located.

<DT><CODE>column</CODE>
<DD>
is a decimal integer identifying the exact location on the
line of the first character of the identifier for the
entity reference. Columns are numbered from 1.

<DT><CODE>file1 file2 ...</CODE>
<DD>
The search will be restricted to these files. If none are given, then
the search will be done for every library file in the search path.
These file must appear only after the pattern or sourcefile.

These file names are considered to be regular expressions, so for instance
specifying 'source*.adb' is the same as giving every file in the current
directory whose name starts with 'source' and whose extension is 'adb'.

Not that if you specify at least one file in this part, <CODE>gnatfind</CODE> may
sometimes not be able to find the body of the subprograms...

</DL>

<P>
At least one of 'sourcefile' or 'pattern' has to be present on
the command line.

</P>
<P>
The following switches are available:
<DL COMPACT>

<DT><CODE>-a</CODE>
<DD>
If this switch is present, <CODE>gnatfind</CODE> and <CODE>gnatxref</CODE> will parse
the read-only files found in the library search path. Otherwise, these files
will be ignored. This option can be used to protect Gnat sources or your own
libraries from being parsed, thus making <CODE>gnatfind</CODE> and <CODE>gnatxref</CODE>
much faster, and their output much smaller.

<DT><CODE>-aIDIR</CODE>
<DD>
When looking for source files also look in directory DIR. The order in which
source file search is undertaken is the same as for <TT>`gnatmake'</TT>.

<DT><CODE>-aODIR</CODE>
<DD>
When searching for library and object files, look in directory
DIR. The order in which library files are searched is the same as for
<TT>`gnatmake'</TT>.

<DT><CODE>-e</CODE>
<DD>
By default, <CODE>gnatfind</CODE> accept the simple regular expression set for
<SAMP>`pattern'</SAMP>. If this switch is set, then the pattern will be
considered as full Unix-style regular expression.

<DT><CODE>-f</CODE>
<DD>
If this switch is set, the output file names will be preceded by their
directory (if the file was found in the search path). If this switch is
not set, the directory will not be printed.

<DT><CODE>-g</CODE>
<DD>
If this switch is set, information is output only for library-level
entities, ignoring local entities. The use of this switch may accelerate
<CODE>gnatfind</CODE> and <CODE>gnatxref</CODE>.

<DT><CODE>-IDIR</CODE>
<DD>
Equivalent to <SAMP>`-aODIR -aIDIR'</SAMP>.

<DT><CODE>-pFILE</CODE>
<DD>
Specify a project file (see section <A HREF="gnat_ug.html#SEC97">Project files</A>) to use.
By default, <CODE>gnatxref</CODE> and <CODE>gnatfind</CODE> will try to locate a
project file in the current directory.

If a project file is either specified or found by the tools, then the content
of the source directory and object directory lines are added as if they
had been specified respectively by <SAMP>`-aI'</SAMP> and
<SAMP>`-aO'</SAMP>.

<DT><CODE>-r</CODE>
<DD>
By default, <CODE>gnatfind</CODE> will output only the information about the
declaration, body or type completion of the entities. If this switch is
set, the <CODE>gnatfind</CODE> will locate every reference to the entities in
the files specified on the command line (or in every file in the search
path if no file is given on the command line).

<DT><CODE>-s</CODE>
<DD>
If this switch is set, then <CODE>gnatfind</CODE> will output the content
of the Ada source file lines were the entity was found.

</DL>

<P>
All these switches may be in any order on the command line, and may even
appear after the file names. They need not be separated by spaces, thus
you can say <SAMP>`gnatxref -ag'</SAMP> instead of
<SAMP>`gnatxref -a -g'</SAMP>.

</P>
<P>
As stated previously, gnatfind will search in every directory in the
search path. You can force it to look only in the current directory if
you specify <CODE>*</CODE> at the end of the command line.

</P>


<H2><A NAME="SEC97" HREF="gnat_ug_toc.html#TOC97">Project files</A></H2>

<P>
The project files allows a programmer to specify how to compile its
application, where to find sources,... These files are used primarily by
the Emacs Ada mode, but they can also be used by the two tools
<CODE>gnatxref</CODE> and <CODE>gnatfind</CODE>.

</P>
<P>
A project file name must end with <TT>`.adp'</TT>. If a single one is
present in the current directory, then <CODE>gnatxref</CODE> and <CODE>gnatfind</CODE> will
extract the information from it. If multiple project files are found, none of
them is read, and you have to use the <SAMP>`-p'</SAMP> switch to specify the one
you want to use.

</P>
<P>
The following lines can be included, even though most of them have default
values which can be used in most cases.
The lines can be entered in any order in the file.
Except for <SAMP>`src_dir'</SAMP> and <SAMP>`obj_dir'</SAMP>, you can only have one instance of
each line. If you have multiple instances, only the last one is taken into
account.

</P>
<DL COMPACT>

<DT><SAMP>`src_dir=DIR         [default: "./"]'</SAMP>
<DD>
specifies a directory where to look for source files. Multiple src_dir lines
can be specified and they will be searched in the order they
are specified.

<DT><SAMP>`obj_dir=DIR         [default: "./"]'</SAMP>
<DD>
specifies a directory where to look for object and library files. Multiple
obj_dir lines can be specified and they will be searched in the order they
are specified

<DT><SAMP>`comp_opt=SWITCHES   [default: ""]'</SAMP>
<DD>
creates a variable which can be referred to subsequently by using
the <SAMP>`${comp_opt}'</SAMP> notation. This is intended to store the default
switches given to <TT>`gnatmake'</TT> and <TT>`gcc'</TT>.

<DT><SAMP>`bind_opt=SWITCHES   [default: ""]'</SAMP>
<DD>
creates a variable which can be referred to subsequently by using
the <SAMP>`${bind_opt}'</SAMP> notation. This is intended to store the default
switches given to <TT>`gnatbind'</TT>.

<DT><SAMP>`link_opt=SWITCHES   [default: ""]'</SAMP>
<DD>
creates a variable which can be referred to subsequently by using
the <SAMP>`${link_opt}'</SAMP> notation. This is intended to store the default
switches given to <TT>`gnatlink'</TT>.

<DT><SAMP>`main=EXECUTABLE     [default: ""]'</SAMP>
<DD>
specifies the name of the executable for the application. This variable can
be referred to in the following lines by using the <SAMP>`${main}'</SAMP> notation.

<DT><SAMP>`comp_cmd=COMMAND    [default: "gcc -c -I${src_dir} -g -gnatq"]'</SAMP>
<DD>
specifies the command used to compile a single file in the application.

<DT><SAMP>`make_cmd=COMMAND    [default: "gnatmake ${main} -aI${src_dir} -aO${obj_dir} -g -gnatq -cargs ${comp_opt} -bargs ${bind_opt} -largs ${link_opt}"]'</SAMP>
<DD>
specifies the command used to recompile the whole application.

<DT><SAMP>`run_cmd=COMMAND     [default: "${main}"]'</SAMP>
<DD>
specifies the command used to run the application.

<DT><SAMP>`debug_cmd=COMMAND   [default: "gdb ${main}"]'</SAMP>
<DD>
specifies the command used to debug the application

</DL>

<P>
<CODE>gnatxref</CODE> and <CODE>gnatfind</CODE> only take into account the <SAMP>`src_dir'</SAMP>
and <SAMP>`obj_dir'</SAMP> lines, and ignore the others.

</P>


<H2><A NAME="SEC98" HREF="gnat_ug_toc.html#TOC98">Regular expressions in gnatfind and gnatxref</A></H2>

<P>
As specified in the section about <CODE>gnatfind</CODE>, the pattern can be a
regular expression. Actually, there are to set of regular expressions
which are recognized by the program :

</P>
<DL COMPACT>

<DT><SAMP>`globbing patterns'</SAMP>
<DD>
These are the most usual regular expression. They are the same that you
generally used in a Unix shell command line, or in a DOS session.

Here is a more formal grammar :

<PRE>
   regexp ::= term
   term   ::= elmt            -- matches elmt
   term   ::= elmt elmt       -- concatenation (elmt then elmt)
   term   ::= *               -- any string of 0 or more characters
   term   ::= ?               -- matches any character
   term   ::= [char {char}] -- matches any character listed
   term   ::= [char - char]   -- matches any character in range
</PRE>

<DT><SAMP>`full regular expression'</SAMP>
<DD>
The second set of regular expressions is much more powerful. This is the
type of regular expressions recognized by utilities such a <TT>`grep'</TT>.

The following is the form of a regular expression, expressed in Ada
reference manual style BNF is as follows


<PRE>
   regexp ::= term {| term} -- alternation (term or term ...)

   term ::= item {item}     -- concatenation (item then item)

   item ::= elmt              -- match elmt
   item ::= elmt *            -- zero or more elmt's
   item ::= elmt +            -- one or more elmt's
   item ::= elmt ?            -- matches elmt or nothing
   elmt ::= nschar            -- matches given character
   elmt ::= [nschar {nschar}]   -- matches any character listed
   elmt ::= [^ nschar {nschar}] -- matches any character not listed
   elmt ::= [char - char]     -- matches chars in given range
   elmt ::= \ char            -- matches given character
   elmt ::= .                 -- matches any single character
   elmt ::= ( regexp )        -- parens used for grouping

   char ::= any character, including special characters
   nschar ::= any character except ()[].*+?^
</PRE>

Following are a few examples :

<DL COMPACT>

<DT><SAMP>`abcde|fghi'</SAMP>
<DD>
will match any of the two strings 'abcde' and 'fghi'.

<DT><SAMP>`abc*d'</SAMP>
<DD>
will match any string like 'abd', 'abcd', 'abccd', 'abcccd', and so on

<DT><SAMP>`[a-z]+'</SAMP>
<DD>
will match any string which has only lower-case characters in it (and at
least one character

</DL>
</DL>



<H2><A NAME="SEC99" HREF="gnat_ug_toc.html#TOC99">Examples of <CODE>gnatxref</CODE> usage</A></H2>



<H3><A NAME="SEC100" HREF="gnat_ug_toc.html#TOC100">General usage</A></H3>

<P>
For the following examples, we will consider the following units :

</P>

<PRE>
   main.ads:
   1: <B>with</B> Bar;
   2: <B>package</B> Main <B>is</B>
   3:     <B>procedure</B> Foo (B : <B>in</B> Integer);
   4:     C : Integer;
   5: <B>private</B>
   6:     D : Integer;
   7: <B>end</B> Main;

   main.adb:
   1: <B>package body</B> Main <B>is</B>
   2:     <B>procedure</B> Foo (B : <B>in</B> Integer) <B>is</B>
   3:     <B>begin</B>
   4:        C := B;
   5:        D := B;
   6:        Bar.Print (B);
   7:        Bar.Print (C);
   8:     <B>end</B> Foo;
   9: <B>end</B> Main;

   bar.ads:
   1: <B>package</B> Bar <B>is</B>
   2:     <B>procedure</B> Print (B : Integer);
   3: <B>end</B> bar;
</PRE>

<DL COMPACT>

The first thing to do is to recompile your application (for instance, in
that case just by doing a <SAMP>`gnatmake main'</SAMP>, so that GNAT generates
the cross-referencing information.
You can then issue any of the following commands:

<DT><CODE>gnatxref main.adb</CODE>
<DD>
<CODE>gnatxref</CODE> generates cross-reference information for main.adb
and every unit 'with'ed by main.adb.

The output would be:

<PRE>
B                                                      Type: Integer
  Decl: bar.ads           2:22
B                                                      Type: Integer
  Decl: main.ads          3:20
  Body: main.adb          2:20
  Ref:  main.adb          4:13     5:13     6:19
Bar                                                    Type: Unit
  Decl: bar.ads           1:9
  Ref:  main.adb          6:8      7:8
       main.ads           1:6
C                                                      Type: Integer
  Decl: main.ads          4:5
  Modi: main.adb          4:8
  Ref:  main.adb          7:19
D                                                      Type: Integer
  Decl: main.ads          6:5
  Modi: main.adb          5:8
Foo                                                    Type: Unit
  Decl: main.ads          3:15
  Body: main.adb          2:15
Main                                                    Type: Unit
  Decl: main.ads          2:9
  Body: main.adb          1:14
Print                                                   Type: Unit
  Decl: bar.ads           2:15
  Ref:  main.adb          6:12     7:12
</PRE>

that is the entity <CODE>Main</CODE> is declared in main.ads, line 2, column 9,
its body is in main.adb, line 1, column 14 and is not referenced any where.

The entity <CODE>Print</CODE> is declared in bar.ads, line 2, column 15 and it
it referenced in main.adb, line 6 column 12 and line 7 column 12.

<DT><CODE>gnatxref package1.adb package2.ads</CODE>
<DD>
<CODE>gnatxref</CODE> will generates cross-reference information for
package1.adb, package2.ads and any other package 'with'ed by any
of these.

</DL>



<H3><A NAME="SEC101" HREF="gnat_ug_toc.html#TOC101">Using gnatxref with vi</A></H3>

<P>
<CODE>gnatxref</CODE> can generate a tags file output, which can be used
directly from <TT>`vi'</TT>. Note that the standard version of <TT>`vi'</TT>
will not work properly with overloaded symbols. Consider using another
free implementation of <TT>`vi'</TT>, such as <TT>`vim'</TT>.

</P>

<PRE>
   $ gnatxref -v gnatfind.adb &#62; tags
</PRE>

<P>
will generate the tags file for <CODE>gnatfind</CODE> itself (if the sources
are in the search path!).

</P>
<P>
From <TT>`vi'</TT>, you can then use the command <SAMP>`:tag <I>entity</I>'</SAMP>
(replacing <I>entity</I> by whatever you are looking for), and vi will
display a new file with the corresponding declaration of entity.

</P>



<H2><A NAME="SEC102" HREF="gnat_ug_toc.html#TOC102">Examples of <CODE>gnatfind</CODE> usage</A></H2>

<DL COMPACT>

<DT><CODE>gnatfind -f xyz:main.adb</CODE>
<DD>
Find declarations for all entities xyz referenced at least once in
main.adb.  The references are search in every library file in the search
path.

The directories will be printed as well (as the <SAMP>`-f'</SAMP>
switch is set)

The output will look like:

<PRE>
   directory/main.ads:106:14: xyz &#60;= declaration
   directory/main.adb:24:10: xyz &#60;= body
   directory/foo.ads:45:23: xyz &#60;= declaration
</PRE>

that is to say, one of the entities xyz found in main.adb is declared at
line 12 of main.ads (and its body is in main.adb), and another one is
declared at line 45 of foo.ads

<DT><CODE>gnatfind -fs xyz:main.adb</CODE>
<DD>
This is the same command as the previous one, instead <CODE>gnatfind</CODE> will
display the content of the Ada source file lines.

The output will look like:


<PRE>
   directory/main.ads:106:14: xyz &#60;= declaration
      procedure xyz;
   directory/main.adb:24:10: xyz &#60;= body
      procedure xyz is
   directory/foo.ads:45:23: xyz &#60;= declaration
      xyz : Integer;
</PRE>

This can make it easier to find exactly the location your are looking
for.

<DT><CODE>gnatfind -r "*x*":main.ads:123 foo.adb</CODE>
<DD>
Find references to all entities containing an x that are
referenced on line 123 of main.ads.
The references will be searched only in main.adb and foo.adb.

<DT><CODE>gnatfind main.ads:123</CODE>
<DD>
Find declarations and bodies for all entities that are referenced on
line 123 of main.ads.

This is the same as <CODE>gnatfind "*":main.adb:123</CODE>.

<DT><CODE>gnatfind mydir/main.adb:123:45</CODE>
<DD>
Find the declaration for the entity referenced at column 45 in
line 123 of file main.adb in directory mydir. Note that it
is usual to omit the identifier name when the column is given,
since the column position identifies a unique reference.

The column has to be the beginning of the identifier, and should not
point to any character in the middle of the identifier.

</DL>



<H1><A NAME="SEC103" HREF="gnat_ug_toc.html#TOC103">File Name Krunching Using <CODE>gnatkr</CODE></A></H1>
<P>
<A NAME="IDX281"></A>

</P>
<P>
This chapter discusses the method used by the compiler to shorten
the default file names chosen for Ada units so that they do not
exceed the maximum length permitted. It also describes the
<CODE>gnatkr</CODE> utility that can be used to determine the result of
applying this shortening.

<UL>
<LI><A HREF="gnat_ug.html#SEC104">About gnatkr</A>
<LI><A HREF="gnat_ug.html#SEC105">Using gnatkr</A>
<LI><A HREF="gnat_ug.html#SEC106">Krunching Method</A>
<LI><A HREF="gnat_ug.html#SEC107">Examples of gnatkr Usage</A>
</UL>



<H2><A NAME="SEC104" HREF="gnat_ug_toc.html#TOC104">About <CODE>gnatkr</CODE></A></H2>

<P>
The default file naming rule in GNAT
is that the file name must be derived from
the unit name. The exact default rule is as follows:

<UL>
<LI>

Take the unit name and replace all dots by hyphens.
<LI>

If such a replacement occurs in the
second character position of a name, and the first character is
a, g, s, or i then replace the dot by the character
~ (tilde)
instead of a minus.
</UL>

<P>
The reason for this exception is to avoid clashes
with the standard names for children of System, Ada, Interfaces,
and GNAT, which use the prefixes s- a- i- and g-
respectively.

</P>
<P>
The <CODE>-gnatk<VAR>nn</VAR></CODE>
switch of the compiler activates a "krunching"
circuit that limits file names to nn characters (where nn is a decimal
integer). For example, using OpenVMS,
where the maximum file name length is
39, the value of nn is usually set to 39, but if you want to generate
a set of files that would be usable if ported to a system with some
different maximum file length, then a different value can be specified.
The default value of 39 for OpenVMS need not be specified.

</P>
<P>
The <CODE>gnatkr</CODE> utility can be used to determine the krunched name for
a given file, when krunched to a specified maximum length.

</P>


<H2><A NAME="SEC105" HREF="gnat_ug_toc.html#TOC105">Using <CODE>gnatkr</CODE></A></H2>

<P>
The <CODE>gnatkr</CODE> command has the form

</P>

<PRE>
   $ gnatkr <VAR>name</VAR> [<VAR>length</VAR>]
</PRE>

<P>
<VAR>name</VAR> can be an Ada name with dots or the GNAT name of the unit,
where the dots representing child units or subunit are replaced by
hyphens. The only confusion arises if a name ends in <CODE>.ads</CODE> or
<CODE>.adb</CODE>.  <CODE>gnatkr</CODE> takes this to be an extension if there are
no other dots in the name and the whole name is in lowercase.

</P>
<P>
<VAR>length</VAR> represents the length of the krunched name. The default
when no argument is given is 8 characters. A length of zero stands for
unlimited, in other words do not chop except for system files which are
always 8.

</P>
<P>
The output is the krunched name. The output has an extension only if the
original argument was a file name with an extension.

</P>


<H2><A NAME="SEC106" HREF="gnat_ug_toc.html#TOC106">Krunching Method</A></H2>

<P>
The initial file name is determined by the name of the unit that the file
contains. The name is formed by taking the full expanded name of the
unit and replacing the separating dots with hyphens and
using lowercase
for all letters, except that a hyphen in the second character position is
replaced by a tilde if the first character is
a, i, g, or s.
The extension is <CODE>.ads</CODE> for a
specification and <CODE>.adb</CODE> for a body.
Krunching does not affect the extension, but the file name is shortened to
the specified length by following these rules:

</P>

<UL>
<LI>

The name is divided into segments separated by hyphens, tildes or
underscores and all hyphens, tildes, and underscores are
eliminated. If this leaves the name short enough, we are done.

<LI>

If the name is too long, the longest segment is located (left-most if there are two
of equal length), and shortened by dropping its last character. This is
repeated until the name is short enough.

As an example, consider the krunching of <TT>`our-strings-wide_fixed.adb'</TT>
to fit the name into 8 characters as required by some operating systems.


<PRE>
   our-strings-wide_fixed 22
   our strings wide fixed 19
   our string  wide fixed 18
   our strin   wide fixed 17
   our stri    wide fixed 16
   our stri    wide fixe  15
   our str     wide fixe  14
   our str     wid  fixe  13
   our str     wid  fix   12
   ou  str     wid  fix   11
   ou  st      wid  fix   10
   ou  st      wi   fix   9
   ou  st      wi   fi    8
   Final file name: oustwifi.adb
</PRE>

<LI>

The file names for all predefined units are always krunched to eight
characters. The krunching of these predefined units uses the following
special prefix replacements:

<DL COMPACT>

<DT><TT>`ada-'</TT>
<DD>
replaced by <TT>`a-'</TT>

<DT><TT>`gnat-'</TT>
<DD>
replaced by <TT>`g-'</TT>

<DT><TT>`interfaces-'</TT>
<DD>
replaced by <TT>`i-'</TT>

<DT><TT>`system-'</TT>
<DD>
replaced by <TT>`s-'</TT>
</DL>

These system files have a hyphen in the second character position.  That
is why normal user files replace such a character with a
tilde, to
avoid confusion with system file names.

As an example of this special rule, consider
<TT>`ada-strings-wide_fixed.adb'</TT>, which gets krunched as follows:


<PRE>
   ada-strings-wide_fixed 22
   a-  strings wide fixed 18
   a-  string  wide fixed 17
   a-  strin   wide fixed 16
   a-  stri    wide fixed 15
   a-  stri    wide fixe  14
   a-  str     wide fixe  13
   a-  str     wid  fixe  12
   a-  str     wid  fix   11
   a-  st      wid  fix   10
   a-  st      wi   fix   9
   a-  st      wi   fi    8
   Final file name: a-stwifi.adb
</PRE>

</UL>

<P>
Of course no file shortening algorithm can guarantee uniqueness over all
possible unit names, and if file name krunching is used then it is your
responsibility to ensure that no name clashes occur.  The utility
program <CODE>gnatkr</CODE> is supplied for conveniently determining the
krunched name of a file.

</P>


<H2><A NAME="SEC107" HREF="gnat_ug_toc.html#TOC107">Examples of <CODE>gnatkr</CODE> Usage</A></H2>


<PRE>
   $ gnatkr very_long_unit_name.ads      --&#62; velounna.ads
   $ gnatkr grandparent-parent-child.ads --&#62; grparchi.ads
   $ gnatkr Grandparent.Parent.Child     --&#62; grparchi
   $ gnatkr very_long_unit_name.ads/count=6    --&#62; vlunna.ads
   $ gnatkr very_long_unit_name.ads/count=0    --&#62; very_long_unit_name.ads
</PRE>



<H1><A NAME="SEC108" HREF="gnat_ug_toc.html#TOC108">Preprocessing Using <CODE>gnatprep</CODE></A></H1>
<P>
<A NAME="IDX282"></A>

</P>
<P>
The <CODE>gnatprep</CODE> utility provides
a simple preprocessing capability for Ada programs.
It is designed for use with GNAT, but is not dependent on any special
features of GNAT.

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC109">Using gnatprep</A>
<LI><A HREF="gnat_ug.html#SEC110">Switches for gnatprep</A>
<LI><A HREF="gnat_ug.html#SEC111">Form of definitions file</A>
<LI><A HREF="gnat_ug.html#SEC112">Form of input text for gnatprep</A>
</UL>



<H2><A NAME="SEC109" HREF="gnat_ug_toc.html#TOC109">Using <CODE>gnatprep</CODE></A></H2>

<P>
To call <CODE>gnatprep</CODE> use

</P>

<PRE>
   $ gnatprep [-bcrsu] [-Dsymbol=value] infile outfile [deffile]
</PRE>

<P>
where
<DL COMPACT>

<DT><CODE>infile</CODE>
<DD>
is the full name of the input file, which is an Ada source
file containing preprocessor directives.

<DT><CODE>outfile</CODE>
<DD>
is the full name of the output file, which is an Ada source
in standard Ada form. When used with GNAT, this file name will
normally have an ads or adb suffix.

<DT><CODE>deffile</CODE>
<DD>
is the full name of a text file containing definitions of
symbols to be referenced by the preprocessor. This argument is
optional, and can be replaced by the use of the <CODE>-D</CODE> switch.

<DT><CODE>switches</CODE>
<DD>
is an optional sequence of switches as described in the next section.
</DL>



<H2><A NAME="SEC110" HREF="gnat_ug_toc.html#TOC110">Switches for <CODE>gnatprep</CODE></A></H2>

<DL COMPACT>

<DT><CODE>-b</CODE>
<DD>
Causes both preprocessor lines and the lines deleted by
preprocessing to be replaced by blank lines in the output source file,
preserving line numbers in the output file.

<DT><CODE>-c</CODE>
<DD>
Causes both preprocessor lines and the lines deleted
by preprocessing to be retained in the output source as comments marked
with the special string "--! ". This option will result in line numbers
being preserved in the output file.

<DT><CODE>-Dsymbol=value</CODE>
<DD>
Defines a new symbol, associated with value. If no value is given on the
command line, then symbol is considered to be <CODE>True</CODE>. This switch
can be used in place of a definition file.

<DT><CODE>-r</CODE>
<DD>
Causes a <CODE>Source_Reference</CODE> pragma to be generated that
references the original input file, so that error messages will use
the file name of this original file. The use of this switch implies
that preprocessor lines are not to be removed from the file, so its
use will force <CODE>-b</CODE> mode if
<CODE>-c</CODE>
has not been specified explicitly.

Note that if the file to be preprocessed contains multiple units, then
it will be necessary to <CODE>gnatchop</CODE> the output file from
<CODE>gnatprep</CODE>. If a <CODE>Source_Reference</CODE> pragma is present
in the preprocessed file, it will be respected by
<CODE>gnatchop -r</CODE>
so that the final chopped files will correctly refer to the original
input source file for <CODE>gnatprep</CODE>.

<DT><CODE>-s</CODE>
<DD>
Causes a sorted list of symbol names and values to be
listed on the standard output file.

<DT><CODE>-u</CODE>
<DD>
Causes undefined symbols to be treated as having the value FALSE in the context
of a preprocessor test. In the absence of this option, an undefined symbol in
a <CODE>#if</CODE> or <CODE>#elsif</CODE> test will be treated as an error.

</DL>

<P>
Note: if neither <CODE>-b</CODE> nor <CODE>-c</CODE> is present,
then preprocessor lines and
deleted lines are completely removed from the output, unless -r is
specified, in which case -b is assumed.

</P>


<H2><A NAME="SEC111" HREF="gnat_ug_toc.html#TOC111">Form of definitions file</A></H2>

<P>
The definitions file contains lines of the form

</P>

<PRE>
   symbol := value
</PRE>

<P>
where symbol is an identifier, following normal Ada (case-insensitive)
rules for its syntax, and value is one of the following:

</P>

<UL>
<LI>

Empty, corresponding to a null substitution
<LI>

A string literal using normal Ada syntax
<LI>

Any sequence of characters from the set
(letters, digits, period, underline).
</UL>

<P>
Comment lines may also appear in the definitions file, starting with
the usual <CODE>--</CODE>,
and comments may be added to the definitions lines.

</P>


<H2><A NAME="SEC112" HREF="gnat_ug_toc.html#TOC112">Form of input text for <CODE>gnatprep</CODE></A></H2>

<P>
The input text may contain preprocessor conditional inclusion lines,
as well as general symbol substitution sequences.
The preprocessor conditional inclusion commands have the form

</P>

<PRE>
   #if <I>expression</I> [then]
      lines
   #elsif <I>expression</I> [then]
      lines
   #elsif <I>expression</I> [then]
      lines
   ...
   #else
      lines
   #end if;
</PRE>

<P>
In this example, <I>expression</I> is defined by the following grammar:

<PRE>
   <I>expression</I> ::=  &#60;symbol&#62;
   <I>expression</I> ::=  &#60;symbol&#62; = "&#60;value&#62;"
   <I>expression</I> ::=  &#60;symbol&#62; = &#60;symbol&#62;
   <I>expression</I> ::=  &#60;symbol&#62; 'Defined
   <I>expression</I> ::=  not <I>expression</I>
   <I>expression</I> ::=  <I>expression</I> and <I>expression</I>
   <I>expression</I> ::=  <I>expression</I> or <I>expression</I>
   <I>expression</I> ::=  <I>expression</I> and then <I>expression</I>
   <I>expression</I> ::=  <I>expression</I> or else <I>expression</I>
   <I>expression</I> ::=  ( <I>expression</I> )
</PRE>

<P>
For the first test (<I>expression</I> ::= &#60;symbol&#62;) the symbol must have
either the value true or false, that is to say the right-hand of the
symbol definition must be one of the (case-insensitive) literals
<CODE>True</CODE> or <CODE>False</CODE>.  If the value is true, then the
corresponding lines are included, and if the value is false, they are
excluded.

</P>
<P>
The test (<I>expression</I> ::= &#60;symbol&#62; <CODE>'Defined</CODE>) is true only if
the symbol has been defined in the definition file or by a <CODE>-D</CODE>
switch on the command line. Otherwise, the test is false.

</P>
<P>
The equality tests are case insensitive, as are all the preprocessor lines.

</P>
<P>
If the symbol referenced is not defined in the symbol definitions file,
then the effect depends on whether or not switch <CODE>-u</CODE>
is specified. If so, then the symbol is treated as if it had the value
false and the test fails. If this switch is not specified, then
it is an error to reference an undefined symbol. It is also an error to
reference a symbol that is defined with a value other than <CODE>True</CODE>
or <CODE>False</CODE>.

</P>
<P>
The use of the not operator inverts the sense of this logical test, so
that the lines are included only if the symbol is not defined.
The <CODE>then</CODE> keyword is optional as shown

</P>
<P>
The <CODE>#</CODE> must be in column one, but otherwise the format is free form.
Spaces or tabs may appear between the <CODE>#</CODE> and the keyword. The keywords
and the symbols are case insensitive as in normal Ada code. Comments
may be used on a preprocessor line, but other than that, no other
tokens may appear on a preprocessor line.
Any number of <CODE>elsif</CODE> clauses can be present, including none at all.
The <CODE>else</CODE> is optional, as in Ada.

</P>
<P>
The <CODE>#</CODE> marking the start of a preprocessor line must be the first
non-blank character on the line, i.e. it must be preceded only by
spaces or horizontal tabs.

</P>
<P>
Symbol substitution outside of preprocessor lines is obtained by using
the sequence

</P>

<PRE>
   $symbol
</PRE>

<P>
anywhere within a source line, except in a comment. The identifier
following the <CODE>$</CODE> must match one of the symbols defined in the symbol
definition file, and the result is to substitute the value of the
symbol in place of <CODE>$symbol</CODE> in the output file.

</P>



<H1><A NAME="SEC113" HREF="gnat_ug_toc.html#TOC113">The GNAT library browser <CODE>gnatls</CODE></A></H1>
<P>
<A NAME="IDX283"></A>
<A NAME="IDX284"></A>

</P>
<P>
<CODE>gnatls</CODE> is a tool that outputs information about compiled
units. It gives the relationship between objects, unit names and source
files. It can also be used to check the source dependencies of a unit
as well as various characteristics.

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC114">Running gnatls</A>
<LI><A HREF="gnat_ug.html#SEC115">Switches for gnatls</A>
<LI><A HREF="gnat_ug.html#SEC116">Examples of gnatls Usage</A>
</UL>



<H2><A NAME="SEC114" HREF="gnat_ug_toc.html#TOC114">Running <CODE>gnatls</CODE></A></H2>

<P>
The <CODE>gnatls</CODE> command has the form

</P>

<PRE>
   $ gnatls switches <VAR>object_or_ali_file</VAR>
</PRE>

<P>
The main argument is the list of object or <TT>`ali'</TT> files
(see section <A HREF="gnat_ug.html#SEC21">The Ada Library Information Files</A>)
for which information is requested.

</P>
<P>
In normal mode, without additional option, <CODE>gnatls</CODE> produces a
four-column listing. Each line represents information for a specific
object. The first column gives the full path of the object, the second
column gives the name of the principal unit in this object, the third
column gives the status of the source and the fourth column gives the
full path of the source representing this unit.
Here is a simple example of use:

</P>

<PRE>
   $ gnatls *.o
   ./demo1.o            demo1            DIF demo1.adb
   ./demo2.o            demo2             OK demo2.adb
   ./hello.o            h1                OK hello.adb
   ./instr-child.o      instr.child      MOK instr-child.adb
   ./instr.o            instr             OK instr.adb
   ./tef.o              tef              DIF tef.adb
   ./text_io_example.o  text_io_example   OK text_io_example.adb
   ./tgef.o             tgef             DIF tgef.adb
</PRE>

<P>
The first line can be interpreted as follows: the main unit which is
contained in
object file <TT>`demo1.o'</TT> is demo1, whose main source is in
<TT>`demo1.adb'</TT>. Furthermore, the version of the source used for the
compilation of demo1 has been modified (DIF). Each source file has a status
qualifier which can be:

</P>
<DL COMPACT>

<DT><CODE>OK (unchanged)</CODE>
<DD>
The version of the source file used for the compilation of the
specified unit corresponds exactly to the actual source file.

<DT><CODE>MOK (slightly modified)</CODE>
<DD>
The version of the source file used for the compilation of the
specified unit differs from the actual source file but not enough to
require recompilation.  If you use gnatmake with the qualifier
<CODE>-m (minimal recompilation)</CODE>, a file marked
MOK will not be recompiled.

<DT><CODE>DIF (modified)</CODE>
<DD>
No version of the source found on the path corresponds to the source
used to build this object.

<DT><CODE>??? (file not found)</CODE>
<DD>
No source file was found for this unit.

<DT><CODE>HID (hidden,  unchanged version not first on PATH)</CODE>
<DD>
The version of the source that corresponds exactly to the source used
for compilation has been found on the path but it is hidden by another
version of the same source that has been modified.

</DL>



<H2><A NAME="SEC115" HREF="gnat_ug_toc.html#TOC115">Switches for <CODE>gnatls</CODE></A></H2>

<P>
<CODE>gnatls</CODE> recognizes the following switches:

</P>
<DL COMPACT>

<DT><CODE>-a</CODE>
<DD>
<A NAME="IDX285"></A>
Consider all units, including those of the predefined Ada library.
Especially useful with <CODE>-d</CODE>.

<DT><CODE>-d</CODE>
<DD>
<A NAME="IDX286"></A>
List sources from which specified units depend on.

<DT><CODE>-h</CODE>
<DD>
<A NAME="IDX287"></A>
Output the list of options.

<DT><CODE>-o</CODE>
<DD>
<A NAME="IDX288"></A>
Only output information about object files.

<DT><CODE>-s</CODE>
<DD>
<A NAME="IDX289"></A>
Only output information about source files.

<DT><CODE>-u</CODE>
<DD>
<A NAME="IDX290"></A>
Only output information about compilation units.

<DT><CODE>-aO<VAR>dir</VAR></CODE>
<DD>
<DT><CODE>-aI<VAR>dir</VAR></CODE>
<DD>
<DT><CODE>-I<VAR>dir</VAR></CODE>
<DD>
<DT><CODE>-I-</CODE>
<DD>
<DT><CODE>-nostdinc</CODE>
<DD>
Source and Object path manipulation. Same meaning as the equivalent
$ gnatmake flags section <A HREF="gnat_ug.html#SEC69">Switches for <CODE>gnatmake</CODE></A>

<DT><CODE>-v</CODE>
<DD>
<A NAME="IDX291"></A>
Verbose mode. Output the complete source and object paths. Do not use
the default column layout but instead use long format giving as much as
information possible on each requested units, including special
characteristics such as:

<DL COMPACT>

<DT><CODE>Preelaborable</CODE>
<DD>
The unit is preelaborable in the Ada 95 sense.

<DT><CODE>No_Elab_Code</CODE>
<DD>
No elaboration code has been produced by the compiler for this unit.

<DT><CODE>Pure</CODE>
<DD>
The unit is pure in the Ada 95 sense.

<DT><CODE>Elaborate_Body</CODE>
<DD>
The unit contains a pragma Elaborate_Body.

<DT><CODE>Remote_Types</CODE>
<DD>
The unit contains a pragma Remote_Types.

<DT><CODE>Shared_Passive</CODE>
<DD>
The unit contains a pragma Shared_Passive.

<DT><CODE>Predefined</CODE>
<DD>
This unit is part of the predefined environment and cannot be modified
by the user.

<DT><CODE>Remote_Call_Interface</CODE>
<DD>
The unit contains a pragma Remote_Call_Interface.

</DL>
</DL>



<H2><A NAME="SEC116" HREF="gnat_ug_toc.html#TOC116">Example of <CODE>gnatls</CODE> Usage</A></H2>

<P>
Example of using the verbose switch. Note how the source and
object paths are affected by the -I switch.

</P>

<PRE>
   $ gnatls -v -I.. demo1.o

   GNATLS 3.10w (970212) Copyright 1999 Free Software Foundation, Inc.

   Source Search Path:
      &#60;Current_Directory&#62;
      ../
      /home/comar/local/adainclude/

   Object Search Path:
      &#60;Current_Directory&#62;
      ../
      /home/comar/local/lib/gcc-lib/mips-sni-sysv4/2.7.2/adalib/

   ./demo1.o
      Unit =&#62;
        Name   =&#62; demo1
        Kind   =&#62; subprogram body
        Flags  =&#62; No_Elab_Code
        Source =&#62; demo1.adb    modified
</PRE>

<P>
The following is an example of use of the dependency list.
Note the use of the -s switch
which gives a straight list of source files. This can be useful for
building specialized scripts.

</P>

<PRE>
   $ gnatls -d demo2.o
   ./demo2.o   demo2        OK demo2.adb
                            OK gen_list.ads
                            OK gen_list.adb
                            OK instr.ads
                            OK instr-child.ads

   $ gnatls -d -s -a demo1.o
   demo1.adb
   /home/comar/local/adainclude/ada.ads
   /home/comar/local/adainclude/a-finali.ads
   /home/comar/local/adainclude/a-filico.ads
   /home/comar/local/adainclude/a-stream.ads
   /home/comar/local/adainclude/a-tags.ads
   gen_list.ads
   gen_list.adb
   /home/comar/local/adainclude/gnat.ads
   /home/comar/local/adainclude/g-io.ads
   instr.ads
   /home/comar/local/adainclude/system.ads
   /home/comar/local/adainclude/s-exctab.ads
   /home/comar/local/adainclude/s-finimp.ads
   /home/comar/local/adainclude/s-finroo.ads
   /home/comar/local/adainclude/s-secsta.ads
   /home/comar/local/adainclude/s-stalib.ads
   /home/comar/local/adainclude/s-stoele.ads
   /home/comar/local/adainclude/s-stratt.ads
   /home/comar/local/adainclude/s-tasoli.ads
   /home/comar/local/adainclude/s-unstyp.ads
   /home/comar/local/adainclude/unchconv.ads
</PRE>



<H1><A NAME="SEC117" HREF="gnat_ug_toc.html#TOC117">Rebuilding the GNAT Library</A></H1>
<P>
<A NAME="IDX292"></A>

</P>
<P>
It may be useful to recompile the GNAT library in various contexts, the
most important one being the use of partition wide configuration pragmas
such as Normalize_Scalar. A special Makefile called
<CODE>Makefile.adalib</CODE> is provided to that effect and can be found in
the directory containing the GNAT library. The location of this
directory depends on how the GNAT environment has been installed and can
be located with the command

</P>

<PRE>
   $ gnatls -v
</PRE>

<P>
The last line of the Object Search Path usually contains the
gnat library. This Makefile contains its own documentation and in
particular the set of instructions needed to rebuild a new library and
to use it.

</P>



<H1><A NAME="SEC118" HREF="gnat_ug_toc.html#TOC118">Finding memory problems with <CODE>gnatmem</CODE></A></H1>
<P>
<A NAME="IDX293"></A>

</P>
<P>
<CODE>gnatmem</CODE>, is a tool that monitors dynamic allocation and
deallocation activity in a program, and displays information about
incorrect deallocations and possible sources of memory leaks. Gnatmem
provides three type of information:

<UL>
<LI>

General information concerning memory management, such as the total
number of allocations and deallocations, the amount of allocated
memory and the high water mark, i.e. the largest amount of allocated
memory in the course of program execution.

<LI>

Backtraces for all incorrect deallocations, that is to say deallocations
which do not correspond to a valid allocation.

<LI>

Information on each allocation that is potentially the origin of a memory
leak.
</UL>


<UL>
<LI><A HREF="gnat_ug.html#SEC119">Running gnatmem</A>
<LI><A HREF="gnat_ug.html#SEC120">Switches for gnatmem</A>
<LI><A HREF="gnat_ug.html#SEC121">Examples of gnatmem Usage</A>
<LI><A HREF="gnat_ug.html#SEC122">Implementation note</A>
</UL>



<H2><A NAME="SEC119" HREF="gnat_ug_toc.html#TOC119">Running <CODE>gnatmem</CODE></A></H2>

<P>
The <CODE>gnatmem</CODE> command has the form

</P>

<PRE>
   $ gnatmem [n] [-o file] user_program [program_arg]*
or
   $ gnatmem [n] -i file
</PRE>

<P>
Gnatmem must be supplied with the executable to examine, followed by its
run-time inputs. For example, if a program is executed with the command:

<PRE>
   $ my_program arg1 arg2
</PRE>

<P>
then it can be run under <CODE>gnatmem</CODE> control using the command:

<PRE>
   $ gnatmem my_program arg1 arg2
</PRE>

<P>
The program is transparently executed under the control of the debugger
section <A HREF="gnat_ug.html#SEC149">The GNAT Debugger GDB</A>. This does not affect the behavior
of the program, except for sensitive real-time programs. When the program
has completed execution, <CODE>gnatmem</CODE> outputs a report containing general
allocation/deallocation information and potential memory leak.
For better results, the user program should be compiled with
debugging options section <A HREF="gnat_ug.html#SEC35">Switches for <CODE>gcc</CODE></A>.

</P>
<P>
Here is a simple example of use:

</P>
<P>
*************** debut cc

<PRE>
   $ gnatmem test_gm

   Global information
   ------------------
      Total number of allocations        :  45
      Total number of deallocations      :   6
      Final Water Mark (non freed mem)   :  11.29 Kilobytes
      High Water Mark                    :  11.40 Kilobytes

   .
   .
   .
   Allocation Root # 2
   -------------------
    Number of non freed allocations    :  11
    Final Water Mark (non freed mem)   :   1.16 Kilobytes
    High Water Mark                    :   1.27 Kilobytes
    Backtrace                          :
      test_gm.adb:23 test_gm.alloc
   .
   .
   .
</PRE>

<P>
The first block of output give general information. In this case, the
Ada construct "new" was executed 45 times, and only 6 calls to an
unchecked deallocation routine occurred.

</P>
<P>
Subsequent paragraphs display  information on all allocation roots.
An allocation
root is a specific point in the execution of the program that generates some
dynamic allocation, such as a "new" construct. This root is represented
by an execution backtrace (or subprogram call stack). By default the
backtrace depth for allocations roots is 1, so that a root corresponds
exactly to a source location. The backtrace can be made deeper, to make
the root more specific.

</P>


<H2><A NAME="SEC120" HREF="gnat_ug_toc.html#TOC120">Switches for <CODE>gnatmem</CODE></A></H2>

<P>
<CODE>gnatmem</CODE> recognizes the following switches:

</P>
<DL COMPACT>

<DT><CODE><CODE>-q</CODE></CODE>
<DD>
<A NAME="IDX294"></A>
Quiet. Gives the minimum output needed to identify the origin of the
memory leaks. Omit statistical information.

<DT><CODE><CODE>n</CODE></CODE>
<DD>
<A NAME="IDX295"></A>
N is an integer literal (usually between 1 and 10) which controls the
depth of the backtraces defining allocation root. The default value for
N is 1. The deeper the backtrace, the more precise the localization of
the root. Note that the total number of roots can depend on this
parameter.

<DT><CODE><CODE>-o file</CODE></CODE>
<DD>
<A NAME="IDX296"></A>
Direct the gdb output to the specified file. The gdb script used
to generate this output is also saved in the file <TT>`gnatmem.tmp'</TT>.

<DT><CODE><CODE>-i file</CODE></CODE>
<DD>
<A NAME="IDX297"></A>
Do the <CODE>gnatmem</CODE>
processing starting from <CODE>file</CODE> which has been generated
by a previous call to <CODE>gnatmem</CODE>
with the -o switch. This is useful for
post mortem processing.

</DL>



<H2><A NAME="SEC121" HREF="gnat_ug_toc.html#TOC121">Example of <CODE>gnatmem</CODE> Usage</A></H2>

<P>
The first example shows the use of <CODE>gnatmem</CODE>
on a simple leaking program.
Suppose that we have the following Ada program:

</P>

<PRE>
   <B>with</B> Unchecked_Deallocation;
   <B>procedure</B> Test_Gm <B>is</B>

      <B>type</B> T <B>is array</B> (1..1000) <B>of</B> Integer;
      <B>type</B> Ptr <B>is access</B> T;
      <B>procedure</B> Free <B>is new</B> Unchecked_Deallocation (T, Ptr);
      A : Ptr;

      <B>procedure</B> My_Alloc <B>is</B>
      <B>begin</B>
         A := <B>new</B> T;
      <B>end</B> My_Alloc;

      <B>procedure</B> My_DeAlloc <B>is</B>
         B : Ptr := A;
      <B>begin</B>
         Free (B);
      <B>end</B> My_DeAlloc;

   <B>begin</B>
      My_Alloc;
      <B>for</B> I <B>in</B> 1 .. 5 <B>loop</B>
         <B>for</B> J <B>in</B> I .. 5 <B>loop</B>
            My_Alloc;
         <B>end loop</B>;
         My_Dealloc;
      <B>end loop</B>;
   <B>end</B>;
</PRE>

<P>
The program needs to be compiled with debugging option:

</P>

<PRE>
   $ gnatmake -g test_gm
</PRE>

<P>
<CODE>gnatmem</CODE> is invoked simply with

<PRE>
   $ gnatmem test_gm
</PRE>

<P>
which produces the following output:

</P>

<PRE>
   Global information
   ------------------
      Total number of allocations        :  18
      Total number of deallocations      :   5
      Final Water Mark (non freed mem)   :  53.00 Kilobytes
      High Water Mark                    :  56.90 Kilobytes

   Allocation Root # 1
   -------------------
    Number of non freed allocations    :  11
    Final Water Mark (non freed mem)   :  42.97 Kilobytes
    High Water Mark                    :  46.88 Kilobytes
    Backtrace                          :
      test_gm.adb:11 test_gm.my_alloc

   Allocation Root # 2
   -------------------
    Number of non freed allocations    :   1
    Final Water Mark (non freed mem)   :  10.02 Kilobytes
    High Water Mark                    :  10.02 Kilobytes
    Backtrace                          :
      s-secsta.adb:81 system.secondary_stack.ss_init

   Allocation Root # 3
   -------------------
    Number of non freed allocations    :   1
    Final Water Mark (non freed mem)   :  12 Bytes
    High Water Mark                    :  12 Bytes
    Backtrace                          :
      s-secsta.adb:181 system.secondary_stack.ss_init
</PRE>

<P>
Note that the GNAT run time contains itself a certain number of
allocations that have no  corresponding deallocation,
as shown here for root #2 and root
#1. This is a normal behavior when the number of non freed allocations
is one, it locates dynamic data structures that the run time needs for
the complete lifetime of the program. Note also that there is only one
allocation root in the user program with a single line back trace:
test_gm.adb:11 test_gm.my_alloc, whereas a careful analysis of the
program shows that 'My_Alloc' is called at 2 different points in the
source (line 21 and line 24). If those two allocation roots need to be
distinguished, the backtrace depth parameter can be used:

</P>

<PRE>
   $ gnatmem 3 test_gm
</PRE>

<P>
which will give the following output:

</P>

<PRE>
   Global information
   ------------------
      Total number of allocations        :  18
      Total number of deallocations      :   5
      Final Water Mark (non freed mem)   :  53.00 Kilobytes
      High Water Mark                    :  56.90 Kilobytes

   Allocation Root # 1
   -------------------
    Number of non freed allocations    :  10
    Final Water Mark (non freed mem)   :  39.06 Kilobytes
    High Water Mark                    :  42.97 Kilobytes
    Backtrace                          :
      test_gm.adb:11 test_gm.my_alloc
      test_gm.adb:24 test_gm
      b_test_gm.c:52 main

   Allocation Root # 2
   -------------------
    Number of non freed allocations    :   1
    Final Water Mark (non freed mem)   :  10.02 Kilobytes
    High Water Mark                    :  10.02 Kilobytes
    Backtrace                          :
      s-secsta.adb:81  system.secondary_stack.ss_init
      s-secsta.adb:283 &#60;system__secondary_stack___elabb&#62;
      b_test_gm.c:33   adainit

   Allocation Root # 3
   -------------------
    Number of non freed allocations    :   1
    Final Water Mark (non freed mem)   :   3.91 Kilobytes
    High Water Mark                    :   3.91 Kilobytes
    Backtrace                          :
      test_gm.adb:11 test_gm.my_alloc
      test_gm.adb:21 test_gm
      b_test_gm.c:52 main

   Allocation Root # 4
   -------------------
    Number of non freed allocations    :   1
    Final Water Mark (non freed mem)   :  12 Bytes
    High Water Mark                    :  12 Bytes
    Backtrace                          :
      s-secsta.adb:181 system.secondary_stack.ss_init
      s-secsta.adb:283 &#60;system__secondary_stack___elabb&#62;
      b_test_gm.c:33   adainit
</PRE>

<P>
The allocation root #1 of the first example has been split in 2 roots #1
and #3 thanks to the more precise associated backtrace.

</P>


<H2><A NAME="SEC122" HREF="gnat_ug_toc.html#TOC122">Implementation note</A></H2>

<P>
<CODE>gnatmem</CODE> executes the user program under the control of <CODE>gdb</CODE> using
a script that sets breakpoints and gathers information on each dynamic
allocation and deallocation. The output of the script is then analyzed
by <CODE>gnatmem</CODE>
in order to locate memory leaks and their origin in the
program. Gnatmem works by recording each address returned by the
allocation procedure (<CODE>__gnat_malloc</CODE>)
along with the backtrace at the
allocation point. On each deallocation, the deallocated address is
matched with the corresponding allocation. At the end of the processing,
the unmatched allocations are considered potential leaks. All the
allocations associated with the same backtrace are grouped together and
form an allocation root. The allocation roots are then sorted so that
those with the biggest number of unmatched allocation are printed
first. A delicate aspect of this technique is to distinguish between the
data produced by the user program and the data produced by the gdb
script. Currently, on systems that allow probing the terminal, the gdb
command "tty" is used to force the program output to be redirected to the
current terminal while the gdb output is directed to a file or to a
pipe in order to be processed subsequently by <CODE>gnatmem</CODE>.

</P>



<H1><A NAME="SEC123" HREF="gnat_ug_toc.html#TOC123">ASIS-Based Tools</A></H1>

<P>
Some of the tools distributed with GNAT are based on the ASIS implementation
for GNAT (ASIS-for-GNAT). Binary executables for such tools do not require
ASIS-for-GNAT to be around and they have a command-line interface similar to
other GNAT tools. The main specific feature of ASIS-based tools is that they
process tree output files.

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC124">The ASIS Implementation for GNAT (ASIS-for-GNAT)</A>
<LI><A HREF="gnat_ug.html#SEC125">Tree Files</A>
</UL>



<H2><A NAME="SEC124" HREF="gnat_ug_toc.html#TOC124">The ASIS Implementation for GNAT (ASIS-for-GNAT)</A></H2>
<P>
<A NAME="IDX298"></A>
<A NAME="IDX299"></A>

</P>
<P>
The ASIS implementation for GNAT, called ASIS-for-GNAT, is the implementation
if the Ada Semantic Interface Specification (ASIS). It is a separate product
which is not included in the standard GNAT distribution. However, the
binary executables for tools created on top of ASIS-for-GNAT do not require
ASIS-for-GNAT installed on your system and they can be used for a standard
GNAT distribution along with other GNAT tools

</P>


<H2><A NAME="SEC125" HREF="gnat_ug_toc.html#TOC125">Tree Files</A></H2>
<P>
<A NAME="IDX300"></A>
<A NAME="IDX301"></A>

</P>
<P>
The ASIS implementation for GNAT is based on tree output files (or, simply,
tree files). A tree file stores a snapshot of the compiler internal data
structures in the very end of a successful compilation. It contains all the
syntactical and semantic information about the unit being compiled and all the
units upon which it depends semantically. ASIS-for-GNAT (and, therefore, any
tool based on its top) processes tree files, extracts this information from it
and converts it into the format prescribing by the ASIS definition.

</P>
<P>
To use some ASIS-based tools, a user should take care of producing the right
set of tree files for the tool, some other ASIS tools produce a needed set of
tree files themselves.

</P>
<P>
GNAT produces a tree file if -gnatt option is set when calling gcc. ASIS needs
tree files created in "compile-only" GNAT mode set by -gnatc gcc switch. Names
of the tree files are obtained by replacing 'd' with 't' in the extension of
the name of the source file being compiled.

</P>
<P>
Therefore, to produce a tree file for the body of a procedure Foo contained in
the source file named 'foo.adb', you can compile it using

</P>

<PRE>
   $ gcc -c -gnatc -gnatt foo.adb
</PRE>

<P>
and you will get the tree file named 'foo.atb' as a result of this
compilation.

</P>


<H1><A NAME="SEC126" HREF="gnat_ug_toc.html#TOC126">Creating Sample Bodies Using <CODE>gnatstub</CODE></A></H1>
<P>
<A NAME="IDX302"></A>

</P>
<P>
<CODE>gnatstub</CODE> creates body samples - that is, empty but compilable bodies for
library unit declarations.

</P>
<P>
<CODE>gnatstub</CODE> is an ASIS-based tool, but it creates a needed tree
file itself, so it can be considered as a usual command-line utility
program when using with GNAT.

</P>
<P>
To create a body sampler, <CODE>gnatstub</CODE> has to compile the library
unit declaration. Therefore, bodies can be created only for legal
library units. Moreover, if a library unit depends semantically upon
units located not only in the current directory, you have to provide
a source search path when calling gnatstub, see the description of
gnatstub switches below.

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC127">Running gnatstub</A>
<LI><A HREF="gnat_ug.html#SEC128">Switches for gnatstub</A>
</UL>



<H2><A NAME="SEC127" HREF="gnat_ug_toc.html#TOC127">Running <CODE>gnatstub</CODE></A></H2>

<P>
<CODE>gnatstub</CODE> has the command-line interface of the form

</P>

<PRE>
   $ gnatstub [switches] filename [directory]
</PRE>

<P>
where
<DL COMPACT>

<DT><CODE>filename</CODE>
<DD>
is the name of a source file containing a library unit declaration to
create a body for. This name should follow the GNAT file name
conventions. No crunching is allowed for this file name. The file
name may contain the path information.

<DT><CODE>directory</CODE>
<DD>
indicates the directory to place a sample body (default is the
current directory)

<DT><CODE>switches</CODE>
<DD>
is an optional sequence of switches as described in the next section
</DL>



<H2><A NAME="SEC128" HREF="gnat_ug_toc.html#TOC128">Switches for <CODE>gnatstub</CODE></A></H2>

<DL COMPACT>

<DT><CODE>-f</CODE>
<DD>
Replace an existing body file (if any) with a body sample. If the
destination directory already contains a file which name has a form
of the body file for the argument spec file, gnatstub replaces it
with the body sample if <CODE>-f</CODE> switch is set or leaves it intact
otherwise.

<DT><CODE>-hs</CODE>
<DD>
Put in body sample the comment header from the source of the library unit
declaration ("comment header" is all the comments preceding the compilation
unit).

<DT><CODE>-hg</CODE>
<DD>
Put in body sample a sample comment header

<DT><CODE>-IDIR</CODE>
<DD>
<DT><CODE>-I-</CODE>
<DD>
These switches have just the same meaning as in calls to gcc or
gnatmake. They are used to define the source search path in the call
to gcc issued by gnatstub to compile an argument source file to
create a tree file.

<DT><CODE>-i<VAR>n</VAR></CODE>
<DD>
(<VAR>n</VAR> is a decimal natural number). Sets the indentation level in the
generated body sample to n, '-i0' means "no indentation",
the default indentation is 3.

<DT><CODE>-k</CODE>
<DD>
Do not remove the tree file: as default, after creating the body
sampler gnatstub removes from the current directory the tree file
created for the argument source file. <CODE>-k</CODE> prevents deleting the
tree file.

<DT><CODE>-l<VAR>n</VAR></CODE>
<DD>
(<VAR>n</VAR> is a decimal positive number) Sets maximum line length in a
body sample to n, the default line length is 78.

<DT><CODE>-q</CODE>
<DD>
Quiet mode: gnatstub does not generate a confirmation when a body is
successfully created or a message when a body is not required for an
argument unit.

<DT><CODE>-r</CODE>
<DD>
Reuse the tree file (if any) instead of creating it: instead of
creating the tree file for the library unit declaration, gnatstub
tries to find it in the current directory and to use it for creating
a body. If the tree file is not found, no body is created. <CODE>-r</CODE>
also implies <CODE>-k</CODE>, whether or not
<CODE>-k</CODE> is set explicitly.

<DT><CODE>-t</CODE>
<DD>
Overwrite the existing tree file: if the current directory already
contains the file which, according to the GNAT file name rules should
be considered as a tree file for the argument source file, gnatstub
will refuse to create the tree file needed to create a body sampler,
unless <CODE>-t</CODE> option is set

<DT><CODE>-v</CODE>
<DD>
Verbose mode: gnatstub generates version information.

</DL>



<H1><A NAME="SEC129" HREF="gnat_ug_toc.html#TOC129">Minimizing Executables for Ada Programs Using <CODE>gnatelim</CODE></A></H1>
<P>
<A NAME="IDX303"></A>

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC130">About gnatelim</A>
<LI><A HREF="gnat_ug.html#SEC131">Eliminate pragma</A>
<LI><A HREF="gnat_ug.html#SEC132">Preparing Tree and Bind Files for gnatelim</A>
<LI><A HREF="gnat_ug.html#SEC133">Running gnatelim</A>
<LI><A HREF="gnat_ug.html#SEC134">Correcting the List of Eliminate Pragmas</A>
<LI><A HREF="gnat_ug.html#SEC135">Making your Executables smaller</A>
<LI><A HREF="gnat_ug.html#SEC136">Summary of the gnatelim Usage Cycle</A>
</UL>



<H2><A NAME="SEC130" HREF="gnat_ug_toc.html#TOC130">About <CODE>gnatelim</CODE></A></H2>

<P>
When a program shares a set of Ada
packages with other programs, it may happen that this program uses
only a fraction of the subprograms defined in these packages. The code
created for those unused subprograms increases the size of the executable.

</P>
<P>
<CODE>gnatelim</CODE> is a utility tracking unused subprograms in an Ada
program. Its output consists of a list of <CODE>Eliminate</CODE> pragmas
marking all the subprograms that are declared, but never called in a
given program. <CODE>Eliminate</CODE> is a GNAT-specific pragma, it is
described in the next section. By placing the list of
<CODE>Eliminate</CODE> pragmas in the GNAT configuration file
<TT>`gnat.adc'</TT> and recompiling your program, you may decrease the
size of its executable, because the compiler will not generate code
for those unused subprograms.

</P>
<P>
<CODE>gnatelim</CODE> is an ASIS-based tool, and it needs as its input data
a set of tree files representing all the components of a program to
process. It also needs a bind file for a main subprogram. (See
section <A HREF="gnat_ug.html#SEC132">Preparing Tree and Bind Files for <CODE>gnatelim</CODE></A> for full details)

</P>


<H2><A NAME="SEC131" HREF="gnat_ug_toc.html#TOC131"><CODE>Eliminate</CODE> pragma</A></H2>
<P>
<A NAME="IDX304"></A>

</P>
<P>
The syntax of Eliminate pragma is

</P>

<PRE>
   <B>pragma</B> Eliminate (Library_Unit_Name, Subprogram_Name);
</PRE>

<DL COMPACT>

<DT><CODE>Library_Unit_Name</CODE>
<DD>
full expanded Ada name of a library unit

<DT><CODE>Subprogram_Name</CODE>
<DD>
a simple or expanded name of a subprogram declared within this
compilation unit

</DL>

<P>
The effect of an Eliminate pragma placed in the GNAT configuration
file <TT>`gnat.adc'</TT> is:

</P>

<UL>

<LI>

If the subprogram denoted by <CODE>Subprogram_Name</CODE> is declared within
the library unit having <CODE>Library_Unit_Name</CODE> as its defining program
unit name, then the compiler will not generate code for this subprogram.
It applies to all overloaded subprograms denoted by
<CODE>Subprogram_Name</CODE>.

<LI>

If a subprogram mentioned in some <CODE>Eliminate</CODE> pragma as unused is
actually used (called) in a program, then the compiler will produce a
diagnosis in place where it is called.
</UL>



<H2><A NAME="SEC132" HREF="gnat_ug_toc.html#TOC132">Preparing Tree and Bind Files for <CODE>gnatelim</CODE></A></H2>

<P>
<CODE>gnatelim</CODE> can process only full Ada programs (partitions) and
it needs a set of tree files representing the whole program
(partition) to be presented in the current directory. It also needs a
bind file for the main subprogram of the program (partition) to be
presented in the current directory.

</P>
<P>
Let <CODE>Main_Prog</CODE> be the name of a main subprogram, and suppose
this subprogram is in a file named <TT>`main_prog.ads'</TT> or
<TT>`main_prog.adb'</TT>.

</P>
<P>
To create a minimal set of tree files covering the whole program, call
<CODE>gnatmake</CODE> for this program as follows:

</P>

<PRE>
   $ gnatmake -c -f -gnatc -gnatt Main_Prog
</PRE>

<P>
The <CODE>-c gnatmake</CODE> option turns off the bind and link phases,
which are impossible anyway, because sources are compiled with
<CODE>-gnatc</CODE> option, which turns off code generation.

</P>
<P>
 the <CODE>-f</CODE> gnatmake option is used to force
recompilation of all the needed sources.

</P>
<P>
To create a bind file for <CODE>gnatelim</CODE>, run <CODE>gnatbind</CODE> for
the main subprogram. <CODE>gnatelim</CODE> can work with either an Ada or a C
bind file, if both are present, it works with the Ada bind file.
To avoid problems with creating a consistent data for
<CODE>gnatelim</CODE>, it is advised to use the following procedure. It creates all
the data needed by <CODE>gnatelim</CODE> from scratch and therefore
guarantees their consistency:

</P>

<OL>
<LI>

creating a bind file:


<PRE>
   $ gnatmake -c Main_Prog
   $ gnatbind main_prog
</PRE>

<LI>

creating a set of tree files:


<PRE>
   $ gnatmake -f -c -gnatc -gnatt Main_Prog
</PRE>

</OL>

<P>
Note, that <CODE>gnatelim</CODE> needs neither object nor ALI files, so they
can be deleted at this stage.

</P>


<H2><A NAME="SEC133" HREF="gnat_ug_toc.html#TOC133">Running <CODE>gnatelim</CODE></A></H2>

<P>
gnatelim has the following command-line interface:

</P>

<PRE>
   $ gnatelim [options] name
</PRE>

<P>
<CODE>name</CODE> should be a full expanded Ada name of a main subprogram
of a program (partition).

</P>
<P>
gnatelim options:

</P>
<DL COMPACT>

<DT><CODE>-v</CODE>
<DD>
Verbose mode: gnatelim version information is printed (in the form of Ada
comments) to the standard output file. Various debugging information and
information reflecting some details of the analysis doing by gnatelim are
output to the standard error file.

<DT><CODE>-a</CODE>
<DD>
Will also indicate subprograms from the GNAT runtime that could be
eliminated.

<DT><CODE>-m</CODE>
<DD>
Will check if tree files are missing for an accurate result.
</DL>

<P>
<CODE>gnatelim</CODE> directs its output to the standard output,
so to produce a proper GNAT configuration file
<TT>`gnat.adc'</TT>, redirection can be used:

</P>

<PRE>
   $ gnatelim Main_Prog &#62; gnat.adc
</PRE>

<P>
or

</P>

<PRE>
   $ gnatelim Main_Prog &#62;&#62; gnat.adc
</PRE>

<P>
In order to append the gnatelim output to the existing contents of
<TT>`gnat.adc'</TT>.

</P>


<H2><A NAME="SEC134" HREF="gnat_ug_toc.html#TOC134">Correcting the List of Eliminate Pragmas</A></H2>

<P>
It may happen that <CODE>gnatelim</CODE> try to eliminate subprograms which
cannot really be eliminated because they are actually called in the
program although this only happens in very rare cases. In this case, the
compiler will generate an error message of the form:

</P>

<PRE>
   file.adb:106:07: cannot call eliminated subprogram "My_Prog"
</PRE>

<P>
You have to correct the <TT>`gnat.adc'</TT> file manually by suppressing
the faulty Eliminate pragmas. It is advised to recompile your program
from scratch after that, because you need a consistent
<TT>`gnat.adc'</TT> file during the complete compilation in order to get
an meaningful result.

</P>


<H2><A NAME="SEC135" HREF="gnat_ug_toc.html#TOC135">Making your Executables smaller</A></H2>

<P>
To get a smaller executable for your program, you have to recompile
the program completely, having the <TT>`gnat.adc'</TT> file with a set of
<CODE>Eliminate</CODE> pragmas created by <CODE>gnatelim</CODE> in your current
directory:

</P>

<PRE>
   $ gnatmake -f Main_Prog
</PRE>

<P>
(you will need <CODE>-f</CODE> option for gnatmake to
recompile everything
with the set of pragmas <CODE>Eliminate</CODE> you have got from
<CODE>gnatelim</CODE>).

</P>
<P>
Be aware that a set of <CODE>Eliminate</CODE> pragmas is specific to each
program. Therefore, it is not advised to merge sets of <CODE>Eliminate</CODE>
pragmas created for different programs in one <TT>`gnat.adc'</TT> file.

</P>


<H2><A NAME="SEC136" HREF="gnat_ug_toc.html#TOC136">Summary of the gnatelim Usage Cycle</A></H2>

<P>
Here is a summary of the steps to be taken in order to reduce the size of
your executables with <CODE>gnatelim</CODE>. You may use
other GNAT options to control the optimization level,
to produce the debugging information, to set search path, etc.

</P>

<OL>
<LI>

Produce a bind file and a set of tree files


<PRE>
   $ gnatmake -c Main_Prog
   $ gnatbind main_prog
   $ gnatmake -f -c -gnatc -gnatt Main_Prog
</PRE>

<LI>

Generate a list of <CODE>Eliminate</CODE> pragmas

<PRE>
   $ gnatelim Main_Prog &#62;[&#62;] gnat.adc
</PRE>

<LI>

Recompile the application


<PRE>
   $ gnatmake -f Main_Prog
</PRE>

</OL>



<H1><A NAME="SEC137" HREF="gnat_ug_toc.html#TOC137">Other Utility Programs</A></H1>

<P>
This chapter discusses some other utility programs available in the Ada
environment.

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC138">Using Other Utility Programs With GNAT</A>
<LI><A HREF="gnat_ug.html#SEC139">The gnatpsys Utility Program</A>
<LI><A HREF="gnat_ug.html#SEC140">The gnatpsta Utility Program</A>
<LI><A HREF="gnat_ug.html#SEC141">The External Symbol Naming Scheme of GNAT</A>
<LI><A HREF="gnat_ug.html#SEC142">Ada Mode for emacs</A>
<LI><A HREF="gnat_ug.html#SEC146">Converting Ada files to html using gnathtml</A>
<LI><A HREF="gnat_ug.html#SEC147">Installing gnathtml</A>
</UL>



<H2><A NAME="SEC138" HREF="gnat_ug_toc.html#TOC138">Using Other Utility Programs With GNAT</A></H2>

<P>
The object files generated by GNAT are in standard system format and in
particular the debugging information uses this format. This means
programs generated by GNAT can be used with existing utilities that
depend on these formats.

</P>
<P>
In general, any utility program that works with C will also often work with
Ada programs generated by GNAT. This includes software utilities such as
gprof (a profiling program), gdb (the FSF debugger), and utilities such
as Purify.

</P>


<H2><A NAME="SEC139" HREF="gnat_ug_toc.html#TOC139">The <CODE>gnatpsys</CODE> Utility Program</A></H2>

<P>
Many of the definitions in package System are implementation-dependent.
Furthermore, although the source of the package System is available
for inspection, it uses special attributes for parameterizing many of
the critical values, so the source is not informative for the casual user.

</P>
<P>
The <CODE>gnatpsys</CODE> utility is designed to deal with this situation.
It is an Ada program that dynamically determines the
values of all the relevant parameters in System, and prints them
out in the form of an Ada source listing for System, displaying all
the values of interest. This output is generated to
<TT>`stdout'</TT>.

</P>
<P>
To determine the value of any parameter in package System, simply
run <CODE>gnatpsys</CODE> with no qualifiers or arguments, and examine
the output. This is preferable to consulting documentation, because
you know that the values you are getting are the actual ones provided
by the executing system.

</P>


<H2><A NAME="SEC140" HREF="gnat_ug_toc.html#TOC140">The <CODE>gnatpsta</CODE> Utility Program</A></H2>

<P>
Many of the definitions in package Standard are implementation-dependent.
However, the source of this package does not exist as an Ada source
file, so these values cannot be determined by inspecting the source.
They can be determined by examining in detail the coding of
<TT>`cstand.adb'</TT> which creates the image of Standard in the compiler,
but this is awkward and requires a great deal of internal knowledge
about the system.

</P>
<P>
The <CODE>gnatpsta</CODE> utility is designed to deal with this situation.
It is an Ada program that dynamically determines the
values of all the relevant parameters in Standard, and prints them
out in the form of an Ada source listing for Standard, displaying all
the values of interest. This output is generated to
<TT>`stdout'</TT>.

</P>
<P>
To determine the value of any parameter in package Standard, simply
run <CODE>gnatpsta</CODE> with no qualifiers or arguments, and examine
the output. This is preferable to consulting documentation, because
you know that the values you are getting are the actual ones provided
by the executing system.

</P>


<H2><A NAME="SEC141" HREF="gnat_ug_toc.html#TOC141">The External Symbol Naming Scheme of GNAT</A></H2>

<P>
In order to interpret the output from GNAT, when using tools that are
originally intended for use with other languages, it is useful to
understand the conventions used to generate link names from the Ada
entity names.

</P>
<P>
All link names are in all lowercase letters. With the exception of library
procedure names, the mechanism used is simply to use the full expanded
Ada name with dots replaced by double underscores. For example, suppose
we have the following package spec:

</P>

<PRE>
   <B>package</B> QRS <B>is</B>
      MN : Integer;
   <B>end</B> QRS;
</PRE>

<P>
The variable <CODE>MN</CODE> has a full expanded Ada name of <CODE>QRS.MN</CODE>, so
the corresponding link name is <CODE>qrs__mn</CODE>.
<A NAME="IDX305"></A>
Of course if a <CODE>pragma Export</CODE> is used this may be overridden:

</P>

<PRE>
   <B>package</B> Exports <B>is</B>
      Var1 : Integer;
      <B>pragma</B> Export (Var1, C, External_Name =&#62; "var1_name");
      Var2 : Integer;
      <B>pragma</B> Export (Var2, C, Link_Name =&#62; "var2_link_name");
   <B>end</B> Exports;
</PRE>

<P>
In this case, the link name for <VAR>Var1</VAR> is <VAR>var1_name</VAR>, and the
link name for <VAR>Var2</VAR> is <VAR>var2_link_name</VAR>.

</P>
<P>
<A NAME="IDX306"></A>
One exception occurs for library level procedures. A potential ambiguity
arises between the required name <CODE>_main</CODE> for the C main program,
and the name we would otherwise assign to an Ada library level procedure
called <CODE>Main</CODE> (which might well not be the main program).

</P>
<P>
To avoid this ambiguity, we attach the prefix <CODE>_ada_</CODE> to such
names. So if we have a library level procedure such as

</P>

<PRE>
   <B>procedure</B> Hello (S : String);
</PRE>

<P>
the external name of this procedure will be <VAR>_ada_hello</VAR>.

</P>


<H2><A NAME="SEC142" HREF="gnat_ug_toc.html#TOC142">Ada Mode for <CODE>emacs</CODE></A></H2>

<P>
The Emacs mode for programming in Ada (both, Ada83 and Ada95) helps the
user in understanding existing code and facilitates writing new code.  It
furthermore provides some utility functions for easier integration of
standard Emacs features when programming in Ada.

</P>


<H2><A NAME="SEC143" HREF="gnat_ug_toc.html#TOC143">General features:</A></H2>


<UL>
<LI>

Full Integrated Development Environment :
  @itemize @bullet
  @item
  support of 'project files' for the configuration (directories,
  compilation options,...)

  @item
  compiling and stepping through error messages.

  @item
  running and debugging your applications within Emacs.
  @end itemize

<LI>

easy to use for beginners by pull-down menus,

<LI>

user configurable by many user-option variables.
</UL>



<H2><A NAME="SEC144" HREF="gnat_ug_toc.html#TOC144">Ada mode features that help understanding code:</A></H2>


<UL>
<LI>

functions for easy and quick stepping through Ada code,

<LI>

getting cross reference information for identifiers (e.g. find the
defining place by a keystroke),

<LI>

displaying an index menu of types and subprograms and move point to
the chosen one,

<LI>

automatic color highlighting of the various entities in Ada code.
</UL>



<H2><A NAME="SEC145" HREF="gnat_ug_toc.html#TOC145">Emacs support for writing Ada code:</A></H2>


<UL>
<LI>

switching between spec and body files with possible
autogeneration of body files,

<LI>

automatic formating of subprograms parameter lists.

<LI>

automatic smart indentation according to Ada syntax,

<LI>

automatic completion of identifiers,

<LI>

automatic casing of identifiers, keywords, and attributes,

<LI>

insertion of statement templates,

<LI>

filling comment paragraphs like filling normal text,
</UL>

<P>
For more information, please see See section <A HREF="gnat_ug.html#SEC142">Ada Mode for <CODE>emacs</CODE></A>.

</P>



<H2><A NAME="SEC146" HREF="gnat_ug_toc.html#TOC146">Converting Ada files to html using gnathtml</A></H2>

<P>
This <CODE>Perl</CODE> script allows Ada source files to be browsed using
standard Web browsers. For installation procedure, see the section
See section <A HREF="gnat_ug.html#SEC147">Installing gnathtml</A>.

</P>
<P>
Ada reserved keywords are highlighted in a bold font and Ada comments in
a blue font. Unless your program was compiled with the gcc <CODE>-gnatx</CODE>
switch to suppress the generation of cross-referencing information, user
defined variables and types will appear in a different color; you will
be able to click on any identifier and go to its declaration.

</P>
<P>
The command line is as follow:

<PRE>
   $ perl gnathtml.pl [switches] ada-files
</PRE>

<P>
You can pass it as many Ada files as you want. <CODE>gnathtml</CODE> will generate
an html file for every ada file, and a global file called <TT>`index.htm'</TT>.
This file is an index of every identifier defined in the files.

</P>
<P>
The available switches are the following ones :

</P>
<DL COMPACT>

<DT><CODE>-83</CODE>
<DD>
<A NAME="IDX307"></A>
Only the subset on the Ada 83 keywords will be highlighted, not the full
Ada 95 keywords set.

<DT><CODE>-cc <VAR>color</VAR></CODE>
<DD>
This options allows you to change the color used for comments. The default
value is green. The color argument can be any name accepted by html.

<DT><CODE>-d</CODE>
<DD>
<A NAME="IDX308"></A>
If the ada files depend on some other files (using for instance the
<CODE>with</CODE> command, the latter will also be converted to html.
Only the files in the user project will be converted to html, not the files
in the runtime library itself.

<DT><CODE>-D</CODE>
<DD>
This command is the same as -d above, but <CODE>gnathtml</CODE> will also look
for files in the runtime library, and generate html files for them.

<DT><CODE>-f</CODE>
<DD>
<A NAME="IDX309"></A>
By default, gnathtml will generate html links only for global entities
('with'ed units, global variables and types,...). If you specify the
<CODE>-f</CODE> on the command line, then links will be generated for local
entities too.

<DT><CODE>-l <VAR>number</VAR></CODE>
<DD>
<A NAME="IDX310"></A>
If this switch is provided and <VAR>number</VAR> is not 0, then <CODE>gnathtml</CODE>
will number the html files every <VAR>number</VAR> line.

<DT><CODE>-I <VAR>dir</VAR></CODE>
<DD>
<A NAME="IDX311"></A>
Specify a directory to search for library files (<TT>`.ali'</TT> files) and
source files. You can provide several -I switches on the command line,
and the directories will be parsed in the order of the command line.

<DT><CODE>-o <VAR>dir</VAR></CODE>
<DD>
<A NAME="IDX312"></A>
Specify the output directory for html files. By default, gnathtml will
saved the generated html files in a subdirectory named <TT>`html/'</TT>.

<DT><CODE>-p <VAR>file</VAR></CODE>
<DD>
<A NAME="IDX313"></A>
If you are using Emacs and the most recent Emacs Ada mode, which provides
a full Integrated Development Environment for compiling, checking,
running and debugging applications, you may be using <TT>`.adp'</TT> files
to give the directories where Emacs can find sources and object files.

Using this switch, you can tell gnathtml to use these files. This allows
you to get an html version of your application, even if it is spread
over multiple directories.

<DT><CODE>-sc <VAR>color</VAR></CODE>
<DD>
This options allows you to change the color used for symbol definitions.
The default value is red. The color argument can be any name accepted by html.

</DL>



<H2><A NAME="SEC147" HREF="gnat_ug_toc.html#TOC147">Installing gnathtml</A></H2>

<P>
<CODE>Perl</CODE> needs to be installed on your machine to run this script.
<CODE>Perl</CODE> is freely available for almost every architecture and
Operating System via the Internet.

</P>
<P>
On Unix systems, you  may want to modify  the  first line of  the script
<CODE>gnathtml</CODE>,  to explicitly  tell  the Operating  system  where Perl
is. The syntax of this line is :

<PRE>
   #!full_path_name_to_perl
</PRE>

<P>
Alternatively, you may run the script using the following command line:

</P>

<PRE>
   $ perl gnathtml.pl [switches] files
</PRE>



<H1><A NAME="SEC148" HREF="gnat_ug_toc.html#TOC148">Running and Debugging Ada Programs</A></H1>
<P>
<A NAME="IDX314"></A>

</P>
<P>
This chapter discusses how to debug Ada programs. An incorrect Ada program
may be handled in three ways by the GNAT compiler:

</P>

<OL>
<LI>

The illegality may be a violation of the static semantics of Ada. In
that case GNAT diagnoses the constructs in the program that are illegal.
It is then a straightforward matter for the user to modify those parts of
the program.

<LI>

The illegality may be a violation of the dynamic semantics of Ada. In
that case the program compiles and executes, but may generate incorrect
results, or may terminate abnormally with some exception.

<LI>

When presented with a program that contains convoluted errors, GNAT
itself may terminate abnormally without providing full diagnostics on
the incorrect user program.
</OL>


<UL>
<LI><A HREF="gnat_ug.html#SEC149">The GNAT Debugger GDB</A>
<LI><A HREF="gnat_ug.html#SEC150">Running GDB</A>
<LI><A HREF="gnat_ug.html#SEC151">Introduction to GDB Commands</A>
<LI><A HREF="gnat_ug.html#SEC152">Using Ada Expressions</A>
<LI><A HREF="gnat_ug.html#SEC153">Calling User-Defined Subprograms</A>
<LI><A HREF="gnat_ug.html#SEC154">Ada Exceptions</A>
<LI><A HREF="gnat_ug.html#SEC155">Ada Tasks</A>
<LI><A HREF="gnat_ug.html#SEC156">Debugging Generic Units</A>
<LI><A HREF="gnat_ug.html#SEC157">GNAT Abnormal Termination</A>
<LI><A HREF="gnat_ug.html#SEC158">Naming Conventions for GNAT Source Files</A>
<LI><A HREF="gnat_ug.html#SEC159">Getting Internal Debugging Information</A>
</UL>

<P>
<A NAME="IDX315"></A>
<A NAME="IDX316"></A>

</P>


<H2><A NAME="SEC149" HREF="gnat_ug_toc.html#TOC149">The GNAT Debugger GDB</A></H2>

<P>
GDB is a general purpose, platform-independent debugger that can be used to
debug mixed-language programs compiled with GCC, and in particular
is capable of debugging Ada programs compiled with GNAT. The latest
versions of GDB are Ada-aware and can handle complex Ada data structures.
The manual <CITE>Debugging with GDB</CITE>
contains full details on the usage of GDB, including a section on its usage
on programs. This manual should be consulted for full details. The section
that follows is a brief introduction to the philosophy and use of GDB.

</P>
<P>
When GNAT programs are compiled, the compiler optionally writes debugging
information into the generated object file, including information on
line numbers, and on declared types and variables. This information is
separate from the generated code. It makes the object files considerably
larger, but it does not add to the size of the actual executable that
will be loaded into memory, and has no impact on run-time performance. The
generation of debug information is triggered by the use of the
-g switch in the gcc or gnatmake command used to carry out
the compilations. It is important to emphasize that the use of these
options does not change the generated code.

</P>
<P>
The debugging information is written in standard system
formats that are used
by many tools, including debuggers and profilers. The format of the
information is typically designed to describe C types and semantics,
but GNAT implements a translation scheme which allows full details about
Ada types and variables to be encoded into these standard C
formats. Details of this encoding scheme may be found in the file
exp_dbug.ads in the GNAT source distribution. However, the
details of this encoding are, in general, of no interest to a user, since GDB
automatically performs the necessary decoding.

</P>
<P>
When a program is bound and linked, the debugging information is
collected from the object files, and stored in the executable image of
the program. Again, this process significantly increases the size
of the generated executable file,
but it does not increase the size of the
executable program itself. Furthermore, if this program
is run in the normal manner, it runs exactly as if the debug
information were not present, and takes no more actual memory.

</P>
<P>
However, if the program is run under control of GDB, the debugger is activated.
The image of the program is loaded, at which point it is ready to run.
If a run command is
given, then the program will run exactly as it would have if GDB
were not present. This is a crucial part of the GDB design philosophy.
GDB is entirely non-intrusive until a breakpoint is encountered.
If no breakpoint is ever hit, the program will run exactly as it
would if no debugger were present. When a breakpoint is hit,
GDB accesses the debugging information and can respond to user
commands to inspect variables, and more generally to report on the state of
execution.

</P>



<H2><A NAME="SEC150" HREF="gnat_ug_toc.html#TOC150">Running GDB</A></H2>

<P>
The debugger can be launched directly and simply from emacs which allows
to browse and modify directly the source code during the debugging
session, See section <A HREF="gnat_ug.html#SEC142">Ada Mode for <CODE>emacs</CODE></A>. Here is described the basic use of
GDB is text mode.

</P>
<P>
The command to run GDB is

</P>

<PRE>
   $ gdb program
</PRE>

<P>
where <CODE>program</CODE> is the name of the executable file. This
activates the debugger and results in a prompt for debugger commands.
The simplest command is simply <CODE>run</CODE>, which causes the program to run
exactly as if the debugger were not present. The following section
describes some of the additional commands that can be given to GDB.

</P>


<H2><A NAME="SEC151" HREF="gnat_ug_toc.html#TOC151">Introduction to GDB Commands</A></H2>

<P>
GDB contains a large repertoire of commands. The manual
<CITE>Debugging with GDB</CITE>
includes extensive documentation on the use
of these commands, together with examples of their use. Furthermore,
the command <VAR>help</VAR> invoked from within GDB activates a simple help
facility which summarizes the available commands and their options.
In this section we summarize a few of the most commonly
used commands to give an idea of what GDB is about. You should create
a simple program with debugging information and experiment with the use of
these GDB commands on the program as you read through the following section.

</P>
<DL COMPACT>

<DT><CODE>set args <VAR>arguments</VAR></CODE>
<DD>
The <VAR>arguments</VAR> list above is a list of arguments to be passed to
the program on a subsequent run command, just as though the arguments
had been entered on a normal invocation of the program. The <CODE>set args</CODE>
command is not needed if the program does not require arguments.

<DT><CODE>run</CODE>
<DD>
The <CODE>run</CODE> command causes execution of the program to start from the
beginning. If the program is already running, that is to say if you
are currently positioned  at a breakpoint,
then a prompt will ask for confirmation that you want
to abandon the current execution and restart.

<DT><CODE>breakpoint <VAR>location</VAR></CODE>
<DD>
The breakpoint command sets a breakpoint, that is to say a point at which
execution will halt and GDB will await further commands. <VAR>location</VAR> is
either a line number within a file, given in the format <CODE>file:linenumber</CODE>,
or it is the name of a subprogram. If you request that a breakpoint be set on
a subprogram that is overloaded, a prompt will ask you to specify on which of
those subprograms you want to breakpoint. You can also
specify that all of them should be breakpointed. If the program is run
and execution encounters the breakpoint, then the program
stops and GDB signals that the breakpoint was encountered by printing the
line of code before which the program is halted.

<DT><CODE>breakpoint exception <VAR>name</VAR></CODE>
<DD>
A special form of the breakpoint command which breakpoints whenever
exception <VAR>name</VAR> is raised.
If <VAR>name</VAR> is omitted,
then a breakpoint will occur when any exception is raised.

<DT><CODE>print <VAR>expression</VAR></CODE>
<DD>
This will print the value of the given expression. Most simple
Ada expression formats are properly handled by GDB, so the expression
can contain function calls, variables, operators, and attribute references.

<DT><CODE>continue</CODE>
<DD>
Continues execution following a breakpoint, until the next breakpoint or the
termination of the program.

<DT><CODE>step</CODE>
<DD>
Executes a single line after a breakpoint. If the next statement is a subprogram
call, execution continues into (the first statement of) the
called subprogram.

<DT><CODE>next</CODE>
<DD>
Executes a single line. If this line is a subprogram call, executes and
returns from the call.

<DT><CODE>list</CODE>
<DD>
Lists a few lines around the current source location. In practice, it
is usually more convenient to have a separate edit window open with the
relevant source file displayed. Successive applications of this command
print subsequent lines. The command can be given an argument which is a
line number, in which case it displays a few lines around the specified one.

<DT><CODE>backtrace</CODE>
<DD>
Displays a backtrace of the call chain. This command is typically
used after a breakpoint has occurred, to examine the sequence of calls that
leads to the current breakpoint. The display includes one line for each
activation record (frame) corresponding to an active subprogram.

<DT><CODE>up</CODE>
<DD>
At a breakpoint, GDB can display the values of variables local
to the current frame. The command <CODE>up</CODE> can be used to
examine the contents of other active frames, by moving the focus up
the stack, that is to say from callee to caller, one frame at a time.

<DT><CODE>down</CODE>
<DD>
Moves the focus of GDB down from the frame currently being examined to the
frame of its callee (the reverse of the previous command),

<DT><CODE>frame <VAR>n</VAR></CODE>
<DD>
Inspect the frame with the given number. The value 0 denotes the frame
of the current breakpoint, that is to say the top of the call stack.

</DL>

<P>
The above list is a very short introduction to the commands that
GDB provides. Important additional capabilities, including conditional
breakpoints, the ability to execute command sequences on a breakpoint,
the ability to debug at the machine instruction level and many other
features are described in detail in <CITE>Debugging with GDB</CITE>.
Note that most commands can be abbreviated
(for example, c for continue, bt for backtrace).

</P>


<H2><A NAME="SEC152" HREF="gnat_ug_toc.html#TOC152">Using Ada Expressions</A></H2>
<P>
<A NAME="IDX317"></A>

</P>
<P>
GDB supports a fairly large subset of Ada expression syntax, with some
extensions. The philosophy behind the design of this subset is

</P>

<UL>
<LI>

That GDB should provide basic literals and access to operations for
arithmetic, dereferencing, field selection, indexing, and subprogram calls,
leaving more sophisticated computations to subprograms written into the
program (which therefore may be called from GDB).

<LI>

That type safety and strict adherence to Ada language restrictions
are not particularly important to the GDB user.

<LI>

That brevity is important to the GDB user.
</UL>

<P>
Thus, for brevity, the debugger acts as if there were
implicit <CODE>with</CODE> and <CODE>use</CODE> clauses in effect for all user-written
packages, thus making it unnecessary to fully qualify most names with
their packages, regardless of context.  Where this causes ambiguity,
GDB asks the user's intent.

</P>
<P>
For details on the supported Ada syntax <CITE>Debugging with GDB</CITE>.

</P>


<H2><A NAME="SEC153" HREF="gnat_ug_toc.html#TOC153">Calling User-Defined Subprograms</A></H2>

<P>
An important capability of GDB is the ability to call user-defined
subprograms while debugging. This is achieved simply by entering
a subprogram call statement in the form:

</P>

<PRE>
   call subprogram-name (parameters)
</PRE>

<P>
The keyword <CODE>call</CODE> can be omitted in the normal case where the
<CODE>subprogram-name</CODE> does not coincide with any of the predefined
GDB commands.

</P>
<P>
The effect is to invoke the given subprogram, passing it the
list of parameters that is supplied. The parameters can be expressions and
can include variables from the program being debugged. The
subprogram must be defined
at the library level within your program, and GDB will call the
subprogram within the environment of your program execution (which
means that the subprogram is free to access or even modify variables
within your program).

</P>
<P>
The most important use of this facility is in allowing the inclusion of
debugging routines that are tailored to particular data structures
in your program. Such debugging routines can be written to provide a suitably
high-level description of an abstract type, rather than a low-level dump
of its physical layout.  After all, the standard
GDB <CODE>print</CODE> command only knows the physical layout of your
types, not their abstract meaning.  Debugging routines can provide information
at the desired semantic level and are thus enormously useful.

</P>
<P>
For example, when debugging GNAT itself, it is crucial to have access to
the contents of the tree nodes used to represent the program internally.
But tree nodes are represented simply by an integer value (which in turn
is an index into a table of nodes).
Using the <CODE>print</CODE> command on a tree node would simply print this integer
value, which is not very useful. But the PN routine (defined in file
treepr.adb in the GNAT sources) takes a tree node as input, and displays
a useful high level representation of the tree node, which includes the
syntactic category of the node, its position in the source, the integers
that denote descendant nodes and parent node, as well as varied
semantic information. To study this example in more detail, you might want to
look at the body of the PN procedure in the stated file.

</P>


<H2><A NAME="SEC154" HREF="gnat_ug_toc.html#TOC154">Breaking on Ada Exceptions</A></H2>
<P>
<A NAME="IDX318"></A>

</P>
<P>
You can set breakpoints that trip when your program raises
selected exceptions.

</P>
<DL COMPACT>

<DT><CODE>break exception</CODE>
<DD>
Set a breakpoint that trips whenever (any task in the) program raises
any exception.

<DT><CODE>break exception <VAR>name</VAR></CODE>
<DD>
Set a breakpoint that trips whenever (any task in the) program raises
the exception <VAR>name</VAR>.

<DT><CODE>break exception unhandled</CODE>
<DD>
Set a breakpoint that trips whenever (any task in the) program raises an
exception for which there is no handler.

<DT><CODE>info exceptions</CODE>
<DD>
<DT><CODE>info exceptions <VAR>regexp</VAR></CODE>
<DD>
The <CODE>info exceptions</CODE> command permits the user to examine all defined
exceptions within Ada programs.  With a regular expression, <VAR>regexp</VAR>, as
argument, prints out only those exceptions whose name matches <VAR>regexp</VAR>.
</DL>



<H2><A NAME="SEC155" HREF="gnat_ug_toc.html#TOC155">Ada Tasks</A></H2>
<P>
<A NAME="IDX319"></A>

</P>
<P>
GDB allows the following task-related commands:

</P>
<DL COMPACT>

<DT><CODE>info tasks</CODE>
<DD>
This command shows a list of current Ada tasks, as in the following example:


<PRE>
   (gdb) info tasks
     ID       TID P-ID   Thread Pri State                 Name
      1   8088000   0   807e000  15 Child Activation Wait main_task
      2   80a4000   1   80ae000  15 Accept/Select Wait    b
      3   809a800   1   80a4800  15 Child Activation Wait a
   *  4   80ae800   3   80b8000  15 Running               c
</PRE>

In this listing, the asterisk before the first task indicates it to be the
currently running task. The first column lists the task ID that is used
to refer to tasks in the following commands.

<DT><CODE>break <VAR>linespec</VAR> task <VAR>taskid</VAR></CODE>
<DD>
<DT><CODE>break <VAR>linespec</VAR> task <VAR>taskid</VAR> if ...</CODE>
<DD>
<A NAME="IDX320"></A>
These commands are like the <CODE>break ... thread ...</CODE>.
<VAR>linespec</VAR> specifies source lines.

Use the qualifier <SAMP>`task <VAR>taskid</VAR>'</SAMP> with a breakpoint command
to specify that you only want GDB to stop the program when a
particular Ada task reaches this breakpoint.  <VAR>taskid</VAR> is one of the
numeric task identifiers assigned by GDB, shown in the first
column of the <SAMP>`info tasks'</SAMP> display.

If you do not specify <SAMP>`task <VAR>taskid</VAR>'</SAMP> when you set a
breakpoint, the breakpoint applies to <EM>all</EM> tasks of your
program.

You can use the <CODE>task</CODE> qualifier on conditional breakpoints as
well; in this case, place <SAMP>`task <VAR>taskid</VAR>'</SAMP> before the
breakpoint condition (before the <CODE>if</CODE>).

<DT><CODE>task <VAR>taskno</VAR></CODE>
<DD>
<A NAME="IDX321"></A>

This command allows to switch to the task referred by <VAR>taskno</VAR>.  In
particular, This allows to browse the backtrace of the specified
task. It is advised to switch back to the original task before
continuing execution otherwise the scheduling of the program may be
perturbated.
</DL>

<P>
For more detailed information on the tasking support <CITE>Debugging with GDB</CITE>.

</P>



<H2><A NAME="SEC156" HREF="gnat_ug_toc.html#TOC156">Debugging Generic Units</A></H2>
<P>
<A NAME="IDX322"></A>

</P>
<P>
GNAT always uses code expansion for generic instantiation. This means that
each time an instantiation occurs, a complete copy of the original code is
made, with appropriate substitutions of formals by actuals.

</P>
<P>
It is not possible to refer to the original generic entities in GDB, but it
is always possible to debug a particular instance of a generic, by using
the appropriate expanded names. For example, if we have

</P>

<PRE>
   <B>procedure</B> g <B>is</B>

      <B>generic package</B> k <B>is</B>
         <B>procedure</B> kp (v1 : <B>in out</B> integer);
      <B>end</B> k;

      <B>package body</B> k <B>is</B>
         <B>procedure</B> kp (v1 : <B>in out</B> integer) <B>is</B>
         <B>begin</B>
            v1 := v1 + 1;
         <B>end</B> kp;
      <B>end</B> k;

      <B>package</B> k1 <B>is new</B> k;
      <B>package</B> k2 <B>is new</B> k;

      var : integer := 1;

   <B>begin</B>
      k1.kp (var);
      k2.kp (var);
      k1.kp (var);
      k2.kp (var);
   <B>end</B>;
</PRE>

<P>
Then to break on a call to procedure kp in the k2 instance, simply
use the command:

</P>

<PRE>
   (gdb) break g.k2.kp
</PRE>

<P>
When the breakpoint occurs, you can step through the code of the
instance in the normal manner and examine the values of local variables, as for
other units.

</P>



<H2><A NAME="SEC157" HREF="gnat_ug_toc.html#TOC157">GNAT Abnormal Termination</A></H2>
<P>
<A NAME="IDX323"></A>

</P>
<P>
When presented with programs that contain serious errors in syntax
or semantics,
GNAT may on rare occasions  experience problems in operation, such
as aborting with a
segmentation fault or illegal memory access, raising an internal
exception, or terminating abnormally. In such cases, you can activate
various features of GNAT that can help you pinpoint the construct in your
program that is the likely source of the problem.

</P>
<P>
The following strategies are presented in increasing order of
difficulty, corresponding to your programming skills and your
familiarity with compiler internals.

</P>

<OL>
<LI>

Run <CODE>gcc</CODE> with the <CODE>-gnatf</CODE> and <CODE>-gnate</CODE> switches. The first
switch causes all errors on a given line to be reported. In its absence,
only the first error on a line is displayed.

The <CODE>-gnate</CODE> switch causes errors to be displayed as soon as they
are encountered, rather than after compilation is terminated. If GNAT
terminates prematurely, the last error message displayed is likely to
pinpoint the culprit.

<LI>

Run <CODE>gcc</CODE> with the <CODE>-v (verbose)</CODE> switch. In this mode,
<CODE>gcc</CODE> produces ongoing information about the progress of the
compilation and provides the name of each procedure as code is
generated. This switch allows you to find which Ada procedure was being
compiled when it encountered a code generation problem.

<LI>

<A NAME="IDX324"></A>
Run <CODE>gcc</CODE> with the <CODE>-gnatdc</CODE> switch. This is a GNAT specific
switch that does for the front-end what <CODE>-v</CODE> does for the back end.
The system prints the name of each unit, either a compilation unit or
nested unit, as it is being analyzed.
<LI>

Finally, you can start
<CODE>gdb</CODE> directly on the <CODE>gnat1</CODE> executable. <CODE>gnat1</CODE> is the
front-end of GNAT, and can be run independently (normally it is just
called from <CODE>gcc</CODE>). You can use <CODE>gdb</CODE> on <CODE>gnat1</CODE> as you
would on a C program (but see section <A HREF="gnat_ug.html#SEC149">The GNAT Debugger GDB</A> for caveats).  The
<CODE>where</CODE> command is the first line of attack; the variable
<CODE>lineno</CODE> (seen by <CODE>print lineno</CODE>), used by the second phase of
<CODE>gnat1</CODE> and by the <CODE>gcc</CODE> backend, indicates the source line at
which the execution stopped, and <CODE>input_file name</CODE> indicates the name of
the source file.
</OL>



<H2><A NAME="SEC158" HREF="gnat_ug_toc.html#TOC158">Naming Conventions for GNAT Source Files</A></H2>

<P>
In order to examine the workings of the GNAT system, the following
brief description of its organization may be helpful:

</P>

<UL>
<LI>

Files with prefix <TT>`sc'</TT> contain the lexical scanner.

<LI>

All files prefixed with <TT>`par'</TT> are components of the parser. The
numbers correspond to chapters of the Ada 95 Reference Manual. For example,
parsing of select statements can be found in <TT>`par-ch9.adb'</TT>.

<LI>

All files prefixed with <TT>`sem'</TT> perform semantic analysis. The
numbers correspond to chapters of the Ada standard. For example, all
issues involving context clauses can be found in <TT>`sem_ch10.adb'</TT>. In
addition, some features of the language require sufficient special processing
to justify their own semantic files: sem_aggr for aggregates, sem_disp for
dynamic dispatching, etc.

<LI>

All files prefixed with <TT>`exp'</TT> perform normalization and
expansion of the intermediate representation (abstract syntax tree, or AST).
these files use the same numbering scheme as the parser and semantics files.
For example, the construction of record initialization procedures is done in
<TT>`exp_ch3.adb'</TT>.

<LI>

The files prefixed with <TT>`bind'</TT> implement the binder, which
verifies the consistency of the compilation, determines an order of
elaboration, and generates the bind file.

<LI>

The files <TT>`atree.ads'</TT> and <TT>`atree.adb'</TT> detail the low-level
data structures used by the front-end.

<LI>

The files <TT>`sinfo.ads'</TT> and <TT>`sinfo.adb'</TT> detail the structure of
the abstract syntax tree as produced by the parser.

<LI>

The files <TT>`einfo.ads'</TT> and <TT>`einfo.adb'</TT> detail the attributes of
all entities, computed during semantic analysis.

<LI>

Library management issues are dealt with in files with prefix
<TT>`lib'</TT>.

<LI>

<A NAME="IDX325"></A>
<A NAME="IDX326"></A>
Ada files with the prefix <TT>`a-'</TT> are children of <CODE>Ada</CODE>, as
defined in Annex A.

<LI>

<A NAME="IDX327"></A>
<A NAME="IDX328"></A>
Files with prefix <TT>`i-'</TT> are children of <CODE>Interfaces</CODE>, as
defined in Annex B.

<LI>

<A NAME="IDX329"></A>
Files with prefix <TT>`s-'</TT> are children of <CODE>System</CODE>. This includes
both language-defined children and GNAT run-time routines.

<LI>

<A NAME="IDX330"></A>
Files with prefix <TT>`g-'</TT> are children of <CODE>GNAT</CODE>. These are useful
general-purpose packages, fully documented in their specifications. All
the other <TT>`.c'</TT> files are modifications of common <CODE>gcc</CODE> files.
</UL>



<H2><A NAME="SEC159" HREF="gnat_ug_toc.html#TOC159">Getting Internal Debugging Information</A></H2>

<P>
Most compilers have internal debugging switches and modes. GNAT
does also, except GNAT internal debugging switches and modes are not
secret. A summary and full description of all the compiler and binder
debug flags are in the file <TT>`debug.adb'</TT>. You must obtain the
sources of the compiler to see the full detailed effects of these flags.

</P>
<P>
The switches that print the source of the program (reconstructed from
the internal tree) are of general interest for user programs, as are the
options to print
the full internal tree, and the entity table (the symbol table
information).  The reconstructed source provides a readable version of the
program after the front-end has completed analysis and  expansion, and is useful
when studying the performance of specific constructs. For example, constraint
checks are indicated, complex aggregates are replaced with loops and
assignments, and tasking primitives are replaced with run-time calls.

</P>



<H1><A NAME="SEC160" HREF="gnat_ug_toc.html#TOC160">Performance Considerations</A></H1>
<P>
<A NAME="IDX331"></A>

</P>
<P>
The GNAT system provides a number of options that allow a trade-off
between

</P>

<UL>
<LI>

performance of the generated code

<LI>

speed of compilation

<LI>

minimization of dependences and recompilation

<LI>

the degree of run-time checking.
</UL>

<P>
The defaults (if no options are selected) aim at improving the speed
of compilation and minimizing dependences, at the expense of performance
of the generated code:

</P>

<UL>
<LI>

no optimization

<LI>

no inlining of subprogram calls

<LI>

all run-time checks enabled except overflow and elaboration checks
</UL>

<P>
These options are suitable for most program development purposes. This
chapter describes how you can modify these choices.

</P>

<UL>
<LI><A HREF="gnat_ug.html#SEC161">Controlling Run-time Checks</A>
<LI><A HREF="gnat_ug.html#SEC162">Optimization Levels</A>
<LI><A HREF="gnat_ug.html#SEC163">Inlining of Subprograms</A>
</UL>



<H2><A NAME="SEC161" HREF="gnat_ug_toc.html#TOC161">Controlling Run-time Checks</A></H2>

<P>
By default, GNAT produces all run-time checks, except arithmetic overflow
checking for integer operations (that includes division by zero) and checks
for access before elaboration on subprogram calls.
<A NAME="IDX332"></A>
<A NAME="IDX333"></A>
Two gnat switches, <CODE>-gnatp</CODE> and <CODE>-gnato</CODE> allow this default to
be modified.  See section <A HREF="gnat_ug.html#SEC39">Run-time Checks</A>.

</P>
<P>
Our experience is that the default is suitable for most development
purposes.

</P>
<P>
We treat integer overflow specially because these
are quite expensive and in our experience are not as important as other
run-time checks in the development process.

</P>
<P>
Elaboration checks are off by default, and also not needed by default, since
GNAT uses a static elaboration analysis approach that avoids the need for
run-time checking. This manual contains a full chapter discussing the issue
of elaboration checks, and if the default is not satisfactory for your use,
you should read this chapter.

</P>
<P>
<A NAME="IDX334"></A>
<A NAME="IDX335"></A>
<A NAME="IDX336"></A>
<A NAME="IDX337"></A>
<A NAME="IDX338"></A>
Note that the setting of the switches controls the default setting of
the checks. They may be modified using either <CODE>pragma Suppress</CODE> (to
remove checks) or <CODE>pragma Unsuppress</CODE> (to add back suppressed
checks) in the program source.

</P>


<H2><A NAME="SEC162" HREF="gnat_ug_toc.html#TOC162">Optimization Levels</A></H2>
<P>
<A NAME="IDX339"></A>

</P>
<P>
The default is optimization off. This results in the fastest compile
times, but GNAT makes absolutely no attempt to optimize, and the
generated programs are considerably larger and slower than when
optimization is enabled. You can use the
<CODE>-O<VAR>n</VAR></CODE> switch, where <VAR>n</VAR> is an integer from 0 to 3,
on the <CODE>gcc</CODE> command line to control the optimization level:

</P>
<DL COMPACT>

<DT><CODE>-O0</CODE>
<DD>
no optimization (the default)

<DT><CODE>-O1</CODE>
<DD>
medium level optimization

<DT><CODE>-O2</CODE>
<DD>
full optimization

<DT><CODE>-O3</CODE>
<DD>
full optimization, and also attempt automatic inlining of small
subprograms within a unit (see section <A HREF="gnat_ug.html#SEC163">Inlining of Subprograms</A>).
</DL>

<P>
Higher optimization levels perform more global transformations on the
program and apply more expensive analysis algorithms in order to generate
faster and more compact code.  The price in compilation time, and the
resulting improvement in execution time,
both depend on the particular application and the hardware environment.
You should experiment to find the best level for your application.

</P>
<P>
Note: Unlike some other compilation systems, <CODE>gcc</CODE> has
been tested extensively at all optimization levels. There are some bugs
which appear only with optimization turned on, but there have also been
bugs which show up only in <EM>unoptimized</EM> code. Selecting a lower
level of optimization does not improve the reliability of the code
generator, which in practice is highly reliable at all optimization
levels.

</P>


<H2><A NAME="SEC163" HREF="gnat_ug_toc.html#TOC163">Inlining of Subprograms</A></H2>

<P>
A call to a subprogram in the current unit is inlined if all the
following conditions are met:

</P>

<UL>
<LI>

The optimization level is at least <CODE>-O1</CODE>.

<LI>

The called subprogram is suitable for inlining: It must be small enough
and not contain nested subprograms or anything else that <CODE>gcc</CODE>
cannot support in inlined subprograms.

<LI>

The call occurs after the definition of the body of the subprogram.

<LI>

<A NAME="IDX340"></A>
Either <CODE>pragma Inline</CODE> applies to the subprogram or it is
small and automatic inlining (optimization level <CODE>-O3</CODE>) is
specified.
</UL>

<P>
Calls to subprograms in <CODE>with</CODE>'ed units are normally not inlined.
To achieve this level of inlining, the following conditions must all be
true:

</P>

<UL>
<LI>

The optimization level is at least <CODE>-O1</CODE>.

<LI>

The called subprogram is suitable for inlining: It must be small enough
and not contain nested subprograms or anything else <CODE>gcc</CODE> cannot
support in inlined subprograms.

<LI>

The call appears in a body (not in a package spec).

<LI>

There is a <CODE>pragma Inline</CODE> for the subprogram.

<LI>

<A NAME="IDX341"></A>
The <CODE>-gnatn</CODE> switch
is used in the <CODE>gcc</CODE> command line
</UL>

<P>
Note that specifying the <CODE>-gnatn</CODE> switch causes additional
compilation dependencies.  Consider the following:

</P>

<PRE>
   <B>package</B> R <B>is</B>
      <B>procedure</B> Q;
      <B>pragma</B> Inline (Q);
   <B>end</B> R;
   <B>package body</B> R <B>is</B>
      ...
   <B>end</B> R;

   <B>with</B> R;
   <B>procedure</B> Main <B>is</B>
   <B>begin</B>
      ...
      R.Q;
   <B>end</B> Main;
</PRE>

<P>
With the default behavior (no <CODE>-gnatn</CODE> switch specified), the
compilation of the <CODE>Main</CODE> procedure depends only on its own source,
<TT>`main.adb'</TT>, and the spec of the package in file <TT>`r.ads'</TT>. This
means that editing the body of <CODE>R</CODE> does not require recompiling
<CODE>Main</CODE>.

</P>
<P>
On the other hand, the call <CODE>R.Q</CODE> is not inlined under these
circumstances. If the <CODE>-gnatn</CODE> switch is present when <CODE>Main</CODE>
is compiled, the call will be inlined if the body of <CODE>Q</CODE> is small
enough, but now <CODE>Main</CODE> depends on the body of <CODE>R</CODE> in
<TT>`r.adb'</TT> as well as on the spec. This means that if this body is edited,
the main program must be recompiled.  Note that this extra dependency
occurs whether or not the call is in fact inlined by <CODE>gcc</CODE>.

</P>
<P>
<A NAME="IDX342"></A>
Note: The <CODE>-fno-inline</CODE> switch
can be used to prevent
all inlining. This switch overrides all other conditions and ensures
that no inlining occurs. The extra dependences resulting from
<CODE>-gnatn</CODE> will still be active, even if
this switch is used to suppress the resulting inlining actions.

</P>



<H1><A NAME="SEC164" HREF="gnat_ug_toc.html#TOC164">Index</A></H1>

<P>
<H2>-</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX213"><CODE>--GCC=compiler_name</CODE> (<CODE>gnatlink</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX217"><CODE>--GCC=compiler_name</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX218"><CODE>--GNATBIND=binder_name</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX219"><CODE>--GNATLINK=linker_name</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX214"><CODE>--LINK=</CODE> (<CODE>gnatlink</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX307"><CODE>-83</CODE> (<CODE>gnathtml</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX182"><CODE>-A</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX203"><CODE>-A</CODE> (<CODE>gnatlink</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX285"><CODE>-a</CODE> (<CODE>gnatls</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX239"><CODE>-A</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX220"><CODE>-a</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX235"><CODE>-aI</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX236"><CODE>-aL</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX237"><CODE>-aO</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX79"><CODE>-B</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX78"><CODE>-b</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX172"><CODE>-b</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX212"><CODE>-B</CODE> (<CODE>gnatlink</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX211"><CODE>-b</CODE> (<CODE>gnatlink</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX248"><CODE>-bargs</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX80"><CODE>-c</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX183"><CODE>-C</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX189"><CODE>-c</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX254"><CODE>-c</CODE> (<CODE>gnatchop</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX204"><CODE>-C</CODE> (<CODE>gnatlink</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX221"><CODE>-c</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX247"><CODE>-cargs</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX308"><CODE>-d</CODE> (<CODE>gnathtml</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX286"><CODE>-d</CODE> (<CODE>gnatls</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX184"><CODE>-e</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX180"><CODE>-f</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX309"><CODE>-f</CODE> (<CODE>gnathtml</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX222"><CODE>-f</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX342"><CODE>-fno-inline</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX81"><CODE>-g</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX206"><CODE>-g</CODE> (<CODE>gnatlink</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX136"><CODE>-gnat83</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX139"><CODE>-gnat95</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX111"><CODE>-gnata</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX98"><CODE>-gnatb</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX134"><CODE>-gnatc</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX154"><CODE>-gnatD</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX324"><CODE>-gnatdc</CODE> switch</A>
<LI><A HREF="gnat_ug.html#IDX128"><CODE>-gnatE</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX103"><CODE>-gnate</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX100"><CODE>-gnatf</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX153"><CODE>-gnatG</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX141"><CODE>-gnatg</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX144"><CODE>-gnati</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX146"><CODE>-gnatk</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX96"><CODE>-gnatl</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX99"><CODE>-gnatm</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX31"><CODE>-gnatn</CODE> switch</A>
<LI><A HREF="gnat_ug.html#IDX147"><CODE>-gnatn</CODE> (<CODE>gcc</CODE>)</A>, <A HREF="gnat_ug.html#IDX341"><CODE>-gnatn</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX124"><CODE>-gnato</CODE> (<CODE>gcc</CODE>)</A>, <A HREF="gnat_ug.html#IDX333"><CODE>-gnato</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX120"><CODE>-gnatp</CODE> (<CODE>gcc</CODE>)</A>, <A HREF="gnat_ug.html#IDX332"><CODE>-gnatp</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX102"><CODE>-gnatq</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX109"><CODE>-gnatR</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX140"><CODE>-gnatr</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX132"><CODE>-gnats</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX148"><CODE>-gnatt</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX97"><CODE>-gnatU</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX151"><CODE>-gnatu</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX94"><CODE>-gnatv</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX145"><CODE>-gnatW</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX105"><CODE>-gnatwe</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX107"><CODE>-gnatwl</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX106"><CODE>-gnatws</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX108"><CODE>-gnatwu</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX110"><CODE>-gnatx</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX181"><CODE>-h</CODE> (<CODE>gnatbind</CODE>)</A>, <A HREF="gnat_ug.html#IDX185"><CODE>-h</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX287"><CODE>-h</CODE> (<CODE>gnatls</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX84"><CODE>-I-</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX241"><CODE>-I-</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX82"><CODE>-I</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX311"><CODE>-I</CODE> (<CODE>gnathtml</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX240"><CODE>-I</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX223"><CODE>-i</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX297"><CODE>-i</CODE> (<CODE>gnatmem</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX224"><CODE>-j</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX255"><CODE>-k</CODE> (<CODE>gnatchop</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX226"><CODE>-k</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX186"><CODE>-l</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX310"><CODE>-l</CODE> (<CODE>gnathtml</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX243"><CODE>-L</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX249"><CODE>-largs</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX174"><CODE>-M</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX173"><CODE>-m</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX229"><CODE>-M</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX227"><CODE>-m</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX190"><CODE>-n</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX207"><CODE>-n</CODE> (<CODE>gnatlink</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX230"><CODE>-n</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX245"><CODE>-nostdinc</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX246"><CODE>-nostdlib</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX87"><CODE>-O</CODE> (<CODE>gcc</CODE>)</A>, <A HREF="gnat_ug.html#IDX339"><CODE>-O</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX86"><CODE>-o</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX188"><CODE>-o</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX187"><CODE>-O</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX312"><CODE>-o</CODE> (<CODE>gnathtml</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX210"><CODE>-o</CODE> (<CODE>gnatlink</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX288"><CODE>-o</CODE> (<CODE>gnatls</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX231"><CODE>-o</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX296"><CODE>-o</CODE> (<CODE>gnatmem</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX313"><CODE>-p</CODE> (<CODE>gnathtml</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX256"><CODE>-q</CODE> (<CODE>gnatchop</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX232"><CODE>-q</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX294"><CODE>-q</CODE> (<CODE>gnatmem</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX257"><CODE>-r</CODE> (<CODE>gnatchop</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX88"><CODE>-S</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX169"><CODE>-s</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX289"><CODE>-s</CODE> (<CODE>gnatls</CODE>)</A>, <A HREF="gnat_ug.html#IDX291"><CODE>-s</CODE> (<CODE>gnatls</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX178"><CODE>-t</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX290"><CODE>-u</CODE> (<CODE>gnatls</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX209"><CODE>-v -v</CODE> (<CODE>gnatlink</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX90"><CODE>-V</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX89"><CODE>-v</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX171"><CODE>-v</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX259"><CODE>-v</CODE> (<CODE>gnatchop</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX208"><CODE>-v</CODE> (<CODE>gnatlink</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX233"><CODE>-v</CODE> (<CODE>gnatmake</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX260"><CODE>-w</CODE> (<CODE>gnatchop</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX177"><CODE>-we</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX175"><CODE>-ws</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX91"><CODE>-Wuninitialized</CODE> (<CODE>gcc</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX170"><CODE>-x</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX194"><CODE>-z</CODE> (<CODE>gnatbind</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX234"><CODE>-z</CODE> (<CODE>gnatmake</CODE>)</A>
</DIR>
<H2>_</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX165">__gnat_finalize</A>
<LI><A HREF="gnat_ug.html#IDX164">__gnat_initialize</A>
<LI><A HREF="gnat_ug.html#IDX306">_main</A>
</DIR>
<H2>a</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX117">Access before elaboration</A>
<LI><A HREF="gnat_ug.html#IDX277">Access-to-subprogram</A>
<LI><A HREF="gnat_ug.html#IDX137">ACVC, Ada 83 tests</A>
<LI><A HREF="gnat_ug.html#IDX198">Ada</A>, <A HREF="gnat_ug.html#IDX325">Ada</A>
<LI><A HREF="gnat_ug.html#IDX135">Ada 83 compatibility</A>
<LI><A HREF="gnat_ug.html#IDX1">Ada 95 Language Reference Manual</A>
<LI><A HREF="gnat_ug.html#IDX317">Ada expressions</A>
<LI><A HREF="gnat_ug.html#IDX16">Ada.Characters.Latin_1</A>
<LI><A HREF="gnat_ug.html#IDX161">Ada.Command_Line</A>
<LI><A HREF="gnat_ug.html#IDX163">Ada.Command_Line.Set_Exit_Status</A>
<LI><A HREF="gnat_ug.html#IDX155">ADA_INCLUDE_PATH</A>
<LI><A HREF="gnat_ug.html#IDX197">ADA_OBJECTS_PATH</A>
<LI><A HREF="gnat_ug.html#IDX192">adafinal</A>
<LI><A HREF="gnat_ug.html#IDX191">adainit</A>
<LI><A HREF="gnat_ug.html#IDX326">Annex A</A>
<LI><A HREF="gnat_ug.html#IDX328">Annex B</A>
<LI><A HREF="gnat_ug.html#IDX159">argc</A>
<LI><A HREF="gnat_ug.html#IDX160">argv</A>
<LI><A HREF="gnat_ug.html#IDX298">ASIS</A>
<LI><A HREF="gnat_ug.html#IDX299">ASIS-for-GNAT</A>
<LI><A HREF="gnat_ug.html#IDX112">Assert</A>
<LI><A HREF="gnat_ug.html#IDX114">Assertions</A>
</DIR>
<H2>b</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX48">Binder output file</A>
<LI><A HREF="gnat_ug.html#IDX193">Binder, multiple input files</A>
<LI><A HREF="gnat_ug.html#IDX168">Body_Version</A>
<LI><A HREF="gnat_ug.html#IDX320">breakpoints and tasks</A>
</DIR>
<H2>c</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX60">C</A>
<LI><A HREF="gnat_ug.html#IDX63">C++</A>
<LI><A HREF="gnat_ug.html#IDX50">Calling Conventions</A>
<LI><A HREF="gnat_ug.html#IDX130">Check, elaboration</A>
<LI><A HREF="gnat_ug.html#IDX126">Check, overflow</A>
<LI><A HREF="gnat_ug.html#IDX119">Checks, access before elaboration</A>
<LI><A HREF="gnat_ug.html#IDX118">Checks, division by zero</A>
<LI><A HREF="gnat_ug.html#IDX122">Checks, suppressing</A>
<LI><A HREF="gnat_ug.html#IDX57">COBOL</A>
<LI><A HREF="gnat_ug.html#IDX20">code page 437</A>
<LI><A HREF="gnat_ug.html#IDX21">code page 850</A>
<LI><A HREF="gnat_ug.html#IDX92">Combining GNAT switches</A>
<LI><A HREF="gnat_ug.html#IDX5">Compilation model</A>
<LI><A HREF="gnat_ug.html#IDX261">Configuration pragmas</A>
<LI><A HREF="gnat_ug.html#IDX53">Convention, Ada</A>
<LI><A HREF="gnat_ug.html#IDX55">Convention, Asm</A>
<LI><A HREF="gnat_ug.html#IDX56">Convention, Assembler</A>
<LI><A HREF="gnat_ug.html#IDX62">Convention, C</A>
<LI><A HREF="gnat_ug.html#IDX65">Convention, C++</A>
<LI><A HREF="gnat_ug.html#IDX59">Convention, COBOL</A>
<LI><A HREF="gnat_ug.html#IDX68">Convention, Fortran</A>
<LI><A HREF="gnat_ug.html#IDX70">Convention, Stdcall</A>
<LI><A HREF="gnat_ug.html#IDX72">Convention, Stubbed</A>
<LI><A HREF="gnat_ug.html#IDX2">Conventions</A>
<LI><A HREF="gnat_ug.html#IDX9">CR</A>
</DIR>
<H2>d</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX113">Debug</A>
<LI><A HREF="gnat_ug.html#IDX315">debugger</A>
<LI><A HREF="gnat_ug.html#IDX314">debugging</A>
<LI><A HREF="gnat_ug.html#IDX205">Debugging information, including</A>
<LI><A HREF="gnat_ug.html#IDX152">Debugging options</A>
<LI><A HREF="gnat_ug.html#IDX228">Dependencies, producing list</A>
<LI><A HREF="gnat_ug.html#IDX216">Dependency rules</A>
<LI><A HREF="gnat_ug.html#IDX116">Division by zero</A>
</DIR>
<H2>e</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX273">Elaborate</A>
<LI><A HREF="gnat_ug.html#IDX275">Elaborate_All</A>
<LI><A HREF="gnat_ug.html#IDX271">Elaborate_Body</A>
<LI><A HREF="gnat_ug.html#IDX129">Elaboration checks</A>, <A HREF="gnat_ug.html#IDX266">Elaboration checks</A>
<LI><A HREF="gnat_ug.html#IDX265">Elaboration control</A>, <A HREF="gnat_ug.html#IDX278">Elaboration control</A>
<LI><A HREF="gnat_ug.html#IDX73">Elaboration order control</A>
<LI><A HREF="gnat_ug.html#IDX304">Eliminate</A>
<LI><A HREF="gnat_ug.html#IDX12">End of source file</A>
<LI><A HREF="gnat_ug.html#IDX101">Error messages, suppressing</A>
<LI><A HREF="gnat_ug.html#IDX24">EUC Coding</A>
<LI><A HREF="gnat_ug.html#IDX318">exceptions</A>
<LI><A HREF="gnat_ug.html#IDX305">Export</A>
</DIR>
<H2>f</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX11">FF</A>
<LI><A HREF="gnat_ug.html#IDX25">File names</A>
<LI><A HREF="gnat_ug.html#IDX49">Foreign Languages</A>
<LI><A HREF="gnat_ug.html#IDX66">Fortran</A>
</DIR>
<H2>g</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX316">GDB</A>
<LI><A HREF="gnat_ug.html#IDX138">Generic formal parameters</A>
<LI><A HREF="gnat_ug.html#IDX29">Generics</A>, <A HREF="gnat_ug.html#IDX322">Generics</A>
<LI><A HREF="gnat_ug.html#IDX201">GNAT</A>, <A HREF="gnat_ug.html#IDX330">GNAT</A>
<LI><A HREF="gnat_ug.html#IDX323">GNAT Abnormal Termination</A>
<LI><A HREF="gnat_ug.html#IDX4">GNAT compilation model</A>
<LI><A HREF="gnat_ug.html#IDX74">GNAT library</A>
<LI><A HREF="gnat_ug.html#IDX27"><TT>`gnat.adc'</TT></A>, <A HREF="gnat_ug.html#IDX263"><TT>`gnat.adc'</TT></A>
<LI><A HREF="gnat_ug.html#IDX77">gnat1</A>
<LI><A HREF="gnat_ug.html#IDX196">gnat_argc</A>
<LI><A HREF="gnat_ug.html#IDX195">gnat_argv</A>
<LI><A HREF="gnat_ug.html#IDX162">gnat_exit_status</A>
<LI><A HREF="gnat_ug.html#IDX157">gnatbind</A>
<LI><A HREF="gnat_ug.html#IDX253">gnatchop</A>
<LI><A HREF="gnat_ug.html#IDX303">gnatelim</A>
<LI><A HREF="gnat_ug.html#IDX280">gnatfind</A>
<LI><A HREF="gnat_ug.html#IDX281">gnatkr</A>
<LI><A HREF="gnat_ug.html#IDX202">gnatlink</A>
<LI><A HREF="gnat_ug.html#IDX283">gnatls</A>
<LI><A HREF="gnat_ug.html#IDX215">gnatmake</A>
<LI><A HREF="gnat_ug.html#IDX293">gnatmem</A>
<LI><A HREF="gnat_ug.html#IDX282">gnatprep</A>
<LI><A HREF="gnat_ug.html#IDX302">gnatstub</A>
<LI><A HREF="gnat_ug.html#IDX34">Gnatvsn</A>
<LI><A HREF="gnat_ug.html#IDX279">gnatxref</A>
<LI><A HREF="gnat_ug.html#IDX252">gnu make</A>
</DIR>
<H2>h</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX8">HT</A>
</DIR>
<H2>i</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX30">Inline</A>
<LI><A HREF="gnat_ug.html#IDX75">Inlining</A>
<LI><A HREF="gnat_ug.html#IDX200">Interfaces</A>, <A HREF="gnat_ug.html#IDX327">Interfaces</A>
<LI><A HREF="gnat_ug.html#IDX51">Interfacing to Ada</A>
<LI><A HREF="gnat_ug.html#IDX54">Interfacing to Assembler</A>
<LI><A HREF="gnat_ug.html#IDX61">Interfacing to C</A>
<LI><A HREF="gnat_ug.html#IDX64">Interfacing to C++</A>
<LI><A HREF="gnat_ug.html#IDX58">Interfacing to COBOL</A>
<LI><A HREF="gnat_ug.html#IDX67">Interfacing to Fortran</A>
<LI><A HREF="gnat_ug.html#IDX150">Internal trees, writing to file</A>
</DIR>
<H2>l</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX6">Latin-1</A>, <A HREF="gnat_ug.html#IDX15">Latin-1</A>
<LI><A HREF="gnat_ug.html#IDX17">Latin-2</A>
<LI><A HREF="gnat_ug.html#IDX18">Latin-3</A>
<LI><A HREF="gnat_ug.html#IDX19">Latin-4</A>
<LI><A HREF="gnat_ug.html#IDX10">LF</A>
<LI><A HREF="gnat_ug.html#IDX292">library</A>
<LI><A HREF="gnat_ug.html#IDX284">library browser</A>
<LI><A HREF="gnat_ug.html#IDX244">Linker libraries</A>
<LI><A HREF="gnat_ug.html#IDX46">Linker_Option</A>
</DIR>
<H2>m</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX127">Machine_Overflows</A>
<LI><A HREF="gnat_ug.html#IDX251">makefile</A>
<LI><A HREF="gnat_ug.html#IDX47">Mixed Language Programming</A>
<LI><A HREF="gnat_ug.html#IDX133">Multiple units, syntax checking</A>
</DIR>
<H2>n</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX295"><CODE>n</CODE> (<CODE>gnatmem</CODE>)</A>
<LI><A HREF="gnat_ug.html#IDX76">No code generated</A>
</DIR>
<H2>o</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX264">Order of elaboration</A>
<LI><A HREF="gnat_ug.html#IDX52">Other Ada compilers</A>
<LI><A HREF="gnat_ug.html#IDX125">Overflow checks</A>, <A HREF="gnat_ug.html#IDX334">Overflow checks</A>
</DIR>
<H2>p</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX225">Parallel make</A>
<LI><A HREF="gnat_ug.html#IDX331">performance</A>
<LI><A HREF="gnat_ug.html#IDX43">pragma Elaborate</A>, <A HREF="gnat_ug.html#IDX274">pragma Elaborate</A>
<LI><A HREF="gnat_ug.html#IDX44">pragma Elaborate_All</A>, <A HREF="gnat_ug.html#IDX276">pragma Elaborate_All</A>
<LI><A HREF="gnat_ug.html#IDX37">pragma Elaborate_Body</A>, <A HREF="gnat_ug.html#IDX272">pragma Elaborate_Body</A>
<LI><A HREF="gnat_ug.html#IDX340">pragma Inline</A>
<LI><A HREF="gnat_ug.html#IDX39">pragma Preelaborate</A>, <A HREF="gnat_ug.html#IDX270">pragma Preelaborate</A>
<LI><A HREF="gnat_ug.html#IDX38">pragma Pure</A>, <A HREF="gnat_ug.html#IDX267">pragma Pure</A>
<LI><A HREF="gnat_ug.html#IDX40">pragma Remote_Call_Interface</A>
<LI><A HREF="gnat_ug.html#IDX41">pragma Remote_Types</A>
<LI><A HREF="gnat_ug.html#IDX42">pragma Shared_Passive</A>
<LI><A HREF="gnat_ug.html#IDX337">pragma Suppress</A>
<LI><A HREF="gnat_ug.html#IDX338">pragma Unsuppress</A>
<LI><A HREF="gnat_ug.html#IDX262">Pragmas, configuration</A>
<LI><A HREF="gnat_ug.html#IDX269">Preelaborate</A>
<LI><A HREF="gnat_ug.html#IDX35">Priority</A>
<LI><A HREF="gnat_ug.html#IDX268">Pure</A>
</DIR>
<H2>r</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX250">Recompilation, by <CODE>gnatmake</CODE></A>
<LI><A HREF="gnat_ug.html#IDX83">RTL</A>, <A HREF="gnat_ug.html#IDX85">RTL</A>
</DIR>
<H2>s</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX238">Search paths, for <CODE>gnatmake</CODE></A>
<LI><A HREF="gnat_ug.html#IDX23">Shift JIS Coding</A>
<LI><A HREF="gnat_ug.html#IDX13">Source file, end</A>
<LI><A HREF="gnat_ug.html#IDX242">Source files, suppressing search</A>
<LI><A HREF="gnat_ug.html#IDX158">Source files, use by binder</A>
<LI><A HREF="gnat_ug.html#IDX26">Source_File_Name pragma</A>
<LI><A HREF="gnat_ug.html#IDX258">Source_Reference</A>
<LI><A HREF="gnat_ug.html#IDX32">Standard</A>, <A HREF="gnat_ug.html#IDX33">Standard</A>, <A HREF="gnat_ug.html#IDX143">Standard</A>
<LI><A HREF="gnat_ug.html#IDX69">Stdcall</A>
<LI><A HREF="gnat_ug.html#IDX93">stderr</A>
<LI><A HREF="gnat_ug.html#IDX95">stdout</A>
<LI><A HREF="gnat_ug.html#IDX45">Stringt</A>
<LI><A HREF="gnat_ug.html#IDX71">Stubbed</A>
<LI><A HREF="gnat_ug.html#IDX142">Style</A>
<LI><A HREF="gnat_ug.html#IDX115">Style checking</A>
<LI><A HREF="gnat_ug.html#IDX14">SUB</A>
<LI><A HREF="gnat_ug.html#IDX28">Subunits</A>
<LI><A HREF="gnat_ug.html#IDX123">Suppress</A>, <A HREF="gnat_ug.html#IDX335">Suppress</A>
<LI><A HREF="gnat_ug.html#IDX121">Suppressing checks</A>
<LI><A HREF="gnat_ug.html#IDX199">System</A>, <A HREF="gnat_ug.html#IDX329">System</A>
<LI><A HREF="gnat_ug.html#IDX156">System.IO</A>
<LI><A HREF="gnat_ug.html#IDX166">System.Task_Specific_Data</A>
</DIR>
<H2>t</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX321">task switching</A>
<LI><A HREF="gnat_ug.html#IDX319">tasks</A>
<LI><A HREF="gnat_ug.html#IDX179">Time stamp errors, in binder</A>
<LI><A HREF="gnat_ug.html#IDX300">tree file</A>
<LI><A HREF="gnat_ug.html#IDX301">tree output file</A>
<LI><A HREF="gnat_ug.html#IDX3">Typographical conventions</A>
</DIR>
<H2>u</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX36">Uname</A>
<LI><A HREF="gnat_ug.html#IDX131">Unsuppress</A>, <A HREF="gnat_ug.html#IDX336">Unsuppress</A>
<LI><A HREF="gnat_ug.html#IDX22">Upper-Half Coding</A>
</DIR>
<H2>v</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX167">Version</A>
<LI><A HREF="gnat_ug.html#IDX7">VT</A>
</DIR>
<H2>w</H2>
<DIR>
<LI><A HREF="gnat_ug.html#IDX104">Warning messages</A>
<LI><A HREF="gnat_ug.html#IDX176">Warnings</A>
<LI><A HREF="gnat_ug.html#IDX149">Writing internal trees</A>
</DIR>

</P>

<P><HR><P>
This document was generated on 2 July 1999 using the
<A HREF="http://wwwcn.cern.ch/dci/texi2html/">texi2html</A>
translator version 1.51.</P>
</BODY>
</HTML>